[asterisk-commits] nadi: branch nadi/trunk-cm r43975 - in
/team/nadi/trunk-cm: include/asterisk/...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Fri Sep 29 02:03:42 MST 2006
Author: nadi
Date: Fri Sep 29 04:03:41 2006
New Revision: 43975
URL: http://svn.digium.com/view/asterisk?rev=43975&view=rev
Log:
change the header of cm_get_next_id
Modified:
team/nadi/trunk-cm/include/asterisk/configman.h
team/nadi/trunk-cm/main/configman.c
Modified: team/nadi/trunk-cm/include/asterisk/configman.h
URL: http://svn.digium.com/view/asterisk/team/nadi/trunk-cm/include/asterisk/configman.h?rev=43975&r1=43974&r2=43975&view=diff
==============================================================================
--- team/nadi/trunk-cm/include/asterisk/configman.h (original)
+++ team/nadi/trunk-cm/include/asterisk/configman.h Fri Sep 29 04:03:41 2006
@@ -106,14 +106,14 @@
/*! \brief Get the subsequent id
* \param cm_t which cm_t to use
* \param sec_id section id to use
- * \param ... preceding integer or string id
+ * \param prev pointer to the previous id, if you want to retrieve the first id, give NULL
+ * \param next output pointer to the id after prev
* Gets the subsequent id of a given id.
*
- * Returns a const pointer to the subsequent id or NULL on error, i.e.
- * if the preceding ID was already the last one.
+ * Returns non-zero if next points to the id after prev, or zero if there
+ * is no subsequent id.
*/
-const
-void * cm_get_next_id (cm_t *cm, int sec_id, ...);
+int cm_get_next_id (cm_t *cm, int sec_id, void *prev, void *next);
int ast_configman_init (void);
Modified: team/nadi/trunk-cm/main/configman.c
URL: http://svn.digium.com/view/asterisk/team/nadi/trunk-cm/main/configman.c?rev=43975&r1=43974&r2=43975&view=diff
==============================================================================
--- team/nadi/trunk-cm/main/configman.c (original)
+++ team/nadi/trunk-cm/main/configman.c Fri Sep 29 04:03:41 2006
@@ -555,13 +555,10 @@
}
}
-const void * cm_get_next_id (cm_t *cm, int sec_id, ...)
-{
- va_list ap;
- int id_int,
- i;
- char * id_string;
- void * retval = NULL;
+int cm_get_next_id (cm_t *cm, int sec_id, void *prev, void *next)
+{
+ int i,
+ retval = 0;
cm_hash_key_t * key_list;
cm_hash_t * hash;
@@ -583,41 +580,33 @@
case KTYPE_NONE:
goto err2;
case KTYPE_INTEGER:
- va_start(ap, sec_id);
- id_int = va_arg(ap, int);
- va_end(ap);
- if (id_int == -1) {
- retval = &key_list[0].i;
+ if (!prev || *(int *)prev < 0) {
+ *(int *)next = key_list[0].i;
} else {
- for (i = 0; i < hash->length && key_list[i].i != id_int; ++i);
+ for (i = 0; i < hash->length && key_list[i].i != *(int *)prev; ++i);
if (i >= (hash->length - 1))
goto err2;
- retval = &key_list[i + 1].i;
- }
+ *(int *)next = key_list[i + 1].i;
+ }
+ retval = 1;
break;
case KTYPE_STRING:
- va_start(ap, sec_id);
- id_string = va_arg(ap, char *);
- va_end(ap);
- if (!id_string) {
- retval = key_list[0].c;
+ if (!prev || !*(char **)prev) {
+ *(char **)next = key_list[0].c;
} else {
- for (i = 0; i < hash->length && strcasecmp(key_list[i].c, id_string); ++i);
+ for (i = 0; i < hash->length && strcasecmp(key_list[i].c, *(char **)prev); ++i);
if (i >= (hash->length - 1))
goto err2;
- retval = key_list[i + 1].c;
- }
+ *(char **)next = key_list[i + 1].c;
+ }
+ retval = 1;
break;
}
-
- UNLOCK(cm);
-
- return retval;
err2:
UNLOCK(cm);
err1:
- return NULL;
+ return retval;
}
/* cli commands for modules */
More information about the asterisk-commits
mailing list