source: global.c @ 32fa306

barnowl_perlaimdebianrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 32fa306 was cb769bb, checked in by Nelson Elhage <nelhage@mit.edu>, 18 years ago
r15874@phanatique: nelhage | 2006-12-24 18:25:33 -0500 Don't quit if we can't contact the hostmaster. r15884@phanatique: nelhage | 2006-12-24 18:56:03 -0500 Respect the displayoutgoing variable r15885@phanatique: nelhage | 2006-12-24 20:10:44 -0500 You can now write filters based off arbitrary message attributes r15887@phanatique: nelhage | 2006-12-24 22:59:39 -0500 r15886@phanatique (orig r476): nelhage | 2006-12-24 22:59:10 -0500 r24493@heretique: nelhage | 2006-12-24 22:59:02 -0500 Moving zephyr initialization later, so that zephyr works again r15891@phanatique: nelhage | 2006-12-25 14:40:08 -0500 * perl messages hashes use `private', not `isprivate' * get rid of a perl warning if login fails r15900@phanatique: nelhage | 2006-12-25 21:04:15 -0500 Merging in filter regression tests from my local branch. r15926@phanatique: nelhage | 2006-12-26 00:57:07 -0500 r15901@phanatique: nelhage | 2006-12-25 21:08:47 -0500 Base framework for the filter rewrite system. Only understands regexes and true/false so far. r15927@phanatique: nelhage | 2006-12-26 00:57:08 -0500 r15902@phanatique: nelhage | 2006-12-25 23:03:33 -0500 support for negation and parentheses r15928@phanatique: nelhage | 2006-12-26 00:57:08 -0500 r15924@phanatique: nelhage | 2006-12-26 00:16:30 -0500 Now passing all tests except for recursion detection r15929@phanatique: nelhage | 2006-12-26 00:57:08 -0500 r15925@phanatique: nelhage | 2006-12-26 00:52:09 -0500 Checking for filter recursion loops
  • Property mode set to 100644
