source: global.c @ 4211f50b

barnowl_perlaimdebianrelease-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 4211f50b was 4211f50b, checked in by Nelson Elhage <nelhage@mit.edu>, 14 years ago
Refactoring the editwin code to use an explicit callback.
  • Property mode set to 100644
File size: 18.5 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->buffercommand=NULL;
71  g->newmsgproc_pid=0;
72 
73  owl_global_set_config_format(g, 0);
74  owl_global_set_userclue(g, OWL_USERCLUE_NONE);
75  owl_global_set_no_have_config(g);
76  owl_history_init(&(g->msghist));
77  owl_history_init(&(g->cmdhist));
78  owl_history_set_norepeats(&(g->cmdhist));
79  g->nextmsgid=0;
80
81  owl_filterelement_create_true(&(g->fe_true));
82  owl_filterelement_create_false(&(g->fe_false));
83  owl_filterelement_create_null(&(g->fe_null));
84
85  _owl_global_setup_windows(g);
86
87  /* Fill in some variables which don't have constant defaults */
88  /* TODO: come back later and check passwd file first */
89  g->homedir=owl_strdup(getenv("HOME"));
90
91  owl_messagelist_create(&(g->msglist));
92  owl_mainwin_init(&(g->mw));
93  owl_popwin_init(&(g->pw));
94
95  g->aim_screenname=NULL;
96  g->aim_loggedin=0;
97  owl_timer_create_countdown(&(g->aim_noop_timer), 30);
98  owl_timer_create_countdown(&(g->aim_ignorelogin_timer), 0);
99  owl_timer_create_countdown(&(g->aim_buddyinfo_timer), 60);
100  owl_buddylist_init(&(g->buddylist));
101   
102  g->response=NULL;
103  g->havezephyr=0;
104  g->haveaim=0;
105  owl_global_set_no_doaimevents(g);
106
107  owl_errqueue_init(&(g->errqueue));
108  g->got_err_signal=0;
109
110  owl_zbuddylist_create(&(g->zbuddies));
111  owl_timer_create_countdown(&(g->zephyr_buddycheck_timer), 60*3);
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  if (g->buffercommand) owl_free(g->buffercommand);
244  g->buffercommand=owl_strdup(command);
245}
246
247char *owl_global_get_buffercommand(owl_global *g) {
248  if (g->buffercommand) return(g->buffercommand);
249  return("");
250}
251
252void owl_global_set_buffercallback(owl_global *g, void (*cb)(char*,char*)) {
253  g->buffercallback = cb;
254}
255
256void (*owl_global_get_buffercallback(owl_global *g))(char*,char*) {
257  return g->buffercallback;
258}
259
260/* refresh */
261
262int owl_global_is_needrefresh(owl_global *g) {
263  if (g->needrefresh==1) return(1);
264  return(0);
265}
266
267void owl_global_set_needrefresh(owl_global *g) {
268  g->needrefresh=1;
269}
270
271void owl_global_set_noneedrefresh(owl_global *g) {
272  g->needrefresh=0;
273}
274
275/* variable dictionary */
276
277owl_vardict *owl_global_get_vardict(owl_global *g) {
278  return &(g->vars);
279}
280
281/* command dictionary */
282
283owl_cmddict *owl_global_get_cmddict(owl_global *g) {
284  return &(g->cmds);
285}
286
287/* rightshift */
288
289void owl_global_set_rightshift(owl_global *g, int i) {
290  g->rightshift=i;
291}
292
293int owl_global_get_rightshift(owl_global *g) {
294  return(g->rightshift);
295}
296
297/* typwin */
298
299int owl_global_is_typwin_active(owl_global *g) {
300  if (g->typwinactive==1) return(1);
301  return(0);
302}
303
304void owl_global_set_typwin_active(owl_global *g) {
305  g->typwinactive=1;
306}
307
308void owl_global_set_typwin_inactive(owl_global *g) {
309  g->typwinactive=0;
310}
311
312/* resize */
313
314void owl_global_set_resize_pending(owl_global *g) {
315  g->resizepending=1;
316}
317
318char *owl_global_get_homedir(owl_global *g) {
319  if (g->homedir) return(g->homedir);
320  return("/");
321}
322
323int owl_global_get_direction(owl_global *g) {
324  return(g->direction);
325}
326
327void owl_global_set_direction_downwards(owl_global *g) {
328  g->direction=OWL_DIRECTION_DOWNWARDS;
329}
330
331void owl_global_set_direction_upwards(owl_global *g) {
332  g->direction=OWL_DIRECTION_UPWARDS;
333}
334
335/* perl stuff */
336
337void owl_global_set_perlinterp(owl_global *g, void *p) {
338  g->perl=p;
339}
340
341void *owl_global_get_perlinterp(owl_global *g) {
342  return(g->perl);
343}
344
345int owl_global_is_config_format(owl_global *g) {
346  if (g->config_format) return(1);
347  return(0);
348}
349
350void owl_global_set_config_format(owl_global *g, int state) {
351  if (state==1) {
352    g->config_format=1;
353  } else {
354    g->config_format=0;
355  }
356}
357
358void owl_global_set_have_config(owl_global *g) {
359  g->haveconfig=1;
360}
361
362void owl_global_set_no_have_config(owl_global *g) {
363  g->haveconfig=0;
364}
365
366int owl_global_have_config(owl_global *g) {
367  if (g->haveconfig) return(1);
368  return(0);
369}
370
371void owl_global_resize(owl_global *g, int x, int y) {
372  /* resize the screen.  If x or y is 0 use the terminal size */
373  struct winsize size;
374   
375  if (!g->resizepending) return;
376
377  /* delete the current windows */
378  delwin(g->recwin);
379  delwin(g->sepwin);
380  delwin(g->msgwin);
381  delwin(g->typwin);
382  if (!isendwin()) {
383    endwin();
384  }
385
386  refresh();
387
388  /* get the new size */
389  ioctl(STDIN_FILENO, TIOCGWINSZ, &size);
390  if (x==0) {
391    g->lines=size.ws_row;
392  } else {
393    g->lines=x;
394  }
395
396  if (y==0) {
397    g->cols=size.ws_col;
398  } else {
399    g->cols=y;
400  }
401
402  resizeterm(size.ws_row, size.ws_col);
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
447void owl_global_get_runtime_string(owl_global *g, char *buff) {
448  time_t diff;
449
450  diff=time(NULL)-owl_global_get_starttime(g);
451
452  /* print something nicer later */   
453  sprintf(buff, "%i seconds", (int) diff);
454}
455
456char *owl_global_get_hostname(owl_global *g) {
457  if (g->thishost) return(g->thishost);
458  return("");
459}
460
461/* userclue */
462
463void owl_global_set_userclue(owl_global *g, int clue) {
464  g->userclue=clue;
465}
466
467void owl_global_add_userclue(owl_global *g, int clue) {
468  g->userclue|=clue;
469}
470
471int owl_global_get_userclue(owl_global *g) {
472  return(g->userclue);
473}
474
475int owl_global_is_userclue(owl_global *g, int clue) {
476  if (g->userclue & clue) return(1);
477  return(0);
478}
479
480/* viewwin */
481
482owl_viewwin *owl_global_get_viewwin(owl_global *g) {
483  return(&(g->vw));
484}
485
486
487/* vert offset */
488
489int owl_global_get_curmsg_vert_offset(owl_global *g) {
490  return(g->curmsg_vert_offset);
491}
492
493void owl_global_set_curmsg_vert_offset(owl_global *g, int i) {
494  g->curmsg_vert_offset=i;
495}
496
497/* startup args */
498
499void owl_global_set_startupargs(owl_global *g, int argc, char **argv) {
500  int i, len;
501
502  if (g->startupargs) owl_free(g->startupargs);
503 
504  len=0;
505  for (i=0; i<argc; i++) {
506    len+=strlen(argv[i])+5;
507  }
508  g->startupargs=malloc(len+5);
509
510  strcpy(g->startupargs, "");
511  for (i=0; i<argc; i++) {
512    sprintf(g->startupargs, "%s%s ", g->startupargs, argv[i]);
513  }
514  g->startupargs[strlen(g->startupargs)-1]='\0';
515}
516
517char *owl_global_get_startupargs(owl_global *g) {
518  if (g->startupargs) return(g->startupargs);
519  return("");
520}
521
522/* history */
523
524owl_history *owl_global_get_msg_history(owl_global *g) {
525  return(&(g->msghist));
526}
527
528owl_history *owl_global_get_cmd_history(owl_global *g) {
529  return(&(g->cmdhist));
530}
531
532/* muxevents */
533
534owl_muxevents *owl_global_get_muxevents(owl_global *g) {
535  return(&(g->muxevents));
536}
537
538/* filterlist */
539
540owl_list *owl_global_get_filterlist(owl_global *g) {
541  return(&(g->filterlist));
542}
543
544owl_filter *owl_global_get_filter(owl_global *g, char *name) {
545  int i, j;
546  owl_filter *f;
547
548  j=owl_list_get_size(&(g->filterlist));
549  for (i=0; i<j; i++) {
550    f=owl_list_get_element(&(g->filterlist), i);
551    if (!strcmp(name, owl_filter_get_name(f))) {
552      return(f);
553    }
554  }
555  return(NULL);
556}
557
558void owl_global_add_filter(owl_global *g, owl_filter *f) {
559  owl_list_append_element(&(g->filterlist), f);
560}
561
562void owl_global_remove_filter(owl_global *g, char *name) {
563  int i, j;
564  owl_filter *f;
565
566  j=owl_list_get_size(&(g->filterlist));
567  for (i=0; i<j; i++) {
568    f=owl_list_get_element(&(g->filterlist), i);
569    if (!strcmp(name, owl_filter_get_name(f))) {
570      owl_filter_free(f);
571      owl_list_remove_element(&(g->filterlist), i);
572      break;
573    }
574  }
575}
576
577/* nextmsgid */
578
579int owl_global_get_nextmsgid(owl_global *g) {
580  return(g->nextmsgid++);
581}
582
583/* current view */
584
585owl_view *owl_global_get_current_view(owl_global *g) {
586  return(&(g->current_view));
587}
588
589owl_filterelement *owl_global_get_filterelement_true(owl_global *g) {
590  return(&(g->fe_true));
591}
592
593owl_filterelement *owl_global_get_filterelement_false(owl_global *g) {
594  return(&(g->fe_false));
595}
596
597owl_filterelement *owl_global_get_filterelement_null(owl_global *g) {
598  return(&(g->fe_null));
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
614/* puntlist */
615
616owl_list *owl_global_get_puntlist(owl_global *g) {
617  return(&(g->puntlist));
618}
619
620int owl_global_message_is_puntable(owl_global *g, owl_message *m) {
621  owl_list *pl;
622  int i, j;
623
624  pl=owl_global_get_puntlist(g);
625  j=owl_list_get_size(pl);
626  for (i=0; i<j; i++) {
627    if (owl_filter_message_match(owl_list_get_element(pl, i), m)) return(1);
628  }
629  return(0);
630}
631
632int owl_global_should_followlast(owl_global *g) {
633  owl_view *v;
634 
635  if (!owl_global_is__followlast(g)) return(0);
636 
637  v=owl_global_get_current_view(g);
638 
639  if (owl_global_get_curmsg(g)==owl_view_get_size(v)-1) return(1);
640  return(0);
641}
642
643int owl_global_is_search_active(owl_global *g) {
644  if (g->searchactive) return(1);
645  return(0);
646}
647
648void owl_global_set_search_active(owl_global *g, char *string) {
649  g->searchactive=1;
650  if (g->searchstring != NULL) owl_free(g->searchstring);
651  g->searchstring=owl_strdup(string);
652}
653
654void owl_global_set_search_inactive(owl_global *g) {
655  g->searchactive=0;
656}
657
658char *owl_global_get_search_string(owl_global *g) {
659  if (g->searchstring==NULL) return("");
660  return(g->searchstring);
661}
662
663void owl_global_set_newmsgproc_pid(owl_global *g, int i) {
664  g->newmsgproc_pid=i;
665}
666
667int owl_global_get_newmsgproc_pid(owl_global *g) {
668  return(g->newmsgproc_pid);
669}
670
671void owl_global_add_to_malloced(owl_global *g, int i) {
672  g->malloced+=i;
673}
674
675void owl_global_add_to_freed(owl_global *g, int i) {
676  g->freed+=1;
677}
678
679int owl_global_get_malloced(owl_global *g) {
680  return(g->malloced);
681}
682
683int owl_global_get_freed(owl_global *g) {
684  return(g->freed);
685}
686
687int owl_global_get_meminuse(owl_global *g) {
688  return(g->malloced-g->freed);
689}
690
691/* AIM stuff */
692
693int owl_global_is_aimloggedin(owl_global *g)
694{
695  if (g->aim_loggedin) return(1);
696  return(0);
697}
698
699char *owl_global_get_aim_screenname(owl_global *g)
700{
701  if (owl_global_is_aimloggedin(g)) {
702    return (g->aim_screenname);
703  }
704  return("");
705}
706
707void owl_global_set_aimloggedin(owl_global *g, char *screenname)
708{
709  g->aim_loggedin=1;
710  if (g->aim_screenname) owl_free(g->aim_screenname);
711  g->aim_screenname=owl_strdup(screenname);
712}
713
714void owl_global_set_aimnologgedin(owl_global *g)
715{
716  g->aim_loggedin=0;
717}
718
719int owl_global_is_doaimevents(owl_global *g)
720{
721  if (g->aim_doprocessing) return(1);
722  return(0);
723}
724
725void owl_global_set_doaimevents(owl_global *g)
726{
727  g->aim_doprocessing=1;
728}
729
730void owl_global_set_no_doaimevents(owl_global *g)
731{
732  g->aim_doprocessing=0;
733}
734
735aim_session_t *owl_global_get_aimsess(owl_global *g)
736{
737  return(&(g->aimsess));
738}
739
740aim_conn_t *owl_global_get_bosconn(owl_global *g)
741{
742  return(&(g->bosconn));
743}
744
745void owl_global_set_bossconn(owl_global *g, aim_conn_t *conn)
746{
747  g->bosconn=*conn;
748}
749
750int owl_global_is_aimnop_time(owl_global *g)
751{
752  if (owl_timer_is_expired(&(g->aim_noop_timer))) return(1);
753  return(0);
754}
755
756void owl_global_aimnop_sent(owl_global *g)
757{
758  owl_timer_reset(&(g->aim_noop_timer));
759}
760
761owl_timer *owl_global_get_aim_login_timer(owl_global *g)
762{
763  return(&(g->aim_ignorelogin_timer));
764}
765
766/* message queue */
767
768void owl_global_messagequeue_addmsg(owl_global *g, owl_message *m)
769{
770  owl_list_append_element(&(g->messagequeue), m);
771}
772
773/* pop off the first message and return it.  Return NULL if the queue
774 * is empty.  The caller should free the message after using it, if
775 * necessary.
776 */
777owl_message *owl_global_messageuque_popmsg(owl_global *g)
778{
779  owl_message *out;
780
781  if (owl_list_get_size(&(g->messagequeue))==0) return(NULL);
782  out=owl_list_get_element(&(g->messagequeue), 0);
783  owl_list_remove_element(&(g->messagequeue), 0);
784  return(out);
785}
786
787int owl_global_messagequeue_pending(owl_global *g)
788{
789  if (owl_list_get_size(&(g->messagequeue))==0) return(0);
790  return(1);
791}
792
793owl_buddylist *owl_global_get_buddylist(owl_global *g)
794{
795  return(&(g->buddylist));
796}
797 
798/* style */
799
800/* Return the style with name 'name'.  If it does not exist return
801 * NULL */
802owl_style *owl_global_get_style_by_name(owl_global *g, char *name)
803{
804  return owl_dict_find_element(&(g->styledict), name);
805}
806
807/* creates a list and fills it in with keys.  duplicates the keys,
808 * so they will need to be freed by the caller. */
809int owl_global_get_style_names(owl_global *g, owl_list *l) {
810  return owl_dict_get_keys(&(g->styledict), l);
811}
812
813void owl_global_add_style(owl_global *g, owl_style *s)
814{
815  owl_dict_insert_element(&(g->styledict), owl_style_get_name(s), 
816                          s, (void(*)(void*))owl_style_free);
817}
818
819char *owl_global_get_response(owl_global *g)
820{
821  if (g->response==NULL) return("");
822  return(g->response);
823}
824
825void owl_global_set_response(owl_global *g, char *resp)
826{
827  if (g->response) owl_free(g->response);
828  g->response=owl_strdup(resp);
829}
830
831
832void owl_global_set_haveaim(owl_global *g)
833{
834  g->haveaim=1;
835}
836
837int owl_global_is_haveaim(owl_global *g)
838{
839  if (g->haveaim) return(1);
840  return(0);
841}
842
843void owl_global_set_havezephyr(owl_global *g)
844{
845  g->havezephyr=1;
846}
847
848int owl_global_is_havezephyr(owl_global *g)
849{
850  if (g->havezephyr) return(1);
851  return(0);
852}
853
854owl_timer *owl_global_get_aim_buddyinfo_timer(owl_global *g)
855{
856  return(&(g->aim_buddyinfo_timer));
857}
858
859owl_errqueue *owl_global_get_errqueue(owl_global *g)
860{
861  return(&(g->errqueue));
862}
863
864void owl_global_set_errsignal(owl_global *g, int signum, siginfo_t *siginfo)
865{
866  g->got_err_signal = signum;
867  if (siginfo) {
868    g->err_signal_info = *siginfo;
869  } else {
870    memset(&(g->err_signal_info), 0, sizeof(siginfo_t));
871  }
872}
873
874int owl_global_get_errsignal_and_clear(owl_global *g, siginfo_t *siginfo)
875{
876  int signum;
877  if (siginfo && g->got_err_signal) {
878    *siginfo = g->err_signal_info;
879  } 
880  signum = g->got_err_signal;
881  g->got_err_signal = 0;
882  return signum;
883}
884
885owl_timer *owl_global_get_zephyr_buddycheck_timer(owl_global *g)
886{
887  return(&(g->zephyr_buddycheck_timer));
888}
889
890owl_zbuddylist *owl_global_get_zephyr_buddylist(owl_global *g)
891{
892  return(&(g->zbuddies));
893}
894
895struct termios *owl_global_get_startup_tio(owl_global *g)
896{
897  return(&(g->startup_tio));
898}
Note: See TracBrowser for help on using the repository browser.