\doxysection{err\+\_\+wince.\+c}
\label{err__wince_8c_source}\index{src/libsphinxbase/util/err\_wince.c@{src/libsphinxbase/util/err\_wince.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}{\ *\ err\_wince.c\ -\/-\/\ Package\ for\ checking\ and\ catching\ common\ errors,\ printing\ out}}
\DoxyCodeLine{00039\ \textcolor{comment}{\ *\ \ \ \ \ \ \ \ \ \ \ \ \ \ errors\ nicely,\ etc.}}
\DoxyCodeLine{00040\ \textcolor{comment}{\ *\ WinCE\ has\ no\ standard\ library\ worth\ the\ name\ so\ we\ need\ this}}
\DoxyCodeLine{00041\ \textcolor{comment}{\ */}}
\DoxyCodeLine{00042\ }
\DoxyCodeLine{00043\ }
\DoxyCodeLine{00044\ \textcolor{preprocessor}{\#include\ <stdio.h>}}
\DoxyCodeLine{00045\ \textcolor{preprocessor}{\#include\ <stdlib.h>}}
\DoxyCodeLine{00046\ \textcolor{preprocessor}{\#include\ <string.h>}}
\DoxyCodeLine{00047\ \textcolor{preprocessor}{\#include\ <windows.h>}}
\DoxyCodeLine{00048\ \textcolor{preprocessor}{\#include\ <assert.h>}}
\DoxyCodeLine{00049\ }
\DoxyCodeLine{00050\ \textcolor{preprocessor}{\#include\ "{}sphinxbase/err.h"{}}}
\DoxyCodeLine{00051\ \textcolor{preprocessor}{\#include\ "{}sphinxbase/ckd\_alloc.h"{}}}
\DoxyCodeLine{00052\ }
\DoxyCodeLine{00053\ \textcolor{keywordtype}{int}\ cst\_verrmsg(\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *fmt,\ va\_list\ args)}
\DoxyCodeLine{00054\ \{}
\DoxyCodeLine{00055\ \ \ \ \ \textcolor{keywordtype}{char}\ msg[256];}
\DoxyCodeLine{00056\ \ \ \ \ WCHAR\ *wmsg;}
\DoxyCodeLine{00057\ \ \ \ \ \textcolor{keywordtype}{size\_t}\ len;}
\DoxyCodeLine{00058\ }
\DoxyCodeLine{00059\ \ \ \ \ \_vsnprintf(msg,256,fmt,args);}
\DoxyCodeLine{00060\ }
\DoxyCodeLine{00061\ \ \ \ \ len\ =\ mbstowcs(NULL,msg,0)\ +\ 1;}
\DoxyCodeLine{00062\ \ \ \ \ wmsg\ =\ ckd\_calloc(len,\textcolor{keyword}{sizeof}(*wmsg));}
\DoxyCodeLine{00063\ \ \ \ \ mbstowcs(wmsg,msg,len);}
\DoxyCodeLine{00064\ }
\DoxyCodeLine{00065\ \ \ \ \ OutputDebugStringW(wmsg);}
\DoxyCodeLine{00066\ \ \ \ \ ckd\_free(wmsg);}
\DoxyCodeLine{00067\ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{00068\ \}}
\DoxyCodeLine{00069\ }
\DoxyCodeLine{00070\ \textcolor{keywordtype}{int}\ cst\_errmsg(\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *fmt,\ ...)}
\DoxyCodeLine{00071\ \{}
\DoxyCodeLine{00072\ \ \ \ \ va\_list\ args;}
\DoxyCodeLine{00073\ }
\DoxyCodeLine{00074\ \ \ \ \ va\_start(args,fmt);}
\DoxyCodeLine{00075\ \ \ \ \ cst\_verrmsg(fmt,\ args);}
\DoxyCodeLine{00076\ \ \ \ \ va\_end(args);}
\DoxyCodeLine{00077\ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{00078\ \}}
\DoxyCodeLine{00079\ }
\DoxyCodeLine{00080\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00081\ \_E\_\_pr\_info\_header\_wofn(\textcolor{keywordtype}{char}\ \textcolor{keyword}{const}\ *msg)}
\DoxyCodeLine{00082\ \{}
\DoxyCodeLine{00083\ \ \ \ \ cst\_errmsg(\textcolor{stringliteral}{"{}\%s:\(\backslash\)t"{}},\ msg);}
\DoxyCodeLine{00084\ \}}
\DoxyCodeLine{00085\ }
\DoxyCodeLine{00086\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00087\ \_E\_\_pr\_header(\textcolor{keywordtype}{char}\ \textcolor{keyword}{const}\ *f,\ \textcolor{keywordtype}{long}\ ln,\ \textcolor{keywordtype}{char}\ \textcolor{keyword}{const}\ *msg)}
\DoxyCodeLine{00088\ \{}
\DoxyCodeLine{00089\ \ \ \ \ cst\_errmsg(\textcolor{stringliteral}{"{}\%s:\ \(\backslash\)"{}\%s\(\backslash\)"{},\ line\ \%ld:\ "{}},\ msg,\ f,\ ln);}
\DoxyCodeLine{00090\ \}}
\DoxyCodeLine{00091\ }
\DoxyCodeLine{00092\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00093\ \_E\_\_pr\_info\_header(\textcolor{keywordtype}{char}\ \textcolor{keyword}{const}\ *f,\ \textcolor{keywordtype}{long}\ ln,\ \textcolor{keywordtype}{char}\ \textcolor{keyword}{const}\ *msg)}
\DoxyCodeLine{00094\ \{}
\DoxyCodeLine{00095\ \ \ \ \ cst\_errmsg(\textcolor{stringliteral}{"{}\%s:\ \%s(\%ld):\ "{}},\ msg,\ f,\ ln);}
\DoxyCodeLine{00096\ \}}
\DoxyCodeLine{00097\ }
\DoxyCodeLine{00098\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00099\ \_E\_\_pr\_warn(\textcolor{keywordtype}{char}\ \textcolor{keyword}{const}\ *fmt,\ ...)}
\DoxyCodeLine{00100\ \{}
\DoxyCodeLine{00101\ \ \ \ \ va\_list\ pvar;}
\DoxyCodeLine{00102\ }
\DoxyCodeLine{00103\ \ \ \ \ va\_start(pvar,\ fmt);}
\DoxyCodeLine{00104\ \ \ \ \ cst\_verrmsg(fmt,\ pvar);}
\DoxyCodeLine{00105\ \ \ \ \ va\_end(pvar);}
\DoxyCodeLine{00106\ \}}
\DoxyCodeLine{00107\ }
\DoxyCodeLine{00108\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00109\ \_E\_\_pr\_info(\textcolor{keywordtype}{char}\ \textcolor{keyword}{const}\ *fmt,\ ...)}
\DoxyCodeLine{00110\ \{}
\DoxyCodeLine{00111\ \ \ \ \ va\_list\ pvar;}
\DoxyCodeLine{00112\ }
\DoxyCodeLine{00113\ \ \ \ \ va\_start(pvar,\ fmt);}
\DoxyCodeLine{00114\ \ \ \ \ cst\_verrmsg(fmt,\ pvar);}
\DoxyCodeLine{00115\ \ \ \ \ va\_end(pvar);}
\DoxyCodeLine{00116\ \}}
\DoxyCodeLine{00117\ }
\DoxyCodeLine{00118\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00119\ \_E\_\_die\_error(\textcolor{keywordtype}{char}\ \textcolor{keyword}{const}\ *fmt,\ ...)}
\DoxyCodeLine{00120\ \{}
\DoxyCodeLine{00121\ \ \ \ \ va\_list\ pvar;}
\DoxyCodeLine{00122\ }
\DoxyCodeLine{00123\ \ \ \ \ va\_start(pvar,\ fmt);}
\DoxyCodeLine{00124\ \ \ \ \ cst\_verrmsg(fmt,\ pvar);}
\DoxyCodeLine{00125\ \ \ \ \ va\_end(pvar);}
\DoxyCodeLine{00126\ \ \ \ \ exit(-\/1);}
\DoxyCodeLine{00127\ \}}
\DoxyCodeLine{00128\ }
\DoxyCodeLine{00129\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00130\ \_E\_\_fatal\_sys\_error(\textcolor{keywordtype}{char}\ \textcolor{keyword}{const}\ *fmt,\ ...)}
\DoxyCodeLine{00131\ \{}
\DoxyCodeLine{00132\ \ \ \ \ LPVOID\ msg\_buf;}
\DoxyCodeLine{00133\ \ \ \ \ DWORD\ error;}
\DoxyCodeLine{00134\ \ \ \ \ va\_list\ pvar;}
\DoxyCodeLine{00135\ }
\DoxyCodeLine{00136\ \ \ \ \ error\ =\ GetLastError();}
\DoxyCodeLine{00137\ \ \ \ \ va\_start(pvar,\ fmt);}
\DoxyCodeLine{00138\ \ \ \ \ cst\_verrmsg(fmt,\ pvar);}
\DoxyCodeLine{00139\ \ \ \ \ va\_end(pvar);}
\DoxyCodeLine{00140\ }
\DoxyCodeLine{00141\ \ \ \ \ OutputDebugStringW(L\textcolor{stringliteral}{"{};\ "{}});}
\DoxyCodeLine{00142\ \ \ \ \ FormatMessage(FORMAT\_MESSAGE\_ALLOCATE\_BUFFER\ |\ }
\DoxyCodeLine{00143\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ FORMAT\_MESSAGE\_FROM\_SYSTEM\ |\ }
\DoxyCodeLine{00144\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ FORMAT\_MESSAGE\_IGNORE\_INSERTS,}
\DoxyCodeLine{00145\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ NULL,}
\DoxyCodeLine{00146\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ error,}
\DoxyCodeLine{00147\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0,\ \textcolor{comment}{//\ Default\ language}}
\DoxyCodeLine{00148\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (LPTSTR)\ \&msg\_buf,}
\DoxyCodeLine{00149\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0,}
\DoxyCodeLine{00150\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ NULL);}
\DoxyCodeLine{00151\ \ \ \ \ OutputDebugString(msg\_buf);}
\DoxyCodeLine{00152\ \ \ \ \ LocalFree(msg\_buf);}
\DoxyCodeLine{00153\ }
\DoxyCodeLine{00154\ \ \ \ \ exit(error);}
\DoxyCodeLine{00155\ \}}
\DoxyCodeLine{00156\ }
\DoxyCodeLine{00157\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00158\ \_E\_\_sys\_error(\textcolor{keywordtype}{char}\ \textcolor{keyword}{const}\ *fmt,\ ...)}
\DoxyCodeLine{00159\ \{}
\DoxyCodeLine{00160\ \ \ \ \ LPVOID\ msg\_buf;}
\DoxyCodeLine{00161\ \ \ \ \ DWORD\ error;}
\DoxyCodeLine{00162\ \ \ \ \ va\_list\ pvar;}
\DoxyCodeLine{00163\ }
\DoxyCodeLine{00164\ \ \ \ \ error\ =\ GetLastError();}
\DoxyCodeLine{00165\ \ \ \ \ va\_start(pvar,\ fmt);}
\DoxyCodeLine{00166\ \ \ \ \ cst\_verrmsg(fmt,\ pvar);}
\DoxyCodeLine{00167\ \ \ \ \ va\_end(pvar);}
\DoxyCodeLine{00168\ }
\DoxyCodeLine{00169\ \ \ \ \ OutputDebugStringW(L\textcolor{stringliteral}{"{};\ "{}});}
\DoxyCodeLine{00170\ \ \ \ \ FormatMessage(FORMAT\_MESSAGE\_ALLOCATE\_BUFFER\ |\ }
\DoxyCodeLine{00171\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ FORMAT\_MESSAGE\_FROM\_SYSTEM\ |\ }
\DoxyCodeLine{00172\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ FORMAT\_MESSAGE\_IGNORE\_INSERTS,}
\DoxyCodeLine{00173\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ NULL,}
\DoxyCodeLine{00174\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ error,}
\DoxyCodeLine{00175\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0,\ \textcolor{comment}{//\ Default\ language}}
\DoxyCodeLine{00176\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (LPTSTR)\ \&msg\_buf,}
\DoxyCodeLine{00177\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0,}
\DoxyCodeLine{00178\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ NULL);}
\DoxyCodeLine{00179\ \ \ \ \ OutputDebugString(msg\_buf);}
\DoxyCodeLine{00180\ \ \ \ \ LocalFree(msg\_buf);}
\DoxyCodeLine{00181\ \}}
\DoxyCodeLine{00182\ }
\DoxyCodeLine{00183\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00184\ \_E\_\_abort\_error(\textcolor{keywordtype}{char}\ \textcolor{keyword}{const}\ *fmt,\ ...)}
\DoxyCodeLine{00185\ \{}
\DoxyCodeLine{00186\ \ \ \ \ va\_list\ pvar;}
\DoxyCodeLine{00187\ }
\DoxyCodeLine{00188\ \ \ \ \ va\_start(pvar,\ fmt);}
\DoxyCodeLine{00189\ \ \ \ \ cst\_verrmsg(fmt,\ pvar);}
\DoxyCodeLine{00190\ \ \ \ \ va\_end(pvar);}
\DoxyCodeLine{00191\ }
\DoxyCodeLine{00192\ \ \ \ \ assert(2+2\ ==\ 5);}
\DoxyCodeLine{00193\ \}}

\end{DoxyCode}
