summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/account.c12
-rw-r--r--util/angel.c6
-rw-r--r--util/buildir.c4
-rw-r--r--util/checkdir.c1
-rw-r--r--util/chkhbf.c1
-rw-r--r--util/countalldice.c6
-rw-r--r--util/descrypt.c9
-rw-r--r--util/indexuser.c2
-rw-r--r--util/initbbs.c11
-rw-r--r--util/merge_board.c10
-rw-r--r--util/merge_passwd.c10
-rw-r--r--util/openticket.c2
-rw-r--r--util/passwdconverter.c6
-rw-r--r--util/poststat.c8
-rw-r--r--util/r2014convert.c2
-rw-r--r--util/reaper.c7
-rw-r--r--util/shmctl.c6
-rw-r--r--util/shmsweep.c9
-rw-r--r--util/showboard.c10
-rw-r--r--util/toplazyBM.c2
-rw-r--r--util/uhash_loader.c29
-rw-r--r--util/userlist.c12
-rw-r--r--util/xchatd.c19
-rw-r--r--util/yearsold.c4
24 files changed, 61 insertions, 127 deletions
diff --git a/util/account.c b/util/account.c
index 1c9ce127..c15411b8 100644
--- a/util/account.c
+++ b/util/account.c
@@ -98,14 +98,14 @@ main(int argc, char **argv)
char buf[256], buf1[256], *p;
FILE *fp, *fp1;
int act[27]; /* 次數/累計時間/pointer */
- time_t now;
+ time4_t now;
struct tm *ptime;
attach_SHM();
nice(10);
chdir(BBSHOME);
now = time(NULL) - ADJUST_M * 60; /* back to ancent */
- ptime = localtime(&now);
+ ptime = localtime4(&now);
memset(act, 0, sizeof(act));
printf("次數/累計時間\n");
@@ -205,7 +205,7 @@ main(int argc, char **argv)
printf("此時段最多同時上線:%d 過去:%d\n", a = SHM->max_user, k);
fclose(fp);
if (a > k) {
- ptime = localtime(&SHM->max_time);
+ ptime = localtime4(&SHM->max_time);
if ((fp1 = fopen("etc/history", "a"))) {
fprintf(fp1,
"◎ 【%02d/%02d/%02d %02d:%02d】"
@@ -222,7 +222,7 @@ main(int argc, char **argv)
} else
fclose(fp);
}
- ptime = localtime(&now);
+ ptime = localtime4(&now);
if (ptime->tm_hour) {
/* rotate one line in today_is */
@@ -254,7 +254,7 @@ main(int argc, char **argv)
printf("壓縮使用者上線監控\n");
/* Ptt 歷史事件處理 */
now = time(NULL) - ADJUST_M * 60; /* back to ancent */
- ptime = localtime(&now);
+ ptime = localtime4(&now);
attach_SHM();
if ((fp = fopen("etc/history.data", "r"))) { /* 單日最多次人次,同時上線
@@ -288,7 +288,7 @@ main(int argc, char **argv)
fclose(fp);
}
now += ADJUST_M * 60; /* back to future */
- ptime = localtime(&now);
+ ptime = localtime4(&now);
/* Ptt 節日處理 */
printf("節日處理\n");
diff --git a/util/angel.c b/util/angel.c
index 57417d0e..f074285f 100644
--- a/util/angel.c
+++ b/util/angel.c
@@ -114,7 +114,7 @@ int mailalertuser(char* userid)
void sendResult(){
int i;
FILE* fp;
- time_t t;
+ time4_t t;
fileheader_t header;
struct stat st;
char filename[512];
@@ -138,13 +138,13 @@ void sendResult(){
return;
}
- time(&t);
+ t = time(NULL);
fprintf(fp, "作者: Ptt 站方統計\n"
"標題: 小天使統計資料\n"
"時間: %s\n"
"\n現在全站小天使有 %d 位\n"
"\n小主人人數最多的 %d 位小天使:\n",
- ctime(&t), count, nReport);
+ Cdate(&t), count, nReport);
for (i = 0; i < nReport; ++i)
fprintf(fp, "%15s %5d 人\n", SHM->userid[list[i][1] - 1], list[i][0]);
fprintf(fp, "\n現在男女皆收的小天使有 %d 位\n"
diff --git a/util/buildir.c b/util/buildir.c
index cc69f57e..cccc8c8a 100644
--- a/util/buildir.c
+++ b/util/buildir.c
@@ -50,7 +50,7 @@ int main(int argc, char **argv)
if(stat(path, &st) == 0 && st.st_size > 0 &&
(fp = fopen(path, "r")) != NULL) {
char buf[512];
- time_t filetime;
+ time4_t filetime;
fileheader_t fhdr;
memset(&fhdr, 0, sizeof(fhdr));
@@ -60,7 +60,7 @@ int main(int argc, char **argv)
/* set file time */
filetime = atoi(dirlist[count]->d_name + 2);
if(filetime > 740000000) {
- struct tm *ptime = localtime(&filetime);
+ struct tm *ptime = localtime4(&filetime);
sprintf(fhdr.date, "%2d/%02d", ptime->tm_mon + 1,
ptime->tm_mday);
} else
diff --git a/util/checkdir.c b/util/checkdir.c
index bbb0b40e..5c98a874 100644
--- a/util/checkdir.c
+++ b/util/checkdir.c
@@ -63,6 +63,7 @@ int main(int argc, char **argv) {
continue;
}
pfh=fh;
+fh.recommend =0;
if(fo)
fwrite(&fh, sizeof(fh), 1, fo);
}
diff --git a/util/chkhbf.c b/util/chkhbf.c
index e63c13fe..2d416de1 100644
--- a/util/chkhbf.c
+++ b/util/chkhbf.c
@@ -5,7 +5,6 @@ struct {
char userid[IDLEN + 1];
time_t lastlogin, expire;
} explist[MAX_FRIEND];
-time_t now;
void usage(void)
{
diff --git a/util/countalldice.c b/util/countalldice.c
index 63354668..45944362 100644
--- a/util/countalldice.c
+++ b/util/countalldice.c
@@ -7,11 +7,7 @@
/*作者:Heat 於1997/10/2 */
/**********************************************/
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include "config.h"
+#include "bbs.h"
#define DICE_WIN BBSHOME "/etc/windice.log"
#define DICE_LOST BBSHOME "/etc/lostdice.log"
diff --git a/util/descrypt.c b/util/descrypt.c
index 6ea6dbe8..ecac9001 100644
--- a/util/descrypt.c
+++ b/util/descrypt.c
@@ -357,9 +357,12 @@ static int des_setkey(const char *key) {
if(!des_initialised)
des_init();
-
- rawkey0 = ntohl(*(unsigned long *) key);
- rawkey1 = ntohl(*(unsigned long *) (key + 4));
+
+#ifdef __linux__
+#include <netinet/in.h>
+#endif
+ rawkey0 = ntohl(*(uint32_t*) key);
+ rawkey1 = ntohl(*(uint32_t*) (key + 4));
if((rawkey0 | rawkey1)
&& rawkey0 == old_rawkey0
diff --git a/util/indexuser.c b/util/indexuser.c
index 8dde8f06..cc5ba78a 100644
--- a/util/indexuser.c
+++ b/util/indexuser.c
@@ -11,7 +11,7 @@ unsigned string_hash(unsigned char *s)
v = (v << 8) | (v >> 24);
v ^= toupper(*s++); /* note this is case insensitive */
}
- return (v * 2654435769UL) >> (32 - HASH_BITS);
+ return (v * 2654435769U) >> (32 - HASH_BITS);
}
diff --git a/util/initbbs.c b/util/initbbs.c
index f952b7ef..d1cddc1a 100644
--- a/util/initbbs.c
+++ b/util/initbbs.c
@@ -1,14 +1,5 @@
/* $Id$ */
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include "config.h"
-#include "pttstruct.h"
-#include "perm.h"
+#include "bbs.h"
static void initDir() {
mkdir("adm", 0755);
diff --git a/util/merge_board.c b/util/merge_board.c
index 12f41346..4fc643c1 100644
--- a/util/merge_board.c
+++ b/util/merge_board.c
@@ -1,11 +1,5 @@
/* $Id$ */
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <string.h>
-#include <sys/types.h>
-#include "config.h"
-#include "pttstruct.h"
+#include "bbs.h"
typedef struct hash_t {
char *brdname;
@@ -28,7 +22,7 @@ unsigned int string_hash(unsigned char *s) {
v = (v << 8) | (v >> 24);
v ^= toupper(*s++); /* note this is case insensitive */
}
- return (v * 2654435769UL) >> (32 - 16);
+ return (v * 2654435769U) >> (32 - 16);
}
int is_exist(char *brdname) {
diff --git a/util/merge_passwd.c b/util/merge_passwd.c
index 20f59aae..7221e384 100644
--- a/util/merge_passwd.c
+++ b/util/merge_passwd.c
@@ -1,11 +1,5 @@
/* $Id$ */
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <string.h>
-#include <sys/types.h>
-#include "config.h"
-#include "pttstruct.h"
+#include "bbs.h"
typedef struct hash_t {
char *userid;
@@ -28,7 +22,7 @@ unsigned int string_hash(unsigned char *s) {
v = (v << 8) | (v >> 24);
v ^= toupper(*s++); /* note this is case insensitive */
}
- return (v * 2654435769UL) >> (32 - 16);
+ return (v * 2654435769U) >> (32 - 16);
}
int is_exist(char *userid) {
diff --git a/util/openticket.c b/util/openticket.c
index bcc58d0a..10a431d9 100644
--- a/util/openticket.c
+++ b/util/openticket.c
@@ -26,7 +26,7 @@ int main(int argc, char **argv)
int money, bet, n, total = 0, ticket[8] =
{0, 0, 0, 0, 0, 0, 0, 0};
FILE *fp;
- time_t now = time(NULL);
+ time4_t now = (time4_t)time(NULL);
char des[MAX_DES][200] =
{"", "", "", ""};
diff --git a/util/passwdconverter.c b/util/passwdconverter.c
index 85b2cf8f..86836d1f 100644
--- a/util/passwdconverter.c
+++ b/util/passwdconverter.c
@@ -10,8 +10,8 @@ typedef struct old_userec_t {
unsigned int userlevel;
unsigned short numlogins;
unsigned short numposts;
- time_t firstlogin;
- time_t lastlogin;
+ time4_t firstlogin;
+ time4_t lastlogin;
char lasthost[16];
int money;
char remoteuser[3]; /* 靽 桀瘝典啁 */
@@ -28,7 +28,7 @@ typedef struct old_userec_t {
unsigned char invisible;
unsigned int exmailbox;
chicken_t mychicken;
- time_t lastsong;
+ time4_t lastsong;
unsigned int loginview;
unsigned char channel; /* (unused?) */
unsigned short vl_count; /* ViolateLaw counter */
diff --git a/util/poststat.c b/util/poststat.c
index 08b17bc1..abd6ef0f 100644
--- a/util/poststat.c
+++ b/util/poststat.c
@@ -22,7 +22,7 @@ struct postrec
char author[13]; /* author name */
char board[13]; /* board name */
char title[66]; /* title name */
- time_t date; /* last post's date */
+ time4_t date; /* last post's date */
int number; /* post number */
struct postrec *next; /* next rec */
}
@@ -327,7 +327,7 @@ poststat(mytype)
int main(argc, argv)
char *argv[];
{
- time_t now;
+ time4_t now;
struct tm *ptime;
attach_SHM();
@@ -343,8 +343,8 @@ int main(argc, argv)
poststat(atoi(argv[2]));
return (0);
}
- time(&now);
- ptime = localtime(&now);
+ now = (time4_t)time(NULL);
+ ptime = localtime4(&now);
if (ptime->tm_hour == 0)
{
if (ptime->tm_mday == 1)
diff --git a/util/r2014convert.c b/util/r2014convert.c
index 766e6e1e..ca91f4c8 100644
--- a/util/r2014convert.c
+++ b/util/r2014convert.c
@@ -20,7 +20,7 @@ int main(){
return 0;
}
} else {
- time_t t = time(NULL);
+ time4_t t = (time4_t)time(NULL);
char* str = ctime(&t);
write(orig_fd, str, strlen(str));
}
diff --git a/util/reaper.c b/util/reaper.c
index 7904566d..f67d38ac 100644
--- a/util/reaper.c
+++ b/util/reaper.c
@@ -2,7 +2,7 @@
#define _UTIL_C_
#include "bbs.h"
-time_t now;
+time4_t now;
int invalid(char *userid) {
int i;
@@ -17,7 +17,7 @@ int invalid(char *userid) {
}
int check(int n, userec_t *u) {
- time_t d;
+ time4_t d;
char buf[256];
if(u->userid[0] != '\0') {
@@ -32,8 +32,7 @@ int check(int n, userec_t *u) {
int unum;
unum = searchuser(u->userid);
- strcpy(buf, ctime(&u->lastlogin));
- strtok(buf, "\n");
+ strcpy(buf, Cdate(&u->lastlogin));
syslog(LOG_NOTICE, "kill user(%d): %s %s", unum, u->userid, buf);
sprintf(buf, "mv home/%c/%s tmp/", u->userid[0], u->userid);
if(system(buf))
diff --git a/util/shmctl.c b/util/shmctl.c
index 60f31238..143bb64a 100644
--- a/util/shmctl.c
+++ b/util/shmctl.c
@@ -186,10 +186,8 @@ int utmpfix(int argc, char **argv)
if( nownum > lowerbound &&
idle[i].idle >
(timeout == -1 ? IDLE_TIMEOUT : timeout) ){
- sprintf(buf, "timeout(%s",
- ctime(&SHM->uinfo[which].lastact));
- buf[strlen(buf) - 1] = 0;
- strcat(buf, ")");
+ sprintf(buf, "timeout(%s)",
+ Cdate(&SHM->uinfo[which].lastact));
clean = buf;
if( SHM->uinfo[which].pid > 0 )
kill(SHM->uinfo[which].pid, SIGHUP);
diff --git a/util/shmsweep.c b/util/shmsweep.c
index 94d5291a..b448270f 100644
--- a/util/shmsweep.c
+++ b/util/shmsweep.c
@@ -1,11 +1,4 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <sys/stat.h>
-#include "config.h"
-#include "pttstruct.h"
+#include "bbs.h"
int main() {
#if 0
diff --git a/util/showboard.c b/util/showboard.c
index 7dee4002..0b473569 100644
--- a/util/showboard.c
+++ b/util/showboard.c
@@ -1,14 +1,6 @@
/* $Id$ */
/* 看板一覽表(sorted) */
-
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include "config.h"
-#include "pttstruct.h"
+#include "bbs.h"
boardheader_t allbrd[MAX_BOARD];
diff --git a/util/toplazyBM.c b/util/toplazyBM.c
index 7d03c07f..5e74478b 100644
--- a/util/toplazyBM.c
+++ b/util/toplazyBM.c
@@ -45,7 +45,7 @@ int main(int argc, char *argv[])
{
int bmid, i, j=0;
FILE *inf, *firef;
- time_t now=time(NULL);
+ time4_t now=time(NULL);
attach_SHM();
resolve_boards();
diff --git a/util/uhash_loader.c b/util/uhash_loader.c
index 86c47414..add528ba 100644
--- a/util/uhash_loader.c
+++ b/util/uhash_loader.c
@@ -1,28 +1,9 @@
/* $Id$ */
/* standalone uhash loader -- jochang */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <sys/mman.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-
-#ifdef __FreeBSD__
-#include <machine/param.h>
-#endif
-
-#include "config.h"
-#include "pttstruct.h"
-#include "common.h"
+#include "bbs.h"
unsigned string_hash(unsigned char *s);
-void add_to_uhash(int n, userec_t *id);
+void userec_add_to_uhash(int n, userec_t *id);
void fill_uhash(void);
void load_uhash(void);
@@ -93,7 +74,7 @@ void fill_uhash(void)
for (mimage = fimage; usernumber < fd; mimage += sizeof(userec_t))
{
- add_to_uhash(usernumber, (userec_t *)mimage);
+ userec_add_to_uhash(usernumber, (userec_t *)mimage);
usernumber++;
}
munmap(fimage, stbuf.st_size);
@@ -114,10 +95,10 @@ unsigned string_hash(unsigned char *s)
v = (v << 8) | (v >> 24);
v ^= toupper(*s++); /* note this is case insensitive */
}
- return (v * 2654435769UL) >> (32 - HASH_BITS);
+ return (v * 2654435769U) >> (32 - HASH_BITS);
}
-void add_to_uhash(int n, userec_t *user)
+void userec_add_to_uhash(int n, userec_t *user)
{
int *p, h = string_hash(user->userid);
strcpy(SHM->userid[n], user->userid);
diff --git a/util/userlist.c b/util/userlist.c
index 794a3daf..aa549a8a 100644
--- a/util/userlist.c
+++ b/util/userlist.c
@@ -1,11 +1,5 @@
-/* $id:$ */
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include "config.h"
-#include "pttstruct.h"
+/* $Id$ */
+#include "bbs.h"
SHM_t *SHM;
@@ -33,7 +27,7 @@ int main(int argc, char **argv) {
f = &SHM->uinfo[i];
printf(
- "%4d(%d) p[%d] i[%d] u[%s] n[%s] f[%s] m[%d] t[%ld]\n",
+ "%4d(%d) p[%d] i[%d] u[%s] n[%s] f[%s] m[%d] t[%d]\n",
++counter, i, f->pager, f->invisible, f->userid,
f->username, f->from, f->mode, f->lastact);
}
diff --git a/util/xchatd.c b/util/xchatd.c
index 22be9620..00c897e3 100644
--- a/util/xchatd.c
+++ b/util/xchatd.c
@@ -83,7 +83,7 @@ struct ChatUser
int uflag;
int clitype; /* Xshadow: client type. 1 for common client,
* 0 for bbs only client */
- time_t uptime; /* Thor: unused */
+ time4_t uptime; /* Thor: unused */
char userid[IDLEN + 1]; /* real userid */
char chatid[9]; /* chat id */
char lasthost[30]; /* host address */
@@ -223,12 +223,12 @@ logit(key, msg)
char *key;
char *msg;
{
- time_t now;
+ time4_t now;
struct tm *p;
char buf[512];
- time(&now);
- p = localtime(&now);
+ now = (time4_t)time(NULL);
+ p = localtime4(&now);
sprintf(buf, "%02d/%02d %02d:%02d:%02d %-13s%s\n",
p->tm_mon + 1, p->tm_mday,
p->tm_hour, p->tm_min, p->tm_sec, key, msg);
@@ -821,10 +821,9 @@ exit_room(user, mode, msg)
static char datemsg[32];
char *
-Ctime(clock)
- time_t *clock;
+Ctime(time4_t *clock)
{
- struct tm *t = localtime(clock);
+ struct tm *t = localtime4(clock);
static char week[] = "日一二三四五六";
sprintf(datemsg, "%d年%2d月%2d日%3d:%02d:%02d 星期%.2s",
@@ -891,9 +890,9 @@ chat_date(cu, msg)
ChatUser *cu;
char *msg;
{
- time_t thetime;
+ time4_t thetime;
- time(&thetime);
+ thetime = time(NULL);
sprintf(chatbuf, "◆ 標準時間: %s", Ctime(&thetime));
send_to_user(cu, chatbuf, 0, MSG_MESSAGE);
}
@@ -3288,7 +3287,7 @@ main()
register fd_set *rptr, *xptr;
fd_set rset, xset;
struct timeval tv;
- time_t uptime, tmaintain;
+ time4_t uptime, tmaintain;
msock = start_daemon();
diff --git a/util/yearsold.c b/util/yearsold.c
index a3a78d27..1418cd59 100644
--- a/util/yearsold.c
+++ b/util/yearsold.c
@@ -30,11 +30,11 @@ int main(int argc, char **argv)
FILE *fp;
int year, max, item, maxyear, totalyear;
int act[25];
- time_t now;
+ time4_t now;
struct tm *ptime;
now = time(NULL);
- ptime = localtime(&now);
+ ptime = localtime4(&now);
attach_SHM();
if(passwd_init())