change project name
[apps/agl-service-homescreen.git] / doc / api-ref / latex / dd / d1d / hs-helper_8c.tex
1 \hypertarget{hs-helper_8c}{}\section{src/hs-\/helper.c File Reference}
2 \label{hs-helper_8c}\index{src/hs-\/helper.\+c@{src/hs-\/helper.\+c}}
3 {\ttfamily \#include \char`\"{}hs-\/helper.\+h\char`\"{}}\newline
4 {\ttfamily \#include $<$stdlib.\+h$>$}\newline
5 {\ttfamily \#include $<$string.\+h$>$}\newline
6 {\ttfamily \#include $<$limits.\+h$>$}\newline
7 {\ttfamily \#include $<$json-\/c/json.\+h$>$}\newline
8 {\ttfamily \#include $<$stdarg.\+h$>$}\newline
9 \subsection*{Functions}
10 \begin{DoxyCompactItemize}
11 \item 
12 \hyperlink{hs-helper_8h_aa49f1dbbf26f01627a5737cf43aad899}{R\+E\+Q\+\_\+\+E\+R\+R\+OR} \hyperlink{hs-helper_8c_a649900645417f2df3a70b9ad67529f53}{get\+\_\+value\+\_\+uint16} (const struct afb\+\_\+req request, const char $\ast$source, uint16\+\_\+t $\ast$out\+\_\+id)
13 \item 
14 \hyperlink{hs-helper_8h_aa49f1dbbf26f01627a5737cf43aad899}{R\+E\+Q\+\_\+\+E\+R\+R\+OR} \hyperlink{hs-helper_8c_a2e62366684e39ea94436bf017e416827}{get\+\_\+value\+\_\+int16} (const struct afb\+\_\+req request, const char $\ast$source, int16\+\_\+t $\ast$out\+\_\+id)
15 \item 
16 \hyperlink{hs-helper_8h_aa49f1dbbf26f01627a5737cf43aad899}{R\+E\+Q\+\_\+\+E\+R\+R\+OR} \hyperlink{hs-helper_8c_ac5b0370643c520377afd3fd4891918d2}{get\+\_\+value\+\_\+int32} (const struct afb\+\_\+req request, const char $\ast$source, int32\+\_\+t $\ast$out\+\_\+id)
17 \item 
18 void \hyperlink{hs-helper_8c_a1ba31a6a94515ff1730ba0043a67d59e}{hs\+\_\+add\+\_\+object\+\_\+to\+\_\+json\+\_\+object} (struct json\+\_\+object $\ast$j\+\_\+obj, int count,...)
19 \item 
20 void \hyperlink{hs-helper_8c_a8777c53f1d4d5412f19b134ad85ffedf}{hs\+\_\+add\+\_\+object\+\_\+to\+\_\+json\+\_\+object\+\_\+str} (struct json\+\_\+object $\ast$j\+\_\+obj, int count,...)
21 \item 
22 void \hyperlink{hs-helper_8c_ae83604a37134e7bdee3ce4f10bb0b47a}{hs\+\_\+add\+\_\+object\+\_\+to\+\_\+json\+\_\+object\+\_\+func} (struct json\+\_\+object $\ast$j\+\_\+obj, const char $\ast$verb\+\_\+name, int count,...)
23 \item 
24 int \hyperlink{hs-helper_8c_a2ff1b894941c3b461ca8119079c4146a}{hs\+\_\+search\+\_\+event\+\_\+name\+\_\+index} (const char $\ast$value)
25 \end{DoxyCompactItemize}
26
27
28 \subsection{Function Documentation}
29 \mbox{\Hypertarget{hs-helper_8c_a2e62366684e39ea94436bf017e416827}\label{hs-helper_8c_a2e62366684e39ea94436bf017e416827}} 
30 \index{hs-\/helper.\+c@{hs-\/helper.\+c}!get\+\_\+value\+\_\+int16@{get\+\_\+value\+\_\+int16}}
31 \index{get\+\_\+value\+\_\+int16@{get\+\_\+value\+\_\+int16}!hs-\/helper.\+c@{hs-\/helper.\+c}}
32 \subsubsection{\texorpdfstring{get\+\_\+value\+\_\+int16()}{get\_value\_int16()}}
33 {\footnotesize\ttfamily \hyperlink{hs-helper_8h_aa49f1dbbf26f01627a5737cf43aad899}{R\+E\+Q\+\_\+\+E\+R\+R\+OR} get\+\_\+value\+\_\+int16 (\begin{DoxyParamCaption}\item[{const struct afb\+\_\+req}]{request,  }\item[{const char $\ast$}]{source,  }\item[{int16\+\_\+t $\ast$}]{out\+\_\+id }\end{DoxyParamCaption})}
34
35
36
37 Definition at line 48 of file hs-\/helper.\+c.
38
39
40 \begin{DoxyCode}
41 49 \{
42 50     \textcolor{keywordtype}{char}* endptr;
43 51     \textcolor{keyword}{const} \textcolor{keywordtype}{char}* tmp = afb\_req\_value (request, source);
44 52     \textcolor{keywordflow}{if}(!tmp)
45 53     \{
46 54         \textcolor{keywordflow}{return} \hyperlink{hs-helper_8h_aa49f1dbbf26f01627a5737cf43aad899a96a855966bc63045222b3dcac524cee1}{REQ\_FAIL};
47 55     \}
48 56     \textcolor{keywordtype}{long} tmp\_id = strtol(tmp,&endptr,10);
49 57 
50 58     \textcolor{comment}{/* error check of range */}
51 59     \textcolor{keywordflow}{if}( (tmp\_id > INT16\_MAX) || (tmp\_id < INT16\_MIN) )
52 60     \{
53 61         \textcolor{keywordflow}{return} \hyperlink{hs-helper_8h_aa49f1dbbf26f01627a5737cf43aad899add1c84bf80c5f80741ee8f37fef1e12b}{OUT\_RANGE};
54 62     \}
55 63     \textcolor{keywordflow}{if}(*endptr != \textcolor{charliteral}{'\(\backslash\)0'})
56 64     \{
57 65         \textcolor{keywordflow}{return} \hyperlink{hs-helper_8h_aa49f1dbbf26f01627a5737cf43aad899aa223eed65c9bee2bf1f4cdecaf90d66a}{NOT\_NUMBER};
58 66     \}
59 67 
60 68     *out\_id = (int16\_t)tmp\_id;
61 69     \textcolor{keywordflow}{return} \hyperlink{hs-helper_8h_aa49f1dbbf26f01627a5737cf43aad899ab093abb14c097b3b7719debb04d5e8ee}{REQ\_OK};
62 70 \}
63 \end{DoxyCode}
64 \mbox{\Hypertarget{hs-helper_8c_ac5b0370643c520377afd3fd4891918d2}\label{hs-helper_8c_ac5b0370643c520377afd3fd4891918d2}} 
65 \index{hs-\/helper.\+c@{hs-\/helper.\+c}!get\+\_\+value\+\_\+int32@{get\+\_\+value\+\_\+int32}}
66 \index{get\+\_\+value\+\_\+int32@{get\+\_\+value\+\_\+int32}!hs-\/helper.\+c@{hs-\/helper.\+c}}
67 \subsubsection{\texorpdfstring{get\+\_\+value\+\_\+int32()}{get\_value\_int32()}}
68 {\footnotesize\ttfamily \hyperlink{hs-helper_8h_aa49f1dbbf26f01627a5737cf43aad899}{R\+E\+Q\+\_\+\+E\+R\+R\+OR} get\+\_\+value\+\_\+int32 (\begin{DoxyParamCaption}\item[{const struct afb\+\_\+req}]{request,  }\item[{const char $\ast$}]{source,  }\item[{int32\+\_\+t $\ast$}]{out\+\_\+id }\end{DoxyParamCaption})}
69
70
71
72 Definition at line 72 of file hs-\/helper.\+c.
73
74
75 \begin{DoxyCode}
76 73 \{
77 74     \textcolor{keywordtype}{char}* endptr;
78 75     \textcolor{keyword}{const} \textcolor{keywordtype}{char}* tmp = afb\_req\_value (request, source);
79 76     \textcolor{keywordflow}{if}(!tmp)
80 77     \{
81 78         \textcolor{keywordflow}{return} \hyperlink{hs-helper_8h_aa49f1dbbf26f01627a5737cf43aad899a96a855966bc63045222b3dcac524cee1}{REQ\_FAIL};
82 79     \}
83 80     \textcolor{keywordtype}{long} tmp\_id = strtol(tmp,&endptr,10);
84 81 
85 82     \textcolor{comment}{/* error check of range */}
86 83     \textcolor{keywordflow}{if}( (tmp\_id > INT32\_MAX) || (tmp\_id < INT32\_MIN) )
87 84     \{
88 85         \textcolor{keywordflow}{return} \hyperlink{hs-helper_8h_aa49f1dbbf26f01627a5737cf43aad899add1c84bf80c5f80741ee8f37fef1e12b}{OUT\_RANGE};
89 86     \}
90 87     \textcolor{keywordflow}{if}(*endptr != \textcolor{charliteral}{'\(\backslash\)0'})
91 88     \{
92 89         \textcolor{keywordflow}{return} \hyperlink{hs-helper_8h_aa49f1dbbf26f01627a5737cf43aad899aa223eed65c9bee2bf1f4cdecaf90d66a}{NOT\_NUMBER};
93 90     \}
94 91 
95 92     *out\_id = (int32\_t)tmp\_id;
96 93     \textcolor{keywordflow}{return} \hyperlink{hs-helper_8h_aa49f1dbbf26f01627a5737cf43aad899ab093abb14c097b3b7719debb04d5e8ee}{REQ\_OK};
97 94 \}
98 \end{DoxyCode}
99 \mbox{\Hypertarget{hs-helper_8c_a649900645417f2df3a70b9ad67529f53}\label{hs-helper_8c_a649900645417f2df3a70b9ad67529f53}} 
100 \index{hs-\/helper.\+c@{hs-\/helper.\+c}!get\+\_\+value\+\_\+uint16@{get\+\_\+value\+\_\+uint16}}
101 \index{get\+\_\+value\+\_\+uint16@{get\+\_\+value\+\_\+uint16}!hs-\/helper.\+c@{hs-\/helper.\+c}}
102 \subsubsection{\texorpdfstring{get\+\_\+value\+\_\+uint16()}{get\_value\_uint16()}}
103 {\footnotesize\ttfamily \hyperlink{hs-helper_8h_aa49f1dbbf26f01627a5737cf43aad899}{R\+E\+Q\+\_\+\+E\+R\+R\+OR} get\+\_\+value\+\_\+uint16 (\begin{DoxyParamCaption}\item[{const struct afb\+\_\+req}]{request,  }\item[{const char $\ast$}]{source,  }\item[{uint16\+\_\+t $\ast$}]{out\+\_\+id }\end{DoxyParamCaption})}
104
105
106
107 Definition at line 24 of file hs-\/helper.\+c.
108
109
110 \begin{DoxyCode}
111 25 \{
112 26     \textcolor{keywordtype}{char}* endptr;
113 27     \textcolor{keyword}{const} \textcolor{keywordtype}{char}* tmp = afb\_req\_value (request, source);
114 28     \textcolor{keywordflow}{if}(!tmp)
115 29     \{
116 30         \textcolor{keywordflow}{return} \hyperlink{hs-helper_8h_aa49f1dbbf26f01627a5737cf43aad899a96a855966bc63045222b3dcac524cee1}{REQ\_FAIL};
117 31     \}
118 32     \textcolor{keywordtype}{long} tmp\_id = strtol(tmp,&endptr,10);
119 33 
120 34     \textcolor{comment}{/* error check of range */}
121 35     \textcolor{keywordflow}{if}( (tmp\_id > UINT16\_MAX) || (tmp\_id < 0) )
122 36     \{
123 37         \textcolor{keywordflow}{return} \hyperlink{hs-helper_8h_aa49f1dbbf26f01627a5737cf43aad899add1c84bf80c5f80741ee8f37fef1e12b}{OUT\_RANGE};
124 38     \}
125 39     \textcolor{keywordflow}{if}(*endptr != \textcolor{charliteral}{'\(\backslash\)0'})
126 40     \{
127 41         \textcolor{keywordflow}{return} \hyperlink{hs-helper_8h_aa49f1dbbf26f01627a5737cf43aad899aa223eed65c9bee2bf1f4cdecaf90d66a}{NOT\_NUMBER};
128 42     \}
129 43 
130 44     *out\_id = (uint16\_t)tmp\_id;
131 45     \textcolor{keywordflow}{return} \hyperlink{hs-helper_8h_aa49f1dbbf26f01627a5737cf43aad899ab093abb14c097b3b7719debb04d5e8ee}{REQ\_OK};
132 46 \}
133 \end{DoxyCode}
134 \mbox{\Hypertarget{hs-helper_8c_a1ba31a6a94515ff1730ba0043a67d59e}\label{hs-helper_8c_a1ba31a6a94515ff1730ba0043a67d59e}} 
135 \index{hs-\/helper.\+c@{hs-\/helper.\+c}!hs\+\_\+add\+\_\+object\+\_\+to\+\_\+json\+\_\+object@{hs\+\_\+add\+\_\+object\+\_\+to\+\_\+json\+\_\+object}}
136 \index{hs\+\_\+add\+\_\+object\+\_\+to\+\_\+json\+\_\+object@{hs\+\_\+add\+\_\+object\+\_\+to\+\_\+json\+\_\+object}!hs-\/helper.\+c@{hs-\/helper.\+c}}
137 \subsubsection{\texorpdfstring{hs\+\_\+add\+\_\+object\+\_\+to\+\_\+json\+\_\+object()}{hs\_add\_object\_to\_json\_object()}}
138 {\footnotesize\ttfamily void hs\+\_\+add\+\_\+object\+\_\+to\+\_\+json\+\_\+object (\begin{DoxyParamCaption}\item[{struct json\+\_\+object $\ast$}]{j\+\_\+obj,  }\item[{int}]{count,  }\item[{}]{... }\end{DoxyParamCaption})}
139
140
141
142 Definition at line 96 of file hs-\/helper.\+c.
143
144
145 \begin{DoxyCode}
146 97 \{
147 98     va\_list args;
148 99     va\_start(args, count);
149 100     \textcolor{keywordflow}{for}(\textcolor{keywordtype}{int} i = 0; i < count; ++i )
150 101     \{
151 102         \textcolor{keywordtype}{char} *key = va\_arg(args, \textcolor{keywordtype}{char}*);
152 103         \textcolor{keywordtype}{int} value = va\_arg(args, \textcolor{keywordtype}{int});
153 104         json\_object\_object\_add(j\_obj, key, json\_object\_new\_int((int32\_t)value));
154 105         ++i;
155 106     \}
156 107     va\_end(args);
157 108 \}
158 \end{DoxyCode}
159 \mbox{\Hypertarget{hs-helper_8c_ae83604a37134e7bdee3ce4f10bb0b47a}\label{hs-helper_8c_ae83604a37134e7bdee3ce4f10bb0b47a}} 
160 \index{hs-\/helper.\+c@{hs-\/helper.\+c}!hs\+\_\+add\+\_\+object\+\_\+to\+\_\+json\+\_\+object\+\_\+func@{hs\+\_\+add\+\_\+object\+\_\+to\+\_\+json\+\_\+object\+\_\+func}}
161 \index{hs\+\_\+add\+\_\+object\+\_\+to\+\_\+json\+\_\+object\+\_\+func@{hs\+\_\+add\+\_\+object\+\_\+to\+\_\+json\+\_\+object\+\_\+func}!hs-\/helper.\+c@{hs-\/helper.\+c}}
162 \subsubsection{\texorpdfstring{hs\+\_\+add\+\_\+object\+\_\+to\+\_\+json\+\_\+object\+\_\+func()}{hs\_add\_object\_to\_json\_object\_func()}}
163 {\footnotesize\ttfamily void hs\+\_\+add\+\_\+object\+\_\+to\+\_\+json\+\_\+object\+\_\+func (\begin{DoxyParamCaption}\item[{struct json\+\_\+object $\ast$}]{j\+\_\+obj,  }\item[{const char $\ast$}]{verb\+\_\+name,  }\item[{int}]{count,  }\item[{}]{... }\end{DoxyParamCaption})}
164
165
166
167 Definition at line 125 of file hs-\/helper.\+c.
168
169
170 \begin{DoxyCode}
171 126 \{
172 127     va\_list args;
173 128     va\_start(args, count);
174 129 
175 130     json\_object\_object\_add(j\_obj,\textcolor{stringliteral}{"verb"}, json\_object\_new\_string(verb\_name));
176 131 
177 132     \textcolor{keywordflow}{for}(\textcolor{keywordtype}{int} i = 0; i < count; ++i )
178 133     \{
179 134         \textcolor{keywordtype}{char} *key = va\_arg(args, \textcolor{keywordtype}{char}*);
180 135         \textcolor{keywordtype}{int} value = va\_arg(args, \textcolor{keywordtype}{int});
181 136         json\_object\_object\_add(j\_obj, key, json\_object\_new\_int((int32\_t)value));
182 137         ++i;
183 138     \}
184 139     va\_end(args);
185 140 \}
186 \end{DoxyCode}
187 \mbox{\Hypertarget{hs-helper_8c_a8777c53f1d4d5412f19b134ad85ffedf}\label{hs-helper_8c_a8777c53f1d4d5412f19b134ad85ffedf}} 
188 \index{hs-\/helper.\+c@{hs-\/helper.\+c}!hs\+\_\+add\+\_\+object\+\_\+to\+\_\+json\+\_\+object\+\_\+str@{hs\+\_\+add\+\_\+object\+\_\+to\+\_\+json\+\_\+object\+\_\+str}}
189 \index{hs\+\_\+add\+\_\+object\+\_\+to\+\_\+json\+\_\+object\+\_\+str@{hs\+\_\+add\+\_\+object\+\_\+to\+\_\+json\+\_\+object\+\_\+str}!hs-\/helper.\+c@{hs-\/helper.\+c}}
190 \subsubsection{\texorpdfstring{hs\+\_\+add\+\_\+object\+\_\+to\+\_\+json\+\_\+object\+\_\+str()}{hs\_add\_object\_to\_json\_object\_str()}}
191 {\footnotesize\ttfamily void hs\+\_\+add\+\_\+object\+\_\+to\+\_\+json\+\_\+object\+\_\+str (\begin{DoxyParamCaption}\item[{struct json\+\_\+object $\ast$}]{j\+\_\+obj,  }\item[{int}]{count,  }\item[{}]{... }\end{DoxyParamCaption})}
192
193
194
195 Definition at line 110 of file hs-\/helper.\+c.
196
197
198 \begin{DoxyCode}
199 111 \{
200 112     va\_list args;
201 113     va\_start(args, count);
202 114     \textcolor{keywordflow}{for}(\textcolor{keywordtype}{int} i = 0; i < count; ++i )
203 115     \{
204 116         \textcolor{keywordtype}{char} *key = va\_arg(args, \textcolor{keywordtype}{char}*);
205 117         \textcolor{keywordtype}{char} *value = va\_arg(args, \textcolor{keywordtype}{char}*);
206 118         json\_object\_object\_add(j\_obj, key, json\_object\_new\_string(value));
207 119         ++i;
208 120     \}
209 121     va\_end(args);
210 122 \}
211 \end{DoxyCode}
212 \mbox{\Hypertarget{hs-helper_8c_a2ff1b894941c3b461ca8119079c4146a}\label{hs-helper_8c_a2ff1b894941c3b461ca8119079c4146a}} 
213 \index{hs-\/helper.\+c@{hs-\/helper.\+c}!hs\+\_\+search\+\_\+event\+\_\+name\+\_\+index@{hs\+\_\+search\+\_\+event\+\_\+name\+\_\+index}}
214 \index{hs\+\_\+search\+\_\+event\+\_\+name\+\_\+index@{hs\+\_\+search\+\_\+event\+\_\+name\+\_\+index}!hs-\/helper.\+c@{hs-\/helper.\+c}}
215 \subsubsection{\texorpdfstring{hs\+\_\+search\+\_\+event\+\_\+name\+\_\+index()}{hs\_search\_event\_name\_index()}}
216 {\footnotesize\ttfamily int hs\+\_\+search\+\_\+event\+\_\+name\+\_\+index (\begin{DoxyParamCaption}\item[{const char $\ast$}]{value }\end{DoxyParamCaption})}
217
218
219
220 Definition at line 142 of file hs-\/helper.\+c.
221
222
223 \begin{DoxyCode}
224 143 \{
225 144     \textcolor{keywordtype}{size\_t} buf\_size = 50;
226 145     \textcolor{keywordtype}{size\_t} size = \textcolor{keyword}{sizeof} \hyperlink{hs-helper_8h_a0cd84b1a2184c9b84d1b7bf24582f28e}{evlist} / \textcolor{keyword}{sizeof} *\hyperlink{hs-helper_8h_a0cd84b1a2184c9b84d1b7bf24582f28e}{evlist};
227 146     \textcolor{keywordtype}{int} ret = -1;
228 147     \textcolor{keywordflow}{for}(\textcolor{keywordtype}{size\_t} i = 0 ; i < size ; ++i)
229 148     \{
230 149         \textcolor{keywordflow}{if}(!strncmp(value, \hyperlink{hs-helper_8h_a0cd84b1a2184c9b84d1b7bf24582f28e}{evlist}[i], buf\_size))
231 150         \{
232 151             ret = i;
233 152             \textcolor{keywordflow}{break};
234 153         \}
235 154     \}
236 155     \textcolor{keywordflow}{return} ret;
237 156 \}
238 \end{DoxyCode}