source: global.c @ 8d0796c0

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