source: global.c @ d0961fe

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