root/doc_inner/doxygen/latex/comet2monitor_8c_source.tex

/* [<][>][^][v][top][bottom][index][help] */
\doxysection{comet2monitor.\+c}
\label{comet2monitor_8c_source}\index{src/comet2monitor.c@{src/comet2monitor.c}}
\textbf{ Go to the documentation of this file.}
\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{preprocessor}{\#include\ "{}package.h"{}}}
\DoxyCodeLine{00002\ \textcolor{preprocessor}{\#include\ "{}exec.h"{}}}
\DoxyCodeLine{00003\ \textcolor{preprocessor}{\#include\ "{}load.h"{}}}
\DoxyCodeLine{00004\ }
\DoxyCodeLine{00008\ \textcolor{keyword}{static}\ \textcolor{keyword}{struct\ }option\ longopts[]\ =\ \{}
\DoxyCodeLine{00009\ \ \ \ \ \{\textcolor{stringliteral}{"{}memorysize"{}},\ required\_argument,\ NULL,\ \textcolor{charliteral}{'M'}\},}
\DoxyCodeLine{00010\ \ \ \ \ \{\textcolor{stringliteral}{"{}clocks"{}},\ required\_argument,\ NULL,\ \textcolor{charliteral}{'C'}\},}
\DoxyCodeLine{00011\ \ \ \ \ \{\textcolor{stringliteral}{"{}version"{}},\ no\_argument,\ NULL,\ \textcolor{charliteral}{'v'}\ \},}
\DoxyCodeLine{00012\ \ \ \ \ \{\textcolor{stringliteral}{"{}help"{}},\ no\_argument,\ NULL,\ \textcolor{charliteral}{'h'}\},}
\DoxyCodeLine{00013\ \ \ \ \ \{0,\ 0,\ 0,\ 0\},}
\DoxyCodeLine{00014\ \};}
\DoxyCodeLine{00015\ }
\DoxyCodeLine{00019\ CERR\ cerr\_comet2monitor[]\ =\ \{}
\DoxyCodeLine{00020\ \ \ \ \ \{\ 401,\ \textcolor{stringliteral}{"{}invalid\ option"{}}\ \},}
\DoxyCodeLine{00021\ \};}
\DoxyCodeLine{00022\ }
\DoxyCodeLine{00023\ \textcolor{keywordtype}{void}\ addcerrlist\_comet2monitor()}
\DoxyCodeLine{00024\ \{}
\DoxyCodeLine{00025\ \ \ \ \ addcerrlist(ARRAYSIZE(cerr\_comet2monitor),\ cerr\_comet2monitor);}
\DoxyCodeLine{00026\ \}}
\DoxyCodeLine{00027\ }
\DoxyCodeLine{00036\ \textcolor{keywordtype}{int}\ main(\textcolor{keywordtype}{int}\ argc,\ \textcolor{keywordtype}{char}\ *argv[])}
\DoxyCodeLine{00037\ \{}
\DoxyCodeLine{00038\ \ \ \ \ \textcolor{keywordtype}{int}\ memsize\ =\ DEFAULT\_MEMSIZE;}
\DoxyCodeLine{00039\ \ \ \ \ \textcolor{keywordtype}{int}\ clocks\ =\ DEFAULT\_CLOCKS;}
\DoxyCodeLine{00040\ \ \ \ \ \textcolor{keywordtype}{int}\ opt\ =\ 0;}
\DoxyCodeLine{00041\ \ \ \ \ \textcolor{keywordtype}{int}\ stat\ =\ 0;}
\DoxyCodeLine{00042\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *version\ =\ PACKAGE\_VERSION;}
\DoxyCodeLine{00043\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *cmdversion\ =\ \textcolor{stringliteral}{"{}comet2monitor:\ COMET\ II\ machine\ code\ monitor\ of\ YACASL2\ version\ \%s\(\backslash\)n"{}};}
\DoxyCodeLine{00044\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *usage\ =\ \textcolor{stringliteral}{"{}Usage:\ \%s\ [-\/vh]\ [-\/M\ <MEMORYSIZE>]\ [-\/C\ <CLOCKS>]\(\backslash\)n"{}};}
\DoxyCodeLine{00045\ }
\DoxyCodeLine{00046\ \ \ \ \ \textcolor{comment}{/*\ エラーの定義\ */}}
\DoxyCodeLine{00047\ \ \ \ \ cerr\_init();}
\DoxyCodeLine{00048\ \ \ \ \ addcerrlist\_load();}
\DoxyCodeLine{00049\ \ \ \ \ addcerrlist\_exec();}
\DoxyCodeLine{00050\ \ \ \ \ addcerrlist\_comet2monitor();}
\DoxyCodeLine{00051\ }
\DoxyCodeLine{00052\ \ \ \ \ \textcolor{comment}{/*\ オプションの処理\ */}}
\DoxyCodeLine{00053\ \ \ \ \ \textcolor{keywordflow}{while}((opt\ =\ getopt\_long(argc,\ argv,\ \textcolor{stringliteral}{"{}M:C:vh"{}},\ longopts,\ NULL))\ !=\ -\/1)\ \{}
\DoxyCodeLine{00054\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{switch}(opt)\ \{}
\DoxyCodeLine{00055\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ \textcolor{charliteral}{'M'}:}
\DoxyCodeLine{00056\ \ \ \ \ \ \ \ \ \ \ \ \ memsize\ =\ atoi(optarg);}
\DoxyCodeLine{00057\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00058\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ \textcolor{charliteral}{'C'}:}
\DoxyCodeLine{00059\ \ \ \ \ \ \ \ \ \ \ \ \ clocks\ =\ atoi(optarg);}
\DoxyCodeLine{00060\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00061\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ \textcolor{charliteral}{'v'}:}
\DoxyCodeLine{00062\ \ \ \ \ \ \ \ \ \ \ \ \ fprintf(stdout,\ cmdversion,\ version);}
\DoxyCodeLine{00063\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{00064\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ \textcolor{charliteral}{'h'}:}
\DoxyCodeLine{00065\ \ \ \ \ \ \ \ \ \ \ \ \ fprintf(stdout,\ usage,\ argv[0]);}
\DoxyCodeLine{00066\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ comet2monitorfin;}
\DoxyCodeLine{00067\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ \textcolor{charliteral}{'?'}:}
\DoxyCodeLine{00068\ \ \ \ \ \ \ \ \ \ \ \ \ fprintf(stderr,\ usage,\ argv[0]);}
\DoxyCodeLine{00069\ \ \ \ \ \ \ \ \ \ \ \ \ setcerr(212,\ \textcolor{stringliteral}{"{}"{}});\ \ \ \ \textcolor{comment}{/*\ invalid\ option\ */}}
\DoxyCodeLine{00070\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ comet2monitorfin;}
\DoxyCodeLine{00071\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00072\ \ \ \ \ \}}
\DoxyCodeLine{00073\ \ \ \ \ create\_cmdtable(HASH\_CMDTYPE);}
\DoxyCodeLine{00074\ \ \ \ \ reset(memsize,\ clocks);\ \ \ \ \ \textcolor{comment}{/*\ COMET\ II仮想マシンのリセット\ */}}
\DoxyCodeLine{00075\ \ \ \ \ execptr-\/>start\ =\ 0;}
\DoxyCodeLine{00076\ \ \ \ \ execmode.monitor\ =\ \textcolor{keyword}{true};}
\DoxyCodeLine{00077\ \ \ \ \ exec();\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ プログラム実行\ */}}
\DoxyCodeLine{00078\ \ \ \ \ shutdown();}
\DoxyCodeLine{00079\ comet2monitorfin:}
\DoxyCodeLine{00080\ \ \ \ \ free\_cmdtable(HASH\_CMDTYPE);}
\DoxyCodeLine{00081\ \ \ \ \ free\_cmdtable(HASH\_CODE);}
\DoxyCodeLine{00082\ \ \ \ \ \textcolor{keywordflow}{if}(cerr-\/>num\ >\ 0)\ \{}
\DoxyCodeLine{00083\ \ \ \ \ \ \ \ \ stat\ =\ 1;}
\DoxyCodeLine{00084\ \ \ \ \ \}}
\DoxyCodeLine{00085\ \ \ \ \ freecerr();\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ エラーの解放\ */}}
\DoxyCodeLine{00086\ \ \ \ \ \textcolor{keywordflow}{return}\ stat;}
\DoxyCodeLine{00087\ \}}

\end{DoxyCode}

/* [<][>][^][v][top][bottom][index][help] */