Annotation of 41BSD/cmd/berknet/header.c, revision 1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.