\doxysection{casl2rev.\+c}
\label{casl2rev_8c_source}\index{src/casl2rev.c@{src/casl2rev.c}}
\textbf{ Go to the documentation of this file.}
\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{preprocessor}{\#include\ "{}package.h"{}}}
\DoxyCodeLine{00002\ \textcolor{preprocessor}{\#include\ "{}disassemble.h"{}}}
\DoxyCodeLine{00003\ \textcolor{preprocessor}{\#include\ "{}load.h"{}}}
\DoxyCodeLine{00004\ }
\DoxyCodeLine{00008\ \textcolor{keyword}{static}\ \textcolor{keyword}{struct\ }option\ longopts[]\ =\ \{}
\DoxyCodeLine{00009\ \ \ \ \ \{\textcolor{stringliteral}{"{}version"{}},\ no\_argument,\ NULL,\ \textcolor{charliteral}{'v'}\ \},}
\DoxyCodeLine{00010\ \ \ \ \ \{\textcolor{stringliteral}{"{}help"{}},\ no\_argument,\ NULL,\ \textcolor{charliteral}{'h'}\},}
\DoxyCodeLine{00011\ \ \ \ \ \{0,\ 0,\ 0,\ 0\},}
\DoxyCodeLine{00012\ \};}
\DoxyCodeLine{00013\ }
\DoxyCodeLine{00022\ \textcolor{keywordtype}{int}\ main(\textcolor{keywordtype}{int}\ argc,\ \textcolor{keywordtype}{char}\ *argv[])}
\DoxyCodeLine{00023\ \{}
\DoxyCodeLine{00024\ \ \ \ \ \textcolor{keywordtype}{int}\ opt\ =\ 0;}
\DoxyCodeLine{00025\ \ \ \ \ \textcolor{keywordtype}{int}\ stat\ =\ 0;}
\DoxyCodeLine{00026\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *version\ =\ PACKAGE\_VERSION;}
\DoxyCodeLine{00027\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *cmdversion\ =\ \textcolor{stringliteral}{"{}disassemble\ of\ YACASL2\ version\ \%s\(\backslash\)n"{}};}
\DoxyCodeLine{00028\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *usage\ =\ \textcolor{stringliteral}{"{}Usage:\ \%s\ [-\/vh]\ FILE\(\backslash\)n"{}};}
\DoxyCodeLine{00029\ }
\DoxyCodeLine{00030\ \ \ \ \ \textcolor{comment}{/*\ エラーの定義\ */}}
\DoxyCodeLine{00031\ \ \ \ \ cerr\_init();}
\DoxyCodeLine{00032\ \ \ \ \ addcerrlist\_load();}
\DoxyCodeLine{00033\ }
\DoxyCodeLine{00034\ \ \ \ \ \textcolor{comment}{/*\ オプションの処理\ */}}
\DoxyCodeLine{00035\ \ \ \ \ \textcolor{keywordflow}{while}((opt\ =\ getopt\_long(argc,\ argv,\ \textcolor{stringliteral}{"{}vh"{}},\ longopts,\ NULL))\ !=\ -\/1)\ \{}
\DoxyCodeLine{00036\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{switch}(opt)\ \{}
\DoxyCodeLine{00037\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ \textcolor{charliteral}{'v'}:}
\DoxyCodeLine{00038\ \ \ \ \ \ \ \ \ \ \ \ \ fprintf(stdout,\ cmdversion,\ version);}
\DoxyCodeLine{00039\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ casl2revfin;}
\DoxyCodeLine{00040\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ \textcolor{charliteral}{'h'}:}
\DoxyCodeLine{00041\ \ \ \ \ \ \ \ \ \ \ \ \ fprintf(stdout,\ usage,\ argv[0]);}
\DoxyCodeLine{00042\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ casl2revfin;}
\DoxyCodeLine{00043\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ \textcolor{charliteral}{'?'}:}
\DoxyCodeLine{00044\ \ \ \ \ \ \ \ \ \ \ \ \ fprintf(stderr,\ usage,\ argv[0]);}
\DoxyCodeLine{00045\ \ \ \ \ \ \ \ \ \ \ \ \ setcerr(212,\ \textcolor{stringliteral}{"{}"{}});\ \ \ \ \textcolor{comment}{/*\ invalid\ option\ */}}
\DoxyCodeLine{00046\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ casl2revfin;}
\DoxyCodeLine{00047\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00048\ \ \ \ \ \}}
\DoxyCodeLine{00049\ \ \ \ \ \textcolor{keywordflow}{if}(argv[optind]\ ==\ NULL)\ \{}
\DoxyCodeLine{00050\ \ \ \ \ \ \ \ \ setcerr(211,\ \textcolor{stringliteral}{"{}"{}});\ \ \ \ \textcolor{comment}{/*\ object\ file\ not\ specified\ */}}
\DoxyCodeLine{00051\ \ \ \ \ \ \ \ \ fprintf(stderr,\ \textcolor{stringliteral}{"{}disassemble\ error\ -\/\ \%d:\ \%s\(\backslash\)n"{}},\ cerr-\/>num,\ cerr-\/>msg);}
\DoxyCodeLine{00052\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ casl2revfin;}
\DoxyCodeLine{00053\ \ \ \ \ \}}
\DoxyCodeLine{00054\ \ \ \ \ disassemble\_file(argv[optind]);\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ プログラム実行\ */}}
\DoxyCodeLine{00055\ casl2revfin:}
\DoxyCodeLine{00056\ \ \ \ \ \textcolor{keywordflow}{if}(cerr-\/>num\ >\ 0)\ \{}
\DoxyCodeLine{00057\ \ \ \ \ \ \ \ \ stat\ =\ 1;}
\DoxyCodeLine{00058\ \ \ \ \ \}}
\DoxyCodeLine{00059\ \ \ \ \ freecerr();\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ エラーの解放\ */}}
\DoxyCodeLine{00060\ \ \ \ \ \textcolor{keywordflow}{return}\ stat;}
\DoxyCodeLine{00061\ \}}
\end{DoxyCode}