annotate src/util.c @ 866:646acb9e9c38

[gaim-migrate @ 876] toc can receive up to 8k, BUF_LONG is 4k. no previous buffer overflow since BUF_LONG was being inforced, but possible data loss. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Fri, 08 Sep 2000 09:32:47 +0000
parents b389c4221c89
children 378c862a2381
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1 /*
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2 * gaim
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
5 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
9 * (at your option) any later version.
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
10 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
14 * GNU General Public License for more details.
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
15 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
19 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
20 */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
21
349
b402a23f35df [gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 278
diff changeset
22 #ifdef HAVE_CONFIG_H
b402a23f35df [gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 278
diff changeset
23 #include "../config.h"
b402a23f35df [gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 278
diff changeset
24 #endif
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
25 #include <unistd.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
26 #include <errno.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
27 #include <stdio.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
28 #include <stdlib.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
29 #include <sys/time.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
30 #include <sys/types.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
31 #include <sys/stat.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
32 #include <string.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
33 #include <sys/wait.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
34 #include <gtk/gtk.h>
210
ec0686b3b03f [gaim-migrate @ 220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 209
diff changeset
35 #include <ctype.h>
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
36 #include <pixmaps/aimicon.xpm>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
37 #include "gaim.h"
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
38
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
39 static GdkPixmap *icon_pm = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
40 static GdkBitmap *icon_bm = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
41 static int state;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
42
70
dead1eb6d654 [gaim-migrate @ 80]
Rob Flynn <gaim@robflynn.com>
parents: 26
diff changeset
43 char *full_date() {
dead1eb6d654 [gaim-migrate @ 80]
Rob Flynn <gaim@robflynn.com>
parents: 26
diff changeset
44 char * date;
dead1eb6d654 [gaim-migrate @ 80]
Rob Flynn <gaim@robflynn.com>
parents: 26
diff changeset
45 time_t tme;
dead1eb6d654 [gaim-migrate @ 80]
Rob Flynn <gaim@robflynn.com>
parents: 26
diff changeset
46
dead1eb6d654 [gaim-migrate @ 80]
Rob Flynn <gaim@robflynn.com>
parents: 26
diff changeset
47 time(&tme);
dead1eb6d654 [gaim-migrate @ 80]
Rob Flynn <gaim@robflynn.com>
parents: 26
diff changeset
48 date = ctime(&tme);
dead1eb6d654 [gaim-migrate @ 80]
Rob Flynn <gaim@robflynn.com>
parents: 26
diff changeset
49 date[strlen(date)-1] = '\0';
dead1eb6d654 [gaim-migrate @ 80]
Rob Flynn <gaim@robflynn.com>
parents: 26
diff changeset
50 return date;
dead1eb6d654 [gaim-migrate @ 80]
Rob Flynn <gaim@robflynn.com>
parents: 26
diff changeset
51 }
dead1eb6d654 [gaim-migrate @ 80]
Rob Flynn <gaim@robflynn.com>
parents: 26
diff changeset
52
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
53 gint badchar(char c)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
54 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
55 if (c == ' ')
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
56 return 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
57 if (c == ',')
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
58 return 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
59 if (c == ')')
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
60 return 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
61 if (c == '(')
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
62 return 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
63 if (c == 0)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
64 return 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
65 if (c == '\n')
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
66 return 1;
413
7ea55575cc01 [gaim-migrate @ 423]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 373
diff changeset
67 if (c == '<')
7ea55575cc01 [gaim-migrate @ 423]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 373
diff changeset
68 return 1;
470
4bf9c74b9e4d [gaim-migrate @ 480]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 423
diff changeset
69 if (c == '>')
4bf9c74b9e4d [gaim-migrate @ 480]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 423
diff changeset
70 return 1;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
71 return 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
72
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
73
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
74 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
75
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
76
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
77 char *sec_to_text(int sec)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
78 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
79 int hrs, min;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
80 char minutes[64];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
81 char hours[64];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
82 char sep[16];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
83 char *ret = g_malloc(256);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
84
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
85 hrs = sec / 3600;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
86 min = sec % 3600;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
87
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
88 min = min / 60;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
89 sec = min % 60;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
90
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
91 if (min) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
92 if (min == 1)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
93 g_snprintf(minutes, sizeof(minutes), "%d minute.", min);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
94 else
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
95 g_snprintf(minutes, sizeof(minutes), "%d minutes.", min);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
96 sprintf(sep, ", ");
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
97 } else {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
98 if (!hrs)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
99 g_snprintf(minutes, sizeof(minutes), "%d minutes.", min);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
100 else {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
101 minutes[0] = '.';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
102 minutes[1] = '\0';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
103 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
104 sep[0] = '\0';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
105 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
106
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
107 if (hrs) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
108 if (hrs == 1)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
109 g_snprintf(hours, sizeof(hours), "%d hour%s", hrs, sep);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
110 else
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
111 g_snprintf(hours, sizeof(hours), "%d hours%s", hrs, sep);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
112 } else
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
113 hours[0] = '\0';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
114
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
115
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
116 g_snprintf(ret, 256, "%s%s", hours, minutes);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
117
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
118 return ret;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
119 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
120
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
121 gint linkify_text(char *text)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
122 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
123 char *c, *t;
845
647b110f7a1a [gaim-migrate @ 855]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 831
diff changeset
124 char *cpy = g_malloc(strlen(text) * 2 + 1);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
125 char url_buf[512];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
126 int cnt=0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
127 /* Assumes you have a buffer able to cary at least BUF_LEN * 2 bytes */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
128
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
129 strncpy(cpy, text, strlen(text));
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
130 cpy[strlen(text)] = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
131 c = cpy;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
132 while(*c) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
133 if (!strncasecmp(c, "<A", 2)) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
134 while(1) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
135 if (!strncasecmp(c, "/A>", 3)) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
136 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
137 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
138 text[cnt++] = *c;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
139 c++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
140 if (!(*c))
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
141 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
142 }
856
b389c4221c89 [gaim-migrate @ 866]
Rob Flynn <gaim@robflynn.com>
parents: 846
diff changeset
143 } else if ( (!strncasecmp(c, "http://", 7) || (!strncasecmp(c, "https://", 8)))) {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
144 t = c;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
145 while(1) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
146 if (badchar(*t)) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
147 if (*(t-1) == '.')
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
148 t--;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
149 strncpy(url_buf, c, t-c);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
150 url_buf[t-c] = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
151 cnt += g_snprintf(&text[cnt++], 1024, "<A HREF=\"%s\">%s</A>", url_buf, url_buf);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
152 cnt--;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
153 c = t;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
154 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
155 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
156 if (!t)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
157 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
158 t++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
159
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
160 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
161 } else if (!strncasecmp(c, "www.", 4)) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
162 if (strncasecmp(c, "www..", 5)) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
163 t = c;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
164 while(1) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
165 if (badchar(*t)) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
166 if (t-c == 4) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
167 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
168 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
169 if (*(t-1) == '.')
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
170 t--;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
171 strncpy(url_buf, c, t-c);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
172 url_buf[t-c] = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
173 cnt += g_snprintf(&text[cnt++], 1024, "<A HREF=\"http://%s\">%s</A>", url_buf, url_buf);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
174 cnt--;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
175 c = t;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
176 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
177 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
178 if (!t)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
179 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
180 t++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
181 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
182 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
183 } else if (!strncasecmp(c, "ftp://", 6)) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
184 t = c;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
185 while(1) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
186 if (badchar(*t)) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
187 if (*(t-1) == '.')
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
188 t--;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
189 strncpy(url_buf, c, t-c);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
190 url_buf[t-c] = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
191 cnt += g_snprintf(&text[cnt++], 1024, "<A HREF=\"%s\">%s</A>", url_buf, url_buf);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
192 cnt--;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
193 c = t;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
194 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
195 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
196 if (!t)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
197 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
198 t++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
199
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
200 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
201 } else if (!strncasecmp(c, "ftp.", 4)) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
202 t = c;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
203 while(1) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
204 if (badchar(*t)) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
205 if (t-c == 4) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
206 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
207 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
208 if (*(t-1) == '.')
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
209 t--;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
210 strncpy(url_buf, c, t-c);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
211 url_buf[t-c] = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
212 cnt += g_snprintf(&text[cnt++], 1024, "<A HREF=\"ftp://%s\">%s</A>", url_buf, url_buf);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
213 cnt--;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
214 c = t;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
215 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
216 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
217 if (!t)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
218 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
219 t++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
220 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
221 } else if (!strncasecmp(c, "mailto:", 7)) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
222 t = c;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
223 while(1) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
224 if (badchar(*t)) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
225 if (*(t-1) == '.')
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
226 t--;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
227 strncpy(url_buf, c, t-c);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
228 url_buf[t-c] = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
229 cnt += g_snprintf(&text[cnt++], 1024, "<A HREF=\"%s\">%s</A>", url_buf, url_buf);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
230 cnt--;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
231 c = t;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
232 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
233 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
234 if (!t)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
235 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
236 t++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
237
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
238 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
239 } else if (!strncasecmp(c, "@", 1)) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
240 char *tmp;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
241 int flag;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
242 int len=0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
243 url_buf[0] = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
244
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
245 if (*(c-1) == ' ' || *(c+1) == ' ')
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
246 flag = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
247 else
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
248 flag = 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
249
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
250 t = c;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
251 while(flag) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
252 if (badchar(*t)) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
253 cnt -= (len - 1);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
254 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
255 } else {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
256 len++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
257 tmp = g_malloc(len + 1);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
258 tmp[len] = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
259 tmp[0] = *t;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
260 strncpy(tmp + 1, url_buf, len - 1);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
261 strcpy(url_buf, tmp);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
262 url_buf[len] = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
263 g_free(tmp);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
264 t--;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
265 if (t < cpy) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
266 cnt = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
267 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
268 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
269 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
270 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
271
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
272
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
273 t = c + 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
274
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
275 while(flag) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
276 if (badchar(*t)) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
277 if (*(t-1) == '.')
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
278 t--;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
279 cnt += g_snprintf(&text[cnt++], 1024, "<A HREF=\"mailto:%s\">%s</A>", url_buf, url_buf);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
280 text[cnt]=0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
281
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
282
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
283 cnt--;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
284 c = t;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
285
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
286 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
287 } else {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
288 strncat(url_buf, t, 1);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
289 len++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
290 url_buf[len] = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
291 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
292
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
293 t++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
294
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
295 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
296
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
297
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
298 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
299
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
300 if (*c == 0)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
301 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
302
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
303 text[cnt++] = *c;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
304 c++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
305
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
306 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
307 text[cnt]=0;
845
647b110f7a1a [gaim-migrate @ 855]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 831
diff changeset
308 g_free(cpy);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
309 return cnt;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
310 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
311
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
312
373
1d29321843b0 [gaim-migrate @ 383]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
313 FILE *open_log_file (char *name)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
314 {
79
bfdc427b936d [gaim-migrate @ 89]
Rob Flynn <gaim@robflynn.com>
parents: 70
diff changeset
315 char *buf;
bfdc427b936d [gaim-migrate @ 89]
Rob Flynn <gaim@robflynn.com>
parents: 70
diff changeset
316 char *buf2;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
317 char log_all_file[256];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
318 struct log_conversation *l;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
319 struct stat st;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
320 int flag = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
321 FILE *fd;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
322 int res;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
323
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
324 if (!(general_options & OPT_GEN_LOG_ALL)) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
325
373
1d29321843b0 [gaim-migrate @ 383]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
326 l = find_log_info(name);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
327 if (!l)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
328 return NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
329
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
330 if (stat(l->filename, &st) < 0)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
331 flag = 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
332
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
333 fd = fopen(l->filename, "a");
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
334
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
335 if (flag) { /* is a new file */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
336 fprintf(fd, "<HTML><HEAD><TITLE>" );
373
1d29321843b0 [gaim-migrate @ 383]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
337 fprintf(fd, "IM Sessions with %s", name );
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
338 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"ffffff\">\n" );
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
339 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
340
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
341 return fd;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
342 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
343
79
bfdc427b936d [gaim-migrate @ 89]
Rob Flynn <gaim@robflynn.com>
parents: 70
diff changeset
344 buf = g_malloc(BUF_LONG);
bfdc427b936d [gaim-migrate @ 89]
Rob Flynn <gaim@robflynn.com>
parents: 70
diff changeset
345 buf2 = g_malloc(BUF_LONG);
bfdc427b936d [gaim-migrate @ 89]
Rob Flynn <gaim@robflynn.com>
parents: 70
diff changeset
346
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
347 /* Dont log yourself */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
348 g_snprintf(log_all_file, 256, "%s/.gaim", getenv("HOME"));
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
349
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
350 stat(log_all_file, &st);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
351 if (!S_ISDIR(st.st_mode))
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
352 unlink(log_all_file);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
353
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
354 fd = fopen(log_all_file, "r");
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
355
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
356 if (!fd) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
357 res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
358 if (res < 0) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
359 g_snprintf(buf, BUF_LONG, "Unable to make directory %s for logging", log_all_file);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
360 do_error_dialog(buf, "Error!");
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
361 g_free(buf);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
362 g_free(buf2);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
363 return NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
364 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
365 } else
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
366 fclose(fd);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
367
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
368 g_snprintf(log_all_file, 256, "%s/.gaim/%s", getenv("HOME"), current_user->username);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
369
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
370 if (stat(log_all_file, &st) < 0)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
371 flag = 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
372 if (!S_ISDIR(st.st_mode))
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
373 unlink(log_all_file);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
374
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
375 fd = fopen(log_all_file, "r");
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
376 if (!fd) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
377 res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
378 if (res < 0) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
379 g_snprintf(buf, BUF_LONG, "Unable to make directory %s for logging", log_all_file);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
380 do_error_dialog(buf, "Error!");
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
381 g_free(buf);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
382 g_free(buf2);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
383 return NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
384 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
385 } else
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
386 fclose(fd);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
387
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
388
373
1d29321843b0 [gaim-migrate @ 383]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
389 g_snprintf(log_all_file, 256, "%s/.gaim/%s/%s.log", getenv("HOME"), current_user->username, normalize(name));
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
390
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
391 if (stat(log_all_file, &st) < 0)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
392 flag = 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
393
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
394 sprintf(debug_buff,"Logging to: \"%s\"\n", log_all_file);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
395 debug_print(debug_buff);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
396
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
397 fd = fopen(log_all_file, "a");
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
398
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
399 if (flag) { /* is a new file */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
400 fprintf(fd, "<HTML><HEAD><TITLE>" );
373
1d29321843b0 [gaim-migrate @ 383]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
401 fprintf(fd, "IM Sessions with %s", name );
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
402 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"ffffff\">\n" );
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
403 }
25
c56db1b46b0d [gaim-migrate @ 34]
Rob Flynn <gaim@robflynn.com>
parents: 17
diff changeset
404
c56db1b46b0d [gaim-migrate @ 34]
Rob Flynn <gaim@robflynn.com>
parents: 17
diff changeset
405 g_free(buf);
c56db1b46b0d [gaim-migrate @ 34]
Rob Flynn <gaim@robflynn.com>
parents: 17
diff changeset
406 g_free(buf2);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
407 return fd;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
408 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
409
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
410
254
fa67d29b53d5 [gaim-migrate @ 264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 210
diff changeset
411 /* we only need this for TOC, because messages must be escaped */
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
412 int escape_message(char *msg)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
413 {
423
0d4e80bdb96b [gaim-migrate @ 433]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 413
diff changeset
414 if (!USE_OSCAR) {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
415 char *c, *cpy;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
416 int cnt=0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
417 /* Assumes you have a buffer able to cary at least BUF_LEN * 2 bytes */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
418 if (strlen(msg) > BUF_LEN) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
419 sprintf(debug_buff, "Warning: truncating message to 2048 bytes\n");
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
420 debug_print(debug_buff);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
421 msg[2047]='\0';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
422 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
423
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
424 cpy = g_strdup(msg);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
425 c = cpy;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
426 while(*c) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
427 switch(*c) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
428 case '$':
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
429 case '[':
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
430 case ']':
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
431 case '(':
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
432 case ')':
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
433 case '#':
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
434 msg[cnt++]='\\';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
435 /* Fall through */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
436 default:
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
437 msg[cnt++]=*c;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
438 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
439 c++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
440 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
441 msg[cnt]='\0';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
442 g_free(cpy);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
443 return cnt;
423
0d4e80bdb96b [gaim-migrate @ 433]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 413
diff changeset
444 } else {
254
fa67d29b53d5 [gaim-migrate @ 264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 210
diff changeset
445 return strlen(msg);
423
0d4e80bdb96b [gaim-migrate @ 433]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 413
diff changeset
446 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
447 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
448
254
fa67d29b53d5 [gaim-migrate @ 264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 210
diff changeset
449 /* we don't need this for oscar either */
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
450 int escape_text(char *msg)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
451 {
423
0d4e80bdb96b [gaim-migrate @ 433]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 413
diff changeset
452 if (!USE_OSCAR) {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
453 char *c, *cpy;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
454 int cnt=0;
79
bfdc427b936d [gaim-migrate @ 89]
Rob Flynn <gaim@robflynn.com>
parents: 70
diff changeset
455 /* Assumes you have a buffer able to cary at least BUF_LEN * 4 bytes */
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
456 if (strlen(msg) > BUF_LEN) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
457 fprintf(stderr, "Warning: truncating message to 2048 bytes\n");
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
458 msg[2047]='\0';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
459 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
460
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
461 cpy = g_strdup(msg);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
462 c = cpy;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
463 while(*c) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
464 switch(*c) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
465 case '\n':
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
466 msg[cnt++] = '<';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
467 msg[cnt++] = 'B';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
468 msg[cnt++] = 'R';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
469 msg[cnt++] = '>';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
470 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
471 case '{':
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
472 case '}':
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
473 case '\\':
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
474 case '"':
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
475 msg[cnt++]='\\';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
476 /* Fall through */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
477 default:
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
478 msg[cnt++]=*c;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
479 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
480 c++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
481 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
482 msg[cnt]='\0';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
483 g_free(cpy);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
484 return cnt;
423
0d4e80bdb96b [gaim-migrate @ 433]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 413
diff changeset
485 } else {
254
fa67d29b53d5 [gaim-migrate @ 264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 210
diff changeset
486 return strlen(msg);
423
0d4e80bdb96b [gaim-migrate @ 433]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 413
diff changeset
487 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
488 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
489
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
490 char * escape_text2(char *msg)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
491 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
492 char *c, *cpy;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
493 char *woo;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
494 int cnt=0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
495 /* Assumes you have a buffer able to cary at least BUF_LEN * 2 bytes */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
496 if (strlen(msg) > BUF_LEN) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
497 fprintf(stderr, "Warning: truncating message to 2048 bytes\n");
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
498 msg[2047]='\0';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
499 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
500
79
bfdc427b936d [gaim-migrate @ 89]
Rob Flynn <gaim@robflynn.com>
parents: 70
diff changeset
501 woo = malloc(strlen(msg) * 2);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
502 cpy = g_strdup(msg);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
503 c = cpy;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
504 while(*c) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
505 switch(*c) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
506 case '\n':
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
507 woo[cnt++] = '<';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
508 woo[cnt++] = 'B';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
509 woo[cnt++] = 'R';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
510 woo[cnt++] = '>';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
511 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
512 case '{':
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
513 case '}':
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
514 case '\\':
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
515 case '"':
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
516 woo[cnt++]='\\';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
517 /* Fall through */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
518 default:
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
519 woo[cnt++]=*c;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
520 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
521 c++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
522 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
523 woo[cnt]='\0';
26
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 25
diff changeset
524
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 25
diff changeset
525 g_free (cpy);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
526 return woo;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
527 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
528
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
529
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
530 char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
531 "0123456789+/";
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
532
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
533
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
534 char *tobase64(char *text)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
535 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
536 char *out = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
537 char *c;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
538 unsigned int tmp = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
539 int len = 0, n = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
540
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
541 c = text;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
542
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
543 while(c) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
544 tmp = tmp << 8;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
545 tmp += *c;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
546 n++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
547
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
548 if (n == 3) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
549 out = g_realloc(out, len+4);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
550 out[len] = alphabet[(tmp >> 18) & 0x3f];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
551 out[len+1] = alphabet[(tmp >> 12) & 0x3f];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
552 out[len+2] = alphabet[(tmp >> 6) & 0x3f];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
553 out[len+3] = alphabet[tmp & 0x3f];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
554 len += 4;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
555 tmp = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
556 n = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
557 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
558 c++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
559 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
560 switch(n) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
561
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
562 case 2:
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
563 out = g_realloc(out, len+5);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
564 out[len] = alphabet[(tmp >> 12) & 0x3f];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
565 out[len+1] = alphabet[(tmp >> 6) & 0x3f];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
566 out[len+2] = alphabet[tmp & 0x3f];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
567 out[len+3] = '=';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
568 out[len+4] = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
569 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
570 case 1:
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
571 out = g_realloc(out, len+4);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
572 out[len] = alphabet[(tmp >> 6) & 0x3f];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
573 out[len+1] = alphabet[tmp & 0x3f];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
574 out[len+2] = '=';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
575 out[len+3] = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
576 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
577 case 0:
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
578 out = g_realloc(out, len+2);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
579 out[len] = '=';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
580 out[len+1] = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
581 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
582 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
583 return out;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
584 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
585
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
586
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
587 char *frombase64(char *text)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
588 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
589 char *out = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
590 char tmp = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
591 char *c;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
592 gint32 tmp2 = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
593 int len = 0, n = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
594
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
595 c = text;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
596
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
597 while(*c) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
598 if (*c >= 'A' && *c <= 'Z') {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
599 tmp = *c - 'A';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
600 } else if (*c >= 'a' && *c <= 'z') {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
601 tmp = 26 + (*c - 'a');
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
602 } else if (*c >= '0' && *c <= 57) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
603 tmp = 52 + (*c - '0');
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
604 } else if (*c == '+') {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
605 tmp = 62;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
606 } else if (*c == '/') {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
607 tmp = 63;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
608 } else if (*c == '=') {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
609 if (n == 3) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
610 out = g_realloc(out, len + 2);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
611 out[len] = (char)(tmp2 >> 10) & 0xff;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
612 len++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
613 out[len] = (char)(tmp2 >> 2) & 0xff;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
614 len++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
615 } else if (n == 2) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
616 out = g_realloc(out, len + 1);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
617 out[len] = (char)(tmp2 >> 4) & 0xff;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
618 len++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
619 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
620 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
621 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
622 tmp2 = ((tmp2 << 6) | (tmp & 0xff));
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
623 n++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
624 if (n == 4) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
625 out = g_realloc(out, len + 3);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
626 out[len] = (char)((tmp2 >> 16) & 0xff);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
627 len++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
628 out[len] = (char)((tmp2 >> 8) & 0xff);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
629 len++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
630 out[len] = (char)(tmp2 & 0xff);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
631 len++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
632 tmp2 = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
633 n = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
634 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
635 c++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
636 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
637
194
d7690984c0f1 [gaim-migrate @ 204]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 180
diff changeset
638 out = g_realloc(out, len+1);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
639 out[len] = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
640
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
641 return out;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
642 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
643
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
644
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
645 char *normalize(const char *s)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
646 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
647 static char buf[BUF_LEN];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
648 char *t, *u;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
649 int x=0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
650
79
bfdc427b936d [gaim-migrate @ 89]
Rob Flynn <gaim@robflynn.com>
parents: 70
diff changeset
651 g_return_val_if_fail ((s != NULL), NULL);
26
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 25
diff changeset
652
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 25
diff changeset
653 u = t = g_strdup(s);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
654
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
655 strcpy(t, s);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
656 g_strdown(t);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
657
26
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 25
diff changeset
658 while(*t && (x < BUF_LEN - 1)) {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
659 if (*t != ' ') {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
660 buf[x] = *t;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
661 x++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
662 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
663 t++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
664 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
665 buf[x]='\0';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
666 g_free(u);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
667 return buf;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
668 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
669
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
670 int query_state()
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
671 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
672 return state;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
673 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
674
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
675 void set_state(int i)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
676 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
677 state = i;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
678 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
679
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
680 char *date()
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
681 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
682 static char date[80];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
683 time_t tme;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
684 time(&tme);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
685 strftime(date, sizeof(date), "%H:%M:%S", localtime(&tme));
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
686 return date;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
687 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
688
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
689
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
690 gint clean_pid(void *dummy)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
691 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
692 int status;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
693 pid_t pid;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
694
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
695 pid = waitpid(-1, &status, WNOHANG);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
696
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
697 if (pid == 0)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
698 return TRUE;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
699
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
700 return FALSE;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
701 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
702
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
703 void aol_icon(GdkWindow *w)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
704 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
705 #ifndef _WIN32
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
706 if (icon_pm == NULL) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
707 icon_pm = gdk_pixmap_create_from_xpm_d(w, &icon_bm,
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
708 NULL, (gchar **)aimicon_xpm);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
709 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
710 gdk_window_set_icon(w, NULL, icon_pm, icon_bm);
10
34db9f242899 [gaim-migrate @ 19]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
711 if (mainwindow) gdk_window_set_group(w, mainwindow->window);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
712 #endif
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
713 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
714
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
715 struct aim_user *find_user(const char *name)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
716 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
717 char *who = g_strdup(normalize(name));
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
718 GList *usr = aim_users;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
719 struct aim_user *u;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
720
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
721 while(usr) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
722 u = (struct aim_user *)usr->data;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
723 if (!strcmp(normalize(u->username), who)) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
724 g_free(who);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
725 return u;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
726 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
727 usr = usr->next;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
728 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
729 g_free(who);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
730 return NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
731 }
180
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
732
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
733 void check_gaim_versions()
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
734 {
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
735 char *cur_ver;
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
736 char *tmp;
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
737
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
738 tmp = (char *)malloc(BUF_LONG);
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
739
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
740 cur_ver = (char *)grab_url("http://www.marko.net/gaim/latest-gaim");
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
741
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
742 if (!strncasecmp(cur_ver, "g00", 3))
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
743 {
278
29e1669b006b [gaim-migrate @ 288]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 254
diff changeset
744 g_free(cur_ver);
29e1669b006b [gaim-migrate @ 288]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 254
diff changeset
745 g_free(tmp);
180
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
746 return;
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
747 }
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
748
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
749 g_snprintf(tmp, BUF_LONG, "%s", strstr(cur_ver, "plain")+9);
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
750 g_strchomp(tmp);
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
751
278
29e1669b006b [gaim-migrate @ 288]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 254
diff changeset
752 if (strcmp(tmp, latest_ver))
180
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
753 {
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
754 g_snprintf(cur_ver, BUF_LONG, "GAIM v%s is now available.\n\nDownload it at http://www.marko.net/gaim\n", tmp);
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
755
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
756 do_error_dialog(cur_ver, "GAIM - New Version!");
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
757 strcpy(latest_ver, tmp);
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
758 save_prefs();
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
759 }
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
760
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
761 free(tmp);
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
762 free(cur_ver);
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
763 }
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
764
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
765
206
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
766 /*
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
767
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
768 This function was taken from EveryBuddy and was written by
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
769 Torrey Searle. tsearle@valhalla.marko.net
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
770
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
771 http://www.everybuddy.com
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
772
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
773 */
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
774
209
6e9b375e30e7 [gaim-migrate @ 219]
Rob Flynn <gaim@robflynn.com>
parents: 206
diff changeset
775 void spell_checker(GtkWidget * text)
206
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
776 {
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
777 int start = 0;
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
778 int end = 0;
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
779 static GdkColor * color = NULL;
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
780 int ignore = 0;
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
781 int point = gtk_editable_get_position(GTK_EDITABLE(text));
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
782
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
783 GString * string;
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
784
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
785 if( color == NULL )
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
786 {
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
787 GdkColormap * gc = gtk_widget_get_colormap( text );
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
788 color = g_new0(GdkColor, 1);
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
789 color->red = 255 * 256;
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
790 gdk_colormap_alloc_color(gc, color, FALSE, TRUE);
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
791 }
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
792
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
793
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
794
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
795 end = point-1;
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
796 for( start = end-1; start >= 0; start-- )
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
797 {
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
798 if((isspace(GTK_TEXT_INDEX(GTK_TEXT(text), start)) || start == 0)
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
799 && !ignore)
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
800 {
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
801 char * word;
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
802 FILE * file;
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
803 char buff[1024];
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
804 word = gtk_editable_get_chars( GTK_EDITABLE(text), start, end );
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
805 g_snprintf(buff, 1024, "echo \"%s\" | ispell -l", word );
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
806 file = popen(buff, "r");
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
807
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
808 buff[0] = 0;
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
809 fgets(buff, 255, file);
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
810
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
811 if(strlen(buff) > 0 )
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
812 {
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
813 string = g_string_new(word);
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
814 gtk_text_set_point(GTK_TEXT(text), end);
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
815 gtk_text_backward_delete(GTK_TEXT(text), end-start);
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
816 gtk_text_insert( GTK_TEXT(text), NULL, color, NULL,
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
817 string->str, string->len );
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
818 g_string_free( string, TRUE );
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
819 }
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
820 else
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
821 {
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
822 string = g_string_new(word);
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
823 gtk_text_set_point(GTK_TEXT(text), end);
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
824 gtk_text_backward_delete(GTK_TEXT(text), end-start);
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
825 gtk_text_insert( GTK_TEXT(text), NULL, &(text->style->fg[0]), NULL,
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
826 string->str, string->len );
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
827 g_string_free( string, TRUE );
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
828 }
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
829 pclose( file);
846
4b05985bae5e [gaim-migrate @ 856]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 845
diff changeset
830 g_free(word);
206
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
831 break;
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
832 }
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
833 else if(!isalpha(GTK_TEXT_INDEX(GTK_TEXT(text), start)))
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
834 {
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
835 ignore = 1;
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
836 }
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
837 }
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
838 gtk_text_set_point(GTK_TEXT(text), point);
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
839
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
840 }
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
841
592
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
842 /* 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
843 or time */
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
844 char *away_subs(char *msg, char *name)
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
845 {
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
846 char *c;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
847 static char cpy[BUF_LONG];
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
848 int cnt=0;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
849 time_t t = time(0);
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
850 struct tm *tme = localtime(&t);
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
851 char tmp[20];
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
852
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
853 cpy[0] = '\0';
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
854 c = msg;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
855 while(*c) {
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
856 switch(*c) {
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
857 case '%':
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
858 if (*(c+1)) {
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
859 switch (*(c+1)) {
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
860 case 'n':
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
861 // append name
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
862 strcpy (cpy+cnt, name);
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
863 cnt += strlen(name);
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
864 c++;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
865 break;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
866 case 'd':
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
867 // append date
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
868 strftime (tmp, 20, "%D", tme);
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
869 strcpy (cpy+cnt, tmp);
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
870 cnt += strlen(tmp);
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
871 c++;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
872 break;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
873 case 't':
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
874 // append time
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
875 strftime (tmp, 20, "%r", tme);
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
876 strcpy (cpy+cnt, tmp);
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
877 cnt += strlen(tmp);
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
878 c++;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
879 break;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
880 default:
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
881 cpy[cnt++]=*c;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
882 }
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
883 }
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
884 break;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
885 default:
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
886 cpy[cnt++]=*c;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
887 }
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
888 c++;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
889 }
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
890 cpy[cnt]='\0';
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
891 return(cpy);
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
892 }
603
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
893
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
894 GtkWidget *picture_button(GtkWidget *window, char *text, char **xpm)
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
895 {
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
896 GtkWidget *button;
619
faa7603ae02e [gaim-migrate @ 629]
Todd Kulesza <fflewddur>
parents: 617
diff changeset
897 GtkWidget *button_box, *button_box_2, *button_box_3;
603
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
898 GtkWidget *label;
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
899 GdkBitmap *mask;
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
900 GdkPixmap *pm;
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
901 GtkWidget *pixmap;
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
902
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
903 button = gtk_button_new();
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
904 if (display_options & OPT_DISP_COOL_LOOK)
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
905 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
906
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
907 button_box = gtk_hbox_new(FALSE, 5);
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
908 gtk_container_add(GTK_CONTAINER(button), button_box);
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
909
619
faa7603ae02e [gaim-migrate @ 629]
Todd Kulesza <fflewddur>
parents: 617
diff changeset
910 button_box_2 = gtk_hbox_new(FALSE, 0);
faa7603ae02e [gaim-migrate @ 629]
Todd Kulesza <fflewddur>
parents: 617
diff changeset
911 button_box_3 = gtk_hbox_new(FALSE, 0);
faa7603ae02e [gaim-migrate @ 629]
Todd Kulesza <fflewddur>
parents: 617
diff changeset
912 gtk_box_pack_start(GTK_BOX(button_box), button_box_2, TRUE, TRUE, 0);
faa7603ae02e [gaim-migrate @ 629]
Todd Kulesza <fflewddur>
parents: 617
diff changeset
913 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
914 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
915 pixmap = gtk_pixmap_new(pm, mask);
619
faa7603ae02e [gaim-migrate @ 629]
Todd Kulesza <fflewddur>
parents: 617
diff changeset
916 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
917
623
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
918 if (text)
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
919 {
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
920 label = gtk_label_new(text);
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
921 gtk_box_pack_start(GTK_BOX(button_box_3), label, FALSE, FALSE, 2);
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
922 }
619
faa7603ae02e [gaim-migrate @ 629]
Todd Kulesza <fflewddur>
parents: 617
diff changeset
923
faa7603ae02e [gaim-migrate @ 629]
Todd Kulesza <fflewddur>
parents: 617
diff changeset
924 gtk_widget_show(pixmap);
623
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
925 if (text)
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
926 {
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
927 gtk_widget_show(label);
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
928 }
619
faa7603ae02e [gaim-migrate @ 629]
Todd Kulesza <fflewddur>
parents: 617
diff changeset
929 gtk_widget_show(button_box_2);
faa7603ae02e [gaim-migrate @ 629]
Todd Kulesza <fflewddur>
parents: 617
diff changeset
930 gtk_widget_show(button_box_3);
faa7603ae02e [gaim-migrate @ 629]
Todd Kulesza <fflewddur>
parents: 617
diff changeset
931 gtk_widget_show(button_box);
651
650687b7ca0e [gaim-migrate @ 661]
Rob Flynn <gaim@robflynn.com>
parents: 644
diff changeset
932
726
012bf218a655 [gaim-migrate @ 736]
Todd Kulesza <fflewddur>
parents: 684
diff changeset
933 /* this causes clipping on lots of buttons with long text */
012bf218a655 [gaim-migrate @ 736]
Todd Kulesza <fflewddur>
parents: 684
diff changeset
934 /* gtk_widget_set_usize(button, 75, 30);*/
619
faa7603ae02e [gaim-migrate @ 629]
Todd Kulesza <fflewddur>
parents: 617
diff changeset
935 gtk_widget_show(button);
644
b3900e312d8e [gaim-migrate @ 654]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 623
diff changeset
936 gdk_pixmap_unref(pm);
804
17def2bb9720 [gaim-migrate @ 814]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 770
diff changeset
937 gdk_bitmap_unref(mask);
619
faa7603ae02e [gaim-migrate @ 629]
Todd Kulesza <fflewddur>
parents: 617
diff changeset
938
603
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
939 return button;
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
940 }
623
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
941
759
9389216aae29 [gaim-migrate @ 769]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 754
diff changeset
942 static GtkTooltips *tips = NULL;
754
bcae3ff49680 [gaim-migrate @ 764]
Rob Flynn <gaim@robflynn.com>
parents: 726
diff changeset
943 GtkWidget *picture_button2(GtkWidget *window, char *text, char **xpm, short showtext)
623
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
944 {
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
945 GtkWidget *button;
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
946 GtkWidget *button_box, *button_box_2;
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
947 GdkBitmap *mask;
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
948 GdkPixmap *pm;
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
949 GtkWidget *pixmap;
754
bcae3ff49680 [gaim-migrate @ 764]
Rob Flynn <gaim@robflynn.com>
parents: 726
diff changeset
950 GtkWidget *label;
623
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
951
759
9389216aae29 [gaim-migrate @ 769]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 754
diff changeset
952 if (!tips) tips = gtk_tooltips_new();
623
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
953 button = gtk_button_new();
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
954 if (display_options & OPT_DISP_COOL_LOOK)
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
955 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
956
651
650687b7ca0e [gaim-migrate @ 661]
Rob Flynn <gaim@robflynn.com>
parents: 644
diff changeset
957 button_box = gtk_hbox_new(FALSE, 0);
623
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
958 gtk_container_add(GTK_CONTAINER(button), button_box);
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
959
754
bcae3ff49680 [gaim-migrate @ 764]
Rob Flynn <gaim@robflynn.com>
parents: 726
diff changeset
960 button_box_2 = gtk_vbox_new(FALSE, 0);
623
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
961
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
962 gtk_box_pack_start(GTK_BOX(button_box), button_box_2, TRUE, TRUE, 0);
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
963 pm = gdk_pixmap_create_from_xpm_d(window->window, &mask, NULL, xpm);
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
964 pixmap = gtk_pixmap_new(pm, mask);
754
bcae3ff49680 [gaim-migrate @ 764]
Rob Flynn <gaim@robflynn.com>
parents: 726
diff changeset
965 gtk_box_pack_start(GTK_BOX(button_box_2), pixmap, FALSE, FALSE, 0);
bcae3ff49680 [gaim-migrate @ 764]
Rob Flynn <gaim@robflynn.com>
parents: 726
diff changeset
966
767
be917c4d3e39 [gaim-migrate @ 777]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 765
diff changeset
967 if (showtext)
754
bcae3ff49680 [gaim-migrate @ 764]
Rob Flynn <gaim@robflynn.com>
parents: 726
diff changeset
968 {
bcae3ff49680 [gaim-migrate @ 764]
Rob Flynn <gaim@robflynn.com>
parents: 726
diff changeset
969 label = gtk_label_new(text);
bcae3ff49680 [gaim-migrate @ 764]
Rob Flynn <gaim@robflynn.com>
parents: 726
diff changeset
970 gtk_widget_show(label);
bcae3ff49680 [gaim-migrate @ 764]
Rob Flynn <gaim@robflynn.com>
parents: 726
diff changeset
971 gtk_box_pack_end(GTK_BOX(button_box_2), label, FALSE, FALSE, 0);
bcae3ff49680 [gaim-migrate @ 764]
Rob Flynn <gaim@robflynn.com>
parents: 726
diff changeset
972 }
623
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
973
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
974 gtk_widget_show(pixmap);
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
975 gtk_widget_show(button_box_2);
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
976 gtk_widget_show(button_box);
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
977 gtk_widget_show(button);
644
b3900e312d8e [gaim-migrate @ 654]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 623
diff changeset
978 gdk_pixmap_unref(pm);
804
17def2bb9720 [gaim-migrate @ 814]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 770
diff changeset
979 gdk_bitmap_unref(mask);
623
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
980
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
981 gtk_tooltips_set_tip(tips, button, text, "Gaim");
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
982 return button;
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
983 }
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
984
684
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
985
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
986 /* remove leading whitespace from a string */
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
987 char *remove_spaces (char *str)
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 int i;
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
990 char *new;
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 if (str == NULL)
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
993 return NULL;
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
994
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
995 i = strspn (str, " \t\n\r\f");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
996 new = &str[i];
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
997
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
998 return new;
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
999 }
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
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1002 /* translate an AIM 3 buddylist (*.lst) to a GAIM buddylist */
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1003 void translate_lst (FILE *src_fp, char *dest)
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1004 {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1005 char line[BUF_LEN], *line2;
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1006 char *name;
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1007 int i;
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1008
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1009 sprintf (dest, "m 1\n");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1010
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1011 while (fgets (line, BUF_LEN, src_fp)) {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1012 line2 = remove_spaces (line);
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1013 if (strstr (line2, "group") == line2) {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1014 name = strpbrk (line2, " \t\n\r\f") + 1;
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1015 strcat (dest, "g ");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1016 for (i = 0; i < strcspn (name, "\n\r"); i++)
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1017 if (name[i] != '\"')
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1018 strncat (dest, &name[i], 1);
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1019 strcat (dest, "\n");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1020 }
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1021 if (strstr (line2, "buddy") == line2) {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1022 name = strpbrk (line2, " \t\n\r\f") + 1;
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1023 strcat (dest, "b ");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1024 for (i = 0; i < strcspn (name, "\n\r"); i++)
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1025 if (name[i] != '\"')
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1026 strncat (dest, &name[i], 1);
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1027 strcat (dest, "\n");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1028 }
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1029 }
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1030
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1031 return;
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1032 }
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1033
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1034
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1035 /* translate an AIM 4 buddylist (*.blt) to GAIM format */
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1036 void translate_blt (FILE *src_fp, char *dest)
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1037 {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1038 int i;
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1039 char line[BUF_LEN];
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1040 char *buddy;
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1041
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1042 sprintf (dest, "m 1\n");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1043
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1044 while (strstr (fgets (line, BUF_LEN, src_fp), "Buddy") == NULL) ;
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1045 while (strstr (fgets (line, BUF_LEN, src_fp), "list") == NULL) ;
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1046
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1047 while (1) {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1048 fgets (line, BUF_LEN, src_fp);
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1049 if (strchr (line, '}') != NULL)
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1050 break;
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1051
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1052 /* Syntax starting with "<group> {" */
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1053 if (strchr (line, '{') != NULL) {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1054 strcat (dest, "g ");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1055 buddy = remove_spaces (strtok (line, "{"));
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1056 for (i = 0; i < strlen(buddy); i++) {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1057 if (buddy[i] != '\"')
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1058 strncat (dest, &buddy[i], 1);
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 strcat (dest, "\n");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1061 while (strchr (fgets (line, BUF_LEN, src_fp), '}') == NULL) {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1062 buddy = remove_spaces (line);
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1063 strcat (dest, "b ");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1064 if (strchr (buddy, '\"') != NULL) {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1065 strncat (dest, &buddy[1], strlen(buddy)-3);
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1066 strcat (dest, "\n");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1067 } else
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1068 strcat (dest, buddy);
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1069 }
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1070 }
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1071 /* Syntax "group buddy buddy ..." */
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1072 else {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1073 buddy = remove_spaces (strtok (line, " \n"));
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1074 strcat (dest, "g ");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1075 if (strchr (buddy, '\"') != NULL) {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1076 strcat (dest, &buddy[1]);
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1077 strcat (dest, " ");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1078 buddy = remove_spaces (strtok (NULL, " \n"));
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1079 while (strchr (buddy, '\"') == NULL) {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1080 strcat (dest, buddy);
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1081 strcat (dest, " ");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1082 buddy = remove_spaces (strtok (NULL, " \n"));
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1083 }
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1084 strncat (dest, buddy, strlen(buddy)-1);
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1085 } else {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1086 strcat (dest, buddy);
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1087 }
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1088 strcat (dest, "\n");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1089 while ((buddy = remove_spaces (strtok (NULL, " \n"))) != NULL) {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1090 strcat (dest, "b ");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1091 if (strchr (buddy, '\"') != NULL) {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1092 strcat (dest, &buddy[1]);
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1093 strcat (dest, " ");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1094 buddy = remove_spaces (strtok (NULL, " \n"));
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1095 while (strchr (buddy, '\"') == NULL) {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1096 strcat (dest, buddy);
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1097 strcat (dest, " ");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1098 buddy = remove_spaces (strtok (NULL, " \n"));
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1099 }
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1100 strncat (dest, buddy, strlen(buddy)-1);
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1101 } else {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1102 strcat (dest, buddy);
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1103 }
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1104 strcat (dest, "\n");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1105 }
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1106 }
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1107 }
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1108
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1109 return;
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1110 }
764
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
1111
765
bf31bf916f53 [gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 764
diff changeset
1112 char *stylize(gchar *text, int length)
764
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
1113 {
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
1114 gchar *buf;
765
bf31bf916f53 [gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 764
diff changeset
1115 char tmp[length];
764
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
1116
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
1117 buf = g_malloc(length);
765
bf31bf916f53 [gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 764
diff changeset
1118 g_snprintf(buf, length, "%s", text);
764
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
1119
831
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
1120 if (font_options & OPT_FONT_BOLD) {
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
1121 g_snprintf(tmp, length, "<B>%s</B>", buf);
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
1122 strcpy(buf, tmp);
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
1123 }
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
1124
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
1125 if (font_options & OPT_FONT_ITALIC) {
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
1126 g_snprintf(tmp, length, "<I>%s</I>", buf);
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
1127 strcpy(buf, tmp);
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
1128 }
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
1129
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
1130 if (font_options & OPT_FONT_UNDERLINE) {
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
1131 g_snprintf(tmp, length, "<U>%s</U>", buf);
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
1132 strcpy(buf, tmp);
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
1133 }
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
1134
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
1135 if (font_options & OPT_FONT_STRIKE) {
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
1136 g_snprintf(tmp, length, "<S>%s</S>", buf);
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
1137 strcpy(buf, tmp);
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
1138 }
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
1139
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
1140 if (font_options & OPT_FONT_FACE) {
765
bf31bf916f53 [gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 764
diff changeset
1141 g_snprintf(tmp, length, "<FONT FACE=\"%s\">%s</FONT>", fontface, buf);
bf31bf916f53 [gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 764
diff changeset
1142 strcpy(buf, tmp);
764
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
1143 }
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
1144
831
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
1145 if (font_options & OPT_FONT_FGCOL) {
765
bf31bf916f53 [gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 764
diff changeset
1146 g_snprintf(tmp, length, "<FONT COLOR=\"#%02X%02X%02X\">%s</FONT>", fgcolor.red, fgcolor.green, fgcolor.blue, buf);
bf31bf916f53 [gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 764
diff changeset
1147 strcpy(buf, tmp);
764
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
1148 }
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
1149
831
97f1ae636ed7 [gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 804
diff changeset
1150 if (font_options & OPT_FONT_BGCOL) {
765
bf31bf916f53 [gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 764
diff changeset
1151 g_snprintf(tmp, length, "<BODY BGCOLOR=\"#%02X%02X%02X\">%s</BODY>", bgcolor.red, bgcolor.green, bgcolor.blue, buf);
bf31bf916f53 [gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 764
diff changeset
1152 strcpy(buf, tmp);
764
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
1153 }
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
1154
765
bf31bf916f53 [gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 764
diff changeset
1155 return buf;
bf31bf916f53 [gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 764
diff changeset
1156 }