commit - 1e054e0b82f2d3037365bc212b917e3434dc1733
commit + af70c3dbc927c77167a26c1f4d8ed6bf2b97e3c5
blob - 74c97a0a8dc41abe99c30981d0f840402f040df9
blob + 2dbf53a2173012a88de0c817f07be8c699a50934
--- src/ngircd/channel.c
+++ src/ngircd/channel.c
{
struct list_head *h = Channel_GetListBans(c);
LogDebug("Adding \"%s\" to \"%s\" %s list", mask, Channel_Name(c), "ban");
- return Lists_Add(h, mask, false);
+ return Lists_Add(h, mask, false, NULL);
}
{
struct list_head *h = Channel_GetListInvites(c);
LogDebug("Adding \"%s\" to \"%s\" %s list", mask, Channel_Name(c), "invite");
- return Lists_Add(h, mask, onlyonce);
+ return Lists_Add(h, mask, onlyonce, NULL);
}
blob - ee034f2873869f47f3f1be493372d1d19f2dde58
blob + aeecaaecc7440313ca89f59b55e6fbf46a57e0c3
--- src/ngircd/class.c
+++ src/ngircd/class.c
}
GLOBAL bool
-Class_AddMask(const int Class, const char *Mask, time_t ValidUntil)
+Class_AddMask(const int Class, const char *Mask, time_t ValidUntil,
+ const char *Reason)
{
assert(Class < CLASS_COUNT);
assert(Mask != NULL);
+ assert(Reason != NULL);
- return Lists_Add(&My_Classes[Class], Mask, ValidUntil);
+ return Lists_Add(&My_Classes[Class], Mask, ValidUntil, Reason);
}
GLOBAL void
blob - 5b04eeaf35394f1f66a0b3f9487b01f265f284ba
blob + deb60f47828220339bec85fd772958a255fa9873
--- src/ngircd/class.h
+++ src/ngircd/class.h
GLOBAL void Class_Exit PARAMS((void));
GLOBAL bool Class_AddMask PARAMS((const int Class, const char *Mask,
- const time_t ValidUntil));
+ const time_t ValidUntil, const char *Reason));
GLOBAL void Class_DeleteMask PARAMS((const int Class, const char *Mask));
GLOBAL bool Class_IsMember PARAMS((const int Class, CLIENT *Client));
blob - 1101ea07421ed2f444583aac92f67297f5d7569c
blob + 9a10ac7dab9f50995b3107b0f1b136cae92f9c44
--- src/ngircd/lists.c
+++ src/ngircd/lists.c
struct list_elem {
struct list_elem *next;
char mask[MASK_LEN];
+ char *reason;
time_t valid_until; /** 0: unlimited; 1: once; t(>1): until t */
};
return e->mask;
}
+GLOBAL const char *
+Lists_GetReason(const struct list_elem *e)
+{
+ assert(e != NULL);
+ return e->reason;
+}
+GLOBAL time_t
+Lists_GetValidity(const struct list_elem *e)
+{
+ assert(e != NULL);
+ return e->valid_until;
+}
+
GLOBAL struct list_elem*
Lists_GetFirst(const struct list_head *h)
{
return e->next;
}
-
+/**
+ * Add a new mask to a list.
+ *
+ * @param header List head.
+ * @param Mask The IRC mask to add to the list.
+ * @param ValidUntil 0: unlimited, 1: only once, t>1: until given time_t.
+ * @param Reason Reason string or NULL, if no reason should be saved.
+ * @return true on success, false otherwise.
+ */
bool
-Lists_Add(struct list_head *header, const char *Mask, time_t ValidUntil )
+Lists_Add(struct list_head *header, const char *Mask, time_t ValidUntil,
+ const char *Reason)
{
struct list_elem *e, *newelem;
return false;
}
- strlcpy( newelem->mask, Mask, sizeof( newelem->mask ));
+ strlcpy(newelem->mask, Mask, sizeof(newelem->mask));
+ if (Reason) {
+ newelem->reason = malloc(strlen(Reason) + 1);
+ if (newelem->reason)
+ strlcpy(newelem->reason, Reason, strlen(Reason) + 1);
+ else
+ Log(LOG_EMERG,
+ "Can't allocate memory for new list reason text!");
+ }
+ else
+ newelem->reason = NULL;
newelem->valid_until = ValidUntil;
newelem->next = e;
header->first = newelem;
if (p) p->next = victim->next;
else header->first = victim->next;
+ if (victim->reason)
+ free(victim->reason);
free(victim);
}
LogDebug("Deleted \"%s\" from invite list" , e->mask);
victim = e;
e = e->next;
- free( victim );
+ if (victim->reason)
+ free(victim->reason);
+ free(victim);
}
}
blob - 7422d601d7acdaf0af0dd9353736d7c2756e218b
blob + 5dd1a68b8ae009752519e07f1392a87bfb6d0b0f
--- src/ngircd/lists.h
+++ src/ngircd/lists.h
GLOBAL bool Lists_Check PARAMS((struct list_head *head, CLIENT *client ));
GLOBAL bool Lists_CheckDupeMask PARAMS((const struct list_head *head, const char *mask ));
-GLOBAL bool Lists_Add PARAMS((struct list_head *header, const char *Mask, time_t ValidUntil ));
+GLOBAL bool Lists_Add PARAMS((struct list_head *header, const char *Mask,
+ time_t ValidUntil, const char *Reason));
GLOBAL void Lists_Del PARAMS((struct list_head *head, const char *Mask ));
GLOBAL bool Lists_AlreadyRegistered PARAMS(( const struct list_head *head, const char *Mask));
GLOBAL void Lists_Free PARAMS(( struct list_head *head ));
GLOBAL const char *Lists_MakeMask PARAMS((const char *Pattern));
-GLOBAL const char *Lists_GetMask PARAMS(( const struct list_elem *e ));
+GLOBAL const char *Lists_GetMask PARAMS((const struct list_elem *e));
+GLOBAL const char *Lists_GetReason PARAMS((const struct list_elem *e));
+GLOBAL time_t Lists_GetValidity PARAMS((const struct list_elem *e));
#endif