jhcal.c

祝日表示カレンダーコマンドメインページ [詳細]

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "number_set.h"

型定義

typedef void(* Calfunc )(void)

関数

void argcheck (int argc, char *argv[])
void year_month_check_main (char chmonth[10], char chyear[10], int *month, int *year)
void year_check_main (char chyear[10], int *year)
int selects (char comarg[11])
void month_mes ()
void year_mes ()
void use_mes ()
void month_print_calendar (int year, int month)
void this_month_cal ()
void this_year_cal ()
void this_three_month ()
void input_ym_three (int year, int month)
void this_fiscal_cal ()
void input_fiscal_cal (int year)
void next_month_cal ()
void before_month_cal ()
void next_year_cal ()
void before_year_cal ()
void next_fiscal_cal ()
void before_fiscal_cal ()
void this_month_cal_gengoh ()
void year_check (int year)
void month_check (int month)
int main (int argc, char *argv[])

説明

祝日表示カレンダーコマンドメインページ

作者:
y_okamon
バージョン:
1.0(2007.04.25) 初版
1.1(2008.10.14)
コマンドプログラムのオプション追加について
(1) 次月を表示する関数next_month_cal、前月を表示する関数before_month_calの参照を行う
(2) 次年を表示する関数next_year_cal、前年を表示する関数before_year_calの参照を行う
(3) 次年度を表示する関数next_year_cal、前年度を表示する関数before_fiscal_calの参照を行う

ファイルoutput_calendar.cに参照される仮引数なしの関数について
(1) これらの関数をCalfunc型のポインタの配列として宣言
(2) 宣言された配列の要素番号に対応したコマンドオプションを配列として宣言
(3) コマンドオプションを関数selectsに設定、入力されたコマンドオプションがあるかどうか調べる
(4) 対応するコマンドオプションがあった場合は、それに対応する関数を参照するように変更
(5) これにより、関数argcheckの行数の膨大を抑えることに成功

年月チェックについて
(1) 関数year_month_check_main、year_check_mainを新に設計
(2) (1)で設計された各関数の処理に関数year_checkと関数month_checkを参照させる
(3) これにより、関数argcheckの行数の膨大を抑えることに成功

その他の仕様変更
jhcal month yearと入力されたときの参照関数を関数input_ym_calから、関数month_print_calendarに変更
 

型定義

typedef void(* Calfunc)(void)

機能
関数をポインタ配列で管理する


関数

void argcheck ( int  argc,
char *  argv[] 
)

機能
入力された引数をチェックして、様々なカレンダーを表示する

引数:
argc 入力された引数の数
*argv[] 入力された引数の内容

処理詳細
ファイルerror_mes.c内 関数use_mes()の内容を参照

被参照自作関数
ファイルjhcal.c内 関数main

参照自作関数
ファイルopreate_calendar.c内 関数this_month_cal
ファイルopreate_calendar.c内 関数month_print_calendar
ファイルopreate_calendar.c内 関数this_year_cal
ファイルopreate_calendar.c内 関数input_year_cal
ファイルopreate_calendar.c内 関数this_fiscal_cal
ファイルopreate_calendar.c内 関数input_fiscal_cal
ファイルopreate_calendar.c内 関数this_three_month
ファイルopreate_calendar.c内 関数input_three_month
ファイルopreate_calendar.c内 関数next_month_cal
ファイルopreate_calendar.c内 関数before_month_cal
ファイルopreate_calendar.c内 関数next_year_cal
ファイルopreate_calendar.c内 関数before_year_cal
ファイルopreate_calendar.c内 関数next_fiscal_cal
ファイルopreate_calendar.c内 関数before_year_cal
ファイルopreate_calendar_gengoh.c内 関数this_month_cal_gengoh
ファイルoutput_calendar.c内 関数month_print_calendar
ファイルjhcal.c内 関数year_check_main
ファイルjhcal.c内 関数year_month_check_main
ファイルjhcal.c内 関数selects
ファイルerror.c内 関数use_mes

void before_fiscal_cal (  ) 

機能
前年度のカレンダーを表示する

処理詳細
(1) システム上の年と月を取得する
(2) 年をマイナス1する。 (3) 取得した月が1月〜3月の間であったら、年を1年マイナス
(4) 取得した年をinput_year_cal関数で処理

被参照自作関数
ファイルhcal.c内 関数argcheck

参照自作関数
ファイルoutput_calendar内 関数input_fiscal_cal

備考
この間数の仮引数は存在しない

更新履歴
2008.10.10 Ver1.1 初版

void before_month_cal (  ) 

機能
先月のカレンダーを表示する

処理詳細
(1) システム上の年月を取得する。
(2) 取得した年月を関数month_print_calendarで処理

