#ifndef RXPD_H
#define RXPD_H
+#define _GNU_SOURCE
+
#include "llist.h"
#include "psplay.h"
struct rxpd_rule*
rxpd_rule_copy (const struct rxpd_rule* src);
+struct rxpd_rule*
+rxpd_rule_activate (struct rxpd_rule* self);
+
struct rxpd_rule*
rxpd_rule_comment (struct rxpd_rule* self, const char* comment);
self->string = rxpd_strdup (namestart+1);
else
{
- regfree (&self->rx);
char ebuf[256];
size_t len = regerror (err, NULL, ebuf, 256);
self->string = rxpd_malloc (len + strlen(namestart+1) + 14);
return self;
}
+struct rxpd_rule*
+rxpd_rule_activate (struct rxpd_rule* self)
+{
+ if (self)
+ {
+ char* buf;
+ if (self->string[0] == '#' && (buf = strstr (self->string, ": ")+2) && *buf)
+ {
+ if (*buf != '#')
+ {
+ char* namestart = strchr (buf, ':');
+ char* rxstart = namestart? strchr (namestart+1, ':') : NULL;
+
+ if (!rxstart)
+ return NULL;
+
+ // TODO regflags from base
+ if (regcomp (&self->rx, rxstart+1, REG_EXTENDED|REG_ICASE|REG_NOSUB))
+ return NULL;
+
+ free (self->string);
+ self->string = rxpd_strdup (namestart+1);
+
+ if (namestart != buf)
+ {
+ /* atime given */
+ self->atime = atoi (buf);
+ if (!self->atime)
+ /* atime was zero or not set */
+ self->atime = time (NULL)-1;
+ }
+ }
+ else
+ self->string = rxpd_strdup (buf);
+ }
+ else
+ return NULL;
+ }
+ return self;
+}
+
struct rxpd_rule*
rxpd_rule_comment (struct rxpd_rule* self, const char* comment)
{