?? vmmvs.c
字號:
while ((lbar = strrchr(G.filename, '.')) != NULL) { memmove(lbar, lbar+1, strlen(lbar)); name_changed = MPN_INF_TRUNC; } /* Finally, convert path delimiters from internal '/' to external '.' */ while ((lbar = strchr(G.filename, '/')) != NULL) *lbar = '.';#endif /* ?VM_CMS */#ifndef MVS if ((lbar = strchr(G.filename, '.')) == NULL) { printf("WARNING: file '%s' has no extension - renamed to '%s.NONAME'\n"\ ,G.filename, G.filename); strcat(G.filename, ".NONAME"); name_changed = MPN_INF_TRUNC; }#endif checkdir(__G__ G.filename, GETPATH); return name_changed;} /* end function mapname() */int checkdir(__G__ pathcomp, flag) __GDEF char *pathcomp; int flag;/* * returns: * MPN_OK - no problem detected * MPN_INF_TRUNC - (on APPEND_NAME) truncated filename * MPN_INF_SKIP - path doesn't exist, not allowed to create * MPN_ERR_SKIP - path doesn't exist, tried to create and failed; or path * exists and is not a directory, but is supposed to be * MPN_ERR_TOOLONG - path is too long * MPN_NOMEM - can't allocate memory for filename buffers */{ static int rootlen = 0; /* length of rootpath */ static char *rootpath; /* user's "extract-to" directory */# define FN_MASK 7# define FUNCTION (flag & FN_MASK)/*--------------------------------------------------------------------------- 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. Note that under OS/2 and MS-DOS, if a candidate extract-to directory specification includes a drive letter (leading "x:"), it is treated just as if it had a trailing '/'--that is, one directory level will be created if the path doesn't exist, unless this is otherwise pro- hibited (e.g., freshening). ---------------------------------------------------------------------------*/#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; } else if ((rootlen = strlen(pathcomp)) > 0) { if ((rootpath = (char *)malloc(rootlen+1)) == NULL) { rootlen = 0; return MPN_NOMEM; } strcpy(rootpath, pathcomp); Trace((stderr, "rootpath now = [%s]\n", rootpath)); } return MPN_OK; }#endif /* !SFX || SFX_EXDIR *//*--------------------------------------------------------------------------- GETPATH: copy full path to the string pointed at by pathcomp, and free buildpath. ---------------------------------------------------------------------------*/ if (FUNCTION == GETPATH) { if (rootlen > 0) {#ifdef VM_CMS /* put the exdir after the filename */ strcat(pathcomp, "."); /* used as minidisk to be save on */ strcat(pathcomp, rootpath);#else /* MVS */ char newfilename[PATH_MAX]; char *start_fname; int quoted = 0; strcpy(newfilename, rootpath); if (newfilename[0] == '\'') { quoted = strlen(newfilename) - 1; if (newfilename[quoted] == '\'') newfilename[quoted] = '\0'; else quoted = 0; } if (strchr(pathcomp, '(') == NULL) { if ((start_fname = strrchr(pathcomp, '.')) == NULL) { start_fname = pathcomp; } else { *start_fname++ = '\0'; strcat(newfilename, "."); strcat(newfilename, pathcomp); } strcat(newfilename, "("); strcat(newfilename, start_fname); strcat(newfilename, ")"); } else { strcat(newfilename, "."); strcat(newfilename, pathcomp); } if (quoted) strcat(newfilename, "'"); Trace((stdout, "new dataset : %s\n", newfilename)); strcpy(pathcomp, newfilename);#endif /* ?VM_CMS */ } return MPN_OK; }/*--------------------------------------------------------------------------- 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 check_for_newer() */ /* used for overwriting/freshening/updating *//******************************/int check_for_newer(__G__ filename) /* return 1 if existing file is newer */ __GDEF /* or equal; 0 if older; -1 if doesn't */ char *filename; /* exist yet */{ FILE *stream; if ((stream = fopen(filename, FOPR)) != NULL) { fclose(stream); /* File exists, assume it is "newer" than archive entry. */ return EXISTS_AND_NEWER; } /* File does not exist. */ return DOES_NOT_EXIST;} /* end function check_for_newer() *//*********************//* Function stat() *//*********************/int stat(const char *path, struct stat *buf){ FILE *fp; char fname[PATH_MAX]; time_t ltime; if ((fp = fopen(path, FOPR)) != NULL) { fldata_t fdata; if (fldata( fp, fname, &fdata ) == 0) { buf->st_dev = fdata.__device; buf->st_mode = *(short *)(&fdata); } /* Determine file size by seeking to EOF */ fseek(fp,0L,SEEK_END); buf->st_size = ftell(fp); fclose(fp); /* set time fields in stat buf to current time. */ time(<ime); buf->st_atime = buf->st_mtime = buf->st_ctime = ltime; /* File exists, return success */ return 0; } return 1;}#ifdef STAND_ALONE/***************************//* Function main_vmmvs() *//***************************//* This function is called as main() to parse arguments *//* into argc and argv. This is required for stand-alone *//* execution. This calls the "real" main() when done. */int MAIN_VMMVS(void) { int argc=0; char *argv[50]; int iArgLen; char argstr[256]; char **pEPLIST, *pCmdStart, *pArgStart, *pArgEnd; /* Get address of extended parameter list from S/370 Register 0 */ pEPLIST = (char **)__xregs(0); /* Null-terminate the argument string */ pCmdStart = *(pEPLIST+0); pArgStart = *(pEPLIST+1); pArgEnd = *(pEPLIST+2); iArgLen = pArgEnd - pCmdStart + 1; /* Make a copy of the command string */ memcpy(argstr, pCmdStart, iArgLen); argstr[iArgLen] = '\0'; /* Null-terminate */ /* Store first token (cmd) */ argv[argc++] = strtok(argstr, " "); /* Store the rest (args) */ while (argv[argc-1]) argv[argc++] = strtok(NULL, " "); argc--; /* Back off last NULL entry */ /* Call "real" main() function */ return MAIN(argc, argv);}#endif /* STAND_ALONE */#ifndef SFX/************************//* Function version() *//************************/void version(__G) __GDEF{ int len; char liblvlmsg [50+1]; char *compiler = "?"; char *platform = "?"; char complevel[64]; /* Map the runtime library level information */ union { unsigned int iVRM; struct { unsigned int pd:4; /* Product designation */ unsigned int vv:4; /* Version */ unsigned int rr:8; /* Release */ unsigned int mm:16; /* Modification level */ } xVRM; } VRM; /* Break down the runtime library level */ VRM.iVRM = __librel(); sprintf(liblvlmsg, "Using runtime library level %s V%dR%dM%d", (VRM.xVRM.pd==1 ? "LE" : "CE"), VRM.xVRM.vv, VRM.xVRM.rr, VRM.xVRM.mm); /* Note: LE = Language Environment, CE = Common Env. (C/370). */ /* This refers ONLY to the current runtimes, not the compiler. */#ifdef VM_CMS platform = "VM/CMS"; #ifdef __IBMC__ compiler = "IBM C"; #else compiler = "C/370"; #endif#endif#ifdef MVS platform = "MVS"; #ifdef __IBMC__ compiler = "IBM C/C++"; #else compiler = "C/370"; #endif#endif#ifdef __COMPILER_VER__ VRM.iVRM = __COMPILER_VER__; sprintf(complevel," V%dR%dM%d", VRM.xVRM.vv, VRM.xVRM.rr, VRM.xVRM.mm);#else#ifdef __IBMC__ sprintf(complevel," V%dR%d", __IBMC__ / 100, (__IBMC__ % 100)/10);#else complevel[0] = '\0';#endif#endif /* Output is in the form "Compiled with %s%s for %s%s%s%s." */ len = sprintf((char *)slide, LoadFarString(CompiledWith), /* Add compiler name and level */ compiler, complevel, /* Add compile environment */ platform, /* Add timestamp */#ifdef __DATE__ " on " __DATE__#ifdef __TIME__ " at " __TIME__#endif#endif ".\n", "", liblvlmsg ); (*G.message)((zvoid *)&G, slide, (ulg)len, 0);} /* end function version() */#endif /* !SFX */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -