--- pgp/src/system.c 2018/04/24 16:39:56 1.1.1.4 +++ pgp/src/system.c 2018/04/24 16:43:24 1.1.1.7 @@ -3,6 +3,23 @@ * * Routines specific for non-MSDOS implementations of pgp. * + * (c) Copyright 1990-1994 by Philip Zimmermann. All rights reserved. + * The author assumes no liability for damages resulting from the use + * of this software, even if the damage results from defects in this + * software. No warranty is expressed or implied. + * + * Note that while most PGP source modules bear Philip Zimmermann's + * copyright notice, many of them have been revised or entirely written + * by contributors who frequently failed to put their names in their + * code. Code that has been incorporated into PGP from other authors + * was either originally published in the public domain or is used with + * permission from the various authors. + * + * PGP is available for free to the public under certain restrictions. + * See the PGP User's Guide (included in the release package) for + * important information about licensing, patent restrictions on + * certain algorithms, trademarks, copyrights, and export controls. + * * Modified 24-Jun-92 HAJK * Adapt for VAX/VMS. * @@ -115,7 +132,8 @@ void ttycbreak(void) #else if (ioctl(ttyfd, TCGETA, &tio) < 0) #endif /* not SVR2 */ - { fprintf (stderr, "\nUnable to get terminal characteristics: "); + { + fprintf (stderr, "\nUnable to get terminal characteristics: "); perror("ioctl"); exitPGP(1); } @@ -130,13 +148,18 @@ void ttycbreak(void) tio.c_cc[VTIME] = 0; tio.c_lflag &= ~(ECHO|ICANON); #ifndef SVR2 +#ifdef ultrix + /* Ultrix is broken and flushes the output as well! */ + tcsetattr (ttyfd, TCSANOW, &tio); +#else tcsetattr (ttyfd, TCSAFLUSH, &tio); +#endif #else ioctl(ttyfd, TCSETAF, &tio); #endif /* not SVR2 */ #else - if (ioctl(ttyfd, TIOCGETP, &sg) < 0) - { fprintf (stderr, "\nUnable to get terminal characteristics: "); + if (ioctl(ttyfd, TIOCGETP, &sg) < 0) { + fprintf (stderr, "\nUnable to get terminal characteristics: "); perror("ioctl"); exitPGP(1); } @@ -169,7 +192,12 @@ void ttynorm(void) #endif #ifndef NOTERMIO #ifndef SVR2 +#ifdef ultrix + /* Ultrix is broken and flushes the output as well! */ + tcsetattr (ttyfd, TCSANOW, &tio); +#else tcsetattr (ttyfd, TCSAFLUSH, &itio); +#endif #else ioctl(ttyfd, TCSETAF, &itio); #endif /* not SVR2 */ @@ -197,14 +225,16 @@ static void sig1 (int sig) } static void sig2 (int sig) -{ if (gottio) +{ + if (gottio) ttycbreak(); else setsigs(); } static void setsigs(void) -{ savesig = signal (SIGINT, sig1); +{ + savesig = signal (SIGINT, sig1); #ifdef SIGTSTP signal (SIGCONT, sig2); signal (SIGTSTP, sig1); @@ -310,7 +340,8 @@ register int n; } #endif /* _BSD */ -#if (defined(MACH) || defined(SVR2) || defined(_BSD)) && !defined(NEXT) +#if (defined(MACH) || defined(SVR2) || defined(_BSD)) && !defined(NEXT) \ +&& !defined(AUX) || (defined(sun) && defined(i386)) int remove(name) char *name; { @@ -318,7 +349,7 @@ char *name; } #endif -#ifdef SVR2 +#if defined(SVR2) && !defined(AUX) int rename(old, new) register char *old, *new; { @@ -337,7 +368,8 @@ register char *old, *new; long Clock() /* not a replacement for clock(), just for random number generation */ { -#if defined(_BSD) || defined(sun) || defined(MACH) || defined(linux) +#if defined(_BSD) || (defined(sun) && !defined(SOLARIS)) || \ +defined(MACH) || defined(linux) #include #include struct rusage ru; @@ -464,7 +496,8 @@ static volatile struct { int ExtChar; } CharBuf, OldCharBuf; -static $DESCRIPTOR (out_file_descr, "SYS$DISK:[]"); /* Default Output File Descr */ +static $DESCRIPTOR (out_file_descr, "SYS$DISK:[]"); /* Default Output + File Descr */ static int flags = FDL$M_FDL_STRING; @@ -812,7 +845,8 @@ void ttycbreak () 0, 0, &buf, - (TypCharBuf.TypAhdCnt >= 80 ? 80 : TypCharBuf.TypAhdCnt), + (TypCharBuf.TypAhdCnt >= 80 ? 80 : + TypCharBuf.TypAhdCnt), 1, &NoTerm, 0, @@ -843,7 +877,8 @@ void ttycbreak () 0, 0)) & 01) sts = iosb.sts; if (!(sts & 01)) { - fprintf(stderr,"\nttybreak()- Failed to set terminal characteristics!"); + fprintf(stderr, + "\nttybreak()- Failed to set terminal characteristics!"); (void) lib$signal(sts); exitPGP(1); } @@ -893,8 +928,8 @@ int vms_GetCmd( char *cmdtbl) */ verb_size = cmdprmt_d.dsc$w_length - 2; /* Loose '> ' characters */ cmdbuf_d.dsc$w_length = MAX_CMDSIZ-verb_size-1; - cmdbuf_d.dsc$a_pointer = strncpy(cmdbuf,cmdprmt_d.dsc$a_pointer,verb_size) + - verb_size+1; + cmdbuf_d.dsc$a_pointer = strncpy(cmdbuf,cmdprmt_d.dsc$a_pointer,verb_size) + + verb_size+1; cmdbuf[verb_size++]=' '; if ((sts = lib$get_foreign ( /* Recover command line from DCL */ &cmdbuf_d, @@ -903,7 +938,8 @@ int vms_GetCmd( char *cmdtbl) 0)) & 01) { cmdbuf_d.dsc$a_pointer = cmdbuf; cmdbuf_d.dsc$w_length = cmdsiz + verb_size; - VAXC$ESTABLISH(lib$sig_to_ret); /* Force unhandled exceptions to return */ + VAXC$ESTABLISH(lib$sig_to_ret); /* Force unhandled exceptions + to return */ sts = cli$dcl_parse( /* Parse Command Line */ &cmdbuf_d, cmdtbl, @@ -945,7 +981,8 @@ vms_TstOpt(char opt) struct dsc$descriptor option_d = { 1, 0, 0, &buf}; buf = _toupper(opt); - VAXC$ESTABLISH(lib$sig_to_ret); /* Force unhandled exceptions to return */ + VAXC$ESTABLISH(lib$sig_to_ret); /* Force unhandled exceptions + to return */ switch (sts=cli$present(&option_d)) { @@ -990,7 +1027,8 @@ vms_GetVal( char opt, char *resval, unsi struct dsc$descriptor value_d = {maxsiz-1, 0, 0, resval }; unsigned short valsiz; - VAXC$ESTABLISH(lib$sig_to_ret); /* Force unhandled exceptions to return */ + VAXC$ESTABLISH(lib$sig_to_ret); /* Force unhandled exceptions + to return */ buf = _toupper(opt); if ((sts = cli$get_value( &option_d, @@ -1029,7 +1067,8 @@ vms_GetArg( unsigned short arg, char *re struct dsc$descriptor value_d = {maxsiz-1, 0, 0, resval }; unsigned short valsiz; - VAXC$ESTABLISH(lib$sig_to_ret); /* Force unhandled exceptions to return */ + VAXC$ESTABLISH(lib$sig_to_ret); /* Force unhandled exceptions + to return */ buf[1] = arg + '0'; if ((sts = cli$present(&option_d)) & 01) { if ((sts = cli$get_value( @@ -1072,7 +1111,8 @@ do_help(char *helptext, char *helplib) struct dsc$descriptor helptext_d = { strlen(helptext), 0, 0, helptext}; struct dsc$descriptor helplib_d = { strlen(helplib), 0, 0, helplib}; - VAXC$ESTABLISH(lib$sig_to_ret); /* Force unhandled exceptions to return */ + VAXC$ESTABLISH(lib$sig_to_ret); /* Force unhandled + exceptions to return */ if (((sts = kbhit_Getchn()) & 01) || sts == 0) { helpflags = HLP$M_PROMPT|HLP$M_SYSTEM|HLP$M_GROUP|HLP$M_PROCESS; sts = lbr$output_help( @@ -1181,7 +1221,8 @@ int fdl_generate(char *in_file, char **f &badblk, len)) & 01)) { if (verbose) - fprintf(stderr,"\n(SYSTEM) Failed to generate FDL\n",in_file); + fprintf(stderr,"\n(SYSTEM) Failed to generate FDL\n", + in_file); free(fdl); } else { if (!(*fdl = malloc(*len))) return(0); @@ -1319,7 +1360,8 @@ VOID * fdl_create( char *fdl, short len, fdl_close(rab); } else sts = rab; } - fab->fab$l_nam = 0; /* I allocated NAM block, so I must deallocate it! */ + fab->fab$l_nam = 0; /* I allocated NAM block, + so I must deallocate it! */ } free(resnam); return(sts); @@ -1366,15 +1408,16 @@ int fdl_copyfile2bin( FILE *f, VOID *rab count = fread(textbuf,1,count,f); if (count > 0) { /* - * No byte order conversion required, source and target system are both VMS so have - * the same byte ordering. + * No byte order conversion required, source and target system are both + * VMS so have the same byte ordering. */ ((struct RAB *) rab)->rab$w_rsz = (unsigned short) count; if (!(sys$write ( rab, NULL, NULL) & 01)) { - lib$signal(((struct RAB *) rab)->rab$l_sts,((struct RAB *) rab)->rab$l_stv); + lib$signal(((struct RAB *) rab)->rab$l_sts, + ((struct RAB *) rab)->rab$l_stv); status = 1; break; }