ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/src/template.C
Revision: 1.7
Committed: Sun Sep 16 18:54:45 2007 UTC (16 years, 8 months ago) by pippijn
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.6: +7 -2 lines
Log Message:
#defines to enum

File Contents

# User Rev Content
1 pippijn 1.1 /*
2     * template.C: Functions to work with predefined flags collections
3 pippijn 1.7 *
4     * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team
5     * Rights to this code are as documented in COPYING.
6     *
7     *
8     * Portions of this file were derived from sources bearing the following license:
9 pippijn 1.2 * Rights to this code are documented in doc/pod/license.pod.
10 pippijn 1.4 * Copyright © 2005-2007 Atheme Project (http://www.atheme.org)
11 pippijn 1.1 */
12    
13 pippijn 1.7 static char const rcsid[] = "$Id: template.C,v 1.6 2007-09-05 11:23:15 pippijn Exp $";
14 pippijn 1.1
15     #include "atheme.h"
16     #include <account/mychan.h>
17     #include "template.h"
18    
19     /* name1=value1 name2=value2 name3=value3... */
20     char *
21 pippijn 1.4 getitem (char *str, char const * const name)
22 pippijn 1.1 {
23     char *p;
24     static char result[300];
25     int l;
26    
27     l = strlen (name);
28     for (;;)
29     {
30     p = strchr (str, '=');
31     if (p == NULL)
32     return NULL;
33     if (p - str == l && !strncasecmp (str, name, p - str))
34     {
35     strlcpy (result, p, sizeof result);
36     p = strchr (result, ' ');
37     if (p != NULL)
38     *p = '\0';
39     return result;
40     }
41     str = strchr (p, ' ');
42     if (str == NULL)
43     return NULL;
44     while (*str == ' ')
45     str++;
46     }
47     }
48    
49     unsigned int
50 pippijn 1.4 get_template_flags (mychan_t *mc, char const * const name)
51 pippijn 1.1 {
52 pippijn 1.6 metadata *md;
53 pippijn 1.1 char *d;
54    
55     if (mc != NULL)
56     {
57     md = mc->find_metadata ("private:templates");
58     if (md != NULL)
59     {
60     d = getitem (md->value, name);
61     if (d != NULL)
62     return flags_to_bitmask (d, chanacs_flags, 0);
63     }
64     }
65     if (*name != '\0' && !strcasecmp (name + 1, "op"))
66     {
67     switch (*name)
68     {
69     case 's':
70     case 'S':
71     return chansvs.ca_sop;
72     case 'a':
73     case 'A':
74     return chansvs.ca_aop;
75     case 'h':
76     case 'H':
77     return chansvs.ca_hop;
78     case 'v':
79     case 'V':
80     return chansvs.ca_vop;
81     }
82     }
83     return 0;
84     }
85    
86     /* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs
87     * vim:ts=8
88     * vim:sw=8
89     * vim:noexpandtab
90     */