⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tandem.c

📁 infozip2.2源码
💻 C
📖 第 1 页 / 共 2 页
字号:
  while (*t != '\0') {  /* File part could be sys,vol,subvol or file */    if (*t == TANDEM_NODE) {    /* System Name */      strcat(n, INTERNAL_NODE_STR);      t++;    }    else if (*t == TANDEM_DELIMITER) {  /* Volume or Subvol */           strcat(n, INTERNAL_DELIMITER_STR);           t++;         };    p = strchr(t,TANDEM_DELIMITER);    if (p == NULL) break;    strncat(n,t,(p - t));    t = p;  }  strcat(n,t);  /* mop up any left over characters */  if (extension) {    strcat(n,DOS_EXTENSION_STR);    strcat(n,ext);  };  if (isdir == 42) return n;      /* avoid warning on unused variable */  if (dosify)    msname(n);  /* Returned malloc'ed name */  if (pdosflag)    *pdosflag = dosflag;  return n;}char *in2ex(n)char *n;                /* internal file name *//* Convert the zip file name to an external file name, returning the malloc'ed   string or NULL if not enough memory. */{  char *x;              /* external file name */  char *t;              /* pointer to internal */  char *p;              /* pointer to internal */  char *e;              /* pointer to internal */  int len;  if ((x = malloc(strlen(n) + 4)) == NULL)  /* + 4 for safety */    return NULL;  t = n;  *x= '\0';  if (!pathput)    t = last(t, INTERNAL_DELIMITER);  while (*t != '\0') {  /* File part could be sys,vol,subvol or file */    if (*t == INTERNAL_DELIMITER) {    /* System, Volume or Subvol Name */      t++;      if (*t == INTERNAL_DELIMITER) {  /* System */        strcat(x, TANDEM_NODE_STR);        t++;      }      else        strcat(x, TANDEM_DELIMITER_STR);    }    p = strchr(t,INTERNAL_DELIMITER);    if (p == NULL) break;    if ((e = strchr(t,DOS_EXTENSION)) == NULL)      e = p;    else      e = (e < p ? e : p);    len = _min (MAXFILEPARTLEN, (e - t));    strncat(x,t,(e - t));    t = p;  }  if ((e = strchr(t,DOS_EXTENSION)) == NULL)    strcat(x,t);  else    strncat(x,t,(e - t));  return x;}void stamp(f, d)char *f;                /* name of file to change */ulg d;                  /* dos-style time to change it to *//* Set last updated and accessed time of file f to the DOS time d. */{  ztimbuf u;            /* argument for utime() */  /* Convert DOS time to time_t format in u.actime and u.modtime */  u.actime = u.modtime = dos2unixtime(d);  utime(f, &u);}ulg filetime(f, a, n, t)char *f;                /* name of file to get info on */ulg *a;                 /* return value: file attributes */long *n;                /* return value: file size */iztimes *t;             /* return value: access and modification time */{  struct stat s;  char fname[FILENAME_MAX + 1];  if (strcmp(f, "-") == 0) {    /* if compressing stdin */    if (n != NULL) {      *n = -1L;    }  }  strcpy(fname, f);  if (stat(fname, &s) != 0) return 0;  if (a!= NULL) {    *a = ((ulg)s.st_mode << 16) | !(s.st_mode & S_IWUSR);    if ((s.st_mode & S_IFMT) == S_IFDIR) {      *a |= MSDOS_DIR_ATTR;    }  }  if (n!= NULL)    *n = (s.st_mode & S_IFMT) == S_IFREG ? s.st_size : -1L;  if (t != NULL) {    t->atime = s.st_atime;    t->mtime = s.st_mtime;    t->ctime = (time_t) s.st_reserved[0];  }  return unix2dostime(&s.st_mtime);}int set_extra_field(z, z_utim)struct zlist far *z;iztimes *z_utim;/* create extra field and change z->att if desired */{  return ZE_OK;}int deletedir(d)char *d;                /* directory to delete *//* Delete the directory *d if it is empty, do nothing otherwise.   Return the result of rmdir(), delete(), or system().   For VMS, d must be in format [x.y]z.dir;1  (not [x.y.z]). */{    return rmdir(d);}/*  COMMENTED OUT - SEE LATER DECLARATION  void version_local()  {      printf("Compiled with %s under %s.\n", "T9255C", "TANDEM NSK"      );  }*/#endif /* !UTIL *//* * TANDEM */DIR *opendir(const char *dirname){   short i, resolve;   char sname[FILENAME_MAX + 1];   short snamelen;   char fname[FILENAME_MAX + 1];   short fnamelen;   char *p;   short searchid,err,end;   struct dirent *entry;   DIR *dirp;   char ext[EXTENSION_MAX + 1];   short extension;   extension = parsename(dirname, sname, ext);   snamelen = strlen(sname);   /*  First we work out how detailed the template is...    *  e.g. If the template is DAVES*.* we want the search result    *       in the same format    */   p = sname;   i = 0;   while ((p = strchr(p, TANDEM_DELIMITER)) != NULL){     i++;     p++;   };   resolve = 2 - i;   /*  Attempt to start a filename template */   err = FILENAME_FINDSTART_ ( &searchid,                               sname,                               snamelen,                               resolve,                               DISK_DEVICE                             );   if (err != 0) {     end = FILENAME_FINDFINISH_(searchid);     return NULL;   }   /* Create DIR structure */   if ((dirp = malloc(sizeof(DIR))) == NULL ) {     end = FILENAME_FINDFINISH_(searchid);     return NULL;   }   dirp->D_list = dirp->D_curpos = NULL;   strcpy(dirp->D_path, dirname);   while ((err = FILENAME_FINDNEXT_(searchid,                                    fname,                                    FILENAME_MAX,                                    &fnamelen                                   )           ) == 0 ){     /*  Create space for entry */     if ((entry = malloc (sizeof(struct dirent))) == NULL) {       end = FILENAME_FINDFINISH_(searchid);       return NULL;     }     /*  Link to last entry */     if (dirp->D_curpos == NULL)       dirp->D_list = dirp->D_curpos = entry;  /* First name */     else {       dirp->D_curpos->d_next = entry;         /* Link */       dirp->D_curpos = entry;     };     /* Add directory entry */     *dirp->D_curpos->d_name = '\0';     strncat(dirp->D_curpos->d_name,fname,fnamelen);     if (extension) {       strcat(dirp->D_curpos->d_name,TANDEM_EXTENSION_STR);       strcat(dirp->D_curpos->d_name,ext);     };     dirp->D_curpos->d_next = NULL;   };   end = FILENAME_FINDFINISH_(searchid);   if (err = 1) {  /*  Should return EOF at end of search */     dirp->D_curpos = dirp->D_list;        /* Set current pos to start */     return dirp;   }   else     return NULL;}struct dirent *readdir(DIR *dirp){   struct dirent *cur;   cur = dirp->D_curpos;   dirp->D_curpos = dirp->D_curpos->d_next;   return cur;}void rewinddir(DIR *dirp){   dirp->D_curpos = dirp->D_list;}int closedir(DIR *dirp){   struct dirent *node;   while (dirp->D_list != NULL) {      node = dirp->D_list;      dirp->D_list = dirp->D_list->d_next;      free( node );   }   free( dirp );   return 0;}local char *readd(d)DIR *d;                 /* directory stream to read from *//* Return a pointer to the next name in the directory stream d, or NULL if   no more entries or an error occurs. */{  struct dirent *e;  e = readdir(d);  return e == NULL ? (char *) NULL : e->d_name;}int procname(n)char *n;                /* name to process *//* Process a name or sh expression to operate on (or exclude).  Return   an error code in the ZE_ class. */{  char *a;              /* path and name for recursion */  DIR *d;               /* directory stream from opendir() */  char *e;              /* pointer to name from readd() */  int m;                /* matched flag */  char *p;              /* path for recursion */  struct stat s;        /* result of stat() */  struct zlist far *z;  /* steps through zfiles list */  if (strcmp(n, "-") == 0)   /* if compressing stdin */    return newname(n, 0);  else if (stat(n, &s))  {    /* Not a file or directory--search for shell expression in zip file */    p = ex2in(n, 0, (int *)NULL);       /* shouldn't affect matching chars */    m = 1;    for (z = zfiles; z != NULL; z = z->nxt) {      if (MATCH(p, z->zname))      {        z->mark = pcount ? filter(z->zname) : 1;        if (verbose)            fprintf(mesg, "zip diagnostic: %scluding %s\n",               z->mark ? "in" : "ex", z->name);        m = 0;      }    }    free((zvoid *)p);    return m ? ZE_MISS : ZE_OK;  }  /* Live name--use if file, recurse if directory */  if ((s.st_mode & S_IFDIR) == 0)  {    /* add or remove name of file */    if ((m = newname(n, 0)) != ZE_OK)      return m;  } else {    if ((p = malloc(strlen(n)+4)) == NULL)      return ZE_MEM;    strcpy(p, n);    /* No concept of directories on Tandem - so do not store them ...*/    /* code removed from which attempted to save dir name if dirnames set */    /*  Test for recurse being set removed, since Tandem has no dir concept */    /*  recurse into template */    if ((d = opendir(n)) != NULL)    {      while ((e = readd(d)) != NULL) {        if ((m = procname(e)) != ZE_OK)   /* recurse on name */        {          if (m == ZE_MISS)            zipwarn("name not matched: ", e);          else            ziperr(m, e);        }      }      closedir(d);    }    free((zvoid *)p);  } /* (s.st_mode & S_IFDIR) == 0) */  return ZE_OK;}/******************************//*  Function version_local()  *//******************************/void version_local(){    static ZCONST char CompiledWith[] = "Compiled with %s%s for %s%s%s%s.\n\n";#if 0    char buf[40];#endif    printf(CompiledWith,#ifdef __GNUC__      "gcc ", __VERSION__,#else#  if 0      "cc ", (sprintf(buf, " version %d", _RELEASE), buf),#  else      "unknown compiler", "",#  endif#endif      "Tandem/NSK", "",#ifdef __DATE__      " on ", __DATE__#else      "", ""#endif      );} /* end function version_local() */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -