/*@H************************ < COMPRESS utility> **************************** * * * compress : compusi.uni * * * * port by : Donald J. Gloistein * * * * Source, Documentation, Object Code: * * released to Public Domain. This code is ported from compress v4.0 * * release joe. * * * *--------------------------- Module Description --------------------------* * Unix system dependent routines. These are specific to either the * * unix file structure or some unix only functions. * * * * Separated out for ease of writing the main module. * * * *--------------------------- Implementation Notes --------------------------* * * * compiled with : compress.h compress.fns * * linked with : compress.o compapi.o * * * * To use, copy or rename this file to compusi.c and recompile. * * Set the defines in compress.h to reflect the status of your compiler's * * runtime library, allocation type for malloc()'s, and memory models if * * applicable, and your library function call for malloc() and free(). * * * * problems: header has some hardcoded defines you may need to change * * for your compiler. Please read the header thoroughly. * * * *--------------------------- Author(s) -------------------------* * Initials ---- Name --------------------------------- * * DjG Donald J. Gloistein * * Plus many others, see rev.hst file for full list * * LvR Lyle V. Rains, thanks for the improved implementation * * of the compression and decompression routines. * *************************************************************************@H*/ #include #include "compress.h" /* contains the rest of the include file declarations */ char *get_program_name(ptr) char *ptr; { char *cp; if ((cp = strrchr(ptr, '/')) != NULL) cp++; else cp = ptr; if(strcmp(cp,"uncompress") == 0) { do_decomp = 1; } else if(strcmp(cp, "zcat") == 0) { keep = TRUE; zcat_flg = do_decomp = 1; } return (cp); } char *name_index(ptr) char *ptr; { char *p; p = strrchr(ptr,'/'); return ((p)? ++p: ptr); } int is_z_name(ptr) /* checks if it is already a z name */ char *ptr; { return (!(strcmp(ptr + strlen(ptr) -2,".Z"))); } int make_z_name(ptr) char *ptr; { if (strlen(name_index(ptr)) > 13 ) { fprintf(stderr,"%s: filename too long to add .Z\n",name_index(ptr)); return FALSE; } strcat(ptr,".Z"); return TRUE; } void unmake_z_name(ptr) char *ptr; { register int len = strlen(ptr)-2; ptr[len] = '\0'; } void copystat(ifname, ofname) char *ifname, *ofname; { /* This is where to copy file dates etc.. */ } void version() { #ifdef XENIX #ifndef NDEBUG fprintf(stderr, "%s\nOptions: Xenix %s MAXBITS = %d\n", rcs_ident, "DEBUG",MAXBITS); #else fprintf(stderr, "%s\nOptions: Xenix MAXBITS = %d\n", rcs_ident,MAXBITS); #endif #else #ifndef NDEBUG fprintf(stderr, "%s\nOptions: Unix %s MAXBITS = %d\n", rcs_ident, "DEBUG",MAXBITS); #else fprintf(stderr, "%s\nOptions: Unix MAXBITS = %d\n", rcs_ident,MAXBITS); #endif #endif } ALLOCTYPE FAR *emalloc(x,y) unsigned int x; int y; { ALLOCTYPE FAR *p; p = (ALLOCTYPE FAR *)ALLOCATE(x,y); return(p); } void efree(ptr) ALLOCTYPE FAR *ptr; { FREEIT(ptr); }