home *** CD-ROM | disk | FTP | other *** search
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- #include <time.h>
- #include "cus.h"
- #include "defines.h"
- #include "lbio.h"
- #include "proto.h"
- #include "status.h"
-
- /*
- [...]
-
- The second field (Any in the examples above) has been implemented
- for 1.06D and beyond. There are no spaces anywhere in the field:
-
- Any the system can be called at any time
-
- Never the system can never be calleod
-
- hh:mm-hh:mm any day in the hour range indicated (24hr time)
-
- MoTuWeThFrSaSuhh:mm-hh:mm
- On the days indicated in the hour range indicated.
-
- <timespec>,<timespec>
- MoTuWeThFr02:00-03:00,SaSu00:00-23:59
- On the days indicated in the hour range indicated,
- time specs separated by commas.
- [...]
- */
-
- struct time {
- int hour;
- int min;
- };
-
- struct date {
- int year;
- int month;
- int day;
- int dow;
- struct time time;
- };
-
- #define DAYMINS (24*60)
- #define DAYSECS (DAYMINS * 60)
- #define WEEKMINS (DAYMINS*7)
-
- #define MOW_FORBIDDEN 0
- #define MOW_PERMITTED 1
- #define MOW_ACTIVETIMES 2
- #define MOW_CURRENTTIME 3
-
- struct TimeInfo {
- struct {
- int type;
- struct date from;
- struct date to;
- struct time total;
- struct time remain;
- } active;
- struct {
- int type;
- struct date from;
- struct date to;
- struct time total;
- struct time in;
- } next;
- int aMOW[WEEKMINS];
- };
-
- #define WEEKDAY_NUM 7
- #define WDAYNAME_NUM WEEKDAY_NUM
- #define WDAYNAME_LEN1 2
-
- static char wday_name1[WDAYNAME_NUM][WDAYNAME_LEN1+1] = {
- "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"
- };
-
- #define SUN 0
- #define SAT 6
-
- /* time interval times */
- #define TYPE_ACTIVE_SPECIFIC 1
- #define TYPE_ACTIVE_NOTCURRENTLY 2
- #define TYPE_ACTIVE_ALWAYS 3
- #define TYPE_ACTIVE_NEVER 4
- #define TYPE_NEXT_SPECIFIC 5
- #define TYPE_NEXT_ALWAYS 6
- #define TYPE_NEXT_NEVER 7
-
- #define TYPESTR_ACTIVE_NOTCURRENTLY "-no one currently-"
- #define TYPESTR_ACTIVE_ALWAYS "-always-"
- #define TYPESTR_ACTIVE_NEVER "-never-"
- #define TYPESTR_NEXT_ALWAYS "-always-"
- #define TYPESTR_NEXT_NEVER "-never-"
-
- #define MODE_FIRST 1
- #define MODE_ANOTHER 2
-
-
- static void setti(struct TimeInfo *ti, char *timeentry, int mode)
- {
- static time_t t;
- time_t tTMP1, tTMP2;
- struct tm *tm;
- int i,j;
- int nTok;
- char **cppTok;
- char *cp;
- unsigned int days, mincnt, days_o;
- int sh, sm, eh, em, et, st, ct;
- int s_active, e_active, s_next, e_next;
-
-
- if (mode == MODE_FIRST)
- time(&t);
- tm = localtime(&t);
-
- if (mode == MODE_FIRST) {
- for (i=0; i < WEEKMINS; i++)
- ti->aMOW[i] = MOW_FORBIDDEN;
- }
- else
- for (i=0; i < WEEKMINS; i++) {
- if (ti->aMOW[i] == MOW_ACTIVETIMES)
- ti->aMOW[i] = MOW_PERMITTED;
-
- if (ti->aMOW[i] == MOW_CURRENTTIME)
- if (ti->active.type == TYPE_ACTIVE_SPECIFIC ||
- ti->active.type == TYPE_ACTIVE_ALWAYS )
- ti->aMOW[i] = MOW_PERMITTED;
- else
- ti->aMOW[i] = MOW_FORBIDDEN;
- }
-
-
- if ((nTok = tokenize(&cppTok, timeentry, strlen(timeentry), ",")) != 0) {
- while(*cppTok != NULL) {
- cp = *cppTok++;
-
- if (strcmpi("Never", cp) == 0) {
- if (mode == MODE_FIRST)
- for (i=0; i < WEEKMINS; i++)
- ti->aMOW[i] = MOW_FORBIDDEN;
- continue;
- }
-
- if (strcmpi("Any", cp) == 0) {
- for (i=0; i < WEEKMINS; i++)
- ti->aMOW[i] = MOW_PERMITTED;
- continue;
- }
-
- days = 0;
- while(isalpha(*cp)) {
- for (i = 0; i < WDAYNAME_NUM; i++) {
- if (strnicmp(cp, wday_name1[i], WDAYNAME_LEN1) == 0) {
- days |= 1L << i;
- cp += 2;
- }
- }
- }
- if (days == 0) /* not specifying a day explicitely */
- days = ~0; /* means the whole week */
-
- if (sscanf(cp, "%d:%d-%d:%d", &sh, &sm, &eh, &em) != 4)
- continue;
-
- st = sh*60+sm;
- et = eh*60+em;
-
- if (et < st) { /* if the interval goes through 00:00 */
- /* we split it up into two peaces */
- /* select all following days */
- days_o = days << 1;
- if (days_o & (1L << (SAT+1)))
- days_o = ((days_o & ~(1L << (SAT+1))) | (1L << SUN));
-
- for (i = 0; i < WDAYNAME_NUM; i++)
- if (days_o & (1L << i))
- for (j = 0; j < et; j++)
- ti->aMOW[i*DAYMINS+j] = MOW_PERMITTED;
- eh = 24;
- em = 0;
- et = sh*60+sm;
- }
-
- for (i = 0; i < WDAYNAME_NUM; i++)
- if (days & (1L << i))
- for (j = st; j < et; j++)
- ti->aMOW[i*DAYMINS+j] = MOW_PERMITTED;
- }
- }
-
- ct = tm->tm_wday * DAYMINS + tm->tm_hour * 60 + tm->tm_min;
-
- if (ti->aMOW[ct] != MOW_PERMITTED) {
- ti->active.type = TYPE_ACTIVE_NOTCURRENTLY;
- }
- else {
-
- i = ct;
- j = (i-1 < 0) ? WEEKMINS-1 : i-1;
- mincnt = 0;
- while( ti->aMOW[i] == MOW_PERMITTED
- && ti->aMOW[j] == MOW_PERMITTED
- && mincnt < WEEKMINS ) {
- ++mincnt;
- i = (i-1 < 0) ? WEEKMINS-1 : i-1;
- j = (i-1 < 0) ? WEEKMINS-1 : i-1;
- }
- s_active = ct - mincnt;
- if (mincnt >= WEEKMINS) {
- ti->active.type = TYPE_ACTIVE_ALWAYS;
- }
- else {
- ti->active.type = TYPE_ACTIVE_SPECIFIC;
- tTMP1 = t - mincnt * 60;
- tm = localtime(&tTMP1);
- ti->active.from.year = tm->tm_year;
- ti->active.from.month = tm->tm_mon+1;
- ti->active.from.day = tm->tm_mday;
- ti->active.from.dow = tm->tm_wday;
- ti->active.from.time.hour = tm->tm_hour;
- ti->active.from.time.min = tm->tm_min;
-
- mincnt = 0;
- i = ct;
- while( ti->aMOW[i] == MOW_PERMITTED
- && mincnt < WEEKMINS ) {
- ++mincnt;
- i = (i + 1) % WEEKMINS;
- }
- e_active = ct + mincnt;
- tTMP2 = t + mincnt * 60;
- tm = localtime(&tTMP2);
- ti->active.to.year = tm->tm_year;
- ti->active.to.month = tm->tm_mon+1;
- ti->active.to.day = tm->tm_mday;
- ti->active.to.dow = tm->tm_wday;
- ti->active.to.time.hour = tm->tm_hour;
- ti->active.to.time.min = tm->tm_min;
-
- ti->active.total.hour = ((tTMP2-tTMP1) / 60) / 60;
- ti->active.total.min = ((tTMP2-tTMP1) / 60) % 60;
- ti->active.remain.hour = ((tTMP2-t) / 60) / 60;
- ti->active.remain.min = ((tTMP2-t) / 60) % 60;
- }
- }
-
- if (ti->active.type == TYPE_ACTIVE_ALWAYS) {
- ti->next.type = TYPE_NEXT_ALWAYS;
- }
- else {
- i = (ct + (ti->active.type == TYPE_ACTIVE_SPECIFIC ? mincnt : 0)) % WEEKMINS;
- mincnt = 0;
- while( ti->aMOW[i] == MOW_FORBIDDEN
- && mincnt < WEEKMINS ) {
- ++mincnt;
- i = (i + 1) % WEEKMINS;
- }
- if (mincnt >= WEEKMINS) {
- ti->next.type = TYPE_NEXT_NEVER;
- ti->active.type = TYPE_ACTIVE_NEVER;
- }
- else {
- ti->next.type = TYPE_NEXT_SPECIFIC;
- s_next = i;
- tTMP1 = (ti->active.type == TYPE_ACTIVE_SPECIFIC ? tTMP2 : t) + mincnt * 60;
- tm = localtime(&tTMP1);
- ti->next.from.year = tm->tm_year;
- ti->next.from.month = tm->tm_mon+1;
- ti->next.from.day = tm->tm_mday;
- ti->next.from.dow = tm->tm_wday;
- ti->next.from.time.hour = tm->tm_hour;
- ti->next.from.time.min = tm->tm_min;
-
- mincnt = 0;
- while( ti->aMOW[i] == MOW_PERMITTED
- && mincnt < WEEKMINS ) {
- ++mincnt;
- i = (i + 1) % WEEKMINS;
- }
- e_next = i;
- tTMP2 = tTMP1 + mincnt * 60;
- tm = localtime(&tTMP2);
- ti->next.to.year = tm->tm_year;
- ti->next.to.month = tm->tm_mon+1;
- ti->next.to.day = tm->tm_mday;
- ti->next.to.dow = tm->tm_wday;
- ti->next.to.time.hour = tm->tm_hour;
- ti->next.to.time.min = tm->tm_min;
-
- ti->next.total.hour = ((tTMP2-tTMP1) / 60) / 60;
- ti->next.total.min = ((tTMP2-tTMP1) / 60) % 60;
- ti->next.in.hour = ((tTMP1-t) / 60) / 60;
- ti->next.in.min = ((tTMP1-t) / 60) % 60;
- }
- }
-
- if (ti->active.type == TYPE_ACTIVE_SPECIFIC) {
- if (s_active < e_active) {
- i = s_active;
- while(i < e_active) {
- ti->aMOW[i] = MOW_ACTIVETIMES;
- i = (i + 1) % WEEKMINS;
- }
- }
- }
- if (ti->active.type == TYPE_ACTIVE_ALWAYS) {
- for (i=0; i < WEEKMINS; i++)
- ti->aMOW[i] = MOW_ACTIVETIMES;
- }
-
- ti->aMOW[ct] = MOW_CURRENTTIME;
-
- return;
- }
-
-
- int calctimes(char *cpLsys, char *cpSystem, struct TimeInfo *ti)
- {
- int nTok;
- char **cppTok;
- int mode;
- int rc;
- FILE *fpLsys = NULL;
- char *cpBuf = NULL;
- long wLsys;
- LB *lb = NULL;
- char caTimeentry[256];
-
- if ((fpLsys = fopen(cpLsys, "r")) == NULL)
- CU(FALSE);
- if (fseek(fpLsys, 0L, SEEK_END) == -1L)
- CU(FALSE);
- if ((wLsys = ftell(fpLsys)) == -1L)
- CU(FALSE);
- if (fseek(fpLsys, 0L, SEEK_SET) == -1L)
- CU(FALSE);
- if ((cpBuf = (char *)malloc(wLsys)) == NULL)
- CU(FALSE);
- if ((fread(cpBuf, wLsys, 1, fpLsys) != 1) && ferror(fpLsys))
- CU(FALSE);
- if ((lb = lbopen(cpBuf, cpBuf + wLsys -1)) == NULL)
- CU(FALSE);
- if (lbseek(lb, 0, LBSEEK_SET) == NULL)
- CU(FALSE);
-
- mode = MODE_FIRST;
- do {
- if ((nTok = tokenize(&cppTok, lb->lb_cpLnCur, lb->lb_wLnCur, " ")) != 0) {
- if (nTok > 5) {
- if (stricmp(*(cppTok+0), cpSystem) == 0) {
- strcpy(caTimeentry, *(cppTok+1));
- setti(ti, caTimeentry, mode);
- mode = MODE_ANOTHER;
- }
- }
- }
- } while (lbseek(lb, 1, LBSEEK_CUR));
-
- rc = TRUE;
-
- CUS:
- if (lb)
- lbfree(lb);
- if (fpLsys)
- fclose(fpLsys);
- if (cpBuf)
- free(cpBuf);
- return rc;
- }
-
-
-
- /*
-
- UUPoll Host Status on angle Fri Jun 05 23:39:47 1992
-
- remote host : cyvaned [|] permitted times
- last polling : successful [.] forbidden times
-
- 55 .||||||..|..#####.||||||.||||||..|..|||||.||||||.||||||..|..|||||.||||||
- 50 .||||||..|..#####.||||||.||||||..|..|||||.||||||.||||||..|..|||||.||||||
- 45 .||||||..|..#####.||||||.||||||..|..|||||.||||||.||||||..|..|||||.||||||
- 40 .||||||..||.#####.||||||.||||||..||.|||||.||||||.||||||..||.|||||.||||||
- 35 .||||||..||.X####.||||||.||||||..||.|||||.||||||.||||||..||.|||||.||||||
- 30 .||||||..||.#####.||||||.||||||..||.|||||.||||||.||||||..||.|||||.||||||
- 25 ..|||||...|.#####.||||||..|||||...|.|||||.||||||..|||||...|.|||||.||||||
- 20 ..|||||...|.#####.||||||..|||||...|.|||||.||||||..|||||...|.|||||.||||||
- 15 ..|||||...|.#####.||||||..|||||...|.|||||.||||||..|||||...|.|||||.||||||
- 10 ..||.||...||#####.||||||..||.||...|||||||.||||||..||.||...|||||||.||||||
- 05 ..||.||...||#####.||||||..||.||...|||||||.||||||..||.||...|||||||.||||||
- 00 ..||.||...||#####.||||||..||.||...|||||||.||||||..||.||...|||||||.||||||
- ^
- 123456789012301234567890123456789012301234567890123456789012301234567890
- 2 Sat 1 2 Sun 1 2 Mon 1
-
- ACTIVE polling time intervall [#] NEXT polling time intervall
- from Fri/23:00 to Sat/04:00 from Sat/05:00 to Sat/11:00
- total time 05:00, remaining 04:21 total time 06:00, in 05:21
-
- */
-
- #define SCREEN_LINES 24
- #define SCREEN_COLS 76
-
- static char *cpaScreen[SCREEN_LINES] = {
-
- /* 0123456789012345678901234567890123456789012345678901234567890123456789012345678
- 0 1 2 3 4 5 6 7 */
-
- " UUPoll Host Status on XXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n", /* 00 */
- " \n", /* 01 */
- " remote host : XXXXXXXX [|] permitted times\n", /* 02 */
- " last polling : XXXXXXXXXX [.] forbidden times\n", /* 03 */
- " \n", /* 04 */
- " 55 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n", /* 05 */
- " 50 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n", /* 06 */
- " 45 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n", /* 07 */
- " 40 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n", /* 08 */
- " 35 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n", /* 09 */
- " 30 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n", /* 10 */
- " 25 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n", /* 11 */
- " 20 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n", /* 12 */
- " 15 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n", /* 13 */
- " 10 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n", /* 14 */
- " 05 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n", /* 15 */
- " 00 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n", /* 16 */
- " ^ \n", /* 17 */
- " aXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n", /* 18 */
- " bXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n", /* 19 */
- " \n", /* 20 */
- " ACTIVE polling time intervall [#] NEXT polling time intervall \n", /* 21 */
- " from XXX/XX:XX to XXX/XX:XX from XXX/XX:XX to XXX/XX:XX \n", /* 22 */
- " total time XX:XX, remaining XX:XX total time XX:XX, in XX:XX \n" /* 23 */
- };
-
- #define CHARTP_FORBIDDEN '.'
- #define CHARTP_PERMITTED '|'
- #define CHARTP_ACTIVETIMES '#'
- #define CHARTP_CURRENTTIME 'X'
-
- #define CHART_X0 4
- #define CHART_Y0 16
- #define CHART_XNUM 24*3
- #define CHART_YNUM 12
-
- char chart_map[CHART_XNUM][CHART_YNUM];
- char chart_xline1[CHART_XNUM];
- char chart_xline2[CHART_XNUM];
-
- #define LOCALHOSTFIELD "NodeName"
-
- #define WDAYNAME_LEN2 3
-
- static char wday_name2[WDAYNAME_NUM][WDAYNAME_LEN2+1] = {
- "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
- };
-
- void hostinfo(char *cpProgname, char *cpLsys, char *cpConfig, char *cpSystem, int mode)
- {
- int i;
- long t;
- struct tm *tm;
- char *cpTmp;
- char caTmp[128];
- char caTmp2[128];
- char *cpEnvvar;
- char caEnvname[256];
- struct TimeInfo *ti = NULL;
- int ch;
- int x,y;
- int h;
- char *cpXl1 = chart_xline1;
- char *cpXl2 = chart_xline2;
-
- if ((ti = (struct TimeInfo *)malloc(sizeof(struct TimeInfo))) == NULL)
- CU2();
-
- (void)time(&t);
- tm = localtime(&t);
-
- sprintf(caTmp, "%s", asctime(tm));
- caTmp[strlen(caTmp)-1] = NUL;
- if (mode == HOSTINFO_LONG)
- sprintf(caTmp2, "%38s", caTmp);
- else
- sprintf(caTmp2, "%-38s", caTmp);
- memcpy(cpaScreen[0]+38, caTmp2, strlen(caTmp2));
-
- if ((cpTmp = getfield(cpConfig, LOCALHOSTFIELD, caTmp)) == NULL)
- cpTmp = "-unknown-";
- else
- truncdomain(cpTmp);
- sprintf(caTmp2, "%-8s", cpTmp);
- memcpy(cpaScreen[0]+23, caTmp2, strlen(caTmp2));
-
- sprintf(caTmp, "%-8s", cpSystem);
- memcpy(cpaScreen[2]+16, caTmp, strlen(caTmp));
-
- sprintf(caEnvname, "%s.%s", cpProgname, cpSystem);
- if ((cpEnvvar = getenv(caEnvname)) == NULL) {
- cpTmp = "-unknown-";
- }
- else {
- sprintf(caTmp, "%s", strlwr(cpEnvvar));
- cpTmp = caTmp;
- }
- sprintf(caTmp2, "%-10s", cpTmp);
- memcpy(cpaScreen[3]+16, caTmp2, strlen(caTmp2));
-
- if (calctimes(cpLsys, cpSystem, ti)) {
-
- if (ti->active.type == TYPE_ACTIVE_SPECIFIC) {
- sprintf(caTmp, "%03s", wday_name2[ti->active.from.dow]);
- memcpy(cpaScreen[22]+6, caTmp, strlen(caTmp));
- sprintf(caTmp, "%02d:%02d", ti->active.from.time.hour, ti->active.from.time.min);
- memcpy(cpaScreen[22]+10, caTmp, strlen(caTmp));
- sprintf(caTmp, "%03s", wday_name2[ti->active.to.dow]);
- memcpy(cpaScreen[22]+19, caTmp, strlen(caTmp));
- sprintf(caTmp, "%02d:%02d", ti->active.to.time.hour, ti->active.to.time.min);
- memcpy(cpaScreen[22]+23, caTmp, strlen(caTmp));
-
- sprintf(caTmp, "%02d:%02d", ti->active.total.hour, ti->active.total.min);
- memcpy(cpaScreen[23]+12, caTmp, strlen(caTmp));
- sprintf(caTmp, "%02d:%02d", ti->active.remain.hour, ti->active.remain.min);
- memcpy(cpaScreen[23]+29, caTmp, strlen(caTmp));
- }
- else {
- for (i = 1; i < 34; i++) {
- *(cpaScreen[22]+i) = ' ';
- *(cpaScreen[23]+i) = ' ';
- }
- if (ti->active.type == TYPE_ACTIVE_NOTCURRENTLY)
- cpTmp = TYPESTR_ACTIVE_NOTCURRENTLY;
- if (ti->active.type == TYPE_ACTIVE_ALWAYS)
- cpTmp = TYPESTR_ACTIVE_ALWAYS;
- if (ti->active.type == TYPE_ACTIVE_NEVER)
- cpTmp = TYPESTR_ACTIVE_NEVER;
- memcpy(cpaScreen[22]+1, cpTmp, strlen(cpTmp));
- }
-
- if (ti->next.type == TYPE_NEXT_SPECIFIC) {
- sprintf(caTmp, "%03s", wday_name2[ti->next.from.dow]);
- memcpy(cpaScreen[22]+43, caTmp, strlen(caTmp));
- sprintf(caTmp, "%02d:%02d", ti->next.from.time.hour, ti->next.from.time.min);
- memcpy(cpaScreen[22]+47, caTmp, strlen(caTmp));
- sprintf(caTmp, "%03s", wday_name2[ti->next.to.dow]);
- memcpy(cpaScreen[22]+56, caTmp, strlen(caTmp));
- sprintf(caTmp, "%02d:%02d", ti->next.to.time.hour, ti->next.to.time.min);
- memcpy(cpaScreen[22]+60, caTmp, strlen(caTmp));
-
- sprintf(caTmp, "%02d:%02d", ti->next.total.hour, ti->next.total.min);
- memcpy(cpaScreen[23]+49, caTmp, strlen(caTmp));
- sprintf(caTmp, "%02d:%02d", ti->next.in.hour, ti->next.in.min);
- memcpy(cpaScreen[23]+59, caTmp, strlen(caTmp));
- }
- else {
- for (i = 38; i < 65; i++) {
- *(cpaScreen[22]+i) = ' ';
- *(cpaScreen[23]+i) = ' ';
- }
-
- if (ti->next.type == TYPE_NEXT_ALWAYS)
- cpTmp = TYPESTR_NEXT_ALWAYS;
- if (ti->next.type == TYPE_NEXT_NEVER)
- cpTmp = TYPESTR_NEXT_NEVER;
- memcpy(cpaScreen[22]+38, cpTmp, strlen(cpTmp));
- }
-
-
- if (mode == HOSTINFO_LONG) {
- (void)time(&t);
- tm = localtime(&t);
-
- for (i=0; i < CHART_XNUM; i++) {
- cpXl1[i] = ' ';
- cpXl2[i] = ' ';
- }
-
- ch = tm->tm_wday * 24 + tm->tm_hour - 12;
- if (ch < 0)
- ch = WEEKDAY_NUM*24 - abs(ch);
-
- for (x=0; x < CHART_XNUM; x++) {
-
- h = ch % 24;
- cpXl1[x] = ('0' + (h % 10));
- if ((h % 10) == 0) {
- if ((h / 10) != 0) {
- cpXl2[x] = ('0' + (h / 10));
- }
- else {
- if (x + WDAYNAME_LEN2 <= CHART_XNUM) {
- memcpy(&cpXl2[x], wday_name2[ch / 24], WDAYNAME_LEN2);
- }
- }
- }
-
- for (y=0; y < CHART_YNUM; y++) {
-
- if (ti->aMOW[ch*60+y*5+0] == MOW_FORBIDDEN ||
- ti->aMOW[ch*60+y*5+1] == MOW_FORBIDDEN ||
- ti->aMOW[ch*60+y*5+2] == MOW_FORBIDDEN ||
- ti->aMOW[ch*60+y*5+3] == MOW_FORBIDDEN ||
- ti->aMOW[ch*60+y*5+4] == MOW_FORBIDDEN ) {
- chart_map[x][y] = CHARTP_FORBIDDEN;
- }
-
- if (ti->aMOW[ch*60+y*5+1] == MOW_PERMITTED &&
- ti->aMOW[ch*60+y*5+2] == MOW_PERMITTED &&
- ti->aMOW[ch*60+y*5+3] == MOW_PERMITTED ) {
- chart_map[x][y] = CHARTP_PERMITTED;
- }
-
- if (ti->aMOW[ch*60+y*5+1] == MOW_ACTIVETIMES &&
- ti->aMOW[ch*60+y*5+2] == MOW_ACTIVETIMES &&
- ti->aMOW[ch*60+y*5+3] == MOW_ACTIVETIMES ) {
- chart_map[x][y] = CHARTP_ACTIVETIMES;
- }
-
- if (ti->aMOW[ch*60+y*5+0] == MOW_CURRENTTIME ||
- ti->aMOW[ch*60+y*5+1] == MOW_CURRENTTIME ||
- ti->aMOW[ch*60+y*5+2] == MOW_CURRENTTIME ||
- ti->aMOW[ch*60+y*5+3] == MOW_CURRENTTIME ||
- ti->aMOW[ch*60+y*5+4] == MOW_CURRENTTIME ) {
- chart_map[x][y] = CHARTP_CURRENTTIME;
- }
- }
-
- ch = (ch + 1) % (WEEKDAY_NUM * 24);
- }
-
- for (x=0; x < CHART_XNUM; x++) {
- *(cpaScreen[CHART_Y0+2]+CHART_X0+x) = *(cpXl1+x);
- *(cpaScreen[CHART_Y0+3]+CHART_X0+x) = *(cpXl2+x);
-
- for (y=0; y < CHART_YNUM; y++)
- *(cpaScreen[CHART_Y0-y]+CHART_X0+x) = chart_map[x][y];
- }
-
- }
- else {
- for (i = 57; i < 76; i++) {
- *(cpaScreen[2]+i) = ' ';
- *(cpaScreen[3]+i) = ' ';
- }
- for (i = 31; i < 34; i++)
- *(cpaScreen[21]+i) = ' ';
- }
-
- }
-
- printf("\n");
-
- if (mode == HOSTINFO_LONG) {
- for (i = 0; i < SCREEN_LINES; i++)
- fwrite(cpaScreen[i], SCREEN_COLS+1, 1, stdout);
- }
- else {
- for (i = 0; i < 4; i++)
- fwrite(cpaScreen[i], SCREEN_COLS+1, 1, stdout);
- for (i = 20; i < SCREEN_LINES; i++)
- fwrite(cpaScreen[i], SCREEN_COLS+1, 1, stdout);
- }
-
- printf("\n");
-
- CUS:
- if (ti)
- free(ti);
- return;
- }
-
-
- int timerestriction(char *cpLsys, char *cpSystem)
- {
- int rc;
- struct TimeInfo *ti = NULL;
-
- if ((ti = (struct TimeInfo *)malloc(sizeof(struct TimeInfo))) == NULL)
- CU(-1);
- if (calctimes(cpLsys, cpSystem, ti) == FALSE)
- CU(-1);
- if (ti->active.type == TYPE_ACTIVE_NOTCURRENTLY ||
- ti->active.type == TYPE_ACTIVE_NEVER )
- CU(-1);
- if (ti->active.type == TYPE_ACTIVE_ALWAYS)
- CU(0);
- if (ti->active.type == TYPE_ACTIVE_SPECIFIC)
- CU(ti->active.remain.hour * 60 + ti->active.remain.min);
-
- rc = -1;
-
- CUS:
- if (ti)
- free(ti);
- return rc;
- }
-
-
-
-