source: global.c @ 95e60d6

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