comparison src/log.c @ 7676:5c5acdf8b982

[gaim-migrate @ 8320] Ambrose C. Li made the log viewer right for you international folk. Thanks, Ambrose! committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Mon, 01 Dec 2003 00:09:48 +0000
parents e293d0c42ccb
children 9e122b8f564f
comparison
equal deleted inserted replaced
7675:66d9440db6ec 7676:5c5acdf8b982
704 { 704 {
705 FILE *file; 705 FILE *file;
706 char buf[BUF_LONG]; 706 char buf[BUF_LONG];
707 struct tm tm; 707 struct tm tm;
708 struct old_logger_data *data = NULL; 708 struct old_logger_data *data = NULL;
709 char day[4], month[4], year[5]; 709 char month[4];
710 char *logfile = g_strdup_printf("%s.log", gaim_normalize(account, sn)); 710 char *logfile = g_strdup_printf("%s.log", gaim_normalize(account, sn));
711 char *date;
712 char *path = g_build_filename(gaim_user_dir(), "logs", logfile, NULL); 711 char *path = g_build_filename(gaim_user_dir(), "logs", logfile, NULL);
713 char *newlog; 712 char *newlog;
714 713
715 GaimLog *log = NULL; 714 GaimLog *log = NULL;
716 GList *list = NULL; 715 GList *list = NULL;
724 723
725 while (fgets(buf, BUF_LONG, file)) { 724 while (fgets(buf, BUF_LONG, file)) {
726 if ((newlog = strstr(buf, "---- New C"))) { 725 if ((newlog = strstr(buf, "---- New C"))) {
727 int length; 726 int length;
728 int offset; 727 int offset;
729 GDate gdate;
730 char convostart[32]; 728 char convostart[32];
731 char *temp = strchr(buf, '@'); 729 char *temp = strchr(buf, '@');
732 730
733 if (temp == NULL || strlen(temp) < 2) 731 if (temp == NULL || strlen(temp) < 2)
734 continue; 732 continue;
767 data->path = g_strdup(path); 765 data->path = g_strdup(path);
768 log->logger_data = data; 766 log->logger_data = data;
769 767
770 768
771 g_snprintf(convostart, length, "%s", temp); 769 g_snprintf(convostart, length, "%s", temp);
772 sscanf(convostart, "%*s %s %s %d:%d:%d %s", 770 sscanf(convostart, "%*s %s %d %d:%d:%d %d",
773 month, day, &tm.tm_hour, &tm.tm_min, &tm.tm_sec, year); 771 month, &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec, &tm.tm_year);
774 date = g_strdup_printf("%s %s %s", month, day, year); 772 /* Ugly hack, in case current locale is not English */
775 g_date_set_parse(&gdate, date); 773 if (strcmp(month, "Jan") == 0) {
776 tm.tm_mday = g_date_get_day(&gdate); 774 tm.tm_mon= 0;
777 tm.tm_mon = g_date_get_month(&gdate) - 1; 775 } else if (strcmp(month, "Feb") == 0) {
778 tm.tm_year = g_date_get_year(&gdate) - 1900; 776 tm.tm_mon = 1;
777 } else if (strcmp(month, "Mar") == 0) {
778 tm.tm_mon = 2;
779 } else if (strcmp(month, "Apr") == 0) {
780 tm.tm_mon = 3;
781 } else if (strcmp(month, "May") == 0) {
782 tm.tm_mon = 4;
783 } else if (strcmp(month, "Jun") == 0) {
784 tm.tm_mon = 5;
785 } else if (strcmp(month, "Jul") == 0) {
786 tm.tm_mon = 6;
787 } else if (strcmp(month, "Aug") == 0) {
788 tm.tm_mon = 7;
789 } else if (strcmp(month, "Sep") == 0) {
790 tm.tm_mon = 8;
791 } else if (strcmp(month, "Oct") == 0) {
792 tm.tm_mon = 9;
793 } else if (strcmp(month, "Nov") == 0) {
794 tm.tm_mon = 10;
795 } else if (strcmp(month, "Dec") == 0) {
796 tm.tm_mon = 11;
797 }
798 tm.tm_year -= 1900;
779 log->time = mktime(&tm); 799 log->time = mktime(&tm);
780 g_free(date);
781
782 } 800 }
783 } 801 }
784 802
785 if (data) { 803 if (data) {
786 data->length = ftell(file) - data->offset; 804 data->length = ftell(file) - data->offset;