annotate plugins/filectl.c @ 2234:2abf9cc183a0

[gaim-migrate @ 2244] don't need these anymore committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Fri, 07 Sep 2001 09:02:57 +0000
parents ece2d1543b20
children 9ab820049ede
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
106
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 #define GAIM_PLUGINS
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 #include "gaim.h"
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 #include <gtk/gtk.h>
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 #include <stdlib.h>
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 #include <unistd.h>
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 #include <sys/types.h>
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 #include <sys/stat.h>
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 #include <string.h>
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 #include <ctype.h>
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11
179
8d8faeab01f6 [gaim-migrate @ 189]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
12 static void *handle;
8d8faeab01f6 [gaim-migrate @ 189]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
13 static int check;
8d8faeab01f6 [gaim-migrate @ 189]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
14 static time_t mtime;
106
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15
179
8d8faeab01f6 [gaim-migrate @ 189]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
16 static void init_file();
8d8faeab01f6 [gaim-migrate @ 189]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
17 static void check_file();
106
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 extern void do_quit();
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 /* parse char * as if were word array */
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 char *getarg(char *, int, int);
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 /* go through file and run any commands */
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 void run_commands() {
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 struct stat finfo;
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 char filename[256];
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 char buffer[1024];
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 char *command, *arg1, *arg2;
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 FILE *file;
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 sprintf(filename, "%s/.gaim/control", getenv("HOME"));
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 file = fopen(filename, "r+");
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 while (fgets(buffer, sizeof buffer, file)) {
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 if (buffer[strlen(buffer) - 1] == '\n')
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 buffer[strlen(buffer) - 1] = 0;
179
8d8faeab01f6 [gaim-migrate @ 189]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
38 sprintf(debug_buff, "read: %s\n", buffer);
8d8faeab01f6 [gaim-migrate @ 189]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
39 debug_print(debug_buff);
106
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40 command = getarg(buffer, 0, 0);
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41 if (!strncasecmp(command, "signon", 6)) {
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42 if (!blist) {
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 show_login();
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 dologin(NULL, NULL);
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 }
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 } else if (!strncasecmp(command, "signoff", 7)) {
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 576
diff changeset
47 struct gaim_connection *gc = NULL;
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 576
diff changeset
48 arg1 = getarg(buffer, 1, 1);
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 576
diff changeset
49 if (arg1) gc = find_gaim_conn_by_name(arg1);
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 576
diff changeset
50 if (gc) signoff(gc);
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 576
diff changeset
51 else signoff_all(NULL, NULL);
106
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52 } else if (!strncasecmp(command, "send", 4)) {
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53 struct conversation *c;
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 arg1 = getarg(buffer, 1, 0);
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 arg2 = getarg(buffer, 2, 1);
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56 c = find_conversation(arg1);
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 if (!c) c = new_conversation(arg1);
576
bb22fb4a7d39 [gaim-migrate @ 586]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 179
diff changeset
58 write_to_conv(c, arg2, WFLAG_SEND, NULL);
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 576
diff changeset
59 serv_send_im(c->gc, arg1, arg2, 0);
106
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60 free(arg1);
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 free(arg2);
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62 } else if (!strncasecmp(command, "away", 4)) {
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63 struct away_message a;
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64 arg1 = getarg(buffer, 1, 1);
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65 snprintf(a.message, 2048, "%s", arg1);
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66 a.name[0] = 0;
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
67 do_away_message(NULL, &a);
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68 free(arg1);
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69 } else if (!strncasecmp(command, "back", 4)) {
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
70 do_im_back();
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71 } else if (!strncasecmp(command, "quit", 4)) {
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72 do_quit();
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73 }
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
74 free(command);
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
75 }
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
76
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
77 fclose(file);
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
78
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
79 if (stat (filename, &finfo) != 0)
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
80 return;
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
81 mtime = finfo.st_mtime;
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
82 }
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
83
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 576
diff changeset
84 char *gaim_plugin_init(GModule *h) {
106
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
85 handle = h;
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
86 init_file();
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
87 check = gtk_timeout_add(5000, (GtkFunction)check_file, NULL);
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
88 }
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
89
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
90 void gaim_plugin_remove() {
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
91 gtk_timeout_remove(check);
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
92 }
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
93
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
94 char *name() {
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
95 return "Gaim File Control";
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
96 }
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
97
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
98 char *description() {
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
99 return "Allows you to control gaim by entering commands in a file.";
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
100 }
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
101
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
102 /* check to see if the size of the file is > 0. if so, run commands */
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
103 void init_file() {
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
104 /* most of this was taken from Bash v2.04 by the FSF */
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
105 struct stat finfo;
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
106 char file[256];
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
107
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
108 sprintf(file, "%s/.gaim/control", getenv("HOME"));
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
109
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
110 if ((stat (file, &finfo) == 0) && (finfo.st_size > 0))
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
111 run_commands();
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
112 }
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
114 /* check to see if we need to run commands from the file */
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
115 void check_file() {
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
116 /* most of this was taken from Bash v2.04 by the FSF */
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
117 struct stat finfo;
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
118 char file[256];
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
119
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
120 sprintf(file, "%s/.gaim/control", getenv("HOME"));
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
121
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
122 if ((stat (file, &finfo) == 0) && (finfo.st_size > 0))
179
8d8faeab01f6 [gaim-migrate @ 189]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
123 if (mtime != finfo.st_mtime) {
8d8faeab01f6 [gaim-migrate @ 189]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
124 sprintf(debug_buff, "control changed, checking\n");
8d8faeab01f6 [gaim-migrate @ 189]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
125 debug_print(debug_buff);
106
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
126 run_commands();
179
8d8faeab01f6 [gaim-migrate @ 189]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
127 }
106
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
128 }
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
129
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
130 char *getarg(char *line, int which, int remain) {
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
131 char *arr;
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
132 char *val;
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
133 int count = -1;
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
134 int i;
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
135 int state = 0;
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
136
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
137 for (i = 0; i < strlen(line) && count < which; i++) {
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
138 switch (state) {
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
139 case 0: /* in whitespace, expecting word */
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
140 if (isalnum(line[i])) {
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
141 count++;
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
142 state = 1;
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
143 }
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
144 break;
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
145 case 1: /* inside word, waiting for whitespace */
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
146 if (isspace(line[i])) {
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
147 state = 0;
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
148 }
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
149 break;
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
150 }
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
151 }
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
152
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
153 arr = strdup(&line[i - 1]);
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
154 if (remain)
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
155 return arr;
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
156
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
157 for (i = 0; i < strlen(arr) && isalnum(arr[i]); i++);
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
158 arr[i] = 0;
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
159 val = strdup(arr);
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
160 arr[i] = ' ';
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
161 free(arr);
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
162 return val;
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
163 }