|
|
1.1 root 1: /* C K C D E B . H */
2:
3: /*
4: This file is included by all C-Kermit modules, including the modules
5: that aren't specific to Kermit (like the command parser and the ck?tio and
6: ck?fio modules. It specifies format codes for debug(), tlog(), and similar
7: functions, and includes any necessary definitions to be used by all C-Kermit
8: modules, and also includes some feature selection compile-time switches, and
9: also system- or compiler-dependent definitions, plus #includes and prototypes
10: required by all C-Kermit modules.
11: */
12:
13: /*
14: Author: Frank da Cruz ([email protected], [email protected]),
15: Columbia University Center for Computing Activities.
16: First released January 1985.
17: Copyright (C) 1985, 1992, Trustees of Columbia University in the City of New
18: York. Permission is granted to any individual or institution to use this
19: software as long as it is not sold for profit. This copyright notice must be
20: retained. This software may not be included in commercial products without
21: written permission of Columbia University.
22: */
23:
24: /*
25: Etymology: The name of this file means "C-Kermit Common-C-Language Debugging
26: Header", because originally it contained only the formats (F000-F111) for
27: the debug() and tlog() functions. See how it has grown...
28: */
29:
30: #ifndef CKCDEB_H /* Don't include me more than once. */
31: #define CKCDEB_H
32:
33: #ifdef OS2 /* For OS/2 debugging */
34: #include "ckoker.h"
35: #endif /* OS2 */
36:
37: #include <stdio.h> /* Begin by including this. */
38: #include <ctype.h> /* and this. */
39:
40: #ifdef MAC
41: /*
42: * The MAC doesn't use standard stdio routines.
43: */
44: #undef getchar
45: #undef putchar
46: #endif /* MAC */
47:
48: /* System-type compilation switches */
49:
50: #ifdef FT21 /* Fortune For:Pro 2.1 implies 1.8 */
51: #ifndef FT18
52: #define FT18
53: #endif /* FT18 */
54: #endif /* FT21 */
55:
56: #ifdef AIXPS2 /* AIXPS2 implies AIX370 */
57: #ifndef AIX370
58: #define AIX370
59: #endif /* AIX370 */
60: #endif /* AIXPS2 */
61:
62: #ifdef AIX370 /* AIX PS/2 or 370 implies BSD4 */
63: #ifndef BSD4
64: #define BSD4
65: #endif /* BSD4 */
66: #endif /* AIX370 */
67:
68: #ifdef DGUX540 /* DG UX 5.40 implies Sys V R 4 */
69: #ifndef SVR4
70: #define SVR4
71: #endif /* SVR4 */
72: #endif /* DGUX540 */
73:
74: #ifdef SUNOS41 /* SUNOS41 implies SUNOS4 */
75: #ifndef SUNOS4
76: #define SUNOS4
77: #endif /* SUNOS4 */
78: #endif /* SUNOS41 */
79:
80: #ifdef SUN4S5 /* Sun-4 System V environment */
81: #ifndef SVR3 /* implies System V R3 or later */
82: #define SVR3
83: #endif /* SVR3 */
84: #endif /* SUN4S5 */
85:
86: #ifdef MIPS /* MIPS System V environment */
87: #ifndef SVR3 /* implies System V R3 or later */
88: #define SVR3
89: #endif /* SVR3 */
90: #endif /* MIPS */
91:
92: /*
93: 4.4BSD is a mixture of System V R4, POSIX, and 4.3BSD.
94: */
95: #ifdef BSD44 /* 4.4 BSD */
96: #ifndef SVR4 /* BSD44 implies SVR4 */
97: #define SVR4
98: #endif /* SVR4 */
99: #ifndef NOSETBUF /* NOSETBUF is safe */
100: #define NOSETBUF
101: #endif /* NOSETBUF */
102: #ifndef DIRENT /* Uses <dirent.h> */
103: #define DIRENT
104: #endif /* DIRENT */
105: #endif /* BSD44 */
106:
107: #ifdef SVR3 /* SVR3 implies ATTSV */
108: #ifndef ATTSV
109: #define ATTSV
110: #endif /* ATTSV */
111: #endif /* SVR3 */
112:
113: #ifdef SVR4 /* SVR4 implies ATTSV */
114: #ifndef ATTSV
115: #define ATTSV
116: #endif /* ATTSV */
117: #ifndef SVR3 /* ...as well as SVR3 */
118: #define SVR3
119: #endif /* SVR3 */
120: #endif /* SVR4 */
121:
122: #ifdef UTSV /* UTSV implies ATTSV */
123: #ifndef ATTSV
124: #define ATTSV
125: #endif /* ATTSV */
126: #endif /* UTSV */
127:
128: #ifdef XENIX /* XENIX implies ATTSV */
129: #ifndef ATTSV
130: #define ATTSV
131: #endif /* ATTSV */
132: #endif /* XENIX */
133:
134: #ifdef AUX /* AUX implies ATTSV */
135: #ifndef ATTSV
136: #define ATTSV
137: #endif /* ATTSV */
138: #endif /* AUX */
139:
140: #ifdef ATT7300 /* ATT7300 implies ATTSV */
141: #ifndef ATTSV
142: #define ATTSV
143: #endif /* ATTSV */
144: #endif /* ATT7300 */
145:
146: #ifdef ATT6300 /* ATT6300 implies ATTSV */
147: #ifndef ATTSV
148: #define ATTSV
149: #endif /* ATTSV */
150: #endif /* ATT6300 */
151:
152: #ifdef HPUX /* HPUX implies ATTSV */
153: #ifndef ATTSV
154: #define ATTSV
155: #endif /* ATTSV */
156: #endif /* HPUX */
157:
158: #ifdef ISIII /* ISIII implies ATTSV */
159: #ifndef ATTSV
160: #define ATTSV
161: #endif /* ATTSV */
162: #endif /* ISIII */
163:
164: #ifdef NEXT /* NEXT implies BSD4 */
165: #ifndef BSD4
166: #define BSD4
167: #endif /* BSD4 */
168: #endif /* NEXT */
169:
170: #ifdef SUNOS4 /* SUNOS4 implies BSD4 */
171: #ifndef BSD4
172: #define BSD4
173: #endif /* BSD4 */
174: #endif /* SUNOS4 */
175:
176: #ifdef BSD41 /* BSD41 implies BSD4 */
177: #ifndef BSD4
178: #define BSD4
179: #endif /* BSD4 */
180: #endif /* BSD41 */
181:
182: #ifdef BSD43 /* BSD43 implies BSD4 */
183: #ifndef BSD4
184: #define BSD4
185: #endif /* BSD4 */
186: #endif /* BSD43 */
187:
188: #ifdef BSD4 /* BSD4 implies ANYBSD */
189: #ifndef ANYBSD
190: #define ANYBSD
191: #endif /* ANYBSD */
192: #endif /* BSD4 */
193:
194: #ifdef BSD29 /* BSD29 implies ANYBSD */
195: #ifndef ANYBSD
196: #define ANYBSD
197: #endif /* ANYBSD */
198: #endif /* BSD29 */
199:
200: #ifdef ATTSV /* ATTSV implies UNIX */
201: #ifndef UNIX
202: #define UNIX
203: #endif /* UNIX */
204: #endif /* ATTSV */
205:
206: #ifdef ANYBSD /* ANYBSD implies UNIX */
207: #ifndef UNIX
208: #define UNIX
209: #endif /* UNIX */
210: #endif /* ANYBSD */
211:
212: #ifdef POSIX /* POSIX implies UNIX */
213: #ifndef UNIX
214: #define UNIX
215: #endif /* UNIX */
216: #ifndef DIRENT /* and DIRENT, i.e. <dirent.h> */
217: #ifndef SDIRENT
218: #define DIRENT
219: #endif /* SDIRENT */
220: #endif /* DIRENT */
221: #ifndef NOFILEH /* POSIX doesn't use <sys/file.h> */
222: #define NOFILEH
223: #endif /* NOFILEH */
224: #endif /* POSIX */
225:
226: #ifdef V7
227: #ifndef UNIX
228: #define UNIX
229: #endif /* UNIX */
230: #endif /* V7 */
231:
232: #ifdef COHERENT
233: #ifndef UNIX
234: #define UNIX
235: #endif /* UNIX */
236: #endif /* COHERENT */
237:
238: #ifdef MINIX
239: #ifndef UNIX
240: #define UNIX
241: #endif /* UNIX */
242: #endif /* MINIX */
243: /*
244: The symbol SVORPOSIX is defined for both AT&T and POSIX compilations
245: to make it easier to select items that System V and POSIX have in common,
246: but which BSD, V7, etc, do not have.
247: */
248: #ifdef ATTSV
249: #ifndef SVORPOSIX
250: #define SVORPOSIX
251: #endif /* SVORPOSIX */
252: #endif /* ATTSV */
253:
254: #ifdef POSIX
255: #ifndef SVORPOSIX
256: #define SVORPOSIX
257: #endif /* SVORPOSIX */
258: #endif /* POSIX */
259:
260: /*
261: The symbol SVR4ORPOSIX is defined for both AT&T System V R4 and POSIX
262: compilations to make it easier to select items that System V R4 and POSIX
263: have in common, but which BSD, V7, and System V R3 and earlier, etc, do
264: not have.
265: */
266: #ifdef POSIX
267: #ifndef SVR4ORPOSIX
268: #define SVR4ORPOSIX
269: #endif /* SVR4ORPOSIX */
270: #endif /* POSIX */
271: #ifdef SVR4
272: #ifndef SVR4ORPOSIX
273: #define SVR4ORPOSIX
274: #endif /* SVR4ORPOSIX */
275: #endif /* SVR4 */
276:
277: /*
278: The symbol BSD44ORPOSIX is defined for both 4.4BSD and POSIX compilations
279: to make it easier to select items that 4.4BSD and POSIX have in common,
280: but which System V, BSD, V7, etc, do not have.
281: */
282: #ifdef BSD44
283: #ifndef BSD44ORPOSIX
284: #define BSD44ORPOSIX
285: #endif /* BSD44ORPOSIX */
286: #endif /* BSD44 */
287:
288: #ifdef POSIX
289: #ifndef BSD44ORPOSIX
290: #define BSD44ORPOSIX
291: #endif /* BSD44ORPOSIX */
292: #endif /* POSIX */
293:
294: #ifdef apollo /* May be ANSI-C, check further */
295: #ifdef __STDCPP__
296: #define CK_ANSIC /* Yes, this is real ANSI-C */
297: #define SIG_V
298: #else
299: #define NOANSI /* Nope, not ANSI */
300: #undef __STDC__ /* Even though it say it is! */
301: #define SIG_I
302: #endif /* __STDCPP__ */
303: #endif /* apollo */
304:
305: #ifdef POSIX /* -DPOSIX on cc command line */
306: #ifndef _POSIX_SOURCE /* Implies _POSIX_SOURCE */
307: #define _POSIX_SOURCE
308: #endif /* _POSIX_SOURCE */
309: #endif /* POSIX */
310:
311: /*
312: ANSI C? That is, do we have function prototypes, new-style
313: function declarations, and parameter type checking and coercion?
314: */
315: #ifdef MAC /* MPW C is ANSI */
316: #ifndef NOANSI
317: #ifndef CK_ANSIC
318: #define CK_ANSIC
319: #endif /* CK_ANSIC */
320: #endif /* NOANSI */
321: #endif /* MAC */
322:
323: #ifndef NOANSI
324: #ifdef __STDC__ /* __STDC__ means ANSI C */
325: #ifndef CK_ANSIC
326: #define CK_ANSIC
327: #endif /* CK_ANSIC */
328: #endif /* __STDC__ */
329: #endif /* NOANSI */
330: /*
331: _PROTOTYP() is used for forward declarations of functions so we can have
332: parameter and return value type checking if the compiler offers it.
333: __STDC__ should be defined by the compiler only if function prototypes are
334: allowed. Otherwise, we get old-style forward declarations. Our own private
335: CK_ANSIC symbol tells whether we use ANSI C prototypes. To force use of
336: ANSI prototypes, include -DCK_ANSIC on the cc command line. To disable the
337: use of ANSI prototypes, include -DNOANSI.
338: */
339: #ifdef CK_ANSIC
340: #define _PROTOTYP( func, parms ) func parms
341: #else /* Not ANSI C */
342: #define _PROTOTYP( func, parms ) func()
343: #endif /* CK_ANSIC */
344:
345: /*
346: Altos-specific items: 486, 586, 986 models...
347: */
348: #ifdef A986
349: #define M_VOID
350: #define void int
351: #define CHAR char
352: #define SIG_I
353: #endif /* A986 */
354:
355: /* Void type */
356:
357: #ifndef VOID /* Used throughout all C-Kermit */
358: #ifdef CK_ANSIC /* modules... */
359: #define VOID void
360: #else
361: #define VOID int
362: #endif /* CK_ANSIC */
363: #endif /* VOID */
364:
365: /* Signal type */
366:
367: #ifndef SIG_V /* signal() type, if not def'd yet */
368: #ifndef SIG_I
369: #ifdef OS2
370: #define SIG_V
371: #else
372: #ifdef POSIX
373: #define SIG_V
374: #else
375: #ifdef SVR3 /* System V R3 and later */
376: #define SIG_V
377: #else
378: #ifdef SUNOS4 /* SUNOS V 4.0 and later */
379: #ifndef sun386
380: #define SIG_V
381: #else
382: #define SIG_I
383: #endif /* sun386 */
384: #else
385: #ifdef NEXT /* NeXT */
386: #define SIG_V
387: #else
388: #ifdef AIX370
389: #define SIG_V
390: #define SIGTYP __SIGVOID /* AIX370 */
391: #else
392: #define SIG_I
393: #endif /* AIX370 */
394: #endif /* NEXT */
395: #endif /* SUNOS4 */
396: #endif /* SVR3 */
397: #endif /* POSIX */
398: #endif /* OS2 */
399: #endif /* SIG_I */
400: #endif /* SIG_V */
401:
402: #ifdef SIG_I
403: #define SIGRETURN return(0)
404: #ifndef SIGTYP
405: #define SIGTYP int
406: #endif /* SIGTYP */
407: #endif /* SIG_I */
408:
409: #ifdef SIG_V
410: #define SIGRETURN return
411: #ifndef SIGTYP
412: #define SIGTYP void
413: #endif /* SIGTYP */
414: #endif /* SIG_V */
415:
416: #ifndef SIGTYP
417: #define SIGTYP int
418: #endif /* SIGTYP */
419:
420: #ifndef SIGRETURN
421: #define SIGRETURN return(0)
422: #endif /* SIGRETURN */
423:
424: /* We want all characters to be unsigned if the compiler supports it */
425:
426: #ifdef PROVX1
427: typedef char CHAR;
428: /* typedef long LONG; */
429: typedef int void;
430: #else
431: #ifdef MINIX
432: typedef unsigned char CHAR;
433: #else
434: #ifdef V7
435: typedef char CHAR;
436: #else
437: #ifdef C70
438: typedef char CHAR;
439: /* typedef long LONG; */
440: #else
441: #ifdef BSD29
442: typedef char CHAR;
443: /* typedef long LONG; */
444: #else
445: #ifdef datageneral
446: #define CHAR unsigned char /* 3.22 compiler */
447: #else
448: #ifdef CHAR
449: #undef CHAR
450: #endif /* CHAR */
451: typedef unsigned char CHAR;
452: #endif /* datageneral */
453: #endif /* BSD29 */
454: #endif /* C70 */
455: #endif /* V7 */
456: #endif /* MINIX */
457: #endif /* PROVX1 */
458:
459: /*
460: Debug and transaction logging is included automatically unless you define
461: NODEBUG or NOTLOG. Do this if you want to save the space and overhead.
462: (Note, in version 4F these definitions changed from "{}" to the null string
463: to avoid problems with semicolons after braces, as in: "if (x) tlog(this);
464: else tlog(that);"
465: */
466: #ifndef NODEBUG
467: #ifndef DEBUG
468: #define DEBUG
469: #endif /* DEBUG */
470: #else
471: #ifdef DEBUG
472: #undef DEBUG
473: #endif /* DEBUG */
474: #endif /* NODEBUG */
475:
476: #ifndef NOTLOG
477: #ifndef TLOG
478: #define TLOG
479: #endif /* TLOG */
480: #endif /* NOTLOG */
481:
482: /* debug() macro style selection. */
483:
484: #ifdef MAC
485: #ifndef IFDEBUG
486: #define IFDEBUG
487: #endif /* IFDEBUG */
488: #endif /* MAC */
489:
490: #ifdef OS2
491: #ifndef IFDEBUG
492: #define IFDEBUG
493: #endif /* IFDEBUG */
494: #endif /* OS2 */
495:
496: #ifndef DEBUG
497: /* Compile all the debug() statements away. Saves a lot of space and time. */
498: #define debug(a,b,c,d)
499: #else
500: #ifndef CKCMAI
501: /* Debugging included. Declare debug log flag in main program only. */
502: extern int deblog;
503: #endif /* CKCMAI */
504: /* Now define the debug() macro. */
505: #ifdef IFDEBUG
506: /* Use this form to avoid function calls: */
507: #define debug(a,b,c,d) if (deblog) dodebug(a,b,(char *)c,(long)d)
508: #else
509: /* Use this form to save space: */
510: #define debug(a,b,c,d) dodebug(a,b,(char *)c,(long)d)
511: #endif /* MAC */
512: _PROTOTYP(int dodebug,(int, char *, char *, long));
513: #endif /* DEBUG */
514:
515: #ifndef TLOG
516: #define tlog(a,b,c,d)
517: #else
518: _PROTOTYP(VOID tlog,(int, char *, char *, long));
519: #endif /* TLOG */
520:
521: /* Formats for debug() and tlog() */
522:
523: #define F000 0
524: #define F001 1
525: #define F010 2
526: #define F011 3
527: #define F100 4
528: #define F101 5
529: #define F110 6
530: #define F111 7
531:
532: /* Kermit feature selection */
533:
534: #ifdef MAC /* For Macintosh, no escape */
535: #define NOPUSH /* to operating system */
536: #endif /* MAC */
537:
538: #ifdef UNIX
539: #ifndef NOPARSEN
540: #define PARSENSE /* Automatic parity detection */
541: #endif /* NOPARSEN */
542: #endif /* UNIX */ /* for Unix */
543:
544: #ifdef VMS /* ... and VMS */
545: #ifndef NOPARSEN
546: #define PARSENSE
547: #endif /* NOPARSEN */
548: #endif /* VMS */
549:
550: #ifdef MAC /* and Macintosh */
551: #ifndef NOPARSEN
552: #define PARSENSE
553: #endif /* NOPARSEN */
554: #endif /* MAC */
555:
556: #ifdef VMS /* Use dynamic memory allocation */
557: #ifndef DYNAMIC
558: #define DYNAMIC /* in VMS version. */
559: #endif /* DYNAMIC */
560: #endif /* VMS */
561:
562: #ifndef CK_LBRK /* Can send Long BREAK */
563:
564: #ifdef UNIX /* (everybody but OS-9) */
565: #define CK_LBRK
566: #endif /* UNIX */
567: #ifdef VMS
568: #define CK_LBRK
569: #endif /* VMS */
570: #ifdef datageneral
571: #define CK_LBRK
572: #endif /* datageneral */
573: #ifdef GEMDOS
574: #define CK_LBRK
575: #endif /* GEMDOS */
576: #ifdef OS2
577: #define CK_LBRK
578: #endif /* OS2 */
579: #ifdef AMIGA
580: #define CK_LBRK
581: #endif /* AMIGA */
582:
583: #endif /* CK_LBRK */
584:
585: /* Carrier treatment */
586: /* These are defined here because they are shared by the system dependent */
587: /* and the system independent modules. */
588:
589: #define CAR_OFF 0 /* On: heed carrier always, except during DIAL. */
590: #define CAR_ON 1 /* Off: ignore carrier always. */
591: #define CAR_AUT 2 /* Auto: heed carrier, but only if line is declared */
592: /* to be a modem line, and only during CONNECT. */
593:
594: /* Hangup by modem command supported by default */
595:
596: #ifndef NODIAL
597: #ifndef NOMDMHUP
598: #ifndef MDMHUP
599: #define MDMHUP
600: #endif /* MDMHUP */
601: #endif /* NOMDMHUP */
602: #endif /* NODIAL */
603:
604: /* Types of flow control available */
605:
606: #define CK_XONXOFF /* Everybody can do this, right? */
607:
608: #ifdef AMIGA /* Commodore Amiga */
609: #define CK_RTSCTS /* has RTS/CTS */
610: #endif /* AMIGA */
611:
612: #ifdef SUN4S5 /* SunOS in System V environment */
613: #define CK_RTSCTS
614: #else /* SunOS 4.0/4.1 in BSD environment */
615: #ifdef SUNOS4 /* SunOS 4.0+later supports RTS/CTS */
616: #ifdef SUNOS41 /* Easy in 4.1 and later */
617: #define CK_RTSCTS
618: #else /* Harder in 4.0 */
619: #ifndef __GNUC__ /* (see tthflow() in ckutio.c) */
620: #ifndef GNUC
621: #define CK_RTSCTS /* Only if not using GNU gcc */
622: #endif /* __GNUC__ */
623: #endif /* GNUC */
624: #endif /* SUNOS41 */
625: #endif /* SUNOS4 */
626: #endif /* SUN4S5 */
627:
628: #ifdef BSD44 /* And in 4.4 BSD */
629: #define CK_RTSCTS
630: #endif /* BSD44 */
631:
632: #ifdef TERMIOX /* Sys V R4 <termiox.h> */
633: #define CK_RTSCTS /* has RTS/CTS */
634: #define CK_DTRCD /* and DTR/CD */
635: #endif /* TERMIOX */
636: #ifdef STERMIOX /* Sys V R4 <sys/termiox.h> */
637: #define CK_RTSCTS /* Ditto. */
638: #define CK_DTRCD
639: #endif /* STERMIOX */
640:
641: /*
642: Systems where we can expand tilde at the beginning of file or directory names
643: */
644: #ifdef POSIX
645: #ifndef DTILDE
646: #define DTILDE
647: #endif /* DTILDE */
648: #endif /* POSIX */
649: #ifdef BSD4
650: #ifndef DTILDE
651: #define DTILDE
652: #endif /* DTILDE */
653: #endif /* BSD4 */
654: #ifdef ATTSV
655: #ifndef DTILDE
656: #define DTILDE
657: #endif /* DTILDE */
658: #endif /* ATTSV */
659: #ifdef OSK
660: #ifndef DTILDE
661: #define DTILDE
662: #endif /* DTILDE */
663: #endif /* OSK */
664: #ifdef HPUX /* I don't know why this is */
665: #ifndef DTILDE /* necessary, since -DHPUX */
666: #define DTILDE /* automatically defines ATTSV */
667: #endif /* DTILDE */ /* (see above) ... */
668: #endif /* HPUX */
669:
670: /* Line delimiter for text files */
671:
672: /*
673: If the system uses a single character for text file line delimitation,
674: define NLCHAR to the value of that character. For text files, that
675: character will be converted to CRLF upon output, and CRLF will be converted
676: to that character on input during text-mode (default) packet operations.
677: */
678: #ifdef MAC /* Macintosh */
679: #define NLCHAR 015
680: #else
681: #ifdef OSK /* OS-9/68K */
682: #define NLCHAR 015
683: #else /* All Unix-like systems */
684: #define NLCHAR 012
685: #endif /* OSK */
686: #endif /* MAC */
687:
688: /*
689: At this point, if there's a system that uses ordinary CRLF line
690: delimitation AND the C compiler actually returns both the CR and
691: the LF when doing input from a file, then #undef NLCHAR.
692: */
693: #ifdef OS2 /* OS/2 */
694: #undef NLCHAR
695: #endif /* OS2 */
696:
697: #ifdef GEMDOS /* Atari ST */
698: #undef NLCHAR
699: #endif /* GEMDOS */
700:
701: /*
702: VMS file formats are so complicated we need to do all the conversion
703: work in the CKVFIO module, so we tell the rest of C-Kermit not to fiddle
704: with the bytes.
705: */
706:
707: #ifdef vms
708: #undef NLCHAR
709: #endif /* vms */
710:
711: /* The device name of a job's controlling terminal */
712: /* Special for VMS, same for all Unixes (?), not used by Macintosh */
713:
714: #ifdef vms
715: #define CTTNAM "TT:"
716: #else
717: #ifdef datageneral
718: #define CTTNAM "@output"
719: #else
720: #ifdef OSK
721: extern char myttystr[];
722: #define CTTNAM myttystr
723: #else
724: #ifdef OS2
725: #define CTTNAM "con"
726: #else
727: #ifdef UNIX
728: #define CTTNAM "/dev/tty"
729: #else
730: #ifdef GEMDOS
731: #define CTTNAM "aux:"
732: #else /* Anyone else... */
733: #define CTTNAM "stdout" /* This is a kludge used by Mac */
734: #endif /* GEMDOS */
735: #endif /* UNIX */
736: #endif /* OS2 */
737: #endif /* OSK */
738: #endif /* datageneral */
739: #endif /* vms */
740:
741: #ifdef SUNS4S5
742: #define tolower _tolower
743: #define toupper _toupper
744: #endif /* SUNS4S5 */
745:
746: /* Error number */
747:
748: #ifndef VMS
749: #ifndef OS2
750: /*
751: The following declaration causes problems for VMS and OS/2, in which
752: errno is an "extern volatile int noshare"...
753: */
754: extern int errno; /* Needed by most modules. */
755: #endif /* OS2 */
756: #endif /* VMS */
757:
758: /* File System Defaults */
759:
760: #ifdef VMS
761: #define DBLKSIZ 512
762: #define DLRECL 512
763: #else
764: #define DBLKSIZ 0
765: #define DLRECL 0
766: #endif
767:
768: /* Program return codes for DECUS C and UNIX (VMS uses UNIX codes) */
769:
770: #ifdef decus
771: #define GOOD_EXIT IO_NORMAL
772: #define BAD_EXIT IO_ERROR
773: #else
774: #define GOOD_EXIT 0
775: #define BAD_EXIT 1
776: #endif /* decus */
777:
778: /* Special hack for Fortune, which doesn't have <sys/file.h>... */
779:
780: #ifdef FT18
781: #define FREAD 0x01
782: #define FWRITE 0x10
783: #endif /* FT18 */
784:
785: /* Special hack for OS-9/68k */
786: #ifdef OSK
787: #define SIGALRM 30 /* May always cancel I/O */
788: #define SIGARB 1234 /* Arbitrary for I/O */
789: SIGTYP (*signal())();
790: #endif /* OSK */
791:
792: #ifdef OS2
793: #ifdef putchar /* MSC 5.1 simply uses a macro which causes */
794: #undef putchar /* no problems. */
795: #endif /* putchar */
796: #endif /* OS2 */
797:
798: #ifdef MINIX
799: #ifdef putchar
800: #undef putchar
801: #endif /* putchar */
802: #define putchar(c) {putc(c,stdout);fflush(stdout);}
803: #endif /* MINIX */
804:
805: /* Escape/quote character used by the command parser */
806:
807: #define CMDQ '\\'
808:
809: /* Symbols for RS-232 modem signals */
810:
811: #define KM_FG 1 /* Frame ground */
812: #define KM_TXD 2 /* Transmit */
813: #define KM_RXD 3 /* Receive */
814: #define KM_RTS 4 /* Request to Send */
815: #define KM_CTS 5 /* Clear to Send */
816: #define KM_DSR 6 /* Data Set Ready */
817: #define KM_SG 7 /* Signal ground */
818: #define KM_DCD 8 /* Carrier Detect */
819: #define KM_DTR 20 /* Data Terminal Ready */
820: #define KM_RI 22 /* Ring Indication */
821:
822: /* Bit mask values for modem signals */
823:
824: #define BM_CTS 0001 /* Clear to send (From DCE) */
825: #define BM_DSR 0002 /* Dataset ready (From DCE) */
826: #define BM_DCD 0004 /* Carrier (From DCE) */
827: #define BM_RNG 0010 /* Ring Indicator (From DCE) */
828: #define BM_DTR 0020 /* Data Terminal Ready (From DTE) */
829: #define BM_RTS 0040 /* Request to Send (From DTE) */
830:
831: /* Codes for full duplex flow control */
832:
833: #define FLO_NONE 0 /* None */
834: #define FLO_XONX 1 /* Xon/Xoff (soft) */
835: #define FLO_RTSC 2 /* RTS/CTS (hard) */
836: #define FLO_DTRC 3 /* DTR/CD (hard) */
837: #define FLO_ETXA 4 /* ETX/ACK (soft) */
838: #define FLO_STRG 5 /* String-based (soft) */
839: #define FLO_DIAL 6 /* DIALing kludge */
840: #define FLO_DIAX 7 /* Cancel dialing kludge */
841: #define FLO_DTRT 8 /* DTR/CTS (hard) */
842: #define FLO_KEEP 9 /* Keep, i.e. don't touch or change */
843:
844: /* And finally... */
845:
846: #ifdef COMMENT /* Make sure this is NOT defined! */
847: #undef COMMENT
848: #endif /* COMMENT */
849:
850: /* Structure definitions for Kermit file attributes */
851: /* All strings come as pointer and length combinations */
852: /* Empty string (or for numeric variables, -1) = unused attribute. */
853:
854: struct zstr { /* string format */
855: int len; /* length */
856: char *val; /* value */
857: };
858: struct zattr { /* Kermit File Attribute structure */
859: long lengthk; /* (!) file length in K */
860: struct zstr type; /* (") file type (text or binary) */
861: struct zstr date; /* (#) file creation date yyyymmdd[ hh:mm[:ss]] */
862: struct zstr creator; /* ($) file creator id */
863: struct zstr account; /* (%) file account */
864: struct zstr area; /* (&) area (e.g. directory) for file */
865: struct zstr passwd; /* (') password for area */
866: long blksize; /* (() file blocksize */
867: struct zstr access; /* ()) file access: new, supersede, append, warn */
868: struct zstr encoding; /* (*) encoding (transfer syntax) */
869: struct zstr disp; /* (+) disposition (mail, message, print, etc) */
870: struct zstr lprotect; /* (,) protection (local syntax) */
871: struct zstr gprotect; /* (-) protection (generic syntax) */
872: struct zstr systemid; /* (.) ID for system of origin */
873: struct zstr recfm; /* (/) record format */
874: struct zstr sysparam; /* (0) system-dependent parameter string */
875: long length; /* (1) exact length on system of origin */
876: struct zstr charset; /* (2) transfer syntax character set */
877: struct zstr reply; /* This goes last, used for attribute reply */
878: };
879:
880: /* Kermit file information structure */
881:
882: struct filinfo {
883: int bs; /* Blocksize */
884: int cs; /* Character set */
885: long rl; /* Record length */
886: int org; /* Organization */
887: int fmt; /* Record format */
888: int cc; /* Carriage control */
889: int typ; /* Type (text/binary) */
890: int dsp; /* Disposition */
891: char *os_specific; /* OS-specific attributes */
892: unsigned int lblopts; /* LABELED FILE options bitmask */
893: };
894:
895: /* VMS values for LABELED FILE options bitmask */
896:
897: #ifdef VMS
898: #define LBL_NAM 1 /* Ignore incoming name if set */
899: #define LBL_PTH 2 /* Use complete path if set */
900: #define LBL_ACL 4 /* Preserve ACLs if set */
901: #define LBL_BCK 8 /* Preserve backup date if set */
902: #define LBL_OWN 16 /* Preserve ownership if set */
903: #endif /* VMS */
904:
905: /*
906: Data types. First the header file for data types so we can pick up the
907: types used for pids, uids, and gids. Override this section by putting
908: -DCKTYP_H=xxx on the command line to specify the header file where your
909: system defines these types.
910: */
911: #ifdef OSK /* OS-9 */
912: #include <types.h>
913: #else /* General case, not OS-9 */
914: #ifndef CKTYP_H
915: #ifndef VMS
916: #ifndef MAC
917: #ifndef AMIGA
918: #define CKTYP_H <sys/types.h>
919: #endif /* AMIGA */
920: #endif /* MAC */
921: #endif /* VMS */
922: #endif /* CKTYP_H */
923:
924: #ifdef GEMDOS
925: #undef CKTYP_H
926: #include <types.h>
927: #endif /* GEMDOS */
928:
929: #ifdef CKTYP_H /* Include it. */
930: #ifdef COHERENT /* Except for COHERENT */
931: #include <sys/types.h>
932: #else
933: #ifdef datageneral
934: #include <sys/types.h> /* Compiler didn't like other */
935: #else
936: #include CKTYP_H
937: #endif /* datageneral */
938: #endif /* COHERENT */
939: #endif /* CKTYP_H */
940:
941: #endif /* OSK */ /* End of types.h section */
942:
943: /*
944: Data type for pids. If your system uses a different type, put something
945: like -DPID_T=pid_t on command line, or override here.
946: */
947: #ifndef PID_T
948: #define PID_T int
949: #endif /* PID_T */
950: /*
951: Data types for uids and gids. Same deal as for pids.
952: Wouldn't be nice if there was a preprocessor test to find out if a
953: typedef existed?
954: */
955: #ifdef VMS
956: /* Not used in VMS so who cares */
957: #define UID_T int
958: #define GID_T int
959: #endif /* VMS */
960:
961: #ifdef POSIX
962: /* Or would it be better (or worse?) to use _POSIX_SOURCE here? */
963: #ifndef UID_T
964: #define UID_T uid_t
965: #endif /* UID_T */
966: #ifndef GID_T
967: #define GID_T gid_t
968: #endif /* GID_T */
969: #else /* Not POSIX */
970: #ifdef SVR4
971: /* SVR4 and later have uid_t and gid_t. */
972: /* SVR3 and earlier use int, or unsigned short, or.... */
973: #ifndef UID_T
974: #define UID_T uid_t
975: #endif /* UID_T */
976: #ifndef GID_T
977: #define GID_T gid_t
978: #endif /* GID_T */
979: #else /* Not SVR4 */
980: #ifdef BSD43
981: #ifndef UID_T
982: #define UID_T uid_t
983: #endif /* UID_T */
984: #ifndef GID_T
985: #define GID_T gid_t
986: #endif /* GID_T */
987: #else /* Not BSD43 */
988: /* Default these to int for older UNIX versions */
989: #ifndef UID_T
990: #define UID_T int
991: #endif /* UID_T */
992: #ifndef GID_T
993: #define GID_T int
994: #endif /* GID_T */
995: #endif /* BSD43 */
996: #endif /* SVR4 */
997: #endif /* POSIX */
998:
999: /*
1000: getpwuid() arg type, which is not necessarily the same as UID_T,
1001: e.g. in SCO UNIX SVR3, it's int.
1002: */
1003: #ifndef PWID_T
1004: #define PWID_T UID_T
1005: #endif /* PWID_T */
1006:
1007: #ifdef NEXT /* Argument for wait() */
1008: #include <sys/wait.h>
1009: typedef union wait WAIT_T;
1010: #else
1011: #ifdef POSIX
1012: #include <sys/wait.h>
1013: #define WAIT_T pid_t
1014: #else
1015: typedef int WAIT_T;
1016: #endif /* POSIX */
1017: #endif /* NEXT */
1018:
1019: /* Forward declarations of system-dependent functions callable from all */
1020: /* C-Kermit modules. */
1021:
1022: /* File-related functions from system-dependent file i/o module */
1023:
1024: _PROTOTYP( int zkself, (void) );
1025: _PROTOTYP( int zopeni, (int, char *) );
1026: _PROTOTYP( int zopeno, (int, char *, struct zattr *, struct filinfo *) );
1027: _PROTOTYP( int zclose, (int) );
1028: #ifndef MAC
1029: _PROTOTYP( int zchin, (int, int *) );
1030: #endif /* MAC */
1031: _PROTOTYP( int zsinl, (int, char *, int) );
1032: _PROTOTYP( int zinfill, (void) );
1033: _PROTOTYP( int zsout, (int, char*) );
1034: _PROTOTYP( int zsoutl, (int, char*) );
1035: _PROTOTYP( int zsoutx, (int, char*, int) );
1036: _PROTOTYP( int zchout, (int, char) );
1037: _PROTOTYP( int zoutdump, (void) );
1038: _PROTOTYP( int zsyscmd, (char *) );
1039: _PROTOTYP( int zshcmd, (char *) );
1040: _PROTOTYP( int chkfn, (int) );
1041: _PROTOTYP( long zchki, (char *) );
1042: _PROTOTYP( int iswild, (char *) );
1043: _PROTOTYP( int zchko, (char *) );
1044: _PROTOTYP( int zdelet, (char *) );
1045: _PROTOTYP( VOID zrtol, (char *,char *) );
1046: _PROTOTYP( VOID zltor, (char *,char *) );
1047: _PROTOTYP( VOID zstrip, (char *,char **) );
1048: _PROTOTYP( int zchdir, (char *) );
1049: _PROTOTYP( char * zhome, (void) );
1050: _PROTOTYP( char * zgtdir, (void) );
1051: _PROTOTYP( int zxcmd, (int, char *) );
1052: #ifndef MAC
1053: _PROTOTYP( int zclosf, (int) );
1054: #endif /* MAC */
1055: _PROTOTYP( int zxpand, (char *) );
1056: _PROTOTYP( int znext, (char *) );
1057: _PROTOTYP( int zchkspa, (char *, long) );
1058: _PROTOTYP( VOID znewn, (char *, char **) );
1059: _PROTOTYP( int zrename, (char *, char *) );
1060: _PROTOTYP( int zsattr, (struct zattr *) );
1061: _PROTOTYP( int zfree, (char *) );
1062: _PROTOTYP( char * zfcdat, (char *) );
1063: _PROTOTYP( int zstime, (char *, struct zattr *, int) );
1064: _PROTOTYP( int zmail, (char *, char *) );
1065: _PROTOTYP( int zprint, (char *, char *) );
1066: _PROTOTYP( char * tilde_expand, (char *) );
1067:
1068: /* Functions from system-dependent terminal i/o module */
1069:
1070: _PROTOTYP( int ttopen, (char *, int *, int, int) ); /* tty functions */
1071: #ifndef MAC
1072: _PROTOTYP( int ttclos, (int) );
1073: #endif /* MAC */
1074: _PROTOTYP( int tthang, (void) );
1075: _PROTOTYP( int ttres, (void) );
1076: _PROTOTYP( int ttpkt, (long, int, int) );
1077: #ifndef MAC
1078: _PROTOTYP( int ttvt, (long, int) );
1079: #endif /* MAC */
1080: _PROTOTYP( int ttsspd, (int) );
1081: _PROTOTYP( long ttgspd, (void) );
1082: _PROTOTYP( int ttflui, (void) );
1083: _PROTOTYP( int ttfluo, (void) );
1084: _PROTOTYP( int ttchk, (void) );
1085: _PROTOTYP( int ttxin, (int, CHAR *) );
1086: _PROTOTYP( int ttol, (CHAR *, int) );
1087: _PROTOTYP( int ttoc, (char) );
1088: _PROTOTYP( int ttinc, (int) );
1089: _PROTOTYP( int ttscarr, (int) );
1090: _PROTOTYP( int ttgmdm, (void) );
1091: _PROTOTYP( int ttsndb, (void) );
1092: _PROTOTYP( int ttsndlb, (void) );
1093: #ifdef PARSENSE
1094: #ifdef UNIX
1095: _PROTOTYP( int ttinl, (CHAR *, int, int, CHAR, CHAR, int) );
1096: #else
1097: #ifdef VMS
1098: _PROTOTYP( int ttinl, (CHAR *, int, int, CHAR, CHAR, int) );
1099: #else
1100: _PROTOTYP( int ttinl, (CHAR *, int, int, CHAR, CHAR) );
1101: #endif /* VMS */
1102: #endif /* UNIX */
1103: #else
1104: _PROTOTYP( int ttinl, (CHAR *, int, int, CHAR) );
1105: #endif /* PARSENSE */
1106:
1107: /* Console functions */
1108:
1109: _PROTOTYP( int congm, (void) );
1110: #ifdef COMMENT
1111: _PROTOTYP( VOID conint, (SIGTYP (*)(int, int), SIGTYP (*)(int, int)) );
1112: #else
1113: _PROTOTYP( VOID conint, (SIGTYP (*)(int), SIGTYP (*)(int)) );
1114: #endif
1115: _PROTOTYP( VOID connoi, (void) );
1116: _PROTOTYP( int concb, (char) );
1117: _PROTOTYP( int conbin, (char) );
1118: _PROTOTYP( int conres, (void) );
1119: _PROTOTYP( int conoc, (char) );
1120: _PROTOTYP( int conxo, (int, char *) );
1121: _PROTOTYP( int conol, (char *) );
1122: _PROTOTYP( int conola, (char *[]) );
1123: _PROTOTYP( int conoll, (char *) );
1124: _PROTOTYP( int conchk, (void) );
1125: _PROTOTYP( int coninc, (int) );
1126: _PROTOTYP( int psuspend, (int) );
1127: _PROTOTYP( int priv_ini, (void) );
1128: _PROTOTYP( int priv_on, (void) );
1129: _PROTOTYP( int priv_off, (void) );
1130: _PROTOTYP( int priv_can, (void) );
1131: _PROTOTYP( int priv_chk, (void) );
1132: _PROTOTYP( int priv_opn, (char *, int) );
1133:
1134: _PROTOTYP( int sysinit, (void) ); /* Misc Kermit functions */
1135: _PROTOTYP( int syscleanup, (void) );
1136: _PROTOTYP( int msleep, (int) );
1137: _PROTOTYP( VOID rtimer, (void) );
1138: _PROTOTYP( int gtimer, (void) );
1139: _PROTOTYP( VOID ttimoff, (void) );
1140: _PROTOTYP( VOID ztime, (char **) );
1141: _PROTOTYP( int parchk, (CHAR *, CHAR, int) );
1142: _PROTOTYP( VOID doexit, (int, int) );
1143: _PROTOTYP( int askmore, (void) );
1144: _PROTOTYP( VOID fatal, (char *) );
1145:
1146: /* Key mapping support */
1147:
1148: #ifdef NOICP
1149: #ifndef NOSETKEY
1150: #define NOSETKEY
1151: #endif /* NOSETKEY */
1152: #endif /* NOICP */
1153:
1154: _PROTOTYP( int congks, (int) );
1155: #ifndef NOSETKEY
1156: #ifdef OS2
1157: #define KMSIZE 768
1158: typedef int KEY;
1159: typedef CHAR *MACRO;
1160: extern int wideresult;
1161: _PROTOTYP( VOID keymapinit, (void) );
1162: #else /* Not OS2 */
1163: /*
1164: Catch-all for systems where we don't know how to read keyboard scan
1165: codes > 255. Note: CHAR (i.e. unsigned char) is very important here.
1166: */
1167: #define KMSIZE 256
1168: typedef CHAR KEY;
1169: typedef CHAR * MACRO;
1170: #define congks coninc
1171: #endif /* OS2 */
1172: #endif /* NOSETKEY */
1173:
1174: /*
1175: Function prototypes for system and library functions.
1176: */
1177: #ifdef _POSIX_SOURCE
1178: #ifndef VMS
1179: #ifndef MAC
1180: #define CK_ANSILIBS
1181: #endif /* MAC */
1182: #endif /* VMS */
1183: #endif /* _POSIX_SOURCE */
1184:
1185: #ifdef NEXT
1186: #define CK_ANSILIBS
1187: #endif /* NEXT */
1188:
1189: #ifdef SVR4
1190: #define CK_ANSILIBS
1191: #endif /* SVR4 */
1192:
1193: #ifdef OS2
1194: #define KANJI
1195: #define CK_ANSILIBS
1196: #define MYCURSES
1197: #define CK_RTSCTS
1198: #ifdef __IBMC__
1199: #define S_IFMT 0xF000
1200: #define timezone _timezone
1201: #endif /* __IBMC__ */
1202: #include <io.h>
1203: #ifdef __EMX__
1204: #ifndef __32BIT__
1205: #define __32BIT__
1206: #endif /* __32BIT__ */
1207: #include <sys/timeb.h>
1208: #else
1209: #include <direct.h>
1210: #define SIGALRM SIGUSR1
1211: _PROTOTYP( unsigned alarm, (unsigned) );
1212: _PROTOTYP( unsigned sleep, (unsigned) );
1213: #endif /* __EMX__ */
1214: _PROTOTYP( long zdskspace, (int) );
1215: _PROTOTYP( int zchdsk, (int) );
1216: _PROTOTYP( int conincraw, (int) );
1217: _PROTOTYP( int ttiscom, (int f) );
1218: _PROTOTYP( int IsFileNameValid, (char *) );
1219: _PROTOTYP( void ChangeNameForFAT, (char *) );
1220: _PROTOTYP( char *GetLoadPath, (void) );
1221: #endif /* OS2 */
1222:
1223: #ifdef MYCURSES /* MYCURSES implies CK_CURSES */
1224: #ifndef CK_CURSES
1225: #define CK_CURSES
1226: #endif /* CK_CURSES */
1227: #endif /* MYCURSES */
1228:
1229: #ifdef CK_ANSILIBS
1230: /*
1231: String library functions.
1232: For ANSI C, get prototypes from <string.h>.
1233: Otherwise, skip the prototypes.
1234: */
1235: #include <string.h>
1236:
1237: /*
1238: Prototypes for other commonly used library functions, such as
1239: malloc, free, getenv, atol, atoi, and exit. Otherwise, no prototypes.
1240: */
1241: #include <stdlib.h>
1242: #ifdef DIAB /* DIAB DS90 */
1243: /* #include <commonC.h> */
1244: #include <sys/wait.h>
1245: #ifdef COMMENT
1246: extern void exit(int status);
1247: extern void _exit(int status);
1248: extern int uname(struct utsname *name);
1249: #endif /* COMMENT */
1250: extern int chmod(char *path, int mode);
1251: extern int ioctl(int fildes, int request, ...);
1252: extern int rdchk(int ttyfd);
1253: extern int nap(int m);
1254: #ifdef COMMENT
1255: extern int getppid(void);
1256: #endif /* COMMENT */
1257: extern int _filbuf(FILE *stream);
1258: extern int _flsbuf(char c,FILE *stream);
1259: #endif /* DIAB */
1260:
1261: /*
1262: Prototypes for UNIX functions like access, alarm, chdir, sleep, fork,
1263: and pause. Otherwise, no prototypes.
1264: */
1265: #ifdef NEXT
1266: #include <libc.h>
1267: #else
1268: #ifndef AMIGA
1269: #ifndef OS2
1270: #include <unistd.h>
1271: #endif /* OS2 */
1272: #endif /* AMIGA */
1273: #endif /* NEXT */
1274:
1275: #else /* Not ANSI libs... */
1276:
1277: #ifdef MAC
1278: #include <String.h>
1279: #include <StdLib.h>
1280: #endif /* MAC */
1281:
1282: #ifdef SUNOS41
1283: #include <unistd.h>
1284: #include <stdlib.h>
1285: #else
1286: /*
1287: It is essential that these are declared correctly!
1288: */
1289: _PROTOTYP( char * malloc, (unsigned int) );
1290: _PROTOTYP( char * getenv, (char *) );
1291: _PROTOTYP( long atol, (char *) );
1292: #endif /* SUNOS4 */
1293: #endif /* CK_ANSILIBS */
1294:
1295: #ifndef NULL /* In case NULL is still not defined */
1296: #define NULL 0L
1297: /* or #define NULL 0 */
1298: /* or #define NULL ((char *) 0) */
1299: /* or #define NULL ((void *) 0) */
1300: #endif /* NULL */
1301:
1302: /* Funny names for library functions department... */
1303:
1304: #ifdef ZILOG
1305: #define setjmp setret
1306: #define longjmp longret
1307: #define jmp_buf ret_buf
1308: #define getcwd curdir
1309: #endif /* ZILOG */
1310:
1311: #endif /* CKCDEB_H */
1312:
1313: /* End of ckcdeb.h */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.