comparison libpurple/plugins/log_reader.c @ 20909:feca1fd51b57

Use functions and loops and all those fancy things.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Fri, 12 Oct 2007 22:12:29 +0000
parents 70082d0db571
children 54d232b52607
comparison
equal deleted inserted replaced
20908:9ec0382e6c8d 20909:feca1fd51b57
25 enum name_guesses { 25 enum name_guesses {
26 NAME_GUESS_UNKNOWN, 26 NAME_GUESS_UNKNOWN,
27 NAME_GUESS_ME, 27 NAME_GUESS_ME,
28 NAME_GUESS_THEM 28 NAME_GUESS_THEM
29 }; 29 };
30
31 /* Some common functions. */
32 static int get_month(const char *month)
33 {
34 int iter;
35 const char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
36 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL};
37 for (iter = 0; months[iter]; iter++) {
38 if (strcmp(month, months[iter]) == 0)
39 break;
40 }
41 return iter;
42 }
30 43
31 44
32 /***************************************************************************** 45 /*****************************************************************************
33 * Adium Logger * 46 * Adium Logger *
34 *****************************************************************************/ 47 *****************************************************************************/
1346 1359
1347 /* Let the C library deal with 1360 /* Let the C library deal with
1348 * daylight savings time. 1361 * daylight savings time.
1349 */ 1362 */
1350 tm.tm_isdst = -1; 1363 tm.tm_isdst = -1;
1351 1364 tm.tm_mon = get_month(month);
1352 /* Ugly hack, in case current locale
1353 * is not English. This code is taken
1354 * from log.c.
1355 */
1356 if (strcmp(month, "Jan") == 0) {
1357 tm.tm_mon= 0;
1358 } else if (strcmp(month, "Feb") == 0) {
1359 tm.tm_mon = 1;
1360 } else if (strcmp(month, "Mar") == 0) {
1361 tm.tm_mon = 2;
1362 } else if (strcmp(month, "Apr") == 0) {
1363 tm.tm_mon = 3;
1364 } else if (strcmp(month, "May") == 0) {
1365 tm.tm_mon = 4;
1366 } else if (strcmp(month, "Jun") == 0) {
1367 tm.tm_mon = 5;
1368 } else if (strcmp(month, "Jul") == 0) {
1369 tm.tm_mon = 6;
1370 } else if (strcmp(month, "Aug") == 0) {
1371 tm.tm_mon = 7;
1372 } else if (strcmp(month, "Sep") == 0) {
1373 tm.tm_mon = 8;
1374 } else if (strcmp(month, "Oct") == 0) {
1375 tm.tm_mon = 9;
1376 } else if (strcmp(month, "Nov") == 0) {
1377 tm.tm_mon = 10;
1378 } else if (strcmp(month, "Dec") == 0) {
1379 tm.tm_mon = 11;
1380 }
1381 1365
1382 data = g_new0( 1366 data = g_new0(
1383 struct trillian_logger_data, 1); 1367 struct trillian_logger_data, 1);
1384 data->path = g_strdup(path); 1368 data->path = g_strdup(path);
1385 data->offset = offset; 1369 data->offset = offset;
2224 found_start = FALSE; 2208 found_start = FALSE;
2225 purple_debug_error("aMSN logger", 2209 purple_debug_error("aMSN logger",
2226 "Error parsing start date for %s\n", 2210 "Error parsing start date for %s\n",
2227 filename); 2211 filename);
2228 } else { 2212 } else {
2229 const char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
2230 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL};
2231 tm.tm_year -= 1900; 2213 tm.tm_year -= 1900;
2232 2214
2233 /* Let the C library deal with 2215 /* Let the C library deal with
2234 * daylight savings time. 2216 * daylight savings time.
2235 */ 2217 */
2236 tm.tm_isdst = -1; 2218 tm.tm_isdst = -1;
2237 2219 tm.tm_mon = get_month(month);
2238 /* Ugly hack, in case current locale 2220
2239 * is not English. This code is taken
2240 * from log.c.
2241 */
2242 for (tm.tm_mon = 0; months[tm.tm_mon]; tm.tm_mon++) {
2243 if (strcmp(month, months[tm.tm_mon]) == 0)
2244 break;
2245 }
2246 found_start = TRUE; 2221 found_start = TRUE;
2247 offset = c - contents; 2222 offset = c - contents;
2248 start_log = c; 2223 start_log = c;
2249 } 2224 }
2250 } else if (purple_str_has_prefix(c, AMSN_LOG_CONV_END) && found_start) { 2225 } else if (purple_str_has_prefix(c, AMSN_LOG_CONV_END) && found_start) {