diff options
-rw-r--r-- | mbbsd/calendar.c | 7 | ||||
-rw-r--r-- | util/Makefile | 4 | ||||
-rw-r--r-- | util/birth.c | 4 |
3 files changed, 12 insertions, 3 deletions
diff --git a/mbbsd/calendar.c b/mbbsd/calendar.c index 2f2e5af6..60cbd59a 100644 --- a/mbbsd/calendar.c +++ b/mbbsd/calendar.c @@ -1,6 +1,8 @@ /* $Id$ */ #include "bbs.h" +#if !defined(PTTBBS_UTIL) + typedef struct event_t { int year, month, day, days; int color; @@ -324,8 +326,13 @@ calendar(void) return 0; } +#endif + int getHoroscope(int m, int d) { + if (m > 11 || m < 0) + return 1; + // 摩羯 水瓶 雙魚 白羊 金牛 雙子 巨蟹 獅子 處女 天秤 天蠍 射手 const int firstday[12] = { /* Dec. */ 22, /* Jan. */ 20, 19, 21, 20, 21, 21, 23, 23, 23, 23, 22 diff --git a/util/Makefile b/util/Makefile index fca3d4e7..1e997e41 100644 --- a/util/Makefile +++ b/util/Makefile @@ -9,12 +9,12 @@ BBSBASE= ../include/var.h UTIL_OBJS= \ util_cache.o util_record.o util_passwd.o util_var.o \ util_stuff.o util_osdep.o util_args.o util_file.o \ - util_crypt.o + util_crypt.o util_calendar.o MBBSD_OBJS= \ cache record passwd var \ stuff osdep args file \ - crypt + crypt calendar # 下面這些程式, 會被 compile 並且和 $(UTIL_OBJS) 聯結 CPROG_WITH_UTIL= \ diff --git a/util/birth.c b/util/birth.c index e9198ef5..a3503390 100644 --- a/util/birth.c +++ b/util/birth.c @@ -60,6 +60,8 @@ int main(argc, argv) "[40m★[32m★[33m★[34m★[35m★[1m★[m \n\n"); fprintf(fp1, "[33m【[1;45m本日壽星[40;33m】[m \n"); int horoscope = getHoroscope(ptime->tm_mon + 1, ptime->tm_mday); + char path[PATHLEN]; + snprintf(path, sizeof(path), BBSHOME "/etc/Welcome_birth.%d", horoscope); for(j = 1; j <= MAX_USERS; j++) { passwd_query(j, &user); if (bad_user_id(NULL)) @@ -71,7 +73,7 @@ int main(argc, argv) strcpy(mymail.owner, BBSNAME); strcpy(mymail.title, "!! 生日快樂 !!"); unlink(genbuf); - Link(BBSHOME "/etc/Welcome_birth.%d", genbuf, horoscope); + Link(path, genbuf); sprintf(genbuf, BBSHOME "/home/%c/%s/.DIR", user.userid[0], user.userid); append_record(genbuf, &mymail, sizeof(mymail)); if ((user.numlogins + user.numposts) < 20) |