{
procstat_t *new;
procstat_t *ptr;
+ int status;
- if ((new = (procstat_t *) malloc (sizeof (procstat_t))) == NULL)
+ new = (procstat_t *) malloc (sizeof (procstat_t));
+ if (new == NULL)
+ {
+ ERROR ("processes plugin: ps_list_register: malloc failed.");
return;
+ }
memset (new, 0, sizeof (procstat_t));
sstrncpy (new->name, name, sizeof (new->name));
+#if HAVE_REGEX_H
if (regexp != NULL)
{
-#if HAVE_REGEX_H
DEBUG ("ProcessMatch: adding \"%s\" as criteria to process %s.", regexp, name);
- if ((new->re = (regex_t *) malloc (sizeof (regex_t))) != NULL)
+ new->re = (regex_t *) malloc (sizeof (regex_t));
+ if (new->re == NULL)
{
- if (regcomp(new->re, regexp, REG_EXTENDED|REG_NOSUB) != 0)
- {
- DEBUG ("ProcessMatch: compiling the regular expression \"%s\" failed.", regexp);
- sfree(new->re);
- }
- } else {
- DEBUG("ProcessMatch: malloc failed when allocating memory for regexp!");
+ ERROR ("processes plugin: ps_list_register: malloc failed.");
+ sfree (new);
+ return;
+ }
+
+ status = regcomp (new->re, regexp, REG_EXTENDED | REG_NOSUB);
+ if (status != 0)
+ {
+ DEBUG ("ProcessMatch: compiling the regular expression \"%s\" failed.", regexp);
+ sfree(new->re);
+ return;
}
+ }
#else
- DEBUG("ProcessMatch: regexp '%s' met in config file, but regexps are not supported!", regexp);
-#endif
+ if (regexp != NULL)
+ {
+ ERROR ("processes plugin: ps_list_register: "
+ "Regular expression \"%s\" found in config "
+ "file, but support for regular expressions "
+ "has been dispabled at compile time.",
+ regexp);
+ sfree (new);
+ return;
}
+#endif
for (ptr = list_head_g; ptr != NULL; ptr = ptr->next)
{
if (strcmp (ptr->name, name) == 0)
+ {
+ WARNING ("processes plugin: You have configured more "
+ "than one `Process' or "
+ "`ProcessMatch' with the same name. "
+ "All but the first setting will be "
+ "ignored.");
+ sfree (new->re);
+ sfree (new);
return;
+ }
+
if (ptr->next == NULL)
break;
}
list_head_g = new;
else
ptr->next = new;
-}
+} /* void ps_list_register */
/* try to match name against entry, returns 1 if success */
static int ps_list_match (const char *name, const char *cmdline, procstat_t *ps)