📄 aosvs.c
字号:
#ifndef SFX/************************//* Function version() *//************************/void version(__G) __GDEF{#if defined(CRAY) || defined(NX_CURRENT_COMPILER_RELEASE) || defined(NetBSD) char buf1[40];#if defined(CRAY) || defined(NX_CURRENT_COMPILER_RELEASE) char buf2[40];#endif#endif /* Pyramid, NeXT have problems with huge macro expansion, too: no Info() */ sprintf((char *)slide, LoadFarString(CompiledWith),#ifdef __GNUC__# ifdef NX_CURRENT_COMPILER_RELEASE (sprintf(buf1, "NeXT DevKit %d.%02d ", NX_CURRENT_COMPILER_RELEASE/100, NX_CURRENT_COMPILER_RELEASE%100), buf1), (strlen(__VERSION__) > 8)? "(gcc)" : (sprintf(buf2, "(gcc %s)", __VERSION__), buf2),# else "gcc ", __VERSION__,# endif#else# if defined(CRAY) && defined(_RELEASE) "cc ", (sprintf(buf1, "version %d", _RELEASE), buf1),# else# ifdef __VERSION__ "cc ", __VERSION__,# else "cc", "",# endif# endif#endif "Unix",#if defined(sgi) || defined(__sgi) " (Silicon Graphics IRIX)",#else#ifdef sun# ifdef sparc# ifdef __SVR4 " (Sun Sparc/Solaris)",# else /* may or may not be SunOS */ " (Sun Sparc)",# endif# else# if defined(sun386) || defined(i386) " (Sun 386i)",# else# if defined(mc68020) || defined(__mc68020__) " (Sun 3)",# else /* mc68010 or mc68000: Sun 2 or earlier */ " (Sun 2)",# endif# endif# endif#else#ifdef __hpux " (HP/UX)",#else#ifdef __osf__ " (DEC OSF/1)",#else#ifdef _AIX " (IBM AIX)",#else#ifdef aiws " (IBM RT/AIX)",#else#if defined(CRAY) || defined(cray)# ifdef _UNICOS (sprintf(buf2, " (Cray UNICOS release %d)", _UNICOS), buf2),# else " (Cray UNICOS)",# endif#else#if defined(uts) || defined(UTS) " (Amdahl UTS)",#else#ifdef NeXT# ifdef mc68000 " (NeXTStep/black)",# else " (NeXTStep for Intel)",# endif#else /* the next dozen or so are somewhat order-dependent */#ifdef LINUX# ifdef __ELF__ " (Linux ELF)",# else " (Linux a.out)",# endif#else#ifdef MINIX " (Minix)",#else#ifdef M_UNIX " (SCO Unix)",#else#ifdef M_XENIX " (SCO Xenix)",#else#ifdef __NetBSD__# ifdef NetBSD0_8 (sprintf(buf1, " (NetBSD 0.8%c)", (char)(NetBSD0_8 - 1 + 'A')), buf1),# else# ifdef NetBSD0_9 (sprintf(buf1, " (NetBSD 0.9%c)", (char)(NetBSD0_9 - 1 + 'A')), buf1),# else# ifdef NetBSD1_0 (sprintf(buf1, " (NetBSD 1.0%c)", (char)(NetBSD1_0 - 1 + 'A')), buf1),# else (BSD4_4 == 0.5)? " (NetBSD before 0.9)" : " (NetBSD 1.1 or later)",# endif# endif# endif#else#ifdef __FreeBSD__ (BSD4_4 == 0.5)? " (FreeBSD 1.x)" : " (FreeBSD 2.0 or later)",#else#ifdef __bsdi__ (BSD4_4 == 0.5)? " (BSD/386 1.0)" : " (BSD/386 1.1 or later)",#else#ifdef __386BSD__ (BSD4_4 == 1)? " (386BSD, post-4.4 release)" : " (386BSD)",#else#if defined(i486) || defined(__i486) || defined(__i486__) " (Intel 486)",#else#if defined(i386) || defined(__i386) || defined(__i386__) " (Intel 386)",#else#ifdef pyr " (Pyramid)",#else#ifdef ultrix# ifdef mips " (DEC/MIPS)",# else# ifdef vax " (DEC/VAX)",# else /* __alpha? */ " (DEC/Alpha)",# endif# endif#else#ifdef gould " (Gould)",#else#ifdef MTS " (MTS)",#else#ifdef __convexc__ " (Convex)",#else "",#endif /* Convex */#endif /* MTS */#endif /* Gould */#endif /* DEC */#endif /* Pyramid */#endif /* 386 */#endif /* 486 */#endif /* 386BSD */#endif /* BSDI BSD/386 */#endif /* NetBSD */#endif /* FreeBSD */#endif /* SCO Xenix */#endif /* SCO Unix */#endif /* Minix */#endif /* Linux */#endif /* NeXT */#endif /* Amdahl */#endif /* Cray */#endif /* RT/AIX */#endif /* AIX */#endif /* OSF/1 */#endif /* HP/UX */#endif /* Sun */#endif /* SGI */#ifdef __DATE__ " on ", __DATE__#else "", ""#endif ); (*G.message)((zvoid *)&G, slide, (ulg)strlen((char *)slide), 0);} /* end function version() */#endif /* !SFX *//* =================================================================== * ZVS_CREATE() * Function to create a file with specified times. The times should be sent * as long ints in DG time format; use -1 to set to the current times. You * may also specify a pointer to the ACL, the file type (see PARU.H, and do * not specify dirs or links), the element size, and the max index level. * For all of these parameters you may use -1 to specify the default. * * Returns 0 if no error, or the error code returned by ?CREATE. * * HISTORY: * 15-dec-93 dbl * 31-may-94 dbl: added call to convert pathname to AOS/VS * * */int zvs_create(ZCONST char *fname, long cretim, long modtim, long acctim, char *pacl, int ftyp, int eltsize, int maxindlev){ P_CREATE pcr_stru; P_CTIM pct_stru; pcr_stru.cftyp_format = 0; /* unspecified record format */ if (ftyp == -1) /* default file type to UNX */ pcr_stru.cftyp_entry = $FUNX; else pcr_stru.cftyp_entry = ftyp; pcr_stru.ctim = &pct_stru; pcr_stru.cacp = pacl; pcr_stru.cdel = eltsize; pcr_stru.cmil = maxindlev; pct_stru.tcth.long_time = cretim; pct_stru.tath.long_time = acctim; pct_stru.tmth.long_time = modtim; return (sys_create(ux_to_vs_name(Vs_path, fname), &pcr_stru));} /* end zvs_create() *//* =================================================================== * ZVS_CREDIR() * Function to create a dir as specified. The times should be sent * as long ints in DG time format; use -1 to set to the current times. You * may also specify a pointer to the ACL, the file type (either $FDIR or $FCPD; see PARU.H), * the max # blocks (if a CPD), the hash frame size, and the max index level. * For all of these parameters (except for the CPD's maximum blocks), * you may use -1 to specify the default. * * (The System Call Dictionary says both that you may specify a * maximum-index-level value up to the maximum, with 0 for a contiguous * directory, and that 3 is always used for this whatever you specify.) * * If you specify anything other than CPD for the file type, DIR will * be used. * * Returns 0 if no error, or the error code returned by ?CREATE. * * HISTORY: * 1-jun-94 dbl * * */int zvs_credir(ZCONST char *dname, long cretim, long modtim, long acctim, char *pacl, int ftyp, long maxblocks, int hashfsize, int maxindlev){ P_CREATE_DIR pcr_stru; P_CTIM pct_stru; if (ftyp != $FCPD) /* default file type to UNX */ pcr_stru.cftyp_entry = $FDIR; else { pcr_stru.cftyp_entry = ftyp; pcr_stru.cmsh = maxblocks; } pcr_stru.ctim = &pct_stru; pcr_stru.cacp = pacl; pcr_stru.chfs = hashfsize; pcr_stru.cmil = maxindlev; pct_stru.tcth.long_time = cretim; pct_stru.tath.long_time = acctim; pct_stru.tmth.long_time = modtim; return (sys_create(ux_to_vs_name(Vs_path, dname), &pcr_stru));} /* end zvs_credir() *//* =================================================================== * UX_TO_VS_NAME() - makes a somewhat dumb pass at converting a Unix * filename to an AOS/VS filename. This should * be just about adequate to handle the results * of similarly-simple AOS/VS-to-Unix conversions * in the ZIP program. It does not guarantee a * legal AOS/VS filename for every Unix filename; * conspicuous examples would be names with * embedded ./ and ../ (which will receive no * special treatment). * * RETURNS: pointer to the result (which is an input parameter) * * NOTE: calling code is responsible for making sure * the output buffer is big enough! * * HISTORY: * 31-may-94 dbl * */char *ux_to_vs_name(char *outname, ZCONST char *inname){ ZCONST char *ip=inname, *op=outname; if (ip[0] == '.') { if (ip[1] == '/') { *(op++) = '='; ip += 2; } else if (ip[1] == '.' && ip[2] == '/') { *(op++) = '^'; ip += 3; } } do { if (*ip == '/') *(op++) = ':'; else if (strchr( "0123456789_$?.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", *ip) != NULL) { *(op++) = *ip; } else *(op++) = '?'; } while (*(ip++) != '\0'); return outname;} /* end ux_to_vs_name() *//* =================================================================== *//* DGDATE Two functions do encode/decode dates in DG system format. Usage: long value,year,month,day; value=dgdate(month,day,year); undgdate(value,&month,&day,&year); [GRR: not used in UnZip: removed] Notes: 1. DG date functions only work on dates within the range Jan 1, 1968 through Dec 31, 2099. I have tested these functions through the same range with exact agreement. For dates outside of that range, the DG system calls may return different values than these functions. 2. dgundate() accepts values between 0 and 48213 inclusive. These correspond to 12/31/1967 and 12/31/2099. 3. Both functions assume the data is in the native OS byte order. So if you're reading or writing these fields from a file that has been passed between AOS/VS and PC-DOS you will need to swap byte order. 4. With reference to byte order, the entire range of values supported by these functions will fit into an unsigned short int. In most cases the input or output will be in that variable type. You are better off casting the value to/from unsigned short so you only need to concern yourself with swapping two bytes instead of four. Written by: Stanley J. Gula US&T, Inc. 529 Main Street, Suite 1 Indian Orchard, MA 01151 (413)-543-3672 Copyright (c) 1990 US&T, Inc. All rights reserved. I hereby release these functions into the public domain. You may use these routines freely as long as the US&T copyright remains intact in the source code. Stanley J. Gula July 24, 1990*/long motable[13]={0,31,59,90,120,151,181,212,243,273,304,334,365};long yrtable[132]={ 366, 731, 1096, 1461, 1827, 2192, 2557, 2922, 3288, 3653, 4018, 4383, 4749, 5114, 5479, 5844, 6210, 6575, 6940, 7305, 7671, 8036, 8401, 8766, 9132, 9497, 9862,10227,10593,10958, 11323,11688,12054,12419,12784,13149,13515,13880,14245,14610, 14976,15341,15706,16071,16437,16802,17167,17532,17898,18263, 18628,18993,19359,19724,20089,20454,20820,21185,21550,21915, 22281,22646,23011,23376,23742,24107,24472,24837,25203,25568, 25933,26298,26664,27029,27394,27759,28125,28490,28855,29220, 29586,29951,30316,30681,31047,31412,31777,32142,32508,32873, 33238,33603,33969,34334,34699,35064,35430,35795,36160,36525, 36891,37256,37621,37986,38352,38717,39082,39447,39813,40178, 40543,40908,41274,41639,42004,42369,42735,43100,43465,43830, 44196,44561,44926,45291,45657,46022,46387,46752,47118,47483, 47848,48213};/* Given y,m,d return # of days since 12/31/67 */long int dgdate(short mm, short dd, short yy){ long int temp; short ytmp; if (mm<1 || mm>12 || dd<1 || dd>31 || yy<1968 || yy>2099) return 0L; /* Figure in whole years since 1968 + whole months plus days */ temp=365L*(long)(yy-1968) + motable[mm-1] + (long)dd; /* Adjust for leap years - note we don't account for skipped leap year in years divisible by 1000 but not by 4000. We're correct through the year 2099 */ temp+=(yy-1965)/4; /* Correct for this year */ /* In leap years, if date is 3/1 or later, bump */ if ((yy%4==0) && (mm>2)) temp++; return temp;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -