📄 novell.c
字号:
return MPN_OK; } /* end if (FUNCTION == APPEND_DIR) *//*--------------------------------------------------------------------------- GETPATH: copy full path to the string pointed at by pathcomp, and free buildpath. ---------------------------------------------------------------------------*/ if (FUNCTION == GETPATH) { strcpy(pathcomp, buildpath); Trace((stderr, "getting and freeing path [%s]\n", FnFilter1(pathcomp))); free(buildpath); buildpath = end = (char *)NULL; return MPN_OK; }/*--------------------------------------------------------------------------- APPEND_NAME: assume the path component is the filename; append it and return without checking for existence. ---------------------------------------------------------------------------*/ if (FUNCTION == APPEND_NAME) {#ifdef SHORT_NAMES char *old_end = end;#endif Trace((stderr, "appending filename [%s]\n", FnFilter1(pathcomp))); while ((*end = *pathcomp++) != '\0') { ++end;#ifdef SHORT_NAMES /* truncate name at 14 characters, typically */ if ((end-old_end) > FILENAME_MAX) /* GRR: proper constant? */ *(end = old_end + FILENAME_MAX) = '\0';#endif if ((end-buildpath) >= FILNAMSIZ) { *--end = '\0'; Info(slide, 0x201, ((char *)slide, "checkdir warning: path too long; truncating\n\ %s\n -> %s\n", FnFilter1(G.filename), FnFilter2(buildpath))); return MPN_INF_TRUNC; /* filename truncated */ } } Trace((stderr, "buildpath now = [%s]\n", FnFilter1(buildpath))); /* could check for existence here, prompt for new name... */ return MPN_OK; }/*--------------------------------------------------------------------------- INIT: allocate and initialize buffer space for the file currently being extracted. If file was renamed with an absolute path, don't prepend the extract-to path. ---------------------------------------------------------------------------*//* GRR: for VMS and TOPS-20, add up to 13 to strlen */ if (FUNCTION == INIT) { Trace((stderr, "initializing buildpath to "));#ifdef ACORN_FTYPE_NFS if ((buildpath = (char *)malloc(strlen(G.filename)+rootlen+ (uO.acorn_nfs_ext ? 5 : 1)))#else if ((buildpath = (char *)malloc(strlen(G.filename)+rootlen+1))#endif == (char *)NULL) return MPN_NOMEM; if ((rootlen > 0) && !renamed_fullpath) { strcpy(buildpath, rootpath); end = buildpath + rootlen; } else { *buildpath = '\0'; end = buildpath; } Trace((stderr, "[%s]\n", FnFilter1(buildpath))); return MPN_OK; }/*--------------------------------------------------------------------------- ROOT: if appropriate, store the path in rootpath and create it if neces- sary; else assume it's a zipfile member and return. This path segment gets used in extracting all members from every zipfile specified on the command line. ---------------------------------------------------------------------------*/#if (!defined(SFX) || defined(SFX_EXDIR)) if (FUNCTION == ROOT) { Trace((stderr, "initializing root path to [%s]\n", FnFilter1(pathcomp))); if (pathcomp == (char *)NULL) { rootlen = 0; return MPN_OK; } if ((rootlen = strlen(pathcomp)) > 0) { if (pathcomp[rootlen-1] == '/') { pathcomp[--rootlen] = '\0'; } if (rootlen > 0 && (stat(pathcomp, &G.statbuf) || !S_ISDIR(G.statbuf.st_mode))) /* path does not exist */ { if (!G.create_dirs /* || iswild(pathcomp) */ ) { rootlen = 0; /* skip (or treat as stored file) */ return MPN_INF_SKIP; } /* create the directory (could add loop here to scan pathcomp * and create more than one level, but why really necessary?) */ if (mkdir(pathcomp) == -1) { Info(slide, 1, ((char *)slide, "checkdir: cannot create extraction directory: %s\n", FnFilter1(pathcomp))); rootlen = 0; /* path didn't exist, tried to create, and failed: */ /* file exists, or 2+ subdirectory levels required */ return MPN_ERR_SKIP; } } if ((rootpath = (char *)malloc(rootlen+2)) == (char *)NULL) { rootlen = 0; return MPN_NOMEM; } strcpy(rootpath, pathcomp); rootpath[rootlen++] = '/'; rootpath[rootlen] = '\0'; Trace((stderr, "rootpath now = [%s]\n", FnFilter1(rootpath))); } return MPN_OK; }#endif /* !SFX || SFX_EXDIR *//*--------------------------------------------------------------------------- END: free rootpath, immediately prior to program exit. ---------------------------------------------------------------------------*/ if (FUNCTION == END) { Trace((stderr, "freeing rootpath\n")); if (rootlen > 0) { free(rootpath); rootlen = 0; } return MPN_OK; } return MPN_INVALID; /* should never reach */} /* end function checkdir() *//****************************//* Function close_outfile() *//****************************/void close_outfile(__G) /* GRR: change to return PK-style warning level */ __GDEF{ WORD date = G.lrec.last_mod_dos_datetime >> 16; WORD time = G.lrec.last_mod_dos_datetime & 0xffff; static struct ModifyStructure changeBuffer; fclose(G.outfile); /* set the file's access and modification times */ changeBuffer.MLastAccessedDate = date; changeBuffer.MLastUpdatedDate = date; changeBuffer.MLastUpdatedTime = time; if (ChangeDirectoryEntry(G.filename, &changeBuffer, MLastAccessedDateBit | MLastUpdatedDateBit | MLastUpdatedTimeBit, 0)) { if (uO.qflag) Info(slide, 0x201, ((char *)slide, "warning: cannot set times for %s\n", FnFilter1(G.filename))); else Info(slide, 0x201, ((char *)slide, " (warning) cannot set times")); }/*--------------------------------------------------------------------------- Change the file permissions from default ones to those stored in the zipfile. ---------------------------------------------------------------------------*/ if (chmod(G.filename, 0xffff & G.pInfo->file_attr)) perror("chmod (file attributes) error");} /* end function close_outfile() */#ifdef TIMESTAMP/***************************//* Function stamp_file() *//***************************/int stamp_file(fname, modtime) ZCONST char *fname; time_t modtime;{ ztimbuf tp; tp.modtime = tp.actime = modtime; return (utime(fname, &tp));} /* end function stamp_file() */#endif /* TIMESTAMP *//************************//* Function version() *//************************/void version(__G) __GDEF{ int len;#if defined(__IBMC__) || defined(__WATCOMC__) || defined(_MSC_VER) char buf[80];#endif len = sprintf((char *)slide, LoadFarString(CompiledWith),#if defined(__GNUC__)# ifdef __EMX__ /* __EMX__ is defined as "1" only (sigh) */ "emx+gcc ", __VERSION__,# else "gcc/2 ", __VERSION__,# endif#elif defined(__WATCOMC__) "Watcom C", (sprintf(buf, " (__WATCOMC__ = %d)", __WATCOMC__), buf),#elif defined(__TURBOC__)# ifdef __BORLANDC__ "Borland C++",# if (__BORLANDC__ < 0x0460) " 1.0",# elif (__BORLANDC__ == 0x0460) " 1.5", /* from Kai Uwe: three less than DOS */# else " 2.0", /* (__BORLANDC__ == 0x0500)? */# endif# else "Turbo C", /* these are probably irrelevant */# if (__TURBOC__ >= 661) "++ 1.0 or later",# elif (__TURBOC__ == 661) " 3.0?",# elif (__TURBOC__ == 397) " 2.0",# else " 1.0 or 1.5?",# endif# endif#elif defined(MSC) "Microsoft C ",# ifdef _MSC_VER (sprintf(buf, "%d.%02d", _MSC_VER/100, _MSC_VER%100), buf),# else "5.1 or earlier",# endif#else "unknown compiler", "",#endif /* ?compilers */ "NetWare", " (32-bit)",#ifdef __DATE__ " on ", __DATE__#else "", ""#endif ); (*G.message)((zvoid *)&G, slide, (ulg)len, 0); /* MSC can't handle huge macro expansions */} /* end function version() */#ifdef MORE/*************************//* Function screensize() *//*************************/int screensize(int *tt_rows, int *tt_cols){ WORD height; WORD width; if (GetSizeOfScreen(&height, &width) == 0) { if (tt_rows != NULL) *tt_rows = height; if (tt_cols != NULL) *tt_cols = width; return 0; /* signal success */ } else { if (tt_rows != NULL) *tt_rows = 25; if (tt_cols != NULL) *tt_cols = 80; return 1; /* signal failure */ }}#endif /* MORE */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -