/* * main.c -- TODAY main for MS-DOS & Human68k & unix & Windows version * * Copyright (C) 1989,1997,1999,2001,2003 by Yoshifumi Mori * * tab:4 */ #include "cdefs.h" #include "extern.h" const char *fmt_sep1 = "/\t "; const char *fmt_sep2 = ",\t "; const char *fmt_sep3 = "\t "; const char *fmt_sep4 = ""; const char *todaycnf_file = "today.cnf"; char msgbuf[MAXMSGBUF]; /* 各種メッセージ出力バッファ */ int screen_max_columns = _T_MAXWIDTH; /* 画面の最大桁数 */ int screen_max_rows = _T_MAXROWS; /* 画面の最大行数 */ struct NOWDATE calendar; struct MONTHTBL monthtbl[MAX_MONTH_TBL]; #if defined(_T_WINDOWS) int win_colormap[MAX_COLORMAP] = { 0x000000, 0x0000AA, 0x00AA00, 0x0055AA, 0xAA0000, 0xAA00AA, 0xAAAA00, 0xAAAAAA, 0x555555, 0x5555FF, 0x55FF55, 0x55FFFF, 0xFF5555, 0xFF55FF, 0xFFFF55, 0xFFFFFF, }; /* 色の RGB */ int win_default_color = 0x07; /* デフォルト色 */ int sysflags = 0; int extflags = 0; char *disp_fontname; int disp_fontsize; #endif /* _T_WINDOWS */ int birthday_flag = TRUE; /* 誕生日表示制御 */ int date_flag = TRUE; /* 日付表示制御 */ int event_flag = TRUE; /* イベント表示制御 */ int history_flag = TRUE; /* 歴史表示制御 */ int schedule_flag = TRUE; /* スケジュール表示制御 */ int display_order[MAX_DISPLAY_ORDER]; /* 表示順序 */ #if !defined(_T_WINDOWS) static int verbose_flag = FALSE; /* バージョン表示制御 */ #else /* !_T_WINDOWS */ static HWND ghWnd; #endif static char cmdpathbuf[_T_MAXPATHNAME]; #if defined(_T_UNIX) static char defpathbuf[_T_MAXPATHBUF]; #endif static const struct OPERAND_TABLE optbl_yesno[] = { { "yes", TRUE }, { "no", FALSE }, { NULL, 0 } }; static const struct OPERAND_TABLE optbl_notice[] = { { "mark_only", NOTICE_MARK_ONLY }, { "all", NOTICE_ALL }, { "no", NOTICE_NO }, { NULL, 0 } }; static const struct OPERAND_TABLE optbl_sortorder[] = { { "昇順", SORT_UP_ORDER }, { "降順", SORT_DOWN_ORDER }, { "なし", SORT_NO_ORDER }, { NULL, 0 } }; static const struct OPERAND_TABLE optbl_birth_age[] = { { "all", BIRTHDAY_AGE_ALL }, { "man_only", BIRTHDAY_AGE_MAN_ONLY }, { "young_only", BIRTHDAY_AGE_YOUNG_ONLY }, { "no", BIRTHDAY_AGE_NO }, { NULL, 0 } }; static const struct OPERAND_TABLE optbl_date_year[] = { { "和暦", DATE_YEAR_JC }, { "西暦", DATE_YEAR_AD }, { NULL, 0 } }; static const struct OPERAND_TABLE optbl_date_time[] = { { "12h", DATE_TIMESYSTEM_12H }, { "24h", DATE_TIMESYSTEM_24H }, { NULL, 0 } }; static const struct OPERAND_TABLE optbl_msg_fold[] = { { "type", MSG_FOLDTYPE_BASE }, { NULL, 0 } }; #if defined(_T_MSDOS) static const struct OPERAND_TABLE optbl_machine[] = { { "ibm", MACHINE_IBM }, { "pc98", MACHINE_PC98 }, { "none", MACHINE_NONE }, { NULL, 0 } }; #endif /* _T_MSDOS */ static struct CONFIG_VARIABLE_TABLE conf_tbl[] = { { "12choku", VAR_OP, { optbl_yesno }, { &date_12_flag } }, { "28syuku", VAR_OP, { optbl_yesno }, { &date_28_flag } }, { "birthday", VAR_OP, { optbl_yesno }, { &birthday_flag } }, { "birthday_addinfo", VAR_INT, { NULL }, { &birthday_addinfo } }, { "birthday_age_class", VAR_OP, { optbl_birth_age }, { &birthday_agelevel } }, { "birthday_age_sort", VAR_OP, { optbl_sortorder }, { &birthday_agesort } }, { "birthday_file", VAR_DIMSTR, { (void *)MAXBIRTHFILE }, { birthday_filetbl } }, { "birthday_flower_always", VAR_OP, { optbl_yesno }, { &birthday_flower } }, { "birthday_notice", VAR_OP, { optbl_notice }, { &birthday_notice_flag } }, { "birthday_notice_range", VAR_INT, { NULL }, { &birthday_notice_range } }, { "birthday_sort", VAR_STR, { NULL }, { &birthday_sortorder } }, { "date", VAR_OP, { optbl_yesno }, { &date_flag } }, { "deathday", VAR_OP, { optbl_yesno }, { &deathday_flag } }, { "deathday_age", VAR_INT, { NULL }, { &deathday_agelevel } }, { "deathday_notice", VAR_OP, { optbl_notice }, { &deathday_notice_flag } }, { "deathday_notice_range", VAR_INT, { NULL }, { &deathday_notice_range } }, { "display_order_birthday", VAR_INT, { NULL }, { &display_order[2] } }, { "display_order_date", VAR_INT, { NULL }, { &display_order[0] } }, { "display_order_event", VAR_INT, { NULL }, { &display_order[1] } }, { "display_order_history", VAR_INT, { NULL }, { &display_order[3] } }, { "display_order_schedule", VAR_INT, { NULL }, { &display_order[4] } }, { "eto", VAR_OP, { optbl_yesno }, { &date_eto_flag } }, { "eto2", VAR_OP, { optbl_yesno }, { &date_eto2_flag } }, { "event", VAR_OP, { optbl_yesno }, { &event_flag } }, { "event_file", VAR_DIMSTR, { (void *)MAXEVENTFILE }, { event_filetbl } }, { "event_level", VAR_STR, { NULL }, { &event_level_str } }, { "event_notice", VAR_OP, { optbl_notice }, { &event_notice_flag } }, { "event_notice_range", VAR_INT, { NULL }, { &event_notice_range } }, { "event_range", VAR_OP, { optbl_yesno }, { &event_range_flag } }, { "event_sort", VAR_STR, { NULL }, { &event_sortorder } }, { "history", VAR_OP, { optbl_yesno }, { &history_flag } }, { "history_addinfo", VAR_INT, { NULL }, { &history_addinfo } }, { "history_both_date", VAR_OP, { optbl_yesno }, { &history_both_date } }, { "history_file", VAR_DIMSTR, { (void *)MAXHISTORYFILE }, { history_filetbl } }, { "history_foldtype", VAR_OPNUM, { optbl_msg_fold }, { &history_foldtype } }, { "history_sort", VAR_OP, { optbl_sortorder }, { &history_sort } }, { "history_year_comment", VAR_INT, { NULL }, { &history_year_comment } }, { "kyureki", VAR_OP, { optbl_yesno }, { &date_kyureki_flag } }, { "kyusei", VAR_OP, { optbl_yesno }, { &date_kyusei_flag } }, #if defined(_T_MSDOS) { "machine", VAR_OP, { optbl_machine }, { &machine_type } }, #else /* _T_HUMAN68K || _T_UNIX || _T_WIN32CONSOLE || _T_WINDOWS */ { "machine", VAR_NONE, { NULL }, { NULL } }, #endif { "outputfile", VAR_STR, { NULL }, { &pager_outputfile } }, { "outputfile_keep", VAR_OP, { optbl_yesno }, { &pager_filekeep } }, { "outputfile_path", VAR_STR, { NULL }, { &pager_filelog_path } }, { "pager", VAR_STR, { NULL }, { &pager_cmd } }, { "pause", VAR_OP, { optbl_yesno }, { &pager_pause } }, { "pause_last", VAR_OP, { optbl_yesno }, { &pager_lastpause } }, { "rekichu", VAR_STR, { NULL }, { &rekichu_f_string } }, { "rekichu_kadan", VAR_STR, { NULL }, { &rekichu_kadan_f_string } }, { "replace_pathenv", VAR_OP, { optbl_yesno }, { &replace_pathenv } }, { "schedule", VAR_OP, { optbl_yesno }, { &schedule_flag } }, { "schedule_file", VAR_DIMSTR, { (void *)MAXSCHEDULEFILE }, { schedule_filetbl } }, { "schedule_foldtype", VAR_OPNUM, { optbl_msg_fold }, { &schedule_foldtype } }, { "schedule_limit", VAR_INT, { NULL }, { &schedule_limit } }, #if defined(_T_MSDOS) || defined(_T_UNIX) || defined(_T_WIN32CONSOLE) || defined(_T_WINDOWS) { "screen_columns", VAR_INT, { NULL }, { &screen_max_columns } }, { "screen_rows", VAR_INT, { NULL }, { &screen_max_rows } }, #else /* _T_HUMAN68K */ { "screen_columns", VAR_NONE, { NULL }, { NULL } }, { "screen_rows", VAR_NONE, { NULL }, { NULL } }, #endif { "suffix_file", VAR_STR, { NULL }, { &suffix_file } }, #if defined(_T_HUMAN68K) || defined(_T_MSDOS) || defined(_T_WIN32CONSOLE) || defined(_T_WINDOWS) { "table_path", VAR_STR, { NULL }, { &search_path } }, #else /* _T_UNIX */ { "table_path", VAR_PATH, { NULL }, { &search_path } }, #endif { "time", VAR_OP, { optbl_yesno }, { &date_time_flag } }, { "timesystem", VAR_OP, { optbl_date_time }, { &date_timesystem_type } }, { "week_file", VAR_DIMSTR, { (void *)MAXWEEKFILE }, { week_filetbl } }, { "year_type", VAR_OP, { optbl_date_year }, { &date_yeartype } }, #if defined(_T_WINDOWS) { "colormap", VAR_DIMINT, { (void *)MAX_COLORMAP }, { win_colormap }, 0x61 }, { "default_color", VAR_INT, { NULL }, { &win_default_color }, 0x21 }, { "extflags", VAR_INT, { NULL }, { &extflags }, 0x81 }, { "file_editor", VAR_STR, { NULL }, { &file_editor_cmd } }, { "find_editor", VAR_STR, { NULL }, { &find_editor_cmd } }, { "screen_fontname", VAR_STR, { NULL }, { &disp_fontname } }, { "screen_fontsize", VAR_INT, { NULL }, { &disp_fontsize } }, { "sysflags", VAR_INT, { NULL }, { &sysflags }, 0x81 }, #endif /* _T_WINDOWS */ { NULL, VAR_NONE, { NULL }, { NULL } } }; #if defined(_T_WINDOWS) static const char *readblock[] = { "today", "common", "windows", "wintoday", NULL }; #else static const char *readblock[] = { "today", "common", NULL }; #endif #if !defined(_T_WINDOWS) /* * メモリエラー処理 */ void memerr(const char *func) { errprint(func, ERR_PANIC, "virtual memory exhausted, program stop."); terminate_program(TERM_MEMERROR); } #endif /* !_T_WINDOWS */ #if !defined(_T_WINDOWS) /* * 実行中のエラー表示 * * func: 実行関数名 * level: エラーレベル (information, warning, debug, error, panic) * fmt: エラーメッセージ */ void errprint(const char *func, int level, const char *fmt, ...) { static const char *statname[] = { "warning", "debug", "error", "panic", }; va_list ap; va_start(ap, fmt); fprintf(stderr, "today: %s"); if (level != ERR_INFO) { fprintf(stderr, "%s: ", statname[level - ERR_WARN]); } if (func != NULL) { fprintf(stderr, "%s: ", func); } vfprintf(stderr, fmt, ap); fputc('\n', stderr); va_end(ap); } #endif /* !_T_WINDOWS */ #if !defined(_T_WINDOWS) /* * インタラプトやエラーによるプログラム中断処理 */ void terminate_program(int sig) { switch (sig) { case SIGINT: pager_clean(TRUE); exit(4); break; case TERM_MEMERROR: pager_clean(FALSE); exit(1); break; case TERM_FILEERROR: pager_clean(FALSE); exit(2); break; } exit(99); } #endif /* !_T_WINDOWS */ /* * 使用法の表示 * * 表示後、プログラム停止 */ static void usage(void) { #if !defined(_T_WINDOWS) fprintf(stderr, "usage: today [options] [[YYYY|YY]MMDD]\n" "options:" " -a|-A\t全部の表示制御\t\t-aで表示(-dbehと同じ)\n" "\t -d|-D\t日付の表示制御\t\t-dで表示\n" "\t -b|-B\t誕生日の表示制御\t-bで表示\n" "\t -e|-E\tイベントの表示制御\t-eで表示\n" "\t -h|-H\t歴史の表示制御\t\t-hで表示\n" "\t -s|-S\tスケジュールの表示制御\t-sで表示\n" "\t -p|-P\tページャーの動作制御\t-pで作動\n" "\t -w|-W\t和暦・西暦表示切替\t-wで和暦\n" "\t -v\tバージョン表示\n\n" "\t -@file\t一時的な%s(file)の読み込み\n" "\t -rvarname=value 一時的な変数の変更\n", todaycnf_file); exit(3); #else /* !_T_WINDOWS */ char szMsg[512]; char szTitle[64]; sprintf(szMsg, "%s [options] [[YYYY|YY]MMDD]\n\n" "options:" "\t-a | -A\t\t全部の表示制御\n\t\t\t-aで表示(-dbehと同じ)\n" "\t-d | -D\t\t日付の表示制御\n\t\t\t-dで表示\n" "\t-b | -B\t\t誕生日の表示制御\n\t\t\t-bで表示\n" "\t-e | -E\t\tイベントの表示制御\n\t\t\t-eで表示\n" "\t-h | -H\t\t歴史の表示制御\n\t\t\t-hで表示\n" "\t-s | -S\t\tスケジュールの表示制御\n\t\t\t-sで表示\n" "\t-w | -W\t\t和暦・西暦表示切替\n\t\t\t-wで和暦\n" "\t-@file\t\t一時的な %s(file) の読み込み\n" "\t-rvarname=value\t一時的な変数の変更", szAppName, todaycnf_file); sprintf(szTitle, "%sのオプション", szAppName); MessageBox(ghWnd, szMsg, szTitle, MB_OK); /* exit(3); */ #endif /* !_T_WINDOWS */ } /* * 日付の正当性判断 * * return value: * TRUE 日付正常 * FALSE 日付エラー */ #if !defined(_T_WINDOWS) static #endif int isDate(int year, int month, int day) { if (year < SUPPORT_MIN_YEAR || year > SUPPORT_MAX_YEAR) { return (FALSE); } if (month < 1 || month > 12) { return (FALSE); } if (day < 1 || day > GetDayofMonth(year, month)) { return (FALSE); } return (TRUE); } /* * 数字列かを判断する * * return value: * TRUE 数字列 or ヌル文字列 * FALSE それ以外 */ static int isNumstring(const char *s) { while (*s != '\0') { if (isdigit((unsigned char)*s) == 0) { return (FALSE); } s++; } return (TRUE); } /* * 日付の読み取り * * return value: * TRUE 読み取り正常 * FALSE エラー発生 */ static int readDate(const char *param) { int err = FALSE; if (isNumstring(param) == FALSE) { err = TRUE; } else { switch (strlen(param)) { case 8: /* YYYYMMDD */ sscanf(param, "%04d%02d%02d", &calendar.year, &calendar.month, &calendar.day); break; case 6: /* YYMMDD */ sscanf(param, "%02d%02d%02d", &calendar.year, &calendar.month, &calendar.day); if (calendar.year < 50) { calendar.year += 2000; /* 00-49 -> 2000-2049 */ } else { calendar.year += 1900; /* 50-99 -> 1950-1999 */ } break; case 4: /* MMDD */ sscanf(param, "%02d%02d", &calendar.month, &calendar.day); break; case 2: /* DD */ calendar.day = atoi(param); break; default: err = TRUE; break; } } if (err == TRUE) { errprint(NULL, ERR_ERROR, "invalid DATE format %s", param); return (FALSE); } if (isDate(calendar.year, calendar.month, calendar.day) == FALSE) { errprint(NULL, ERR_ERROR, "illegal DATE %d/%02d/%02d", calendar.year, calendar.month, calendar.day); return (FALSE); } return (TRUE); } /* * 日付を変更する */ static void changes_date(int argc, char **argv) { int phase = 0; while (argc > 0) { if (**argv == '+') { ++*argv; date_inc((struct DATE_T *)&calendar, atoi(*argv)); /* * struct NOWDATE の先頭 4項目が * struct DATE_T と同じことを利用 */ phase = 1; } else { if (phase == 0) { if (readDate(*argv) != FALSE) { phase = 1; date_time_inhibit = TRUE; /* 日付を変更したら時刻は表示しない date.c */ #if !defined(_T_WINDOWS) } else { usage(); #endif } } } argc--; argv++; } } /* * オプションパラメータの解析 * * return value: * TRUE パラメータOK * FALSE エラー */ static int option_check(int argc, char **argv) { int c; int flag; while ((c = getopt(argc, argv, "0@::AaBbDdEeHhPpq::r::SsTtvWw?")) != EOF) { flag = islower(c) ? TRUE : FALSE; switch (c) { case 'A': case 'a': /* 全部の表示制御 */ birthday_flag = flag; date_flag = flag; event_flag = flag; history_flag = flag; break; case 'D': case 'd': /* 日付表示制御 */ date_flag = flag; break; case 'T': case 't': /* 時間制選択 */ date_timesystem_type = (c == 'T') ? DATE_TIMESYSTEM_24H : DATE_TIMESYSTEM_12H; break; case 'B': case 'b': /* 誕生日表示制御 */ birthday_flag = flag; break; case '0': /* 年齢表示 */ birthday_agelevel = BIRTHDAY_AGE_ALL; break; case 'E': case 'e': /* イベント表示制御 */ event_flag = flag; break; case 'H': case 'h': /* 歴史表示制御 */ history_flag = flag; break; case 'S': case 's': /* スケジュール表示制御 */ schedule_flag = flag; break; #if !defined(_T_WINDOWS) case 'P': case 'p': /* ページャー動作制御 */ pager_action = flag; break; #endif case 'W': case 'w': /* 西暦表示・和暦表示 */ date_yeartype = (c == 'W') ? DATE_YEAR_AD : DATE_YEAR_JC; break; #if !defined(_T_WINDOWS) case 'v': /* バージョン表示 */ verbose_flag = TRUE; break; #endif #if defined(_T_WINDOWS) case'q': /* quick(skip splash window) */ if (optarg == NULL) { splash_timeout = 0; } else { splash_timeout = strtol(optarg, NULL, 0) * 1000; } break; #endif case 'r': /* 一時的な変数の設定 */ if (optarg != NULL) { config_oneline("cmdline", &conf_tbl[0], optarg); } break; case '@': /* 一時的な TODAY.CNF の読み込み */ config(optarg, &conf_tbl[0], &readblock[0]); break; case '?': /* 使用法表示 */ default: usage(); return (FALSE); } } return (TRUE); } /* * TODAY configuration procedure * * 定義ファイルの読み込み * カレンダー読み込み * オプションチェック * * return value: * TRUE 正常終了 * FALSE エラー発生 */ #if !defined(_T_WINDOWS) static #endif int configuration_today(int argc, char **argv) { int c_rtc; #if defined(_T_HUMAN68K) || defined(_T_MSDOS) || defined(_T_WIN32CONSOLE) || defined(_T_WINDOWS) { char *p; strncpy(cmdpathbuf, argv[0], sizeof(cmdpathbuf) - 1); p = strrchr(cmdpathbuf, _T_FS_CHR); if (p == NULL) { p = strrchr(cmdpathbuf, '/'); if (p == NULL) { p = strrchr(cmdpathbuf, ':'); } } if (p != NULL) { p[1] = '\0'; search_cmdpath = cmdpathbuf; } } #else /* _T_UNIX */ if (readlink(_T_PROCSELFEXE_PATH, cmdpathbuf, sizeof(cmdpathbuf) - 1) > 0 && cmdpathbuf[0] == '/') { char *p; p = strrchr(cmdpathbuf, '/'); if (p != NULL) { p[1] = '\0'; } search_cmdpath = cmdpathbuf; } (void)setlocale(LC_ALL, ""); strncpy(defpathbuf, _T_SEARCH_DEFPATHS, sizeof(defpathbuf) - 1); search_defpath = defpathbuf; #endif search_envname = "TODAYTBL"; replace_pathenv = TRUE; c_rtc = config(todaycnf_file, &conf_tbl[0], &readblock[0]); #if defined(_T_UNIX) /* * unix では _T_SEARCH_DEFPATH の today.cnf が読めたら HOME の * today.cnf を読み込む * * table_path は & を HOME にある today.cnf の table_path に設定してい * れば & の部分を以前のパスと置き換える * * 例 table_path = &:/home/mori/tbl */ if (c_rtc == 0 && search_hitphase == 1) { /* _T_SEARCH_DEFPATH で発見できた */ search_errignore = TRUE; search_gophase = 6; /* _T_HOMEENV を調べる */ (void)config(todaycnf_file, &conf_tbl[0], &readblock[0]); search_gophase = 0; search_errignore = FALSE; } #endif /* _T_UNIX */ rdcalendar((struct CALENDAR *)&calendar); /* * struct NOWDATE の先頭 7項目が struct CALENDAR と同じことを利用 */ if (option_check(argc, argv) == FALSE) { return (FALSE); } argc -= optind; argv += optind; changes_date(argc, argv); if (Loading_GengoTbl() != LOAD_OK) { errprint(NULL, ERR_ERROR, "年号変換はできません"); } if (Loading_SuffixTbl() != LOAD_OK) { errprint(NULL, ERR_ERROR, "接尾語変換はできません"); } if (Loading_HolidayTbl() != LOAD_OK) { errprint(NULL, ERR_ERROR, "祝日・休日の処理はできません"); } #if !defined(_T_WINDOWS) machine_setup(); #endif return (TRUE); } /* * 内部カレンダー変数を初期化する * * 構造体 calendar を設定する * 構造体 monthtbl を設定する(3か月分) */ static void setup_calendar(void) { const struct kansi_t *k; const struct LUNAR_CALENDAR *lc; struct LC_MONTHTBL lc_montbl[MAX_MONTH_TBL]; int i; calendar.dayofweek = GetDayofWeek(calendar.year, calendar.month, calendar.day); calendar.leap = isleap(calendar.year); calendar.julian_day = Julian(calendar.year, calendar.month, calendar.day); k = kansi(calendar.year, calendar.month, calendar.julian_day); calendar.eto = k->et; calendar.de = k->de; calendar.dt = k->dt; lc = GetLunarCalendar(calendar.year, calendar.month, calendar.day); if (lc != NULL) { calendar.lc_valid = TRUE; calendar.lc_year = lc->year; calendar.lc_month = lc->month; calendar.lc_day = lc->day; calendar.lc_leap = lc->leap; calendar.lc_dayofweek = lc->dayofweek; strcpy(calendar.lc_rokuyou, lc->rokuyou); } else { calendar.lc_valid = FALSE; calendar.lc_year = 0; calendar.lc_month = 0; calendar.lc_day = 0; calendar.lc_leap = 0; calendar.lc_dayofweek = 0; calendar.lc_rokuyou[0] = '\0'; errprint(NULL, ERR_ERROR, "旧暦を求めることができません"); } for (i = 0; i < MAX_MONTH_TBL; i++) { int nyear; int nmonth; int j; nyear = calendar.year; nmonth = calendar.month + (i - CENTER_MONTH); if (nmonth < 1) { nyear--; nmonth += 12; } if (nmonth > 12) { nyear++; nmonth -= 12; } monthtbl[i].year = nyear; monthtbl[i].month = nmonth; monthtbl[i].leap = isleap(nyear); monthtbl[i].dayofmonth = GetDayofMonth(nyear, nmonth); monthtbl[i].first_dayofweek = GetDayofWeek(nyear, nmonth, 1); monthtbl[i].last_dayofweek = GetDayofWeek(nyear, nmonth, monthtbl[i].dayofmonth); monthtbl[i].offset_day = 0; for (j = i - 1; j >= 0; j--) { monthtbl[i].offset_day += monthtbl[j].dayofmonth; } } makeHolidayTbl(); if (make_lc_monthtbl(&lc_montbl[0], MAX_MONTH_TBL, CENTER_MONTH, calendar.year, calendar.month, calendar.day) != 0) { calendar.lc_tbl = FALSE; return ; } calendar.lc_tbl = TRUE; for (i = 0; i < MAX_MONTH_TBL; i++) { monthtbl[i].lc = lc_montbl[i]; } } /* * TODAY main procedure */ #if defined(_T_WINDOWS) int execute_today(HWND hWnd, int mode) #else static int execute_today(void) #endif { int i; #if defined(_T_WINDOWS) ghWnd = hWnd; switch (mode) { case T_CALL_FIRST: break; case T_CALL_DATENOW: rdcalendar((struct CALENDAR *)&calendar); /* * struct NOWDATE の先頭 7項目が struct CALENDAR と同じことを利用 */ date_time_inhibit = FALSE; break; case T_CALL_DATECHANGE: date_time_inhibit = TRUE; /* 日付を変更したら時刻は表示しない date.c */ break; } #endif setup_calendar(); #if !defined(_T_WINDOWS) signal(SIGINT, terminate_program); #endif pager_init(); #if !defined(_T_WINDOWS) if (verbose_flag) { pager_output(Copyright); #ifdef TRANS pager_output(Modify); #endif pager_output(Version); pager_output("Compiled with %s", UseLanguage); } #endif for (i = 0; i <= MAX_DISPLAY_ORDER; i++) { if (display_order[0] == i && date_flag) { date(); } if (display_order[1] == i && event_flag) { event(); } if (display_order[2] == i && birthday_flag) { birthday(); } if (display_order[3] == i && history_flag) { history(); } if (display_order[4] == i && schedule_flag) { schedule(); } } pager_term(); return (0); } /* * TODAY terminate procedure */ #if defined(_T_WINDOWS) void terminate_today(HWND hWnd) #else static void terminate_today(void) #endif { #if defined(_T_WINDOWS) pager_text_free(); #endif } #if defined(_T_WINDOWS) /* * 設定情報の保存 */ void preserveConfig(HWND hWnd) { if (writeConfig(todaycnf_file, &conf_tbl[0], &readblock[0]) == FALSE) { MessageBox(hWnd, "TODAY.CNF 保存時にエラーが発生しました", "プロパティ", MB_ICONEXCLAMATION | MB_OK); } } #endif #if !defined(_T_WINDOWS) /* * TODAY main for DOS/human68k/unix/win32 console */ int main(int argc, char **argv) { configuration_today(argc, argv); execute_today(); terminate_today(); return (0); } #endif /* !_T_WINDOWS */