?? filedate.c
字號:
*ptr = strlen(fib->fib_FileName); FreeMem(fib,(long)sizeof(*fib)); UnLock(lock); /* now fill in argument array */ pktargs[0] = 0; pktargs[1] = (LONG)dirlock; pktargs[2] = (LONG)&ptr[0] >> 2; pktargs[3] = (LONG)&pDate; errno = ret = sendpkt(taskport,ACTION_SET_DATE,pktargs,4L); FreeMem(ptr,64L); UnLock(dirlock); return SUCCESS; } /* ?(SysBase->lib_Version >= ReqVers) */} /* FileDate() */char *getenv(const char *var) /* not reentrant! */{ static char space[ENVSIZE]; struct Process *me = (void *) FindTask(NULL); void *old_window = me->pr_WindowPtr; char *ret = NULL; me->pr_WindowPtr = (void *) -1; /* suppress any "Please insert" popups */ if (SysBase->LibNode.lib_Version >= ReqVers) { if (GetVar((char *) var, space, ENVSIZE - 1, /*GVF_GLOBAL_ONLY*/ 0) > 0) ret = space; } else { /* early AmigaDOS, get env var the crude way */ BPTR hand, foot, spine; int z = 0; if (foot = Lock("ENV:", ACCESS_READ)) { spine = CurrentDir(foot); if (hand = Open((char *) var, MODE_OLDFILE)) { z = Read(hand, space, ENVSIZE - 1); Close(hand); } UnLock(CurrentDir(spine)); } if (z > 0) { space[z] = '\0'; ret = space; } } me->pr_WindowPtr = old_window; return ret;}#ifdef __SASCint setenv(const char *var, const char *value, int overwrite){ struct Process *me = (void *) FindTask(NULL); void *old_window = me->pr_WindowPtr; int ret = -1; me->pr_WindowPtr = (void *) -1; /* suppress any "Please insert" popups */ if (SysBase->LibNode.lib_Version >= ReqVers) ret = !SetVar((char *)var, (char *)value, -1, GVF_GLOBAL_ONLY | LV_VAR); else { BPTR hand, foot, spine; long len = value ? strlen(value) : 0; if (foot = Lock("ENV:", ACCESS_READ)) { spine = CurrentDir(foot); if (len) { if (hand = Open((char *) var, MODE_NEWFILE)) { ret = Write(hand, (char *) value, len + 1) >= len; Close(hand); } } else ret = DeleteFile((char *) var); UnLock(CurrentDir(spine)); } } me->pr_WindowPtr = old_window; return ret;}/* Stores data from timezone and daylight to ENV:TZ. *//* ENV:TZ is required to exist by some other SAS/C library functions, *//* like stat() or fstat(). */void set_TZ(long time_zone, int day_light){ char put_tz[MAXTIMEZONELEN]; /* string for putenv: "TZ=aaabbb:bb:bbccc" */ int offset; void *exists; /* dummy ptr to see if global envvar TZ already exists */ exists = (void *)getenv(TZ_ENVVAR); /* see if there is already an envvar TZ_ENVVAR. If not, create it */ if (exists == NULL) { /* create TZ string by pieces: */ sprintf(put_tz, "GMT%+ld", time_zone / 3600L); if (time_zone % 3600L) { offset = (int) labs(time_zone % 3600L); sprintf(put_tz + strlen(put_tz), ":%02d", offset / 60); if (offset % 60) sprintf(put_tz + strlen(put_tz), ":%02d", offset % 60); } if (day_light) strcat(put_tz,"DST"); setenv(TZ_ENVVAR, put_tz, 1); }}#endif /* __SASC *//* set state as well as possible from settings found in locale.library */int GetPlatformLocalTimezone(sp, fill_tzstate_from_rules) register struct state * ZCONST sp; void (*fill_tzstate_from_rules)(struct state * ZCONST sp_res, ZCONST struct rule * ZCONST start, ZCONST struct rule * ZCONST end);{ struct Library *LocaleBase; struct Locale *ll; struct Process *me = (void *) FindTask(NULL); void *old_window = me->pr_WindowPtr; BPTR eh; int z, valid = FALSE; /* read timezone from locale.library if TZ envvar missing */ me->pr_WindowPtr = (void *) -1; /* suppress any "Please insert" popups */ if (LocaleBase = OpenLibrary("locale.library", 0)) { if (ll = OpenLocale(NULL)) { z = ll->loc_GMTOffset; /* in minutes */ if (z == -300) { if (eh = Lock("ENV:sys/locale.prefs", ACCESS_READ)) { UnLock(eh); valid = TRUE; } else z = 300; /* bug: locale not initialized, default bogus! */ } else valid = TRUE; if (valid) { struct rule startrule, stoprule; sp->timecnt = 0; sp->typecnt = 1; sp->charcnt = 2; sp->chars[0] = sp->chars[1] = '\0'; sp->ttis[0].tt_abbrind = 0; sp->ttis[1].tt_abbrind = 1; sp->ttis[0].tt_gmtoff = -z * MINSPERHOUR; sp->ttis[1].tt_gmtoff = -z * MINSPERHOUR + SECSPERHOUR; sp->ttis[0].tt_isdst = 0; sp->ttis[1].tt_isdst = 1; stoprule.r_type = MONTH_NTH_DAY_OF_WEEK; stoprule.r_day = 0; stoprule.r_week = 5; stoprule.r_mon = 10; stoprule.r_time = 2 * SECSPERHOUR; startrule = stoprule; startrule.r_mon = 4; startrule.r_week = 1; if (z >= -180 && z < 150) { /* At this point we make a really gratuitous assumption: */ /* if the time zone could be Europe, we use the European */ /* Union rules without checking what country we're in. */ /* The AmigaDOS locale country codes do not, at least in */ /* 2.x versions of the OS, recognize very many countries */ /* outside of Europe and North America. */ sp->typecnt = 2; startrule.r_mon = 3; /* one week earlier than US DST */ startrule.r_week = 5; } else if (z >= 150 && z <= 480 && /* no DST in alaska, hawaii */ (ll->loc_CountryCode == 0x55534100 /*"USA"*/ || ll->loc_CountryCode == 0x43414E00 /*"CAN"*/)) sp->typecnt = 2; /* We check the country code for U.S. or Canada because */ /* most of Latin America has no DST. Even in these two */ /* countries there are some exceptions... */ /* else if... Feel free to add more cases here! */ if (sp->typecnt > 1) (*fill_tzstate_from_rules)(sp, &startrule, &stoprule); } CloseLocale(ll); } CloseLibrary(LocaleBase); } me->pr_WindowPtr = old_window; return valid;}#ifdef ZIPtime_t time(time_t *tp){ time_t t; struct DateStamp ds; DateStamp(&ds); t = ds.ds_Tick / TICKS_PER_SECOND + ds.ds_Minute * 60 + (ds.ds_Days + 2922) * SECSPERDAY; t = mktime(gmtime(&t)); /* gmtime leaves ds in the local timezone, mktime converts it to GMT */ if (tp) *tp = t; return t;}#endif /* ZIP */#endif /* !FUNZIP && !UTIL */#if CRYPT || !defined(FUNZIP)/* sendpkt.c * by A. Finkel, P. Lindsay, C. Sheppner * returns Res1 of the reply packet *//*#include <exec/types.h>#include <exec/memory.h>#include <libraries/dos.h>#include <libraries/dosextens.h>#include <proto/exec.h>#include <proto/dos.h>*/LONG sendpkt(struct MsgPort *pid, LONG action, LONG *args, LONG nargs);LONG sendpkt(pid,action,args,nargs)struct MsgPort *pid; /* process identifier (handler message port) */LONG action, /* packet type (desired action) */ *args, /* a pointer to argument list */ nargs; /* number of arguments in list */{ struct MsgPort *replyport, *CreatePort(UBYTE *, long); void DeletePort(struct MsgPort *); struct StandardPacket *packet; LONG count, *pargs, res1; replyport = CreatePort(NULL,0L); if( !replyport ) return(0); packet = (struct StandardPacket *)AllocMem( (long)sizeof(struct StandardPacket),MEMF_PUBLIC|MEMF_CLEAR); if( !packet ) { DeletePort(replyport); return(0); } packet->sp_Msg.mn_Node.ln_Name = (char *)&(packet->sp_Pkt); packet->sp_Pkt.dp_Link = &(packet->sp_Msg); packet->sp_Pkt.dp_Port = replyport; packet->sp_Pkt.dp_Type = action; /* copy the args into the packet */ pargs = &(packet->sp_Pkt.dp_Arg1); /* address of 1st argument */ for( count=0; count<nargs; count++ ) pargs[count] = args[count]; PutMsg(pid,(struct Message *)packet); /* send packet */ WaitPort(replyport); GetMsg(replyport); res1 = packet->sp_Pkt.dp_Res1; FreeMem((char *)packet,(long)sizeof(*packet)); DeletePort(replyport); return(res1);} /* sendpkt() */#endif /* CRYPT || !FUNZIP */#if CRYPT || (defined(UNZIP) && !defined(FUNZIP))/* Agetch() reads one raw keystroke -- uses sendpkt() */int Agetch(void){ LONG sendpkt(struct MsgPort *pid, LONG action, LONG *args, LONG nargs); struct Task *me = FindTask(NULL); struct CommandLineInterface *cli = BADDR(((struct Process *) me)->pr_CLI); BPTR fh = cli->cli_StandardInput; /* this is immune to < redirection */ void *conp = ((struct FileHandle *) BADDR(fh))->fh_Type; char longspace[8]; long *flag = (long *) ((ULONG) &longspace[4] & ~3); /* LONGWORD ALIGNED! */ UBYTE c; *flag = 1; sendpkt(conp, ACTION_SCREEN_MODE, flag, 1); /* assume success */ Read(fh, &c, 1); *flag = 0; sendpkt(conp, ACTION_SCREEN_MODE, flag, 1); if (c == 3) /* ^C in input */ Signal(me, SIGBREAKF_CTRL_C); return c;}#endif /* CRYPT || (UNZIP && !FUNZIP) */#endif /* __amiga_filedate_c*/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -