ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/src/template.C
Revision: 1.3
Committed: Sat Jul 21 13:23:22 2007 UTC (16 years, 10 months ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.2: +1 -1 lines
Log Message:
- added rcsid to some files
- more documentation tweaks
- made most protocol commands local to phandler.C
- added ircd metadata (inspircd only for now)
- added inspircd swhois support

File Contents

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