Default items defined.

FossilOrigin-Name: 1c8c514f88afc8b87be00b49e888aad6974c98b424d8f5f05f589ce967dc1cce
This commit is contained in:
7u83@mail.ru 2015-05-04 05:37:19 +00:00
parent 533fb98dbb
commit ff7fb043ed
2 changed files with 8 additions and 3 deletions

View File

@ -22,10 +22,11 @@
const char CW_ITEM_NONE[] = ""; const char CW_ITEM_NONE[] = "";
const char CW_ITEM_ANY[] = "*";
struct cw_itemdef *cw_item_get_by_name(const char *id, struct cw_itemdef *table) struct cw_itemdef *cw_item_get_by_name(const char *id, struct cw_itemdef *table)
{ {
int i;
while (table->id != CW_ITEM_NONE) { while (table->id != CW_ITEM_NONE) {
if (!strcmp(table->id, id)) if (!strcmp(table->id, id))
return table; return table;
@ -42,6 +43,7 @@ static int cmp(const void *x1, const void *x2)
cw_itemdef_t *i1, *i2; cw_itemdef_t *i1, *i2;
i1 = (cw_itemdef_t *) x1; i1 = (cw_itemdef_t *) x1;
i2 = (cw_itemdef_t *) x2; i2 = (cw_itemdef_t *) x2;
int rc = strcmp(i1->id, i2->id); int rc = strcmp(i1->id, i2->id);
if (rc != 0) if (rc != 0)
return rc; return rc;
@ -53,6 +55,7 @@ const cw_itemdef_t * cw_itemdef_get(cw_itemdefheap_t t, const char *id, const ch
cw_itemdef_t idef; cw_itemdef_t idef;
idef.id = id; idef.id = id;
idef.sub_id = !sub_id ? CW_ITEM_NONE : sub_id; idef.sub_id = !sub_id ? CW_ITEM_NONE : sub_id;
return mavl_get(t, &idef); return mavl_get(t, &idef);
} }

View File

@ -23,6 +23,8 @@
#include "mbag.h" #include "mbag.h"
extern const char CW_ITEM_NONE[]; extern const char CW_ITEM_NONE[];
extern const char CW_ITEM_ANY[];
/* Definitions for CAPWAP Items */ /* Definitions for CAPWAP Items */
@ -49,6 +51,6 @@ extern const cw_itemdef_t * cw_itemdef_get(cw_itemdefheap_t t, const char *id,
struct cw_itemdef *cw_item_get_by_name(const char *name, struct cw_itemdef *table); struct cw_itemdef *cw_item_get_by_name(const char *name, struct cw_itemdef *table);
typedef const char *cw_item_t; typedef const char *cw_item_id_t;
//
#endif #endif