ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/src/template.C
Revision: 1.4
Committed: Tue Aug 28 17:08:12 2007 UTC (19 years ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.3: +4 -4 lines
Log Message:
- changed name
- updated the example config to the new system
- added more documentation
- enhanced documentation generators
- added a link to the pdf to the website
- added an RSS feed generator
- transitioned hooks to c++ callbacks
- did various merges with upstream along the way
- added const where appropriate
- removed the old block allocator
- fixed most memory leaks
- transitioned some dictionaries to std::map
- transitioned some lists to std::vector
- made some free functions members where appropriate
- renamed string to dynstr and added a static string ststr
- use NOW instead of time (NULL) if possible
- completely reworked database backends, crypto handlers and protocol handlers
  to use an object factory
- removed the old module system. ermyth does not do any dynamic loading anymore
- fixed most of the build system
- reworked how protocol commands work

File Contents

# User Rev Content
1 pippijn 1.1 /*
2     * template.C: Functions to work with predefined flags collections
3 pippijn 1.2 * Rights to this code are documented in doc/pod/license.pod.
4 pippijn 1.1 *
5 pippijn 1.4 * Copyright © 2005-2007 Atheme Project (http://www.atheme.org)
6 pippijn 1.1 */
7    
8 pippijn 1.4 static char const rcsid[] = "$Id: template.C,v 1.3 2007-07-21 13:23:22 pippijn Exp $";
9 pippijn 1.1
10     #include "atheme.h"
11     #include <account/mychan.h>
12     #include "template.h"
13    
14     /* name1=value1 name2=value2 name3=value3... */
15     char *
16 pippijn 1.4 getitem (char *str, char const * const name)
17 pippijn 1.1 {
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 pippijn 1.4 get_template_flags (mychan_t *mc, char const * const name)
46 pippijn 1.1 {
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     */