|
|
#include <sys/types.h>
#include <time.h>
#include "main.h"
#include "mit-copyright.h"
#include <netdb.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include "error.h"
#include "variables.h"
#include "notice.h"
Go to the source code of this file.
Functions | |
int | count_nulls (char *data, int length) |
string | get_next_field (char **data_p, int *length_p) |
string | get_field (char *data, int length, int num) |
string | convert_nulls_to_newlines (char *data, int length) |
char * | decode_notice (struct jabpacket_struct *notice) |
|
Definition at line 132 of file notice.c. 00135 { 00136 char *result, *ptr; 00137 char c; 00138 00139 result = (char *) malloc(length + 1); 00140 result[length] = '\0'; 00141 00142 for (ptr = result; length; data++, ptr++, length--) 00143 *ptr = (c = *data) ? c : '\n'; 00144 00145 return (result); 00146 }
|
|
Definition at line 35 of file notice.c. 00038 { 00039 int count = 0; 00040 00041 for (; length; data++, length--) 00042 if (!*data) 00043 count++; 00044 00045 return (count); 00046 }
|
|
Definition at line 155 of file notice.c. References dprintf(), dXML, find_nickname_from_jid(), jid_struct::full, jab_subtype_to_ascii(), jab_type_to_ascii(), jid, ns, NS_EVENT, NULL, unicode_to_str(), var_set_variable(), var_set_variable_then_free_value(), xode, xode_get_attrib(), xode_get_data(), xode_get_tag(), and xode_to_prettystr(). 00157 { 00158 char *temp, *c, *d, *from, *ns, *jid; 00159 xode x, y; 00160 char timestr[26]; 00161 time_t curtime; 00162 00163 var_set_variable_then_free_value("type", 00164 jab_type_to_ascii(notice->type)); 00165 var_set_variable_then_free_value("subtype", 00166 jab_subtype_to_ascii(notice->subtype)); 00167 00168 dprintf(dXML, "Decoding Notice [%d,%d]:\n%s\n", 00169 notice->type, 00170 notice->subtype, 00171 xode_to_prettystr(notice->x)); 00172 00173 temp = xode_get_attrib(notice->x, "type"); 00174 if (temp) { 00175 var_set_variable("msgtype", temp); 00176 } 00177 else { 00178 var_set_variable("msgtype", ""); 00179 } 00180 00181 var_set_variable("from", ""); 00182 var_set_variable("sender", ""); 00183 var_set_variable("server", ""); 00184 var_set_variable("resource", ""); 00185 var_set_variable("nickname", ""); 00186 jid = notice->from->full; 00187 if (jid) { 00188 from = strdup(jid); 00189 } 00190 else { 00191 from = strdup(xode_get_attrib(notice->x, "from")); 00192 } 00193 if (from) { 00194 var_set_variable("from", from); 00195 temp = (char *) find_nickname_from_jid(from); 00196 if (temp) { 00197 var_set_variable_then_free_value("nickname", temp); 00198 } 00199 00200 c = from; 00201 d = strchr(c, '@'); 00202 if (d) { 00203 *d = '\0'; 00204 temp = strdup(c); 00205 var_set_variable_then_free_value("sender", temp); 00206 d++; 00207 c = d; 00208 d = strchr(c, '/'); 00209 if (d) { 00210 *d = '\0'; 00211 temp = strdup(c); 00212 var_set_variable_then_free_value("server", 00213 temp); 00214 d++; 00215 c = d; 00216 temp = strdup(c); 00217 var_set_variable_then_free_value("resource", 00218 temp); 00219 } 00220 else { 00221 var_set_variable("server", c); 00222 var_set_variable("resource", ""); 00223 } 00224 } 00225 else { 00226 var_set_variable("sender", from); 00227 } 00228 } 00229 else { 00230 var_set_variable("from", "[unknown]"); 00231 } 00232 free(from); 00233 00234 x = xode_get_tag(notice->x, "subject"); 00235 if (x) { 00236 temp = xode_get_data(x); 00237 var_set_variable("subject", temp); 00238 } 00239 else { 00240 var_set_variable("subject", ""); 00241 } 00242 00243 var_set_variable("event", ""); 00244 x = xode_get_tag(notice->x, "x"); 00245 if (x) { 00246 ns = xode_get_attrib(x, "xmlns"); 00247 if (ns && !strcmp(ns, NS_EVENT)) { 00248 y = xode_get_tag(x, "composing"); 00249 if (y) { 00250 var_set_variable("event", "composing"); 00251 } 00252 } 00253 } 00254 00255 x = xode_get_tag(notice->x, "show"); 00256 if (x) { 00257 char *convtemp; 00258 temp = xode_get_data(x); 00259 if (!unicode_to_str(temp, &convtemp)) { 00260 convtemp = strdup(""); 00261 } 00262 var_set_variable_then_free_value("show", convtemp); 00263 } 00264 else { 00265 var_set_variable("show", ""); 00266 } 00267 00268 x = xode_get_tag(notice->x, "status"); 00269 if (x) { 00270 char *convtemp; 00271 temp = xode_get_data(x); 00272 if (!unicode_to_str(temp, &convtemp)) { 00273 convtemp = strdup(""); 00274 } 00275 if (temp) { 00276 var_set_variable_then_free_value("status", convtemp); 00277 } 00278 else { 00279 var_set_variable("status", ""); 00280 } 00281 } 00282 else { 00283 var_set_variable("status", ""); 00284 } 00285 00286 x = xode_get_tag(notice->x, "error"); 00287 if (x) { 00288 temp = xode_get_data(x); 00289 var_set_variable("error", temp); 00290 } 00291 else { 00292 var_set_variable("error", ""); 00293 } 00294 00295 curtime = time(NULL); 00296 strftime(timestr, 25, "%T", localtime(&curtime)); 00297 var_set_variable("time", timestr); 00298 00299 strftime(timestr, 25, "%r", localtime(&curtime)); 00300 var_set_variable("time12", timestr); 00301 00302 strftime(timestr, 25, "%x", localtime(&curtime)); 00303 var_set_variable("date", timestr); 00304 00305 strftime(timestr, 25, "%a %b %e %Y", localtime(&curtime)); 00306 var_set_variable("longdate", timestr); 00307 00308 return (0); 00309 }
|
|
Definition at line 97 of file notice.c. References get_next_field(), and string_Copy. 00101 { 00102 /* 00103 * While num>1 and there are fields left, skip a field & decrement num: 00104 */ 00105 while (length && num > 1) { 00106 if (!*data) 00107 num--; 00108 length--; 00109 data++; 00110 } 00111 00112 /* 00113 * If any more fields left, the first field is the one we want. 00114 * Otherwise, there is no such field as num -- return "". 00115 */ 00116 if (length) 00117 return (get_next_field(&data, &length)); 00118 else 00119 return (string_Copy("")); 00120 }
|
|
Definition at line 64 of file notice.c. References string_Copy, and string_CreateFromData. 00067 { 00068 char *data = *data_p; 00069 int length = *length_p; 00070 char *ptr; 00071 00072 for (ptr = data; length; ptr++, length--) 00073 if (!*ptr) { 00074 *data_p = ptr + 1; 00075 *length_p = length - 1; 00076 return (string_Copy(data)); 00077 } 00078 00079 length = *length_p; 00080 *data_p = ptr; 00081 *length_p = 0; 00082 return (string_CreateFromData(data, length)); 00083 }
|
Last updated at Tue Dec 18 21:07:42 PST 2007. | This site and project hosted by... |