source: global.c @ 7f792c1

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