home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / Ascii-Ansi / vec3.231.lha / vec3231 / source / vec.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-08  |  9.8 KB  |  362 lines

  1. /*
  2.  * VEC.H (VEC)
  3.  *
  4.  * Copyright (c) 1993 Ville Saari
  5.  * All rights reserved
  6.  *
  7.  * Created: 07-Apr-93
  8.  * Updated: 06-Dec-93
  9.  */
  10.  
  11. #include <stdlib.h>
  12. #include <string.h>
  13. #include <ctype.h>
  14.  
  15. #define UENAME "VEC"
  16. #define UDNAME "VDC"
  17. #define ENAME "vec"
  18. #define DNAME "vdc"
  19.  
  20. #ifndef MACH_HDR
  21.     #define MACH_HDR "gener.h"
  22. #endif
  23.  
  24. #include "version.h"
  25. #include MACH_HDR
  26.  
  27. #ifndef SYSTEM
  28.     #define SYSTEM    "g"
  29. #endif
  30.  
  31. #ifndef COPYRSIGN
  32.     #define COPYRSIGN "(c)"
  33. #endif
  34.  
  35. #ifndef BOLDON
  36.     #define BOLDON    ""
  37. #endif
  38.  
  39. #ifndef BOLDOFF
  40.     #define BOLDOFF   ""
  41. #endif
  42.  
  43. #ifndef DEFMETHOD
  44.     #define DEFMETHOD '1'
  45. #endif
  46.  
  47. #ifndef DEFWIDTH
  48.     #define DEFWIDTH  80
  49. #endif
  50.  
  51. #ifndef DEFWIDTHS
  52.     #define DEFWIDTHS "80"
  53. #endif
  54.  
  55. #ifndef OK
  56.     #define OK        0
  57. #endif
  58.  
  59. #ifndef WARN
  60.     #define WARN      1
  61. #endif
  62.  
  63. #ifndef ERROR
  64.     #define ERROR     2
  65. #endif
  66.  
  67. #ifndef FAIL
  68.     #define FAIL      3
  69. #endif
  70.  
  71. #ifndef BUFSIZE
  72.     #define BUFSIZE   32768
  73. #endif
  74.  
  75. #define DEF0 ""
  76. #define DEF1 ""
  77. #define DEF2 ""
  78. #define DEF3 ""
  79. #define DEFa ""
  80. #define DEFi ""
  81. #define DEFu ""
  82. #define DEFx ""
  83.  
  84. #ifndef FINNISH
  85.     #if (DEFMETHOD=='0')
  86.         #undef DEF0
  87.         #define DEF0 " (default)"
  88.     #elif (DEFMETHOD=='1')
  89.         #undef DEF1
  90.         #define DEF1 " (default)"
  91.     #elif (DEFMETHOD=='2')
  92.         #undef DEF2
  93.         #define DEF2 " (default)"
  94.     #elif (DEFMETHOD=='3')
  95.         #undef DEF3
  96.         #define DEF3 " (default)"
  97.     #elif (DEFMETHOD=='a')
  98.         #undef DEFa
  99.         #define DEFa " (default)"
  100.     #elif (DEFMETHOD=='i')
  101.         #undef DEFi
  102.         #define DEFi " (default)"
  103.     #elif (DEFMETHOD=='u')
  104.         #undef DEFu
  105.         #define DEFu " (default)"
  106.     #elif (DEFMETHOD=='x')
  107.         #undef DEFx
  108.         #define DEFx " (default)"
  109.     #endif
  110.  
  111.     #define COPYRIGHT \
  112.         BOLDON UENAME "/" UDNAME BOLDOFF " V" RELEASE "." VERSION SYSTEM"\n" \
  113.         "Copyright " COPYRSIGN " 1991, 1992, 1993 Ville Saari\n" \
  114.         "All rights reserved\n" \
  115.         "\n"
  116.  
  117.     #ifdef SMALLUSAGE
  118.         #define USAGE \
  119.             COPYRIGHT \
  120.             "Usage: " ENAME " [-(0|1|2|3|a|d|e|f|i|N|p|q|r|s|t|u|x)] [-(A|n|o) <file>]\n" \
  121.             "       " "   " " [-(b|w) <number>] [-] [<files>]\n" \
  122.             "  or   " DNAME " [-(d|e|l|L|N|p|q|R|s)] [-(A|o) <file>] [-b <number>]\n" \
  123.             "       " "   " " [-D <directory>] [-] [<files>]\n"
  124.     #else
  125.         #define USAGE \
  126.             COPYRIGHT \
  127.             "Usage: " ENAME " [<options>] [<files>]\n" \
  128.             "  or   " DNAME " [<options>] [<files>]\n" \
  129.             "\n" \
  130.             "Options:\n" \
  131.             "\t-0\t\t"              "encoding method 0 - 7 bit charset, fast" DEF0 "\n" \
  132.             "\t-1\t\t"              "encoding method 1 - 7 bit charset, good" DEF1 "\n" \
  133.             "\t-2\t\t"              "encoding method 2 - 8 bit charset, fast" DEF2 "\n" \
  134.             "\t-3\t\t"              "encoding method 3 - 8 bit charset, good" DEF3 "\n" \
  135.             "\t-a\t\t"              "ASCII escape encoding method" DEFa "\n" \
  136.             "\t-A <file_name>\t"    "append output to named file\n" \
  137.             "\t-b <number>\t"       "set size of I/O buffers\n" \
  138.             "\t-d\t\t"              "decode\n" \
  139.             "\t-D <directory>\t"    "select destination directory for decoded files\n" \
  140.             "\t-e\t\t"                    "encode\n" \
  141.             "\t-f\t\t"              "write full lines in escape modes\n" \
  142.             "\t-i\t\t"              "ISO 8859-1 escape encoding method" DEFi "\n" \
  143.             "\t-l\t\t"              "filter non-decoded lines to stdout\n" \
  144.             "\t-L\t\t"              "same as above without file name lines\n" \
  145.             "\t-n <file_name>\t"    "set new name for encoded file\n" \
  146.             "\t-N\t\t"                    "do not store or set file mode flags\n" \
  147.             "\t-o <file_name>\t"    "output to named file, overwrite existing file\n" \
  148.             "\t-p\t\t"              "output to standard output (default for " ENAME ")\n" \
  149.             "\t-q\t\t"              "quick mode - checksum not calculated\n" \
  150.             "\t-r\t\t"              "use CR-LF pair as newline character\n" \
  151.             "\t-R\t\t"              "reset uuencode table after each decoded file\n" \
  152.             "\t-s\t\t"              "silent mode - file names not displayed\n" \
  153.             "\t-t\t\t"              "write TABs literally in escape modes\n" \
  154.             "\t-u\t\t"              "encoding method compatible with uuencode" DEFu "\n" \
  155.             "\t-w <number>\t"       "set output line length (default " DEFWIDTHS ")\n" \
  156.             "\t-x\t\t"              "hexdump encoding method" DEFx "\n" \
  157.             "\t-\t\t"               "option delimiter - all parameters beyond it are\n" \
  158.             "\t\t\t"                "file names even if they start with `-'\n" \
  159.             "\n" \
  160.             "if no file names given, the standard input will be read\n"
  161.     #endif
  162. #else
  163.     #ifndef A_
  164.         #define A_ "\304"
  165.     #endif
  166.  
  167.     #ifndef O_
  168.         #define O_ "\326"
  169.     #endif
  170.  
  171.     #ifndef a_
  172.         #define a_ "\344"
  173.     #endif
  174.  
  175.     #ifndef o_
  176.         #define o_ "\366"
  177.     #endif
  178.  
  179.     #if (DEFMETHOD=='0')
  180.         #undef DEF0
  181.         #define DEF0 " (oletus)"
  182.     #elif (DEFMETHOD=='1')
  183.         #undef DEF1
  184.         #define DEF1 " (oletus)"
  185.     #elif (DEFMETHOD=='2')
  186.         #undef DEF2
  187.         #define DEF2 " (oletus)"
  188.     #elif (DEFMETHOD=='3')
  189.         #undef DEF3
  190.         #define DEF3 " (oletus)"
  191.     #elif (DEFMETHOD=='a')
  192.         #undef DEFa
  193.         #define DEFa " (oletus)"
  194.     #elif (DEFMETHOD=='i')
  195.         #undef DEFi
  196.         #define DEFi " (oletus)"
  197.     #elif (DEFMETHOD=='u')
  198.         #undef DEFu
  199.         #define DEFu " (oletus)"
  200.     #elif (DEFMETHOD=='x')
  201.         #undef DEFx
  202.         #define DEFx " (oletus)"
  203.     #endif
  204.  
  205.     #define COPYRIGHT \
  206.         BOLDON UENAME "/" UDNAME BOLDOFF " V" RELEASE "." VERSION SYSTEM"\n" \
  207.         "Copyright " COPYRSIGN " 1991, 1992, 1993 Ville Saari\n" \
  208.         "Kaikki oikeudet pid" a_ "tet" a_ a_ "n\n" \
  209.         "\n"
  210.  
  211.     #ifdef SMALLUSAGE
  212.         #define USAGE \
  213.             COPYRIGHT \
  214.             "K" a_ "ytt" o_ ": " ENAME " [-(0|1|2|3|a|d|e|f|i|N|p|q|r|s|t|u|x)] [-(A|n|o) <tiedosto>]\n" \
  215.             "        "           "   " " [-(b|w) <numero>] [-] [<tiedostot>]\n" \
  216.             "  tai   "           DNAME " [-(d|e|l|L|N|p|q|R|s)] [-(A|o) <tiedosto>] [-b <numero>]\n" \
  217.             "        "           "   " " [-D <hakemisto>] [-] [<tiedostot>]\n"
  218.     #else
  219.         #define USAGE \
  220.             "K" a_ "ytt" o_ ": " ENAME " [<optiot>] [<tiedostot>]\n" \
  221.             "  tai   " DNAME " [<optiot>] [<tiedostot>]\n" \
  222.             "\n" \
  223.             "Optiot:\n" \
  224.             "\t-0\t\t"              "koodausmenetelm" a_ " 0 - 7-bittinen, nopea" DEF0 "\n" \
  225.             "\t-1\t\t"              "koodausmenetelm" a_ " 1 - 7-bittinen, tiivis" DEF1 "\n" \
  226.             "\t-2\t\t"              "koodausmenetelm" a_ " 2 - 8-bittinen, nopea" DEF2 "\n" \
  227.             "\t-3\t\t"              "koodausmenetelm" a_ " 3 - 8-bittinen, tiivis" DEF3 "\n" \
  228.             "\t-a\t\t"              "ASCII escape-koodausmenetelm" a_ "" DEFa "\n" \
  229.             "\t-A <tiedosto>\t"     "tulosta annetun tiedoston per" a_ a_ "n\n" \
  230.             "\t-b <numero>\t"       "aseta I/O-puskureiden koko\n" \
  231.             "\t-d\t\t"              "pura\n" \
  232.             "\t-D <hakemisto>\t"    "valitse kohdehakemisto purettaville tiedostoille\n" \
  233.             "\t-e\t\t"                    "koodaa\n" \
  234.             "\t-f\t\t"              "kirjoita t" a_ "ysleveit" a_ " rivej" a_ " escapemenetelmill" a_ "\n" \
  235.             "\t-i\t\t"              "ISO 8859-1 escape-koodausmenetelm" a_ "" DEFi "\n" \
  236.             "\t-l\t\t"              "tulosta purkamattomat rivit stdouttiin\n" \
  237.             "\t-L\t\t"              "kuten edell" _a ", mutta ilman tiedostonimi" _a "\n" \
  238.             "\t-n <tiedosto>\t"     "aseta uusi nimi koodatulle tiedostolle\n" \
  239.             "\t-N\t\t"                    "" a_ "l" a_ " talleta tai aseta tiedostojen suojausbittej" a_ "\n" \
  240.             "\t-o <tiedosto>\t"     "tulosta annettuun tiedostoon, tuhoa vanha, jos oli\n" \
  241.             "\t-p\t\t"              "tulosta standard outputtiin (oletusarvo " ENAME "ille)\n" \
  242.             "\t-q\t\t"              "nopea tila - tarkistussummia ei lasketa\n" \
  243.             "\t-r\t\t"              "k" a_ "yt" a_ " CR-LF paria rivisiirtona\n" \
  244.             "\t-R\t\t"              "nollaa uuencode taulukko joka tiedoston j" a_ "lkeen\n" \
  245.             "\t-s\t\t"              "hiljainen tila - tiedostonimi" a_ " ei n" a_ "ytet" a_ "\n" \
  246.             "\t-t\t\t"              "tulosta TABit sellaisenaan escape-menetelmill" a_ "\n" \
  247.             "\t-u\t\t"              "uuencodeyhteensopiva koodausmenetelm" a_ "" DEFu "\n" \
  248.             "\t-w <numero>\t"       "aseta rivileveys (oletusarvo " DEFWIDTHS ")\n" \
  249.             "\t-x\t\t"              "heksadesimaalinen koodausmenetelm" a_ "" DEFx "\n" \
  250.             "\t-\t\t"               "optiorajoitin - parametrit t" a_ "m" a_ "n j" a_ "lkeen tulkitaan\n" \
  251.             "\t\t\t"                "tiedostonimiksi, vaikka ne alkaisivat '-':lla\n" \
  252.             "\n" \
  253.             "jos tiedostonimi" a_ " ei ole annettu, luetaan standard inputtia\n"
  254.     #endif
  255. #endif
  256.  
  257. #define SPAREBUF 48
  258.  
  259. void vec(const char *);
  260. int vdc(void);
  261. unsigned char *get(unsigned long);
  262. void flushoutput(void);
  263. void put(const unsigned char *, unsigned long);
  264. void errcleanup(const char *);
  265. void emittable(void);
  266. int fillbuffer(int);
  267. char *ltoa(unsigned long);
  268. void printerrh(const char *);
  269.  
  270. #ifndef init
  271. void init(void);
  272. #endif
  273.  
  274. #ifndef cleanup
  275. void cleanup(void);
  276. #endif
  277.  
  278. #ifndef interrupt
  279. int interrupt(void);
  280. #endif
  281.  
  282. #ifndef getstdin
  283. filehandle getstdin(int);
  284. #endif
  285.  
  286. #ifndef getstdout
  287. filehandle getstdout(int);
  288. #endif
  289.  
  290. #ifndef openread
  291. filehandle openread(const char *, int);
  292. #endif
  293.  
  294. #ifndef openwrite
  295. filehandle openwrite(const char *, int);
  296. #endif
  297.  
  298. #ifndef openappend
  299. filehandle openappend(const char *, int);
  300. #endif
  301.  
  302. #ifndef failedopen
  303. int failedopen(filehandle);
  304. #endif
  305.  
  306. #ifndef closefile
  307. void closefile(filehandle);
  308. #endif
  309.  
  310. #ifndef readfile
  311. int readfile(filehandle, unsigned char *, int);
  312. #endif
  313.  
  314. #ifndef writefile
  315. int writefile(filehandle, const unsigned char *, int);
  316. #endif
  317.  
  318. #ifndef basename
  319. char *basename(const char *);
  320. #endif
  321.  
  322. #ifndef setfilemode
  323. void setfilemode(const char *, const unsigned char *);
  324. #endif
  325.  
  326. #ifndef getfilemode
  327. void getfilemode(const char *, unsigned char *, int);
  328. #endif
  329.  
  330. #ifndef modifyname
  331. void modifyname(char *, unsigned int);
  332. #endif
  333.  
  334. #ifndef firstmatch
  335. char *firstmatch(const char *);
  336. #endif
  337.  
  338. #ifndef nextmatch
  339. char *nextmatch(void);
  340. #endif
  341.  
  342. #ifndef printerr
  343. void printerr(const char *);
  344. #endif
  345.  
  346. #ifndef changedir
  347. int changedir(const char *);
  348. #endif
  349.  
  350. extern int quick, cr, silent, nomode, outfileflag, shortlines;
  351. extern int pipe, literaltabs, lines, resetuu;
  352. extern long width;
  353. extern unsigned long bufsize, trueread;
  354. extern unsigned char method;
  355. extern const unsigned short crc16tab[];
  356. extern char *name;
  357. extern unsigned char *inbuf, *outptr, *inptr, *outbufend, *inbufend;
  358. extern filehandle outfile, stdoutfile;
  359.  
  360. #define put1(c) { if(outptr>=outbufend) flushoutput(); *outptr++=(c); }
  361. #define get1() (inptr>=inbufend && !fillbuffer(1)?-1:*inptr++)
  362.