author | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
commit | b9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (unidiff) | |
tree | 2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /libical/src/libicalss/icalcstp.c | |
download | kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2 |
Initial revision
Diffstat (limited to 'libical/src/libicalss/icalcstp.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libical/src/libicalss/icalcstp.c | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/libical/src/libicalss/icalcstp.c b/libical/src/libicalss/icalcstp.c new file mode 100644 index 0000000..ed62b40 --- a/dev/null +++ b/libical/src/libicalss/icalcstp.c | |||
@@ -0,0 +1,122 @@ | |||
1 | /* -*- Mode: C -*- | ||
2 | ====================================================================== | ||
3 | FILE: icalcstps.c | ||
4 | CREATOR: ebusboom 23 Jun 2000 | ||
5 | |||
6 | $Id$ | ||
7 | $Locker$ | ||
8 | |||
9 | (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org | ||
10 | |||
11 | This program is free software; you can redistribute it and/or modify | ||
12 | it under the terms of either: | ||
13 | |||
14 | The LGPL as published by the Free Software Foundation, version | ||
15 | 2.1, available at: http://www.fsf.org/copyleft/lesser.html | ||
16 | |||
17 | Or: | ||
18 | |||
19 | The Mozilla Public License Version 1.0. You may obtain a copy of | ||
20 | the License at http://www.mozilla.org/MPL/ | ||
21 | |||
22 | |||
23 | ======================================================================*/ | ||
24 | |||
25 | #ifdef HAVE_CONFIG_H | ||
26 | #include "config.h" | ||
27 | #endif | ||
28 | |||
29 | #include "ical.h" | ||
30 | #include "icalcstp.h" | ||
31 | #include "pvl.h" | ||
32 | |||
33 | // Eugen C. <eug@thekompany.com> | ||
34 | #include <defines.h> | ||
35 | #ifndef _QTWIN_ | ||
36 | #include <sys/types.h> /* For send(), others */ | ||
37 | #include <sys/socket.h> /* For send(), others. */ | ||
38 | #include <unistd.h> | ||
39 | #endif | ||
40 | // Eugen C. <eug@thekompany.com> | ||
41 | #include <errno.h> | ||
42 | #include <stdlib.h> /* for malloc */ | ||
43 | #include <string.h> | ||
44 | |||
45 | |||
46 | struct command_map { | ||
47 | enum icalcstp_command command; | ||
48 | char *str; | ||
49 | } command_map[] = | ||
50 | { | ||
51 | {ICAL_ABORT_COMMAND,"ABORT"}, | ||
52 | {ICAL_AUTHENTICATE_COMMAND,"AUTHENTICATE"}, | ||
53 | {ICAL_CAPABILITY_COMMAND,"CAPABILITY"}, | ||
54 | {ICAL_CONTINUE_COMMAND,"CONTINUE"}, | ||
55 | {ICAL_CALIDEXPAND_COMMAND,"CALIDEXPAND"}, | ||
56 | {ICAL_IDENTIFY_COMMAND,"IDENTIFY"}, | ||
57 | {ICAL_DISCONNECT_COMMAND,"DISCONNECT"}, | ||
58 | {ICAL_SENDDATA_COMMAND,"SENDDATA"}, | ||
59 | {ICAL_STARTTLS_COMMAND,"STARTTLS"}, | ||
60 | {ICAL_UPNEXPAND_COMMAND,"UPNEXPAND"}, | ||
61 | {ICAL_UNKNOWN_COMMAND,"UNKNOWN"} | ||
62 | }; | ||
63 | |||
64 | |||
65 | icalcstp_command icalcstp_line_command(char* line) | ||
66 | { | ||
67 | int i; | ||
68 | |||
69 | for(i = 0; command_map[i].command != ICAL_UNKNOWN_COMMAND; i++){ | ||
70 | size_t l = strlen(command_map[i].str); | ||
71 | |||
72 | if(strncmp(line, command_map[i].str, l) == 0){ | ||
73 | return command_map[i].command; | ||
74 | } | ||
75 | |||
76 | } | ||
77 | |||
78 | return ICAL_UNKNOWN_COMMAND; | ||
79 | } | ||
80 | |||
81 | icalrequeststatus icalcstp_line_response_code(char* line) | ||
82 | { | ||
83 | struct icalreqstattype rs; | ||
84 | |||
85 | rs = icalreqstattype_from_string(line); | ||
86 | |||
87 | return rs.code; | ||
88 | } | ||
89 | |||
90 | int icalcstp_line_is_endofdata(char* line) | ||
91 | { | ||
92 | if(line[0] == '.' && line[1] == '\n'){ | ||
93 | return 1; | ||
94 | } | ||
95 | |||
96 | return 0; | ||
97 | |||
98 | } | ||
99 | |||
100 | int icalcstp_line_is_mime(char* line) | ||
101 | { | ||
102 | return 0; | ||
103 | } | ||
104 | |||
105 | |||
106 | const char* icalcstp_command_to_string(icalcstp_command command){ | ||
107 | |||
108 | int i; | ||
109 | |||
110 | for(i = 0; command_map[i].command != ICAL_UNKNOWN_COMMAND; i++){ | ||
111 | size_t l = strlen(command_map[i].str); | ||
112 | |||
113 | if(command_map[i].command == command){ | ||
114 | return command_map[i].str; | ||
115 | } | ||
116 | |||
117 | } | ||
118 | |||
119 | return command_map[i].str; | ||
120 | |||
121 | } | ||
122 | |||