annotate src/util.c @ 771:72e556f6b99d

[gaim-migrate @ 781] libfaim gets warnings, and other minor changes committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Mon, 28 Aug 2000 05:07:43 +0000
parents 172c5cf98dfa
children 17def2bb9720
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;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
124 char cpy[BUF_LONG];
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 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
143 } else if (!strncasecmp(c, "http://", 7)) {
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;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
308 return cnt;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
309 }
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
373
1d29321843b0 [gaim-migrate @ 383]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
312 FILE *open_log_file (char *name)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
313 {
79
bfdc427b936d [gaim-migrate @ 89]
Rob Flynn <gaim@robflynn.com>
parents: 70
diff changeset
314 char *buf;
bfdc427b936d [gaim-migrate @ 89]
Rob Flynn <gaim@robflynn.com>
parents: 70
diff changeset
315 char *buf2;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
316 char log_all_file[256];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
317 struct log_conversation *l;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
318 struct stat st;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
319 int flag = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
320 FILE *fd;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
321 int res;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
322
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
323 if (!(general_options & OPT_GEN_LOG_ALL)) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
324
373
1d29321843b0 [gaim-migrate @ 383]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
325 l = find_log_info(name);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
326 if (!l)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
327 return NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
328
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
329 if (stat(l->filename, &st) < 0)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
330 flag = 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
331
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
332 fd = fopen(l->filename, "a");
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
333
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
334 if (flag) { /* is a new file */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
335 fprintf(fd, "<HTML><HEAD><TITLE>" );
373
1d29321843b0 [gaim-migrate @ 383]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
336 fprintf(fd, "IM Sessions with %s", name );
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
337 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"ffffff\">\n" );
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
338 }
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 return fd;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
341 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
342
79
bfdc427b936d [gaim-migrate @ 89]
Rob Flynn <gaim@robflynn.com>
parents: 70
diff changeset
343 buf = g_malloc(BUF_LONG);
bfdc427b936d [gaim-migrate @ 89]
Rob Flynn <gaim@robflynn.com>
parents: 70
diff changeset
344 buf2 = g_malloc(BUF_LONG);
bfdc427b936d [gaim-migrate @ 89]
Rob Flynn <gaim@robflynn.com>
parents: 70
diff changeset
345
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
346 /* Dont log yourself */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
347 g_snprintf(log_all_file, 256, "%s/.gaim", getenv("HOME"));
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
348
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
349 stat(log_all_file, &st);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
350 if (!S_ISDIR(st.st_mode))
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
351 unlink(log_all_file);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
352
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
353 fd = fopen(log_all_file, "r");
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
354
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
355 if (!fd) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
356 res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
357 if (res < 0) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
358 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
359 do_error_dialog(buf, "Error!");
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
360 g_free(buf);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
361 g_free(buf2);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
362 return NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
363 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
364 } else
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
365 fclose(fd);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
366
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
367 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
368
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
369 if (stat(log_all_file, &st) < 0)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
370 flag = 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
371 if (!S_ISDIR(st.st_mode))
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
372 unlink(log_all_file);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
373
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
374 fd = fopen(log_all_file, "r");
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
375 if (!fd) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
376 res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
377 if (res < 0) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
378 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
379 do_error_dialog(buf, "Error!");
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
380 g_free(buf);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
381 g_free(buf2);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
382 return NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
383 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
384 } else
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
385 fclose(fd);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
386
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
387
373
1d29321843b0 [gaim-migrate @ 383]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
388 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
389
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
390 if (stat(log_all_file, &st) < 0)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
391 flag = 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
392
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
393 sprintf(debug_buff,"Logging to: \"%s\"\n", log_all_file);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
394 debug_print(debug_buff);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
395
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
396 fd = fopen(log_all_file, "a");
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
397
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
398 if (flag) { /* is a new file */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
399 fprintf(fd, "<HTML><HEAD><TITLE>" );
373
1d29321843b0 [gaim-migrate @ 383]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
400 fprintf(fd, "IM Sessions with %s", name );
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
401 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"ffffff\">\n" );
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
402 }
25
c56db1b46b0d [gaim-migrate @ 34]
Rob Flynn <gaim@robflynn.com>
parents: 17
diff changeset
403
c56db1b46b0d [gaim-migrate @ 34]
Rob Flynn <gaim@robflynn.com>
parents: 17
diff changeset
404 g_free(buf);
c56db1b46b0d [gaim-migrate @ 34]
Rob Flynn <gaim@robflynn.com>
parents: 17
diff changeset
405 g_free(buf2);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
406 return fd;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
407 }
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
254
fa67d29b53d5 [gaim-migrate @ 264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 210
diff changeset
410 /* we only need this for TOC, because messages must be escaped */
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
411 int escape_message(char *msg)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
412 {
423
0d4e80bdb96b [gaim-migrate @ 433]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 413
diff changeset
413 if (!USE_OSCAR) {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
414 char *c, *cpy;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
415 int cnt=0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
416 /* 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
417 if (strlen(msg) > BUF_LEN) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
418 sprintf(debug_buff, "Warning: truncating message to 2048 bytes\n");
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
419 debug_print(debug_buff);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
420 msg[2047]='\0';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
421 }
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 cpy = g_strdup(msg);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
424 c = cpy;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
425 while(*c) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
426 switch(*c) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
427 case '$':
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 msg[cnt++]='\\';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
434 /* Fall through */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
435 default:
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
436 msg[cnt++]=*c;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
437 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
438 c++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
439 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
440 msg[cnt]='\0';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
441 g_free(cpy);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
442 return cnt;
423
0d4e80bdb96b [gaim-migrate @ 433]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 413
diff changeset
443 } else {
254
fa67d29b53d5 [gaim-migrate @ 264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 210
diff changeset
444 return strlen(msg);
423
0d4e80bdb96b [gaim-migrate @ 433]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 413
diff changeset
445 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
446 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
447
254
fa67d29b53d5 [gaim-migrate @ 264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 210
diff changeset
448 /* we don't need this for oscar either */
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
449 int escape_text(char *msg)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
450 {
423
0d4e80bdb96b [gaim-migrate @ 433]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 413
diff changeset
451 if (!USE_OSCAR) {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
452 char *c, *cpy;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
453 int cnt=0;
79
bfdc427b936d [gaim-migrate @ 89]
Rob Flynn <gaim@robflynn.com>
parents: 70
diff changeset
454 /* 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
455 if (strlen(msg) > BUF_LEN) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
456 fprintf(stderr, "Warning: truncating message to 2048 bytes\n");
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
457 msg[2047]='\0';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
458 }
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 cpy = g_strdup(msg);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
461 c = cpy;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
462 while(*c) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
463 switch(*c) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
464 case '\n':
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
465 msg[cnt++] = '<';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
466 msg[cnt++] = 'B';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
467 msg[cnt++] = 'R';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
468 msg[cnt++] = '>';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
469 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
470 case '{':
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 msg[cnt++]='\\';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
475 /* Fall through */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
476 default:
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
477 msg[cnt++]=*c;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
478 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
479 c++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
480 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
481 msg[cnt]='\0';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
482 g_free(cpy);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
483 return cnt;
423
0d4e80bdb96b [gaim-migrate @ 433]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 413
diff changeset
484 } else {
254
fa67d29b53d5 [gaim-migrate @ 264]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 210
diff changeset
485 return strlen(msg);
423
0d4e80bdb96b [gaim-migrate @ 433]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 413
diff changeset
486 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
487 }
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 char * escape_text2(char *msg)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
490 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
491 char *c, *cpy;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
492 char *woo;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
493 int cnt=0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
494 /* 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
495 if (strlen(msg) > BUF_LEN) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
496 fprintf(stderr, "Warning: truncating message to 2048 bytes\n");
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
497 msg[2047]='\0';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
498 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
499
79
bfdc427b936d [gaim-migrate @ 89]
Rob Flynn <gaim@robflynn.com>
parents: 70
diff changeset
500 woo = malloc(strlen(msg) * 2);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
501 cpy = g_strdup(msg);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
502 c = cpy;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
503 while(*c) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
504 switch(*c) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
505 case '\n':
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
506 woo[cnt++] = '<';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
507 woo[cnt++] = 'B';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
508 woo[cnt++] = 'R';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
509 woo[cnt++] = '>';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
510 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
511 case '{':
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 woo[cnt++]='\\';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
516 /* Fall through */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
517 default:
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
518 woo[cnt++]=*c;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
519 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
520 c++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
521 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
522 woo[cnt]='\0';
26
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 25
diff changeset
523
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 25
diff changeset
524 g_free (cpy);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
525 return woo;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
526 }
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 char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
530 "0123456789+/";
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
531
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 char *tobase64(char *text)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
534 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
535 char *out = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
536 char *c;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
537 unsigned int tmp = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
538 int len = 0, n = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
539
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
540 c = text;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
541
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
542 while(c) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
543 tmp = tmp << 8;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
544 tmp += *c;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
545 n++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
546
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
547 if (n == 3) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
548 out = g_realloc(out, len+4);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
549 out[len] = alphabet[(tmp >> 18) & 0x3f];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
550 out[len+1] = alphabet[(tmp >> 12) & 0x3f];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
551 out[len+2] = alphabet[(tmp >> 6) & 0x3f];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
552 out[len+3] = alphabet[tmp & 0x3f];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
553 len += 4;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
554 tmp = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
555 n = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
556 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
557 c++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
558 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
559 switch(n) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
560
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
561 case 2:
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
562 out = g_realloc(out, len+5);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
563 out[len] = alphabet[(tmp >> 12) & 0x3f];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
564 out[len+1] = alphabet[(tmp >> 6) & 0x3f];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
565 out[len+2] = alphabet[tmp & 0x3f];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
566 out[len+3] = '=';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
567 out[len+4] = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
568 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
569 case 1:
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
570 out = g_realloc(out, len+4);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
571 out[len] = alphabet[(tmp >> 6) & 0x3f];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
572 out[len+1] = alphabet[tmp & 0x3f];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
573 out[len+2] = '=';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
574 out[len+3] = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
575 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
576 case 0:
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
577 out = g_realloc(out, len+2);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
578 out[len] = '=';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
579 out[len+1] = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
580 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
581 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
582 return out;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
583 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
584
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 char *frombase64(char *text)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
587 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
588 char *out = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
589 char tmp = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
590 char *c;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
591 gint32 tmp2 = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
592 int len = 0, n = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
593
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
594 c = text;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
595
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
596 while(*c) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
597 if (*c >= 'A' && *c <= 'Z') {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
598 tmp = *c - 'A';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
599 } else if (*c >= 'a' && *c <= 'z') {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
600 tmp = 26 + (*c - 'a');
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
601 } else if (*c >= '0' && *c <= 57) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
602 tmp = 52 + (*c - '0');
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
603 } else if (*c == '+') {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
604 tmp = 62;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
605 } else if (*c == '/') {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
606 tmp = 63;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
607 } else if (*c == '=') {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
608 if (n == 3) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
609 out = g_realloc(out, len + 2);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
610 out[len] = (char)(tmp2 >> 10) & 0xff;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
611 len++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
612 out[len] = (char)(tmp2 >> 2) & 0xff;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
613 len++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
614 } else if (n == 2) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
615 out = g_realloc(out, len + 1);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
616 out[len] = (char)(tmp2 >> 4) & 0xff;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
617 len++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
618 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
619 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
620 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
621 tmp2 = ((tmp2 << 6) | (tmp & 0xff));
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
622 n++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
623 if (n == 4) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
624 out = g_realloc(out, len + 3);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
625 out[len] = (char)((tmp2 >> 16) & 0xff);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
626 len++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
627 out[len] = (char)((tmp2 >> 8) & 0xff);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
628 len++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
629 out[len] = (char)(tmp2 & 0xff);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
630 len++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
631 tmp2 = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
632 n = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
633 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
634 c++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
635 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
636
194
d7690984c0f1 [gaim-migrate @ 204]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 180
diff changeset
637 out = g_realloc(out, len+1);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
638 out[len] = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
639
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
640 return out;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
641 }
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 char *normalize(const char *s)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
645 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
646 static char buf[BUF_LEN];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
647 char *t, *u;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
648 int x=0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
649
79
bfdc427b936d [gaim-migrate @ 89]
Rob Flynn <gaim@robflynn.com>
parents: 70
diff changeset
650 g_return_val_if_fail ((s != NULL), NULL);
26
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 25
diff changeset
651
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 25
diff changeset
652 u = t = g_strdup(s);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
653
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
654 strcpy(t, s);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
655 g_strdown(t);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
656
26
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 25
diff changeset
657 while(*t && (x < BUF_LEN - 1)) {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
658 if (*t != ' ') {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
659 buf[x] = *t;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
660 x++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
661 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
662 t++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
663 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
664 buf[x]='\0';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
665 g_free(u);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
666 return buf;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
667 }
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 int query_state()
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
670 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
671 return state;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
672 }
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 void set_state(int i)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
675 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
676 state = i;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
677 }
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 char *date()
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
680 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
681 static char date[80];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
682 time_t tme;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
683 time(&tme);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
684 strftime(date, sizeof(date), "%H:%M:%S", localtime(&tme));
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
685 return date;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
686 }
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 gint clean_pid(void *dummy)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
690 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
691 int status;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
692 pid_t pid;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
693
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
694 pid = waitpid(-1, &status, WNOHANG);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
695
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
696 if (pid == 0)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
697 return TRUE;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
698
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
699 return FALSE;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
700 }
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 void aol_icon(GdkWindow *w)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
703 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
704 #ifndef _WIN32
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
705 if (icon_pm == NULL) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
706 icon_pm = gdk_pixmap_create_from_xpm_d(w, &icon_bm,
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
707 NULL, (gchar **)aimicon_xpm);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
708 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
709 gdk_window_set_icon(w, NULL, icon_pm, icon_bm);
10
34db9f242899 [gaim-migrate @ 19]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
710 if (mainwindow) gdk_window_set_group(w, mainwindow->window);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
711 #endif
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
712 }
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 struct aim_user *find_user(const char *name)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
715 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
716 char *who = g_strdup(normalize(name));
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
717 GList *usr = aim_users;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
718 struct aim_user *u;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
719
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
720 while(usr) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
721 u = (struct aim_user *)usr->data;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
722 if (!strcmp(normalize(u->username), who)) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
723 g_free(who);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
724 return u;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
725 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
726 usr = usr->next;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
727 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
728 g_free(who);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
729 return NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
730 }
180
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
731
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
732 void check_gaim_versions()
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
733 {
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
734 char *cur_ver;
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
735 char *tmp;
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
736
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
737 tmp = (char *)malloc(BUF_LONG);
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
738
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
739 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
740
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
741 if (!strncasecmp(cur_ver, "g00", 3))
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
742 {
278
29e1669b006b [gaim-migrate @ 288]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 254
diff changeset
743 g_free(cur_ver);
29e1669b006b [gaim-migrate @ 288]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 254
diff changeset
744 g_free(tmp);
180
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
745 return;
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
746 }
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 g_snprintf(tmp, BUF_LONG, "%s", strstr(cur_ver, "plain")+9);
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
749 g_strchomp(tmp);
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
750
278
29e1669b006b [gaim-migrate @ 288]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 254
diff changeset
751 if (strcmp(tmp, latest_ver))
180
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
752 {
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
753 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
754
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
755 do_error_dialog(cur_ver, "GAIM - New Version!");
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
756 strcpy(latest_ver, tmp);
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
757 save_prefs();
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
758 }
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 free(tmp);
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
761 free(cur_ver);
0ff9f19b9b23 [gaim-migrate @ 190]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
762 }
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
206
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
765 /*
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 This function was taken from EveryBuddy and was written by
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
768 Torrey Searle. tsearle@valhalla.marko.net
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
769
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
770 http://www.everybuddy.com
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
771
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
209
6e9b375e30e7 [gaim-migrate @ 219]
Rob Flynn <gaim@robflynn.com>
parents: 206
diff changeset
774 void spell_checker(GtkWidget * text)
206
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
775 {
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
776 int start = 0;
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
777 int end = 0;
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
778 static GdkColor * color = NULL;
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
779 int ignore = 0;
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
780 int point = gtk_editable_get_position(GTK_EDITABLE(text));
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
781
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
782 GString * string;
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
783
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
784 if( color == NULL )
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
785 {
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
786 GdkColormap * gc = gtk_widget_get_colormap( text );
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
787 color = g_new0(GdkColor, 1);
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
788 color->red = 255 * 256;
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
789 gdk_colormap_alloc_color(gc, color, FALSE, TRUE);
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
790 }
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 end = point-1;
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
795 for( start = end-1; start >= 0; start-- )
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
796 {
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
797 if((isspace(GTK_TEXT_INDEX(GTK_TEXT(text), start)) || start == 0)
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
798 && !ignore)
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
799 {
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
800 char * word;
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
801 FILE * file;
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
802 char buff[1024];
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
803 word = gtk_editable_get_chars( GTK_EDITABLE(text), start, end );
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
804 g_snprintf(buff, 1024, "echo \"%s\" | ispell -l", word );
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
805 file = popen(buff, "r");
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
806
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
807 buff[0] = 0;
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
808 fgets(buff, 255, file);
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
809
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
810 if(strlen(buff) > 0 )
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
811 {
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
812 string = g_string_new(word);
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
813 gtk_text_set_point(GTK_TEXT(text), end);
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
814 gtk_text_backward_delete(GTK_TEXT(text), end-start);
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
815 gtk_text_insert( GTK_TEXT(text), NULL, color, NULL,
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
816 string->str, string->len );
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
817 g_string_free( string, TRUE );
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
818 }
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
819 else
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
820 {
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
821 string = g_string_new(word);
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
822 gtk_text_set_point(GTK_TEXT(text), end);
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
823 gtk_text_backward_delete(GTK_TEXT(text), end-start);
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
824 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
825 string->str, string->len );
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
826 g_string_free( string, TRUE );
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
827 }
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
828 pclose( file);
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
829 break;
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
830 }
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
831 else if(!isalpha(GTK_TEXT_INDEX(GTK_TEXT(text), start)))
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 ignore = 1;
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 }
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
836 gtk_text_set_point(GTK_TEXT(text), point);
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 }
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 194
diff changeset
839
592
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
840 /* 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
841 or time */
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
842 char *away_subs(char *msg, char *name)
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
843 {
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
844 char *c;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
845 static char cpy[BUF_LONG];
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
846 int cnt=0;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
847 time_t t = time(0);
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
848 struct tm *tme = localtime(&t);
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
849 char tmp[20];
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
850
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
851 cpy[0] = '\0';
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
852 c = msg;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
853 while(*c) {
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
854 switch(*c) {
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
855 case '%':
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
856 if (*(c+1)) {
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
857 switch (*(c+1)) {
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
858 case 'n':
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
859 // append name
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
860 strcpy (cpy+cnt, name);
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
861 cnt += strlen(name);
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
862 c++;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
863 break;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
864 case 'd':
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
865 // append date
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
866 strftime (tmp, 20, "%D", tme);
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
867 strcpy (cpy+cnt, tmp);
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
868 cnt += strlen(tmp);
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
869 c++;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
870 break;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
871 case 't':
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
872 // append time
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
873 strftime (tmp, 20, "%r", tme);
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
874 strcpy (cpy+cnt, tmp);
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
875 cnt += strlen(tmp);
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
876 c++;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
877 break;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
878 default:
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
879 cpy[cnt++]=*c;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
880 }
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
881 }
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
882 break;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
883 default:
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
884 cpy[cnt++]=*c;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
885 }
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
886 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 cpy[cnt]='\0';
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
889 return(cpy);
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 470
diff changeset
890 }
603
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
891
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
892 GtkWidget *picture_button(GtkWidget *window, char *text, char **xpm)
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 *button;
619
faa7603ae02e [gaim-migrate @ 629]
Todd Kulesza <fflewddur>
parents: 617
diff changeset
895 GtkWidget *button_box, *button_box_2, *button_box_3;
603
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
896 GtkWidget *label;
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
897 GdkBitmap *mask;
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
898 GdkPixmap *pm;
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
899 GtkWidget *pixmap;
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
900
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
901 button = gtk_button_new();
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
902 if (display_options & OPT_DISP_COOL_LOOK)
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
903 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
904
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
905 button_box = gtk_hbox_new(FALSE, 5);
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
906 gtk_container_add(GTK_CONTAINER(button), button_box);
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
907
619
faa7603ae02e [gaim-migrate @ 629]
Todd Kulesza <fflewddur>
parents: 617
diff changeset
908 button_box_2 = gtk_hbox_new(FALSE, 0);
faa7603ae02e [gaim-migrate @ 629]
Todd Kulesza <fflewddur>
parents: 617
diff changeset
909 button_box_3 = gtk_hbox_new(FALSE, 0);
faa7603ae02e [gaim-migrate @ 629]
Todd Kulesza <fflewddur>
parents: 617
diff changeset
910 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
911 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
912 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
913 pixmap = gtk_pixmap_new(pm, mask);
619
faa7603ae02e [gaim-migrate @ 629]
Todd Kulesza <fflewddur>
parents: 617
diff changeset
914 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
915
623
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
916 if (text)
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
917 {
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
918 label = gtk_label_new(text);
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
919 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
920 }
619
faa7603ae02e [gaim-migrate @ 629]
Todd Kulesza <fflewddur>
parents: 617
diff changeset
921
faa7603ae02e [gaim-migrate @ 629]
Todd Kulesza <fflewddur>
parents: 617
diff changeset
922 gtk_widget_show(pixmap);
623
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
923 if (text)
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
924 {
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
925 gtk_widget_show(label);
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
926 }
619
faa7603ae02e [gaim-migrate @ 629]
Todd Kulesza <fflewddur>
parents: 617
diff changeset
927 gtk_widget_show(button_box_2);
faa7603ae02e [gaim-migrate @ 629]
Todd Kulesza <fflewddur>
parents: 617
diff changeset
928 gtk_widget_show(button_box_3);
faa7603ae02e [gaim-migrate @ 629]
Todd Kulesza <fflewddur>
parents: 617
diff changeset
929 gtk_widget_show(button_box);
651
650687b7ca0e [gaim-migrate @ 661]
Rob Flynn <gaim@robflynn.com>
parents: 644
diff changeset
930
726
012bf218a655 [gaim-migrate @ 736]
Todd Kulesza <fflewddur>
parents: 684
diff changeset
931 /* this causes clipping on lots of buttons with long text */
012bf218a655 [gaim-migrate @ 736]
Todd Kulesza <fflewddur>
parents: 684
diff changeset
932 /* gtk_widget_set_usize(button, 75, 30);*/
619
faa7603ae02e [gaim-migrate @ 629]
Todd Kulesza <fflewddur>
parents: 617
diff changeset
933 gtk_widget_show(button);
644
b3900e312d8e [gaim-migrate @ 654]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 623
diff changeset
934 gdk_pixmap_unref(pm);
619
faa7603ae02e [gaim-migrate @ 629]
Todd Kulesza <fflewddur>
parents: 617
diff changeset
935
603
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
936 return button;
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
937 }
623
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
938
759
9389216aae29 [gaim-migrate @ 769]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 754
diff changeset
939 static GtkTooltips *tips = NULL;
754
bcae3ff49680 [gaim-migrate @ 764]
Rob Flynn <gaim@robflynn.com>
parents: 726
diff changeset
940 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
941 {
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
942 GtkWidget *button;
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
943 GtkWidget *button_box, *button_box_2;
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
944 GdkBitmap *mask;
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
945 GdkPixmap *pm;
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
946 GtkWidget *pixmap;
754
bcae3ff49680 [gaim-migrate @ 764]
Rob Flynn <gaim@robflynn.com>
parents: 726
diff changeset
947 GtkWidget *label;
623
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
948
759
9389216aae29 [gaim-migrate @ 769]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 754
diff changeset
949 if (!tips) tips = gtk_tooltips_new();
623
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
950 button = gtk_button_new();
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
951 if (display_options & OPT_DISP_COOL_LOOK)
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
952 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
953
651
650687b7ca0e [gaim-migrate @ 661]
Rob Flynn <gaim@robflynn.com>
parents: 644
diff changeset
954 button_box = gtk_hbox_new(FALSE, 0);
623
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
955 gtk_container_add(GTK_CONTAINER(button), button_box);
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
956
754
bcae3ff49680 [gaim-migrate @ 764]
Rob Flynn <gaim@robflynn.com>
parents: 726
diff changeset
957 button_box_2 = gtk_vbox_new(FALSE, 0);
623
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
958
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
959 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
960 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
961 pixmap = gtk_pixmap_new(pm, mask);
754
bcae3ff49680 [gaim-migrate @ 764]
Rob Flynn <gaim@robflynn.com>
parents: 726
diff changeset
962 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
963
767
be917c4d3e39 [gaim-migrate @ 777]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 765
diff changeset
964 if (showtext)
754
bcae3ff49680 [gaim-migrate @ 764]
Rob Flynn <gaim@robflynn.com>
parents: 726
diff changeset
965 {
bcae3ff49680 [gaim-migrate @ 764]
Rob Flynn <gaim@robflynn.com>
parents: 726
diff changeset
966 label = gtk_label_new(text);
bcae3ff49680 [gaim-migrate @ 764]
Rob Flynn <gaim@robflynn.com>
parents: 726
diff changeset
967 gtk_widget_show(label);
bcae3ff49680 [gaim-migrate @ 764]
Rob Flynn <gaim@robflynn.com>
parents: 726
diff changeset
968 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
969 }
623
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
970
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
971 gtk_widget_show(pixmap);
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
972 gtk_widget_show(button_box_2);
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
973 gtk_widget_show(button_box);
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
974 gtk_widget_show(button);
644
b3900e312d8e [gaim-migrate @ 654]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 623
diff changeset
975 gdk_pixmap_unref(pm);
623
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
976
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
977 gtk_tooltips_set_tip(tips, button, text, "Gaim");
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
978 return button;
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
979 }
83b0caceea9a [gaim-migrate @ 633]
Rob Flynn <gaim@robflynn.com>
parents: 619
diff changeset
980
684
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
981
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
982 /* remove leading whitespace from a string */
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
983 char *remove_spaces (char *str)
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
984 {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
985 int i;
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
986 char *new;
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
987
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
988 if (str == NULL)
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
989 return NULL;
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
990
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
991 i = strspn (str, " \t\n\r\f");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
992 new = &str[i];
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
993
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
994 return new;
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
995 }
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
996
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 /* translate an AIM 3 buddylist (*.lst) to a GAIM buddylist */
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
999 void translate_lst (FILE *src_fp, char *dest)
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 char line[BUF_LEN], *line2;
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1002 char *name;
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1003 int i;
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 sprintf (dest, "m 1\n");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1006
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1007 while (fgets (line, BUF_LEN, src_fp)) {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1008 line2 = remove_spaces (line);
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1009 if (strstr (line2, "group") == line2) {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1010 name = strpbrk (line2, " \t\n\r\f") + 1;
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1011 strcat (dest, "g ");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1012 for (i = 0; i < strcspn (name, "\n\r"); i++)
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1013 if (name[i] != '\"')
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1014 strncat (dest, &name[i], 1);
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1015 strcat (dest, "\n");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1016 }
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1017 if (strstr (line2, "buddy") == line2) {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1018 name = strpbrk (line2, " \t\n\r\f") + 1;
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1019 strcat (dest, "b ");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1020 for (i = 0; i < strcspn (name, "\n\r"); i++)
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1021 if (name[i] != '\"')
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1022 strncat (dest, &name[i], 1);
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1023 strcat (dest, "\n");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1024 }
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1025 }
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1026
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1027 return;
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 /* translate an AIM 4 buddylist (*.blt) to GAIM format */
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1032 void translate_blt (FILE *src_fp, char *dest)
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 int i;
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1035 char line[BUF_LEN];
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1036 char *buddy;
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 sprintf (dest, "m 1\n");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1039
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1040 while (strstr (fgets (line, BUF_LEN, src_fp), "Buddy") == NULL) ;
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1041 while (strstr (fgets (line, BUF_LEN, src_fp), "list") == NULL) ;
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1042
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1043 while (1) {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1044 fgets (line, BUF_LEN, src_fp);
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1045 if (strchr (line, '}') != NULL)
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1046 break;
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1047
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1048 /* Syntax starting with "<group> {" */
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 strcat (dest, "g ");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1051 buddy = remove_spaces (strtok (line, "{"));
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1052 for (i = 0; i < strlen(buddy); i++) {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1053 if (buddy[i] != '\"')
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1054 strncat (dest, &buddy[i], 1);
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1055 }
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1056 strcat (dest, "\n");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1057 while (strchr (fgets (line, BUF_LEN, src_fp), '}') == NULL) {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1058 buddy = remove_spaces (line);
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1059 strcat (dest, "b ");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1060 if (strchr (buddy, '\"') != NULL) {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1061 strncat (dest, &buddy[1], strlen(buddy)-3);
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1062 strcat (dest, "\n");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1063 } else
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1064 strcat (dest, buddy);
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1065 }
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1066 }
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1067 /* Syntax "group buddy buddy ..." */
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1068 else {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1069 buddy = remove_spaces (strtok (line, " \n"));
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1070 strcat (dest, "g ");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1071 if (strchr (buddy, '\"') != NULL) {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1072 strcat (dest, &buddy[1]);
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1073 strcat (dest, " ");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1074 buddy = remove_spaces (strtok (NULL, " \n"));
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1075 while (strchr (buddy, '\"') == NULL) {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1076 strcat (dest, buddy);
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 }
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1080 strncat (dest, buddy, strlen(buddy)-1);
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1081 } else {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1082 strcat (dest, buddy);
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 strcat (dest, "\n");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1085 while ((buddy = remove_spaces (strtok (NULL, " \n"))) != NULL) {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1086 strcat (dest, "b ");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1087 if (strchr (buddy, '\"') != NULL) {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1088 strcat (dest, &buddy[1]);
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1089 strcat (dest, " ");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1090 buddy = remove_spaces (strtok (NULL, " \n"));
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1091 while (strchr (buddy, '\"') == NULL) {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1092 strcat (dest, buddy);
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 }
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1096 strncat (dest, buddy, strlen(buddy)-1);
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1097 } else {
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1098 strcat (dest, buddy);
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 strcat (dest, "\n");
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1101 }
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1102 }
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
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1105 return;
b29c92be568b [gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 651
diff changeset
1106 }
764
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
1107
765
bf31bf916f53 [gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 764
diff changeset
1108 char *stylize(gchar *text, int length)
764
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
1109 {
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
1110 gchar *buf;
765
bf31bf916f53 [gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 764
diff changeset
1111 char tmp[length];
764
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
1112
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
1113 buf = g_malloc(length);
765
bf31bf916f53 [gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 764
diff changeset
1114 g_snprintf(buf, length, "%s", text);
764
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
1115
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
1116 if (font_options & OPT_FONT_FACE)
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
1117 {
765
bf31bf916f53 [gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 764
diff changeset
1118 g_snprintf(tmp, length, "<FONT FACE=\"%s\">%s</FONT>", fontface, buf);
bf31bf916f53 [gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 764
diff changeset
1119 strcpy(buf, tmp);
764
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
1120 }
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
1121
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
1122 if (font_options & OPT_FONT_FGCOL)
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
1123 {
765
bf31bf916f53 [gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 764
diff changeset
1124 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
1125 strcpy(buf, tmp);
764
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
1126 }
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
1127
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
1128 if (font_options & OPT_FONT_BGCOL)
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
1129 {
765
bf31bf916f53 [gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 764
diff changeset
1130 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
1131 strcpy(buf, tmp);
764
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
1132 }
a566fc987db9 [gaim-migrate @ 774]
Todd Kulesza <fflewddur>
parents: 759
diff changeset
1133
765
bf31bf916f53 [gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 764
diff changeset
1134 return buf;
bf31bf916f53 [gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 764
diff changeset
1135 }