File size: 17.8 KB
Line 
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
11static const char fileIdent[] = "$Id$";
12
13#ifndef MAXHOSTNAMELEN
14#define MAXHOSTNAMELEN 256
15#endif
16
17void 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    g->thishost=owl_strdup("localhost");
28  } else {
29    g->thishost=owl_strdup(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  g->startupargs=NULL;
38
39  owl_variable_dict_setup(&(g->vars));
40  owl_cmddict_setup(&(g->cmds));
41
42  g->lines=LINES;
43  g->cols=COLS;
44
45  g->rightshift=0;
46
47  owl_editwin_init(&(g->tw), NULL, owl_global_get_typwin_lines(g), g->cols, OWL_EDITWIN_STYLE_ONELINE, NULL);
48
49  owl_keyhandler_init(&g->kh);
50  owl_keys_setup_keymaps(&g->kh);
51
52  owl_list_create(&(g->muxevents));
53  owl_list_create(&(g->filterlist));
54  owl_list_create(&(g->puntlist));
55  owl_list_create(&(g->messagequeue));
56  owl_dict_create(&(g->styledict));
57  g->curmsg_vert_offset=0;
58  g->resizepending=0;
59  g->typwinactive=0;
60  g->direction=OWL_DIRECTION_DOWNWARDS;
61  g->zaway=0;
62  if (has_colors()) {
63    g->hascolors=1;
64  }
65  g->colorpairs=COLOR_PAIRS;
66  g->debug=OWL_DEBUG;
67  g->searchactive=0;
68  g->searchstring=NULL;
69  g->starttime=time(NULL); /* assumes we call init only a start time */
70  g->newmsgproc_pid=0;
71 
72  owl_global_set_config_format(g, 0);
73  owl_global_set_userclue(g, OWL_USERCLUE_NONE);
74  owl_global_set_no_have_config(g);
75  owl_history_init(&(g->msghist));
76  owl_history_init(&(g->cmdhist));
77  owl_history_set_norepeats(&(g->cmdhist));
78  g->nextmsgid=0;
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  g->homedir=owl_strdup(getenv("HOME"));
85
86  owl_messagelist_create(&(g->msglist));
87  owl_mainwin_init(&(g->mw));
88  owl_popwin_init(&(g->pw));
89
90  g->aim_screenname=NULL;
91  g->aim_loggedin=0;
92  owl_timer_create_countdown(&(g->aim_noop_timer), 30);
93  owl_timer_create_countdown(&(g->aim_ignorelogin_timer), 0);
94  owl_timer_create_countdown(&(g->aim_buddyinfo_timer), 60);
95  owl_buddylist_init(&(g->buddylist));
96   
97  g->havezephyr=0;
98  g->haveaim=0;
99  owl_global_set_no_doaimevents(g);
100
101  owl_errqueue_init(&(g->errqueue));
102  g->got_err_signal=0;
103
104  owl_zbuddylist_create(&(g->zbuddies));
105  owl_timer_create_countdown(&(g->zephyr_buddycheck_timer), 60*3);
106}
107
108void _owl_global_setup_windows(owl_global *g) {
109  int cols, typwin_lines;
110
111  cols=g->cols;
112  typwin_lines=owl_global_get_typwin_lines(g);
113
114  /* set the new window sizes */
115  g->recwinlines=g->lines-(typwin_lines+2);
116  if (g->recwinlines<0) {
117    /* gotta deal with this */
118    g->recwinlines=0;
119  }
120
121  owl_function_debugmsg("_owl_global_setup_windows: about to call newwin(%i, %i, 0, 0)\n", g->recwinlines, cols);
122
123  /* create the new windows */
124  g->recwin=newwin(g->recwinlines, cols, 0, 0);
125  if (g->recwin==NULL) {
126    owl_function_debugmsg("_owl_global_setup_windows: newwin returned NULL\n", g->recwinlines, cols);
127    endwin();
128    exit(50);
129  }
130     
131  g->sepwin=newwin(1, cols, g->recwinlines, 0);
132  g->msgwin=newwin(1, cols, g->recwinlines+1, 0);
133  g->typwin=newwin(typwin_lines, cols, g->recwinlines+2, 0);
134
135  owl_editwin_set_curswin(&(g->tw), g->typwin, typwin_lines, g->cols);
136
137  idlok(g->typwin, FALSE);
138  idlok(g->recwin, FALSE);
139  idlok(g->sepwin, FALSE);
140  idlok(g->msgwin, FALSE);
141
142  nodelay(g->typwin, 1);
143  keypad(g->typwin, TRUE);
144  wmove(g->typwin, 0, 0);
145
146  meta(g->typwin, TRUE);
147}
148
149owl_context *owl_global_get_context(owl_global *g) {
150  return(&g->ctx);
151}
152                         
153int owl_global_get_lines(owl_global *g) {
154  return(g->lines);
155}
156
157int owl_global_get_cols(owl_global *g) {
158  return(g->cols);
159}
160
161int owl_global_get_recwin_lines(owl_global *g) {
162  return(g->recwinlines);
163}
164
165/* curmsg */
166
167int owl_global_get_curmsg(owl_global *g) {
168  return(g->curmsg);
169}
170
171void owl_global_set_curmsg(owl_global *g, int i) {
172  g->curmsg=i;
173  /* we will reset the vertical offset from here */
174  /* we might want to move this out to the functions later */
175  owl_global_set_curmsg_vert_offset(g, 0);
176}
177
178/* topmsg */
179
180int owl_global_get_topmsg(owl_global *g) {
181  return(g->topmsg);
182}
183
184void owl_global_set_topmsg(owl_global *g, int i) {
185  g->topmsg=i;
186}
187
188/* windows */
189
190owl_mainwin *owl_global_get_mainwin(owl_global *g) {
191  return(&(g->mw));
192}
193
194owl_popwin *owl_global_get_popwin(owl_global *g) {
195  return(&(g->pw));
196}
197
198/* msglist */
199
200owl_messagelist *owl_global_get_msglist(owl_global *g) {
201  return(&(g->msglist));
202}
203
204/* keyhandler */
205
206owl_keyhandler *owl_global_get_keyhandler(owl_global *g) {
207  return(&(g->kh));
208}
209
210/* curses windows */
211
212WINDOW *owl_global_get_curs_recwin(owl_global *g) {
213  return(g->recwin);
214}
215
216WINDOW *owl_global_get_curs_sepwin(owl_global *g) {
217  return(g->sepwin);
218}
219
220WINDOW *owl_global_get_curs_msgwin(owl_global *g) {
221  return(g->msgwin);
222}
223
224WINDOW *owl_global_get_curs_typwin(owl_global *g) {
225  return(g->typwin);
226}
227
228/* typwin */
229
230owl_editwin *owl_global_get_typwin(owl_global *g) {
231  return(&(g->tw));
232}
233
234/* buffercommand */
235
236void owl_global_set_buffercommand(owl_global *g, char *command) {
237  owl_editwin_set_command(owl_global_get_typwin(g), command);
238}
239
240char *owl_global_get_buffercommand(owl_global *g) {
241  return owl_editwin_get_command(owl_global_get_typwin(g));
242}
243
244void owl_global_set_buffercallback(owl_global *g, void (*cb)(owl_editwin*)) {
245  owl_editwin_set_callback(owl_global_get_typwin(g), cb);
246}
247
248void (*owl_global_get_buffercallback(owl_global *g))(owl_editwin*) {
249  return owl_editwin_get_callback(owl_global_get_typwin(g));
250}
251
252/* refresh */
253
254int owl_global_is_needrefresh(owl_global *g) {
255  if (g->needrefresh==1) return(1);
256  return(0);
257}
258
259void owl_global_set_needrefresh(owl_global *g) {
260  g->needrefresh=1;
261}
262
263void owl_global_set_noneedrefresh(owl_global *g) {
264  g->needrefresh=0;
265}
266
267/* variable dictionary */
268
269owl_vardict *owl_global_get_vardict(owl_global *g) {
270  return &(g->vars);
271}
272
273/* command dictionary */
274
275owl_cmddict *owl_global_get_cmddict(owl_global *g) {
276  return &(g->cmds);
277}
278
279/* rightshift */
280
281void owl_global_set_rightshift(owl_global *g, int i) {
282  g->rightshift=i;
283}
284
285int owl_global_get_rightshift(owl_global *g) {
286  return(g->rightshift);
287}
288
289/* typwin */
290
291int owl_global_is_typwin_active(owl_global *g) {
292  if (g->typwinactive==1) return(1);
293  return(0);
294}
295
296void owl_global_set_typwin_active(owl_global *g) {
297  g->typwinactive=1;
298}
299
300void owl_global_set_typwin_inactive(owl_global *g) {
301  g->typwinactive=0;
302}
303
304/* resize */
305
306void owl_global_set_resize_pending(owl_global *g) {
307  g->resizepending=1;
308}
309
310char *owl_global_get_homedir(owl_global *g) {
311  if (g->homedir) return(g->homedir);
312  return("/");
313}
314
315int owl_global_get_direction(owl_global *g) {
316  return(g->direction);
317}
318
319void owl_global_set_direction_downwards(owl_global *g) {
320  g->direction=OWL_DIRECTION_DOWNWARDS;
321}
322
323void owl_global_set_direction_upwards(owl_global *g) {
324  g->direction=OWL_DIRECTION_UPWARDS;
325}
326
327/* perl stuff */
328
329void owl_global_set_perlinterp(owl_global *g, void *p) {
330  g->perl=p;
331}
332
333void *owl_global_get_perlinterp(owl_global *g) {
334  return(g->perl);
335}
336
337int owl_global_is_config_format(owl_global *g) {
338  if (g->config_format) return(1);
339  return(0);
340}
341
342void owl_global_set_config_format(owl_global *g, int state) {
343  if (state==1) {
344    g->config_format=1;
345  } else {
346    g->config_format=0;
347  }
348}
349
350void owl_global_set_have_config(owl_global *g) {
351  g->haveconfig=1;
352}
353
354void owl_global_set_no_have_config(owl_global *g) {
355  g->haveconfig=0;
356}
357
358int owl_global_have_config(owl_global *g) {
359  if (g->haveconfig) return(1);
360  return(0);
361}
362
363void owl_global_resize(owl_global *g, int x, int y) {
364  /* resize the screen.  If x or y is 0 use the terminal size */
365  struct winsize size;
366   
367  if (!g->resizepending) return;
368
369  /* delete the current windows */
370  delwin(g->recwin);
371  delwin(g->sepwin);
372  delwin(g->msgwin);
373  delwin(g->typwin);
374  if (!isendwin()) {
375    endwin();
376  }
377
378  refresh();
379
380  /* get the new size */
381  ioctl(STDIN_FILENO, TIOCGWINSZ, &size);
382  if (x==0) {
383    g->lines=size.ws_row;
384  } else {
385    g->lines=x;
386  }
387
388  if (y==0) {
389    g->cols=size.ws_col;
390  } else {
391    g->cols=y;
392  }
393
394  resizeterm(size.ws_row, size.ws_col);
395
396  /* re-initialize the windows */
397  _owl_global_setup_windows(g);
398
399  /* in case any styles rely on the current width */
400  owl_messagelist_invalidate_formats(owl_global_get_msglist(g));
401
402  /* refresh stuff */
403  g->needrefresh=1;
404  owl_mainwin_redisplay(&(g->mw));
405  sepbar(NULL);
406
407  if (owl_global_is_typwin_active(g)) {
408    owl_editwin_redisplay(&(g->tw), 0);
409  }     
410  /* TODO: this should handle other forms of popwins */
411  if (owl_popwin_is_active(owl_global_get_popwin(g)) 
412      && owl_global_get_viewwin(g)) {
413    owl_popwin_refresh(owl_global_get_popwin(g));
414    owl_viewwin_redisplay(owl_global_get_viewwin(g), 0);
415  }
416
417  owl_function_debugmsg("New size is %i lines, %i cols.", size.ws_row, size.ws_col);
418  owl_function_makemsg("");
419  g->resizepending=0;
420}
421
422/* debug */
423
424int owl_global_is_debug_fast(owl_global *g) {
425  if (g->debug) return(1);
426  return(0);
427}
428
429/* starttime */
430
431time_t owl_global_get_starttime(owl_global *g) {
432  return(g->starttime);
433}
434
435time_t owl_global_get_runtime(owl_global *g) {
436  return(time(NULL)-g->starttime);
437}
438
439void owl_global_get_runtime_string(owl_global *g, char *buff) {
440  time_t diff;
441
442  diff=time(NULL)-owl_global_get_starttime(g);
443
444  /* print something nicer later */   
445  sprintf(buff, "%i seconds", (int) diff);
446}
447
448char *owl_global_get_hostname(owl_global *g) {
449  if (g->thishost) return(g->thishost);
450  return("");
451}
452
453/* userclue */
454
455void owl_global_set_userclue(owl_global *g, int clue) {
456  g->userclue=clue;
457}
458
459void owl_global_add_userclue(owl_global *g, int clue) {
460  g->userclue|=clue;
461}
462
463int owl_global_get_userclue(owl_global *g) {
464  return(g->userclue);
465}
466
467int owl_global_is_userclue(owl_global *g, int clue) {
468  if (g->userclue & clue) return(1);
469  return(0);
470}
471
472/* viewwin */
473
474owl_viewwin *owl_global_get_viewwin(owl_global *g) {
475  return(&(g->vw));
476}
477
478
479/* vert offset */
480
481int owl_global_get_curmsg_vert_offset(owl_global *g) {
482  return(g->curmsg_vert_offset);
483}
484
485void owl_global_set_curmsg_vert_offset(owl_global *g, int i) {
486  g->curmsg_vert_offset=i;
487}
488
489/* startup args */
490
491void owl_global_set_startupargs(owl_global *g, int argc, char **argv) {
492  int i, len;
493
494  if (g->startupargs) owl_free(g->startupargs);
495 
496  len=0;
497  for (i=0; i<argc; i++) {
498    len+=strlen(argv[i])+5;
499  }
500  g->startupargs=malloc(len+5);
501
502  strcpy(g->startupargs, "");
503  for (i=0; i<argc; i++) {
504    sprintf(g->startupargs, "%s%s ", g->startupargs, argv[i]);
505  }
506  g->startupargs[strlen(g->startupargs)-1]='\0';
507}
508
509char *owl_global_get_startupargs(owl_global *g) {
510  if (g->startupargs) return(g->startupargs);
511  return("");
512}
513
514/* history */
515
516owl_history *owl_global_get_msg_history(owl_global *g) {
517  return(&(g->msghist));
518}
519
520owl_history *owl_global_get_cmd_history(owl_global *g) {
521  return(&(g->cmdhist));
522}
523
524/* muxevents */
525
526owl_muxevents *owl_global_get_muxevents(owl_global *g) {
527  return(&(g->muxevents));
528}
529
530/* filterlist */
531
532owl_list *owl_global_get_filterlist(owl_global *g) {
533  return(&(g->filterlist));
534}
535
536owl_filter *owl_global_get_filter(owl_global *g, char *name) {
537  int i, j;
538  owl_filter *f;
539
540  j=owl_list_get_size(&(g->filterlist));
541  for (i=0; i<j; i++) {
542    f=owl_list_get_element(&(g->filterlist), i);
543    if (!strcmp(name, owl_filter_get_name(f))) {
544      return(f);
545    }
546  }
547  return(NULL);
548}
549
550void owl_global_add_filter(owl_global *g, owl_filter *f) {
551  owl_list_append_element(&(g->filterlist), f);
552}
553
554void owl_global_remove_filter(owl_global *g, char *name) {
555  int i, j;
556  owl_filter *f;
557
558  j=owl_list_get_size(&(g->filterlist));
559  for (i=0; i<j; i++) {
560    f=owl_list_get_element(&(g->filterlist), i);
561    if (!strcmp(name, owl_filter_get_name(f))) {
562      owl_filter_free(f);
563      owl_list_remove_element(&(g->filterlist), i);
564      break;
565    }
566  }
567}
568
569/* nextmsgid */
570
571int owl_global_get_nextmsgid(owl_global *g) {
572  return(g->nextmsgid++);
573}
574
575/* current view */
576
577owl_view *owl_global_get_current_view(owl_global *g) {
578  return(&(g->current_view));
579}
580
581/* has colors */
582
583int owl_global_get_hascolors(owl_global *g) {
584  if (g->hascolors) return(1);
585  return(0);
586}
587
588/* color pairs */
589
590int owl_global_get_colorpairs(owl_global *g) {
591  return(g->colorpairs);
592}
593
594/* puntlist */
595
596owl_list *owl_global_get_puntlist(owl_global *g) {
597  return(&(g->puntlist));
598}
599
600int owl_global_message_is_puntable(owl_global *g, owl_message *m) {
601  owl_list *pl;
602  int i, j;
603
604  pl=owl_global_get_puntlist(g);
605  j=owl_list_get_size(pl);
606  for (i=0; i<j; i++) {
607    if (owl_filter_message_match(owl_list_get_element(pl, i), m)) return(1);
608  }
609  return(0);
610}
611
612int owl_global_should_followlast(owl_global *g) {
613  owl_view *v;
614 
615  if (!owl_global_is__followlast(g)) return(0);
616 
617  v=owl_global_get_current_view(g);
618 
619  if (owl_global_get_curmsg(g)==owl_view_get_size(v)-1) return(1);
620  return(0);
621}
622
623int owl_global_is_search_active(owl_global *g) {
624  if (g->searchactive) return(1);
625  return(0);
626}
627
628void owl_global_set_search_active(owl_global *g, char *string) {
629  g->searchactive=1;
630  if (g->searchstring != NULL) owl_free(g->searchstring);
631  g->searchstring=owl_strdup(string);
632}
633
634void owl_global_set_search_inactive(owl_global *g) {
635  g->searchactive=0;
636}
637
638char *owl_global_get_search_string(owl_global *g) {
639  if (g->searchstring==NULL) return("");
640  return(g->searchstring);
641}
642
643void owl_global_set_newmsgproc_pid(owl_global *g, int i) {
644  g->newmsgproc_pid=i;
645}
646
647int owl_global_get_newmsgproc_pid(owl_global *g) {
648  return(g->newmsgproc_pid);
649}
650
651void owl_global_add_to_malloced(owl_global *g, int i) {
652  g->malloced+=i;
653}
654
655void owl_global_add_to_freed(owl_global *g, int i) {
656  g->freed+=1;
657}
658
659int owl_global_get_malloced(owl_global *g) {
660  return(g->malloced);
661}
662
663int owl_global_get_freed(owl_global *g) {
664  return(g->freed);
665}
666
667int owl_global_get_meminuse(owl_global *g) {
668  return(g->malloced-g->freed);
669}
670
671/* AIM stuff */
672
673int owl_global_is_aimloggedin(owl_global *g)
674{
675  if (g->aim_loggedin) return(1);
676  return(0);
677}
678
679char *owl_global_get_aim_screenname(owl_global *g)
680{
681  if (owl_global_is_aimloggedin(g)) {
682    return (g->aim_screenname);
683  }
684  return("");
685}
686
687void owl_global_set_aimloggedin(owl_global *g, char *screenname)
688{
689  g->aim_loggedin=1;
690  if (g->aim_screenname) owl_free(g->aim_screenname);
691  g->aim_screenname=owl_strdup(screenname);
692}
693
694void owl_global_set_aimnologgedin(owl_global *g)
695{
696  g->aim_loggedin=0;
697}
698
699int owl_global_is_doaimevents(owl_global *g)
700{
701  if (g->aim_doprocessing) return(1);
702  return(0);
703}
704
705void owl_global_set_doaimevents(owl_global *g)
706{
707  g->aim_doprocessing=1;
708}
709
710void owl_global_set_no_doaimevents(owl_global *g)
711{
712  g->aim_doprocessing=0;
713}
714
715aim_session_t *owl_global_get_aimsess(owl_global *g)
716{
717  return(&(g->aimsess));
718}
719
720aim_conn_t *owl_global_get_bosconn(owl_global *g)
721{
722  return(&(g->bosconn));
723}
724
725void owl_global_set_bossconn(owl_global *g, aim_conn_t *conn)
726{
727  g->bosconn=*conn;
728}
729
730int owl_global_is_aimnop_time(owl_global *g)
731{
732  if (owl_timer_is_expired(&(g->aim_noop_timer))) return(1);
733  return(0);
734}
735
736void owl_global_aimnop_sent(owl_global *g)
737{
738  owl_timer_reset(&(g->aim_noop_timer));
739}
740
741owl_timer *owl_global_get_aim_login_timer(owl_global *g)
742{
743  return(&(g->aim_ignorelogin_timer));
744}
745
746/* message queue */
747
748void owl_global_messagequeue_addmsg(owl_global *g, owl_message *m)
749{
750  owl_list_append_element(&(g->messagequeue), m);
751}
752
753/* pop off the first message and return it.  Return NULL if the queue
754 * is empty.  The caller should free the message after using it, if
755 * necessary.
756 */
757owl_message *owl_global_messageuque_popmsg(owl_global *g)
758{
759  owl_message *out;
760
761  if (owl_list_get_size(&(g->messagequeue))==0) return(NULL);
762  out=owl_list_get_element(&(g->messagequeue), 0);
763  owl_list_remove_element(&(g->messagequeue), 0);
764  return(out);
765}
766
767int owl_global_messagequeue_pending(owl_global *g)
768{
769  if (owl_list_get_size(&(g->messagequeue))==0) return(0);
770  return(1);
771}
772
773owl_buddylist *owl_global_get_buddylist(owl_global *g)
774{
775  return(&(g->buddylist));
776}
777 
778/* style */
779
780/* Return the style with name 'name'.  If it does not exist return
781 * NULL */
782owl_style *owl_global_get_style_by_name(owl_global *g, char *name)
783{
784  return owl_dict_find_element(&(g->styledict), name);
785}
786
787/* creates a list and fills it in with keys.  duplicates the keys,
788 * so they will need to be freed by the caller. */
789int owl_global_get_style_names(owl_global *g, owl_list *l) {
790  return owl_dict_get_keys(&(g->styledict), l);
791}
792
793void owl_global_add_style(owl_global *g, owl_style *s)
794{
795  owl_dict_insert_element(&(g->styledict), owl_style_get_name(s), 
796                          s, (void(*)(void*))owl_style_free);
797}
798
799void owl_global_set_haveaim(owl_global *g)
800{
801  g->haveaim=1;
802}
803
804int owl_global_is_haveaim(owl_global *g)
805{
806  if (g->haveaim) return(1);
807  return(0);
808}
809
810void owl_global_set_havezephyr(owl_global *g)
811{
812  g->havezephyr=1;
813}
814
815int owl_global_is_havezephyr(owl_global *g)
816{
817  if (g->havezephyr) return(1);
818  return(0);
819}
820
821owl_timer *owl_global_get_aim_buddyinfo_timer(owl_global *g)
822{
823  return(&(g->aim_buddyinfo_timer));
824}
825
826owl_errqueue *owl_global_get_errqueue(owl_global *g)
827{
828  return(&(g->errqueue));
829}
830
831void owl_global_set_errsignal(owl_global *g, int signum, siginfo_t *siginfo)
832{
833  g->got_err_signal = signum;
834  if (siginfo) {
835    g->err_signal_info = *siginfo;
836  } else {
837    memset(&(g->err_signal_info), 0, sizeof(siginfo_t));
838  }
839}
840
841int owl_global_get_errsignal_and_clear(owl_global *g, siginfo_t *siginfo)
842{
843  int signum;
844  if (siginfo && g->got_err_signal) {
845    *siginfo = g->err_signal_info;
846  } 
847  signum = g->got_err_signal;
848  g->got_err_signal = 0;
849  return signum;
850}
851
852owl_timer *owl_global_get_zephyr_buddycheck_timer(owl_global *g)
853{
854  return(&(g->zephyr_buddycheck_timer));
855}
856
857owl_zbuddylist *owl_global_get_zephyr_buddylist(owl_global *g)
858{
859  return(&(g->zbuddies));
860}
861
862struct termios *owl_global_get_startup_tio(owl_global *g)
863{
864  return(&(g->startup_tio));
865}
Note: See TracBrowser for help on using the repository browser.