Mercurial > pidgin.yaz
annotate src/util.c @ 2155:3619cbbd6bdf
[gaim-migrate @ 2165]
this warning was getting annoying.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Wed, 22 Aug 2001 22:25:17 +0000 |
parents | b66aca8e8dce |
children | 757e10018950 |
rev | line source |
---|---|
1 | 1 /* |
2 * gaim | |
3 * | |
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 */ | |
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 | 25 #include <unistd.h> |
26 #include <errno.h> | |
27 #include <stdio.h> | |
28 #include <stdlib.h> | |
29 #include <sys/time.h> | |
30 #include <sys/types.h> | |
31 #include <sys/stat.h> | |
32 #include <string.h> | |
33 #include <sys/wait.h> | |
34 #include <gtk/gtk.h> | |
210
ec0686b3b03f
[gaim-migrate @ 220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
209
diff
changeset
|
35 #include <ctype.h> |
1376
730a1a19b4cc
[gaim-migrate @ 1386]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1293
diff
changeset
|
36 #include <math.h> |
1 | 37 #include <pixmaps/aimicon.xpm> |
38 #include "gaim.h" | |
1575
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
39 #include "prpl.h" |
1 | 40 |
41 static GdkPixmap *icon_pm = NULL; | |
42 static GdkBitmap *icon_bm = NULL; | |
43 | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
44 char *full_date() |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
45 { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
46 char *date; |
70 | 47 time_t tme; |
48 | |
49 time(&tme); | |
50 date = ctime(&tme); | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
51 date[strlen(date) - 1] = '\0'; |
70 | 52 return date; |
53 } | |
54 | |
1 | 55 gint badchar(char c) |
56 { | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
57 switch (c) { |
970 | 58 case ' ': |
59 case ',': | |
60 case '(': | |
61 case ')': | |
62 case '\0': | |
976
2586b2a3725e
[gaim-migrate @ 986]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
970
diff
changeset
|
63 case '\n': |
970 | 64 case '<': |
65 case '>': | |
1706
e6671b80a1f2
[gaim-migrate @ 1716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1622
diff
changeset
|
66 case '"': |
413
7ea55575cc01
[gaim-migrate @ 423]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
373
diff
changeset
|
67 return 1; |
970 | 68 default: |
69 return 0; | |
70 } | |
1 | 71 } |
72 | |
73 | |
1376
730a1a19b4cc
[gaim-migrate @ 1386]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1293
diff
changeset
|
74 gchar *sec_to_text(guint sec) |
1 | 75 { |
1826
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
76 int daze, hrs, min; |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
77 char *ret = g_malloc(256); |
1 | 78 |
1826
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
79 daze = sec / (60 * 60 * 24); |
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
80 hrs = (sec % (60 * 60 * 24)) / (60 * 60); |
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
81 min = (sec % (60 * 60)) / 60; |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
82 sec = min % 60; |
1 | 83 |
1826
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
84 if (daze) { |
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
85 if (hrs || min) { |
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
86 if (hrs) { |
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
87 if (min) { |
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
88 g_snprintf(ret, 256, |
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
89 "%d day%s, %d hour%s, %d minute%s.", |
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
90 daze, daze == 1 ? "" : "s", |
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
91 hrs, hrs == 1 ? "" : "s", |
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
92 min, min == 1 ? "" : "s"); |
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
93 } else { |
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
94 g_snprintf(ret, 256, |
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
95 "%d day%s, %d hour%s.", |
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
96 daze, daze == 1 ? "" : "s", |
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
97 hrs, hrs == 1 ? "" : "s"); |
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, |
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
101 "%d day%s, %d minute%s.", |
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
102 daze, daze == 1 ? "" : "s", |
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
103 min, min == 1 ? "" : "s"); |
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
104 } |
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
105 } else |
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
106 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
|
107 } else { |
1826
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
108 if (hrs) { |
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
109 if (min) { |
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
110 g_snprintf(ret, 256, |
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
111 "%d hour%s, %d minute%s.", |
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
112 hrs, hrs == 1 ? "" : "s", |
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
113 min, min == 1 ? "" : "s"); |
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
114 } else { |
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
115 g_snprintf(ret, 256, "%d hour%s.", hrs, hrs == 1 ? "" : "s"); |
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
116 } |
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
117 } else { |
7f889cdfa03e
[gaim-migrate @ 1836]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
118 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
|
119 } |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
120 } |
1 | 121 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
122 return ret; |
1 | 123 } |
124 | |
125 gint linkify_text(char *text) | |
126 { | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
127 char *c, *t; |
1622
1acef460964a
[gaim-migrate @ 1632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1609
diff
changeset
|
128 char *cpy = g_malloc(strlen(text) * 3 + 1); |
1acef460964a
[gaim-migrate @ 1632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1609
diff
changeset
|
129 char url_buf[BUF_LEN * 4]; |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
130 int cnt = 0; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
131 /* Assumes you have a buffer able to cary at least BUF_LEN * 2 bytes */ |
1 | 132 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
133 strncpy(cpy, text, strlen(text)); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
134 cpy[strlen(text)] = 0; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
135 c = cpy; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
136 while (*c) { |
2048
3366311426df
[gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2043
diff
changeset
|
137 if (!g_strncasecmp(c, "<A", 2)) { |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
138 while (1) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
139 if (!strncasecmp(c, "/A>", 3)) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
140 break; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
141 } |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
142 text[cnt++] = *c; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
143 c++; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
144 if (!(*c)) |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
145 break; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
146 } |
2048
3366311426df
[gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2043
diff
changeset
|
147 } 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
|
148 t = c; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
149 while (1) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
150 if (badchar(*t)) { |
925 | 151 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
152 if (*(t) == ',' && (*(t + 1) != ' ')) { |
925 | 153 t++; |
154 continue; | |
155 } | |
156 | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
157 if (*(t - 1) == '.') |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
158 t--; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
159 strncpy(url_buf, c, t - c); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
160 url_buf[t - c] = 0; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
161 cnt += |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
162 g_snprintf(&text[cnt++], 1024, "<A HREF=\"%s\">%s</A>", |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
163 url_buf, url_buf); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
164 cnt--; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
165 c = t; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
166 break; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
167 } |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
168 if (!t) |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
169 break; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
170 t++; |
1 | 171 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
172 } |
2048
3366311426df
[gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2043
diff
changeset
|
173 } else if (!g_strncasecmp(c, "www.", 4)) { |
3366311426df
[gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2043
diff
changeset
|
174 if (g_strncasecmp(c, "www..", 5)) { |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
175 t = c; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
176 while (1) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
177 if (badchar(*t)) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
178 if (t - c == 4) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
179 break; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
180 } |
925 | 181 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
182 if (*(t) == ',' && (*(t + 1) != ' ')) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
183 t++; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
184 continue; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
185 } |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
186 |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
187 if (*(t - 1) == '.') |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
188 t--; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
189 strncpy(url_buf, c, t - c); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
190 url_buf[t - c] = 0; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
191 cnt += |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
192 g_snprintf(&text[cnt++], 1024, |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
193 "<A HREF=\"http://%s\">%s</A>", url_buf, |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
194 url_buf); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
195 cnt--; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
196 c = t; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
197 break; |
925 | 198 } |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
199 if (!t) |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
200 break; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
201 t++; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
202 } |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
203 } |
2048
3366311426df
[gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2043
diff
changeset
|
204 } else if (!g_strncasecmp(c, "ftp://", 6)) { |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
205 t = c; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
206 while (1) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
207 if (badchar(*t)) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
208 if (*(t - 1) == '.') |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
209 t--; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
210 strncpy(url_buf, c, t - c); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
211 url_buf[t - c] = 0; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
212 cnt += |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
213 g_snprintf(&text[cnt++], 1024, "<A HREF=\"%s\">%s</A>", |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
214 url_buf, url_buf); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
215 cnt--; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
216 c = t; |
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) |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
220 break; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
221 t++; |
1 | 222 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
223 } |
2048
3366311426df
[gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2043
diff
changeset
|
224 } else if (!g_strncasecmp(c, "ftp.", 4)) { |
3366311426df
[gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2043
diff
changeset
|
225 if (g_strncasecmp(c, "ftp..", 5)) { |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
226 t = c; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
227 while (1) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
228 if (badchar(*t)) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
229 if (t - c == 4) { |
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 } |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
232 if (*(t - 1) == '.') |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
233 t--; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
234 strncpy(url_buf, c, t - c); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
235 url_buf[t - c] = 0; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
236 cnt += |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
237 g_snprintf(&text[cnt++], 1024, |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
238 "<A HREF=\"ftp://%s\">%s</A>", url_buf, |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
239 url_buf); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
240 cnt--; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
241 c = t; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
242 break; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
243 } |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
244 if (!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 t++; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
247 } |
924 | 248 } |
2048
3366311426df
[gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2043
diff
changeset
|
249 } else if (!g_strncasecmp(c, "mailto:", 7)) { |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
250 t = c; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
251 while (1) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
252 if (badchar(*t)) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
253 if (*(t - 1) == '.') |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
254 t--; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
255 strncpy(url_buf, c, t - c); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
256 url_buf[t - c] = 0; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
257 cnt += |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
258 g_snprintf(&text[cnt++], 1024, "<A HREF=\"%s\">%s</A>", |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
259 url_buf, url_buf); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
260 cnt--; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
261 c = t; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
262 break; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
263 } |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
264 if (!t) |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
265 break; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
266 t++; |
1 | 267 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
268 } |
2048
3366311426df
[gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2043
diff
changeset
|
269 } else if (c != cpy && !g_strncasecmp(c, "@", 1)) { |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
270 char *tmp; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
271 int flag; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
272 int len = 0; |
924 | 273 char illegal_chars[] = "!@#$%^&*()[]{}/\\<>\":;\0"; |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
274 url_buf[0] = 0; |
1 | 275 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
276 if (*(c - 1) == ' ' || *(c + 1) == ' ' || rindex(illegal_chars, *(c + 1)) |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
277 || *(c + 1) == 13 || *(c + 1) == 10) |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
278 flag = 0; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
279 else |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
280 flag = 1; |
1 | 281 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
282 t = c; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
283 while (flag) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
284 if (badchar(*t)) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
285 cnt -= (len - 1); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
286 break; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
287 } else { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
288 len++; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
289 tmp = g_malloc(len + 1); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
290 tmp[len] = 0; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
291 tmp[0] = *t; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
292 strncpy(tmp + 1, url_buf, len - 1); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
293 strcpy(url_buf, tmp); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
294 url_buf[len] = 0; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
295 g_free(tmp); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
296 t--; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
297 if (t < cpy) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
298 cnt = 0; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
299 break; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
300 } |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
301 } |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
302 } |
1 | 303 |
304 | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
305 t = c + 1; |
1 | 306 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
307 while (flag) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
308 if (badchar(*t)) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
309 if (*(t - 1) == '.') |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
310 t--; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
311 cnt += |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
312 g_snprintf(&text[cnt++], 1024, |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
313 "<A HREF=\"mailto:%s\">%s</A>", url_buf, url_buf); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
314 text[cnt] = 0; |
1 | 315 |
316 | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
317 cnt--; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
318 c = t; |
1 | 319 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
320 break; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
321 } else { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
322 strncat(url_buf, t, 1); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
323 len++; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
324 url_buf[len] = 0; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
325 } |
1 | 326 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
327 t++; |
1 | 328 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
329 } |
1 | 330 |
331 | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
332 } |
1 | 333 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
334 if (*c == 0) |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
335 break; |
1 | 336 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
337 text[cnt++] = *c; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
338 c++; |
1 | 339 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
340 } |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
341 text[cnt] = 0; |
845
647b110f7a1a
[gaim-migrate @ 855]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
831
diff
changeset
|
342 g_free(cpy); |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
343 return cnt; |
1 | 344 } |
345 | |
346 | |
1575
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
347 FILE *open_gaim_log_file(char *name, int *flag) |
1 | 348 { |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
349 char *buf; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
350 char *buf2; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
351 char log_all_file[256]; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
352 struct stat st; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
353 FILE *fd; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
354 int res; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
355 gchar *gaim_dir; |
1 | 356 |
79 | 357 buf = g_malloc(BUF_LONG); |
358 buf2 = g_malloc(BUF_LONG); | |
1238
78c4f497db2b
[gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1202
diff
changeset
|
359 gaim_dir = gaim_user_dir(); |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
360 |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
361 /* Dont log yourself */ |
1238
78c4f497db2b
[gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1202
diff
changeset
|
362 strncpy(log_all_file, gaim_dir, 256); |
1 | 363 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
364 stat(log_all_file, &st); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
365 if (!S_ISDIR(st.st_mode)) |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
366 unlink(log_all_file); |
1 | 367 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
368 fd = fopen(log_all_file, "r"); |
1 | 369 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
370 if (!fd) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
371 res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
372 if (res < 0) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
373 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
|
374 log_all_file); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
375 do_error_dialog(buf, "Error!"); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
376 g_free(buf); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
377 g_free(buf2); |
1575
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
378 g_free(gaim_dir); |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
379 return NULL; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
380 } |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
381 } else |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
382 fclose(fd); |
1 | 383 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
384 g_snprintf(log_all_file, 256, "%s/logs", gaim_dir); |
1 | 385 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
386 if (stat(log_all_file, &st) < 0) |
1575
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
387 *flag = 1; |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
388 if (!S_ISDIR(st.st_mode)) |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
389 unlink(log_all_file); |
1 | 390 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
391 fd = fopen(log_all_file, "r"); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
392 if (!fd) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
393 res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
394 if (res < 0) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
395 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
|
396 log_all_file); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
397 do_error_dialog(buf, "Error!"); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
398 g_free(buf); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
399 g_free(buf2); |
1575
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
400 g_free(gaim_dir); |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
401 return NULL; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
402 } |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
403 } else |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
404 fclose(fd); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
405 |
1 | 406 |
407 | |
1575
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
408 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
|
409 if (stat(log_all_file, &st) < 0) |
1575
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
410 *flag = 1; |
1 | 411 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
412 debug_printf("Logging to: \"%s\"\n", log_all_file); |
1 | 413 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
414 fd = fopen(log_all_file, "a"); |
1 | 415 |
1575
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
416 g_free(buf); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
417 g_free(buf2); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
418 g_free(gaim_dir); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
419 return fd; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
420 } |
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 FILE *open_log_file(char *name) |
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 struct stat st; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
425 char realname[256]; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
426 struct log_conversation *l; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
427 FILE *fd; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
428 int flag = 0; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
429 |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
430 if (!(logging_options & OPT_LOG_ALL)) { |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
431 |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
432 l = find_log_info(name); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
433 if (!l) |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
434 return NULL; |
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 if (stat(l->filename, &st) < 0) |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
437 flag = 1; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
438 |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
439 fd = fopen(l->filename, "a"); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
440 |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
441 if (flag) { /* is a new file */ |
1856 | 442 if (logging_options & OPT_LOG_STRIP_HTML) { |
443 fprintf(fd, "IM Sessions with %s\n", name); | |
444 }else { | |
445 fprintf(fd, "<HTML><HEAD><TITLE>"); | |
446 fprintf(fd, "IM Sessions with %s", name); | |
447 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"ffffff\">\n"); | |
448 } | |
1575
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
449 } |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
450 |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
451 return fd; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
452 } |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
453 |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
454 g_snprintf(realname, sizeof(realname), "%s.log", normalize(name)); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
455 fd = open_gaim_log_file(realname, &flag); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
456 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
457 if (fd && flag) { /* is a new file */ |
1856 | 458 if (logging_options & OPT_LOG_STRIP_HTML) { |
459 fprintf(fd, "IM Sessions with %s\n", name); | |
460 }else { | |
461 fprintf(fd, "<HTML><HEAD><TITLE>"); | |
462 fprintf(fd, "IM Sessions with %s", name); | |
463 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"ffffff\">\n"); | |
464 } | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
465 } |
25 | 466 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
467 return fd; |
1 | 468 } |
469 | |
1575
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
470 FILE *open_system_log_file(char *name) |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
471 { |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
472 int x; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
473 |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
474 if (name) |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
475 return open_log_file(name); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
476 else |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
477 return open_gaim_log_file("system", &x); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
478 } |
1 | 479 |
254
fa67d29b53d5
[gaim-migrate @ 264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
480 /* we only need this for TOC, because messages must be escaped */ |
1 | 481 int escape_message(char *msg) |
482 { | |
483 char *c, *cpy; | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
484 int cnt = 0; |
1 | 485 /* Assumes you have a buffer able to cary at least BUF_LEN * 2 bytes */ |
486 if (strlen(msg) > BUF_LEN) { | |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1238
diff
changeset
|
487 debug_printf("Warning: truncating message to 2048 bytes\n"); |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
488 msg[2047] = '\0'; |
1 | 489 } |
1238
78c4f497db2b
[gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1202
diff
changeset
|
490 |
1 | 491 cpy = g_strdup(msg); |
492 c = cpy; | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
493 while (*c) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
494 switch (*c) { |
1 | 495 case '$': |
496 case '[': | |
497 case ']': | |
498 case '(': | |
499 case ')': | |
500 case '#': | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
501 msg[cnt++] = '\\'; |
1 | 502 /* Fall through */ |
503 default: | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
504 msg[cnt++] = *c; |
1 | 505 } |
506 c++; | |
507 } | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
508 msg[cnt] = '\0'; |
1 | 509 g_free(cpy); |
510 return cnt; | |
511 } | |
512 | |
254
fa67d29b53d5
[gaim-migrate @ 264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
513 /* we don't need this for oscar either */ |
1 | 514 int escape_text(char *msg) |
515 { | |
516 char *c, *cpy; | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
517 int cnt = 0; |
79 | 518 /* Assumes you have a buffer able to cary at least BUF_LEN * 4 bytes */ |
1 | 519 if (strlen(msg) > BUF_LEN) { |
520 fprintf(stderr, "Warning: truncating message to 2048 bytes\n"); | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
521 msg[2047] = '\0'; |
1 | 522 } |
1238
78c4f497db2b
[gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1202
diff
changeset
|
523 |
1 | 524 cpy = g_strdup(msg); |
525 c = cpy; | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
526 while (*c) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
527 switch (*c) { |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
927
diff
changeset
|
528 case '\n': |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
927
diff
changeset
|
529 msg[cnt++] = '<'; |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
927
diff
changeset
|
530 msg[cnt++] = 'B'; |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
927
diff
changeset
|
531 msg[cnt++] = 'R'; |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
927
diff
changeset
|
532 msg[cnt++] = '>'; |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
927
diff
changeset
|
533 break; |
1 | 534 case '{': |
535 case '}': | |
536 case '\\': | |
537 case '"': | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
538 msg[cnt++] = '\\'; |
1 | 539 /* Fall through */ |
540 default: | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
541 msg[cnt++] = *c; |
1 | 542 } |
543 c++; | |
544 } | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
545 msg[cnt] = '\0'; |
1 | 546 g_free(cpy); |
547 return cnt; | |
548 } | |
549 | |
1945
ee1adc242b11
[gaim-migrate @ 1955]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1920
diff
changeset
|
550 char *escape_text2(const char *msg) |
1 | 551 { |
1238
78c4f497db2b
[gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1202
diff
changeset
|
552 char *c, *cpy; |
1 | 553 char *woo; |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
554 int cnt = 0; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
555 /* Assumes you have a buffer able to cary at least BUF_LEN * 2 bytes */ |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
556 if (strlen(msg) > BUF_LEN) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
557 fprintf(stderr, "Warning: truncating message to 2048 bytes\n"); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
558 } |
1 | 559 |
1521
ba83e9e2fd9b
[gaim-migrate @ 1531]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1441
diff
changeset
|
560 woo = malloc(strlen(msg) * 4 + 1); |
1946
4e93ea84f7dd
[gaim-migrate @ 1956]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1945
diff
changeset
|
561 cpy = g_strndup(msg, 2048); |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
562 c = cpy; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
563 while (*c) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
564 switch (*c) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
565 case '\n': |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
566 woo[cnt++] = '<'; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
567 woo[cnt++] = 'B'; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
568 woo[cnt++] = 'R'; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
569 woo[cnt++] = '>'; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
570 break; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
571 case '{': |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
572 case '}': |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
573 case '\\': |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
574 case '"': |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
575 woo[cnt++] = '\\'; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
576 /* Fall through */ |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
577 default: |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
578 woo[cnt++] = *c; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
579 } |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
580 c++; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
581 } |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
582 woo[cnt] = '\0'; |
26 | 583 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
584 g_free(cpy); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
585 return woo; |
1 | 586 } |
587 | |
588 | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
589 char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" "0123456789+/"; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
590 |
1 | 591 |
1920
5bed3bc833b5
[gaim-migrate @ 1930]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1878
diff
changeset
|
592 char *tobase64(const char *text) |
1 | 593 { |
594 char *out = NULL; | |
1920
5bed3bc833b5
[gaim-migrate @ 1930]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1878
diff
changeset
|
595 const char *c; |
1 | 596 unsigned int tmp = 0; |
597 int len = 0, n = 0; | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
598 |
1 | 599 c = text; |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
600 |
1829
bdfb37ae28b4
[gaim-migrate @ 1839]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1826
diff
changeset
|
601 while (*c) { |
1 | 602 tmp = tmp << 8; |
603 tmp += *c; | |
604 n++; | |
605 | |
606 if (n == 3) { | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
607 out = g_realloc(out, len + 4); |
1 | 608 out[len] = alphabet[(tmp >> 18) & 0x3f]; |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
609 out[len + 1] = alphabet[(tmp >> 12) & 0x3f]; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
610 out[len + 2] = alphabet[(tmp >> 6) & 0x3f]; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
611 out[len + 3] = alphabet[tmp & 0x3f]; |
1 | 612 len += 4; |
613 tmp = 0; | |
614 n = 0; | |
615 } | |
616 c++; | |
617 } | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
618 switch (n) { |
1238
78c4f497db2b
[gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1202
diff
changeset
|
619 |
1 | 620 case 2: |
1829
bdfb37ae28b4
[gaim-migrate @ 1839]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1826
diff
changeset
|
621 tmp <<= 8; |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
622 out = g_realloc(out, len + 5); |
1829
bdfb37ae28b4
[gaim-migrate @ 1839]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1826
diff
changeset
|
623 out[len] = alphabet[(tmp >> 18) & 0x3f]; |
bdfb37ae28b4
[gaim-migrate @ 1839]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1826
diff
changeset
|
624 out[len + 1] = alphabet[(tmp >> 12) & 0x3f]; |
bdfb37ae28b4
[gaim-migrate @ 1839]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1826
diff
changeset
|
625 out[len + 2] = alphabet[(tmp >> 6) & 0x3f]; |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
626 out[len + 3] = '='; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
627 out[len + 4] = 0; |
1238
78c4f497db2b
[gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1202
diff
changeset
|
628 break; |
1 | 629 case 1: |
1829
bdfb37ae28b4
[gaim-migrate @ 1839]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1826
diff
changeset
|
630 tmp <<= 16; |
1843
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1829
diff
changeset
|
631 out = g_realloc(out, len + 5); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1829
diff
changeset
|
632 out[len] = alphabet[(tmp >> 18) & 0x3f]; |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1829
diff
changeset
|
633 out[len + 1] = alphabet[(tmp >> 12) & 0x3f]; |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
634 out[len + 2] = '='; |
1843
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1829
diff
changeset
|
635 out[len + 3] = '='; |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1829
diff
changeset
|
636 out[len + 4] = 0; |
1238
78c4f497db2b
[gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1202
diff
changeset
|
637 break; |
1 | 638 case 0: |
1843
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1829
diff
changeset
|
639 out = g_realloc(out, len + 1); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1829
diff
changeset
|
640 out[len] = 0; |
1 | 641 break; |
642 } | |
643 return out; | |
644 } | |
645 | |
646 | |
1920
5bed3bc833b5
[gaim-migrate @ 1930]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1878
diff
changeset
|
647 void frombase64(const char *text, char **data, int *size) |
1 | 648 { |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
649 char *out = NULL; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
650 char tmp = 0; |
1920
5bed3bc833b5
[gaim-migrate @ 1930]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1878
diff
changeset
|
651 const char *c; |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
652 gint32 tmp2 = 0; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
653 int len = 0, n = 0; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
654 |
1920
5bed3bc833b5
[gaim-migrate @ 1930]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1878
diff
changeset
|
655 if (!text || !data) |
5bed3bc833b5
[gaim-migrate @ 1930]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1878
diff
changeset
|
656 return; |
5bed3bc833b5
[gaim-migrate @ 1930]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1878
diff
changeset
|
657 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
658 c = text; |
1 | 659 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
660 while (*c) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
661 if (*c >= 'A' && *c <= 'Z') { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
662 tmp = *c - 'A'; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
663 } else if (*c >= 'a' && *c <= 'z') { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
664 tmp = 26 + (*c - 'a'); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
665 } else if (*c >= '0' && *c <= 57) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
666 tmp = 52 + (*c - '0'); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
667 } else if (*c == '+') { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
668 tmp = 62; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
669 } else if (*c == '/') { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
670 tmp = 63; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
671 } else if (*c == '=') { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
672 if (n == 3) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
673 out = g_realloc(out, len + 2); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
674 out[len] = (char)(tmp2 >> 10) & 0xff; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
675 len++; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
676 out[len] = (char)(tmp2 >> 2) & 0xff; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
677 len++; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
678 } else if (n == 2) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
679 out = g_realloc(out, len + 1); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
680 out[len] = (char)(tmp2 >> 4) & 0xff; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
681 len++; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
682 } |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
683 break; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
684 } |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
685 tmp2 = ((tmp2 << 6) | (tmp & 0xff)); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
686 n++; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
687 if (n == 4) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
688 out = g_realloc(out, len + 3); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
689 out[len] = (char)((tmp2 >> 16) & 0xff); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
690 len++; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
691 out[len] = (char)((tmp2 >> 8) & 0xff); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
692 len++; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
693 out[len] = (char)(tmp2 & 0xff); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
694 len++; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
695 tmp2 = 0; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
696 n = 0; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
697 } |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
698 c++; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
699 } |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
700 |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
701 out = g_realloc(out, len + 1); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
702 out[len] = 0; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
703 |
1920
5bed3bc833b5
[gaim-migrate @ 1930]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1878
diff
changeset
|
704 *data = out; |
5bed3bc833b5
[gaim-migrate @ 1930]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1878
diff
changeset
|
705 if (size) |
5bed3bc833b5
[gaim-migrate @ 1930]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1878
diff
changeset
|
706 *size = len; |
1 | 707 } |
708 | |
709 | |
710 char *normalize(const char *s) | |
711 { | |
712 static char buf[BUF_LEN]; | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
713 char *t, *u; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
714 int x = 0; |
1 | 715 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
716 g_return_val_if_fail((s != NULL), NULL); |
26 | 717 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
718 u = t = g_strdup(s); |
1 | 719 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
720 strcpy(t, s); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
721 g_strdown(t); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
722 |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
723 while (*t && (x < BUF_LEN - 1)) { |
1 | 724 if (*t != ' ') { |
725 buf[x] = *t; | |
726 x++; | |
727 } | |
728 t++; | |
729 } | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
730 buf[x] = '\0'; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
731 g_free(u); |
1 | 732 return buf; |
733 } | |
734 | |
735 char *date() | |
736 { | |
737 static char date[80]; | |
738 time_t tme; | |
739 time(&tme); | |
740 strftime(date, sizeof(date), "%H:%M:%S", localtime(&tme)); | |
741 return date; | |
742 } | |
743 | |
744 | |
745 gint clean_pid(void *dummy) | |
746 { | |
747 int status; | |
748 pid_t pid; | |
749 | |
750 pid = waitpid(-1, &status, WNOHANG); | |
751 | |
752 if (pid == 0) | |
753 return TRUE; | |
754 | |
755 return FALSE; | |
756 } | |
757 | |
758 void aol_icon(GdkWindow *w) | |
759 { | |
760 #ifndef _WIN32 | |
761 if (icon_pm == NULL) { | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
762 icon_pm = gdk_pixmap_create_from_xpm_d(w, &icon_bm, NULL, (gchar **)aimicon_xpm); |
1 | 763 } |
764 gdk_window_set_icon(w, NULL, icon_pm, icon_bm); | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
765 if (mainwindow) |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
766 gdk_window_set_group(w, mainwindow->window); |
1 | 767 #endif |
768 } | |
769 | |
1030
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1009
diff
changeset
|
770 struct aim_user *find_user(const char *name, int protocol) |
1 | 771 { |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
772 char *who = g_strdup(normalize(name)); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
773 GList *usr = aim_users; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
774 struct aim_user *u; |
1 | 775 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
776 while (usr) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
777 u = (struct aim_user *)usr->data; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
778 if (!strcmp(normalize(u->username), who)) { |
1030
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1009
diff
changeset
|
779 if (protocol != -1) { |
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1009
diff
changeset
|
780 if (u->protocol == protocol) { |
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1009
diff
changeset
|
781 g_free(who); |
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1009
diff
changeset
|
782 return u; |
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1009
diff
changeset
|
783 } |
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1009
diff
changeset
|
784 } else { |
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1009
diff
changeset
|
785 g_free(who); |
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1009
diff
changeset
|
786 return u; |
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1009
diff
changeset
|
787 } |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
788 |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
789 } |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
790 usr = usr->next; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
791 } |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
792 g_free(who); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
793 return NULL; |
1 | 794 } |
180 | 795 |
206 | 796 |
592
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
797 /* 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
|
798 or time */ |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
799 char *away_subs(char *msg, char *name) |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
800 { |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
801 char *c; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
802 static char cpy[BUF_LONG]; |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
803 int cnt = 0; |
592
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
804 time_t t = time(0); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
805 struct tm *tme = localtime(&t); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
806 char tmp[20]; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
807 |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
808 cpy[0] = '\0'; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
809 c = msg; |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
810 while (*c) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
811 switch (*c) { |
592
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
812 case '%': |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
813 if (*(c + 1)) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
814 switch (*(c + 1)) { |
592
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
815 case 'n': |
1976 | 816 /* append name */ |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
817 strcpy(cpy + cnt, name); |
592
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
818 cnt += strlen(name); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
819 c++; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
820 break; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
821 case 'd': |
1976 | 822 /* append date */ |
2155
3619cbbd6bdf
[gaim-migrate @ 2165]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
823 strftime(tmp, 20, "%m%d%Y", tme); |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
824 strcpy(cpy + cnt, tmp); |
592
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
825 cnt += strlen(tmp); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
826 c++; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
827 break; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
828 case 't': |
1976 | 829 /* append time */ |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
830 strftime(tmp, 20, "%r", tme); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
831 strcpy(cpy + cnt, tmp); |
592
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
832 cnt += strlen(tmp); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
833 c++; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
834 break; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
835 default: |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
836 cpy[cnt++] = *c; |
592
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
837 } |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
838 } |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
839 break; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
840 default: |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
841 cpy[cnt++] = *c; |
592
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
842 } |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
843 c++; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
844 } |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
845 cpy[cnt] = '\0'; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
846 return (cpy); |
592
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
847 } |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
848 |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
849 GtkWidget *picture_button(GtkWidget *window, char *text, char **xpm) |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
850 { |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
851 GtkWidget *button; |
619 | 852 GtkWidget *button_box, *button_box_2, *button_box_3; |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
853 GtkWidget *label; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
854 GdkBitmap *mask; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
855 GdkPixmap *pm; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
856 GtkWidget *pixmap; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
857 |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
858 button = gtk_button_new(); |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
859 if (display_options & OPT_DISP_COOL_LOOK) |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
860 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
861 |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
862 button_box = gtk_hbox_new(FALSE, 5); |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
863 gtk_container_add(GTK_CONTAINER(button), button_box); |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
864 |
619 | 865 button_box_2 = gtk_hbox_new(FALSE, 0); |
866 button_box_3 = gtk_hbox_new(FALSE, 0); | |
867 gtk_box_pack_start(GTK_BOX(button_box), button_box_2, TRUE, TRUE, 0); | |
868 gtk_box_pack_start(GTK_BOX(button_box), button_box_3, TRUE, TRUE, 0); | |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
869 pm = gdk_pixmap_create_from_xpm_d(window->window, &mask, NULL, xpm); |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
870 pixmap = gtk_pixmap_new(pm, mask); |
619 | 871 gtk_box_pack_end(GTK_BOX(button_box_2), pixmap, FALSE, FALSE, 0); |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
872 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
873 if (text) { |
623 | 874 label = gtk_label_new(text); |
875 gtk_box_pack_start(GTK_BOX(button_box_3), label, FALSE, FALSE, 2); | |
967
17ff662183b2
[gaim-migrate @ 977]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
963
diff
changeset
|
876 gtk_widget_show(label); |
623 | 877 } |
619 | 878 |
879 gtk_widget_show(pixmap); | |
880 gtk_widget_show(button_box_2); | |
881 gtk_widget_show(button_box_3); | |
882 gtk_widget_show(button_box); | |
651 | 883 |
726 | 884 /* this causes clipping on lots of buttons with long text */ |
1238
78c4f497db2b
[gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1202
diff
changeset
|
885 /* gtk_widget_set_usize(button, 75, 30);*/ |
619 | 886 gtk_widget_show(button); |
644
b3900e312d8e
[gaim-migrate @ 654]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
623
diff
changeset
|
887 gdk_pixmap_unref(pm); |
804
17def2bb9720
[gaim-migrate @ 814]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
770
diff
changeset
|
888 gdk_bitmap_unref(mask); |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
889 |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
890 return button; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
891 } |
623 | 892 |
1152
201ec77f3a60
[gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1117
diff
changeset
|
893 static GtkTooltips *button_tips = NULL; |
915
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
894 GtkWidget *picture_button2(GtkWidget *window, char *text, char **xpm, short dispstyle) |
623 | 895 { |
896 GtkWidget *button; | |
897 GtkWidget *button_box, *button_box_2; | |
898 GdkBitmap *mask; | |
899 GdkPixmap *pm; | |
900 GtkWidget *pixmap; | |
754 | 901 GtkWidget *label; |
1238
78c4f497db2b
[gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1202
diff
changeset
|
902 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
903 if (!button_tips) |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
904 button_tips = gtk_tooltips_new(); |
623 | 905 button = gtk_button_new(); |
906 if (display_options & OPT_DISP_COOL_LOOK) | |
907 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
908 | |
651 | 909 button_box = gtk_hbox_new(FALSE, 0); |
623 | 910 gtk_container_add(GTK_CONTAINER(button), button_box); |
911 | |
754 | 912 button_box_2 = gtk_vbox_new(FALSE, 0); |
623 | 913 |
914 gtk_box_pack_start(GTK_BOX(button_box), button_box_2, TRUE, TRUE, 0); | |
967
17ff662183b2
[gaim-migrate @ 977]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
963
diff
changeset
|
915 gtk_widget_show(button_box_2); |
17ff662183b2
[gaim-migrate @ 977]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
963
diff
changeset
|
916 gtk_widget_show(button_box); |
915
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
917 if (dispstyle == 2 || dispstyle == 0) { |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
918 pm = gdk_pixmap_create_from_xpm_d(window->window, &mask, NULL, xpm); |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
919 pixmap = gtk_pixmap_new(pm, mask); |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
920 gtk_box_pack_start(GTK_BOX(button_box_2), pixmap, FALSE, FALSE, 0); |
754 | 921 |
915
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
922 gtk_widget_show(pixmap); |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
923 |
967
17ff662183b2
[gaim-migrate @ 977]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
963
diff
changeset
|
924 gdk_pixmap_unref(pm); |
17ff662183b2
[gaim-migrate @ 977]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
963
diff
changeset
|
925 gdk_bitmap_unref(mask); |
915
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
926 } |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
927 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
928 if (dispstyle == 2 || dispstyle == 1) { |
754 | 929 label = gtk_label_new(text); |
930 gtk_widget_show(label); | |
931 gtk_box_pack_end(GTK_BOX(button_box_2), label, FALSE, FALSE, 0); | |
932 } | |
623 | 933 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
934 gtk_tooltips_set_tip(button_tips, button, text, "Gaim"); |
623 | 935 gtk_widget_show(button); |
936 return button; | |
937 } | |
938 | |
684
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
939 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
940 /* remove leading whitespace from a string */ |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
941 char *remove_spaces(char *str) |
684
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
942 { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
943 int i; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
944 char *new; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
945 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
946 if (str == NULL) |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
947 return NULL; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
948 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
949 i = strspn(str, " \t\n\r\f"); |
684
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
950 new = &str[i]; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
951 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
952 return new; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
953 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
954 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
955 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
956 /* translate an AIM 3 buddylist (*.lst) to a GAIM buddylist */ |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
957 void translate_lst(FILE *src_fp, char *dest) |
684
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
958 { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
959 char line[BUF_LEN], *line2; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
960 char *name; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
961 int i; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
962 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
963 sprintf(dest, "m 1\n"); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
964 |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
965 while (fgets(line, BUF_LEN, src_fp)) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
966 line2 = remove_spaces(line); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
967 if (strstr(line2, "group") == line2) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
968 name = strpbrk(line2, " \t\n\r\f") + 1; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
969 strcat(dest, "g "); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
970 for (i = 0; i < strcspn(name, "\n\r"); i++) |
684
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
971 if (name[i] != '\"') |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
972 strncat(dest, &name[i], 1); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
973 strcat(dest, "\n"); |
684
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
974 } |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
975 if (strstr(line2, "buddy") == line2) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
976 name = strpbrk(line2, " \t\n\r\f") + 1; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
977 strcat(dest, "b "); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
978 for (i = 0; i < strcspn(name, "\n\r"); i++) |
684
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
979 if (name[i] != '\"') |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
980 strncat(dest, &name[i], 1); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
981 strcat(dest, "\n"); |
684
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
982 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
983 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
984 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
985 return; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
986 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
987 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
988 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
989 /* translate an AIM 4 buddylist (*.blt) to GAIM format */ |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
990 void translate_blt(FILE *src_fp, char *dest) |
684
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
991 { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
992 int i; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
993 char line[BUF_LEN]; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
994 char *buddy; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
995 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
996 sprintf(dest, "m 1\n"); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
997 |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
998 while (strstr(fgets(line, BUF_LEN, src_fp), "Buddy") == NULL); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
999 while (strstr(fgets(line, BUF_LEN, src_fp), "list") == NULL); |
684
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1000 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1001 while (1) { |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1002 fgets(line, BUF_LEN, src_fp); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1003 if (strchr(line, '}') != NULL) |
684
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1004 break; |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1005 |
684
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1006 /* Syntax starting with "<group> {" */ |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1007 if (strchr(line, '{') != NULL) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1008 strcat(dest, "g "); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1009 buddy = remove_spaces(strtok(line, "{")); |
684
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1010 for (i = 0; i < strlen(buddy); i++) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1011 if (buddy[i] != '\"') |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1012 strncat(dest, &buddy[i], 1); |
684
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1013 } |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1014 strcat(dest, "\n"); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1015 while (strchr(fgets(line, BUF_LEN, src_fp), '}') == NULL) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1016 buddy = remove_spaces(line); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1017 strcat(dest, "b "); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1018 if (strchr(buddy, '\"') != NULL) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1019 strncat(dest, &buddy[1], strlen(buddy) - 3); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1020 strcat(dest, "\n"); |
684
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1021 } else |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1022 strcat(dest, buddy); |
684
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1023 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1024 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1025 /* Syntax "group buddy buddy ..." */ |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1026 else { |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1027 buddy = remove_spaces(strtok(line, " \n")); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1028 strcat(dest, "g "); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1029 if (strchr(buddy, '\"') != NULL) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1030 strcat(dest, &buddy[1]); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1031 strcat(dest, " "); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1032 buddy = remove_spaces(strtok(NULL, " \n")); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1033 while (strchr(buddy, '\"') == NULL) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1034 strcat(dest, buddy); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1035 strcat(dest, " "); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1036 buddy = remove_spaces(strtok(NULL, " \n")); |
684
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1037 } |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1038 strncat(dest, buddy, strlen(buddy) - 1); |
684
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1039 } else { |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1040 strcat(dest, buddy); |
684
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1041 } |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1042 strcat(dest, "\n"); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1043 while ((buddy = remove_spaces(strtok(NULL, " \n"))) != NULL) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1044 strcat(dest, "b "); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1045 if (strchr(buddy, '\"') != NULL) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1046 strcat(dest, &buddy[1]); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1047 strcat(dest, " "); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1048 buddy = remove_spaces(strtok(NULL, " \n")); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1049 while (strchr(buddy, '\"') == NULL) { |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1050 strcat(dest, buddy); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1051 strcat(dest, " "); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1052 buddy = remove_spaces(strtok(NULL, " \n")); |
684
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1053 } |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1054 strncat(dest, buddy, strlen(buddy) - 1); |
684
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1055 } else { |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1056 strcat(dest, buddy); |
684
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1057 } |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1058 strcat(dest, "\n"); |
684
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1059 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1060 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1061 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1062 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1063 return; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1064 } |
764 | 1065 |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1066 char *stylize(gchar *text, int length) |
764 | 1067 { |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1068 gchar *buf; |
2016
9a2e3902658c
[gaim-migrate @ 2026]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
1069 char *tmp = g_malloc(length); |
764 | 1070 |
1071 buf = g_malloc(length); | |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1072 g_snprintf(buf, length, "%s", text); |
764 | 1073 |
831
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1074 if (font_options & OPT_FONT_BOLD) { |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1075 g_snprintf(tmp, length, "<B>%s</B>", buf); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1076 strcpy(buf, tmp); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1077 } |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1078 |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1079 if (font_options & OPT_FONT_ITALIC) { |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1080 g_snprintf(tmp, length, "<I>%s</I>", buf); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1081 strcpy(buf, tmp); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1082 } |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1083 |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1084 if (font_options & OPT_FONT_UNDERLINE) { |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1085 g_snprintf(tmp, length, "<U>%s</U>", buf); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1086 strcpy(buf, tmp); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1087 } |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1088 |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1089 if (font_options & OPT_FONT_STRIKE) { |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1090 g_snprintf(tmp, length, "<S>%s</S>", buf); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1091 strcpy(buf, tmp); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1092 } |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1093 |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1094 if (font_options & OPT_FONT_FACE) { |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1095 g_snprintf(tmp, length, "<FONT FACE=\"%s\">%s</FONT>", fontface, buf); |
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1096 strcpy(buf, tmp); |
764 | 1097 } |
1098 | |
1441
5c67b8794991
[gaim-migrate @ 1451]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1376
diff
changeset
|
1099 if (font_options & OPT_FONT_SIZE) { |
5c67b8794991
[gaim-migrate @ 1451]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1376
diff
changeset
|
1100 g_snprintf(tmp, length, "<FONT SIZE=\"%d\">%s</FONT>", fontsize, buf); |
5c67b8794991
[gaim-migrate @ 1451]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1376
diff
changeset
|
1101 strcpy(buf, tmp); |
5c67b8794991
[gaim-migrate @ 1451]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1376
diff
changeset
|
1102 } |
5c67b8794991
[gaim-migrate @ 1451]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1376
diff
changeset
|
1103 |
831
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1104 if (font_options & OPT_FONT_FGCOL) { |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1105 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
|
1106 fgcolor.green, fgcolor.blue, buf); |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1107 strcpy(buf, tmp); |
764 | 1108 } |
1109 | |
831
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1110 if (font_options & OPT_FONT_BGCOL) { |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1111 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
|
1112 bgcolor.green, bgcolor.blue, buf); |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1113 strcpy(buf, tmp); |
764 | 1114 } |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1115 |
2016
9a2e3902658c
[gaim-migrate @ 2026]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
1116 g_free(tmp); |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1117 return buf; |
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1118 } |
915
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1119 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1120 int set_dispstyle(int chat) |
915
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1121 { |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1122 int dispstyle; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1123 |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1124 if (chat) { |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1125 switch (display_options & (OPT_DISP_CHAT_BUTTON_TEXT | OPT_DISP_CHAT_BUTTON_XPM)) { |
915
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1126 case OPT_DISP_CHAT_BUTTON_TEXT: |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1127 dispstyle = 1; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1128 break; |
915
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1129 case OPT_DISP_CHAT_BUTTON_XPM: |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1130 dispstyle = 0; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1131 break; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1132 default: /* both or neither */ |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1133 dispstyle = 2; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1134 break; |
915
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1135 } |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1136 } else { |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1137 switch (display_options & (OPT_DISP_CONV_BUTTON_TEXT | OPT_DISP_CONV_BUTTON_XPM)) { |
915
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1138 case OPT_DISP_CONV_BUTTON_TEXT: |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1139 dispstyle = 1; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1140 break; |
915
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1141 case OPT_DISP_CONV_BUTTON_XPM: |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1142 dispstyle = 0; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1143 break; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1144 default: /* both or neither */ |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1145 dispstyle = 2; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1146 break; |
915
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1147 } |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1148 } |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1149 return dispstyle; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1150 } |
1009
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1151 |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1152 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1153 void show_usage(int mode, char *name) |
1009
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1154 { |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1155 switch (mode) { |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1156 case 0: /* full help text */ |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1157 printf("Usage: %s [OPTION]...\n\n" |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1158 " -a, --acct display account editor window\n" |
1254
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
1159 " -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
|
1160 " name of away message to use)\n" |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1161 " -l, --login[=NAME] automatically login (optional argument NAME specifies\n" |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1162 " account(s) to use)\n" |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1163 " -u, --user=NAME use account NAME\n" |
1560
72235e3fcff6
[gaim-migrate @ 1570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1525
diff
changeset
|
1164 " -f, --file=FILE use FILE as config\n" |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1165 " -v, --version display version information window\n" |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1166 " -h, --help display this help and exit\n", name); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1167 break; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1168 case 1: /* short message */ |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1169 printf("Try `%s -h' for more information.\n", name); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1170 break; |
1009
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1171 } |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1172 } |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1173 |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1174 |
2043
1b8f4b90bf09
[gaim-migrate @ 2053]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2042
diff
changeset
|
1175 void set_first_user(char *name) |
1b8f4b90bf09
[gaim-migrate @ 2053]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2042
diff
changeset
|
1176 { |
1b8f4b90bf09
[gaim-migrate @ 2053]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2042
diff
changeset
|
1177 struct aim_user *u; |
1b8f4b90bf09
[gaim-migrate @ 2053]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2042
diff
changeset
|
1178 |
1b8f4b90bf09
[gaim-migrate @ 2053]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2042
diff
changeset
|
1179 u = find_user(name, -1); |
1b8f4b90bf09
[gaim-migrate @ 2053]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2042
diff
changeset
|
1180 |
1b8f4b90bf09
[gaim-migrate @ 2053]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2042
diff
changeset
|
1181 if (!u) { /* new user */ |
1b8f4b90bf09
[gaim-migrate @ 2053]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2042
diff
changeset
|
1182 u = g_new0(struct aim_user, 1); |
1b8f4b90bf09
[gaim-migrate @ 2053]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2042
diff
changeset
|
1183 g_snprintf(u->username, sizeof(u->username), "%s", name); |
1b8f4b90bf09
[gaim-migrate @ 2053]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2042
diff
changeset
|
1184 u->protocol = DEFAULT_PROTO; |
1b8f4b90bf09
[gaim-migrate @ 2053]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2042
diff
changeset
|
1185 aim_users = g_list_prepend(aim_users, u); |
1b8f4b90bf09
[gaim-migrate @ 2053]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2042
diff
changeset
|
1186 } else { /* user already exists */ |
1b8f4b90bf09
[gaim-migrate @ 2053]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2042
diff
changeset
|
1187 aim_users = g_list_remove(aim_users, u); |
1b8f4b90bf09
[gaim-migrate @ 2053]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2042
diff
changeset
|
1188 aim_users = g_list_prepend(aim_users, u); |
1b8f4b90bf09
[gaim-migrate @ 2053]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2042
diff
changeset
|
1189 } |
1b8f4b90bf09
[gaim-migrate @ 2053]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2042
diff
changeset
|
1190 save_prefs(); |
1b8f4b90bf09
[gaim-migrate @ 2053]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2042
diff
changeset
|
1191 } |
1b8f4b90bf09
[gaim-migrate @ 2053]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2042
diff
changeset
|
1192 |
1b8f4b90bf09
[gaim-migrate @ 2053]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2042
diff
changeset
|
1193 |
1009
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1194 /* <name> is a comma-separated list of names, or NULL |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1195 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
|
1196 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
|
1197 .gaimrc and, if it's there, try to login. |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1198 returns: 0 if successful |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1199 -1 if no user was found that had a saved password |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1200 */ |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1201 int do_auto_login(char *name) |
1009
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1202 { |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1203 struct aim_user *u; |
2042
d5033540df18
[gaim-migrate @ 2052]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2039
diff
changeset
|
1204 char **names, **n; |
1009
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1205 int retval = -1; |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1206 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1207 if (name !=NULL) { /* list of names given */ |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1208 names = g_strsplit(name, ",", 32); |
1009
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1209 for (n = names; *n != NULL; n++) { |
1030
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1009
diff
changeset
|
1210 u = find_user(*n, -1); |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1211 if (u) { /* found a user */ |
1009
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1212 if (u->options & OPT_USR_REM_PASS) { |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1213 retval = 0; |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1214 serv_login(u); |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1215 } |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1216 } |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1217 } |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1218 g_strfreev(names); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1219 } else { /* no name given, use default */ |
1009
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1220 u = (struct aim_user *)aim_users->data; |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1221 if (u->options & OPT_USR_REM_PASS) { |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1222 retval = 0; |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1223 serv_login(u); |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1224 } |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1225 } |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1226 |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1227 return retval; |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1228 } |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1229 |
1035
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1230 |
1949
3397860c22e9
[gaim-migrate @ 1959]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1946
diff
changeset
|
1231 int file_is_dir(const char *path, GtkWidget *w) |
1035
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1232 { |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1233 struct stat st; |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1234 char *name; |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1235 |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1236 if (stat(path, &st) == 0 && S_ISDIR(st.st_mode)) { |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1237 /* append a / if needed */ |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1238 if (path[strlen(path) - 1] != '/') |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1239 name = g_strconcat(path, "/", NULL); |
1035
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1240 else |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1241 name = g_strdup(path); |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1242 gtk_file_selection_set_filename(GTK_FILE_SELECTION(w), name); |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1243 g_free(name); |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1244 return 1; |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1245 } |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1246 |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1247 return 0; |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1248 } |
1100
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1249 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1250 GSList *message_split(char *message, int limit) |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1251 { |
1100
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1252 static GSList *ret = NULL; |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1253 int lastgood = 0, curgood = 0, curpos = 0, len = strlen(message); |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1254 gboolean intag = FALSE; |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1255 |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1256 if (ret) { |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1257 GSList *tmp = ret; |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1258 while (tmp) { |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1259 g_free(tmp->data); |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1260 tmp = g_slist_remove(tmp, tmp->data); |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1261 } |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1262 ret = NULL; |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1263 } |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1264 |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1265 while (TRUE) { |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1266 if (lastgood >= len) |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1267 return ret; |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1268 |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1269 if (len - lastgood < limit) { |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1270 ret = g_slist_append(ret, g_strdup(&message[lastgood])); |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1271 return ret; |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1272 } |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1273 |
1100
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1274 curgood = curpos = 0; |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1275 intag = FALSE; |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1276 while (curpos <= limit) { |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1277 if (isspace(message[curpos + lastgood]) && !intag) |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1278 curgood = curpos; |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1279 if (message[curpos + lastgood] == '<') |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1280 intag = TRUE; |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1281 if (message[curpos + lastgood] == '>') |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1282 intag = FALSE; |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1283 curpos++; |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1284 } |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1285 |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1286 if (curgood) { |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1287 ret = g_slist_append(ret, g_strndup(&message[lastgood], curgood)); |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1288 if (isspace(message[curgood + lastgood])) |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1289 lastgood += curgood + 1; |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1290 else |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1291 lastgood += curgood; |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1292 } else { |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1293 /* whoops, guess we have to fudge it here */ |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1294 ret = g_slist_append(ret, g_strndup(&message[lastgood], limit)); |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1295 lastgood += limit; |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1296 } |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1297 } |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
1298 } |
1191
4fd0d35826fe
[gaim-migrate @ 1201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
1299 |
1238
78c4f497db2b
[gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1202
diff
changeset
|
1300 /* 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
|
1301 * 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
|
1302 * trailing slash after .gaim. */ |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1303 gchar *gaim_user_dir() |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1304 { |
1238
78c4f497db2b
[gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1202
diff
changeset
|
1305 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
|
1306 } |
78c4f497db2b
[gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1202
diff
changeset
|
1307 |
1292 | 1308 /* |
1309 * rcg10312000 This could be more robust, but it works for my current | |
1310 * goal: to remove those annoying <BR> tags. :) | |
1311 * dtf12162000 made the loop more readable. i am a neat freak. ;) */ | |
1312 void strncpy_nohtml(gchar *dest, const gchar *src, size_t destsize) | |
1313 { | |
1314 gchar *ptr; | |
1315 g_snprintf(dest, destsize, "%s", src); | |
1316 | |
1815
f15d449b3167
[gaim-migrate @ 1825]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1805
diff
changeset
|
1317 while ((ptr = strstr(dest, "<BR>")) != NULL) { |
1292 | 1318 /* replace <BR> with a newline. */ |
1319 *ptr = '\n'; | |
1320 memmove(ptr + 1, ptr + 4, strlen(ptr + 4) + 1); | |
1321 } | |
1322 } | |
1323 | |
1191
4fd0d35826fe
[gaim-migrate @ 1201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
1324 void strncpy_withhtml(gchar *dest, const gchar *src, size_t destsize) |
4fd0d35826fe
[gaim-migrate @ 1201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
1325 { |
1202 | 1326 gchar *end = dest + destsize; |
1191
4fd0d35826fe
[gaim-migrate @ 1201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
1327 |
1293 | 1328 while (dest < end) { |
1329 if (*src == '\n' && dest < end - 5) { | |
1202 | 1330 strcpy(dest, "<BR>"); |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1331 src++; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1332 dest += 4; |
1293 | 1333 } else { |
1334 *dest++ = *src; | |
1335 if (*src == '\0') return; | |
1336 else src++; | |
1337 } | |
1191
4fd0d35826fe
[gaim-migrate @ 1201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
1338 } |
4fd0d35826fe
[gaim-migrate @ 1201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
1339 } |
1254
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
1340 |
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
1341 |
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
1342 void away_on_login (char *mesg) |
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
1343 { |
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
1344 GSList *awy = away_messages; |
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
1345 struct away_message *a, *message = NULL; |
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
1346 |
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
1347 if (!blist) { |
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
1348 return; |
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
1349 } |
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
1350 |
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
1351 if (mesg == NULL) { |
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
1352 /* Use default message */ |
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
1353 do_away_message((GtkWidget*)NULL, default_away); |
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
1354 } else { |
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
1355 /* Use argument */ |
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
1356 while (awy) { |
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
1357 a = (struct away_message *)awy->data; |
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
1358 if (strcmp (a->name, mesg) == 0) { |
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
1359 message = a; |
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
1360 break; |
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
1361 } |
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
1362 awy = awy->next; |
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
1363 } |
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
1364 if (message == NULL) |
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
1365 message = default_away; |
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
1366 do_away_message((GtkWidget*)NULL, message); |
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
1367 } |
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
1368 return; |
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
1369 } |
1575
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1370 |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1371 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
|
1372 { |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1373 FILE *fd; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1374 char text[256], html[256]; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1375 |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1376 if ((logging_options & why) != why) |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1377 return; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1378 |
1609
b4473be6fcc5
[gaim-migrate @ 1619]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1575
diff
changeset
|
1379 if (logging_options & OPT_LOG_INDIVIDUAL) { |
b4473be6fcc5
[gaim-migrate @ 1619]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1575
diff
changeset
|
1380 if (why & OPT_LOG_MY_SIGNON) |
b4473be6fcc5
[gaim-migrate @ 1619]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1575
diff
changeset
|
1381 fd = open_system_log_file(gc ? gc->username : NULL); |
b4473be6fcc5
[gaim-migrate @ 1619]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1575
diff
changeset
|
1382 else |
b4473be6fcc5
[gaim-migrate @ 1619]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1575
diff
changeset
|
1383 fd = open_system_log_file(who->name); |
b4473be6fcc5
[gaim-migrate @ 1619]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1575
diff
changeset
|
1384 } else |
1575
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1385 fd = open_system_log_file(NULL); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1386 |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1387 if (!fd) |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1388 return; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1389 |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1390 if (why & OPT_LOG_MY_SIGNON) { |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1391 switch (what) { |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1392 case log_signon: |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1393 g_snprintf(text, sizeof(text), "+++ %s (%s) signed on @ %s", |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1394 gc->username, (*gc->prpl->name)(), full_date()); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1395 g_snprintf(html, sizeof(html), "<B>%s</B>", text); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1396 break; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1397 case log_signoff: |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1398 g_snprintf(text, sizeof(text), "+++ %s (%s) signed off @ %s", |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1399 gc->username, (*gc->prpl->name)(), full_date()); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1400 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
|
1401 break; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1402 case log_away: |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1403 g_snprintf(text, sizeof(text), "+++ %s (%s) changed away state @ %s", |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1404 gc->username, (*gc->prpl->name)(), full_date()); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1405 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1406 break; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1407 case log_back: |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1408 g_snprintf(text, sizeof(text), "+++ %s (%s) came back @ %s", |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1409 gc->username, (*gc->prpl->name)(), full_date()); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1410 g_snprintf(html, sizeof(html), "%s", text); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1411 break; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1412 case log_idle: |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1413 g_snprintf(text, sizeof(text), "+++ %s (%s) became idle @ %s", |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1414 gc->username, (*gc->prpl->name)(), full_date()); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1415 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1416 break; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1417 case log_unidle: |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1418 g_snprintf(text, sizeof(text), "+++ %s (%s) returned from idle @ %s", |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1419 gc->username, (*gc->prpl->name)(), full_date()); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1420 g_snprintf(html, sizeof(html), "%s", text); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1421 break; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1422 case log_quit: |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1423 g_snprintf(text, sizeof(text), "+++ Program exit @ %s", full_date()); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1424 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
|
1425 break; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1426 } |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1427 } else if (strcmp(who->name, who->show)) { |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1428 switch (what) { |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1429 case log_signon: |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1430 g_snprintf(text, sizeof(text), "%s (%s) reported that %s (%s) signed on @ %s", |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1431 gc->username, (*gc->prpl->name)(), who->show, who->name, full_date()); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1432 g_snprintf(html, sizeof(html), "<B>%s</B>", text); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1433 break; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1434 case log_signoff: |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1435 g_snprintf(text, sizeof(text), "%s (%s) reported that %s (%s) signed off @ %s", |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1436 gc->username, (*gc->prpl->name)(), who->show, who->name, full_date()); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1437 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
|
1438 break; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1439 case log_away: |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1440 g_snprintf(text, sizeof(text), "%s (%s) reported that %s (%s) went away @ %s", |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1441 gc->username, (*gc->prpl->name)(), who->show, who->name, full_date()); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1442 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1443 break; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1444 case log_back: |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1445 g_snprintf(text, sizeof(text), "%s (%s) reported that %s (%s) came back @ %s", |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1446 gc->username, (*gc->prpl->name)(), who->show, who->name, full_date()); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1447 g_snprintf(html, sizeof(html), "%s", text); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1448 break; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1449 case log_idle: |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1450 g_snprintf(text, sizeof(text), "%s (%s) reported that %s (%s) became idle @ %s", |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1451 gc->username, (*gc->prpl->name)(), who->show, who->name, full_date()); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1452 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1453 break; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1454 case log_unidle: |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1455 g_snprintf(text, sizeof(text), "%s (%s) reported that %s (%s) returned from idle @ %s", |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1456 gc->username, (*gc->prpl->name)(), who->show, who->name, full_date()); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1457 g_snprintf(html, sizeof(html), "%s", text); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1458 break; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1459 default: |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1460 fclose(fd); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1461 return; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1462 break; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1463 } |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1464 } else { |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1465 switch (what) { |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1466 case log_signon: |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1467 g_snprintf(text, sizeof(text), "%s (%s) reported that %s signed on @ %s", |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1468 gc->username, (*gc->prpl->name)(), who->name, full_date()); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1469 g_snprintf(html, sizeof(html), "<B>%s</B>", text); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1470 break; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1471 case log_signoff: |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1472 g_snprintf(text, sizeof(text), "%s (%s) reported that %s signed off @ %s", |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1473 gc->username, (*gc->prpl->name)(), who->name, full_date()); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1474 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
|
1475 break; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1476 case log_away: |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1477 g_snprintf(text, sizeof(text), "%s (%s) reported that %s went away @ %s", |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1478 gc->username, (*gc->prpl->name)(), who->name, full_date()); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1479 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1480 break; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1481 case log_back: |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1482 g_snprintf(text, sizeof(text), "%s (%s) reported that %s came back @ %s", |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1483 gc->username, (*gc->prpl->name)(), who->name, full_date()); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1484 g_snprintf(html, sizeof(html), "%s", text); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1485 break; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1486 case log_idle: |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1487 g_snprintf(text, sizeof(text), "%s (%s) reported that %s became idle @ %s", |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1488 gc->username, (*gc->prpl->name)(), who->name, full_date()); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1489 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1490 break; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1491 case log_unidle: |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1492 g_snprintf(text, sizeof(text), "%s (%s) reported that %s returned from idle @ %s", |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1493 gc->username, (*gc->prpl->name)(), who->name, full_date()); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1494 g_snprintf(html, sizeof(html), "%s", text); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1495 break; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1496 default: |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1497 fclose(fd); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1498 return; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1499 break; |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1500 } |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1501 } |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1502 |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1503 if (logging_options & OPT_LOG_STRIP_HTML) { |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1504 fprintf(fd, "---- %s ----\n", text); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1505 } else { |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1506 if (logging_options & OPT_LOG_INDIVIDUAL) |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1507 fprintf(fd, "<HR>%s<BR><HR><BR>\n", html); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1508 else |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1509 fprintf(fd, "%s<BR>\n", html); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1510 } |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1511 |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1512 fclose(fd); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1560
diff
changeset
|
1513 } |
1805
caa605e70917
[gaim-migrate @ 1815]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1753
diff
changeset
|
1514 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1515 unsigned char *utf8_to_str(unsigned char *in) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1516 { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1517 int n = 0,i = 0; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1518 int inlen; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1519 unsigned char *result; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1520 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1521 if (!in) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1522 return NULL; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1523 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1524 inlen = strlen(in); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1525 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1526 result = g_malloc(inlen+1); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1527 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1528 while(n <= inlen-1) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1529 long c = (long)in[n]; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1530 if(c<0x80) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1531 result[i++] = (char)c; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1532 else { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1533 if((c&0xC0) == 0xC0) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1534 result[i++] = (char)(((c&0x03)<<6)|(((unsigned char)in[++n])&0x3F)); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1535 else if((c&0xE0) == 0xE0) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1536 if (n + 2 <= inlen) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1537 result[i] = (char)(((c&0xF)<<4)|(((unsigned char)in[++n])&0x3F)); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1538 result[i] = (char)(((unsigned char)result[i]) |(((unsigned char)in[++n])&0x3F)); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1539 i++; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1540 } else n += 2; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1541 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1542 else if((c&0xF0) == 0xF0) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1543 n += 3; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1544 else if((c&0xF8) == 0xF8) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1545 n += 4; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1546 else if((c&0xFC) == 0xFC) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1547 n += 5; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1548 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1549 n++; |
2039
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1550 } |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1551 result[i] = '\0'; |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1552 |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1553 return result; |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1554 } |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1555 |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1556 char *str_to_utf8(unsigned char *in) |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1557 { |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1558 int n = 0,i = 0; |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1559 int inlen; |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1560 char *result = NULL; |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1561 |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1562 if (!in) |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1563 return NULL; |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1564 |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1565 inlen = strlen(in); |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1566 |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1567 result = g_malloc(inlen * 2 + 1); |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1568 |
2039
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1569 while (n < inlen) { |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1570 long c = (long)in[n]; |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1571 if (c == 27) { |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1572 n += 2; |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1573 if (in[n] == 'x') |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1574 n++; |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1575 if (in[n] == '3') |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1576 n++; |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1577 n += 2; |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1578 continue; |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1579 } |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1580 if ((c == 0x0D) || (c == 0x0A)) { |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1581 n++; continue; |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1582 } |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1583 if (c < 128) |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1584 result[i++] = (char)c; |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1585 else { |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1586 result[i++] = (char)((c>>6)|192); |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1587 result[i++] = (char)((c&63)|128); |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1588 } |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1589 n++; |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1590 } |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1591 result[i] = '\0'; |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1592 |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2016
diff
changeset
|
1593 return result; |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1594 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
1595 |
1805
caa605e70917
[gaim-migrate @ 1815]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1753
diff
changeset
|
1596 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
|
1597 { |
caa605e70917
[gaim-migrate @ 1815]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1753
diff
changeset
|
1598 struct tm tm; |
caa605e70917
[gaim-migrate @ 1815]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1753
diff
changeset
|
1599 |
caa605e70917
[gaim-migrate @ 1815]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1753
diff
changeset
|
1600 tm.tm_year = year - 1900; |
caa605e70917
[gaim-migrate @ 1815]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1753
diff
changeset
|
1601 tm.tm_mon = month - 1; |
caa605e70917
[gaim-migrate @ 1815]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1753
diff
changeset
|
1602 tm.tm_mday = day; |
caa605e70917
[gaim-migrate @ 1815]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1753
diff
changeset
|
1603 tm.tm_hour = hour; |
caa605e70917
[gaim-migrate @ 1815]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1753
diff
changeset
|
1604 tm.tm_min = min; |
caa605e70917
[gaim-migrate @ 1815]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1753
diff
changeset
|
1605 tm.tm_sec = sec >= 0 ? sec : time(NULL) % 60; |
caa605e70917
[gaim-migrate @ 1815]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1753
diff
changeset
|
1606 return mktime(&tm); |
caa605e70917
[gaim-migrate @ 1815]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1753
diff
changeset
|
1607 } |