annotate src/util.c @ 3474:cfbdfe334975

[gaim-migrate @ 3525] Rob McQueen removed aol_icon() and made Gaim use the pretty png as our default icon. Thanks. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Fri, 30 Aug 2002 03:14:05 +0000
parents 7a3f16a375a5
children 3da42b64304e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1 /*
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2 * gaim
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
5 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
9 * (at your option) any later version.
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
10 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
14 * GNU General Public License for more details.
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
15 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
19 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
20 */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
21
349
b402a23f35df [gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 278
diff changeset
22 #ifdef HAVE_CONFIG_H
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
23 #include <config.h>
349
b402a23f35df [gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 278
diff changeset
24 #endif
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
25 #include <unistd.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
26 #include <errno.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
27 #include <stdio.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
28 #include <stdlib.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
29 #include <sys/time.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
30 #include <sys/types.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
31 #include <sys/stat.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
32 #include <string.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
33 #include <sys/wait.h>
210
ec0686b3b03f [gaim-migrate @ 220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 209
diff changeset
34 #include <ctype.h>
3361
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
35 #include <iconv.h>
1376
730a1a19b4cc [gaim-migrate @ 1386]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1293
diff changeset
36 #include <math.h>
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
37 #include "gaim.h"
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
38 #include "prpl.h"
3105
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3076
diff changeset
39 #include "gtkspell.h"
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
40
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
41 char *full_date()
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
42 {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
43 char *date;
70
dead1eb6d654 [gaim-migrate @ 80]
Rob Flynn <gaim@robflynn.com>
parents: 26
diff changeset
44 time_t tme;
dead1eb6d654 [gaim-migrate @ 80]
Rob Flynn <gaim@robflynn.com>
parents: 26
diff changeset
45
dead1eb6d654 [gaim-migrate @ 80]
Rob Flynn <gaim@robflynn.com>
parents: 26
diff changeset
46 time(&tme);
dead1eb6d654 [gaim-migrate @ 80]
Rob Flynn <gaim@robflynn.com>
parents: 26
diff changeset
47 date = ctime(&tme);
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
48 date[strlen(date) - 1] = '\0';
70
dead1eb6d654 [gaim-migrate @ 80]
Rob Flynn <gaim@robflynn.com>
parents: 26
diff changeset
49 return date;
dead1eb6d654 [gaim-migrate @ 80]
Rob Flynn <gaim@robflynn.com>
parents: 26
diff changeset
50 }
dead1eb6d654 [gaim-migrate @ 80]
Rob Flynn <gaim@robflynn.com>
parents: 26
diff changeset
51
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
52 gint badchar(char c)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
53 {
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
54 switch (c) {
970
9eb07b383df4 [gaim-migrate @ 980]
Rob Flynn <gaim@robflynn.com>
parents: 967
diff changeset
55 case ' ':
9eb07b383df4 [gaim-migrate @ 980]
Rob Flynn <gaim@robflynn.com>
parents: 967
diff changeset
56 case ',':
9eb07b383df4 [gaim-migrate @ 980]
Rob Flynn <gaim@robflynn.com>
parents: 967
diff changeset
57 case '(':
9eb07b383df4 [gaim-migrate @ 980]
Rob Flynn <gaim@robflynn.com>
parents: 967
diff changeset
58 case ')':
9eb07b383df4 [gaim-migrate @ 980]
Rob Flynn <gaim@robflynn.com>
parents: 967
diff changeset
59 case '\0':
976
2586b2a3725e [gaim-migrate @ 986]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 970
diff changeset
60 case '\n':
970
9eb07b383df4 [gaim-migrate @ 980]
Rob Flynn <gaim@robflynn.com>
parents: 967
diff changeset
61 case '<':
9eb07b383df4 [gaim-migrate @ 980]
Rob Flynn <gaim@robflynn.com>
parents: 967
diff changeset
62 case '>':
1706
e6671b80a1f2 [gaim-migrate @ 1716]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1622
diff changeset
63 case '"':
413
7ea55575cc01 [gaim-migrate @ 423]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 373
diff changeset
64 return 1;
970
9eb07b383df4 [gaim-migrate @ 980]
Rob Flynn <gaim@robflynn.com>
parents: 967
diff changeset
65 default:
9eb07b383df4 [gaim-migrate @ 980]
Rob Flynn <gaim@robflynn.com>
parents: 967
diff changeset
66 return 0;
9eb07b383df4 [gaim-migrate @ 980]
Rob Flynn <gaim@robflynn.com>
parents: 967
diff changeset
67 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
68 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
69
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
70
1376
730a1a19b4cc [gaim-migrate @ 1386]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1293
diff changeset
71 gchar *sec_to_text(guint sec)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
72 {
1826
7f889cdfa03e [gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1815
diff changeset
73 int daze, hrs, min;
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
74 char *ret = g_malloc(256);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
75
1826
7f889cdfa03e [gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1815
diff changeset
76 daze = sec / (60 * 60 * 24);
7f889cdfa03e [gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1815
diff changeset
77 hrs = (sec % (60 * 60 * 24)) / (60 * 60);
7f889cdfa03e [gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1815
diff changeset
78 min = (sec % (60 * 60)) / 60;
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
79 sec = min % 60;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
80
1826
7f889cdfa03e [gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1815
diff changeset
81 if (daze) {
7f889cdfa03e [gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1815
diff changeset
82 if (hrs || min) {
7f889cdfa03e [gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1815
diff changeset
83 if (hrs) {
7f889cdfa03e [gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1815
diff changeset
84 if (min) {
7f889cdfa03e [gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1815
diff changeset
85 g_snprintf(ret, 256,
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2371
diff changeset
86 "%d day%s, %d hour%s, %d minute%s.",
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2371
diff changeset
87 daze, daze == 1 ? "" : "s",
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2371
diff changeset
88 hrs, hrs == 1 ? "" : "s", min, min == 1 ? "" : "s");
1826
7f889cdfa03e [gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1815
diff changeset
89 } else {
7f889cdfa03e [gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1815
diff changeset
90 g_snprintf(ret, 256,
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2371
diff changeset
91 "%d day%s, %d hour%s.",
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2371
diff changeset
92 daze, daze == 1 ? "" : "s", hrs, hrs == 1 ? "" : "s");
1826
7f889cdfa03e [gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1815
diff changeset
93 }
7f889cdfa03e [gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1815
diff changeset
94 } else {
7f889cdfa03e [gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1815
diff changeset
95 g_snprintf(ret, 256,
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2371
diff changeset
96 "%d day%s, %d minute%s.",
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2371
diff changeset
97 daze, daze == 1 ? "" : "s", min, min == 1 ? "" : "s");
1826
7f889cdfa03e [gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1815
diff changeset
98 }
7f889cdfa03e [gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1815
diff changeset
99 } else
7f889cdfa03e [gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1815
diff changeset
100 g_snprintf(ret, 256, "%d day%s.", daze, daze == 1 ? "" : "s");
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
101 } else {
1826
7f889cdfa03e [gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1815
diff changeset
102 if (hrs) {
7f889cdfa03e [gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1815
diff changeset
103 if (min) {
7f889cdfa03e [gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1815
diff changeset
104 g_snprintf(ret, 256,
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2371
diff changeset
105 "%d hour%s, %d minute%s.",
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2371
diff changeset
106 hrs, hrs == 1 ? "" : "s", min, min == 1 ? "" : "s");
1826
7f889cdfa03e [gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1815
diff changeset
107 } else {
7f889cdfa03e [gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1815
diff changeset
108 g_snprintf(ret, 256, "%d hour%s.", hrs, hrs == 1 ? "" : "s");
7f889cdfa03e [gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1815
diff changeset
109 }
7f889cdfa03e [gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1815
diff changeset
110 } else {
7f889cdfa03e [gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1815
diff changeset
111 g_snprintf(ret, 256, "%d minute%s.", min, min == 1 ? "" : "s");
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
112 }
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
113 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
114
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
115 return ret;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
116 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
117
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
118 gint linkify_text(char *text)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
119 {
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
120 char *c, *t;
1622
1acef460964a [gaim-migrate @ 1632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1609
diff changeset
121 char *cpy = g_malloc(strlen(text) * 3 + 1);
1acef460964a [gaim-migrate @ 1632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1609
diff changeset
122 char url_buf[BUF_LEN * 4];
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
123 int cnt = 0;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
124 /* Assumes you have a buffer able to cary at least BUF_LEN * 2 bytes */
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
125
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
126 strncpy(cpy, text, strlen(text));
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
127 cpy[strlen(text)] = 0;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
128 c = cpy;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
129 while (*c) {
2048
3366311426df [gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2043
diff changeset
130 if (!g_strncasecmp(c, "<A", 2)) {
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
131 while (1) {
2596
35c23df11d16 [gaim-migrate @ 2609]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2397
diff changeset
132 if (!g_strncasecmp(c, "/A>", 3)) {
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
133 break;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
134 }
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
135 text[cnt++] = *c;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
136 c++;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
137 if (!(*c))
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
138 break;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
139 }
2048
3366311426df [gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2043
diff changeset
140 } else if ((!g_strncasecmp(c, "http://", 7) || (!g_strncasecmp(c, "https://", 8)))) {
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
141 t = c;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
142 while (1) {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
143 if (badchar(*t)) {
925
1ff824e6bc19 [gaim-migrate @ 935]
Rob Flynn <gaim@robflynn.com>
parents: 924
diff changeset
144
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
145 if (*(t) == ',' && (*(t + 1) != ' ')) {
925
1ff824e6bc19 [gaim-migrate @ 935]
Rob Flynn <gaim@robflynn.com>
parents: 924
diff changeset
146 t++;
1ff824e6bc19 [gaim-migrate @ 935]
Rob Flynn <gaim@robflynn.com>
parents: 924
diff changeset
147 continue;
1ff824e6bc19 [gaim-migrate @ 935]
Rob Flynn <gaim@robflynn.com>
parents: 924
diff changeset
148 }
1ff824e6bc19 [gaim-migrate @ 935]
Rob Flynn <gaim@robflynn.com>
parents: 924
diff changeset
149
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
150 if (*(t - 1) == '.')
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
151 t--;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
152 strncpy(url_buf, c, t - c);
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
153 url_buf[t - c] = 0;
2614
3e2f455cb924 [gaim-migrate @ 2627]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
154 cnt += g_snprintf(&text[cnt], 1024, "<A HREF=\"%s\">%s</A>",
3e2f455cb924 [gaim-migrate @ 2627]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
155 url_buf, url_buf);
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
156 c = t;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
157 break;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
158 }
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
159 if (!t)
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
160 break;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
161 t++;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
162
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
163 }
2048
3366311426df [gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2043
diff changeset
164 } else if (!g_strncasecmp(c, "www.", 4)) {
3366311426df [gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2043
diff changeset
165 if (g_strncasecmp(c, "www..", 5)) {
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
166 t = c;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
167 while (1) {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
168 if (badchar(*t)) {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
169 if (t - c == 4) {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
170 break;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
171 }
925
1ff824e6bc19 [gaim-migrate @ 935]
Rob Flynn <gaim@robflynn.com>
parents: 924
diff changeset
172
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
173 if (*(t) == ',' && (*(t + 1) != ' ')) {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
174 t++;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
175 continue;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
176 }
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
177
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
178 if (*(t - 1) == '.')
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
179 t--;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
180 strncpy(url_buf, c, t - c);
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
181 url_buf[t - c] = 0;
2614
3e2f455cb924 [gaim-migrate @ 2627]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
182 cnt += g_snprintf(&text[cnt], 1024,
3e2f455cb924 [gaim-migrate @ 2627]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
183 "<A HREF=\"http://%s\">%s</A>", url_buf,
3e2f455cb924 [gaim-migrate @ 2627]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
184 url_buf);
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
185 c = t;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
186 break;
925
1ff824e6bc19 [gaim-migrate @ 935]
Rob Flynn <gaim@robflynn.com>
parents: 924
diff changeset
187 }
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
188 if (!t)
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
189 break;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
190 t++;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
191 }
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
192 }
2048
3366311426df [gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2043
diff changeset
193 } else if (!g_strncasecmp(c, "ftp://", 6)) {
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
194 t = c;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
195 while (1) {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
196 if (badchar(*t)) {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
197 if (*(t - 1) == '.')
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
198 t--;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
199 strncpy(url_buf, c, t - c);
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
200 url_buf[t - c] = 0;
2614
3e2f455cb924 [gaim-migrate @ 2627]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
201 cnt += g_snprintf(&text[cnt], 1024, "<A HREF=\"%s\">%s</A>",
3e2f455cb924 [gaim-migrate @ 2627]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
202 url_buf, url_buf);
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
203 c = t;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
204 break;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
205 }
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
206 if (!t)
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
207 break;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
208 t++;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
209
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
210 }
2048
3366311426df [gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2043
diff changeset
211 } else if (!g_strncasecmp(c, "ftp.", 4)) {
3366311426df [gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2043
diff changeset
212 if (g_strncasecmp(c, "ftp..", 5)) {
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
213 t = c;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
214 while (1) {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
215 if (badchar(*t)) {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
216 if (t - c == 4) {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
217 break;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
218 }
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
219 if (*(t - 1) == '.')
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
220 t--;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
221 strncpy(url_buf, c, t - c);
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
222 url_buf[t - c] = 0;
2614
3e2f455cb924 [gaim-migrate @ 2627]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
223 cnt += g_snprintf(&text[cnt], 1024,
3e2f455cb924 [gaim-migrate @ 2627]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
224 "<A HREF=\"ftp://%s\">%s</A>", url_buf,
3e2f455cb924 [gaim-migrate @ 2627]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
225 url_buf);
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
226 c = t;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
227 break;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
228 }
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
229 if (!t)
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
230 break;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
231 t++;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
232 }
924
f6aa60716419 [gaim-migrate @ 934]
Rob Flynn <gaim@robflynn.com>
parents: 915
diff changeset
233 }
2048
3366311426df [gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2043
diff changeset
234 } else if (!g_strncasecmp(c, "mailto:", 7)) {
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
235 t = c;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
236 while (1) {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
237 if (badchar(*t)) {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
238 if (*(t - 1) == '.')
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
239 t--;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
240 strncpy(url_buf, c, t - c);
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
241 url_buf[t - c] = 0;
2614
3e2f455cb924 [gaim-migrate @ 2627]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
242 cnt += g_snprintf(&text[cnt], 1024, "<A HREF=\"%s\">%s</A>",
3e2f455cb924 [gaim-migrate @ 2627]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
243 url_buf, url_buf);
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
244 c = t;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
245 break;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
246 }
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
247 if (!t)
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
248 break;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
249 t++;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
250
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
251 }
2048
3366311426df [gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2043
diff changeset
252 } else if (c != cpy && !g_strncasecmp(c, "@", 1)) {
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
253 char *tmp;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
254 int flag;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
255 int len = 0;
3330
af52fdf06166 [gaim-migrate @ 3348]
Christian Hammond <chipx86@chipx86.com>
parents: 3279
diff changeset
256 char illegal_chars[] = "!@#$%^&*()[]{}/|\\<>\":;\0";
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
257 url_buf[0] = 0;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
258
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
259 if (*(c - 1) == ' ' || *(c + 1) == ' ' || rindex(illegal_chars, *(c + 1))
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
260 || *(c + 1) == 13 || *(c + 1) == 10)
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
261 flag = 0;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
262 else
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
263 flag = 1;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
264
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
265 t = c;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
266 while (flag) {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
267 if (badchar(*t)) {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
268 cnt -= (len - 1);
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
269 break;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
270 } else {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
271 len++;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
272 tmp = g_malloc(len + 1);
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
273 tmp[len] = 0;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
274 tmp[0] = *t;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
275 strncpy(tmp + 1, url_buf, len - 1);
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
276 strcpy(url_buf, tmp);
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
277 url_buf[len] = 0;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
278 g_free(tmp);
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
279 t--;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
280 if (t < cpy) {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
281 cnt = 0;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
282 break;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
283 }
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
284 }
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
285 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
286
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
287 t = c + 1;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
288
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
289 while (flag) {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
290 if (badchar(*t)) {
3331
8f69ff64f0bf [gaim-migrate @ 3349]
Christian Hammond <chipx86@chipx86.com>
parents: 3330
diff changeset
291 char *d;
8f69ff64f0bf [gaim-migrate @ 3349]
Christian Hammond <chipx86@chipx86.com>
parents: 3330
diff changeset
292
8f69ff64f0bf [gaim-migrate @ 3349]
Christian Hammond <chipx86@chipx86.com>
parents: 3330
diff changeset
293 for (d = url_buf + strlen(url_buf) - 1; *d == '.'; d--, t--)
8f69ff64f0bf [gaim-migrate @ 3349]
Christian Hammond <chipx86@chipx86.com>
parents: 3330
diff changeset
294 *d = '\0';
3330
af52fdf06166 [gaim-migrate @ 3348]
Christian Hammond <chipx86@chipx86.com>
parents: 3279
diff changeset
295
2614
3e2f455cb924 [gaim-migrate @ 2627]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
296 cnt += g_snprintf(&text[cnt], 1024,
3e2f455cb924 [gaim-migrate @ 2627]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
297 "<A HREF=\"mailto:%s\">%s</A>", url_buf,
3e2f455cb924 [gaim-migrate @ 2627]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
298 url_buf);
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
299 text[cnt] = 0;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
300
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
301
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
302 c = t;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
303
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
304 break;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
305 } else {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
306 strncat(url_buf, t, 1);
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
307 len++;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
308 url_buf[len] = 0;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
309 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
310
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
311 t++;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
312 }
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
313 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
314
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
315 if (*c == 0)
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
316 break;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
317
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
318 text[cnt++] = *c;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
319 c++;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
320
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
321 }
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
322 text[cnt] = 0;
845
647b110f7a1a [gaim-migrate @ 855]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 831
diff changeset
323 g_free(cpy);
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
324 return cnt;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
325 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
326
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
327
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
328 FILE *open_gaim_log_file(char *name, int *flag)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
329 {
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
330 char *buf;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
331 char *buf2;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
332 char log_all_file[256];
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
333 struct stat st;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
334 FILE *fd;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
335 int res;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
336 gchar *gaim_dir;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
337
79
bfdc427b936d [gaim-migrate @ 89]
Rob Flynn <gaim@robflynn.com>
parents: 70
diff changeset
338 buf = g_malloc(BUF_LONG);
bfdc427b936d [gaim-migrate @ 89]
Rob Flynn <gaim@robflynn.com>
parents: 70
diff changeset
339 buf2 = g_malloc(BUF_LONG);
1238
78c4f497db2b [gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1202
diff changeset
340 gaim_dir = gaim_user_dir();
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
341
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
342 /* Dont log yourself */
1238
78c4f497db2b [gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1202
diff changeset
343 strncpy(log_all_file, gaim_dir, 256);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
344
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
345 stat(log_all_file, &st);
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
346 if (!S_ISDIR(st.st_mode))
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
347 unlink(log_all_file);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
348
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
349 fd = fopen(log_all_file, "r");
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
350
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
351 if (!fd) {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
352 res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR);
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
353 if (res < 0) {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
354 g_snprintf(buf, BUF_LONG, "Unable to make directory %s for logging",
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
355 log_all_file);
3427
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3373
diff changeset
356 do_error_dialog(buf, NULL, GAIM_ERROR);
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
357 g_free(buf);
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
358 g_free(buf2);
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
359 g_free(gaim_dir);
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
360 return NULL;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
361 }
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
362 } else
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
363 fclose(fd);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
364
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
365 g_snprintf(log_all_file, 256, "%s/logs", gaim_dir);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
366
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
367 if (stat(log_all_file, &st) < 0)
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
368 *flag = 1;
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
369 if (!S_ISDIR(st.st_mode))
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
370 unlink(log_all_file);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
371
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
372 fd = fopen(log_all_file, "r");
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
373 if (!fd) {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
374 res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR);
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
375 if (res < 0) {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
376 g_snprintf(buf, BUF_LONG, "Unable to make directory %s for logging",
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
377 log_all_file);
3427
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3373
diff changeset
378 do_error_dialog(buf, NULL, GAIM_ERROR);
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
379 g_free(buf);
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
380 g_free(buf2);
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
381 g_free(gaim_dir);
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
382 return NULL;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
383 }
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
384 } else
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
385 fclose(fd);
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
386
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
387
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
388
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
389 g_snprintf(log_all_file, 256, "%s/logs/%s", gaim_dir, name);
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
390 if (stat(log_all_file, &st) < 0)
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
391 *flag = 1;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
392
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
393 debug_printf("Logging to: \"%s\"\n", log_all_file);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
394
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
395 fd = fopen(log_all_file, "a");
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
396
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
397 g_free(buf);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
398 g_free(buf2);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
399 g_free(gaim_dir);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
400 return fd;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
401 }
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
402
3457
222e23f91092 [gaim-migrate @ 3505]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
403 FILE *open_log_file(char *name, int is_chat)
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
404 {
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
405 struct stat st;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
406 char realname[256];
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
407 struct log_conversation *l;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
408 FILE *fd;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
409 int flag = 0;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
410
3457
222e23f91092 [gaim-migrate @ 3505]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
411 if (((is_chat == 2) && !(logging_options & OPT_LOG_INDIVIDUAL))
222e23f91092 [gaim-migrate @ 3505]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
412 || ((is_chat == 1) && !(logging_options & OPT_LOG_CHATS))
222e23f91092 [gaim-migrate @ 3505]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
413 || ((is_chat == 0) && !(logging_options & OPT_LOG_CONVOS))) {
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
414
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
415 l = find_log_info(name);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
416 if (!l)
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
417 return NULL;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
418
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
419 if (stat(l->filename, &st) < 0)
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
420 flag = 1;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
421
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
422 fd = fopen(l->filename, "a");
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
423
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
424 if (flag) { /* is a new file */
1856
8f06476b1296 [gaim-migrate @ 1866]
Rob Flynn <gaim@robflynn.com>
parents: 1843
diff changeset
425 if (logging_options & OPT_LOG_STRIP_HTML) {
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2371
diff changeset
426 fprintf(fd, "IM Sessions with %s\n", name);
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2371
diff changeset
427 } else {
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2371
diff changeset
428 fprintf(fd, "<HTML><HEAD><TITLE>");
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2371
diff changeset
429 fprintf(fd, "IM Sessions with %s", name);
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2371
diff changeset
430 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"ffffff\">\n");
1856
8f06476b1296 [gaim-migrate @ 1866]
Rob Flynn <gaim@robflynn.com>
parents: 1843
diff changeset
431 }
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
432 }
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
433
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
434 return fd;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
435 }
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
436
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
437 g_snprintf(realname, sizeof(realname), "%s.log", normalize(name));
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
438 fd = open_gaim_log_file(realname, &flag);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
439
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
440 if (fd && flag) { /* is a new file */
1856
8f06476b1296 [gaim-migrate @ 1866]
Rob Flynn <gaim@robflynn.com>
parents: 1843
diff changeset
441 if (logging_options & OPT_LOG_STRIP_HTML) {
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2371
diff changeset
442 fprintf(fd, "IM Sessions with %s\n", name);
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2371
diff changeset
443 } else {
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2371
diff changeset
444 fprintf(fd, "<HTML><HEAD><TITLE>");
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2371
diff changeset
445 fprintf(fd, "IM Sessions with %s", name);
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2371
diff changeset
446 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"ffffff\">\n");
1856
8f06476b1296 [gaim-migrate @ 1866]
Rob Flynn <gaim@robflynn.com>
parents: 1843
diff changeset
447 }
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
448 }
25
c56db1b46b0d [gaim-migrate @ 34]
Rob Flynn <gaim@robflynn.com>
parents: 17
diff changeset
449
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
450 return fd;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
451 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
452
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
453 FILE *open_system_log_file(char *name)
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
454 {
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
455 int x;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
456
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
457 if (name)
3457
222e23f91092 [gaim-migrate @ 3505]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
458 return open_log_file(name, 2);
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
459 else
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
460 return open_gaim_log_file("system", &x);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
461 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
462
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
463 char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" "0123456789+/";
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
464
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3105
diff changeset
465 /* XXX Find bug */
1920
5bed3bc833b5 [gaim-migrate @ 1930]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1878
diff changeset
466 char *tobase64(const char *text)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
467 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
468 char *out = NULL;
1920
5bed3bc833b5 [gaim-migrate @ 1930]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1878
diff changeset
469 const char *c;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
470 unsigned int tmp = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
471 int len = 0, n = 0;
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
472
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
473 c = text;
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
474
1829
bdfb37ae28b4 [gaim-migrate @ 1839]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1826
diff changeset
475 while (*c) {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
476 tmp = tmp << 8;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
477 tmp += *c;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
478 n++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
479
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
480 if (n == 3) {
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
481 out = g_realloc(out, len + 4);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
482 out[len] = alphabet[(tmp >> 18) & 0x3f];
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
483 out[len + 1] = alphabet[(tmp >> 12) & 0x3f];
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
484 out[len + 2] = alphabet[(tmp >> 6) & 0x3f];
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
485 out[len + 3] = alphabet[tmp & 0x3f];
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
486 len += 4;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
487 tmp = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
488 n = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
489 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
490 c++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
491 }
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
492 switch (n) {
1238
78c4f497db2b [gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1202
diff changeset
493
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
494 case 2:
1829
bdfb37ae28b4 [gaim-migrate @ 1839]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1826
diff changeset
495 tmp <<= 8;
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
496 out = g_realloc(out, len + 5);
1829
bdfb37ae28b4 [gaim-migrate @ 1839]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1826
diff changeset
497 out[len] = alphabet[(tmp >> 18) & 0x3f];
bdfb37ae28b4 [gaim-migrate @ 1839]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1826
diff changeset
498 out[len + 1] = alphabet[(tmp >> 12) & 0x3f];
bdfb37ae28b4 [gaim-migrate @ 1839]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1826
diff changeset
499 out[len + 2] = alphabet[(tmp >> 6) & 0x3f];
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
500 out[len + 3] = '=';
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
501 out[len + 4] = 0;
1238
78c4f497db2b [gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1202
diff changeset
502 break;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
503 case 1:
1829
bdfb37ae28b4 [gaim-migrate @ 1839]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1826
diff changeset
504 tmp <<= 16;
1843
4dbd8533d209 [gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1829
diff changeset
505 out = g_realloc(out, len + 5);
4dbd8533d209 [gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1829
diff changeset
506 out[len] = alphabet[(tmp >> 18) & 0x3f];
4dbd8533d209 [gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1829
diff changeset
507 out[len + 1] = alphabet[(tmp >> 12) & 0x3f];
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
508 out[len + 2] = '=';
1843
4dbd8533d209 [gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1829
diff changeset
509 out[len + 3] = '=';
4dbd8533d209 [gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1829
diff changeset
510 out[len + 4] = 0;
1238
78c4f497db2b [gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1202
diff changeset
511 break;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
512 case 0:
1843
4dbd8533d209 [gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1829
diff changeset
513 out = g_realloc(out, len + 1);
4dbd8533d209 [gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1829
diff changeset
514 out[len] = 0;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
515 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
516 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
517 return out;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
518 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
519
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
520
1920
5bed3bc833b5 [gaim-migrate @ 1930]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1878
diff changeset
521 void frombase64(const char *text, char **data, int *size)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
522 {
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
523 char *out = NULL;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
524 char tmp = 0;
1920
5bed3bc833b5 [gaim-migrate @ 1930]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1878
diff changeset
525 const char *c;
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
526 gint32 tmp2 = 0;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
527 int len = 0, n = 0;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
528
1920
5bed3bc833b5 [gaim-migrate @ 1930]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1878
diff changeset
529 if (!text || !data)
5bed3bc833b5 [gaim-migrate @ 1930]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1878
diff changeset
530 return;
5bed3bc833b5 [gaim-migrate @ 1930]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1878
diff changeset
531
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
532 c = text;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
533
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
534 while (*c) {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
535 if (*c >= 'A' && *c <= 'Z') {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
536 tmp = *c - 'A';
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
537 } else if (*c >= 'a' && *c <= 'z') {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
538 tmp = 26 + (*c - 'a');
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
539 } else if (*c >= '0' && *c <= 57) {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
540 tmp = 52 + (*c - '0');
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
541 } else if (*c == '+') {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
542 tmp = 62;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
543 } else if (*c == '/') {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
544 tmp = 63;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
545 } else if (*c == '=') {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
546 if (n == 3) {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
547 out = g_realloc(out, len + 2);
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
548 out[len] = (char)(tmp2 >> 10) & 0xff;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
549 len++;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
550 out[len] = (char)(tmp2 >> 2) & 0xff;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
551 len++;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
552 } else if (n == 2) {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
553 out = g_realloc(out, len + 1);
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
554 out[len] = (char)(tmp2 >> 4) & 0xff;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
555 len++;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
556 }
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
557 break;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
558 }
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
559 tmp2 = ((tmp2 << 6) | (tmp & 0xff));
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
560 n++;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
561 if (n == 4) {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
562 out = g_realloc(out, len + 3);
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
563 out[len] = (char)((tmp2 >> 16) & 0xff);
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
564 len++;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
565 out[len] = (char)((tmp2 >> 8) & 0xff);
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
566 len++;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
567 out[len] = (char)(tmp2 & 0xff);
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
568 len++;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
569 tmp2 = 0;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
570 n = 0;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
571 }
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
572 c++;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
573 }
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
574
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
575 out = g_realloc(out, len + 1);
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
576 out[len] = 0;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
577
1920
5bed3bc833b5 [gaim-migrate @ 1930]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1878
diff changeset
578 *data = out;
5bed3bc833b5 [gaim-migrate @ 1930]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1878
diff changeset
579 if (size)
5bed3bc833b5 [gaim-migrate @ 1930]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1878
diff changeset
580 *size = len;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
581 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
582
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
583
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
584 char *normalize(const char *s)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
585 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
586 static char buf[BUF_LEN];
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
587 char *t, *u;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
588 int x = 0;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
589
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
590 g_return_val_if_fail((s != NULL), NULL);
26
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 25
diff changeset
591
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
592 u = t = g_strdup(s);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
593
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
594 strcpy(t, s);
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
595 g_strdown(t);
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
596
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
597 while (*t && (x < BUF_LEN - 1)) {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
598 if (*t != ' ') {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
599 buf[x] = *t;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
600 x++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
601 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
602 t++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
603 }
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
604 buf[x] = '\0';
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
605 g_free(u);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
606 return buf;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
607 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
608
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
609 char *date()
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
610 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
611 static char date[80];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
612 time_t tme;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
613 time(&tme);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
614 strftime(date, sizeof(date), "%H:%M:%S", localtime(&tme));
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
615 return date;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
616 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
617
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
618
3076
a7e03c5d2205 [gaim-migrate @ 3090]
Rob Flynn <gaim@robflynn.com>
parents: 2956
diff changeset
619 void clean_pid(void)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
620 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
621 int status;
3105
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3076
diff changeset
622 pid_t pid, spell_pid;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
623
3105
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3076
diff changeset
624 while((pid = waitpid(-1, &status, WNOHANG)) > 0) {
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3076
diff changeset
625 if((spell_pid = gtkspell_running()) != 0 && pid == spell_pid) {
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3076
diff changeset
626 gtkspell_notrunning();
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3076
diff changeset
627 }
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3076
diff changeset
628 }
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3076
diff changeset
629 if(pid < 0 && errno != ECHILD) {
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3076
diff changeset
630 char errmsg[BUFSIZ];
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3076
diff changeset
631 sprintf(errmsg, "Warning: waitpid() returned %d", pid);
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3076
diff changeset
632 perror(errmsg);
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3076
diff changeset
633 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
634 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
635
1030
38452403563b [gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1009
diff changeset
636 struct aim_user *find_user(const char *name, int protocol)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
637 {
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
638 char *who = g_strdup(normalize(name));
2397
520257562955 [gaim-migrate @ 2410]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
639 GSList *usr = aim_users;
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
640 struct aim_user *u;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
641
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
642 while (usr) {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
643 u = (struct aim_user *)usr->data;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
644 if (!strcmp(normalize(u->username), who)) {
1030
38452403563b [gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1009
diff changeset
645 if (protocol != -1) {
38452403563b [gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1009
diff changeset
646 if (u->protocol == protocol) {
38452403563b [gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1009
diff changeset
647 g_free(who);
38452403563b [gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1009
diff changeset
648 return u;
38452403563b [gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1009
diff changeset
649 }
38452403563b [gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1009
diff changeset
650 } else {
38452403563b [gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1009
diff changeset
651 g_free(who);
38452403563b [gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1009
diff changeset
652 return u;
38452403563b [gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1009
diff changeset
653 }
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
654
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
655 }
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
656 usr = usr->next;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
657 }
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
658 g_free(who);
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
659 return NULL;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
660 }
180
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
661
206
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
662
592
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
663 /* Look for %n, %d, or %t in msg, and replace with the sender's name, date,
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
664 or time */
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
665 char *away_subs(char *msg, char *name)
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
666 {
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
667 char *c;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
668 static char cpy[BUF_LONG];
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
669 int cnt = 0;
592
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
670 time_t t = time(0);
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
671 struct tm *tme = localtime(&t);
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
672 char tmp[20];
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
673
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
674 cpy[0] = '\0';
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
675 c = msg;
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
676 while (*c) {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
677 switch (*c) {
592
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
678 case '%':
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
679 if (*(c + 1)) {
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
680 switch (*(c + 1)) {
592
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
681 case 'n':
1976
24aed1c31342 [gaim-migrate @ 1986]
Rob Flynn <gaim@robflynn.com>
parents: 1949
diff changeset
682 /* append name */
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
683 strcpy(cpy + cnt, name);
592
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
684 cnt += strlen(name);
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
685 c++;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
686 break;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
687 case 'd':
1976
24aed1c31342 [gaim-migrate @ 1986]
Rob Flynn <gaim@robflynn.com>
parents: 1949
diff changeset
688 /* append date */
2161
757e10018950 [gaim-migrate @ 2171]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2155
diff changeset
689 strftime(tmp, 20, "%m/%d/%Y", tme);
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
690 strcpy(cpy + cnt, tmp);
592
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
691 cnt += strlen(tmp);
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
692 c++;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
693 break;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
694 case 't':
1976
24aed1c31342 [gaim-migrate @ 1986]
Rob Flynn <gaim@robflynn.com>
parents: 1949
diff changeset
695 /* append time */
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
696 strftime(tmp, 20, "%r", tme);
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
697 strcpy(cpy + cnt, tmp);
592
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
698 cnt += strlen(tmp);
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
699 c++;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
700 break;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
701 default:
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
702 cpy[cnt++] = *c;
592
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
703 }
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
704 }
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
705 break;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
706 default:
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
707 cpy[cnt++] = *c;
592
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
708 }
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
709 c++;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
710 }
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
711 cpy[cnt] = '\0';
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
712 return (cpy);
592
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
713 }
603
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
714
765
bf31bf916f53 [gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 764
diff changeset
715 char *stylize(gchar *text, int length)
764
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
716 {
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
717 gchar *buf;
2016
9a2e3902658c [gaim-migrate @ 2026]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1985
diff changeset
718 char *tmp = g_malloc(length);
764
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
719
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
720 buf = g_malloc(length);
765
bf31bf916f53 [gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 764
diff changeset
721 g_snprintf(buf, length, "%s", text);
764
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
722
831
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
723 if (font_options & OPT_FONT_BOLD) {
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
724 g_snprintf(tmp, length, "<B>%s</B>", buf);
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
725 strcpy(buf, tmp);
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
726 }
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
727
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
728 if (font_options & OPT_FONT_ITALIC) {
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
729 g_snprintf(tmp, length, "<I>%s</I>", buf);
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
730 strcpy(buf, tmp);
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
731 }
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
732
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
733 if (font_options & OPT_FONT_UNDERLINE) {
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
734 g_snprintf(tmp, length, "<U>%s</U>", buf);
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
735 strcpy(buf, tmp);
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
736 }
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
737
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
738 if (font_options & OPT_FONT_STRIKE) {
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
739 g_snprintf(tmp, length, "<S>%s</S>", buf);
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
740 strcpy(buf, tmp);
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
741 }
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
742
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
743 if (font_options & OPT_FONT_FACE) {
765
bf31bf916f53 [gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 764
diff changeset
744 g_snprintf(tmp, length, "<FONT FACE=\"%s\">%s</FONT>", fontface, buf);
bf31bf916f53 [gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 764
diff changeset
745 strcpy(buf, tmp);
764
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
746 }
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
747
1441
5c67b8794991 [gaim-migrate @ 1451]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1376
diff changeset
748 if (font_options & OPT_FONT_SIZE) {
5c67b8794991 [gaim-migrate @ 1451]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1376
diff changeset
749 g_snprintf(tmp, length, "<FONT SIZE=\"%d\">%s</FONT>", fontsize, buf);
5c67b8794991 [gaim-migrate @ 1451]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1376
diff changeset
750 strcpy(buf, tmp);
5c67b8794991 [gaim-migrate @ 1451]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1376
diff changeset
751 }
5c67b8794991 [gaim-migrate @ 1451]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1376
diff changeset
752
831
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
753 if (font_options & OPT_FONT_FGCOL) {
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
754 g_snprintf(tmp, length, "<FONT COLOR=\"#%02X%02X%02X\">%s</FONT>", fgcolor.red,
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
755 fgcolor.green, fgcolor.blue, buf);
765
bf31bf916f53 [gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 764
diff changeset
756 strcpy(buf, tmp);
764
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
757 }
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
758
831
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
759 if (font_options & OPT_FONT_BGCOL) {
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
760 g_snprintf(tmp, length, "<BODY BGCOLOR=\"#%02X%02X%02X\">%s</BODY>", bgcolor.red,
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
761 bgcolor.green, bgcolor.blue, buf);
765
bf31bf916f53 [gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 764
diff changeset
762 strcpy(buf, tmp);
764
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
763 }
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
764
2016
9a2e3902658c [gaim-migrate @ 2026]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1985
diff changeset
765 g_free(tmp);
765
bf31bf916f53 [gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 764
diff changeset
766 return buf;
bf31bf916f53 [gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 764
diff changeset
767 }
915
378c862a2381 [gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 856
diff changeset
768
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
769 void show_usage(int mode, char *name)
1009
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
770 {
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
771 switch (mode) {
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
772 case 0: /* full help text */
3474
cfbdfe334975 [gaim-migrate @ 3525]
Sean Egan <seanegan@gmail.com>
parents: 3466
diff changeset
773 printf("Gaim %s\n"
cfbdfe334975 [gaim-migrate @ 3525]
Sean Egan <seanegan@gmail.com>
parents: 3466
diff changeset
774 "Usage: %s [OPTION]...\n\n"
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
775 " -a, --acct display account editor window\n"
1254
9da444224f0e [gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
776 " -w, --away[=MESG] make away on signon (optional argument MESG specifies\n"
9da444224f0e [gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
777 " name of away message to use)\n"
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
778 " -l, --login[=NAME] automatically login (optional argument NAME specifies\n"
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
779 " account(s) to use)\n"
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
780 " -u, --user=NAME use account NAME\n"
1560
72235e3fcff6 [gaim-migrate @ 1570]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1525
diff changeset
781 " -f, --file=FILE use FILE as config\n"
2823
cd23279122ed [gaim-migrate @ 2836]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2662
diff changeset
782 " -d, --debug print debugging messages to stdout\n"
3474
cfbdfe334975 [gaim-migrate @ 3525]
Sean Egan <seanegan@gmail.com>
parents: 3466
diff changeset
783 " -v, --version display the current version and exit\n"
cfbdfe334975 [gaim-migrate @ 3525]
Sean Egan <seanegan@gmail.com>
parents: 3466
diff changeset
784 " -h, --help display this help and exit\n", VERSION, name);
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
785 break;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
786 case 1: /* short message */
3474
cfbdfe334975 [gaim-migrate @ 3525]
Sean Egan <seanegan@gmail.com>
parents: 3466
diff changeset
787 printf("Gaim %s. Try `%s -h' for more information.\n", VERSION, name);
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
788 break;
1009
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
789 }
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
790 }
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
791
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
792
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
793 /* <name> is a comma-separated list of names, or NULL
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
794 if NULL and there is at least one user defined in .gaimrc, try to login.
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
795 if not NULL, parse <name> into separate strings, look up each one in
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
796 .gaimrc and, if it's there, try to login.
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
797 returns: 0 if successful
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
798 -1 if no user was found that had a saved password
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
799 */
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
800 int do_auto_login(char *name)
1009
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
801 {
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
802 struct aim_user *u;
2042
d5033540df18 [gaim-migrate @ 2052]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2039
diff changeset
803 char **names, **n;
1009
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
804 int retval = -1;
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
805
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
806 if (name !=NULL) { /* list of names given */
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
807 names = g_strsplit(name, ",", 32);
1009
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
808 for (n = names; *n != NULL; n++) {
1030
38452403563b [gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1009
diff changeset
809 u = find_user(*n, -1);
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
810 if (u) { /* found a user */
1009
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
811 if (u->options & OPT_USR_REM_PASS) {
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
812 retval = 0;
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
813 serv_login(u);
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
814 }
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
815 }
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
816 }
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
817 g_strfreev(names);
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
818 } else { /* no name given, use default */
1009
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
819 u = (struct aim_user *)aim_users->data;
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
820 if (u->options & OPT_USR_REM_PASS) {
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
821 retval = 0;
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
822 serv_login(u);
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
823 }
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
824 }
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
825
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
826 return retval;
d496fe2614a6 [gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 976
diff changeset
827 }
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
828
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
829 GSList *message_split(char *message, int limit)
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
830 {
1100
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
831 static GSList *ret = NULL;
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
832 int lastgood = 0, curgood = 0, curpos = 0, len = strlen(message);
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
833 gboolean intag = FALSE;
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
834
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
835 if (ret) {
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
836 GSList *tmp = ret;
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
837 while (tmp) {
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
838 g_free(tmp->data);
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
839 tmp = g_slist_remove(tmp, tmp->data);
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
840 }
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
841 ret = NULL;
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
842 }
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
843
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
844 while (TRUE) {
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
845 if (lastgood >= len)
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
846 return ret;
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
847
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
848 if (len - lastgood < limit) {
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
849 ret = g_slist_append(ret, g_strdup(&message[lastgood]));
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
850 return ret;
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
851 }
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
852
1100
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
853 curgood = curpos = 0;
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
854 intag = FALSE;
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
855 while (curpos <= limit) {
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
856 if (isspace(message[curpos + lastgood]) && !intag)
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
857 curgood = curpos;
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
858 if (message[curpos + lastgood] == '<')
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
859 intag = TRUE;
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
860 if (message[curpos + lastgood] == '>')
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
861 intag = FALSE;
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
862 curpos++;
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
863 }
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
864
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
865 if (curgood) {
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
866 ret = g_slist_append(ret, g_strndup(&message[lastgood], curgood));
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
867 if (isspace(message[curgood + lastgood]))
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
868 lastgood += curgood + 1;
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
869 else
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
870 lastgood += curgood;
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
871 } else {
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
872 /* whoops, guess we have to fudge it here */
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
873 ret = g_slist_append(ret, g_strndup(&message[lastgood], limit));
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
874 lastgood += limit;
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
875 }
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
876 }
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1087
diff changeset
877 }
1191
4fd0d35826fe [gaim-migrate @ 1201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1152
diff changeset
878
1238
78c4f497db2b [gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1202
diff changeset
879 /* returns a string of the form ~/.gaim, where ~ is replaced by the user's home
78c4f497db2b [gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1202
diff changeset
880 * dir. this string should be freed after it's used. Note that there is no
78c4f497db2b [gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1202
diff changeset
881 * trailing slash after .gaim. */
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
882 gchar *gaim_user_dir()
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
883 {
1238
78c4f497db2b [gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1202
diff changeset
884 return g_strjoin(G_DIR_SEPARATOR_S, g_get_home_dir(), ".gaim", NULL);
78c4f497db2b [gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1202
diff changeset
885 }
78c4f497db2b [gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1202
diff changeset
886
1292
cb84b5c6d9ab [gaim-migrate @ 1302]
Rob Flynn <gaim@robflynn.com>
parents: 1269
diff changeset
887 /*
cb84b5c6d9ab [gaim-migrate @ 1302]
Rob Flynn <gaim@robflynn.com>
parents: 1269
diff changeset
888 * rcg10312000 This could be more robust, but it works for my current
cb84b5c6d9ab [gaim-migrate @ 1302]
Rob Flynn <gaim@robflynn.com>
parents: 1269
diff changeset
889 * goal: to remove those annoying <BR> tags. :)
cb84b5c6d9ab [gaim-migrate @ 1302]
Rob Flynn <gaim@robflynn.com>
parents: 1269
diff changeset
890 * dtf12162000 made the loop more readable. i am a neat freak. ;) */
cb84b5c6d9ab [gaim-migrate @ 1302]
Rob Flynn <gaim@robflynn.com>
parents: 1269
diff changeset
891 void strncpy_nohtml(gchar *dest, const gchar *src, size_t destsize)
cb84b5c6d9ab [gaim-migrate @ 1302]
Rob Flynn <gaim@robflynn.com>
parents: 1269
diff changeset
892 {
cb84b5c6d9ab [gaim-migrate @ 1302]
Rob Flynn <gaim@robflynn.com>
parents: 1269
diff changeset
893 gchar *ptr;
cb84b5c6d9ab [gaim-migrate @ 1302]
Rob Flynn <gaim@robflynn.com>
parents: 1269
diff changeset
894 g_snprintf(dest, destsize, "%s", src);
cb84b5c6d9ab [gaim-migrate @ 1302]
Rob Flynn <gaim@robflynn.com>
parents: 1269
diff changeset
895
1815
f15d449b3167 [gaim-migrate @ 1825]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1805
diff changeset
896 while ((ptr = strstr(dest, "<BR>")) != NULL) {
1292
cb84b5c6d9ab [gaim-migrate @ 1302]
Rob Flynn <gaim@robflynn.com>
parents: 1269
diff changeset
897 /* replace <BR> with a newline. */
cb84b5c6d9ab [gaim-migrate @ 1302]
Rob Flynn <gaim@robflynn.com>
parents: 1269
diff changeset
898 *ptr = '\n';
cb84b5c6d9ab [gaim-migrate @ 1302]
Rob Flynn <gaim@robflynn.com>
parents: 1269
diff changeset
899 memmove(ptr + 1, ptr + 4, strlen(ptr + 4) + 1);
cb84b5c6d9ab [gaim-migrate @ 1302]
Rob Flynn <gaim@robflynn.com>
parents: 1269
diff changeset
900 }
cb84b5c6d9ab [gaim-migrate @ 1302]
Rob Flynn <gaim@robflynn.com>
parents: 1269
diff changeset
901 }
cb84b5c6d9ab [gaim-migrate @ 1302]
Rob Flynn <gaim@robflynn.com>
parents: 1269
diff changeset
902
1191
4fd0d35826fe [gaim-migrate @ 1201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1152
diff changeset
903 void strncpy_withhtml(gchar *dest, const gchar *src, size_t destsize)
4fd0d35826fe [gaim-migrate @ 1201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1152
diff changeset
904 {
1202
d5146df6d2ab [gaim-migrate @ 1212]
Rob Flynn <gaim@robflynn.com>
parents: 1197
diff changeset
905 gchar *end = dest + destsize;
1191
4fd0d35826fe [gaim-migrate @ 1201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1152
diff changeset
906
1293
fbc0cbf24a62 [gaim-migrate @ 1303]
Rob Flynn <gaim@robflynn.com>
parents: 1292
diff changeset
907 while (dest < end) {
fbc0cbf24a62 [gaim-migrate @ 1303]
Rob Flynn <gaim@robflynn.com>
parents: 1292
diff changeset
908 if (*src == '\n' && dest < end - 5) {
1202
d5146df6d2ab [gaim-migrate @ 1212]
Rob Flynn <gaim@robflynn.com>
parents: 1197
diff changeset
909 strcpy(dest, "<BR>");
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
910 src++;
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
911 dest += 4;
1293
fbc0cbf24a62 [gaim-migrate @ 1303]
Rob Flynn <gaim@robflynn.com>
parents: 1292
diff changeset
912 } else {
fbc0cbf24a62 [gaim-migrate @ 1303]
Rob Flynn <gaim@robflynn.com>
parents: 1292
diff changeset
913 *dest++ = *src;
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2371
diff changeset
914 if (*src == '\0')
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2371
diff changeset
915 return;
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2371
diff changeset
916 else
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2371
diff changeset
917 src++;
1293
fbc0cbf24a62 [gaim-migrate @ 1303]
Rob Flynn <gaim@robflynn.com>
parents: 1292
diff changeset
918 }
1191
4fd0d35826fe [gaim-migrate @ 1201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1152
diff changeset
919 }
4fd0d35826fe [gaim-migrate @ 1201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1152
diff changeset
920 }
1254
9da444224f0e [gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
921
9da444224f0e [gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
922
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2823
diff changeset
923 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2823
diff changeset
924 * Like strncpy_withhtml (above), but malloc()'s the necessary space
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2823
diff changeset
925 *
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2823
diff changeset
926 * The caller is responsible for freeing the space pointed to by the
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2823
diff changeset
927 * return value.
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2823
diff changeset
928 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2823
diff changeset
929
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2823
diff changeset
930 gchar *strdup_withhtml(const gchar *src)
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2823
diff changeset
931 {
3279
86fdd015f40e [gaim-migrate @ 3297]
Sean Egan <seanegan@gmail.com>
parents: 3233
diff changeset
932 gchar *sp, *dest;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2823
diff changeset
933 gulong destsize;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2823
diff changeset
934
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2823
diff changeset
935 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2823
diff changeset
936 * All we need do is multiply the number of newlines by 3 (the
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2823
diff changeset
937 * additional length of "<BR>" over "\n"), account for the
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2823
diff changeset
938 * terminator, malloc the space and call strncpy_withhtml.
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2823
diff changeset
939 */
3279
86fdd015f40e [gaim-migrate @ 3297]
Sean Egan <seanegan@gmail.com>
parents: 3233
diff changeset
940 for(destsize = 0, sp = (gchar *)src; (sp = strchr(sp, '\n')) != NULL; ++sp, ++destsize)
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2823
diff changeset
941 ;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2823
diff changeset
942 destsize *= 3;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2823
diff changeset
943 destsize += strlen(src) + 1;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2823
diff changeset
944 dest = g_malloc(destsize);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2823
diff changeset
945 strncpy_withhtml(dest, src, destsize);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2823
diff changeset
946
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2823
diff changeset
947 return(dest);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2823
diff changeset
948 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2823
diff changeset
949
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2371
diff changeset
950 void away_on_login(char *mesg)
1254
9da444224f0e [gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
951 {
9da444224f0e [gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
952 GSList *awy = away_messages;
9da444224f0e [gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
953 struct away_message *a, *message = NULL;
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2371
diff changeset
954
1254
9da444224f0e [gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
955 if (!blist) {
9da444224f0e [gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
956 return;
9da444224f0e [gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
957 }
9da444224f0e [gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
958
9da444224f0e [gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
959 if (mesg == NULL) {
9da444224f0e [gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
960 /* Use default message */
2379
cacaf7ace3a5 [gaim-migrate @ 2392]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
961 do_away_message(NULL, default_away);
1254
9da444224f0e [gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
962 } else {
9da444224f0e [gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
963 /* Use argument */
9da444224f0e [gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
964 while (awy) {
9da444224f0e [gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
965 a = (struct away_message *)awy->data;
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2371
diff changeset
966 if (strcmp(a->name, mesg) == 0) {
1254
9da444224f0e [gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
967 message = a;
9da444224f0e [gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
968 break;
9da444224f0e [gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
969 }
9da444224f0e [gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
970 awy = awy->next;
9da444224f0e [gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
971 }
9da444224f0e [gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
972 if (message == NULL)
9da444224f0e [gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
973 message = default_away;
2379
cacaf7ace3a5 [gaim-migrate @ 2392]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
974 do_away_message(NULL, message);
1254
9da444224f0e [gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
975 }
9da444224f0e [gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
976 return;
9da444224f0e [gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
977 }
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
978
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
979 void system_log(enum log_event what, struct gaim_connection *gc, struct buddy *who, int why)
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
980 {
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
981 FILE *fd;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
982 char text[256], html[256];
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
983
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
984 if ((logging_options & why) != why)
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
985 return;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
986
1609
b4473be6fcc5 [gaim-migrate @ 1619]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1575
diff changeset
987 if (logging_options & OPT_LOG_INDIVIDUAL) {
b4473be6fcc5 [gaim-migrate @ 1619]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1575
diff changeset
988 if (why & OPT_LOG_MY_SIGNON)
b4473be6fcc5 [gaim-migrate @ 1619]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1575
diff changeset
989 fd = open_system_log_file(gc ? gc->username : NULL);
b4473be6fcc5 [gaim-migrate @ 1619]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1575
diff changeset
990 else
b4473be6fcc5 [gaim-migrate @ 1619]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1575
diff changeset
991 fd = open_system_log_file(who->name);
b4473be6fcc5 [gaim-migrate @ 1619]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1575
diff changeset
992 } else
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
993 fd = open_system_log_file(NULL);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
994
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
995 if (!fd)
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
996 return;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
997
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
998 if (why & OPT_LOG_MY_SIGNON) {
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
999 switch (what) {
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1000 case log_signon:
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1001 g_snprintf(text, sizeof(text), "+++ %s (%s) signed on @ %s",
2662
b0c5770156e1 [gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2614
diff changeset
1002 gc->username, gc->prpl->name(), full_date());
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1003 g_snprintf(html, sizeof(html), "<B>%s</B>", text);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1004 break;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1005 case log_signoff:
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1006 g_snprintf(text, sizeof(text), "+++ %s (%s) signed off @ %s",
2662
b0c5770156e1 [gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2614
diff changeset
1007 gc->username, gc->prpl->name(), full_date());
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1008 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1009 break;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1010 case log_away:
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1011 g_snprintf(text, sizeof(text), "+++ %s (%s) changed away state @ %s",
2662
b0c5770156e1 [gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2614
diff changeset
1012 gc->username, gc->prpl->name(), full_date());
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1013 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1014 break;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1015 case log_back:
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1016 g_snprintf(text, sizeof(text), "+++ %s (%s) came back @ %s",
2662
b0c5770156e1 [gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2614
diff changeset
1017 gc->username, gc->prpl->name(), full_date());
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1018 g_snprintf(html, sizeof(html), "%s", text);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1019 break;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1020 case log_idle:
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1021 g_snprintf(text, sizeof(text), "+++ %s (%s) became idle @ %s",
2662
b0c5770156e1 [gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2614
diff changeset
1022 gc->username, gc->prpl->name(), full_date());
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1023 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1024 break;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1025 case log_unidle:
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1026 g_snprintf(text, sizeof(text), "+++ %s (%s) returned from idle @ %s",
2662
b0c5770156e1 [gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2614
diff changeset
1027 gc->username, gc->prpl->name(), full_date());
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1028 g_snprintf(html, sizeof(html), "%s", text);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1029 break;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1030 case log_quit:
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1031 g_snprintf(text, sizeof(text), "+++ Program exit @ %s", full_date());
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1032 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1033 break;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1034 }
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1035 } else if (strcmp(who->name, who->show)) {
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1036 switch (what) {
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1037 case log_signon:
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1038 g_snprintf(text, sizeof(text), "%s (%s) reported that %s (%s) signed on @ %s",
2662
b0c5770156e1 [gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2614
diff changeset
1039 gc->username, gc->prpl->name(), who->show, who->name, full_date());
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1040 g_snprintf(html, sizeof(html), "<B>%s</B>", text);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1041 break;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1042 case log_signoff:
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1043 g_snprintf(text, sizeof(text), "%s (%s) reported that %s (%s) signed off @ %s",
2662
b0c5770156e1 [gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2614
diff changeset
1044 gc->username, gc->prpl->name(), who->show, who->name, full_date());
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1045 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1046 break;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1047 case log_away:
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1048 g_snprintf(text, sizeof(text), "%s (%s) reported that %s (%s) went away @ %s",
2662
b0c5770156e1 [gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2614
diff changeset
1049 gc->username, gc->prpl->name(), who->show, who->name, full_date());
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1050 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1051 break;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1052 case log_back:
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1053 g_snprintf(text, sizeof(text), "%s (%s) reported that %s (%s) came back @ %s",
2662
b0c5770156e1 [gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2614
diff changeset
1054 gc->username, gc->prpl->name(), who->show, who->name, full_date());
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1055 g_snprintf(html, sizeof(html), "%s", text);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1056 break;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1057 case log_idle:
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1058 g_snprintf(text, sizeof(text), "%s (%s) reported that %s (%s) became idle @ %s",
2662
b0c5770156e1 [gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2614
diff changeset
1059 gc->username, gc->prpl->name(), who->show, who->name, full_date());
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1060 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1061 break;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1062 case log_unidle:
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2371
diff changeset
1063 g_snprintf(text, sizeof(text),
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2371
diff changeset
1064 "%s (%s) reported that %s (%s) returned from idle @ %s", gc->username,
2662
b0c5770156e1 [gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2614
diff changeset
1065 gc->prpl->name(), who->show, who->name, full_date());
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1066 g_snprintf(html, sizeof(html), "%s", text);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1067 break;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1068 default:
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1069 fclose(fd);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1070 return;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1071 break;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1072 }
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1073 } else {
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1074 switch (what) {
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1075 case log_signon:
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1076 g_snprintf(text, sizeof(text), "%s (%s) reported that %s signed on @ %s",
2662
b0c5770156e1 [gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2614
diff changeset
1077 gc->username, gc->prpl->name(), who->name, full_date());
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1078 g_snprintf(html, sizeof(html), "<B>%s</B>", text);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1079 break;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1080 case log_signoff:
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1081 g_snprintf(text, sizeof(text), "%s (%s) reported that %s signed off @ %s",
2662
b0c5770156e1 [gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2614
diff changeset
1082 gc->username, gc->prpl->name(), who->name, full_date());
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1083 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1084 break;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1085 case log_away:
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1086 g_snprintf(text, sizeof(text), "%s (%s) reported that %s went away @ %s",
2662
b0c5770156e1 [gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2614
diff changeset
1087 gc->username, gc->prpl->name(), who->name, full_date());
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1088 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1089 break;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1090 case log_back:
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1091 g_snprintf(text, sizeof(text), "%s (%s) reported that %s came back @ %s",
2662
b0c5770156e1 [gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2614
diff changeset
1092 gc->username, gc->prpl->name(), who->name, full_date());
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1093 g_snprintf(html, sizeof(html), "%s", text);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1094 break;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1095 case log_idle:
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1096 g_snprintf(text, sizeof(text), "%s (%s) reported that %s became idle @ %s",
2662
b0c5770156e1 [gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2614
diff changeset
1097 gc->username, gc->prpl->name(), who->name, full_date());
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1098 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1099 break;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1100 case log_unidle:
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2371
diff changeset
1101 g_snprintf(text, sizeof(text),
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2371
diff changeset
1102 "%s (%s) reported that %s returned from idle @ %s", gc->username,
2662
b0c5770156e1 [gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2614
diff changeset
1103 gc->prpl->name(), who->name, full_date());
1575
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1104 g_snprintf(html, sizeof(html), "%s", text);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1105 break;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1106 default:
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1107 fclose(fd);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1108 return;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1109 break;
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1110 }
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1111 }
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1112
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1113 if (logging_options & OPT_LOG_STRIP_HTML) {
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1114 fprintf(fd, "---- %s ----\n", text);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1115 } else {
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1116 if (logging_options & OPT_LOG_INDIVIDUAL)
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1117 fprintf(fd, "<HR>%s<BR><HR><BR>\n", html);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1118 else
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1119 fprintf(fd, "%s<BR>\n", html);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1120 }
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1121
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1122 fclose(fd);
427e1409917c [gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1560
diff changeset
1123 }
1805
caa605e70917 [gaim-migrate @ 1815]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1753
diff changeset
1124
3361
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1125 char *convert_string(char *str, const char *destset, const char *srcset)
1985
008a4cc4a82c [gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1976
diff changeset
1126 {
3370
eb7b398051f2 [gaim-migrate @ 3389]
Sean Egan <seanegan@gmail.com>
parents: 3361
diff changeset
1127 #ifdef HAVE_ICONV
3361
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1128 char *buf;
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1129 iconv_t cd;
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1130 size_t insize = 0;
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1131 size_t outsize = 0;
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1132 size_t nconv = 0;
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1133 char *inptr;
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1134 char *outptr;
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1135 char *ret;
1985
008a4cc4a82c [gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1976
diff changeset
1136
3361
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1137 if (!str)
3373
0e79bf1d79ea [gaim-migrate @ 3392]
Sean Egan <seanegan@gmail.com>
parents: 3371
diff changeset
1138 return NULL;
3361
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1139 buf = g_malloc(strlen(str)*4);
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1140 insize = strlen(str);
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1141 inptr = str;
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1142 outsize = strlen(str)*4;
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1143 outptr = buf;
2039
859e9c2c5813 [gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2016
diff changeset
1144
3361
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1145 cd = iconv_open(destset, srcset);
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1146 if (cd == (iconv_t) -1) {
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1147 g_free(buf);
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1148 debug_printf("iconv_open(%s, %s) Error\n",destset, srcset);
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1149 return g_strdup(str);
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1150 }
1985
008a4cc4a82c [gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1976
diff changeset
1151
3361
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1152 nconv = iconv(cd, &inptr, &insize, &outptr, &outsize);
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1153 if (nconv == (size_t) -1) {
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1154 debug_printf("iconv Error\n");
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1155 g_free(buf);
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1156 return g_strdup(str);
2039
859e9c2c5813 [gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2016
diff changeset
1157 }
3361
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1158 *outptr = '\0';
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1159 iconv_close(cd);
2039
859e9c2c5813 [gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2016
diff changeset
1160
3361
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1161 ret = g_strdup(buf);
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1162 g_free(buf);
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1163
9bb2e904fadb [gaim-migrate @ 3380]
Sean Egan <seanegan@gmail.com>
parents: 3331
diff changeset
1164 return ret;
3370
eb7b398051f2 [gaim-migrate @ 3389]
Sean Egan <seanegan@gmail.com>
parents: 3361
diff changeset
1165 #else
eb7b398051f2 [gaim-migrate @ 3389]
Sean Egan <seanegan@gmail.com>
parents: 3361
diff changeset
1166 return g_strdup(str);
3371
363af6ce86a8 [gaim-migrate @ 3390]
Sean Egan <seanegan@gmail.com>
parents: 3370
diff changeset
1167 #endif
1985
008a4cc4a82c [gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1976
diff changeset
1168 }
008a4cc4a82c [gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1976
diff changeset
1169
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1170 void strip_linefeed(gchar *text)
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1171 {
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1172 int i, j;
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1173 gchar *text2 = g_malloc(strlen(text) + 1);
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1174
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1175 for (i = 0, j = 0; text[i]; i++)
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1176 if (text[i] != '\r')
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1177 text2[j++] = text[i];
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1178 text2[j] = '\0';
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1179
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1180 strcpy(text, text2);
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1181 g_free(text2);
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1182 }
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1183
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1184 char *add_cr(char *text)
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1185 {
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1186 char *ret = NULL;
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1187 int count = 0, i, j;
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1188
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1189 if (text[0] == '\n')
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1190 count++;
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1191 for (i = 1; i < strlen(text); i++)
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1192 if (text[i] == '\n' && text[i - 1] != '\r')
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1193 count++;
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1194
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1195 if (count == 0)
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1196 return g_strdup(text);
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1197
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1198 ret = g_malloc0(strlen(text) + count + 1);
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1199
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1200 i = 0; j = 0;
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1201 if (text[i] == '\n')
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1202 ret[j++] = '\r';
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1203 ret[j++] = text[i++];
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1204 for (; i < strlen(text); i++) {
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1205 if (text[i] == '\n' && text[i - 1] != '\r')
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1206 ret[j++] = '\r';
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1207 ret[j++] = text[i];
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1208 }
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1209
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1210 debug_printf("got: %s, leaving with %s\n", text, ret);
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1211
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1212 return ret;
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1213 }
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2596
diff changeset
1214
1805
caa605e70917 [gaim-migrate @ 1815]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1753
diff changeset
1215 time_t get_time(int year, int month, int day, int hour, int min, int sec)
caa605e70917 [gaim-migrate @ 1815]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1753
diff changeset
1216 {
caa605e70917 [gaim-migrate @ 1815]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1753
diff changeset
1217 struct tm tm;
caa605e70917 [gaim-migrate @ 1815]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1753
diff changeset
1218
caa605e70917 [gaim-migrate @ 1815]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1753
diff changeset
1219 tm.tm_year = year - 1900;
caa605e70917 [gaim-migrate @ 1815]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1753
diff changeset
1220 tm.tm_mon = month - 1;
caa605e70917 [gaim-migrate @ 1815]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1753
diff changeset
1221 tm.tm_mday = day;
caa605e70917 [gaim-migrate @ 1815]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1753
diff changeset
1222 tm.tm_hour = hour;
caa605e70917 [gaim-migrate @ 1815]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1753
diff changeset
1223 tm.tm_min = min;
caa605e70917 [gaim-migrate @ 1815]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1753
diff changeset
1224 tm.tm_sec = sec >= 0 ? sec : time(NULL) % 60;
caa605e70917 [gaim-migrate @ 1815]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1753
diff changeset
1225 return mktime(&tm);
caa605e70917 [gaim-migrate @ 1815]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1753
diff changeset
1226 }
3230
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1227
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1228 /*
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1229 * Like mkstemp() but returns a file pointer, uses a pre-set template,
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1230 * uses the semantics of tempnam() for the directory to use and allocates
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1231 * the space for the filepath.
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1232 *
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1233 * Caller is responsible for closing the file and removing it when done,
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1234 * as well as freeing the space pointed-to by "path" with g_free().
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1235 *
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1236 * Returns NULL on failure and cleans up after itself if so.
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1237 */
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1238 static const char *gaim_mkstemp_templ = {"gaimXXXXXX"};
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1239
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1240 FILE *gaim_mkstemp(gchar **fpath)
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1241 {
3466
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3457
diff changeset
1242 const gchar *tmpdir;
3230
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1243 int fd;
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1244 FILE *fp = NULL;
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1245
3233
96e215745dc0 [gaim-migrate @ 3250]
Jim Seymour <jseymour>
parents: 3232
diff changeset
1246 if((tmpdir = g_get_tmp_dir()) != NULL) {
3230
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1247 if((*fpath = g_strdup_printf("%s/%s", tmpdir, gaim_mkstemp_templ)) != NULL) {
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1248 if((fd = mkstemp(*fpath)) == -1) {
3232
cf460a8c859c [gaim-migrate @ 3249]
Jim Seymour <jseymour>
parents: 3230
diff changeset
1249 debug_printf("Error: Couldn't make \"%s\", error: %d\n", *fpath, errno);
3230
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1250 } else {
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1251 if((fp = fdopen(fd, "r+")) == NULL) {
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1252 close(fd);
3232
cf460a8c859c [gaim-migrate @ 3249]
Jim Seymour <jseymour>
parents: 3230
diff changeset
1253 debug_printf("Error: Couldn't fdopen(), error: %d\n", errno);
3230
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1254 }
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1255 }
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1256 if(!fp) {
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1257 g_free(*fpath);
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1258 *fpath = NULL;
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1259 }
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1260 }
3233
96e215745dc0 [gaim-migrate @ 3250]
Jim Seymour <jseymour>
parents: 3232
diff changeset
1261 } else {
96e215745dc0 [gaim-migrate @ 3250]
Jim Seymour <jseymour>
parents: 3232
diff changeset
1262 debug_printf("Error: g_get_tmp_dir() failed in gaim_mkstemp()!\n");
3230
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1263 }
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1264
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1265 return fp;
d05dc05bde8a [gaim-migrate @ 3247]
Jim Seymour <jseymour>
parents: 3153
diff changeset
1266 }