void getdate() { char *encodedweekday = getweekday(); serial_print(toweekday(encodedweekday)); serial_print(" "); char *encodedmonth = getmonth(); serial_print(tomonth(encodedmonth)); serial_print(" "); serial_print(getmonthday()); serial_print(" "); char *encodedyear = getyear(); char *year = sys_alloc_mem(5); year[0] = '2'; year[1] = '0'; year[2] = encodedyear[0]; year[3] = encodedyear[1]; year[4] = '\0'; serial_println(year); serial_println(""); sys_free_mem(encodedyear); sys_free_mem(encodedweekday); sys_free_mem(encodedmonth); sys_free_mem(year); }
static int getfield(char *p, char **endp, int *flags) { int val; char *start; char savech; /* * note this macro has an arg that isn't used ... it is retained * (it is believed) to make the macro call look more "natural" * and suggest at the call site what is happening. */ #define FLDCHAR(a) (*p != '\0' && !isdigit((unsigned char)*p) && \ !isalpha((unsigned char)*p) && *p != '*') val = 0; for (/*EMPTY*/; FLDCHAR(*p); ++p) continue; if (*p == '*') { /* `*' is current month */ if (!(*flags & F_ISMONTH)) { *flags |= F_ISMONTH | F_WILDMONTH; *endp = p + 1; return tp->tm_mon + 1; } else { *flags |= F_ISDAY | F_WILDDAY; *endp = p + 1; return 1; } } if (isdigit((unsigned char)*p)) { val = (int)strtol(p, &p, 10); /* if 0, it's failure */ for (/*EMPTY*/; FLDCHAR(*p); ++p) continue; *endp = p; return val; } for (start = p; *p != '\0' && isalpha((unsigned char)*p); p++) continue; savech = *p; if (p != start) { *p = '\0'; if ((val = getmonth(start)) != 0) *flags |= F_ISMONTH; else if ((val = getday(start)) != 0) *flags |= F_ISDOW; else { *p = savech; *endp = start; return 0; } } for (*p = savech; FLDCHAR(*p); ++p) continue; *endp = p; return val; }
char *tmmodify(time_t timeval, char *time) { char other[24]; char year[8]; int month; struct tm * local = localtime(&timeval); strftime(year, 7, "%Y", local); month = getmonth(local); strftime(other,23,"%d %H:%M:%S",local); sprintf(time,"%s/%d/%s\r\n",year,month,other); return time; }
int compare_2_dates(char *dob1, char *dob2) { if (strcompare(getyear(dob1), getyear(dob2)) == 0) { if (strcompare(getmonth(dob1), getmonth(dob2)) == 0) { if (strcompare(getDate(dob1), getDate(dob2)) == 0) { return 0; } else if (strcompare(getDate(dob1), getDate(dob2)) < 0) { return 1; } return 2; } else if (strcompare(getmonth(dob1), getmonth(dob2))<0) { return 1; } return 2; } else if (strcompare(getyear(dob1), getyear(dob2))<0) { return 1; } return 2; }
int validate(char *dob) { int counter = 0, datetrue = 0; char *dd, *mm, *yyyy; if (strlength(dob) == 10) { for (counter = 0; counter < 10; counter++) { if ((dob[counter] >= '0' && dob[counter] <= '9') || dob[counter] == '-'); else { return -1; } } dd = getDate(dob); mm = getmonth(dob); yyyy = getyear(dob); if (strcompare(mm, "13") < 0) { if (strcompare(mm, "01") == 0 || strcompare(mm, "03") == 0 || strcompare(mm, "05") == 0 || strcompare(mm, "07") == 0 || strcompare(mm, "08") == 0 || strcompare(mm, "10") == 0 || strcompare(mm, "12") == 0) { if (strcompare(dd, "31") <= 0) { datetrue = 1; } } else if (strcompare(mm, "04") == 0 || strcompare(mm, "06") == 0 || strcompare(mm, "09") == 0 || strcompare(mm, "11") == 0) { if (strcompare(dd, "30") <= 0) { datetrue = 1; } } else { if (atoi(yyyy) % 400 == 0 || (atoi(yyyy) % 100 != 0 && atoi(yyyy) % 4 == 0)) { if (strcompare(dd, "29") <= 0) { datetrue = 1; } } else { if (strcompare(dd, "28") <= 0) { datetrue = 1; } } } } else { return -1; } } else return -1; return datetrue; }
void writetime() { time_t timeval; char other[24]; char year[8]; char together[64]; int month; time(&timeval); struct tm *local=localtime(&timeval); /* get year */ strftime(year,7,"%Y",local); /*get month */ month=getmonth(local); /*get other */ strftime(other,23,"%d %H:%M:%S",local); /*together all */ sprintf(together,"%s/%d/%s\r\n",year,month,other); fwrite(together,strlen(together),1,logfp); }
int getfield(char *p, char **endp, int *flags) { int val, var; char *start, savech; for (; !isdigit((unsigned char)*p) && !isalpha((unsigned char)*p) && *p != '*'; ++p); if (*p == '*') { /* `*' is current month */ *flags |= F_ISMONTH; *endp = p+1; return(tp->tm_mon + 1); } if (isdigit((unsigned char)*p)) { val = strtol(p, &p, 10); /* if 0, it's failure */ for (; !isdigit((unsigned char)*p) && !isalpha((unsigned char)*p) && *p != '*'; ++p); *endp = p; return(val); } for (start = p; isalpha((unsigned char)*++p);); /* Sunday-1 */ if (*p == '+' || *p == '-') for(; isdigit((unsigned char)*++p);); savech = *p; *p = '\0'; /* Month */ if ((val = getmonth(start)) != 0) *flags |= F_ISMONTH; /* Day */ else if ((val = getday(start)) != 0) { *flags |= F_ISDAY; /* variable weekday */ if ((var = getdayvar(start)) != 0) { if (var <=5 && var >= -4) val += var * 10; #ifdef DEBUG printf("var: %d\n", var); #endif } } /* Easter */ else if ((val = geteaster(start, tp->tm_year + 1900)) != 0) *flags |= F_EASTER; /* Paskha */ else if ((val = getpaskha(start, tp->tm_year + 1900)) != 0) *flags |= F_EASTER; /* undefined rest */ else { *p = savech; return (0); } for (*p = savech; !isdigit((unsigned char)*p) && !isalpha((unsigned char)*p) && *p != '*'; ++p); *endp = p; return(val); }
int ftpparse(struct ftpparse *fp,char *buf,int len) { int i; int j; int state; long size; long year; long month; long mday; long hour; long minute; fp->name = 0; fp->namelen = 0; fp->flagtrycwd = 0; fp->flagtryretr = 0; fp->sizetype = FTPPARSE_SIZE_UNKNOWN; fp->size = 0; fp->mtimetype = FTPPARSE_MTIME_UNKNOWN; fp->mtime = 0; fp->idtype = FTPPARSE_ID_UNKNOWN; fp->id = 0; fp->idlen = 0; if (len < 2) /* an empty name in EPLF, with no info, could be 2 chars */ return 0; switch(*buf) { /* see http://pobox.com/~djb/proto/eplf.txt */ /* "+i8388621.29609,m824255902,/,\tdev" */ /* "+i8388621.44468,m839956783,r,s10376,\tRFCEPLF" */ case '+': i = 1; for (j = 1;j < len;++j) { if (buf[j] == 9) { fp->name = buf + j + 1; fp->namelen = len - j - 1; return 1; } if (buf[j] == ',') { switch(buf[i]) { case '/': fp->flagtrycwd = 1; break; case 'r': fp->flagtryretr = 1; break; case 's': fp->sizetype = FTPPARSE_SIZE_BINARY; fp->size = getlong(buf + i + 1,j - i - 1); break; case 'm': fp->mtimetype = FTPPARSE_MTIME_LOCAL; initbase(); fp->mtime = base + getlong(buf + i + 1,j - i - 1); break; case 'i': fp->idtype = FTPPARSE_ID_FULL; fp->id = buf + i + 1; fp->idlen = j - i - 1; } i = j + 1; } } return 0; /* UNIX-style listing, without inum and without blocks */ /* "-rw-r--r-- 1 root other 531 Jan 29 03:26 README" */ /* "dr-xr-xr-x 2 root other 512 Apr 8 1994 etc" */ /* "dr-xr-xr-x 2 root 512 Apr 8 1994 etc" */ /* "lrwxrwxrwx 1 root other 7 Jan 25 00:17 bin -> usr/bin" */ /* Also produced by Microsoft's FTP servers for Windows: */ /* "---------- 1 owner group 1803128 Jul 10 10:18 ls-lR.Z" */ /* "d--------- 1 owner group 0 May 9 19:45 Softlib" */ /* Also WFTPD for MSDOS: */ /* "-rwxrwxrwx 1 noone nogroup 322 Aug 19 1996 message.ftp" */ /* Also NetWare: */ /* "d [R----F--] supervisor 512 Jan 16 18:53 login" */ /* "- [R----F--] rhesus 214059 Oct 20 15:27 cx.exe" */ /* Also NetPresenz for the Mac: */ /* "-------r-- 326 1391972 1392298 Nov 22 1995 MegaPhone.sit" */ /* "drwxrwxr-x folder 2 May 10 1996 network" */ case 'b': case 'c': case 'd': case 'l': case 'p': case 's': case '-': if (*buf == 'd') fp->flagtrycwd = 1; if (*buf == '-') fp->flagtryretr = 1; if (*buf == 'l') fp->flagtrycwd = fp->flagtryretr = 1; state = 1; i = 0; for (j = 1;j < len;++j) if ((buf[j] == ' ') && (buf[j - 1] != ' ')) { switch(state) { case 1: /* skipping perm */ state = 2; break; case 2: /* skipping nlink */ state = 3; if ((j - i == 6) && (buf[i] == 'f')) /* for NetPresenz */ state = 4; break; case 3: /* skipping uid */ state = 4; break; case 4: /* getting tentative size */ size = getlong(buf + i,j - i); state = 5; break; case 5: /* searching for month, otherwise getting tentative size */ month = getmonth(buf + i,j - i); if (month >= 0) state = 6; else size = getlong(buf + i,j - i); break; case 6: /* have size and month */ mday = getlong(buf + i,j - i); state = 7; break; case 7: /* have size, month, mday */ if ((j - i == 4) && (buf[i + 1] == ':')) { hour = getlong(buf + i,1); minute = getlong(buf + i + 2,2); fp->mtimetype = FTPPARSE_MTIME_REMOTEMINUTE; initbase(); fp->mtime = base + guesstai(month,mday) + hour * 3600 + minute * 60; } else if ((j - i == 5) && (buf[i + 2] == ':')) { hour = getlong(buf + i,2); minute = getlong(buf + i + 3,2); fp->mtimetype = FTPPARSE_MTIME_REMOTEMINUTE; initbase(); fp->mtime = base + guesstai(month,mday) + hour * 3600 + minute * 60; } else if (j - i >= 4) { year = getlong(buf + i,j - i); fp->mtimetype = FTPPARSE_MTIME_REMOTEDAY; initbase(); fp->mtime = base + totai(year,month,mday); } else return 0; fp->name = buf + j + 1; fp->namelen = len - j - 1; state = 8; break; case 8: /* twiddling thumbs */ break; } i = j + 1; while ((i < len) && (buf[i] == ' ')) ++i; } if (state != 8) return 0; fp->size = size; fp->sizetype = FTPPARSE_SIZE_BINARY; if (*buf == 'l') for (i = 0;i + 3 < fp->namelen;++i) if (fp->name[i] == ' ') if (fp->name[i + 1] == '-') if (fp->name[i + 2] == '>') if (fp->name[i + 3] == ' ') { fp->namelen = i; break; } /* eliminate extra NetWare spaces */ if ((buf[1] == ' ') || (buf[1] == '[')) if (fp->namelen > 3) if (fp->name[0] == ' ') if (fp->name[1] == ' ') if (fp->name[2] == ' ') { fp->name += 3; fp->namelen -= 3; } return 1; } /* MultiNet (some spaces removed from examples) */ /* "00README.TXT;1 2 30-DEC-1996 17:44 [SYSTEM] (RWED,RWED,RE,RE)" */ /* "CORE.DIR;1 1 8-SEP-1996 16:09 [SYSTEM] (RWE,RWE,RE,RE)" */ /* and non-MutliNet VMS: */ /* "CII-MANUAL.TEX;1 213/216 29-JAN-1996 03:33:12 [ANONYMOU,ANONYMOUS] (RWED,RWED,,)" */ for (i = 0;i < len;++i) if (buf[i] == ';') break; if (i < len) { fp->name = buf; fp->namelen = i; if (i > 4) if (buf[i - 4] == '.') if (buf[i - 3] == 'D') if (buf[i - 2] == 'I') if (buf[i - 1] == 'R') { fp->namelen -= 4; fp->flagtrycwd = 1; } if (!fp->flagtrycwd) fp->flagtryretr = 1; while (buf[i] != ' ') if (++i == len) return 0; while (buf[i] == ' ') if (++i == len) return 0; while (buf[i] != ' ') if (++i == len) return 0; while (buf[i] == ' ') if (++i == len) return 0; j = i; while (buf[j] != '-') if (++j == len) return 0; mday = getlong(buf + i,j - i); while (buf[j] == '-') if (++j == len) return 0; i = j; while (buf[j] != '-') if (++j == len) return 0; month = getmonth(buf + i,j - i); if (month < 0) return 0; while (buf[j] == '-') if (++j == len) return 0; i = j; while (buf[j] != ' ') if (++j == len) return 0; year = getlong(buf + i,j - i); while (buf[j] == ' ') if (++j == len) return 0; i = j; while (buf[j] != ':') if (++j == len) return 0; hour = getlong(buf + i,j - i); while (buf[j] == ':') if (++j == len) return 0; i = j; while ((buf[j] != ':') && (buf[j] != ' ')) if (++j == len) return 0; minute = getlong(buf + i,j - i); fp->mtimetype = FTPPARSE_MTIME_REMOTEMINUTE; initbase(); fp->mtime = base + totai(year,month,mday) + hour * 3600 + minute * 60; return 1; } /* MSDOS format */ /* 04-27-00 09:09PM <DIR> licensed */ /* 07-18-00 10:16AM <DIR> pub */ /* 04-14-00 03:47PM 589 readme.htm */ if ((*buf >= '0') && (*buf <= '9')) { i = 0; j = 0; while (buf[j] != '-') if (++j == len) return 0; month = getlong(buf + i,j - i) - 1; while (buf[j] == '-') if (++j == len) return 0; i = j; while (buf[j] != '-') if (++j == len) return 0; mday = getlong(buf + i,j - i); while (buf[j] == '-') if (++j == len) return 0; i = j; while (buf[j] != ' ') if (++j == len) return 0; year = getlong(buf + i,j - i); if (year < 50) year += 2000; if (year < 1000) year += 1900; while (buf[j] == ' ') if (++j == len) return 0; i = j; while (buf[j] != ':') if (++j == len) return 0; hour = getlong(buf + i,j - i); while (buf[j] == ':') if (++j == len) return 0; i = j; while ((buf[j] != 'A') && (buf[j] != 'P')) if (++j == len) return 0; minute = getlong(buf + i,j - i); if (hour == 12) hour = 0; if (buf[j] == 'A') if (++j == len) return 0; if (buf[j] == 'P') { hour += 12; if (++j == len) return 0; } if (buf[j] == 'M') if (++j == len) return 0; while (buf[j] == ' ') if (++j == len) return 0; if (buf[j] == '<') { fp->flagtrycwd = 1; while (buf[j] != ' ') if (++j == len) return 0; } else { i = j; while (buf[j] != ' ') if (++j == len) return 0; fp->size = getlong(buf + i,j - i); fp->sizetype = FTPPARSE_SIZE_BINARY; fp->flagtryretr = 1; } while (buf[j] == ' ') if (++j == len) return 0; fp->name = buf + j; fp->namelen = len - j; fp->mtimetype = FTPPARSE_MTIME_REMOTEMINUTE; initbase(); fp->mtime = base + totai(year,month,mday) + hour * 3600 + minute * 60; return 1; } /* Some useless lines, safely ignored: */ /* "Total of 11 Files, 10966 Blocks." (VMS) */ /* "total 14786" (UNIX) */ /* "DISK$ANONFTP:[ANONYMOUS]" (VMS) */ /* "Directory DISK$PCSA:[ANONYM]" (VMS) */ return 0; }
int getfield(char *p, char **endp, int *flags) { int val, var, i; char *start, savech; for (; !isdigit((unsigned char)*p) && !isalpha((unsigned char)*p) && *p != '*' && *p != '\t'; ++p) ; if (*p == '*') { /* `*' is every month */ *flags |= F_ISMONTH; *endp = p+1; return (-1); /* means 'every month' */ } if (isdigit((unsigned char)*p)) { val = strtol(p, &p, 10); /* if 0, it's failure */ for (; !isdigit((unsigned char)*p) && !isalpha((unsigned char)*p) && *p != '*'; ++p) ; *endp = p; return (val); } for (start = p; isalpha((unsigned char)*++p);) ; /* Sunday-1 */ if (*p == '+' || *p == '-') for(; isdigit((unsigned char)*++p); ) ; savech = *p; *p = '\0'; /* Month */ if ((val = getmonth(start)) != 0) *flags |= F_ISMONTH; /* Day */ else if ((val = getday(start)) != 0) { *flags |= F_ISDAY; /* variable weekday */ if ((var = getdayvar(start)) != 0) { if (var <= 5 && var >= -4) val += var * 10; #ifdef DEBUG printf("var: %d\n", var); #endif } } /* Try specials (Easter, Paskha, ...) */ else { for (i = 0; i < NUMEV; i++) { if (strncasecmp(start, spev[i].name, spev[i].nlen) == 0) { start += spev[i].nlen; val = i + 1; i = NUMEV + 1; } else if (spev[i].uname != NULL && strncasecmp(start, spev[i].uname, spev[i].ulen) == 0) { start += spev[i].ulen; val = i + 1; i = NUMEV + 1; } } if (i > NUMEV) { const char *errstr; switch (*start) { case '-': case '+': var = strtonum(start + 1, 0, 365, &errstr); if (errstr) return (0); /* Someone is just being silly */ if (*start == '-') var = -var; val += (NUMEV + 1) * var; /* We add one to the matching event and multiply by * (NUMEV + 1) so as not to return 0 if there's a match. * val will overflow if there is an obscenely large * number of special events. */ break; } *flags |= F_SPECIAL; } if (!(*flags & F_SPECIAL)) { /* undefined rest */ *p = savech; return (0); } } for (*p = savech; !isdigit((unsigned char)*p) && !isalpha((unsigned char)*p) && *p != '*' && *p != '\t'; ++p) ; *endp = p; return (val); }
/* displays the high score board */ void viewhighscores(int musicoverride) { if(musicoverride!=MUSIC_OFF) music.play(musicoverride); int s; loadhighscores(); short validsum=0; for(s=0;s<SCORENUM;s++) { if(score[s].valid)validsum++; } if(!validsum)return; erase(); set_color(COLOR_WHITE,COLOR_BLACK,1); move(0,0); addstr("The Liberal ELITE"); int y=2; for(s=0;s<SCORENUM;s++) { if(score[s].valid) { if(yourscore==s&&score[s].endtype==END_WON)set_color(COLOR_GREEN,COLOR_BLACK,1); else if(yourscore==s)set_color(COLOR_RED,COLOR_BLACK,1); else set_color(COLOR_WHITE,COLOR_BLACK,1); move(y,0); addstr(score[s].slogan); if(yourscore==s&&score[s].endtype==END_WON)set_color(COLOR_GREEN,COLOR_BLACK,0); else if(yourscore==s)set_color(COLOR_RED,COLOR_BLACK,0); else set_color(COLOR_WHITE,COLOR_BLACK,0); move(y+1,0); switch(score[s].endtype) { case END_WON: addstr("The Liberal Crime Squad liberalized the country in "); if(yourscore==s&&musicoverride==MUSIC_OFF) music.play(MUSIC_VICTORY); break; case END_POLICE: addstr("The Liberal Crime Squad was brought to justice in "); if(yourscore==s&&musicoverride==MUSIC_OFF) music.play(MUSIC_DEFEAT); break; case END_CIA: addstr("The Liberal Crime Squad was blotted out in "); if(yourscore==s&&musicoverride==MUSIC_OFF) music.play(MUSIC_DEFEAT); break; case END_HICKS: addstr("The Liberal Crime Squad was mobbed in "); if(yourscore==s&&musicoverride==MUSIC_OFF) music.play(MUSIC_DEFEAT); break; case END_CORP: addstr("The Liberal Crime Squad was downsized in "); if(yourscore==s&&musicoverride==MUSIC_OFF) music.play(MUSIC_DEFEAT); break; case END_DEAD: addstr("The Liberal Crime Squad was KIA in "); if(yourscore==s&&musicoverride==MUSIC_OFF) music.play(MUSIC_DEFEAT); break; case END_REAGAN: addstr("The country was Reaganified in "); if(yourscore==s&&musicoverride==MUSIC_OFF) music.play(MUSIC_REAGANIFIED); break; case END_PRISON: addstr("The Liberal Crime Squad died in prison in "); if(yourscore==s&&musicoverride==MUSIC_OFF) music.play(MUSIC_DEFEAT); break; case END_EXECUTED: addstr("The Liberal Crime Squad was executed in "); if(yourscore==s&&musicoverride==MUSIC_OFF) music.play(MUSIC_DEFEAT); break; case END_DATING: addstr("The Liberal Crime Squad was on vacation in "); if(yourscore==s&&musicoverride==MUSIC_OFF) music.play(MUSIC_DEFEAT); break; case END_HIDING: addstr("The Liberal Crime Squad was in permanent hiding in "); if(yourscore==s&&musicoverride==MUSIC_OFF) music.play(MUSIC_DEFEAT); break; case END_DISBANDLOSS: addstr("The Liberal Crime Squad was hunted down in "); if(yourscore==s&&musicoverride==MUSIC_OFF) music.play(MUSIC_DEFEAT); break; case END_DISPERSED: addstr("The Liberal Crime Squad was scattered in "); if(yourscore==s&&musicoverride==MUSIC_OFF) music.play(MUSIC_DEFEAT); break; case END_CCS: addstr("The Liberal Crime Squad was out-Crime Squadded in "); if(yourscore==s&&musicoverride==MUSIC_OFF) music.play(MUSIC_DEFEAT); break; case END_FIREMEN: addstr("The Liberal Crime Squad was burned in "); if(yourscore==s&&musicoverride==MUSIC_OFF) music.play(MUSIC_DEFEAT); break; case END_STALIN: addstr("The country was Stalinized in "); if(yourscore==s&&musicoverride==MUSIC_OFF) music.play(MUSIC_STALINIZED); break; } addstr(getmonth(score[s].month)); addstr(" "); addstr(score[s].year); addstr(". "); move(y+2,0); addstr("Recruits: "); addstr(score[s].stat_recruits); move(y+3,0); addstr("Martyrs: "); addstr(score[s].stat_dead); move(y+2,20); addstr("Kills: "); addstr(score[s].stat_kills); move(y+3,20); addstr("Kidnappings: "); addstr(score[s].stat_kidnappings); move(y+2,40); addstr("$ Taxed: "); addstr(score[s].stat_funds); move(y+3,40); addstr("$ Spent: "); addstr(score[s].stat_spent); move(y+2,60); addstr("Flags Bought: "); addstr(score[s].stat_buys); move(y+3,60); addstr("Flags Burned: "); addstr(score[s].stat_burns); y+=4; } } set_color(COLOR_GREEN,COLOR_BLACK,1); //UNIVERSAL STATS move(22,0); addstr("Universal Liberal Statistics:"); move(23,0); addstr("Recruits: "); addstr(ustat_recruits); move(24,0); addstr("Martyrs: "); addstr(ustat_dead); move(23,20); addstr("Kills: "); addstr(ustat_kills); move(24,20); addstr("Kidnappings: "); addstr(ustat_kidnappings); move(23,40); addstr("$ Taxed: "); addstr(ustat_funds); move(24,40); addstr("$ Spent: "); addstr(ustat_spent); move(23,60); addstr("Flags Bought: "); addstr(ustat_buys); move(24,60); addstr("Flags Burned: "); addstr(ustat_burns); getkey(); }
int getday(int date) { return (date-10000*getyear(date)-100*getmonth(date)); }
void table_gen(long long nrows, Stringlist wlist,int numcols, int *column_types, double *column_mins, double *column_maxes) { int itemp; int i,j,ii, nwords; int year, month, day, hour, minute, second; int minyear, minmonth, minday; int maxyear, maxmonth, maxday; int leaps[] = LEAPS; int nonleaps[] = NONLEAPS; //printf("Number of rows to be generated: %ld\n",nrows); //exit(0); for (i=0; i<nrows; i++) { for (j=0; j<numcols; j++) { switch (column_types[j]) { case INTEGER: //printf("column_type[%d] = INTEGER\n",j+1); printf("%d",(int)randomrange(column_mins[j],column_maxes[j])); break;; case VARCHAR: //printf("column_type[%d] = VARCHAR\n",j+1); nwords = (int)randomrange(column_mins[j],column_maxes[j]); for (ii=0; ii<nwords ; ii++) { itemp = (int)randomrange(0,wlist.used_size-1); printf("%s",wlist.list[itemp]); if (ii != (nwords-1)) printf(" "); } break;; case TIMESTAMP: //printf("column_type[%d] = TIMESTAMP\n",j+1); minyear = getyear(column_mins[j]); maxyear = getyear(column_maxes[j]); minmonth = getmonth(column_mins[j]); maxmonth = getmonth(column_maxes[j]); minday = getday(column_mins[j]); maxday = getday(column_maxes[j]); year = (int)randomrange(minyear,maxyear); month = (int)randomrange(minmonth,maxmonth); day = (int)randomrange(minday,maxday); if (ISLEAP(year)) { day = MIN(leaps[month-1],day); } else { day = MIN(nonleaps[month-1],day); } hour = (int)randomrange(0,23); minute = (int)randomrange(0,59); second = (int)randomrange(0,59); printf("%.4d-%.2d-%.2d %.2d:%.2d:%.2d",year,month,day,hour,minute,second); break;; case NUMERIC: //printf("column_type[%d] = NUMERIC\n",j+1); printf("%.6f",(float)randomrange(column_mins[j],column_maxes[j])); break;; } if (j != (numcols-1)) printf("|"); } //End of numcolumns printf("\n"); } }
bool show_disbanding_screen(int& oldforcemonth) { if(oldforcemonth == month) return true; for(int p=pool.size()-1;p>=0;p--) { int targetjuice=0; for(int i=0;i<(year-disbandtime)+1;i++) { targetjuice+=LCSrandom(100); } if(targetjuice>1000) { targetjuice=1000; } if(pool[p]->juice<targetjuice) { if(pool[p]->hireid!=-1 && !(pool[p]->flag & CREATUREFLAG_SLEEPER)) pool[p]->alive=0; // Kill for the purposes of disbanding all contacts below } } oldforcemonth=month; erase(); move(0,0); char num[20]; itoa(year,num,10); set_color(COLOR_WHITE,COLOR_BLACK,1); addstr(getmonth(month)); addstr(" "); addstr(num); //int y=2; set_alignment_color(exec[EXEC_PRESIDENT], true); mvaddstr(1,0,"President: "); addstr(execname[EXEC_PRESIDENT]);addstr(", "); switch(exec[EXEC_PRESIDENT]) { case -2:addstr("Arch-Conservative");break; case -1:addstr("Conservative");break; case 0:addstr("moderate");break; case 1:addstr("Liberal");break; case 2:addstr("Elite Liberal");break; } if(execterm==1)addstr(", 1st Term"); else addstr(", 2nd Term"); int housemake[5]={0,0,0,0,0}; for(int h=0;h<435;h++) housemake[house[h]+2]++; int lsum=housemake[3]+housemake[4]-housemake[0]-housemake[1]; if(lsum<=-145)set_color(COLOR_RED,COLOR_BLACK,1); else if(lsum<0)set_color(COLOR_MAGENTA,COLOR_BLACK,1); else if(lsum<145)set_color(COLOR_YELLOW,COLOR_BLACK,1); else if(housemake[4]<290)set_color(COLOR_CYAN,COLOR_BLACK,1); else set_color(COLOR_GREEN,COLOR_BLACK,1); move(2,0); addstr("House: "); itoa(housemake[4],num,10); addstr(num);addstr("Lib+, "); itoa(housemake[3],num,10); addstr(num);addstr("Lib, "); itoa(housemake[2],num,10); addstr(num);addstr("Mod, "); itoa(housemake[1],num,10); addstr(num);addstr("Cons, "); itoa(housemake[0],num,10); addstr(num);addstr("Cons+"); int senatemake[5]={0,0,0,0,0}; for(int s=0;s<100;s++) senatemake[senate[s]+2]++; lsum=senatemake[3]+senatemake[4]-senatemake[0]-senatemake[1]; if(lsum<=-33)set_color(COLOR_RED,COLOR_BLACK,1); else if(lsum<0)set_color(COLOR_MAGENTA,COLOR_BLACK,1); else if(lsum<33)set_color(COLOR_YELLOW,COLOR_BLACK,1); else if(senatemake[4]<67)set_color(COLOR_CYAN,COLOR_BLACK,1); else set_color(COLOR_GREEN,COLOR_BLACK,1); move(3,0); addstr("Senate: "); itoa(senatemake[4],num,10); addstr(num);addstr("Lib+, "); itoa(senatemake[3],num,10); addstr(num);addstr("Lib, "); itoa(senatemake[2],num,10); addstr(num);addstr("Mod, "); itoa(senatemake[1],num,10); addstr(num);addstr("Cons, "); itoa(senatemake[0],num,10); addstr(num);addstr("Cons+"); int courtmake[5]={0,0,0,0,0}; for(int s=0;s<9;s++) { courtmake[court[s]+2]++; } lsum=courtmake[3]+courtmake[4] -courtmake[0]-courtmake[1]; if(courtmake[0]>=5)set_alignment_color(ALIGN_ARCHCONSERVATIVE, true); else if(courtmake[0]+courtmake[1]>=5)set_alignment_color(ALIGN_CONSERVATIVE, true); else if(courtmake[3]+courtmake[4]<5)set_alignment_color(ALIGN_MODERATE, true); else if(courtmake[4]<5)set_alignment_color(ALIGN_LIBERAL, true); else set_alignment_color(ALIGN_ELITELIBERAL, true); mvaddstr(4,0,"Supreme Court: "); itoa(courtmake[4],num,10); addstr(num);addstr("Lib+, "); itoa(courtmake[3],num,10); addstr(num);addstr("Lib, "); itoa(courtmake[2],num,10); addstr(num);addstr("Mod, "); itoa(courtmake[1],num,10); addstr(num);addstr("Cons, "); itoa(courtmake[0],num,10); addstr(num);addstr("Cons+"); //y=0; for(int l=0;l<LAWNUM;l++) { set_alignment_color(law[l], true); move(6+l/3,l%3*30); char str[40]; getlaw(str,l); addstr(str); } set_color(COLOR_WHITE,COLOR_BLACK,0); mvaddstr(19,33,"Public Mood"); mvaddstr(21,1,"Conservative"); mvaddstr(21,66,"Liberal"); mvaddstr(22,0,"<------------------------------------------------------------------------------>"); move(22,77*publicmood(-1)/100+1); addstr("|"); mvaddstr(23,0,"R - Recreate the Liberal Crime Squad Any Other Key - Next Month"); refresh(); char c=getch(); if(c=='r') return false; else return true; }
void preparepage(newsstoryst& ns, bool liberalguardian) { set_color(COLOR_WHITE,COLOR_WHITE,0); for(int x=0;x<80;x++) for(int y=0;y<25;y++) mvaddchar(y,x,' '); set_color(COLOR_WHITE,COLOR_BLACK,0); if(ns.page==1||(liberalguardian&&ns.guardianpage==1)) { //TOP int pap=LCSrandom(5); for(int x=0;x<80;x++) { for(int y=0;y<5;y++) { move(y,x); if(liberalguardian) { set_color(translateGraphicsColor(newstops[5][x][y][1]), translateGraphicsColor(newstops[5][x][y][2]), newstops[5][x][y][3]); addchar(newstops[5][x][y][0]); } else { set_color(translateGraphicsColor(newstops[pap][x][y][1]), translateGraphicsColor(newstops[pap][x][y][2]), newstops[pap][x][y][3]); addchar(newstops[pap][x][y][0]); } } } if(!liberalguardian) // Liberal Guardian graphics don't support adding a date { //DATE set_color(COLOR_BLACK,COLOR_WHITE,0); int pday=day, pmonth=month, pyear=year; if(pday>monthday()) // Day counter has increased but end-of-month has not yet { // been checked so it has to be accounted for here. pday=1,pmonth++; if(pmonth>12) pmonth=1,pyear++; } move(3,66+(pday<10)); addstr(getmonth(pmonth,true)); addstr(" "); addstr(pday); addstr(", "); addstr(pyear); } } else { //PAGE set_color(COLOR_BLACK,COLOR_WHITE,0); move(0,76); if(!liberalguardian) addstr(ns.page); else addstr(ns.guardianpage); } }