Annotation of researchv9/cmd/emacs/xusend.c, revision 1.1

1.1     ! root        1: #include <stdio.h>
        !             2: #include <sys/types.h>
        !             3: #include <sys/stat.h>
        !             4: 
        !             5: /* EMACS_MODES: c, !fill */
        !             6: 
        !             7: /* xusend -- Warren Montgomery  12/15/80 */
        !             8: 
        !             9: /* xusend  calls usend, segmenting the list files sent so that each
        !            10:  * invocation of usend sends no more than 150,000 bytes.  This is a
        !            11:  * temporary kludge, that really should be part of the standard
        !            12:  * usend command. */
        !            13: 
        !            14: /* Usage is: 
        !            15:  * 
        !            16:  * xusend "usend args" <files>
        !            17:  *
        !            18:  */
        !            19: 
        !            20: char *usend = "usend ";                        /* program to call */
        !            21: #define FLIMIT 100000
        !            22: #define ALIMIT 160000
        !            23: 
        !            24: char combuf[2048];
        !            25: 
        !            26: char *
        !            27: strcat(cp,cp1)
        !            28: 
        !            29: register char *cp;
        !            30: register char *cp1;
        !            31: {
        !            32:        while (*cp++ = *cp1++);
        !            33:        return(cp-1);
        !            34: }
        !            35: 
        !            36: main(argc,argv)
        !            37: 
        !            38: int argc;
        !            39: char **argv;
        !            40: {
        !            41:        long fbytes = 0;
        !            42:        int filecount = 0;
        !            43:        int status;
        !            44:        struct stat statb;
        !            45:        char *bufptr;
        !            46:        char *savbuf;
        !            47:        
        !            48:        if (argc < 3) {
        !            49:                printf ("Usage is:\n\n");
        !            50:                printf ("xusend \"usend args\" <files>\n\n");
        !            51:                exit(0);
        !            52:        }
        !            53:        
        !            54:        savbuf = strcat(combuf,usend);
        !            55:        savbuf=strcat(savbuf,argv[1]);
        !            56:        argc-= 2;
        !            57:        argv+= 2;
        !            58:        
        !            59:        while (argc>0) {
        !            60:                
        !            61:                
        !            62:                                        /* process next block of files */
        !            63:                
        !            64:                bufptr = savbuf;
        !            65:                fbytes = 0;
        !            66:                filecount = 0;
        !            67:                
        !            68:                while (argc && (fbytes < FLIMIT)) {
        !            69:                        status = stat(*argv,&statb);
        !            70:                        if (status != 0) {
        !            71:                                printf ("Can't stat %s, ignoring it\n", *argv);;
        !            72:                                argv++;
        !            73:                                argc--;
        !            74:                        } else {
        !            75:                                fbytes += statb.st_size;
        !            76:                                if ((fbytes < FLIMIT) || (filecount == 0)){
        !            77:                                        *bufptr++ = ' ';
        !            78:                                        bufptr = strcat(bufptr,*argv);
        !            79:                                        argv++;
        !            80:                                        argc--;
        !            81:                                        filecount++;
        !            82:                                        if (fbytes >FLIMIT) {
        !            83:                                                printf ("File %s may be to big for usend\n", *argv);
        !            84:                                        }
        !            85:                                }
        !            86:                        }
        !            87:                }
        !            88:                if (filecount) {
        !            89:                        printf("\n%s\n",combuf);
        !            90:                        system (combuf);
        !            91:                } else {
        !            92:                        printf ("File %s is too big for usend, ignoring it\n", *argv);
        !            93:                        argv++;
        !            94:                        argc--;
        !            95:                }
        !            96:        }
        !            97: }
        !            98: 

unix.superglobalmegacorp.com

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