*/
#include "stdinc.h"
-#include "tools.h"
-#include "balloc.h"
#include "s_user.h"
-#include "irc_string.h"
+#include "snomask.h"
+#include "match.h"
+#include "substitution.h"
+#include "s_assert.h"
/*
* Simple mappings for $foo -> 'bar'.
/*
* substitution_append_var
*
- * Inputs - A variable list (dlink_list), name -> value for mapping to make
+ * Inputs - A variable list (rb_dlink_list), name -> value for mapping to make
* Output - none
* Side Effects - Adds a name->value mapping to a list.
*/
-void substitution_append_var(dlink_list *varlist, const char *name, const char *value)
+void substitution_append_var(rb_dlink_list *varlist, const char *name, const char *value)
{
- struct substitution_variable *tmp = MyMalloc(sizeof(struct substitution_variable));
+ struct substitution_variable *tmp = rb_malloc(sizeof(struct substitution_variable));
- DupString(tmp->name, name);
- DupString(tmp->value, value);
+ tmp->name = rb_strdup(name);
+ tmp->value = rb_strdup(value);
- dlinkAddAlloc(tmp, varlist);
+ rb_dlinkAddAlloc(tmp, varlist);
}
/*
* substitution_free
*
- * Inputs - A dlink_list of markup variables to free.
+ * Inputs - A rb_dlink_list of markup variables to free.
* Outputs - none
* Side Effects - Empties a list of markup variables.
*/
-void substitution_free(dlink_list *varlist)
+void substitution_free(rb_dlink_list *varlist)
{
- dlink_node *nptr, *nptr2;
+ rb_dlink_node *nptr, *nptr2;
- DLINK_FOREACH_SAFE(nptr, nptr2, varlist->head)
+ RB_DLINK_FOREACH_SAFE(nptr, nptr2, varlist->head)
{
struct substitution_variable *tmp = (struct substitution_variable *) nptr->data;
- dlinkDelete(nptr, varlist);
- MyFree(tmp->name);
- MyFree(tmp->value);
- MyFree(tmp);
+ rb_dlinkDelete(nptr, varlist);
+ rb_free(tmp->name);
+ rb_free(tmp->value);
+ rb_free(tmp);
}
}
/*
* substitution_parse
*
- * Inputs - A markup string, dlink-list of markup values
+ * Inputs - A markup string, rb_dlink-list of markup values
* Output - A string which has been markup-replaced.
* Side Effects - Strings larger than BUFSIZE are terminated.
*/
-char *substitution_parse(const char *fmt, dlink_list *varlist)
+char *substitution_parse(const char *fmt, rb_dlink_list *varlist)
{
static char buf[BUFSIZE];
const char *ptr;
static char varname[BUFSIZE];
char *vptr = varname;
const char *pptr;
- dlink_node *nptr;
+ rb_dlink_node *nptr;
*vptr = '\0';
/* advance ptr by length of variable */
ptr += (pptr - ptr);
- DLINK_FOREACH(nptr, varlist->head)
+ RB_DLINK_FOREACH(nptr, varlist->head)
{
struct substitution_variable *val = (struct substitution_variable *) nptr->data;
if (!strcasecmp(varname, val->name))
{
- strlcpy(bptr, val->value, BUFSIZE - (bptr - buf));
+ rb_strlcpy(bptr, val->value, BUFSIZE - (bptr - buf));
bptr += strlen(val->value);
break;
}