被参照自作関数
ファイルhcal.c内 関数argcheck

参照自作関数
ファイルoutput_calendar内 関数month_print_calendar

備考
この間数には仮引数は存在しない

void before_year_cal (  ) 

機能
昨年の年間カレンダーを表示する

処理詳細
(1) システム上の年を取得する
(2) 取得した年から1を引いた年をinput_year_cal関数で処理

被参照自作関数
ファイルhcal.c内 関数argcheck

参照自作関数
ファイルopreate_calendar内 関数input_year_cal

備考
この間数の仮引数は存在しない

更新履歴
2008.10.09 Ver1.0 初版

void input_fiscal_cal ( int  year  ) 

機能
入力された年の年度カレンダーを表示させる

引数:
year 

被参照自作関数
ファイルhcal.c内 関数argcheck
ファイルopreate_calendar内 関数next_fiscal_cal
ファイルopreate_calendar内 関数before_fiscal_cal

参照自作関数
ファイルopeate_calendar.c内 関数input_ym_three

void input_ym_three ( int  year,
int  month 
)

機能 先月、今月、来月の3ヶ月カレンダーを表示する

処理詳細 (1) 入力/システムから獲得した月によって以下の処理をする。
(1.1) 月が1月なら、前年の12月からシステム上の年の2月までのカレンダーを作る。
(1.2) 月が12月なら、11月から翌年の1月までのカレンダーを作る。
(1.3) それ以外の月なら、前の月から翌月までのカレンダーを作る。
(2) 3ヶ月分のカレンダーが作成したら、横にカレンダーを表示する

引数:
year 
month 

被参照自作関数
ファイルhcal.c内 関数argcheck
ファイルoutput_calendar内 関数input_year_cal
ファイルoutput_calendar内 関数input_fiscal_cal

参照自作関数
ファイルopreate_calendar.c内 関数make_array
ファイルcalendar_main.c内 関数make_three_calendar
ファイルcalendar_main.c内 関数make_holiday
ファイルoutput_calendar.c内 関数print_calendar_three
ファイルoutput_calendar.c内 関数row_calendar_main
ファイルoutput_calendar.c内 関数row_holiday

更新履歴
2007.04.25 Ver1.0 初版
2008.10.09 Ver1.1 カレンダーに色を付けるための関数仕様変更

int main ( int  argc,
char *  argv[] 
)

機能
入力されたコマンドのタイプによってさまざまなタイプのカレンダーを表示する。

引数:
argc 入力された引数の数
*argv[] 入力された引数の内容
戻り値:
0 正常終了

被参照自作関数
なし

参照自作関数
ファイルjhcal.c内 関数argcheck

void month_check ( int  month  ) 

機能
入力された月の有効範囲をチェックする

引数:
month 

被参照自作関数
ファイルjhcal.c内 関数year_month_check_main

参照自作関数
ファイルerror_mes.c内 関数month_mes

void month_mes (  ) 

機能
使用可能な月の数値を表示する

被参照自作関数
ファイルhcal.c内 関数month_check

参照自作関数
なし

備考
この間数に仮引数は存在しない

void month_print_calendar ( int  year,
int  month 
)

機能
year年month月のカレンダーを祝日とともに表示する

処理詳細 
(1) year年month月の初日の曜日を算出
(2) year年month月の月日数を取得
(3) 初日から月末までのカレンダーを表示
(3.1) 日曜日なら赤で表示
(3.2) 土曜日なら青で表示
(3.3) それ以外の曜日は黒で表示
(4) 祝日名を表示する

引数:
year 
month 

被参照自作関数
ファイルopreate_calendar.c内 関数next_month_cal
ファイルopreate_calendar.c内 関数before_month_cal
ファイルjhcal.c内 関数argcheck

参照自作関数
ファイルcalendar_main.c内 関数day_of_week
ファイルcalendar_main.c内 関数month_days

void next_fiscal_cal (  ) 

機能
翌年度のカレンダーを表示する

処理詳細
(1) システム上の年と月を取得する
(2) 年をプラス1する。
(3) 取得した月が1月〜3月の間であったら、年を1年マイナス
(4) 取得した年をinput_year_cal関数で処理

被参照自作関数
ファイルhcal.c内 関数argcheck

参照自作関数
ファイルoutput_calendar内 関数input_fiscal_cal

備考
この間数の仮引数は存在しない

void next_month_cal (  ) 

機能
来月のカレンダーを表示する

処理詳細
(1) システム上の年月を取得する。
(2) 取得した年月を関数month_print_calendarで処理

被参照自作関数
ファイルhcal.c内 関数argcheck

参照自作関数
ファイルoutput_calendar内 関数month_print_calendar

