[cvslog] (2002-10-11 07:27:42 UTC) Module eggdrop1.7: Change committed

cvslog cvs at tsss.org
Fri Oct 11 02:28:00 CST 2002


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.7
Commit time: 2002-10-11 07:27:42 UTC
Commited by: stdarg <stdarg at techmonkeys.org>

Added files:
     lib/eggdrop/flags.c

Log message:

* Forgot a file.

---------------------- diff included ----------------------
Index: eggdrop1.7/lib/eggdrop/flags.c
diff -u /dev/null eggdrop1.7/lib/eggdrop/flags.c:1.1
--- /dev/null	Fri Oct 11 02:27:42 2002
+++ eggdrop1.7/lib/eggdrop/flags.c	Fri Oct 11 02:27:32 2002
@@ -0,0 +1,53 @@
+#include "flags.h"
+
+/* str must be at least 26+26+1 = 53 bytes. */
+int flag_to_str(flags_t *flags, char *str)
+{
+	int i, j;
+
+	j = 0;
+	for (i = 0; i < 26; i++) {
+		if (flags->builtin & (1 << i)) str[j++] = 'a' + i;
+	}
+	for (i = 0; i < 26; i++) {
+		if (flags->udef & (1 << i)) str[j++] = 'A' + i;
+	}
+	str[j] = 0;
+	return(0);
+}
+
+static inline int add_flag(int *intptr, int dir, int flag)
+{
+	if (dir < 0) *intptr &= ~(1 << flag);
+	else *intptr |= 1 << flag;
+}
+
+int flag_merge_str(flags_t *flags, char *str)
+{
+	int dir;
+
+	/* If it doesn't start with +/-, then it's absolute. */
+	if (*str != '+' && *str != '-') {
+		flags->builtin = flags->udef = 0;
+		dir = 1;
+	}
+	while (*str) {
+		if (*str >= 'a' && *str <= 'z') {
+			add_flag(&flags->builtin, dir, *str - 'a');
+		}
+		else if (*str >= 'A' && *str <= 'A') {
+			add_flag(&flags->udef, dir, *str - 'A');
+		}
+		else if (*str == '-') dir = -1;
+		else if (*str == '+') dir = 1;
+		str++;
+	}
+}
+
+int flag_from_str(flags_t *flags, char *str)
+{
+	/* Always reset flags first. */
+	flags->builtin = flags->udef = 0;
+	return flag_merge_str(flags, str);
+}
+
----------------------- End of diff -----------------------



More information about the Changes mailing list