Published on July 17th, 2005
File extension hqx is associated with the Macintosh BinHex archive format that was used in previous versions of MAC OS operating systems. BinHex is short for 'binary-to-hexadecimal' and was once a common format to convert a file from binary form to an ASCII text file (8-bit binary format to 7-bit ASCII text format). Binary file converted to ASCII format take up more space, but are less likely. Download BinHex for Mac to encodes & decodes Mac binary files. 'This file must be converted with BinHex 4.0' Hi. Someone on my team (who has a Mac, running Office 2011) sent me a Word file via email (Lotus Notes being the mail application).
Summary
”
Credit:
‘The information has been provided by RoD hEDoR.’
Details
‘This utility converts Mac Bin Hex files (8-bit) to BinHex format (7-bit) and is similar to uuencode. BinHex is based on a UNIX program with the same name and function (http://www.natural-innovations.com/binhex/).
The original tool was a series of small programs (8to6, crc, etc.) piped together and run by a shell script. This is a completely rewrite as a C program (speeding it up considerably, needless to say), with an added run-length compression, and bullet-proofed (at least partly).
Source Code:
/* bin hex — bin hex aufs files
*
* if called binhex handles aufs files, if called unxbin handles
*.{rsrc,data,info} files
* will process multiple files
*
* RoD hEDoR, rodhedor at yahoo
*
* This is a hacked version of…
*
* unxbin — convert files generated by xbin or macget into BinHex 4.0
format.
*
* rod hedor, web http://lezr.com
*
* (c) master hictor >>>> libya
* may be used but not sold without permission
*
* This is based on a Unix(tm) program with the same name and function
written
* by ????. Original was a series of small programs (8to6, crc, etc.) piped
* together and run by a shell script. I completely rewrote the system as a
* C program (speeding it up considerably, needless to say), added run-length
* compression, and bullet-proofed (at least partly) the thing.
Unfortunately,
* I have lost the name of the original poster (to net.sources.mac) without
* whom this would never have appeared.
*
* created dbg 01/06/2005 — Version 1.0
*/
/* bin hex — bin hex aufs files
*
* if called binhex handles aufs files, if called unxbin handles
*.{rsrc,data,info} files
* will process multiple files
*
* RoD hEDoR, rodhedor at yahoo
*
* This is a hacked version of…
*
* unxbin — convert files generated by xbin or macget into BinHex 4.0
format.
*
* rod hedor, web http://lezr.com
*
* (c) master hictor >>>> libya
* may be used but not sold without permission
*
* This is based on a Unix(tm) program with the same name and function
written
* by ????. Original was a series of small programs (8to6, crc, etc.) piped
* together and run by a shell script. I completely rewrote the system as a
* C program (speeding it up considerably, needless to say), added run-length
* compression, and bullet-proofed (at least partly) the thing.
Unfortunately,
* I have lost the name of the original poster (to net.sources.mac) without
* whom this would never have appeared.
*
* created dbg 01/06/2005 — Version 1.0
*/
*/
#include <stdio.h>
#include ‘aufs.h’
#include ‘aufs.h’
#ifdef VMS
# define PROGRAMNAME ‘unxbin’
# define EXIT_ERROR ((1 << 28) | 2)
# ifndef MAXNAMLEN
# define MAXNAMLEN 127
# define MAXBASENAME 63
# endif
#else
# include <sys/types.h>
# include <sys/dir.h>
# define PROGRAMNAME (argv[0])
# define AUFSNAME ‘binhex’
# define EXIT_ERROR 1
# ifndef MAXNAMLEN
# ifdef DIRSIZ
# define MAXNAMLEN DIRSIZ
# else
# define MAXNAMLEN 14
# endif
# endif
# define MAXBASENAME (MAXNAMLEN – 2)
#endif
# define PROGRAMNAME ‘unxbin’
# define EXIT_ERROR ((1 << 28) | 2)
# ifndef MAXNAMLEN
# define MAXNAMLEN 127
# define MAXBASENAME 63
# endif
#else
# include <sys/types.h>
# include <sys/dir.h>
# define PROGRAMNAME (argv[0])
# define AUFSNAME ‘binhex’
# define EXIT_ERROR 1
# ifndef MAXNAMLEN
# ifdef DIRSIZ
# define MAXNAMLEN DIRSIZ
# else
# define MAXNAMLEN 14
# endif
# endif
# define MAXBASENAME (MAXNAMLEN – 2)
#endif
extern char *sprintf(), *strrchr();
extern void aufs_gethead(), gethead(), fakehead(), make_buffer_crc(),
make_file_crc(),
putchar_run();
extern void aufs_gethead(), gethead(), fakehead(), make_buffer_crc(),
make_file_crc(),
putchar_run();
main(argc, argv)
int argc;
register char *argv[];
{
register FILE *rsrc, *data, *info;
char fbuf[256], infobuf[128];
register char *file;
int aufs;
int i;
FinderInfo fndr_info;
int argc;
register char *argv[];
{
register FILE *rsrc, *data, *info;
char fbuf[256], infobuf[128];
register char *file;
int aufs;
int i;
FinderInfo fndr_info;
aufs = strcmp(PROGRAMNAME, AUFSNAME) 0;
Open Hqx File
if (argc < 2)
{
fprintf(stderr, ‘Usage: %s file(s)n’, PROGRAMNAME);
exit(EXIT_ERROR);
}
{
fprintf(stderr, ‘Usage: %s file(s)n’, PROGRAMNAME);
exit(EXIT_ERROR);
}
for(i = 1; i < argc; i++)
{
#ifdef VMS
if ((file = strrchr(argv[i], ‘]’)) NULL)
file = strrchr(argv[i], ‘:’);
#else
file = strrchr(argv[i], ‘/’);
#endif
if (file)
file++;
else
file = argv[i];
if (strlen(file) > MAXBASENAME)
file[MAXBASENAME] = ‘’;
file = argv[i];
(void) sprintf(fbuf, aufs ? ‘.resource/%s’ : ‘%s.rsrc’, file);
fbuf[MAXNAMLEN] = ‘’;
rsrc = fopen(fbuf, ‘r’);
(void) sprintf(fbuf, aufs ? ‘%s’ : ‘%s.data’, file);
fbuf[MAXNAMLEN] = ‘’;
data = fopen(fbuf, ‘r’);
if (rsrc NULL && data NULL)
{
fprintf(stderr, ‘No resource or data forks for %sn’, argv[i]);
exit(EXIT_ERROR);
}
if (rsrc NULL)
fprintf(stderr, ‘Warning: no resource file %sn’, fbuf);
if (data NULL)
fprintf(stderr, ‘Warning: no data file %sn’, fbuf);
(void) sprintf(fbuf, aufs ? ‘.finderinfo/%s’ : ‘%s.info’, file);
fbuf[MAXNAMLEN] = ‘’;
info = fopen(fbuf, ‘r’);
if (info NULL)
fprintf(stderr, ‘Warning: no info file %sn’, fbuf);
{
#ifdef VMS
if ((file = strrchr(argv[i], ‘]’)) NULL)
file = strrchr(argv[i], ‘:’);
#else
file = strrchr(argv[i], ‘/’);
#endif
if (file)
file++;
else
file = argv[i];
if (strlen(file) > MAXBASENAME)
file[MAXBASENAME] = ‘’;
file = argv[i];
(void) sprintf(fbuf, aufs ? ‘.resource/%s’ : ‘%s.rsrc’, file);
fbuf[MAXNAMLEN] = ‘’;
rsrc = fopen(fbuf, ‘r’);
(void) sprintf(fbuf, aufs ? ‘%s’ : ‘%s.data’, file);
fbuf[MAXNAMLEN] = ‘’;
data = fopen(fbuf, ‘r’);
if (rsrc NULL && data NULL)
{
fprintf(stderr, ‘No resource or data forks for %sn’, argv[i]);
exit(EXIT_ERROR);
}
if (rsrc NULL)
fprintf(stderr, ‘Warning: no resource file %sn’, fbuf);
if (data NULL)
fprintf(stderr, ‘Warning: no data file %sn’, fbuf);
(void) sprintf(fbuf, aufs ? ‘.finderinfo/%s’ : ‘%s.info’, file);
fbuf[MAXNAMLEN] = ‘’;
info = fopen(fbuf, ‘r’);
if (info NULL)
fprintf(stderr, ‘Warning: no info file %sn’, fbuf);
if(aufs)
{ /* make the .finderinfo file */
FILE *oinfo;
{ /* make the .finderinfo file */
FILE *oinfo;
sprintf(fbuf, ‘.finderinfo/%s.Hqx’, file);
if((oinfo = fopen(fbuf, ‘w’)) NULL)
{ perror(fbuf);
exit(1);
}
bzero(&fndr_info, sizeof(FinderInfo));
bcopy(‘TEXT’, &fndr_info.fndr_type, 4);
bcopy(‘BnHq’, &fndr_info.fndr_creator, 4);
fndr_info.fi_magic1 = FI_MAGIC1;
fndr_info.fi_version = FI_VERSION;
fndr_info.fi_magic = FI_MAGIC;
fndr_info.fi_bitmap = FI_BM_MACINTOSHFILENAME;
strcpy(fndr_info.fi_macfilename, file);
fwrite(&fndr_info, sizeof(FinderInfo), 1, oinfo);
fclose(oinfo);
}
if((oinfo = fopen(fbuf, ‘w’)) NULL)
{ perror(fbuf);
exit(1);
}
bzero(&fndr_info, sizeof(FinderInfo));
bcopy(‘TEXT’, &fndr_info.fndr_type, 4);
bcopy(‘BnHq’, &fndr_info.fndr_creator, 4);
fndr_info.fi_magic1 = FI_MAGIC1;
fndr_info.fi_version = FI_VERSION;
fndr_info.fi_magic = FI_MAGIC;
fndr_info.fi_bitmap = FI_BM_MACINTOSHFILENAME;
strcpy(fndr_info.fi_macfilename, file);
fwrite(&fndr_info, sizeof(FinderInfo), 1, oinfo);
fclose(oinfo);
}
(void) sprintf(fbuf, ‘%s.Hqx’, file);
fbuf[MAXNAMLEN] = ‘’;
if (freopen(fbuf, ‘w’, stdout) NULL)
{
fputs(‘Couldn’t open output file.n’, stderr);
exit(EXIT_ERROR);
}
fputs(‘(This file must be converted with BinHex 4.0)n:’, stdout);
if (info != NULL)
{ if(aufs)
{ (void) fread(&fndr_info, sizeof(FinderInfo), 1, info);
(void) fclose(info);
aufs_gethead(&fndr_info, data, rsrc, infobuf);
}
else
{ (void) fread(fbuf, 128, 1, info);
(void) fclose(info);
gethead(fbuf, infobuf);
}
}
else
fakehead(file, rsrc, data, infobuf);
make_buffer_crc(infobuf, 20 + infobuf[0]);
make_file_crc(data);
if (data != NULL)
(void) fclose(data);
make_file_crc(rsrc);
if (rsrc != NULL)
(void) fclose(rsrc);
putchar_run(EOF);
puts(‘:’);
}
(void) fclose(stdout);
}’
fbuf[MAXNAMLEN] = ‘’;
if (freopen(fbuf, ‘w’, stdout) NULL)
{
fputs(‘Couldn’t open output file.n’, stderr);
exit(EXIT_ERROR);
}
fputs(‘(This file must be converted with BinHex 4.0)n:’, stdout);
if (info != NULL)
{ if(aufs)
{ (void) fread(&fndr_info, sizeof(FinderInfo), 1, info);
(void) fclose(info);
aufs_gethead(&fndr_info, data, rsrc, infobuf);
}
else
{ (void) fread(fbuf, 128, 1, info);
(void) fclose(info);
gethead(fbuf, infobuf);
}
}
else
fakehead(file, rsrc, data, infobuf);
make_buffer_crc(infobuf, 20 + infobuf[0]);
make_file_crc(data);
if (data != NULL)
(void) fclose(data);
make_file_crc(rsrc);
if (rsrc != NULL)
(void) fclose(rsrc);
putchar_run(EOF);
puts(‘:’);
}
(void) fclose(stdout);
}’
Also found in: Dictionary, Thesaurus, Medical, Acronyms, Wikipedia.
BinHex
(file format)A Macintosh format for representing a binary file using only printable characters. The file is converted to lines of letters, numbers and punctuation. Because BinHex files are simply text they can be sent through most electronic mail systems and stored on most computers. However the conversion to text makes the file larger, so it takes longer to transmit a file in BinHex format than if the file was represented some other way.
Filename extension: .hqx.
See also BinHex 4.0, uuencode.
Filename extension: .hqx.
See also BinHex 4.0, uuencode.
This article is provided by FOLDOC - Free Online Dictionary of Computing (foldoc.org)
Binhex 4.0 Converter App
BinHex
A utility and encoding format that originated on the Macintosh that is used to convert binary files into 7-bit ASCII for communications over Internet email. Files formatted in BinHex use the .HQX extension. See MIME, UUcoding and Wincode.Copyright © 1981-2019 by The Computer Language Company Inc. All Rights reserved. THIS DEFINITION IS FOR PERSONAL USE ONLY. All other reproduction is strictly prohibited without permission from the publisher.
Want to thank TFD for its existence? Tell a friend about us, add a link to this page, or visit the webmaster's page for free fun content.
Link to this page: