-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathatnd.c
79 lines (67 loc) · 1.67 KB
/
atnd.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <stdio.h>
#include "atnd.h"
#include "ez_libc.h"
#include "util.h"
#include "vcalendar.h"
ATND*
ATND_constructor (ATND * self, const char *src)
/***********************************************
* Construct a ATND.
*
* src is the string with attendee information.
* returns - pointer to the object, or NULL for failure.
*/
{
ATND *rtn= NULL;
memset(self, 0, sizeof(*self));
const char *str= strstr(src, "CN=");
if(!str)
goto abort;
int rc= sscanf(str + 3, "%63[^:]:MAILTO:%127s", self->name, self->email);
if(2 != rc) {
rc= sscanf(str + 3, "%63[^:]:mailto:%127s", self->name, self->email);
if(2 != rc)
goto abort;
}
/* Note required participants */
if(strstr(src, "REQ-PARTICIPANT"))
self->flags |= ATND_REQD_FLG;
rtn= self;
abort:
if(!rtn)
eprintf("ERROR: cannot extract attendee from \"%s\"", src);
return rtn;
}
void*
ATND_destructor (ATND * self)
/***********************************************
* Destruct a ATND.
*/
{
return self;
}
int
ATND_report(ATND *self, FILE *fh)
/***********************************************
* Print out Attendee information for report
*/
{
const char *reqd= G.BOLD[0] ? G.BOLD : "*";
ez_fprintf(fh, "\t%s%s%s <%s>\n"
, self->flags & ATND_REQD_FLG ? reqd : ""
, self->name
, G.NORMAL
, self->email
);
return 0;
}
int
ATND_ptrvec_cmp(const void *const* pp1, const void *const* pp2)
/***********************************************
* Comparision function for PTRVEC_sort()
*/
{
const ATND *a1= *(const ATND *const*)pp1,
*a2= *(const ATND *const*)pp2;
return strcasecmp(a1->name, a2->name);
}