1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
|
#include "e.h"
/* FIXME: handle LANG!!!! */
static void _e_help(void);
/* externally accessible functions */
int
main(int argc, char **argv)
{
int i;
Eet_File *ef;
char buf[4096];
char *lang = NULL;
int del_name = 0;
int del_generic = 0;
int del_comment = 0;
int del_exe = 0;
int del_win_name = 0;
int del_win_class = 0;
int del_startup_notify = 0;
int del_wait_exit = 0;
char *file = NULL;
char *set_name = NULL;
char *set_generic = NULL;
char *set_comment = NULL;
char *set_exe = NULL;
char *set_win_name = NULL;
char *set_win_class = NULL;
int set_startup_notify = -1;
int set_wait_exit = -1;
/* handle some command-line parameters */
for (i = 1; i < argc; i++)
{
if ((!strcmp(argv[i], "-lang")) && (i < (argc - 1)))
{
i++;
lang = argv[i];
}
else if ((!strcmp(argv[i], "-set-name")) && (i < (argc - 1)))
{
i++;
set_name = argv[i];
}
else if ((!strcmp(argv[i], "-set-generic")) && (i < (argc - 1)))
{
i++;
set_generic = argv[i];
}
else if ((!strcmp(argv[i], "-set-comment")) && (i < (argc - 1)))
{
i++;
set_comment = argv[i];
}
else if ((!strcmp(argv[i], "-set-exe")) && (i < (argc - 1)))
{
i++;
set_exe = argv[i];
}
else if ((!strcmp(argv[i], "-set-win-name")) && (i < (argc - 1)))
{
i++;
set_win_name = argv[i];
}
else if ((!strcmp(argv[i], "-set-win-class")) && (i < (argc - 1)))
{
i++;
set_win_class = argv[i];
}
else if ((!strcmp(argv[i], "-set-win-class")) && (i < (argc - 1)))
{
i++;
set_win_class = argv[i];
}
else if ((!strcmp(argv[i], "-set-startup-notify")) && (i < (argc - 1)))
{
i++;
set_startup_notify = atoi(argv[i]);
}
else if ((!strcmp(argv[i], "-set-wait-exit")) && (i < (argc - 1)))
{
i++;
set_wait_exit = atoi(argv[i]);
}
else if ((!strcmp(argv[i], "-del-all")))
{
del_name = 1;
del_generic = 1;
del_comment = 1;
del_exe = 1;
del_win_name = 1;
del_win_class = 1;
}
else if ((!strcmp(argv[i], "-del-name")))
{
del_name = 1;
}
else if ((!strcmp(argv[i], "-del-generic")))
{
del_generic = 1;
}
else if ((!strcmp(argv[i], "-del-comment")))
{
del_comment = 1;
}
else if ((!strcmp(argv[i], "-del-exe")))
{
del_exe = 1;
}
else if ((!strcmp(argv[i], "-del-win-name")))
{
del_win_name = 1;
}
else if ((!strcmp(argv[i], "-del-win-class")))
{
del_win_class = 1;
}
else if ((!strcmp(argv[i], "-del-startup-notify")))
{
del_startup_notify = 1;
}
else if ((!strcmp(argv[i], "-del-wait-exit")))
{
del_wait_exit = 1;
}
else if ((!strcmp(argv[i], "-h")) ||
(!strcmp(argv[i], "-help")) ||
(!strcmp(argv[i], "--h")) ||
(!strcmp(argv[i], "--help")))
{
_e_help();
exit(0);
}
else
file = argv[i];
}
if (!file)
{
printf("ERROR: no file specified!\n");
_e_help();
exit(0);
}
eet_init();
ef = eet_open(file, EET_FILE_MODE_RW);
if (!ef)
{
printf("ERROR: cannot open file %s for READ/WRITE\n", file);
return -1;
}
if (set_name)
{
if (lang) snprintf(buf, sizeof(buf), "app/info/name[%s]", lang);
else snprintf(buf, sizeof(buf), "app/info/name");
eet_write(ef, buf, set_name, strlen(set_name), 0);
}
if (set_generic)
{
if (lang) snprintf(buf, sizeof(buf), "app/info/generic[%s]", lang);
else snprintf(buf, sizeof(buf), "app/info/generic");
eet_write(ef, buf, set_generic, strlen(set_generic), 0);
}
if (set_comment)
{
if (lang) snprintf(buf, sizeof(buf), "app/info/comment[%s]", lang);
else snprintf(buf, sizeof(buf), "app/info/comment");
eet_write(ef, buf, set_comment, strlen(set_comment), 0);
}
if (set_exe)
eet_write(ef, "app/info/exe", set_exe, strlen(set_exe), 0);
if (set_win_name)
eet_write(ef, "app/window/name", set_win_name, strlen(set_win_name), 0);
if (set_win_class)
eet_write(ef, "app/window/class", set_win_class, strlen(set_win_class), 0);
if (set_startup_notify >= 0)
{
unsigned char tmp[1];
tmp[0] = set_startup_notify;
if (set_startup_notify)
eet_write(ef, "app/info/startup_notify", tmp, 1, 0);
else
eet_write(ef, "app/info/startup_notify", tmp, 1, 0);
}
if (set_wait_exit >= 0)
{
unsigned char tmp[1];
tmp[0] = set_wait_exit;
if (set_wait_exit)
eet_write(ef, "app/info/wait_exit", tmp, 1, 0);
else
eet_write(ef, "app/info/wait_exit", tmp, 1, 0);
}
if (del_name)
{
char **matches = NULL;
int match_num = 0;
matches = eet_list(ef, "app/info/name*", &match_num);
if (matches)
{
for (i = 0; i < match_num; i++) eet_delete(ef, matches[i]);
free(matches);
}
}
if (del_generic)
{
char **matches = NULL;
int match_num = 0;
matches = eet_list(ef, "app/info/generic*", &match_num);
if (matches)
{
for (i = 0; i < match_num; i++) eet_delete(ef, matches[i]);
free(matches);
}
}
if (del_comment)
{
char **matches = NULL;
int match_num = 0;
matches = eet_list(ef, "app/info/comment*", &match_num);
if (matches)
{
for (i = 0; i < match_num; i++) eet_delete(ef, matches[i]);
free(matches);
}
}
if (del_exe)
eet_delete(ef, "app/info/exe");
if (del_win_name)
eet_delete(ef, "app/window/name");
if (del_win_class)
eet_delete(ef, "app/window/class");
if (del_startup_notify)
eet_delete(ef, "app/info/startup_notify");
if (del_wait_exit)
eet_delete(ef, "app/info/wait_exit");
eet_close(ef);
eet_shutdown();
/* just return 0 to keep the compiler quiet */
return 0;
}
static void
_e_help(void)
{
printf("OPTIONS:\n"
" -lang LANG Set the language properties to modify\n"
" -set-name NAME Set the application name\n"
" -set-generic GENERIC Set the application generic name\n"
" -set-comment COMMENT Set the application comment\n"
" -set-exe EXE Set the application execute line\n"
" -set-win-name WIN_NAME Set the application window name\n"
" -set-win-class WIN_CLASS Set the application window class\n"
" -set-startup-notify [1/0] Set the application startup notify flag to on/off\n"
" -set-wait-exit [1/0] Set the application wait exit flag to on/off\n"
" -del-name Delete the application name\n"
" -del-generic Delete the application generic name\n"
" -del-comment Delete the application comment\n"
" -del-exe Delete the application execute line\n"
" -del-win-name Delete the application window name\n"
" -del-win-class Delete the application window class\n"
" -del-startup-notify Delete the application startup notify flag\n"
" -del-wait-exit Delete the application wait exit flag\n"
);
}
|