Ken Yourek / ucmd

Dependents:   nucleo_ucmd_helloworld

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ucArgTok.c Source File

ucArgTok.c

00001 #include "ucmd_internal.h"
00002 
00003 ucArgTok *ucArgTok_get_next(ucArgTok* p) {
00004     ucTok *tok;
00005     if (NULL == p) return NULL;
00006     tok = ucTok_get_next((ucTok*)p);
00007     if (NULL == tok) return NULL;
00008     if (ucTok_is_switch(tok)) return NULL;
00009     return (ucArgTok*)tok;
00010 }
00011 
00012 int ucArgTok_count(ucArgTok* p) {
00013     int count = 0;
00014     while (NULL != p) {
00015         count++;
00016         p = ucArgTok_get_next(p);
00017     }
00018     return count;
00019 }
00020 
00021 ucArgTok *ucArgTok_find(ucArgTok *p, const char *arg_value) {
00022     while (NULL != p) {
00023         if (ucTok_equals((ucTok*)p, arg_value)) {
00024             return p;
00025         }
00026         p = ucArgTok_get_next(p);
00027     }
00028     return NULL;
00029 }
00030 
00031 ucBool ucArgTok_contains(ucArgTok* p, const char *arg_value) {
00032     return NULL == ucArgTok_find(p, arg_value) ? ucBool_FALSE : ucBool_TRUE;
00033 }
00034