\doxysection{cmd\+\_\+ln.\+c}
\label{cmd__ln_8c_source}\index{src/libsphinxbase/util/cmd\_ln.c@{src/libsphinxbase/util/cmd\_ln.c}}

\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{comment}{/*\ -\/*-\/\ c-\/basic-\/offset:\ 4;\ indent-\/tabs-\/mode:\ nil\ -\/*-\/\ */}}
\DoxyCodeLine{00002\ \textcolor{comment}{/*\ ====================================================================}}
\DoxyCodeLine{00003\ \textcolor{comment}{\ *\ Copyright\ (c)\ 1999-\/2004\ Carnegie\ Mellon\ University.\ \ All\ rights}}
\DoxyCodeLine{00004\ \textcolor{comment}{\ *\ reserved.}}
\DoxyCodeLine{00005\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00006\ \textcolor{comment}{\ *\ Redistribution\ and\ use\ in\ source\ and\ binary\ forms,\ with\ or\ without}}
\DoxyCodeLine{00007\ \textcolor{comment}{\ *\ modification,\ are\ permitted\ provided\ that\ the\ following\ conditions}}
\DoxyCodeLine{00008\ \textcolor{comment}{\ *\ are\ met:}}
\DoxyCodeLine{00009\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00010\ \textcolor{comment}{\ *\ 1.\ Redistributions\ of\ source\ code\ must\ retain\ the\ above\ copyright}}
\DoxyCodeLine{00011\ \textcolor{comment}{\ *\ \ \ \ notice,\ this\ list\ of\ conditions\ and\ the\ following\ disclaimer.\ }}
\DoxyCodeLine{00012\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00013\ \textcolor{comment}{\ *\ 2.\ Redistributions\ in\ binary\ form\ must\ reproduce\ the\ above\ copyright}}
\DoxyCodeLine{00014\ \textcolor{comment}{\ *\ \ \ \ notice,\ this\ list\ of\ conditions\ and\ the\ following\ disclaimer\ in}}
\DoxyCodeLine{00015\ \textcolor{comment}{\ *\ \ \ \ the\ documentation\ and/or\ other\ materials\ provided\ with\ the}}
\DoxyCodeLine{00016\ \textcolor{comment}{\ *\ \ \ \ distribution.}}
\DoxyCodeLine{00017\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00018\ \textcolor{comment}{\ *\ This\ work\ was\ supported\ in\ part\ by\ funding\ from\ the\ Defense\ Advanced\ }}
\DoxyCodeLine{00019\ \textcolor{comment}{\ *\ Research\ Projects\ Agency\ and\ the\ National\ Science\ Foundation\ of\ the\ }}
\DoxyCodeLine{00020\ \textcolor{comment}{\ *\ United\ States\ of\ America,\ and\ the\ CMU\ Sphinx\ Speech\ Consortium.}}
\DoxyCodeLine{00021\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00022\ \textcolor{comment}{\ *\ THIS\ SOFTWARE\ IS\ PROVIDED\ BY\ CARNEGIE\ MELLON\ UNIVERSITY\ \`{}\`{}AS\ IS''\ AND\ }}
\DoxyCodeLine{00023\ \textcolor{comment}{\ *\ ANY\ EXPRESSED\ OR\ IMPLIED\ WARRANTIES,\ INCLUDING,\ BUT\ NOT\ LIMITED\ TO,\ }}
\DoxyCodeLine{00024\ \textcolor{comment}{\ *\ THE\ IMPLIED\ WARRANTIES\ OF\ MERCHANTABILITY\ AND\ FITNESS\ FOR\ A\ PARTICULAR}}
\DoxyCodeLine{00025\ \textcolor{comment}{\ *\ PURPOSE\ ARE\ DISCLAIMED.\ \ IN\ NO\ EVENT\ SHALL\ CARNEGIE\ MELLON\ UNIVERSITY}}
\DoxyCodeLine{00026\ \textcolor{comment}{\ *\ NOR\ ITS\ EMPLOYEES\ BE\ LIABLE\ FOR\ ANY\ DIRECT,\ INDIRECT,\ INCIDENTAL,}}
\DoxyCodeLine{00027\ \textcolor{comment}{\ *\ SPECIAL,\ EXEMPLARY,\ OR\ CONSEQUENTIAL\ DAMAGES\ (INCLUDING,\ BUT\ NOT\ }}
\DoxyCodeLine{00028\ \textcolor{comment}{\ *\ LIMITED\ TO,\ PROCUREMENT\ OF\ SUBSTITUTE\ GOODS\ OR\ SERVICES;\ LOSS\ OF\ USE,\ }}
\DoxyCodeLine{00029\ \textcolor{comment}{\ *\ DATA,\ OR\ PROFITS;\ OR\ BUSINESS\ INTERRUPTION)\ HOWEVER\ CAUSED\ AND\ ON\ ANY\ }}
\DoxyCodeLine{00030\ \textcolor{comment}{\ *\ THEORY\ OF\ LIABILITY,\ WHETHER\ IN\ CONTRACT,\ STRICT\ LIABILITY,\ OR\ TORT\ }}
\DoxyCodeLine{00031\ \textcolor{comment}{\ *\ (INCLUDING\ NEGLIGENCE\ OR\ OTHERWISE)\ ARISING\ IN\ ANY\ WAY\ OUT\ OF\ THE\ USE\ }}
\DoxyCodeLine{00032\ \textcolor{comment}{\ *\ OF\ THIS\ SOFTWARE,\ EVEN\ IF\ ADVISED\ OF\ THE\ POSSIBILITY\ OF\ SUCH\ DAMAGE.}}
\DoxyCodeLine{00033\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00034\ \textcolor{comment}{\ *\ ====================================================================}}
\DoxyCodeLine{00035\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00036\ \textcolor{comment}{\ */}}
\DoxyCodeLine{00037\ \textcolor{comment}{/*}}
\DoxyCodeLine{00038\ \textcolor{comment}{\ *\ cmd\_ln.c\ -\/-\/\ Command\ line\ argument\ parsing.}}
\DoxyCodeLine{00039\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00040\ \textcolor{comment}{\ *\ **********************************************}}
\DoxyCodeLine{00041\ \textcolor{comment}{\ *\ CMU\ ARPA\ Speech\ Project}}
\DoxyCodeLine{00042\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00043\ \textcolor{comment}{\ *\ Copyright\ (c)\ 1999\ Carnegie\ Mellon\ University.}}
\DoxyCodeLine{00044\ \textcolor{comment}{\ *\ ALL\ RIGHTS\ RESERVED.}}
\DoxyCodeLine{00045\ \textcolor{comment}{\ *\ **********************************************}}
\DoxyCodeLine{00046\ \textcolor{comment}{\ *\ }}
\DoxyCodeLine{00047\ \textcolor{comment}{\ *\ HISTORY}}
\DoxyCodeLine{00048\ \textcolor{comment}{\ *\ }}
\DoxyCodeLine{00049\ \textcolor{comment}{\ *\ 10-\/Sep-\/1998\ \ M\ K\ Ravishankar\ (rkm@cs.cmu.edu)\ at\ Carnegie\ Mellon\ University}}
\DoxyCodeLine{00050\ \textcolor{comment}{\ *\ \ \ \ \ \ \ \ \ \ \ \ \ \ Changed\ strcasecmp()\ call\ in\ cmp\_name()\ to\ strcmp\_nocase()\ call.}}
\DoxyCodeLine{00051\ \textcolor{comment}{\ *\ }}
\DoxyCodeLine{00052\ \textcolor{comment}{\ *\ 15-\/Jul-\/1997\ \ M\ K\ Ravishankar\ (rkm@cs.cmu.edu)\ at\ Carnegie\ Mellon\ University}}
\DoxyCodeLine{00053\ \textcolor{comment}{\ *\ \ \ \ \ \ \ \ \ \ \ \ \ \ Added\ required\ arguments\ handling.}}
\DoxyCodeLine{00054\ \textcolor{comment}{\ *\ }}
\DoxyCodeLine{00055\ \textcolor{comment}{\ *\ 07-\/Dec-\/96\ \ \ \ M\ K\ Ravishankar\ (rkm@cs.cmu.edu)\ at\ Carnegie\ Mellon\ University}}
\DoxyCodeLine{00056\ \textcolor{comment}{\ *\ \ \ \ \ \ \ \ \ \ \ \ \ \ Created,\ based\ on\ Eric's\ implementation.\ \ Basically,\ combined\ several}}
\DoxyCodeLine{00057\ \textcolor{comment}{\ *\ \ \ \ \ \ \ \ \ \ \ \ \ \ functions\ into\ one,\ eliminated\ validation,\ and\ simplified\ the\ interface.}}
\DoxyCodeLine{00058\ \textcolor{comment}{\ */}}
\DoxyCodeLine{00059\ }
\DoxyCodeLine{00060\ }
\DoxyCodeLine{00061\ \textcolor{preprocessor}{\#include\ <stdio.h>}}
\DoxyCodeLine{00062\ \textcolor{preprocessor}{\#include\ <stdlib.h>}}
\DoxyCodeLine{00063\ \textcolor{preprocessor}{\#include\ <string.h>}}
\DoxyCodeLine{00064\ \textcolor{preprocessor}{\#include\ <assert.h>}}
\DoxyCodeLine{00065\ }
\DoxyCodeLine{00066\ \textcolor{preprocessor}{\#ifdef\ \_MSC\_VER}}
\DoxyCodeLine{00067\ \textcolor{preprocessor}{\#pragma\ warning\ (disable:\ 4996\ 4018)}}
\DoxyCodeLine{00068\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00069\ }
\DoxyCodeLine{00070\ \textcolor{preprocessor}{\#ifdef\ HAVE\_CONFIG\_H}}
\DoxyCodeLine{00071\ \textcolor{preprocessor}{\#include\ <config.h>}}
\DoxyCodeLine{00072\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00073\ }
\DoxyCodeLine{00074\ \textcolor{preprocessor}{\#ifdef\ HAVE\_UNISTD\_H}}
\DoxyCodeLine{00075\ \textcolor{preprocessor}{\#include\ <unistd.h>}}
\DoxyCodeLine{00076\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00077\ }
\DoxyCodeLine{00078\ \textcolor{preprocessor}{\#include\ "{}sphinxbase/cmd\_ln.h"{}}}
\DoxyCodeLine{00079\ \textcolor{preprocessor}{\#include\ "{}sphinxbase/err.h"{}}}
\DoxyCodeLine{00080\ \textcolor{preprocessor}{\#include\ "{}sphinxbase/ckd\_alloc.h"{}}}
\DoxyCodeLine{00081\ \textcolor{preprocessor}{\#include\ "{}sphinxbase/hash\_table.h"{}}}
\DoxyCodeLine{00082\ \textcolor{preprocessor}{\#include\ "{}sphinxbase/case.h"{}}}
\DoxyCodeLine{00083\ \textcolor{preprocessor}{\#include\ "{}sphinxbase/strfuncs.h"{}}}
\DoxyCodeLine{00084\ }
\DoxyCodeLine{00085\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{struct\ }cmd\_ln\_val\_s\ \{}
\DoxyCodeLine{00086\ \ \ \ \ anytype\_t\ val;}
\DoxyCodeLine{00087\ \ \ \ \ \textcolor{keywordtype}{int}\ type;}
\DoxyCodeLine{00088\ \}\ cmd\_ln\_val\_t;}
\DoxyCodeLine{00089\ }
\DoxyCodeLine{00090\ \textcolor{keyword}{struct\ }cmd\_ln\_s\ \{}
\DoxyCodeLine{00091\ \ \ \ \ \textcolor{keywordtype}{int}\ refcount;}
\DoxyCodeLine{00092\ \ \ \ \ hash\_table\_t\ *ht;}
\DoxyCodeLine{00093\ \ \ \ \ \textcolor{keywordtype}{char}\ **f\_argv;}
\DoxyCodeLine{00094\ \ \ \ \ uint32\ f\_argc;}
\DoxyCodeLine{00095\ \};}
\DoxyCodeLine{00096\ }
\DoxyCodeLine{00098\ cmd\_ln\_t\ *global\_cmdln;}
\DoxyCodeLine{00099\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{void}\ arg\_dump\_r(cmd\_ln\_t\ *cmdln,\ FILE\ *\ fp,\ arg\_t\ \textcolor{keyword}{const}\ *defn,\ int32\ doc);}
\DoxyCodeLine{00100\ \textcolor{keyword}{static}\ cmd\_ln\_t\ *\ parse\_options(cmd\_ln\_t\ *cmdln,\ \textcolor{keyword}{const}\ arg\_t\ *defn,\ int32\ argc,\ \textcolor{keywordtype}{char}*\ argv[],\ int32\ strict);}
\DoxyCodeLine{00101\ }
\DoxyCodeLine{00102\ \textcolor{comment}{/*}}
\DoxyCodeLine{00103\ \textcolor{comment}{\ *\ Find\ max\ length\ of\ name\ and\ default\ fields\ in\ the\ given\ defn\ array.}}
\DoxyCodeLine{00104\ \textcolor{comment}{\ *\ Return\ \#items\ in\ defn\ array.}}
\DoxyCodeLine{00105\ \textcolor{comment}{\ */}}
\DoxyCodeLine{00106\ \textcolor{keyword}{static}\ int32}
\DoxyCodeLine{00107\ arg\_strlen(\textcolor{keyword}{const}\ arg\_t\ *\ defn,\ int32\ *\ namelen,\ int32\ *\ deflen)}
\DoxyCodeLine{00108\ \{}
\DoxyCodeLine{00109\ \ \ \ \ int32\ i,\ l;}
\DoxyCodeLine{00110\ }
\DoxyCodeLine{00111\ \ \ \ \ *namelen\ =\ *deflen\ =\ 0;}
\DoxyCodeLine{00112\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ defn[i].name;\ i++)\ \{}
\DoxyCodeLine{00113\ \ \ \ \ \ \ \ \ l\ =\ strlen(defn[i].name);}
\DoxyCodeLine{00114\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (*namelen\ <\ l)}
\DoxyCodeLine{00115\ \ \ \ \ \ \ \ \ \ \ \ \ *namelen\ =\ l;}
\DoxyCodeLine{00116\ }
\DoxyCodeLine{00117\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (defn[i].deflt)}
\DoxyCodeLine{00118\ \ \ \ \ \ \ \ \ \ \ \ \ l\ =\ strlen(defn[i].deflt);}
\DoxyCodeLine{00119\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{00120\ \ \ \ \ \ \ \ \ \ \ \ \ l\ =\ strlen(\textcolor{stringliteral}{"{}(null)"{}});}
\DoxyCodeLine{00121\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ \ \ \ \ \ E\_INFO("{}string\ default,\ \%s\ ,\ name\ \%s,\ length\ \%d\(\backslash\)n"{},defn[i].deflt,defn[i].name,l);\ */}}
\DoxyCodeLine{00122\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (*deflen\ <\ l)}
\DoxyCodeLine{00123\ \ \ \ \ \ \ \ \ \ \ \ \ *deflen\ =\ l;}
\DoxyCodeLine{00124\ \ \ \ \ \}}
\DoxyCodeLine{00125\ }
\DoxyCodeLine{00126\ \ \ \ \ \textcolor{keywordflow}{return}\ i;}
\DoxyCodeLine{00127\ \}}
\DoxyCodeLine{00128\ }
\DoxyCodeLine{00129\ }
\DoxyCodeLine{00130\ \textcolor{keyword}{static}\ int32}
\DoxyCodeLine{00131\ cmp\_name(\textcolor{keyword}{const}\ \textcolor{keywordtype}{void}\ *a,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{void}\ *b)}
\DoxyCodeLine{00132\ \{}
\DoxyCodeLine{00133\ \ \ \ \ \textcolor{keywordflow}{return}\ (strcmp\_nocase}
\DoxyCodeLine{00134\ \ \ \ \ \ \ \ \ \ \ \ \ ((*\ (arg\_t**)\ a)-\/>name,}
\DoxyCodeLine{00135\ \ \ \ \ \ \ \ \ \ \ \ \ \ (*\ (arg\_t**)\ b)-\/>name));}
\DoxyCodeLine{00136\ \}}
\DoxyCodeLine{00137\ }
\DoxyCodeLine{00138\ \textcolor{keyword}{static}\ \textcolor{keyword}{const}\ arg\_t\ **}
\DoxyCodeLine{00139\ arg\_sort(\textcolor{keyword}{const}\ arg\_t\ *\ defn,\ int32\ n)}
\DoxyCodeLine{00140\ \{}
\DoxyCodeLine{00141\ \ \ \ \ \textcolor{keyword}{const}\ arg\_t\ **\ pos;}
\DoxyCodeLine{00142\ \ \ \ \ int32\ i;}
\DoxyCodeLine{00143\ }
\DoxyCodeLine{00144\ \ \ \ \ pos\ =\ (\textcolor{keyword}{const}\ arg\_t\ **)\ ckd\_calloc(n,\ \textcolor{keyword}{sizeof}(arg\_t\ *));}
\DoxyCodeLine{00145\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ n;\ ++i)}
\DoxyCodeLine{00146\ \ \ \ \ \ \ \ \ pos[i]\ =\ \&defn[i];}
\DoxyCodeLine{00147\ \ \ \ \ qsort(pos,\ n,\ \textcolor{keyword}{sizeof}(arg\_t\ *),\ cmp\_name);}
\DoxyCodeLine{00148\ }
\DoxyCodeLine{00149\ \ \ \ \ \textcolor{keywordflow}{return}\ pos;}
\DoxyCodeLine{00150\ \}}
\DoxyCodeLine{00151\ }
\DoxyCodeLine{00152\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{size\_t}}
\DoxyCodeLine{00153\ strnappend(\textcolor{keywordtype}{char}\ **dest,\ \textcolor{keywordtype}{size\_t}\ *dest\_allocation,\ }
\DoxyCodeLine{00154\ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *source,\ \textcolor{keywordtype}{size\_t}\ n)}
\DoxyCodeLine{00155\ \{}
\DoxyCodeLine{00156\ \ \ \ \ \textcolor{keywordtype}{size\_t}\ source\_len,\ required\_allocation;}
\DoxyCodeLine{00157\ }
\DoxyCodeLine{00158\ \ \ \ \ \textcolor{keywordflow}{if}\ (dest\ ==\ NULL\ ||\ dest\_allocation\ ==\ NULL)}
\DoxyCodeLine{00159\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{00160\ \ \ \ \ \textcolor{keywordflow}{if}\ (*dest\ ==\ NULL\ \&\&\ *dest\_allocation\ !=\ 0)}
\DoxyCodeLine{00161\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{00162\ \ \ \ \ \textcolor{keywordflow}{if}\ (source\ ==\ NULL)}
\DoxyCodeLine{00163\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ *dest\_allocation;}
\DoxyCodeLine{00164\ }
\DoxyCodeLine{00165\ \ \ \ \ source\_len\ =\ strlen(source);}
\DoxyCodeLine{00166\ \ \ \ \ \textcolor{keywordflow}{if}\ (n\ \&\&\ n\ <\ source\_len)}
\DoxyCodeLine{00167\ \ \ \ \ \ \ \ \ source\_len\ =\ n;}
\DoxyCodeLine{00168\ }
\DoxyCodeLine{00169\ \ \ \ \ required\_allocation\ =\ (*dest\ ?\ strlen(*dest)\ :\ 0)\ +\ source\_len\ +\ 1;}
\DoxyCodeLine{00170\ \ \ \ \ \textcolor{keywordflow}{if}\ (*dest\_allocation\ <\ required\_allocation)\ \{}
\DoxyCodeLine{00171\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (*dest\_allocation\ ==\ 0)\ \{}
\DoxyCodeLine{00172\ \ \ \ \ \ \ \ \ \ \ \ \ *dest\ =\ ckd\_calloc(required\_allocation\ *\ 2,\ 1);}
\DoxyCodeLine{00173\ \ \ \ \ \ \ \ \ \}\ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00174\ \ \ \ \ \ \ \ \ \ \ \ \ *dest\ =\ ckd\_realloc(*dest,\ required\_allocation\ *\ 2);}
\DoxyCodeLine{00175\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00176\ \ \ \ \ \ \ \ \ *dest\_allocation\ =\ required\_allocation\ *\ 2;}
\DoxyCodeLine{00177\ \ \ \ \ \}\ }
\DoxyCodeLine{00178\ }
\DoxyCodeLine{00179\ \ \ \ \ strncat(*dest,\ source,\ source\_len);}
\DoxyCodeLine{00180\ }
\DoxyCodeLine{00181\ \ \ \ \ \textcolor{keywordflow}{return}\ *dest\_allocation;}
\DoxyCodeLine{00182\ \}}
\DoxyCodeLine{00183\ }
\DoxyCodeLine{00184\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{size\_t}}
\DoxyCodeLine{00185\ strappend(\textcolor{keywordtype}{char}\ **dest,\ \textcolor{keywordtype}{size\_t}\ *dest\_allocation,\ }
\DoxyCodeLine{00186\ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *source)}
\DoxyCodeLine{00187\ \{}
\DoxyCodeLine{00188\ \ \ \ \ \textcolor{keywordflow}{return}\ strnappend(dest,\ dest\_allocation,\ source,\ 0);}
\DoxyCodeLine{00189\ \}}
\DoxyCodeLine{00190\ }
\DoxyCodeLine{00191\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{char}*}
\DoxyCodeLine{00192\ arg\_resolve\_env(\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *str)}
\DoxyCodeLine{00193\ \{}
\DoxyCodeLine{00194\ \ \ \ \ \textcolor{keywordtype}{char}\ *resolved\_str\ =\ NULL;}
\DoxyCodeLine{00195\ \ \ \ \ \textcolor{keywordtype}{char}\ env\_name[100];}
\DoxyCodeLine{00196\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *env\_val;}
\DoxyCodeLine{00197\ \ \ \ \ \textcolor{keywordtype}{size\_t}\ alloced\ =\ 0;}
\DoxyCodeLine{00198\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *i\ =\ str,\ *j;}
\DoxyCodeLine{00199\ }
\DoxyCodeLine{00200\ \ \ \ \ \textcolor{comment}{/*\ calculate\ required\ resolved\_str\ size\ */}}
\DoxyCodeLine{00201\ \ \ \ \ \textcolor{keywordflow}{do}\ \{}
\DoxyCodeLine{00202\ \ \ \ \ \ \ \ \ j\ =\ strstr(i,\ \textcolor{stringliteral}{"{}\$("{}});}
\DoxyCodeLine{00203\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (j\ !=\ NULL)\ \{}
\DoxyCodeLine{00204\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (j\ !=\ i)\ \{}
\DoxyCodeLine{00205\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ strnappend(\&resolved\_str,\ \&alloced,\ i,\ j\ -\/\ i);}
\DoxyCodeLine{00206\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ i\ =\ j;}
\DoxyCodeLine{00207\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00208\ \ \ \ \ \ \ \ \ \ \ \ \ j\ =\ strchr(i\ +\ 2,\ \textcolor{charliteral}{')'});}
\DoxyCodeLine{00209\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (j\ !=\ NULL)\ \{}
\DoxyCodeLine{00210\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (j\ -\/\ (i\ +\ 2)\ <\ 100)\ \{}
\DoxyCodeLine{00211\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ strncpy(env\_name,\ i\ +\ 2,\ j\ -\/\ (i\ +\ 2));}
\DoxyCodeLine{00212\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ env\_name[j\ -\/\ (i\ +\ 2)]\ =\ \textcolor{charliteral}{'\(\backslash\)0'};}
\DoxyCodeLine{00213\ \textcolor{preprocessor}{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \#if\ !defined(\_WIN32\_WCE)}}
\DoxyCodeLine{00214\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ env\_val\ =\ getenv(env\_name);}
\DoxyCodeLine{00215\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (env\_val)}
\DoxyCodeLine{00216\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ strappend(\&resolved\_str,\ \&alloced,\ env\_val);}
\DoxyCodeLine{00217\ \textcolor{preprocessor}{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \#else}}
\DoxyCodeLine{00218\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ env\_val\ =\ 0;}
\DoxyCodeLine{00219\ \textcolor{preprocessor}{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \#endif}}
\DoxyCodeLine{00220\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00221\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ i\ =\ j\ +\ 1;}
\DoxyCodeLine{00222\ \ \ \ \ \ \ \ \ \ \ \ \ \}\ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00223\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ unclosed,\ copy\ and\ skip\ */}}
\DoxyCodeLine{00224\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ j\ =\ i\ +\ 2;}
\DoxyCodeLine{00225\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ strnappend(\&resolved\_str,\ \&alloced,\ i,\ j\ -\/\ i);}
\DoxyCodeLine{00226\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ i\ =\ j;}
\DoxyCodeLine{00227\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00228\ \ \ \ \ \ \ \ \ \}\ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00229\ \ \ \ \ \ \ \ \ \ \ \ \ strappend(\&resolved\_str,\ \&alloced,\ i);}
\DoxyCodeLine{00230\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00231\ \ \ \ \ \}\ \textcolor{keywordflow}{while}(j\ !=\ NULL);}
\DoxyCodeLine{00232\ }
\DoxyCodeLine{00233\ \ \ \ \ \textcolor{keywordflow}{return}\ resolved\_str;}
\DoxyCodeLine{00234\ \}}
\DoxyCodeLine{00235\ }
\DoxyCodeLine{00236\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00237\ arg\_dump\_r(cmd\_ln\_t\ *cmdln,\ FILE\ *\ fp,\ \textcolor{keyword}{const}\ arg\_t\ *\ defn,\ int32\ doc)}
\DoxyCodeLine{00238\ \{}
\DoxyCodeLine{00239\ \ \ \ \ \textcolor{keyword}{const}\ arg\_t\ **pos;}
\DoxyCodeLine{00240\ \ \ \ \ int32\ i,\ l,\ n;}
\DoxyCodeLine{00241\ \ \ \ \ int32\ namelen,\ deflen;}
\DoxyCodeLine{00242\ \ \ \ \ anytype\_t\ *vp;}
\DoxyCodeLine{00243\ \ \ \ \ \textcolor{keywordtype}{char}\ \textcolor{keyword}{const}\ **array;}
\DoxyCodeLine{00244\ }
\DoxyCodeLine{00245\ \ \ \ \ \textcolor{comment}{/*\ No\ definitions,\ do\ nothing.\ */}}
\DoxyCodeLine{00246\ \ \ \ \ \textcolor{keywordflow}{if}\ (defn\ ==\ NULL)}
\DoxyCodeLine{00247\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return};}
\DoxyCodeLine{00248\ \ \ \ \ \textcolor{keywordflow}{if}\ (fp\ ==\ NULL)}
\DoxyCodeLine{00249\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return};}
\DoxyCodeLine{00250\ }
\DoxyCodeLine{00251\ \ \ \ \ \textcolor{comment}{/*\ Find\ max\ lengths\ of\ name\ and\ default\ value\ fields,\ and\ \#entries\ in\ defn\ */}}
\DoxyCodeLine{00252\ \ \ \ \ n\ =\ arg\_strlen(defn,\ \&namelen,\ \&deflen);}
\DoxyCodeLine{00253\ \ \ \ \ \textcolor{comment}{/*\ \ \ \ E\_INFO("{}String\ length\ \%d.\ Name\ length\ \%d,\ Default\ Length\ \%d\(\backslash\)n"{},n,\ namelen,\ deflen);\ */}}
\DoxyCodeLine{00254\ \ \ \ \ namelen\ =\ namelen\ \&\ 0xfffffff8;\ \ \ \ \ \textcolor{comment}{/*\ Previous\ tab\ position\ */}}
\DoxyCodeLine{00255\ \ \ \ \ deflen\ =\ deflen\ \&\ 0xfffffff8;\ \ \ \ \ \ \ \textcolor{comment}{/*\ Previous\ tab\ position\ */}}
\DoxyCodeLine{00256\ }
\DoxyCodeLine{00257\ \ \ \ \ fprintf(fp,\ \textcolor{stringliteral}{"{}[NAME]"{}});}
\DoxyCodeLine{00258\ \ \ \ \ \textcolor{keywordflow}{for}\ (l\ =\ strlen(\textcolor{stringliteral}{"{}[NAME]"{}});\ l\ <\ namelen;\ l\ +=\ 8)}
\DoxyCodeLine{00259\ \ \ \ \ \ \ \ \ fprintf(fp,\ \textcolor{stringliteral}{"{}\(\backslash\)t"{}});}
\DoxyCodeLine{00260\ \ \ \ \ fprintf(fp,\ \textcolor{stringliteral}{"{}\(\backslash\)t[DEFLT]"{}});}
\DoxyCodeLine{00261\ \ \ \ \ \textcolor{keywordflow}{for}\ (l\ =\ strlen(\textcolor{stringliteral}{"{}[DEFLT]"{}});\ l\ <\ deflen;\ l\ +=\ 8)}
\DoxyCodeLine{00262\ \ \ \ \ \ \ \ \ fprintf(fp,\ \textcolor{stringliteral}{"{}\(\backslash\)t"{}});}
\DoxyCodeLine{00263\ }
\DoxyCodeLine{00264\ \ \ \ \ \textcolor{keywordflow}{if}\ (doc)\ \{}
\DoxyCodeLine{00265\ \ \ \ \ \ \ \ \ fprintf(fp,\ \textcolor{stringliteral}{"{}\(\backslash\)t[DESCR]\(\backslash\)n"{}});}
\DoxyCodeLine{00266\ \ \ \ \ \}}
\DoxyCodeLine{00267\ \ \ \ \ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00268\ \ \ \ \ \ \ \ \ fprintf(fp,\ \textcolor{stringliteral}{"{}\(\backslash\)t[VALUE]\(\backslash\)n"{}});}
\DoxyCodeLine{00269\ \ \ \ \ \}}
\DoxyCodeLine{00270\ }
\DoxyCodeLine{00271\ \ \ \ \ \textcolor{comment}{/*\ Print\ current\ configuration,\ sorted\ by\ name\ */}}
\DoxyCodeLine{00272\ \ \ \ \ pos\ =\ arg\_sort(defn,\ n);}
\DoxyCodeLine{00273\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ n;\ i++)\ \{}
\DoxyCodeLine{00274\ \ \ \ \ \ \ \ \ fprintf(fp,\ \textcolor{stringliteral}{"{}\%s"{}},\ pos[i]-\/>name);}
\DoxyCodeLine{00275\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (l\ =\ strlen(pos[i]-\/>name);\ l\ <\ namelen;\ l\ +=\ 8)}
\DoxyCodeLine{00276\ \ \ \ \ \ \ \ \ \ \ \ \ fprintf(fp,\ \textcolor{stringliteral}{"{}\(\backslash\)t"{}});}
\DoxyCodeLine{00277\ }
\DoxyCodeLine{00278\ \ \ \ \ \ \ \ \ fprintf(fp,\ \textcolor{stringliteral}{"{}\(\backslash\)t"{}});}
\DoxyCodeLine{00279\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (pos[i]-\/>deflt)\ \{}
\DoxyCodeLine{00280\ \ \ \ \ \ \ \ \ \ \ \ \ fprintf(fp,\ \textcolor{stringliteral}{"{}\%s"{}},\ pos[i]-\/>deflt);}
\DoxyCodeLine{00281\ \ \ \ \ \ \ \ \ \ \ \ \ l\ =\ strlen(pos[i]-\/>deflt);}
\DoxyCodeLine{00282\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00283\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{00284\ \ \ \ \ \ \ \ \ \ \ \ \ l\ =\ 0;}
\DoxyCodeLine{00285\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (;\ l\ <\ deflen;\ l\ +=\ 8)}
\DoxyCodeLine{00286\ \ \ \ \ \ \ \ \ \ \ \ \ fprintf(fp,\ \textcolor{stringliteral}{"{}\(\backslash\)t"{}});}
\DoxyCodeLine{00287\ }
\DoxyCodeLine{00288\ \ \ \ \ \ \ \ \ fprintf(fp,\ \textcolor{stringliteral}{"{}\(\backslash\)t"{}});}
\DoxyCodeLine{00289\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (doc)\ \{}
\DoxyCodeLine{00290\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (pos[i]-\/>doc)}
\DoxyCodeLine{00291\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fprintf(fp,\ \textcolor{stringliteral}{"{}\%s"{}},\ pos[i]-\/>doc);}
\DoxyCodeLine{00292\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00293\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00294\ \ \ \ \ \ \ \ \ \ \ \ \ vp\ =\ cmd\_ln\_access\_r(cmdln,\ pos[i]-\/>name);}
\DoxyCodeLine{00295\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (vp)\ \{}
\DoxyCodeLine{00296\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{switch}\ (pos[i]-\/>type)\ \{}
\DoxyCodeLine{00297\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ ARG\_INTEGER:}
\DoxyCodeLine{00298\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ REQARG\_INTEGER:}
\DoxyCodeLine{00299\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fprintf(fp,\ \textcolor{stringliteral}{"{}\%ld"{}},\ vp-\/>i);}
\DoxyCodeLine{00300\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00301\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ ARG\_FLOATING:}
\DoxyCodeLine{00302\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ REQARG\_FLOATING:}
\DoxyCodeLine{00303\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fprintf(fp,\ \textcolor{stringliteral}{"{}\%e"{}},\ vp-\/>fl);}
\DoxyCodeLine{00304\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00305\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ ARG\_STRING:}
\DoxyCodeLine{00306\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ REQARG\_STRING:}
\DoxyCodeLine{00307\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (vp-\/>ptr)}
\DoxyCodeLine{00308\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fprintf(fp,\ \textcolor{stringliteral}{"{}\%s"{}},\ (\textcolor{keywordtype}{char}\ *)vp-\/>ptr);}
\DoxyCodeLine{00309\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00310\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ ARG\_STRING\_LIST:}
\DoxyCodeLine{00311\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ array\ =\ (\textcolor{keywordtype}{char}\ \textcolor{keyword}{const}**)vp-\/>ptr;}
\DoxyCodeLine{00312\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (array)}
\DoxyCodeLine{00313\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (l\ =\ 0;\ array[l]\ !=\ 0;\ l++)\ \{}
\DoxyCodeLine{00314\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fprintf(fp,\ \textcolor{stringliteral}{"{}\%s,"{}},\ array[l]);}
\DoxyCodeLine{00315\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00316\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00317\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ ARG\_BOOLEAN:}
\DoxyCodeLine{00318\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ REQARG\_BOOLEAN:}
\DoxyCodeLine{00319\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fprintf(fp,\ \textcolor{stringliteral}{"{}\%s"{}},\ vp-\/>i\ ?\ \textcolor{stringliteral}{"{}yes"{}}\ :\ \textcolor{stringliteral}{"{}no"{}});}
\DoxyCodeLine{00320\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00321\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{default}:}
\DoxyCodeLine{00322\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Unknown\ argument\ type:\ \%d\(\backslash\)n"{}},\ pos[i]-\/>type);}
\DoxyCodeLine{00323\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00324\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00325\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00326\ }
\DoxyCodeLine{00327\ \ \ \ \ \ \ \ \ fprintf(fp,\ \textcolor{stringliteral}{"{}\(\backslash\)n"{}});}
\DoxyCodeLine{00328\ \ \ \ \ \}}
\DoxyCodeLine{00329\ \ \ \ \ ckd\_free(pos);}
\DoxyCodeLine{00330\ }
\DoxyCodeLine{00331\ \ \ \ \ fprintf(fp,\ \textcolor{stringliteral}{"{}\(\backslash\)n"{}});}
\DoxyCodeLine{00332\ \ \ \ \ fflush(fp);}
\DoxyCodeLine{00333\ \}}
\DoxyCodeLine{00334\ }
\DoxyCodeLine{00335\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{char}\ **}
\DoxyCodeLine{00336\ parse\_string\_list(\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *str)}
\DoxyCodeLine{00337\ \{}
\DoxyCodeLine{00338\ \ \ \ \ \textcolor{keywordtype}{int}\ count,\ i,\ j;}
\DoxyCodeLine{00339\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *p;}
\DoxyCodeLine{00340\ \ \ \ \ \textcolor{keywordtype}{char}\ **\ result;}
\DoxyCodeLine{00341\ }
\DoxyCodeLine{00342\ \ \ \ \ p\ =\ str;}
\DoxyCodeLine{00343\ \ \ \ \ count\ =\ 1;}
\DoxyCodeLine{00344\ \ \ \ \ \textcolor{keywordflow}{while}\ (*p)\ \{}
\DoxyCodeLine{00345\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (*p\ ==\ \textcolor{charliteral}{','})}
\DoxyCodeLine{00346\ \ \ \ \ \ \ \ \ \ \ \ \ count++;}
\DoxyCodeLine{00347\ \ \ \ \ \ \ \ \ p++;}
\DoxyCodeLine{00348\ \ \ \ \ \}}
\DoxyCodeLine{00349\ \ \ \ \ \textcolor{comment}{/*\ Should\ end\ with\ NULL\ */}}
\DoxyCodeLine{00350\ \ \ \ \ result\ =\ (\textcolor{keywordtype}{char}\ **)\ ckd\_calloc(count\ +\ 1,\ \textcolor{keyword}{sizeof}(\textcolor{keywordtype}{char}\ *));}
\DoxyCodeLine{00351\ \ \ \ \ p\ =\ str;}
\DoxyCodeLine{00352\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ count;\ i++)\ \{}
\DoxyCodeLine{00353\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (j\ =\ 0;\ p[j]\ !=\ \textcolor{charliteral}{','}\ \&\&\ p[j]\ !=\ 0;\ j++);}
\DoxyCodeLine{00354\ \ \ \ \ \ \ \ \ result[i]\ =\ ckd\_calloc(j\ +\ 1,\ \textcolor{keyword}{sizeof}(\textcolor{keywordtype}{char}));}
\DoxyCodeLine{00355\ \ \ \ \ \ \ \ \ strncpy(\ result[i],\ p,\ j);}
\DoxyCodeLine{00356\ \ \ \ \ \ \ \ \ p\ =\ p\ +\ j\ +\ 1;}
\DoxyCodeLine{00357\ \ \ \ \ \}}
\DoxyCodeLine{00358\ \ \ \ \ \textcolor{keywordflow}{return}\ result;}
\DoxyCodeLine{00359\ \}}
\DoxyCodeLine{00360\ }
\DoxyCodeLine{00361\ \textcolor{keyword}{static}\ cmd\_ln\_val\_t\ *}
\DoxyCodeLine{00362\ cmd\_ln\_val\_init(\textcolor{keywordtype}{int}\ t,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *str)}
\DoxyCodeLine{00363\ \{}
\DoxyCodeLine{00364\ \ \ \ \ cmd\_ln\_val\_t\ *v;}
\DoxyCodeLine{00365\ \ \ \ \ anytype\_t\ val;}
\DoxyCodeLine{00366\ \ \ \ \ \textcolor{keywordtype}{char}\ *e\_str;}
\DoxyCodeLine{00367\ }
\DoxyCodeLine{00368\ \ \ \ \ \textcolor{keywordflow}{if}\ (!str)\ \{}
\DoxyCodeLine{00369\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ For\ lack\ of\ a\ better\ default\ value.\ */}}
\DoxyCodeLine{00370\ \ \ \ \ \ \ \ \ memset(\&val,\ 0,\ \textcolor{keyword}{sizeof}(val));}
\DoxyCodeLine{00371\ \ \ \ \ \}}
\DoxyCodeLine{00372\ \ \ \ \ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00373\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ valid\ =\ 1;}
\DoxyCodeLine{00374\ \ \ \ \ \ \ \ \ e\_str\ =\ arg\_resolve\_env(str);}
\DoxyCodeLine{00375\ }
\DoxyCodeLine{00376\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{switch}\ (t)\ \{}
\DoxyCodeLine{00377\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ ARG\_INTEGER:}
\DoxyCodeLine{00378\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ REQARG\_INTEGER:}
\DoxyCodeLine{00379\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (sscanf(e\_str,\ \textcolor{stringliteral}{"{}\%ld"{}},\ \&val.i)\ !=\ 1)}
\DoxyCodeLine{00380\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ valid\ =\ 0;}
\DoxyCodeLine{00381\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00382\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ ARG\_FLOATING:}
\DoxyCodeLine{00383\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ REQARG\_FLOATING:}
\DoxyCodeLine{00384\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (e\_str\ ==\ NULL\ ||\ e\_str[0]\ ==\ 0)}
\DoxyCodeLine{00385\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ valid\ =\ 0;}
\DoxyCodeLine{00386\ \ \ \ \ \ \ \ \ \ \ \ \ val.fl\ =\ atof\_c(e\_str);}
\DoxyCodeLine{00387\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00388\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ ARG\_BOOLEAN:}
\DoxyCodeLine{00389\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ REQARG\_BOOLEAN:}
\DoxyCodeLine{00390\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ ((e\_str[0]\ ==\ \textcolor{charliteral}{'y'})\ ||\ (e\_str[0]\ ==\ \textcolor{charliteral}{'t'})\ ||}
\DoxyCodeLine{00391\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (e\_str[0]\ ==\ \textcolor{charliteral}{'Y'})\ ||\ (e\_str[0]\ ==\ \textcolor{charliteral}{'T'})\ ||\ (e\_str[0]\ ==\ \textcolor{charliteral}{'1'}))\ \{}
\DoxyCodeLine{00392\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ val.i\ =\ TRUE;}
\DoxyCodeLine{00393\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00394\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ ((e\_str[0]\ ==\ \textcolor{charliteral}{'n'})\ ||\ (e\_str[0]\ ==\ \textcolor{charliteral}{'f'})\ ||}
\DoxyCodeLine{00395\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (e\_str[0]\ ==\ \textcolor{charliteral}{'N'})\ ||\ (e\_str[0]\ ==\ \textcolor{charliteral}{'F'})\ |}
\DoxyCodeLine{00396\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (e\_str[0]\ ==\ \textcolor{charliteral}{'0'}))\ \{}
\DoxyCodeLine{00397\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ val.i\ =\ FALSE;}
\DoxyCodeLine{00398\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00399\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00400\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Unparsed\ boolean\ value\ '\%s'\(\backslash\)n"{}},\ str);}
\DoxyCodeLine{00401\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ valid\ =\ 0;}
\DoxyCodeLine{00402\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00403\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00404\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ ARG\_STRING:}
\DoxyCodeLine{00405\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ REQARG\_STRING:}
\DoxyCodeLine{00406\ \ \ \ \ \ \ \ \ \ \ \ \ val.ptr\ =\ ckd\_salloc(e\_str);}
\DoxyCodeLine{00407\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00408\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ ARG\_STRING\_LIST:}
\DoxyCodeLine{00409\ \ \ \ \ \ \ \ \ \ \ \ \ val.ptr\ =\ parse\_string\_list(e\_str);}
\DoxyCodeLine{00410\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00411\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{default}:}
\DoxyCodeLine{00412\ \ \ \ \ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Unknown\ argument\ type:\ \%d\(\backslash\)n"{}},\ t);}
\DoxyCodeLine{00413\ \ \ \ \ \ \ \ \ \ \ \ \ valid\ =\ 0;}
\DoxyCodeLine{00414\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00415\ }
\DoxyCodeLine{00416\ \ \ \ \ \ \ \ \ ckd\_free(e\_str);}
\DoxyCodeLine{00417\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (valid\ ==\ 0)}
\DoxyCodeLine{00418\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ NULL;}
\DoxyCodeLine{00419\ \ \ \ \ \}}
\DoxyCodeLine{00420\ }
\DoxyCodeLine{00421\ \ \ \ \ v\ =\ ckd\_calloc(1,\ \textcolor{keyword}{sizeof}(*v));}
\DoxyCodeLine{00422\ \ \ \ \ memcpy(v,\ \&val,\ \textcolor{keyword}{sizeof}(val));}
\DoxyCodeLine{00423\ \ \ \ \ v-\/>type\ =\ t;}
\DoxyCodeLine{00424\ }
\DoxyCodeLine{00425\ \ \ \ \ \textcolor{keywordflow}{return}\ v;}
\DoxyCodeLine{00426\ \}}
\DoxyCodeLine{00427\ }
\DoxyCodeLine{00428\ \textcolor{comment}{/*}}
\DoxyCodeLine{00429\ \textcolor{comment}{\ *\ Handles\ option\ parsing\ for\ cmd\_ln\_parse\_file\_r()\ and\ cmd\_ln\_init()}}
\DoxyCodeLine{00430\ \textcolor{comment}{\ *\ also\ takes\ care\ of\ storing\ argv.}}
\DoxyCodeLine{00431\ \textcolor{comment}{\ *\ DO\ NOT\ call\ it\ from\ cmd\_ln\_parse\_r()}}
\DoxyCodeLine{00432\ \textcolor{comment}{\ */}}
\DoxyCodeLine{00433\ \textcolor{keyword}{static}\ cmd\_ln\_t\ *}
\DoxyCodeLine{00434\ parse\_options(cmd\_ln\_t\ *cmdln,\ \textcolor{keyword}{const}\ arg\_t\ *defn,\ int32\ argc,\ \textcolor{keywordtype}{char}*\ argv[],\ int32\ strict)}
\DoxyCodeLine{00435\ \{}
\DoxyCodeLine{00436\ \ \ \ \ cmd\_ln\_t\ *new\_cmdln;}
\DoxyCodeLine{00437\ }
\DoxyCodeLine{00438\ \ \ \ \ new\_cmdln\ =\ cmd\_ln\_parse\_r(cmdln,\ defn,\ argc,\ argv,\ strict);}
\DoxyCodeLine{00439\ \ \ \ \ \textcolor{comment}{/*\ If\ this\ failed\ then\ clean\ up\ and\ return\ NULL.\ */}}
\DoxyCodeLine{00440\ \ \ \ \ \textcolor{keywordflow}{if}\ (new\_cmdln\ ==\ NULL)\ \{}
\DoxyCodeLine{00441\ \ \ \ \ \ \ \ \ int32\ i;}
\DoxyCodeLine{00442\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ argc;\ ++i)}
\DoxyCodeLine{00443\ \ \ \ \ \ \ \ \ \ \ \ \ ckd\_free(argv[i]);}
\DoxyCodeLine{00444\ \ \ \ \ \ \ \ \ ckd\_free(argv);}
\DoxyCodeLine{00445\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ NULL;}
\DoxyCodeLine{00446\ \ \ \ \ \}}
\DoxyCodeLine{00447\ }
\DoxyCodeLine{00448\ \ \ \ \ \textcolor{comment}{/*\ Otherwise,\ we\ need\ to\ add\ the\ contents\ of\ f\_argv\ to\ the\ new\ object.\ */}}
\DoxyCodeLine{00449\ \ \ \ \ \textcolor{keywordflow}{if}\ (new\_cmdln\ ==\ cmdln)\ \{}
\DoxyCodeLine{00450\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ If\ we\ are\ adding\ to\ a\ previously\ passed-\/in\ cmdln,\ then}}
\DoxyCodeLine{00451\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ *\ store\ our\ allocated\ strings\ in\ its\ f\_argv.\ */}}
\DoxyCodeLine{00452\ \ \ \ \ \ \ \ \ new\_cmdln-\/>f\_argv\ =\ ckd\_realloc(new\_cmdln-\/>f\_argv,}
\DoxyCodeLine{00453\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (new\_cmdln-\/>f\_argc\ +\ argc)}
\DoxyCodeLine{00454\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *\ \textcolor{keyword}{sizeof}(*new\_cmdln-\/>f\_argv));}
\DoxyCodeLine{00455\ \ \ \ \ \ \ \ \ memcpy(new\_cmdln-\/>f\_argv\ +\ new\_cmdln-\/>f\_argc,\ argv,}
\DoxyCodeLine{00456\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ argc\ *\ \textcolor{keyword}{sizeof}(*argv));}
\DoxyCodeLine{00457\ \ \ \ \ \ \ \ \ ckd\_free(argv);}
\DoxyCodeLine{00458\ \ \ \ \ \ \ \ \ new\_cmdln-\/>f\_argc\ +=\ argc;}
\DoxyCodeLine{00459\ \ \ \ \ \}}
\DoxyCodeLine{00460\ \ \ \ \ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00461\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Otherwise,\ store\ f\_argc\ and\ f\_argv.\ */}}
\DoxyCodeLine{00462\ \ \ \ \ \ \ \ \ new\_cmdln-\/>f\_argc\ =\ argc;}
\DoxyCodeLine{00463\ \ \ \ \ \ \ \ \ new\_cmdln-\/>f\_argv\ =\ argv;}
\DoxyCodeLine{00464\ \ \ \ \ \}}
\DoxyCodeLine{00465\ }
\DoxyCodeLine{00466\ \ \ \ \ \textcolor{keywordflow}{return}\ new\_cmdln;}
\DoxyCodeLine{00467\ \}}
\DoxyCodeLine{00468\ }
\DoxyCodeLine{00469\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00470\ cmd\_ln\_val\_free(cmd\_ln\_val\_t\ *val)}
\DoxyCodeLine{00471\ \{}
\DoxyCodeLine{00472\ \ \ \ \ \textcolor{keywordtype}{int}\ i;}
\DoxyCodeLine{00473\ \ \ \ \ \textcolor{keywordflow}{if}\ (val-\/>type\ \&\ ARG\_STRING\_LIST)\ \{}
\DoxyCodeLine{00474\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{char}\ **\ array\ =\ (\textcolor{keywordtype}{char}\ **)val-\/>val.ptr;}
\DoxyCodeLine{00475\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (array)\ \{}
\DoxyCodeLine{00476\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ array[i]\ !=\ NULL;\ i++)\ \{}
\DoxyCodeLine{00477\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ckd\_free(array[i]);}
\DoxyCodeLine{00478\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00479\ \ \ \ \ \ \ \ \ \ \ \ \ ckd\_free(array);}
\DoxyCodeLine{00480\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00481\ \ \ \ \ \}}
\DoxyCodeLine{00482\ \ \ \ \ \textcolor{keywordflow}{if}\ (val-\/>type\ \&\ ARG\_STRING)}
\DoxyCodeLine{00483\ \ \ \ \ \ \ \ \ ckd\_free(val-\/>val.ptr);}
\DoxyCodeLine{00484\ \ \ \ \ ckd\_free(val);}
\DoxyCodeLine{00485\ \}}
\DoxyCodeLine{00486\ }
\DoxyCodeLine{00487\ cmd\_ln\_t\ *}
\DoxyCodeLine{00488\ cmd\_ln\_get(\textcolor{keywordtype}{void})}
\DoxyCodeLine{00489\ \{}
\DoxyCodeLine{00490\ \ \ \ \ \textcolor{keywordflow}{return}\ global\_cmdln;}
\DoxyCodeLine{00491\ \}}
\DoxyCodeLine{00492\ }
\DoxyCodeLine{00493\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00494\ cmd\_ln\_appl\_enter(\textcolor{keywordtype}{int}\ argc,\ \textcolor{keywordtype}{char}\ *argv[],}
\DoxyCodeLine{00495\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *default\_argfn,}
\DoxyCodeLine{00496\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ arg\_t\ *\ defn)}
\DoxyCodeLine{00497\ \{}
\DoxyCodeLine{00498\ \ \ \ \ \textcolor{comment}{/*\ Look\ for\ default\ or\ specified\ arguments\ file\ */}}
\DoxyCodeLine{00499\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *str;}
\DoxyCodeLine{00500\ }
\DoxyCodeLine{00501\ \ \ \ \ str\ =\ NULL;}
\DoxyCodeLine{00502\ }
\DoxyCodeLine{00503\ \ \ \ \ \textcolor{keywordflow}{if}\ ((argc\ ==\ 2)\ \&\&\ (strcmp(argv[1],\ \textcolor{stringliteral}{"{}help"{}})\ ==\ 0))\ \{}
\DoxyCodeLine{00504\ \ \ \ \ \ \ \ \ cmd\_ln\_print\_help(stderr,\ defn);}
\DoxyCodeLine{00505\ \ \ \ \ \ \ \ \ exit(1);}
\DoxyCodeLine{00506\ \ \ \ \ \}}
\DoxyCodeLine{00507\ }
\DoxyCodeLine{00508\ \ \ \ \ \textcolor{keywordflow}{if}\ ((argc\ ==\ 2)\ \&\&\ (argv[1][0]\ !=\ \textcolor{charliteral}{'-\/'}))}
\DoxyCodeLine{00509\ \ \ \ \ \ \ \ \ str\ =\ argv[1];}
\DoxyCodeLine{00510\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (argc\ ==\ 1)\ \{}
\DoxyCodeLine{00511\ \ \ \ \ \ \ \ \ FILE\ *fp;}
\DoxyCodeLine{00512\ \ \ \ \ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}Looking\ for\ default\ argument\ file:\ \%s\(\backslash\)n"{}},\ default\_argfn);}
\DoxyCodeLine{00513\ }
\DoxyCodeLine{00514\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ ((fp\ =\ fopen(default\_argfn,\ \textcolor{stringliteral}{"{}r"{}}))\ ==\ NULL)\ \{}
\DoxyCodeLine{00515\ \ \ \ \ \ \ \ \ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}Can't\ find\ default\ argument\ file\ \%s.\(\backslash\)n"{}},}
\DoxyCodeLine{00516\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ default\_argfn);}
\DoxyCodeLine{00517\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00518\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00519\ \ \ \ \ \ \ \ \ \ \ \ \ str\ =\ default\_argfn;}
\DoxyCodeLine{00520\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00521\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (fp\ !=\ NULL)}
\DoxyCodeLine{00522\ \ \ \ \ \ \ \ \ \ \ \ \ fclose(fp);}
\DoxyCodeLine{00523\ \ \ \ \ \}}
\DoxyCodeLine{00524\ }
\DoxyCodeLine{00525\ }
\DoxyCodeLine{00526\ \ \ \ \ \textcolor{keywordflow}{if}\ (str)\ \{}
\DoxyCodeLine{00527\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Build\ command\ line\ argument\ list\ from\ file\ */}}
\DoxyCodeLine{00528\ \ \ \ \ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}Parsing\ command\ lines\ from\ file\ \%s\(\backslash\)n"{}},\ str);}
\DoxyCodeLine{00529\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (cmd\_ln\_parse\_file(defn,\ str,\ TRUE))\ \{}
\DoxyCodeLine{00530\ \ \ \ \ \ \ \ \ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{}Usage:\(\backslash\)n"{}});}
\DoxyCodeLine{00531\ \ \ \ \ \ \ \ \ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{}\(\backslash\)t\%s\ argument-\/list,\ or\(\backslash\)n"{}},\ argv[0]);}
\DoxyCodeLine{00532\ \ \ \ \ \ \ \ \ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{}\(\backslash\)t\%s\ [argument-\/file]\ (default\ file:\ .\ \%s)\(\backslash\)n\(\backslash\)n"{}},}
\DoxyCodeLine{00533\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ argv[0],\ default\_argfn);}
\DoxyCodeLine{00534\ \ \ \ \ \ \ \ \ \ \ \ \ cmd\_ln\_print\_help(stderr,\ defn);}
\DoxyCodeLine{00535\ \ \ \ \ \ \ \ \ \ \ \ \ exit(1);}
\DoxyCodeLine{00536\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00537\ \ \ \ \ \}}
\DoxyCodeLine{00538\ \ \ \ \ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00539\ \ \ \ \ \ \ \ \ cmd\_ln\_parse(defn,\ argc,\ argv,\ TRUE);}
\DoxyCodeLine{00540\ \ \ \ \ \}}
\DoxyCodeLine{00541\ \}}
\DoxyCodeLine{00542\ }
\DoxyCodeLine{00543\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00544\ cmd\_ln\_appl\_exit()}
\DoxyCodeLine{00545\ \{}
\DoxyCodeLine{00546\ \ \ \ \ cmd\_ln\_free();}
\DoxyCodeLine{00547\ \}}
\DoxyCodeLine{00548\ }
\DoxyCodeLine{00549\ }
\DoxyCodeLine{00550\ cmd\_ln\_t\ *}
\DoxyCodeLine{00551\ cmd\_ln\_parse\_r(cmd\_ln\_t\ *inout\_cmdln,\ \textcolor{keyword}{const}\ arg\_t\ *\ defn,\ int32\ argc,\ \textcolor{keywordtype}{char}\ *argv[],\ \textcolor{keywordtype}{int}\ strict)}
\DoxyCodeLine{00552\ \{}
\DoxyCodeLine{00553\ \ \ \ \ int32\ i,\ j,\ n,\ argstart;}
\DoxyCodeLine{00554\ \ \ \ \ hash\_table\_t\ *defidx\ =\ NULL;}
\DoxyCodeLine{00555\ \ \ \ \ cmd\_ln\_t\ *cmdln;}
\DoxyCodeLine{00556\ \ \ \ \ }
\DoxyCodeLine{00557\ \ \ \ \ \textcolor{comment}{/*\ Construct\ command-\/line\ object\ */}}
\DoxyCodeLine{00558\ \ \ \ \ \textcolor{keywordflow}{if}\ (inout\_cmdln\ ==\ NULL)\ \{}
\DoxyCodeLine{00559\ \ \ \ \ \ \ \ \ cmdln\ =\ ckd\_calloc(1,\ \textcolor{keyword}{sizeof}(*cmdln));}
\DoxyCodeLine{00560\ \ \ \ \ \ \ \ \ cmdln-\/>refcount\ =\ 1;}
\DoxyCodeLine{00561\ \ \ \ \ \}}
\DoxyCodeLine{00562\ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{00563\ \ \ \ \ \ \ \ \ cmdln\ =\ inout\_cmdln;}
\DoxyCodeLine{00564\ }
\DoxyCodeLine{00565\ \ \ \ \ \textcolor{comment}{/*\ Build\ a\ hash\ table\ for\ argument\ definitions\ */}}
\DoxyCodeLine{00566\ \ \ \ \ defidx\ =\ hash\_table\_new(50,\ 0);}
\DoxyCodeLine{00567\ \ \ \ \ \textcolor{keywordflow}{if}\ (defn)\ \{}
\DoxyCodeLine{00568\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (n\ =\ 0;\ defn[n].name;\ n++)\ \{}
\DoxyCodeLine{00569\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{void}\ *v;}
\DoxyCodeLine{00570\ }
\DoxyCodeLine{00571\ \ \ \ \ \ \ \ \ \ \ \ \ v\ =\ hash\_table\_enter(defidx,\ defn[n].name,\ (\textcolor{keywordtype}{void}\ *)\&defn[n]);}
\DoxyCodeLine{00572\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (strict\ \&\&\ (v\ !=\ \&defn[n]))\ \{}
\DoxyCodeLine{00573\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Duplicate\ argument\ name\ in\ definition:\ \%s\(\backslash\)n"{}},\ defn[n].name);}
\DoxyCodeLine{00574\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ error;}
\DoxyCodeLine{00575\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00576\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00577\ \ \ \ \ \}}
\DoxyCodeLine{00578\ \ \ \ \ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00579\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ No\ definitions.\ */}}
\DoxyCodeLine{00580\ \ \ \ \ \ \ \ \ n\ =\ 0;}
\DoxyCodeLine{00581\ \ \ \ \ \}}
\DoxyCodeLine{00582\ }
\DoxyCodeLine{00583\ \ \ \ \ \textcolor{comment}{/*\ Allocate\ memory\ for\ argument\ values\ */}}
\DoxyCodeLine{00584\ \ \ \ \ \textcolor{keywordflow}{if}\ (cmdln-\/>ht\ ==\ NULL)}
\DoxyCodeLine{00585\ \ \ \ \ \ \ \ \ cmdln-\/>ht\ =\ hash\_table\_new(n,\ 0\ \textcolor{comment}{/*\ argument\ names\ are\ case-\/sensitive\ */}\ );}
\DoxyCodeLine{00586\ }
\DoxyCodeLine{00587\ }
\DoxyCodeLine{00588\ \ \ \ \ \textcolor{comment}{/*\ skip\ argv[0]\ if\ it\ doesn't\ start\ with\ dash\ */}}
\DoxyCodeLine{00589\ \ \ \ \ argstart\ =\ 0;}
\DoxyCodeLine{00590\ \ \ \ \ \textcolor{keywordflow}{if}\ (argc\ >\ 0\ \&\&\ argv[0][0]\ !=\ \textcolor{charliteral}{'-\/'})\ \{}
\DoxyCodeLine{00591\ \ \ \ \ \ \ \ \ argstart\ =\ 1;}
\DoxyCodeLine{00592\ \ \ \ \ \}\ }
\DoxyCodeLine{00593\ }
\DoxyCodeLine{00594\ \ \ \ \ \textcolor{comment}{/*\ Parse\ command\ line\ arguments\ (name-\/value\ pairs)\ */}}
\DoxyCodeLine{00595\ \ \ \ \ \textcolor{keywordflow}{for}\ (j\ =\ argstart;\ j\ <\ argc;\ j\ +=\ 2)\ \{}
\DoxyCodeLine{00596\ \ \ \ \ \ \ \ \ arg\_t\ *argdef;}
\DoxyCodeLine{00597\ \ \ \ \ \ \ \ \ cmd\_ln\_val\_t\ *val;}
\DoxyCodeLine{00598\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{void}\ *v;}
\DoxyCodeLine{00599\ }
\DoxyCodeLine{00600\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (hash\_table\_lookup(defidx,\ argv[j],\ \&v)\ <\ 0)\ \{}
\DoxyCodeLine{00601\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (strict)\ \{}
\DoxyCodeLine{00602\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Unknown\ argument\ name\ '\%s'\(\backslash\)n"{}},\ argv[j]);}
\DoxyCodeLine{00603\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ error;}
\DoxyCodeLine{00604\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00605\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (defn\ ==\ NULL)}
\DoxyCodeLine{00606\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ v\ =\ NULL;}
\DoxyCodeLine{00607\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{00608\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{continue};}
\DoxyCodeLine{00609\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00610\ \ \ \ \ \ \ \ \ argdef\ =\ v;}
\DoxyCodeLine{00611\ }
\DoxyCodeLine{00612\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Enter\ argument\ value\ */}\ \ \ \ \ \ }
\DoxyCodeLine{00613\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (j\ +\ 1\ >=\ argc)\ \{}
\DoxyCodeLine{00614\ \ \ \ \ \ \ \ \ \ \ \ \ cmd\_ln\_print\_help\_r(cmdln,\ stderr,\ defn);}
\DoxyCodeLine{00615\ \ \ \ \ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Argument\ value\ for\ '\%s'\ missing\(\backslash\)n"{}},\ argv[j]);}
\DoxyCodeLine{00616\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ error;}
\DoxyCodeLine{00617\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00618\ }
\DoxyCodeLine{00619\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (argdef\ ==\ NULL)}
\DoxyCodeLine{00620\ \ \ \ \ \ \ \ \ \ \ \ \ val\ =\ cmd\_ln\_val\_init(ARG\_STRING,\ argv[j\ +\ 1]);}
\DoxyCodeLine{00621\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00622\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ ((val\ =\ cmd\_ln\_val\_init(argdef-\/>type,\ argv[j\ +\ 1]))\ ==\ NULL)\ \{}
\DoxyCodeLine{00623\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ cmd\_ln\_print\_help\_r(cmdln,\ stderr,\ defn);}
\DoxyCodeLine{00624\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Bad\ argument\ value\ for\ \%s:\ \%s\(\backslash\)n"{}},\ argv[j],}
\DoxyCodeLine{00625\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ argv[j\ +\ 1]);}
\DoxyCodeLine{00626\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ error;}
\DoxyCodeLine{00627\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00628\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00629\ }
\DoxyCodeLine{00630\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ ((v\ =\ hash\_table\_enter(cmdln-\/>ht,\ argv[j],\ (\textcolor{keywordtype}{void}\ *)val))\ !=\ (\textcolor{keywordtype}{void}\ *)val)\ \{}
\DoxyCodeLine{00631\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (strict)\ \{}
\DoxyCodeLine{00632\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ cmd\_ln\_val\_free(val);}
\DoxyCodeLine{00633\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Duplicate\ argument\ name\ in\ arguments:\ \%s\(\backslash\)n"{}},}
\DoxyCodeLine{00634\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ argdef-\/>name);}
\DoxyCodeLine{00635\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ error;}
\DoxyCodeLine{00636\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00637\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00638\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ v\ =\ hash\_table\_replace(cmdln-\/>ht,\ argv[j],\ (\textcolor{keywordtype}{void}\ *)val);}
\DoxyCodeLine{00639\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ cmd\_ln\_val\_free((cmd\_ln\_val\_t\ *)v);}
\DoxyCodeLine{00640\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00641\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00642\ \ \ \ \ \}}
\DoxyCodeLine{00643\ }
\DoxyCodeLine{00644\ \ \ \ \ \textcolor{comment}{/*\ Fill\ in\ default\ values,\ if\ any,\ for\ unspecified\ arguments\ */}}
\DoxyCodeLine{00645\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ n;\ i++)\ \{}
\DoxyCodeLine{00646\ \ \ \ \ \ \ \ \ cmd\_ln\_val\_t\ *val;}
\DoxyCodeLine{00647\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{void}\ *v;}
\DoxyCodeLine{00648\ }
\DoxyCodeLine{00649\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (hash\_table\_lookup(cmdln-\/>ht,\ defn[i].name,\ \&v)\ <\ 0)\ \{}
\DoxyCodeLine{00650\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ ((val\ =\ cmd\_ln\_val\_init(defn[i].type,\ defn[i].deflt))\ ==\ NULL)\ \{}
\DoxyCodeLine{00651\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ E\_ERROR}
\DoxyCodeLine{00652\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\textcolor{stringliteral}{"{}Bad\ default\ argument\ value\ for\ \%s:\ \%s\(\backslash\)n"{}},}
\DoxyCodeLine{00653\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ defn[i].name,\ defn[i].deflt);}
\DoxyCodeLine{00654\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ error;}
\DoxyCodeLine{00655\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00656\ \ \ \ \ \ \ \ \ \ \ \ \ hash\_table\_enter(cmdln-\/>ht,\ defn[i].name,\ (\textcolor{keywordtype}{void}\ *)val);}
\DoxyCodeLine{00657\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00658\ \ \ \ \ \}}
\DoxyCodeLine{00659\ }
\DoxyCodeLine{00660\ \ \ \ \ \textcolor{comment}{/*\ Check\ for\ required\ arguments;\ exit\ if\ any\ missing\ */}}
\DoxyCodeLine{00661\ \ \ \ \ j\ =\ 0;}
\DoxyCodeLine{00662\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ n;\ i++)\ \{}
\DoxyCodeLine{00663\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (defn[i].type\ \&\ ARG\_REQUIRED)\ \{}
\DoxyCodeLine{00664\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{void}\ *v;}
\DoxyCodeLine{00665\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (hash\_table\_lookup(cmdln-\/>ht,\ defn[i].name,\ \&v)\ !=\ 0)}
\DoxyCodeLine{00666\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Missing\ required\ argument\ \%s\(\backslash\)n"{}},\ defn[i].name);}
\DoxyCodeLine{00667\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00668\ \ \ \ \ \}}
\DoxyCodeLine{00669\ \ \ \ \ \textcolor{keywordflow}{if}\ (j\ >\ 0)\ \{}
\DoxyCodeLine{00670\ \ \ \ \ \ \ \ \ cmd\_ln\_print\_help\_r(cmdln,\ stderr,\ defn);}
\DoxyCodeLine{00671\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ error;}
\DoxyCodeLine{00672\ \ \ \ \ \}}
\DoxyCodeLine{00673\ }
\DoxyCodeLine{00674\ \ \ \ \ \textcolor{keywordflow}{if}\ (strict\ \&\&\ argc\ ==\ 1)\ \{}
\DoxyCodeLine{00675\ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}No\ arguments\ given,\ available\ options\ are:\(\backslash\)n"{}});}
\DoxyCodeLine{00676\ \ \ \ \ \ \ \ \ cmd\_ln\_print\_help\_r(cmdln,\ stderr,\ defn);}
\DoxyCodeLine{00677\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (defidx)}
\DoxyCodeLine{00678\ \ \ \ \ \ \ \ \ \ \ \ \ hash\_table\_free(defidx);}
\DoxyCodeLine{00679\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (inout\_cmdln\ ==\ NULL)}
\DoxyCodeLine{00680\ \ \ \ \ \ \ \ \ \ \ \ \ cmd\_ln\_free\_r(cmdln);}
\DoxyCodeLine{00681\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ NULL;}
\DoxyCodeLine{00682\ \ \ \ \ \}}
\DoxyCodeLine{00683\ }
\DoxyCodeLine{00684\ \textcolor{preprocessor}{\#ifndef\ \_WIN32\_WCE}}
\DoxyCodeLine{00685\ \ \ \ \ \textcolor{comment}{/*\ Set\ up\ logging.\ We\ need\ to\ do\ this\ earlier\ because\ we\ want\ to\ dump}}
\DoxyCodeLine{00686\ \textcolor{comment}{\ \ \ \ \ *\ the\ information\ to\ the\ configured\ log,\ not\ to\ the\ stderr.\ */}}
\DoxyCodeLine{00687\ \ \ \ \ \textcolor{keywordflow}{if}\ (cmd\_ln\_exists\_r(cmdln,\ \textcolor{stringliteral}{"{}-\/logfn"{}})\ \&\&\ cmd\_ln\_str\_r(cmdln,\ \textcolor{stringliteral}{"{}-\/logfn"{}}))}
\DoxyCodeLine{00688\ \ \ \ \ \ \ \ \ err\_set\_logfile(cmd\_ln\_str\_r(cmdln,\ \textcolor{stringliteral}{"{}-\/logfn"{}}));}
\DoxyCodeLine{00689\ }
\DoxyCodeLine{00690\ \ \ \ \ \textcolor{comment}{/*\ Echo\ command\ line\ */}}
\DoxyCodeLine{00691\ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}Parsing\ command\ line:\(\backslash\)n"{}});}
\DoxyCodeLine{00692\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ argc;\ i++)\ \{}
\DoxyCodeLine{00693\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (argv[i][0]\ ==\ \textcolor{charliteral}{'-\/'})}
\DoxyCodeLine{00694\ \ \ \ \ \ \ \ \ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{}\(\backslash\)\(\backslash\)\(\backslash\)n\(\backslash\)t"{}});}
\DoxyCodeLine{00695\ \ \ \ \ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{}\%s\ "{}},\ argv[i]);}
\DoxyCodeLine{00696\ \ \ \ \ \}}
\DoxyCodeLine{00697\ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{}\(\backslash\)n\(\backslash\)n"{}});}
\DoxyCodeLine{00698\ \ \ \ \ fflush(stderr);}
\DoxyCodeLine{00699\ }
\DoxyCodeLine{00700\ \ \ \ \ \textcolor{comment}{/*\ Print\ configuration\ */}}
\DoxyCodeLine{00701\ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{}Current\ configuration:\(\backslash\)n"{}});}
\DoxyCodeLine{00702\ \ \ \ \ arg\_dump\_r(cmdln,\ err\_get\_logfp(),\ defn,\ 0);}
\DoxyCodeLine{00703\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00704\ }
\DoxyCodeLine{00705\ \ \ \ \ hash\_table\_free(defidx);}
\DoxyCodeLine{00706\ \ \ \ \ \textcolor{keywordflow}{return}\ cmdln;}
\DoxyCodeLine{00707\ }
\DoxyCodeLine{00708\ \ \ error:}
\DoxyCodeLine{00709\ \ \ \ \ \textcolor{keywordflow}{if}\ (defidx)}
\DoxyCodeLine{00710\ \ \ \ \ \ \ \ \ hash\_table\_free(defidx);}
\DoxyCodeLine{00711\ \ \ \ \ \textcolor{keywordflow}{if}\ (inout\_cmdln\ ==\ NULL)}
\DoxyCodeLine{00712\ \ \ \ \ \ \ \ \ cmd\_ln\_free\_r(cmdln);}
\DoxyCodeLine{00713\ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Failed\ to\ parse\ arguments\ list\(\backslash\)n"{}});}
\DoxyCodeLine{00714\ \ \ \ \ \textcolor{keywordflow}{return}\ NULL;}
\DoxyCodeLine{00715\ \}}
\DoxyCodeLine{00716\ }
\DoxyCodeLine{00717\ cmd\_ln\_t\ *}
\DoxyCodeLine{00718\ cmd\_ln\_init(cmd\_ln\_t\ *inout\_cmdln,\ \textcolor{keyword}{const}\ arg\_t\ *defn,\ int32\ strict,\ ...)}
\DoxyCodeLine{00719\ \{}
\DoxyCodeLine{00720\ \ \ \ \ va\_list\ args;}
\DoxyCodeLine{00721\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *arg,\ *val;}
\DoxyCodeLine{00722\ \ \ \ \ \textcolor{keywordtype}{char}\ **f\_argv;}
\DoxyCodeLine{00723\ \ \ \ \ int32\ f\_argc;}
\DoxyCodeLine{00724\ }
\DoxyCodeLine{00725\ \ \ \ \ va\_start(args,\ strict);}
\DoxyCodeLine{00726\ \ \ \ \ f\_argc\ =\ 0;}
\DoxyCodeLine{00727\ \ \ \ \ \textcolor{keywordflow}{while}\ ((arg\ =\ va\_arg(args,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *)))\ \{}
\DoxyCodeLine{00728\ \ \ \ \ \ \ \ \ ++f\_argc;}
\DoxyCodeLine{00729\ \ \ \ \ \ \ \ \ val\ =\ va\_arg(args,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}*);}
\DoxyCodeLine{00730\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (val\ ==\ NULL)\ \{}
\DoxyCodeLine{00731\ \ \ \ \ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Number\ of\ arguments\ must\ be\ even!\(\backslash\)n"{}});}
\DoxyCodeLine{00732\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ NULL;}
\DoxyCodeLine{00733\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00734\ \ \ \ \ \ \ \ \ ++f\_argc;}
\DoxyCodeLine{00735\ \ \ \ \ \}}
\DoxyCodeLine{00736\ \ \ \ \ va\_end(args);}
\DoxyCodeLine{00737\ }
\DoxyCodeLine{00738\ \ \ \ \ \textcolor{comment}{/*\ Now\ allocate\ f\_argv\ */}}
\DoxyCodeLine{00739\ \ \ \ \ f\_argv\ =\ ckd\_calloc(f\_argc,\ \textcolor{keyword}{sizeof}(*f\_argv));}
\DoxyCodeLine{00740\ \ \ \ \ va\_start(args,\ strict);}
\DoxyCodeLine{00741\ \ \ \ \ f\_argc\ =\ 0;}
\DoxyCodeLine{00742\ \ \ \ \ \textcolor{keywordflow}{while}\ ((arg\ =\ va\_arg(args,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *)))\ \{}
\DoxyCodeLine{00743\ \ \ \ \ \ \ \ \ f\_argv[f\_argc]\ =\ ckd\_salloc(arg);}
\DoxyCodeLine{00744\ \ \ \ \ \ \ \ \ ++f\_argc;}
\DoxyCodeLine{00745\ \ \ \ \ \ \ \ \ val\ =\ va\_arg(args,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}*);}
\DoxyCodeLine{00746\ \ \ \ \ \ \ \ \ f\_argv[f\_argc]\ =\ ckd\_salloc(val);}
\DoxyCodeLine{00747\ \ \ \ \ \ \ \ \ ++f\_argc;}
\DoxyCodeLine{00748\ \ \ \ \ \}}
\DoxyCodeLine{00749\ \ \ \ \ va\_end(args);}
\DoxyCodeLine{00750\ }
\DoxyCodeLine{00751\ \ \ \ \ \textcolor{keywordflow}{return}\ parse\_options(inout\_cmdln,\ defn,\ f\_argc,\ f\_argv,\ strict);}
\DoxyCodeLine{00752\ \}}
\DoxyCodeLine{00753\ }
\DoxyCodeLine{00754\ \textcolor{keywordtype}{int}}
\DoxyCodeLine{00755\ cmd\_ln\_parse(\textcolor{keyword}{const}\ arg\_t\ *\ defn,\ int32\ argc,\ \textcolor{keywordtype}{char}\ *argv[],\ \textcolor{keywordtype}{int}\ strict)}
\DoxyCodeLine{00756\ \{}
\DoxyCodeLine{00757\ \ \ \ \ cmd\_ln\_t\ *cmdln;}
\DoxyCodeLine{00758\ }
\DoxyCodeLine{00759\ \ \ \ \ cmdln\ =\ cmd\_ln\_parse\_r(global\_cmdln,\ defn,\ argc,\ argv,\ strict);}
\DoxyCodeLine{00760\ \ \ \ \ \textcolor{keywordflow}{if}\ (cmdln\ ==\ NULL)\ \{}
\DoxyCodeLine{00761\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Old,\ bogus\ behaviour...\ */}}
\DoxyCodeLine{00762\ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Failed\ to\ parse\ arguments\ list,\ forced\ exit\(\backslash\)n"{}});}
\DoxyCodeLine{00763\ \ \ \ \ \ \ \ \ exit(-\/1);}
\DoxyCodeLine{00764\ \ \ \ \ \}}
\DoxyCodeLine{00765\ \ \ \ \ \textcolor{comment}{/*\ Initialize\ global\_cmdln\ if\ not\ present.\ */}}
\DoxyCodeLine{00766\ \ \ \ \ \textcolor{keywordflow}{if}\ (global\_cmdln\ ==\ NULL)\ \{}
\DoxyCodeLine{00767\ \ \ \ \ \ \ \ \ global\_cmdln\ =\ cmdln;}
\DoxyCodeLine{00768\ \ \ \ \ \}}
\DoxyCodeLine{00769\ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{00770\ \}}
\DoxyCodeLine{00771\ }
\DoxyCodeLine{00772\ cmd\_ln\_t\ *}
\DoxyCodeLine{00773\ cmd\_ln\_parse\_file\_r(cmd\_ln\_t\ *inout\_cmdln,\ \textcolor{keyword}{const}\ arg\_t\ *\ defn,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *filename,\ int32\ strict)}
\DoxyCodeLine{00774\ \{}
\DoxyCodeLine{00775\ \ \ \ \ FILE\ *file;}
\DoxyCodeLine{00776\ \ \ \ \ \textcolor{keywordtype}{int}\ argc;}
\DoxyCodeLine{00777\ \ \ \ \ \textcolor{keywordtype}{int}\ argv\_size;}
\DoxyCodeLine{00778\ \ \ \ \ \textcolor{keywordtype}{char}\ *str;}
\DoxyCodeLine{00779\ \ \ \ \ \textcolor{keywordtype}{int}\ arg\_max\_length\ =\ 512;}
\DoxyCodeLine{00780\ \ \ \ \ \textcolor{keywordtype}{int}\ len\ =\ 0;}
\DoxyCodeLine{00781\ \ \ \ \ \textcolor{keywordtype}{int}\ quoting,\ ch;}
\DoxyCodeLine{00782\ \ \ \ \ \textcolor{keywordtype}{char}\ **f\_argv;}
\DoxyCodeLine{00783\ \ \ \ \ \textcolor{keywordtype}{int}\ rv\ =\ 0;}
\DoxyCodeLine{00784\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ separator[]\ =\ \textcolor{stringliteral}{"{}\ \(\backslash\)t\(\backslash\)r\(\backslash\)n"{}};}
\DoxyCodeLine{00785\ }
\DoxyCodeLine{00786\ \ \ \ \ \textcolor{keywordflow}{if}\ ((file\ =\ fopen(filename,\ \textcolor{stringliteral}{"{}r"{}}))\ ==\ NULL)\ \{}
\DoxyCodeLine{00787\ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Cannot\ open\ configuration\ file\ \%s\ for\ reading\(\backslash\)n"{}},}
\DoxyCodeLine{00788\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ filename);}
\DoxyCodeLine{00789\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ NULL;}
\DoxyCodeLine{00790\ \ \ \ \ \}}
\DoxyCodeLine{00791\ }
\DoxyCodeLine{00792\ \ \ \ \ ch\ =\ fgetc(file);}
\DoxyCodeLine{00793\ \ \ \ \ \textcolor{comment}{/*\ Skip\ to\ the\ next\ interesting\ character\ */}}
\DoxyCodeLine{00794\ \ \ \ \ \textcolor{keywordflow}{for}\ (;\ ch\ !=\ EOF\ \&\&\ strchr(separator,\ ch);\ ch\ =\ fgetc(file))\ ;}
\DoxyCodeLine{00795\ }
\DoxyCodeLine{00796\ \ \ \ \ \textcolor{keywordflow}{if}\ (ch\ ==\ EOF)\ \{}
\DoxyCodeLine{00797\ \ \ \ \ \ \ \ \ fclose(file);}
\DoxyCodeLine{00798\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ NULL;}
\DoxyCodeLine{00799\ \ \ \ \ \}}
\DoxyCodeLine{00800\ }
\DoxyCodeLine{00801\ \ \ \ \ \textcolor{comment}{/*}}
\DoxyCodeLine{00802\ \textcolor{comment}{\ \ \ \ \ *\ Initialize\ default\ argv,\ argc,\ and\ argv\_size.}}
\DoxyCodeLine{00803\ \textcolor{comment}{\ \ \ \ \ */}}
\DoxyCodeLine{00804\ \ \ \ \ argv\_size\ =\ 10;}
\DoxyCodeLine{00805\ \ \ \ \ argc\ =\ 0;}
\DoxyCodeLine{00806\ \ \ \ \ f\_argv\ =\ ckd\_calloc(argv\_size,\ \textcolor{keyword}{sizeof}(\textcolor{keywordtype}{char}\ *));}
\DoxyCodeLine{00807\ \ \ \ \ \textcolor{comment}{/*\ Silently\ make\ room\ for\ \(\backslash\)0\ */}}
\DoxyCodeLine{00808\ \ \ \ \ str\ =\ ckd\_calloc(arg\_max\_length\ +\ 1,\ \textcolor{keyword}{sizeof}(\textcolor{keywordtype}{char}));}
\DoxyCodeLine{00809\ \ \ \ \ quoting\ =\ 0;}
\DoxyCodeLine{00810\ }
\DoxyCodeLine{00811\ \ \ \ \ \textcolor{keywordflow}{do}\ \{}
\DoxyCodeLine{00812\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Handle\ arguments\ that\ are\ commented\ out\ */}}
\DoxyCodeLine{00813\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (len\ ==\ 0\ \&\&\ argc\ \%\ 2\ ==\ 0)\ \{}
\DoxyCodeLine{00814\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{while}\ (ch\ ==\ \textcolor{charliteral}{'\#'})\ \{}
\DoxyCodeLine{00815\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Skip\ everything\ until\ newline\ */}}
\DoxyCodeLine{00816\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (ch\ =\ fgetc(file);\ ch\ !=\ EOF\ \&\&\ ch\ !=\ \textcolor{charliteral}{'\(\backslash\)n'};\ ch\ =\ fgetc(file))\ ;}
\DoxyCodeLine{00817\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Skip\ to\ the\ next\ interesting\ character\ */}}
\DoxyCodeLine{00818\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (ch\ =\ fgetc(file);\ ch\ !=\ EOF\ \&\&\ strchr(separator,\ ch);\ ch\ =\ fgetc(file))\ ;}
\DoxyCodeLine{00819\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00820\ }
\DoxyCodeLine{00821\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Check\ if\ we\ are\ at\ the\ last\ line\ (without\ anything\ interesting\ in\ it)\ */}}
\DoxyCodeLine{00822\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (ch\ ==\ EOF)}
\DoxyCodeLine{00823\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00824\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00825\ }
\DoxyCodeLine{00826\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Handle\ quoted\ arguments\ */}}
\DoxyCodeLine{00827\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (ch\ ==\ \textcolor{charliteral}{'"{}'}\ ||\ ch\ ==\ \textcolor{charliteral}{'\(\backslash\)''})\ \{}
\DoxyCodeLine{00828\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (quoting\ ==\ ch)\ \textcolor{comment}{/*\ End\ a\ quoted\ section\ with\ the\ same\ type\ */}}
\DoxyCodeLine{00829\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ quoting\ =\ 0;}
\DoxyCodeLine{00830\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (quoting)\ \{}
\DoxyCodeLine{00831\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Nesting\ quotations\ is\ not\ supported!\(\backslash\)n"{}});}
\DoxyCodeLine{00832\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ rv\ =\ 1;}
\DoxyCodeLine{00833\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00834\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00835\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{00836\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ quoting\ =\ ch;\ \textcolor{comment}{/*\ Start\ a\ quoted\ section\ */}}
\DoxyCodeLine{00837\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00838\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (ch\ ==\ EOF\ ||\ (!quoting\ \&\&\ strchr(separator,\ ch)))\ \{}
\DoxyCodeLine{00839\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Reallocate\ argv\ so\ it\ is\ big\ enough\ to\ contain\ all\ the\ arguments\ */}}
\DoxyCodeLine{00840\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (argc\ >=\ argv\_size)\ \{}
\DoxyCodeLine{00841\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{char}\ **tmp\_argv;}
\DoxyCodeLine{00842\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (!(tmp\_argv\ =}
\DoxyCodeLine{00843\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ckd\_realloc(f\_argv,\ argv\_size\ *\ 2\ *\ \textcolor{keyword}{sizeof}(\textcolor{keywordtype}{char}\ *))))\ \{}
\DoxyCodeLine{00844\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ rv\ =\ 1;}
\DoxyCodeLine{00845\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00846\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00847\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ f\_argv\ =\ tmp\_argv;}
\DoxyCodeLine{00848\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ argv\_size\ *=\ 2;}
\DoxyCodeLine{00849\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00850\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Add\ the\ string\ to\ the\ list\ of\ arguments\ */}}
\DoxyCodeLine{00851\ \ \ \ \ \ \ \ \ \ \ \ \ f\_argv[argc]\ =\ ckd\_salloc(str);}
\DoxyCodeLine{00852\ \ \ \ \ \ \ \ \ \ \ \ \ len\ =\ 0;}
\DoxyCodeLine{00853\ \ \ \ \ \ \ \ \ \ \ \ \ str[0]\ =\ \textcolor{charliteral}{'\(\backslash\)0'};}
\DoxyCodeLine{00854\ \ \ \ \ \ \ \ \ \ \ \ \ argc++;}
\DoxyCodeLine{00855\ }
\DoxyCodeLine{00856\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (quoting)}
\DoxyCodeLine{00857\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ E\_WARN(\textcolor{stringliteral}{"{}Unclosed\ quotation,\ having\ EOF\ close\ it...\(\backslash\)n"{}});}
\DoxyCodeLine{00858\ }
\DoxyCodeLine{00859\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Skip\ to\ the\ next\ interesting\ character\ */}}
\DoxyCodeLine{00860\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (;\ ch\ !=\ EOF\ \&\&\ strchr(separator,\ ch);\ ch\ =\ fgetc(file))\ ;}
\DoxyCodeLine{00861\ }
\DoxyCodeLine{00862\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (ch\ ==\ EOF)}
\DoxyCodeLine{00863\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00864\ }
\DoxyCodeLine{00865\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ We\ already\ have\ the\ next\ character\ */}}
\DoxyCodeLine{00866\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{continue};}
\DoxyCodeLine{00867\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00868\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00869\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (len\ >=\ arg\_max\_length)\ \{}
\DoxyCodeLine{00870\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Make\ room\ for\ more\ chars\ (including\ the\ \(\backslash\)0\ !)\ */}}
\DoxyCodeLine{00871\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{char}\ *tmp\_str\ =\ str;}
\DoxyCodeLine{00872\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ ((tmp\_str\ =\ ckd\_realloc(str,\ (1\ +\ arg\_max\_length\ *\ 2)\ *\ \textcolor{keyword}{sizeof}(\textcolor{keywordtype}{char})))\ ==\ NULL)\ \{}
\DoxyCodeLine{00873\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ rv\ =\ 1;}
\DoxyCodeLine{00874\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00875\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00876\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ str\ =\ tmp\_str;}
\DoxyCodeLine{00877\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ arg\_max\_length\ *=\ 2;}
\DoxyCodeLine{00878\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00879\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Add\ the\ char\ to\ the\ argument\ string\ */}}
\DoxyCodeLine{00880\ \ \ \ \ \ \ \ \ \ \ \ \ str[len++]\ =\ ch;}
\DoxyCodeLine{00881\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Always\ null\ terminate\ */}}
\DoxyCodeLine{00882\ \ \ \ \ \ \ \ \ \ \ \ \ str[len]\ =\ \textcolor{charliteral}{'\(\backslash\)0'};}
\DoxyCodeLine{00883\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00884\ }
\DoxyCodeLine{00885\ \ \ \ \ \ \ \ \ ch\ =\ fgetc(file);}
\DoxyCodeLine{00886\ \ \ \ \ \}\ \textcolor{keywordflow}{while}\ (1);}
\DoxyCodeLine{00887\ }
\DoxyCodeLine{00888\ \ \ \ \ fclose(file);}
\DoxyCodeLine{00889\ }
\DoxyCodeLine{00890\ \ \ \ \ ckd\_free(str);}
\DoxyCodeLine{00891\ }
\DoxyCodeLine{00892\ \ \ \ \ \textcolor{keywordflow}{if}\ (rv)\ \{}
\DoxyCodeLine{00893\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (ch\ =\ 0;\ ch\ <\ argc;\ ++ch)}
\DoxyCodeLine{00894\ \ \ \ \ \ \ \ \ \ \ \ \ ckd\_free(f\_argv[ch]);}
\DoxyCodeLine{00895\ \ \ \ \ \ \ \ \ ckd\_free(f\_argv);}
\DoxyCodeLine{00896\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ NULL;}
\DoxyCodeLine{00897\ \ \ \ \ \}}
\DoxyCodeLine{00898\ }
\DoxyCodeLine{00899\ \ \ \ \ \textcolor{keywordflow}{return}\ parse\_options(inout\_cmdln,\ defn,\ argc,\ f\_argv,\ strict);}
\DoxyCodeLine{00900\ \}}
\DoxyCodeLine{00901\ }
\DoxyCodeLine{00902\ \textcolor{keywordtype}{int}}
\DoxyCodeLine{00903\ cmd\_ln\_parse\_file(\textcolor{keyword}{const}\ arg\_t\ *\ defn,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *filename,\ int32\ strict)}
\DoxyCodeLine{00904\ \{}
\DoxyCodeLine{00905\ \ \ \ \ cmd\_ln\_t\ *cmdln;}
\DoxyCodeLine{00906\ }
\DoxyCodeLine{00907\ \ \ \ \ cmdln\ =\ cmd\_ln\_parse\_file\_r(global\_cmdln,\ defn,\ filename,\ strict);}
\DoxyCodeLine{00908\ \ \ \ \ \textcolor{keywordflow}{if}\ (cmdln\ ==\ NULL)\ \{}
\DoxyCodeLine{00909\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{00910\ \ \ \ \ \}}
\DoxyCodeLine{00911\ \ \ \ \ \textcolor{comment}{/*\ Initialize\ global\_cmdln\ if\ not\ present.\ */}}
\DoxyCodeLine{00912\ \ \ \ \ \textcolor{keywordflow}{if}\ (global\_cmdln\ ==\ NULL)\ \{}
\DoxyCodeLine{00913\ \ \ \ \ \ \ \ \ global\_cmdln\ =\ cmdln;}
\DoxyCodeLine{00914\ \ \ \ \ \}}
\DoxyCodeLine{00915\ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{00916\ \}}
\DoxyCodeLine{00917\ }
\DoxyCodeLine{00918\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00919\ cmd\_ln\_print\_help\_r(cmd\_ln\_t\ *cmdln,\ FILE\ *\ fp,\ arg\_t\ \textcolor{keyword}{const}*\ defn)}
\DoxyCodeLine{00920\ \{}
\DoxyCodeLine{00921\ \ \ \ \ \textcolor{keywordflow}{if}\ (defn\ ==\ NULL)}
\DoxyCodeLine{00922\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return};}
\DoxyCodeLine{00923\ \ \ \ \ fprintf(fp,\ \textcolor{stringliteral}{"{}Arguments\ list\ definition:\(\backslash\)n"{}});}
\DoxyCodeLine{00924\ \ \ \ \ arg\_dump\_r(cmdln,\ fp,\ defn,\ 1);}
\DoxyCodeLine{00925\ \ \ \ \ fflush(fp);}
\DoxyCodeLine{00926\ \}}
\DoxyCodeLine{00927\ }
\DoxyCodeLine{00928\ \textcolor{keywordtype}{int}}
\DoxyCodeLine{00929\ cmd\_ln\_exists\_r(cmd\_ln\_t\ *cmdln,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *name)}
\DoxyCodeLine{00930\ \{}
\DoxyCodeLine{00931\ \ \ \ \ \textcolor{keywordtype}{void}\ *val;}
\DoxyCodeLine{00932\ \ \ \ \ \textcolor{keywordflow}{if}\ (cmdln\ ==\ NULL)}
\DoxyCodeLine{00933\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ FALSE;}
\DoxyCodeLine{00934\ \ \ \ \ \textcolor{keywordflow}{return}\ (hash\_table\_lookup(cmdln-\/>ht,\ name,\ \&val)\ ==\ 0);}
\DoxyCodeLine{00935\ \}}
\DoxyCodeLine{00936\ }
\DoxyCodeLine{00937\ anytype\_t\ *}
\DoxyCodeLine{00938\ cmd\_ln\_access\_r(cmd\_ln\_t\ *cmdln,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *name)}
\DoxyCodeLine{00939\ \{}
\DoxyCodeLine{00940\ \ \ \ \ \textcolor{keywordtype}{void}\ *val;}
\DoxyCodeLine{00941\ \ \ \ \ \textcolor{keywordflow}{if}\ (hash\_table\_lookup(cmdln-\/>ht,\ name,\ \&val)\ <\ 0)\ \{}
\DoxyCodeLine{00942\ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Unknown\ argument:\ \%s\(\backslash\)n"{}},\ name);}
\DoxyCodeLine{00943\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ NULL;}
\DoxyCodeLine{00944\ \ \ \ \ \}}
\DoxyCodeLine{00945\ \ \ \ \ \textcolor{keywordflow}{return}\ (anytype\_t\ *)val;}
\DoxyCodeLine{00946\ \}}
\DoxyCodeLine{00947\ }
\DoxyCodeLine{00948\ \textcolor{keywordtype}{char}\ \textcolor{keyword}{const}\ *}
\DoxyCodeLine{00949\ cmd\_ln\_str\_r(cmd\_ln\_t\ *cmdln,\ \textcolor{keywordtype}{char}\ \textcolor{keyword}{const}\ *name)}
\DoxyCodeLine{00950\ \{}
\DoxyCodeLine{00951\ \ \ \ \ anytype\_t\ *val;}
\DoxyCodeLine{00952\ \ \ \ \ val\ =\ cmd\_ln\_access\_r(cmdln,\ name);}
\DoxyCodeLine{00953\ \ \ \ \ \textcolor{keywordflow}{if}\ (val\ ==\ NULL)}
\DoxyCodeLine{00954\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ NULL;}
\DoxyCodeLine{00955\ \ \ \ \ \textcolor{keywordflow}{return}\ (\textcolor{keywordtype}{char}\ \textcolor{keyword}{const}\ *)val-\/>ptr;}
\DoxyCodeLine{00956\ \}}
\DoxyCodeLine{00957\ }
\DoxyCodeLine{00958\ \textcolor{keywordtype}{char}\ \textcolor{keyword}{const}\ **}
\DoxyCodeLine{00959\ cmd\_ln\_str\_list\_r(cmd\_ln\_t\ *cmdln,\ \textcolor{keywordtype}{char}\ \textcolor{keyword}{const}\ *name)}
\DoxyCodeLine{00960\ \{}
\DoxyCodeLine{00961\ \ \ \ \ anytype\_t\ *val;}
\DoxyCodeLine{00962\ \ \ \ \ val\ =\ cmd\_ln\_access\_r(cmdln,\ name);}
\DoxyCodeLine{00963\ \ \ \ \ \textcolor{keywordflow}{if}\ (val\ ==\ NULL)}
\DoxyCodeLine{00964\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ NULL;}
\DoxyCodeLine{00965\ \ \ \ \ \textcolor{keywordflow}{return}\ (\textcolor{keywordtype}{char}\ \textcolor{keyword}{const}\ **)val-\/>ptr;}
\DoxyCodeLine{00966\ \}}
\DoxyCodeLine{00967\ }
\DoxyCodeLine{00968\ \textcolor{keywordtype}{long}}
\DoxyCodeLine{00969\ cmd\_ln\_int\_r(cmd\_ln\_t\ *cmdln,\ \textcolor{keywordtype}{char}\ \textcolor{keyword}{const}\ *name)}
\DoxyCodeLine{00970\ \{}
\DoxyCodeLine{00971\ \ \ \ \ anytype\_t\ *val;}
\DoxyCodeLine{00972\ \ \ \ \ val\ =\ cmd\_ln\_access\_r(cmdln,\ name);}
\DoxyCodeLine{00973\ \ \ \ \ \textcolor{keywordflow}{if}\ (val\ ==\ NULL)}
\DoxyCodeLine{00974\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 0L;}
\DoxyCodeLine{00975\ \ \ \ \ \textcolor{keywordflow}{return}\ val-\/>i;}
\DoxyCodeLine{00976\ \}}
\DoxyCodeLine{00977\ }
\DoxyCodeLine{00978\ \textcolor{keywordtype}{double}}
\DoxyCodeLine{00979\ cmd\_ln\_float\_r(cmd\_ln\_t\ *cmdln,\ \textcolor{keywordtype}{char}\ \textcolor{keyword}{const}\ *name)}
\DoxyCodeLine{00980\ \{}
\DoxyCodeLine{00981\ \ \ \ \ anytype\_t\ *val;}
\DoxyCodeLine{00982\ \ \ \ \ val\ =\ cmd\_ln\_access\_r(cmdln,\ name);}
\DoxyCodeLine{00983\ \ \ \ \ \textcolor{keywordflow}{if}\ (val\ ==\ NULL)}
\DoxyCodeLine{00984\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 0.0;}
\DoxyCodeLine{00985\ \ \ \ \ \textcolor{keywordflow}{return}\ val-\/>fl;}
\DoxyCodeLine{00986\ \}}
\DoxyCodeLine{00987\ }
\DoxyCodeLine{00988\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00989\ cmd\_ln\_set\_str\_r(cmd\_ln\_t\ *cmdln,\ \textcolor{keywordtype}{char}\ \textcolor{keyword}{const}\ *name,\ \textcolor{keywordtype}{char}\ \textcolor{keyword}{const}\ *str)}
\DoxyCodeLine{00990\ \{}
\DoxyCodeLine{00991\ \ \ \ \ anytype\_t\ *val;}
\DoxyCodeLine{00992\ \ \ \ \ val\ =\ cmd\_ln\_access\_r(cmdln,\ name);}
\DoxyCodeLine{00993\ \ \ \ \ \textcolor{keywordflow}{if}\ (val\ ==\ NULL)\ \{}
\DoxyCodeLine{00994\ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Unknown\ argument:\ \%s\(\backslash\)n"{}},\ name);}
\DoxyCodeLine{00995\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return};}
\DoxyCodeLine{00996\ \ \ \ \ \}}
\DoxyCodeLine{00997\ \ \ \ \ ckd\_free(val-\/>ptr);}
\DoxyCodeLine{00998\ \ \ \ \ \textcolor{keywordflow}{if}\ (str\ ==\ NULL)}
\DoxyCodeLine{00999\ \ \ \ \ \ \ \ \ val-\/>ptr\ =\ NULL;}
\DoxyCodeLine{01000\ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{01001\ \ \ \ \ \ \ \ \ val-\/>ptr\ =\ ckd\_salloc(str);}
\DoxyCodeLine{01002\ \}}
\DoxyCodeLine{01003\ }
\DoxyCodeLine{01004\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{01005\ cmd\_ln\_set\_int\_r(cmd\_ln\_t\ *cmdln,\ \textcolor{keywordtype}{char}\ \textcolor{keyword}{const}\ *name,\ \textcolor{keywordtype}{long}\ iv)}
\DoxyCodeLine{01006\ \{}
\DoxyCodeLine{01007\ \ \ \ \ anytype\_t\ *val;}
\DoxyCodeLine{01008\ \ \ \ \ val\ =\ cmd\_ln\_access\_r(cmdln,\ name);}
\DoxyCodeLine{01009\ \ \ \ \ \textcolor{keywordflow}{if}\ (val\ ==\ NULL)\ \{}
\DoxyCodeLine{01010\ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Unknown\ argument:\ \%s\(\backslash\)n"{}},\ name);}
\DoxyCodeLine{01011\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return};}
\DoxyCodeLine{01012\ \ \ \ \ \}}
\DoxyCodeLine{01013\ \ \ \ \ val-\/>i\ =\ iv;}
\DoxyCodeLine{01014\ \}}
\DoxyCodeLine{01015\ }
\DoxyCodeLine{01016\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{01017\ cmd\_ln\_set\_float\_r(cmd\_ln\_t\ *cmdln,\ \textcolor{keywordtype}{char}\ \textcolor{keyword}{const}\ *name,\ \textcolor{keywordtype}{double}\ fv)}
\DoxyCodeLine{01018\ \{}
\DoxyCodeLine{01019\ \ \ \ \ anytype\_t\ *val;}
\DoxyCodeLine{01020\ \ \ \ \ val\ =\ cmd\_ln\_access\_r(cmdln,\ name);}
\DoxyCodeLine{01021\ \ \ \ \ \textcolor{keywordflow}{if}\ (val\ ==\ NULL)\ \{}
\DoxyCodeLine{01022\ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Unknown\ argument:\ \%s\(\backslash\)n"{}},\ name);}
\DoxyCodeLine{01023\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return};}
\DoxyCodeLine{01024\ \ \ \ \ \}}
\DoxyCodeLine{01025\ \ \ \ \ val-\/>fl\ =\ fv;}
\DoxyCodeLine{01026\ \}}
\DoxyCodeLine{01027\ }
\DoxyCodeLine{01028\ cmd\_ln\_t\ *}
\DoxyCodeLine{01029\ cmd\_ln\_retain(cmd\_ln\_t\ *cmdln)}
\DoxyCodeLine{01030\ \{}
\DoxyCodeLine{01031\ \ \ \ \ ++cmdln-\/>refcount;}
\DoxyCodeLine{01032\ \ \ \ \ \textcolor{keywordflow}{return}\ cmdln;}
\DoxyCodeLine{01033\ \}}
\DoxyCodeLine{01034\ }
\DoxyCodeLine{01035\ \textcolor{keywordtype}{int}}
\DoxyCodeLine{01036\ cmd\_ln\_free\_r(cmd\_ln\_t\ *cmdln)}
\DoxyCodeLine{01037\ \{}
\DoxyCodeLine{01038\ \ \ \ \ \textcolor{keywordflow}{if}\ (cmdln\ ==\ NULL)}
\DoxyCodeLine{01039\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{01040\ \ \ \ \ \textcolor{keywordflow}{if}\ (-\/-\/cmdln-\/>refcount\ >\ 0)}
\DoxyCodeLine{01041\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ cmdln-\/>refcount;}
\DoxyCodeLine{01042\ }
\DoxyCodeLine{01043\ \ \ \ \ \textcolor{keywordflow}{if}\ (cmdln-\/>ht)\ \{}
\DoxyCodeLine{01044\ \ \ \ \ \ \ \ \ glist\_t\ entries;}
\DoxyCodeLine{01045\ \ \ \ \ \ \ \ \ gnode\_t\ *gn;}
\DoxyCodeLine{01046\ \ \ \ \ \ \ \ \ int32\ n;}
\DoxyCodeLine{01047\ }
\DoxyCodeLine{01048\ \ \ \ \ \ \ \ \ entries\ =\ hash\_table\_tolist(cmdln-\/>ht,\ \&n);}
\DoxyCodeLine{01049\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (gn\ =\ entries;\ gn;\ gn\ =\ gnode\_next(gn))\ \{}
\DoxyCodeLine{01050\ \ \ \ \ \ \ \ \ \ \ \ \ hash\_entry\_t\ *e\ =\ gnode\_ptr(gn);}
\DoxyCodeLine{01051\ \ \ \ \ \ \ \ \ \ \ \ \ cmd\_ln\_val\_free((cmd\_ln\_val\_t\ *)e-\/>val);}
\DoxyCodeLine{01052\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{01053\ \ \ \ \ \ \ \ \ glist\_free(entries);}
\DoxyCodeLine{01054\ \ \ \ \ \ \ \ \ hash\_table\_free(cmdln-\/>ht);}
\DoxyCodeLine{01055\ \ \ \ \ \ \ \ \ cmdln-\/>ht\ =\ NULL;}
\DoxyCodeLine{01056\ \ \ \ \ \}}
\DoxyCodeLine{01057\ }
\DoxyCodeLine{01058\ \ \ \ \ \textcolor{keywordflow}{if}\ (cmdln-\/>f\_argv)\ \{}
\DoxyCodeLine{01059\ \ \ \ \ \ \ \ \ int32\ i;}
\DoxyCodeLine{01060\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ cmdln-\/>f\_argc;\ ++i)\ \{}
\DoxyCodeLine{01061\ \ \ \ \ \ \ \ \ \ \ \ \ ckd\_free(cmdln-\/>f\_argv[i]);}
\DoxyCodeLine{01062\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{01063\ \ \ \ \ \ \ \ \ ckd\_free(cmdln-\/>f\_argv);}
\DoxyCodeLine{01064\ \ \ \ \ \ \ \ \ cmdln-\/>f\_argv\ =\ NULL;}
\DoxyCodeLine{01065\ \ \ \ \ \ \ \ \ cmdln-\/>f\_argc\ =\ 0;}
\DoxyCodeLine{01066\ \ \ \ \ \}}
\DoxyCodeLine{01067\ \ \ \ \ ckd\_free(cmdln);}
\DoxyCodeLine{01068\ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{01069\ \}}
\DoxyCodeLine{01070\ }
\DoxyCodeLine{01071\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{01072\ cmd\_ln\_free(\textcolor{keywordtype}{void})}
\DoxyCodeLine{01073\ \{}
\DoxyCodeLine{01074\ \ \ \ \ cmd\_ln\_free\_r(global\_cmdln);}
\DoxyCodeLine{01075\ \ \ \ \ global\_cmdln\ =\ NULL;}
\DoxyCodeLine{01076\ \}}

\end{DoxyCode}
