Annotation of researchv9/jerq/sgs/libsdp/copy.c, revision 1.1

1.1     ! root        1: static char ID[] = "@(#) copy.c: 1.1 3/16/82";
        !             2: #include <stdio.h>
        !             3: #include <fcntl.h>
        !             4: #include "define2.h"
        !             5: #include "define3.h"
        !             6: #include "sdp.h"
        !             7: 
        !             8: #define CP01   "CP01 "
        !             9: #define CP02   "CP02 "
        !            10: #define CP03   "CP03 "
        !            11: #define CP04   "CP04 "
        !            12: #define CP05   "CP05 "
        !            13: #define CP06   "CP06 "
        !            14: #define CP07   "CP07 "
        !            15: #define CP08   "CP08 "
        !            16: #define CP09   "CP09 "
        !            17: #define CP10   "CP10 "
        !            18: #define CP11   "CP11 "
        !            19: #define CP12   "CP12 "
        !            20: #define CP13   "CP13 "
        !            21: extern struct  LIBFILE lib_file ;
        !            22: extern struct  LIBFILE *Glib_file ;
        !            23: extern struct  LIBMEM  *Glib_mem ;
        !            24: extern struct  SPACE   *rdSPACE() ;
        !            25: extern int             wtSPACE() ;
        !            26: extern                 freeSPACE() ;
        !            27: 
        !            28: sdp_copy(in_name,out_name,library)
        !            29: char           *in_name ;
        !            30: char           *out_name ;
        !            31: struct LIBFILE *library ;
        !            32: {
        !            33:        struct SPACE    *sp ;
        !            34:        int             in_fd ;
        !            35:        int             out_fd ;
        !            36:        int             n ;
        !            37:        int             i ;
        !            38:        char            *namebuf ;
        !            39:        char            *databuf ;
        !            40:        int             nameleng ;
        !            41: 
        !            42:        Glib_file = (library == NULL ) ? &lib_file : library ;
        !            43:        if ( (sp = rdSPACE(in_name)) == NULL )
        !            44:                ERR_RET(CP01,ERROR)
        !            45:        if ( (databuf = (char *)ALLOC(sp->page_size)) == NULL )
        !            46:                ERR_RET(CP02,ERROR)
        !            47:        nameleng = strlen(in_name) ;
        !            48:        if ( strlen(out_name) > strlen(in_name) )
        !            49:                nameleng = strlen(out_name) ;
        !            50:        if ( (namebuf = (char *)ALLOC(nameleng+strlen(SUFFIX)+COUNT+1)) == NULL )
        !            51:                ERR_RET(CP03,ERROR)
        !            52:        for(i=0; i<sp->numbfile; i++)
        !            53:                if(sp->fileinfo[i].desc != NOTMADE)
        !            54:                {
        !            55:                        sprintf(namebuf,"%s%d",sp->head_name,i) ;
        !            56:                        if((in_fd=MOPEN(namebuf,O_RDONLY)) == ERROR)
        !            57:                                ERR_RET(CP04,ERROR)
        !            58:                        sprintf(namebuf,"%s%s%d",out_name,SUFFIX,i) ;
        !            59:                        if ( MCREATE(namebuf,sp->mode) == ERROR )
        !            60:                                ERR_RET(CP05,ERROR)
        !            61:                        if ( (out_fd=MOPEN(namebuf,O_RDWR)) == ERROR )
        !            62:                                ERR_RET(CP06,ERROR)
        !            63:                        while(1)
        !            64:                        {
        !            65:                                switch(n=MREAD(in_fd,databuf,sp->page_size))
        !            66:                                {
        !            67:                                        case 0 :
        !            68:                                                break ;
        !            69:                
        !            70:                                        case ERROR :
        !            71:                                                ERR_RET(CP07,ERROR)
        !            72:                
        !            73:                                        default :
        !            74:                                                if ( n != sp->page_size )
        !            75:                                                        ERR_RET(CP08,ERROR)
        !            76:                                                if ( MWRITE(out_fd,databuf,sp->page_size) == ERROR )
        !            77:                                                        ERR_RET(CP09,ERROR)
        !            78:                                                continue ;
        !            79:                                }
        !            80:                                break ;
        !            81:                        }
        !            82:                        if(MCLOSE(in_fd) == ERROR)
        !            83:                                ERR_RET(CP10,ERROR)
        !            84:                        if(MCLOSE(out_fd) == ERROR)
        !            85:                                ERR_RET(CP11,ERROR)
        !            86:                }
        !            87:        sp->head_name = namebuf ;
        !            88:        sprintf(sp->head_name,"%s%s",out_name,SUFFIX) ;
        !            89:        sp->perms = WRTN ;
        !            90:        if ( MCREATE(sp->head_name,sp->mode) == ERROR )
        !            91:                ERR_RET(CP12,ERROR)
        !            92:        if ( wtSPACE(sp) == ERROR )
        !            93:                ERR_RET(CP13,ERROR)
        !            94:        freeSPACE(sp) ;
        !            95:        return(SUCCESS) ;
        !            96: }

unix.superglobalmegacorp.com

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