00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 #include "wsint.h"
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 #define NF(f) (sizeof(f) / sizeof(f[0]))
00086
00087
00088 struct WsStdLibFuncRegRec
00089 {
00090 char *name;
00091
00092
00093 int num_args;
00094
00095
00096 WsUInt8 function_id;
00097 };
00098
00099 typedef struct WsStdLibFuncRegRec WsStdLibFuncReg;
00100
00101
00102 struct WsStdLibRegRec
00103 {
00104 char *name;
00105
00106 WsUInt16 library_id;
00107
00108
00109 WsUInt8 num_functions;
00110
00111
00112 WsStdLibFuncReg *functions;
00113 };
00114
00115 typedef struct WsStdLibRegRec WsStdLibReg;
00116
00117
00118
00119 static WsStdLibFuncReg lib_lang_functions[] =
00120 {
00121 {"abs", 1, 0},
00122 {"min", 2, 1},
00123 {"max", 2, 2},
00124 {"parseInt", 1, 3},
00125 {"parseFloat", 1, 4},
00126 {"isInt", 1, 5},
00127 {"isFloat", 1, 6},
00128 {"maxInt", 0, 7},
00129 {"minInt", 0, 8},
00130 {"float", 0, 9},
00131 {"exit", 1, 10},
00132 {"abort", 1, 11},
00133 {"random", 1, 12},
00134 {"seed", 1, 13},
00135 {"characterSet", 0, 14},
00136 };
00137
00138 static WsStdLibFuncReg lib_float_functions[] =
00139 {
00140 {"int", 1, 0},
00141 {"floor", 1, 1},
00142 {"ceil", 1, 2},
00143 {"pow", 2, 3},
00144 {"round", 1, 4},
00145 {"sqrt", 1, 5},
00146 {"maxFloat", 0, 6},
00147 {"minFloat", 0, 7},
00148 };
00149
00150 static WsStdLibFuncReg lib_string_functions[] =
00151 {
00152 {"length", 1, 0},
00153 {"isEmpty", 1, 1},
00154 {"charAt", 2, 2},
00155 {"subString", 3, 3},
00156 {"find", 2, 4},
00157 {"replace", 3, 5},
00158 {"elements", 2, 6},
00159 {"elementAt", 3, 7},
00160 {"removeAt", 3, 8},
00161 {"replaceAt", 4, 9},
00162 {"insertAt", 4, 10},
00163 {"squeeze", 1, 11},
00164 {"trim", 1, 12},
00165 {"compare", 2, 13},
00166 {"toString", 1, 14},
00167 {"format", 2, 15},
00168 };
00169
00170 static WsStdLibFuncReg lib_url_functions[] =
00171 {
00172 {"isValid", 1, 0},
00173 {"getScheme", 1, 1},
00174 {"getHost", 1, 2},
00175 {"getPort", 1, 3},
00176 {"getPath", 1, 4},
00177 {"getParameters", 1, 5},
00178 {"getQuery", 1, 6},
00179 {"getFragment", 1, 7},
00180 {"getBase", 0, 8},
00181 {"getReferer", 0, 9},
00182 {"resolve", 2, 10},
00183 {"escapeString", 1, 11},
00184 {"unescapeString", 1, 12},
00185 {"loadString", 2, 13},
00186 };
00187
00188 static WsStdLibFuncReg lib_wmlbrowser_functions[] =
00189 {
00190 {"getVar", 1, 0},
00191 {"setVar", 2, 1},
00192 {"go", 1, 2},
00193 {"prev", 0, 3},
00194 {"newContext", 0, 4},
00195 {"getCurrentCard", 0, 5},
00196 {"refresh", 0, 6},
00197 };
00198
00199 static WsStdLibFuncReg lib_dialogs_functions[] =
00200 {
00201 {"prompt", 2, 0},
00202 {"confirm", 3, 1},
00203 {"alert", 1, 2},
00204 };
00205
00206 static WsStdLibFuncReg lib_crypto_functions[] =
00207 {
00208 {"signText", 4, 16},
00209 };
00210
00211 static WsStdLibFuncReg lib_efi_functions[] =
00212 {
00213 {"set", 3, 0},
00214 {"get", 2, 1},
00215 {"getFirstName", 1, 2},
00216 {"getNextName", 2, 3},
00217 {"getAllAttributes", 1, 4},
00218 {"getAttribute", 2, 5},
00219 {"getClassProperty", 2, 6},
00220 {"getUnits", 1, 7},
00221 {"query", 1, 8},
00222 {"invoke", 3, 9},
00223 {"call", 3, 10},
00224 {"status", 1, 11},
00225 {"control", 3, 12},
00226 };
00227
00228 static WsStdLibFuncReg lib_wtapublic_functions[] =
00229 {
00230 {"makeCall", 1, 0},
00231 {"sendDTMF", 1, 1},
00232 {"addPBEntry", 2, 2},
00233 };
00234
00235 static WsStdLibFuncReg lib_wtavoicecall_functions[] =
00236 {
00237 {"setup", 2, 0},
00238 {"accept", 2, 1},
00239 {"release", 1, 2},
00240 {"sendDTMF", 2, 3},
00241 {"callStatus", 2, 4},
00242 {"list", 1, 5},
00243 };
00244
00245 static WsStdLibFuncReg lib_wtanettext_functions[] =
00246 {
00247 {"send", 2, 0},
00248 {"list", 2, 1},
00249 {"remove", 1, 2},
00250 {"getFieldValue", 2, 3},
00251 {"markAsRead", 1, 4},
00252 };
00253
00254 static WsStdLibFuncReg lib_wtaphonebook_functions[] =
00255 {
00256 {"write", 3, 0},
00257 {"search", 2, 1},
00258 {"remove", 1, 2},
00259 {"getFieldValue", 2, 3},
00260 {"change", 3, 4},
00261 };
00262
00263 static WsStdLibFuncReg lib_wtamisc_functions[] =
00264 {
00265 {"setIndicator", 2, 0},
00266 {"endContext", 0, 1},
00267 {"getProtection", 0, 2},
00268 {"setProtection", 1, 3},
00269 };
00270
00271 static WsStdLibFuncReg lib_wtaansi136_functions[] =
00272 {
00273 {"sendFlash", 2, 0},
00274 {"sendAlert", 2, 1},
00275 };
00276
00277 static WsStdLibFuncReg lib_wtagsm_functions[] =
00278 {
00279 {"hold", 1, 0},
00280 {"retrieve", 1, 1},
00281 {"transfer", 2, 2},
00282 {"deflect", 2, 3},
00283 {"multiparty", 0, 4},
00284 {"seperate", 1, 5},
00285 {"sendUSSD", 4, 6},
00286 {"netinfo", 1, 7},
00287 {"callWaiting", 1, 8},
00288 {"sendBusy", 1, 9},
00289 };
00290
00291 static WsStdLibFuncReg lib_wtacalllog_functions[] =
00292 {
00293 {"dialled", 1, 0},
00294 {"missed", 1, 1},
00295 {"received", 1, 2},
00296 {"getFieldValue", 2, 3},
00297 };
00298
00299 static WsStdLibFuncReg lib_wtapdc_functions[] =
00300 {
00301 {"hold", 1, 0},
00302 {"retrieve", 1, 1},
00303 {"transfer", 2, 2},
00304 {"deflect", 2, 3},
00305 {"multiparty", 0, 4},
00306 {"seperate", 1, 5},
00307 };
00308
00309 static WsStdLibFuncReg lib_wtais95_functions[] =
00310 {
00311 {"sendText", 6, 0},
00312 {"cancelText", 1, 1},
00313 {"sendAck", 1, 2},
00314 };
00315
00316 static WsStdLibReg libraries[] =
00317 {
00318 {"Lang", 0, NF(lib_lang_functions), lib_lang_functions},
00319 {"Float", 1, NF(lib_float_functions), lib_float_functions},
00320 {"String", 2, NF(lib_string_functions), lib_string_functions},
00321 {"URL", 3, NF(lib_url_functions), lib_url_functions},
00322 {"WMLBrowser", 4, NF(lib_wmlbrowser_functions), lib_wmlbrowser_functions},
00323 {"Dialogs", 5, NF(lib_dialogs_functions), lib_dialogs_functions},
00324 {"Crypto", 6, NF(lib_crypto_functions), lib_crypto_functions},
00325 {"EFI", 7, NF(lib_efi_functions), lib_efi_functions},
00326 {"WTAPublic", 512, NF(lib_wtapublic_functions), lib_wtapublic_functions},
00327 {"WTAVoiceCall", 513, NF(lib_wtavoicecall_functions), lib_wtavoicecall_functions},
00328 {"WTANetText", 514, NF(lib_wtanettext_functions), lib_wtanettext_functions},
00329 {"WTAPhoneBook", 515, NF(lib_wtaphonebook_functions), lib_wtaphonebook_functions},
00330 {"WTAMisc", 516, NF(lib_wtamisc_functions), lib_wtamisc_functions},
00331 {"WTAANSI163", 517, NF(lib_wtaansi136_functions), lib_wtaansi136_functions},
00332 {"WTAGSM", 518, NF(lib_wtagsm_functions), lib_wtagsm_functions},
00333 {"WTACallLog", 519, NF(lib_wtacalllog_functions), lib_wtacalllog_functions},
00334 {"WTAPDC", 520, NF(lib_wtapdc_functions), lib_wtapdc_functions},
00335 {"WTAIS95", 521, NF(lib_wtais95_functions), lib_wtais95_functions},
00336 {NULL, 0, 0, NULL}
00337 };
00338
00339
00340
00341 WsBool ws_stdlib_function(const char *library, const char *function,
00342 WsUInt16 *lindex_return, WsUInt8 *findex_return,
00343 WsUInt8 *num_args_return, WsBool *lindex_found_return,
00344 WsBool *findex_found_return)
00345 {
00346 WsUInt16 l;
00347
00348 *lindex_found_return = WS_FALSE;
00349 *findex_found_return = WS_FALSE;
00350
00351 for (l = 0; libraries[l].name != NULL; l++) {
00352 if (strcmp(libraries[l].name, library) == 0) {
00353 WsUInt8 f;
00354
00355 *lindex_return = libraries[l].library_id;
00356 *lindex_found_return = WS_TRUE;
00357
00358 for (f = 0; f < libraries[l].num_functions; f++) {
00359 if (strcmp(libraries[l].functions[f].name, function) == 0) {
00360 *findex_return = libraries[l].functions[f].function_id;
00361 *findex_found_return = WS_TRUE;
00362
00363 *num_args_return = libraries[l].functions[f].num_args;
00364
00365 return WS_TRUE;
00366 }
00367 }
00368 }
00369 }
00370
00371 return WS_FALSE;
00372 }
00373
00374
00375 WsBool ws_stdlib_function_name(WsUInt16 lindex, WsUInt8 findex,
00376 const char **library_return,
00377 const char **function_return)
00378 {
00379 WsUInt16 l;
00380 WsUInt8 f;
00381
00382 *library_return = NULL;
00383 *function_return = NULL;
00384
00385 for (l = 0; libraries[l].name != NULL; l++)
00386 if (libraries[l].library_id == lindex)
00387 for (f = 0; f < libraries[l].num_functions; f++) {
00388 if (libraries[l].functions[f].function_id == findex) {
00389 *library_return = libraries[l].name;
00390 *function_return = libraries[l].functions[f].name;
00391 return WS_TRUE;
00392 }
00393 }
00394
00395 return WS_FALSE;
00396 }
See file LICENSE for details about the license agreement for using,
modifying, copying or deriving work from this software.