備考
この間数には仮引数は存在しない

更新履歴
2008.10.09 Ver1.1 初版

void next_year_cal (  ) 

機能
翌年の年間カレンダーを表示する

処理詳細
(1) システム上の年を取得する
(2) 取得した年+1をinput_year_cal関数で処理

被参照自作関数
ファイルhcal.c内 関数argcheck

参照自作関数
ファイルopreate_calendar内 関数input_year_cal

備考
この間数の仮引数は存在しない

更新履歴
2008.10.09 Ver1.0 初版

int selects ( char  comarg[11]  ) 

機能
入力コマンドがあるかどうか調べる

引数:
comarg[] コマンドラインからの入力
戻り値:
i 配列の番号

被参照自作関数
ファイルjhcal.c内 関数argcheck

参照自作関数
なし

void this_fiscal_cal (  ) 

機能
今年度のカレンダーを表示する

処理詳細
(1) システム上の年と月を取得する
(2) 取得した月が1月〜3月の間であったら、年を1年マイナス
(3) 取得した年をinput_year_cal関数で処理

被参照自作関数
ファイルhcal.c内 関数argcheck

参照自作関数
ファイルoutput_calendar内 関数input_ym_three_today

備考
この間数の仮引数は存在しない

void this_month_cal (  ) 

機能
今月のカレンダーを表示する

処理詳細
(1) システム上の年月を取得する。
(2) 取得した年月を関数month_print_calendar_gengohで処理

被参照自作関数
ファイルjhcal.c内 関数argcheck

参照自作関数
ファイルoutput_calendar内 関数month_print_calendar_today

void this_month_cal_gengoh (  ) 

機能
今月のカレンダーを元号で表記する

処理詳細
(1) システム上の年月を取得する。
(2) 取得した年月を関数month_print_calendar_today_gengohで処理

被参照自作関数
ファイルjhcal.c内 関数argcheck

参照自作関数
ファイルoutput_calendar内 関数month_print_calendar_today_gengoh

void this_three_month (  ) 

機能
前月、今月、来月の3ヶ月を表示する

処理詳細
(1) システム上の年月を取得する
(2) 取得した年をinput_ym_three関数で処理

被参照自作関数
ファイルhcal.c内 関数argcheck

参照自作関数
ファイルopeate_calendar内 関数input_ym_three_today

備考
この間数の仮引数は存在しない

更新履歴 
2007.04.25 Ver1.0 初版
2008.10.17 Ver1.1 システム上の日付は文字色と背景色を反転

void this_year_cal (  ) 

機能
今年の年間カレンダーを表示する

処理詳細
(1) システム上の年を取得する
(2) 取得した年をinput_year_cal関数で処理

被参照自作関数
ファイルhcal.c内 関数argcheck

参照自作関数
ファイルoutput_calendar内 関数input_ym_three_today

備考
この間数の仮引数は存在しない

更新履歴
2007.04.25 Ver1.0 初版
2008.10.17 Ver1.1 システム上の日付は文字色と背景色を反転させる

void use_mes (  ) 

機能
正しいコマンドの利用方法を表示する

被参照自作関数
ファイルhcal.c内 関数argcheck

参照自作関数
なし

備考
この間数に仮引数は存在しない

void year_check ( int  year  ) 

機能
入力された年の有効範囲をチェックする

引数:
year 

被参照自作関数
ファイルjhcal.c内 関数year_month_check_main
ファイルjhcal.c内 関数year_check_main

参照自作関数
ファイルerror_mes.c内 関数year_mes

void year_check_main ( char  chyear[10],
int *  year 
)

機能
(1) コマンドラインからの入力された数字を数値に変換
(2) 変換された数値が有効な年かどうか調べる

引数:
chyear[] 年数字
*year 

被参照自作関数
ファイルjhcal.c内 関数argcheck

参照自作関数
ファイルjhcal.c内 関数year_check

void year_mes (  ) 

機能
使用可能な年の数値を表示する

被参照自作関数
ファイルhcal.c内 関数year_check

参照自作関数
なし

備考
この間数に仮引数は存在しない

更新履歴
2007.04.25 Ver1.0 初版

void year_month_check_main ( char  chmonth[10],
char  chyear[10],
int *  month,
int *  year 
)

機能
(1) コマンドラインからの入力された数字を数値に変換
(2) 変換された数値が有効な年月かどうか調べる

引数:
chmonth 月数字
chyear 年数字
*month 
*year 

被参照自作関数
ファイルjhcal.c内 関数argcheck

参照自作関数
ファイルjhcal.c内 関数month_check
ファイルjhcal.c内 関数year_check

Wed Jun 29 23:59:58 2011に生成されました。  doxygen 1.6.3