1 | #include <stdio.h> |
---|
2 | #include <unistd.h> |
---|
3 | #include <stdlib.h> |
---|
4 | #include <string.h> |
---|
5 | #include <netdb.h> |
---|
6 | #include <termios.h> |
---|
7 | #include <sys/ioctl.h> |
---|
8 | #include <time.h> |
---|
9 | #include "owl.h" |
---|
10 | |
---|
11 | static const char fileIdent[] = "$Id$"; |
---|
12 | |
---|
13 | #ifndef MAXHOSTNAMELEN |
---|
14 | #define MAXHOSTNAMELEN 256 |
---|
15 | #endif |
---|
16 | |
---|
17 | void owl_global_init(owl_global *g) { |
---|
18 | struct hostent *hent; |
---|
19 | char hostname[MAXHOSTNAMELEN]; |
---|
20 | |
---|
21 | g->malloced=0; |
---|
22 | g->freed=0; |
---|
23 | |
---|
24 | gethostname(hostname, MAXHOSTNAMELEN); |
---|
25 | hent=gethostbyname(hostname); |
---|
26 | if (!hent) { |
---|
27 | strcpy(g->thishost, "localhost"); |
---|
28 | } else { |
---|
29 | strcpy(g->thishost, hent->h_name); |
---|
30 | } |
---|
31 | |
---|
32 | owl_context_init(&g->ctx); |
---|
33 | owl_context_set_startup(&g->ctx); |
---|
34 | g->curmsg=0; |
---|
35 | g->topmsg=0; |
---|
36 | g->needrefresh=1; |
---|
37 | |
---|
38 | owl_variable_dict_setup(&(g->vars)); |
---|
39 | owl_cmddict_setup(&(g->cmds)); |
---|
40 | |
---|
41 | g->lines=LINES; |
---|
42 | g->cols=COLS; |
---|
43 | |
---|
44 | g->rightshift=0; |
---|
45 | |
---|
46 | owl_editwin_init(&(g->tw), NULL, owl_global_get_typwin_lines(g), g->cols, OWL_EDITWIN_STYLE_ONELINE, NULL); |
---|
47 | |
---|
48 | owl_keyhandler_init(&g->kh); |
---|
49 | owl_keys_setup_keymaps(&g->kh); |
---|
50 | |
---|
51 | owl_list_create(&(g->filterlist)); |
---|
52 | owl_list_create(&(g->puntlist)); |
---|
53 | g->curmsg_vert_offset=0; |
---|
54 | g->resizepending=0; |
---|
55 | g->typwinactive=0; |
---|
56 | g->direction=OWL_DIRECTION_DOWNWARDS; |
---|
57 | g->zaway=0; |
---|
58 | if (has_colors()) { |
---|
59 | g->hascolors=1; |
---|
60 | } |
---|
61 | g->colorpairs=COLOR_PAIRS; |
---|
62 | g->debug=OWL_DEBUG; |
---|
63 | g->searchactive=0; |
---|
64 | g->searchstring=NULL; |
---|
65 | g->starttime=time(NULL); /* assumes we call init only a start time */ |
---|
66 | strcpy(g->buffercommand, ""); |
---|
67 | g->newmsgproc_pid=0; |
---|
68 | |
---|
69 | owl_global_set_config_format(g, 0); |
---|
70 | owl_global_set_userclue(g, OWL_USERCLUE_NONE); |
---|
71 | owl_global_set_no_have_config(g); |
---|
72 | owl_history_init(&(g->msghist)); |
---|
73 | owl_history_init(&(g->cmdhist)); |
---|
74 | g->nextmsgid=0; |
---|
75 | |
---|
76 | owl_filterelement_create_true(&(g->fe_true)); |
---|
77 | owl_filterelement_create_false(&(g->fe_false)); |
---|
78 | owl_filterelement_create_null(&(g->fe_null)); |
---|
79 | |
---|
80 | _owl_global_setup_windows(g); |
---|
81 | |
---|
82 | /* Fill in some variables which don't have constant defaults */ |
---|
83 | /* TODO: come back later and check passwd file first */ |
---|
84 | strcpy(g->homedir, getenv("HOME")); |
---|
85 | |
---|
86 | owl_messagelist_create(&(g->msglist)); |
---|
87 | owl_mainwin_init(&(g->mw)); |
---|
88 | owl_popwin_init(&(g->pw)); |
---|
89 | } |
---|
90 | |
---|
91 | void _owl_global_setup_windows(owl_global *g) { |
---|
92 | int cols, typwin_lines; |
---|
93 | |
---|
94 | cols=g->cols; |
---|
95 | typwin_lines=owl_global_get_typwin_lines(g); |
---|
96 | |
---|
97 | /* set the new window sizes */ |
---|
98 | g->recwinlines=g->lines-(typwin_lines+2); |
---|
99 | if (g->recwinlines<1) { |
---|
100 | /* this will screw things up. I'm not sure what to do yet, |
---|
101 | but this is better than nothing */ |
---|
102 | /* g->recwinlines=1; */ |
---|
103 | } |
---|
104 | |
---|
105 | /* create the new windows */ |
---|
106 | g->recwin=newwin(g->recwinlines, cols, 0, 0); |
---|
107 | if (g->recwin==NULL) { |
---|
108 | owl_function_debugmsg("\n\nI just received an error on creating a new receive window\n"); |
---|
109 | owl_function_debugmsg("newwin was called with arguments (%i, %i, 0, 0) and returned NULL\n", |
---|
110 | g->recwinlines, cols); |
---|
111 | endwin(); |
---|
112 | |
---|
113 | exit(50); |
---|
114 | } |
---|
115 | |
---|
116 | g->sepwin=newwin(1, cols, g->recwinlines, 0); |
---|
117 | g->msgwin=newwin(1, cols, g->recwinlines+1, 0); |
---|
118 | g->typwin=newwin(typwin_lines, cols, g->recwinlines+2, 0); |
---|
119 | |
---|
120 | owl_editwin_set_curswin(&(g->tw), g->typwin, typwin_lines, g->cols); |
---|
121 | |
---|
122 | idlok(g->typwin, FALSE); |
---|
123 | idlok(g->recwin, FALSE); |
---|
124 | idlok(g->sepwin, FALSE); |
---|
125 | idlok(g->msgwin, FALSE); |
---|
126 | |
---|
127 | nodelay(g->typwin, 1); |
---|
128 | keypad(g->typwin, TRUE); |
---|
129 | wmove(g->typwin, 0, 0); |
---|
130 | |
---|
131 | meta(g->typwin, TRUE); |
---|
132 | } |
---|
133 | |
---|
134 | owl_context *owl_global_get_context(owl_global *g) { |
---|
135 | return(&g->ctx); |
---|
136 | } |
---|
137 | |
---|
138 | int owl_global_get_lines(owl_global *g) { |
---|
139 | return(g->lines); |
---|
140 | } |
---|
141 | |
---|
142 | int owl_global_get_cols(owl_global *g) { |
---|
143 | return(g->cols); |
---|
144 | } |
---|
145 | |
---|
146 | int owl_global_get_recwin_lines(owl_global *g) { |
---|
147 | return(g->recwinlines); |
---|
148 | } |
---|
149 | |
---|
150 | /* curmsg */ |
---|
151 | |
---|
152 | int owl_global_get_curmsg(owl_global *g) { |
---|
153 | return(g->curmsg); |
---|
154 | } |
---|
155 | |
---|
156 | void owl_global_set_curmsg(owl_global *g, int i) { |
---|
157 | g->curmsg=i; |
---|
158 | /* we will reset the vertical offset from here */ |
---|
159 | /* we might want to move this out to the functions later */ |
---|
160 | owl_global_set_curmsg_vert_offset(g, 0); |
---|
161 | } |
---|
162 | |
---|
163 | /* topmsg */ |
---|
164 | |
---|
165 | int owl_global_get_topmsg(owl_global *g) { |
---|
166 | return(g->topmsg); |
---|
167 | } |
---|
168 | |
---|
169 | void owl_global_set_topmsg(owl_global *g, int i) { |
---|
170 | g->topmsg=i; |
---|
171 | } |
---|
172 | |
---|
173 | /* windows */ |
---|
174 | |
---|
175 | owl_mainwin *owl_global_get_mainwin(owl_global *g) { |
---|
176 | return(&(g->mw)); |
---|
177 | } |
---|
178 | |
---|
179 | owl_popwin *owl_global_get_popwin(owl_global *g) { |
---|
180 | return(&(g->pw)); |
---|
181 | } |
---|
182 | |
---|
183 | /* msglist */ |
---|
184 | |
---|
185 | owl_messagelist *owl_global_get_msglist(owl_global *g) { |
---|
186 | return(&(g->msglist)); |
---|
187 | } |
---|
188 | |
---|
189 | /* keyhandler */ |
---|
190 | |
---|
191 | owl_keyhandler *owl_global_get_keyhandler(owl_global *g) { |
---|
192 | return(&(g->kh)); |
---|
193 | } |
---|
194 | |
---|
195 | /* curses windows */ |
---|
196 | |
---|
197 | WINDOW *owl_global_get_curs_recwin(owl_global *g) { |
---|
198 | return(g->recwin); |
---|
199 | } |
---|
200 | |
---|
201 | WINDOW *owl_global_get_curs_sepwin(owl_global *g) { |
---|
202 | return(g->sepwin); |
---|
203 | } |
---|
204 | |
---|
205 | WINDOW *owl_global_get_curs_msgwin(owl_global *g) { |
---|
206 | return(g->msgwin); |
---|
207 | } |
---|
208 | |
---|
209 | WINDOW *owl_global_get_curs_typwin(owl_global *g) { |
---|
210 | return(g->typwin); |
---|
211 | } |
---|
212 | |
---|
213 | /* typwin */ |
---|
214 | |
---|
215 | owl_editwin *owl_global_get_typwin(owl_global *g) { |
---|
216 | return(&(g->tw)); |
---|
217 | } |
---|
218 | |
---|
219 | /* buffercommand */ |
---|
220 | |
---|
221 | void owl_global_set_buffercommand(owl_global *g, char *command) { |
---|
222 | strcpy(g->buffercommand, command); |
---|
223 | } |
---|
224 | |
---|
225 | char *owl_global_get_buffercommand(owl_global *g) { |
---|
226 | return(g->buffercommand); |
---|
227 | } |
---|
228 | |
---|
229 | /* refresh */ |
---|
230 | |
---|
231 | int owl_global_is_needrefresh(owl_global *g) { |
---|
232 | if (g->needrefresh==1) return(1); |
---|
233 | return(0); |
---|
234 | } |
---|
235 | |
---|
236 | void owl_global_set_needrefresh(owl_global *g) { |
---|
237 | g->needrefresh=1; |
---|
238 | } |
---|
239 | |
---|
240 | void owl_global_set_noneedrefresh(owl_global *g) { |
---|
241 | g->needrefresh=0; |
---|
242 | } |
---|
243 | |
---|
244 | /* variable dictionary */ |
---|
245 | |
---|
246 | owl_vardict *owl_global_get_vardict(owl_global *g) { |
---|
247 | return &(g->vars); |
---|
248 | } |
---|
249 | |
---|
250 | /* command dictionary */ |
---|
251 | |
---|
252 | owl_cmddict *owl_global_get_cmddict(owl_global *g) { |
---|
253 | return &(g->cmds); |
---|
254 | } |
---|
255 | |
---|
256 | /* rightshift */ |
---|
257 | |
---|
258 | void owl_global_set_rightshift(owl_global *g, int i) { |
---|
259 | g->rightshift=i; |
---|
260 | } |
---|
261 | |
---|
262 | int owl_global_get_rightshift(owl_global *g) { |
---|
263 | return(g->rightshift); |
---|
264 | } |
---|
265 | |
---|
266 | /* typwin */ |
---|
267 | |
---|
268 | int owl_global_is_typwin_active(owl_global *g) { |
---|
269 | if (g->typwinactive==1) return(1); |
---|
270 | return(0); |
---|
271 | } |
---|
272 | |
---|
273 | void owl_global_set_typwin_active(owl_global *g) { |
---|
274 | g->typwinactive=1; |
---|
275 | } |
---|
276 | |
---|
277 | void owl_global_set_typwin_inactive(owl_global *g) { |
---|
278 | g->typwinactive=0; |
---|
279 | } |
---|
280 | |
---|
281 | /* resize */ |
---|
282 | |
---|
283 | void owl_global_set_resize_pending(owl_global *g) { |
---|
284 | g->resizepending=1; |
---|
285 | } |
---|
286 | |
---|
287 | char *owl_global_get_homedir(owl_global *g) { |
---|
288 | return(g->homedir); |
---|
289 | } |
---|
290 | |
---|
291 | int owl_global_get_direction(owl_global *g) { |
---|
292 | return(g->direction); |
---|
293 | } |
---|
294 | |
---|
295 | void owl_global_set_direction_downwards(owl_global *g) { |
---|
296 | g->direction=OWL_DIRECTION_DOWNWARDS; |
---|
297 | } |
---|
298 | |
---|
299 | void owl_global_set_direction_upwards(owl_global *g) { |
---|
300 | g->direction=OWL_DIRECTION_UPWARDS; |
---|
301 | } |
---|
302 | |
---|
303 | /* perl stuff */ |
---|
304 | |
---|
305 | void owl_global_set_perlinterp(owl_global *g, void *p) { |
---|
306 | g->perl=p; |
---|
307 | } |
---|
308 | |
---|
309 | void *owl_global_get_perlinterp(owl_global *g) { |
---|
310 | return(g->perl); |
---|
311 | } |
---|
312 | |
---|
313 | int owl_global_is_config_format(owl_global *g) { |
---|
314 | if (g->config_format) return(1); |
---|
315 | return(0); |
---|
316 | } |
---|
317 | |
---|
318 | void owl_global_set_config_format(owl_global *g, int state) { |
---|
319 | if (state==1) { |
---|
320 | g->config_format=1; |
---|
321 | } else { |
---|
322 | g->config_format=0; |
---|
323 | } |
---|
324 | } |
---|
325 | |
---|
326 | void owl_global_set_have_config(owl_global *g) { |
---|
327 | g->haveconfig=1; |
---|
328 | } |
---|
329 | |
---|
330 | void owl_global_set_no_have_config(owl_global *g) { |
---|
331 | g->haveconfig=0; |
---|
332 | } |
---|
333 | |
---|
334 | int owl_global_have_config(owl_global *g) { |
---|
335 | if (g->haveconfig) return(1); |
---|
336 | return(0); |
---|
337 | } |
---|
338 | |
---|
339 | void owl_global_resize(owl_global *g, int x, int y) { |
---|
340 | /* resize the screen. If x or y is 0 use the terminal size */ |
---|
341 | struct winsize size; |
---|
342 | |
---|
343 | if (!g->resizepending) return; |
---|
344 | |
---|
345 | /* delete the current windows */ |
---|
346 | delwin(g->recwin); |
---|
347 | delwin(g->sepwin); |
---|
348 | delwin(g->msgwin); |
---|
349 | delwin(g->typwin); |
---|
350 | if (!isendwin()) { |
---|
351 | endwin(); |
---|
352 | } |
---|
353 | |
---|
354 | refresh(); |
---|
355 | |
---|
356 | /* get the new size */ |
---|
357 | ioctl(STDIN_FILENO, TIOCGWINSZ, &size); |
---|
358 | if (x==0) { |
---|
359 | g->lines=size.ws_row; |
---|
360 | } else { |
---|
361 | g->lines=x; |
---|
362 | } |
---|
363 | |
---|
364 | if (y==0) { |
---|
365 | g->cols=size.ws_col; |
---|
366 | } else { |
---|
367 | g->cols=y; |
---|
368 | } |
---|
369 | |
---|
370 | /* resizeterm(size.ws_row, size.ws_col); */ |
---|
371 | |
---|
372 | /* re-initialize the windows */ |
---|
373 | _owl_global_setup_windows(g); |
---|
374 | |
---|
375 | /* refresh stuff */ |
---|
376 | g->needrefresh=1; |
---|
377 | owl_mainwin_redisplay(&(g->mw)); |
---|
378 | sepbar(NULL); |
---|
379 | |
---|
380 | if (owl_global_is_typwin_active(g)) { |
---|
381 | owl_editwin_redisplay(&(g->tw), 0); |
---|
382 | } |
---|
383 | /* TODO: this should handle other forms of popwins */ |
---|
384 | if (owl_popwin_is_active(owl_global_get_popwin(g)) |
---|
385 | && owl_global_get_viewwin(g)) { |
---|
386 | owl_popwin_refresh(owl_global_get_popwin(g)); |
---|
387 | owl_viewwin_redisplay(owl_global_get_viewwin(g), 0); |
---|
388 | } |
---|
389 | |
---|
390 | owl_function_debugmsg("New size is %i lines, %i cols.", size.ws_row, size.ws_col); |
---|
391 | owl_function_makemsg(""); |
---|
392 | g->resizepending=0; |
---|
393 | } |
---|
394 | |
---|
395 | /* debug */ |
---|
396 | |
---|
397 | int owl_global_is_debug_fast(owl_global *g) { |
---|
398 | if (g->debug) return(1); |
---|
399 | return(0); |
---|
400 | } |
---|
401 | |
---|
402 | /* starttime */ |
---|
403 | |
---|
404 | time_t owl_global_get_starttime(owl_global *g) { |
---|
405 | return(g->starttime); |
---|
406 | } |
---|
407 | |
---|
408 | time_t owl_global_get_runtime(owl_global *g) { |
---|
409 | return(time(NULL)-g->starttime); |
---|
410 | } |
---|
411 | |
---|
412 | void owl_global_get_runtime_string(owl_global *g, char *buff) { |
---|
413 | time_t diff; |
---|
414 | |
---|
415 | diff=time(NULL)-owl_global_get_starttime(g); |
---|
416 | |
---|
417 | /* print something nicer later */ |
---|
418 | sprintf(buff, "%i seconds", (int) diff); |
---|
419 | } |
---|
420 | |
---|
421 | char *owl_global_get_hostname(owl_global *g) { |
---|
422 | return(g->thishost); |
---|
423 | } |
---|
424 | |
---|
425 | /* userclue */ |
---|
426 | |
---|
427 | void owl_global_set_userclue(owl_global *g, int clue) { |
---|
428 | g->userclue=clue; |
---|
429 | } |
---|
430 | |
---|
431 | void owl_global_add_userclue(owl_global *g, int clue) { |
---|
432 | g->userclue|=clue; |
---|
433 | } |
---|
434 | |
---|
435 | int owl_global_get_userclue(owl_global *g) { |
---|
436 | return(g->userclue); |
---|
437 | } |
---|
438 | |
---|
439 | int owl_global_is_userclue(owl_global *g, int clue) { |
---|
440 | if (g->userclue & clue) return(1); |
---|
441 | return(0); |
---|
442 | } |
---|
443 | |
---|
444 | /* viewwin */ |
---|
445 | |
---|
446 | owl_viewwin *owl_global_get_viewwin(owl_global *g) { |
---|
447 | return(&(g->vw)); |
---|
448 | } |
---|
449 | |
---|
450 | |
---|
451 | /* vert offset */ |
---|
452 | |
---|
453 | int owl_global_get_curmsg_vert_offset(owl_global *g) { |
---|
454 | return(g->curmsg_vert_offset); |
---|
455 | } |
---|
456 | |
---|
457 | void owl_global_set_curmsg_vert_offset(owl_global *g, int i) { |
---|
458 | g->curmsg_vert_offset=i; |
---|
459 | } |
---|
460 | |
---|
461 | /* startup args */ |
---|
462 | |
---|
463 | void owl_global_set_startupargs(owl_global *g, int argc, char **argv) { |
---|
464 | int i; |
---|
465 | |
---|
466 | strcpy(g->startupargs, ""); |
---|
467 | for (i=0; i<argc; i++) { |
---|
468 | sprintf(g->startupargs, "%s%s ", g->startupargs, argv[i]); |
---|
469 | } |
---|
470 | g->startupargs[strlen(g->startupargs)-1]='\0'; |
---|
471 | } |
---|
472 | |
---|
473 | char *owl_global_get_startupargs(owl_global *g) { |
---|
474 | return(g->startupargs); |
---|
475 | } |
---|
476 | |
---|
477 | /* history */ |
---|
478 | |
---|
479 | owl_history *owl_global_get_msg_history(owl_global *g) { |
---|
480 | return(&(g->msghist)); |
---|
481 | } |
---|
482 | |
---|
483 | owl_history *owl_global_get_cmd_history(owl_global *g) { |
---|
484 | return(&(g->cmdhist)); |
---|
485 | } |
---|
486 | |
---|
487 | /* filterlist */ |
---|
488 | |
---|
489 | owl_list *owl_global_get_filterlist(owl_global *g) { |
---|
490 | return(&(g->filterlist)); |
---|
491 | } |
---|
492 | |
---|
493 | owl_filter *owl_global_get_filter(owl_global *g, char *name) { |
---|
494 | int i, j; |
---|
495 | owl_filter *f; |
---|
496 | |
---|
497 | j=owl_list_get_size(&(g->filterlist)); |
---|
498 | for (i=0; i<j; i++) { |
---|
499 | f=owl_list_get_element(&(g->filterlist), i); |
---|
500 | if (!strcmp(name, owl_filter_get_name(f))) { |
---|
501 | return(f); |
---|
502 | } |
---|
503 | } |
---|
504 | return(NULL); |
---|
505 | } |
---|
506 | |
---|
507 | void owl_global_add_filter(owl_global *g, owl_filter *f) { |
---|
508 | owl_list_append_element(&(g->filterlist), f); |
---|
509 | } |
---|
510 | |
---|
511 | void owl_global_remove_filter(owl_global *g, char *name) { |
---|
512 | int i, j; |
---|
513 | owl_filter *f; |
---|
514 | |
---|
515 | j=owl_list_get_size(&(g->filterlist)); |
---|
516 | for (i=0; i<j; i++) { |
---|
517 | f=owl_list_get_element(&(g->filterlist), i); |
---|
518 | if (!strcmp(name, owl_filter_get_name(f))) { |
---|
519 | owl_filter_free(f); |
---|
520 | owl_list_remove_element(&(g->filterlist), i); |
---|
521 | break; |
---|
522 | } |
---|
523 | } |
---|
524 | } |
---|
525 | |
---|
526 | /* nextmsgid */ |
---|
527 | |
---|
528 | int owl_global_get_nextmsgid(owl_global *g) { |
---|
529 | return(g->nextmsgid++); |
---|
530 | } |
---|
531 | |
---|
532 | /* current view */ |
---|
533 | |
---|
534 | owl_view *owl_global_get_current_view(owl_global *g) { |
---|
535 | return(&(g->current_view)); |
---|
536 | } |
---|
537 | |
---|
538 | owl_filterelement *owl_global_get_filterelement_true(owl_global *g) { |
---|
539 | return(&(g->fe_true)); |
---|
540 | } |
---|
541 | |
---|
542 | owl_filterelement *owl_global_get_filterelement_false(owl_global *g) { |
---|
543 | return(&(g->fe_false)); |
---|
544 | } |
---|
545 | |
---|
546 | owl_filterelement *owl_global_get_filterelement_null(owl_global *g) { |
---|
547 | return(&(g->fe_null)); |
---|
548 | } |
---|
549 | |
---|
550 | /* has colors */ |
---|
551 | |
---|
552 | int owl_global_get_hascolors(owl_global *g) { |
---|
553 | if (g->hascolors) return(1); |
---|
554 | return(0); |
---|
555 | } |
---|
556 | |
---|
557 | /* color pairs */ |
---|
558 | |
---|
559 | int owl_global_get_colorpairs(owl_global *g) { |
---|
560 | return(g->colorpairs); |
---|
561 | } |
---|
562 | |
---|
563 | /* puntlist */ |
---|
564 | |
---|
565 | owl_list *owl_global_get_puntlist(owl_global *g) { |
---|
566 | return(&(g->puntlist)); |
---|
567 | } |
---|
568 | |
---|
569 | int owl_global_message_is_puntable(owl_global *g, owl_message *m) { |
---|
570 | owl_list *pl; |
---|
571 | int i, j; |
---|
572 | |
---|
573 | pl=owl_global_get_puntlist(g); |
---|
574 | j=owl_list_get_size(pl); |
---|
575 | for (i=0; i<j; i++) { |
---|
576 | if (owl_filter_message_match(owl_list_get_element(pl, i), m)) return(1); |
---|
577 | } |
---|
578 | return(0); |
---|
579 | } |
---|
580 | |
---|
581 | int owl_global_should_followlast(owl_global *g) { |
---|
582 | owl_view *v; |
---|
583 | |
---|
584 | if (!owl_global_is__followlast(g)) return(0); |
---|
585 | |
---|
586 | v=owl_global_get_current_view(g); |
---|
587 | |
---|
588 | if (owl_global_get_curmsg(g)==owl_view_get_size(v)-1) return(1); |
---|
589 | return(0); |
---|
590 | } |
---|
591 | |
---|
592 | int owl_global_is_search_active(owl_global *g) { |
---|
593 | if (g->searchactive) return(1); |
---|
594 | return(0); |
---|
595 | } |
---|
596 | |
---|
597 | void owl_global_set_search_active(owl_global *g, char *string) { |
---|
598 | g->searchactive=1; |
---|
599 | if (g->searchstring != NULL) owl_free(g->searchstring); |
---|
600 | g->searchstring=owl_strdup(string); |
---|
601 | } |
---|
602 | |
---|
603 | void owl_global_set_search_inactive(owl_global *g) { |
---|
604 | g->searchactive=0; |
---|
605 | } |
---|
606 | |
---|
607 | char *owl_global_get_search_string(owl_global *g) { |
---|
608 | if (g->searchstring==NULL) return(""); |
---|
609 | return(g->searchstring); |
---|
610 | } |
---|
611 | |
---|
612 | void owl_global_set_newmsgproc_pid(owl_global *g, int i) { |
---|
613 | g->newmsgproc_pid=i; |
---|
614 | } |
---|
615 | |
---|
616 | int owl_global_get_newmsgproc_pid(owl_global *g) { |
---|
617 | return(g->newmsgproc_pid); |
---|
618 | } |
---|
619 | |
---|
620 | void owl_global_add_to_malloced(owl_global *g, int i) { |
---|
621 | g->malloced+=i; |
---|
622 | } |
---|
623 | |
---|
624 | void owl_global_add_to_freed(owl_global *g, int i) { |
---|
625 | g->freed+=1; |
---|
626 | } |
---|
627 | |
---|
628 | int owl_global_get_malloced(owl_global *g) { |
---|
629 | return(g->malloced); |
---|
630 | } |
---|
631 | |
---|
632 | int owl_global_get_freed(owl_global *g) { |
---|
633 | return(g->freed); |
---|
634 | } |
---|
635 | |
---|
636 | int owl_global_get_meminuse(owl_global *g) { |
---|
637 | return(g->malloced-g->freed); |
---|
638 | } |
---|