\doxysection{dumpword.\+c}
\label{dumpword_8c_source}\index{src/dumpword.c@{src/dumpword.c}}
\textbf{ Go to the documentation of this file.}
\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{preprocessor}{\#include\ "{}package.h"{}}}
\DoxyCodeLine{00002\ \textcolor{preprocessor}{\#include\ "{}word.h"{}}}
\DoxyCodeLine{00003\ }
\DoxyCodeLine{00007\ \textcolor{keyword}{static}\ \textcolor{keyword}{struct\ }option\ longopts[]\ =\ \{}
\DoxyCodeLine{00008\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}arithmetic"{}},\ no\_argument,\ NULL,\ \textcolor{charliteral}{'a'}\ \},}
\DoxyCodeLine{00009\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}logical"{}},\ no\_argument,\ NULL,\ \textcolor{charliteral}{'l'}\ \},}
\DoxyCodeLine{00010\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}version"{}},\ no\_argument,\ NULL,\ \textcolor{charliteral}{'v'}\ \},}
\DoxyCodeLine{00011\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}help"{}},\ no\_argument,\ NULL,\ \textcolor{charliteral}{'h'}\ \},}
\DoxyCodeLine{00012\ \ \ \ \ \{\ 0,\ 0,\ 0,\ 0\ \},}
\DoxyCodeLine{00013\ \};}
\DoxyCodeLine{00014\ }
\DoxyCodeLine{00023\ \textcolor{keywordtype}{int}\ main(\textcolor{keywordtype}{int}\ argc,\ \textcolor{keywordtype}{char}\ *argv[])}
\DoxyCodeLine{00024\ \{}
\DoxyCodeLine{00025\ \ \ \ \ \textcolor{keywordtype}{bool}\ logicalmode\ =\ \textcolor{keyword}{false};\ \ \ \ \textcolor{comment}{/*\ レジストリの内容を論理値(0から65535)で表示する場合はtrue\ */}}
\DoxyCodeLine{00026\ \ \ \ \ \textcolor{keywordtype}{int}\ opt\ =\ 0;}
\DoxyCodeLine{00027\ \ \ \ \ \textcolor{keywordtype}{int}\ stat\ =\ 0;}
\DoxyCodeLine{00028\ \ \ \ \ WORD\ word\ =\ 0;}
\DoxyCodeLine{00029\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *version\ =\ PACKAGE\_VERSION;}
\DoxyCodeLine{00030\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *cmdversion\ =\ \textcolor{stringliteral}{"{}dumpword\ of\ YACASL2\ version\ \%s\(\backslash\)n"{}};}
\DoxyCodeLine{00031\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *usage\ =\ \textcolor{stringliteral}{"{}Usage:\ \%s\ [-\/alh]\ WORD\(\backslash\)n"{}};}
\DoxyCodeLine{00032\ }
\DoxyCodeLine{00033\ \ \ \ \ \textcolor{comment}{/*\ エラーの定義\ */}}
\DoxyCodeLine{00034\ \ \ \ \ cerr\_init();}
\DoxyCodeLine{00035\ \ \ \ \ addcerrlist\_word();}
\DoxyCodeLine{00036\ }
\DoxyCodeLine{00037\ \ \ \ \ \textcolor{comment}{/*\ オプションの処理\ */}}
\DoxyCodeLine{00038\ \ \ \ \ \textcolor{keywordflow}{while}((opt\ =\ getopt\_long(argc,\ argv,\ \textcolor{stringliteral}{"{}alvh"{}},\ longopts,\ NULL))\ !=\ -\/1)\ \{}
\DoxyCodeLine{00039\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{switch}(opt)\ \{}
\DoxyCodeLine{00040\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ \textcolor{charliteral}{'l'}:}
\DoxyCodeLine{00041\ \ \ \ \ \ \ \ \ \ \ \ \ logicalmode\ =\ \textcolor{keyword}{true};}
\DoxyCodeLine{00042\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00043\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ \textcolor{charliteral}{'v'}:}
\DoxyCodeLine{00044\ \ \ \ \ \ \ \ \ \ \ \ \ fprintf(stdout,\ cmdversion,\ version);}
\DoxyCodeLine{00045\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ dumpwordfin;}
\DoxyCodeLine{00046\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ \textcolor{charliteral}{'h'}:}
\DoxyCodeLine{00047\ \ \ \ \ \ \ \ \ \ \ \ \ fprintf(stdout,\ usage,\ argv[0]);}
\DoxyCodeLine{00048\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ dumpwordfin;}
\DoxyCodeLine{00049\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ \textcolor{charliteral}{'?'}:}
\DoxyCodeLine{00050\ \ \ \ \ \ \ \ \ \ \ \ \ fprintf(stderr,\ usage,\ argv[0]);}
\DoxyCodeLine{00051\ \ \ \ \ \ \ \ \ \ \ \ \ setcerr(999,\ \textcolor{stringliteral}{"{}"{}});}
\DoxyCodeLine{00052\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ dumpwordfin;}
\DoxyCodeLine{00053\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00054\ \ \ \ \ \}}
\DoxyCodeLine{00055\ }
\DoxyCodeLine{00056\ \ \ \ \ \textcolor{keywordflow}{if}(argv[optind]\ ==\ NULL)\ \{}
\DoxyCodeLine{00057\ \ \ \ \ \ \ \ \ fprintf(stderr,\ usage,\ argv[0]);}
\DoxyCodeLine{00058\ \ \ \ \ \ \ \ \ setcerr(999,\ \textcolor{stringliteral}{"{}"{}});}
\DoxyCodeLine{00059\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ dumpwordfin;}
\DoxyCodeLine{00060\ \ \ \ \ \}}
\DoxyCodeLine{00061\ \ \ \ \ \textcolor{comment}{/*\ WORD値に変換\ */}}
\DoxyCodeLine{00062\ \ \ \ \ word\ =\ nh2word(argv[optind]);}
\DoxyCodeLine{00063\ \ \ \ \ \textcolor{keywordflow}{if}(cerr-\/>num\ >\ 0)\ \{}
\DoxyCodeLine{00064\ \ \ \ \ \ \ \ \ fprintf(stderr,\ \textcolor{stringliteral}{"{}Dumpword\ Error\ -\/\ \%d:\ \%s\(\backslash\)n"{}},\ cerr-\/>num,\ cerr-\/>msg);}
\DoxyCodeLine{00065\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ dumpwordfin;}
\DoxyCodeLine{00066\ \ \ \ \ \}}
\DoxyCodeLine{00067\ \ \ \ \ fprintf(stdout,\ \textcolor{stringliteral}{"{}\%6s:\ "{}},\ argv[optind]);}
\DoxyCodeLine{00068\ \ \ \ \ print\_dumpword(word,\ logicalmode);}
\DoxyCodeLine{00069\ \ \ \ \ fprintf(stdout,\ \textcolor{stringliteral}{"{}\(\backslash\)n"{}});}
\DoxyCodeLine{00070\ dumpwordfin:}
\DoxyCodeLine{00071\ \ \ \ \ \textcolor{keywordflow}{if}(cerr-\/>num\ >\ 0)\ \{}
\DoxyCodeLine{00072\ \ \ \ \ \ \ \ \ stat\ =\ 1;}
\DoxyCodeLine{00073\ \ \ \ \ \}}
\DoxyCodeLine{00074\ \ \ \ \ freecerr();\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ エラーの解放\ */}}
\DoxyCodeLine{00075\ \ \ \ \ \textcolor{keywordflow}{return}\ stat;}
\DoxyCodeLine{00076\ \}}
\end{DoxyCode}