1: static char sccsid[] = "@(#)header.c	4.1	(Berkeley)	9/12/82";
   2: 
   3: /* sccs id variable */
   4: static char *header_sid = "@(#)header.c	1.3";
   5: /*
   6: 	header.c
   7: 
   8: 	these routines provide a way of transferring the information
   9: 	in the "header" structure between machines.
  10: 	Programs calling these routines either read or write
  11: 	their information into the header structure.
  12: 	These procedures format the info in a way that is acceptable.
  13: 	Called by net.c, netdaemon.c, and netq.c.
  14: */
  15: /*
  16: 	protocol that is sent (in ASCII):
  17: 	code, remote mach, local mach, version stamp (2), remote login name,
  18: 	password, -i, -o, -r files,
  19: 	local login name, terminal, flag, utmp tty login time,
  20: 	cc jobno(variable parameter list), current time,
  21: 	command '\n' real command '\n'
  22: 	any data
  23: 
  24: 	changes:
  25: 	1) remove header
  26: 	3) use ascii length instead of 4 bytes
  27: 	4) encrypt the login name, command, and part of data as well
  28: */
  29: # include "defs.h"
  30: 
  31: 
  32: writehdfd(phd,fd)
  33: register struct header *phd;
  34: FILE *fd;
  35: {
  36:     char *genparmlist();
  37:     char cflag = 'a';
  38: 
  39:     /* cflag is initially 'a'. Add the flags as needed. */
  40:     if(phd->hd_fnonotify)cflag += F_NONOTIFY;
  41:     if(phd->hd_fquiet)cflag += F_QUIET;
  42: 
  43:     fprintf(fd,
  44:     "%c :%c :%c :%c :%c :%s :%s :%s :%s :%s :%s :%s :%c :%lo :%s%s :%ld :",
  45:         phd->hd_code,phd->hd_mchto,phd->hd_mchfrom,
  46:         phd->hd_vmajor+'a',phd->hd_vminor+'a',phd->hd_snto,
  47:         phd->hd_spasswd,phd->hd_sinfile,phd->hd_soutfile,
  48:         phd->hd_srespfile,
  49:         phd->hd_snfrom,phd->hd_sttyname,cflag,phd->hd_lttytime,
  50:         phd->hd_ijobno,genparmlist(phd),phd->hd_ltimesent-TIMEBASE);
  51:     fputs(phd->hd_scmdact,fd);
  52:     putc('\n',fd);
  53:     fputs(phd->hd_scmdvirt,fd);
  54:     putc('\n',fd);
  55:     /* not used, but a good idea */
  56:     sprintf(phd->hd_addrfrom,"%c:%s",phd->hd_mchfrom,phd->hd_snfrom);
  57:     sprintf(phd->hd_addrto,  "%c:%s",phd->hd_mchto,  phd->hd_snto);
  58: }
  59: /*
  60: 	print out debugging values of a header structure
  61: */
  62: printhd(phd)
  63: register struct header *phd;
  64: {
  65:     if(debugflg){
  66:         printf("To %s From %s quiet=%c nonotify=%c\n",
  67:             phd->hd_addrto, phd->hd_addrfrom,
  68:             chfromf(phd->hd_fquiet), chfromf(phd->hd_fnonotify));
  69:         /* don't print out for security reasons
  70: 		printf("Password %s\n",phd->hd_spasswd);
  71: 		*/
  72:         printf("Code '%c' Version (%d,%d) Infile '%s'\n",
  73:             phd->hd_code, phd->hd_vmajor,phd->hd_vminor,
  74:             phd->hd_sinfile);
  75:         printf("Outfile '%s' Respfile '%s' TTYName '%s'\n",
  76:             phd->hd_soutfile,phd->hd_srespfile, phd->hd_sttyname);
  77:         printf("Jobno %s TimeSent %s", phd->hd_ijobno,
  78:             ctime(&phd->hd_ltimesent));
  79:         if(phd->hd_lttytime != 0)
  80:             printf("TTYTime %s", ctime(&phd->hd_lttytime));
  81:         printf("Virtual Command \"%s\"\n", phd->hd_scmdvirt);
  82:         printf("Actual Command \"%s\"\n", phd->hd_scmdact);
  83:     }
  84: }
  85: /*
  86: 	generate a variable parameter list
  87: 	the format is:
  88: 		(name value, name value, ..., name value)
  89: 	where names are unquoted single words and values
  90: 	are unquoted if a single alphanumeric word, and are
  91: 	surrounded by {} otherwise. \ quotes { and }.
  92: 	the values are escape-processed, e.g. \n becomes 012.
  93: 	this function returns such a list.
  94: 	Returns the null parm list if nothing to give, i.e. "()"
  95: 
  96: 	Should also default so single keywords can have on/off
  97: 	states, and so do not require a value.
  98: 
  99: 	Things this variable protocol should specify:
 100: 		EPASSWD 	encrypted passwd
 101: 		FILEMODE 	file mode
 102: 		FROMUID  	from users' uid
 103: 		FROMGID  	from users' gid
 104: 		COMPRESS 	use colin's compression
 105: 		ACCTPAIR	handle acct pairs
 106: 		MESSAGEID	unique number identifying this request.
 107: 		FILENAME	when omitted by netcp, will use FILENAME ext.
 108: 		REPLYTO		the person the response should be sent to
 109: 
 110: 		 --- possibly ---
 111: 		MACHINE2	a second machine (e.g. 3way netcp)
 112: 		LOGIN2		a second login name
 113: 		PASSWD2		a second passwd
 114: 
 115: */
 116: static char *genparmlist(phd)
 117: register struct header *phd;
 118: {
 119:     static char returnstr[PARMLIST];
 120:     strcpy(returnstr,"()");
 121:     return(returnstr);
 122: }

Defined functions

genparmlist defined in line 116; used 2 times
printhd defined in line 62; used 3 times
writehdfd defined in line 32; used 1 times

Defined variables

header_sid defined in line 4; never used
sccsid defined in line 1; never used
Last modified: 1982-09-13
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1058
Valid CSS Valid XHTML 1.0 Strict