source: global.c @ d1948ce

owl
Last change on this file since d1948ce was d1948ce, checked in by James M. Kretchmar <kretch@mit.edu>, 15 years ago
2.1.12 included a patch that breaks opaque resizing for some versions of ncurses on solaris. Reverting that part of the change to fix.
  • Property mode set to 100644
File size: 19.4 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  /* get the new size */
404  ioctl(STDIN_FILENO, TIOCGWINSZ, &size);
405  if (x==0) {
406    g->lines=size.ws_row;
407  } else {
408    g->lines=x;
409  }
410
411  if (y==0) {
412    g->cols=size.ws_col;
413  } else {
414    g->cols=y;
415  }
416
417#ifdef HAVE_RESIZETERM
418  resizeterm(size.ws_row, size.ws_col);
419#endif
420  refresh();
421
422  /* re-initialize the windows */
423  _owl_global_setup_windows(g);
424
425  /* in case any styles rely on the current width */
426  owl_messagelist_invalidate_formats(owl_global_get_msglist(g));
427
428  /* recalculate the topmsg to make sure the current message is on
429   * screen */
430  owl_function_calculate_topmsg(OWL_DIRECTION_NONE);
431
432  /* refresh stuff */
433  g->needrefresh=1;
434  owl_mainwin_redisplay(&(g->mw));
435  sepbar(NULL);
436  owl_editwin_redisplay(&(g->tw), 0);
437  owl_function_full_redisplay(&g);
438
439  /* TODO: this should handle other forms of popwins */
440  if (owl_popwin_is_active(owl_global_get_popwin(g)) 
441      && owl_global_get_viewwin(g)) {
442    owl_popwin_refresh(owl_global_get_popwin(g));
443    owl_viewwin_redisplay(owl_global_get_viewwin(g), 0);
444  }
445
446  owl_function_debugmsg("New size is %i lines, %i cols.", size.ws_row, size.ws_col);
447  owl_function_makemsg("");
448  g->resizepending=0;
449}
450
451/* debug */
452
453int owl_global_is_debug_fast(owl_global *g) {
454  if (g->debug) return(1);
455  return(0);
456}
457
458/* starttime */
459
460time_t owl_global_get_starttime(owl_global *g) {
461  return(g->starttime);
462}
463
464time_t owl_global_get_runtime(owl_global *g) {
465  return(time(NULL)-g->starttime);
466}
467
468char *owl_global_get_runtime_string(owl_global *g) {
469  time_t diff;
470
471  diff=time(NULL)-owl_global_get_starttime(g);
472
473  /* print something nicer later */   
474  return(owl_sprintf("%i seconds", (int) diff));
475}
476
477char *owl_global_get_hostname(owl_global *g) {
478  if (g->thishost) return(g->thishost);
479  return("");
480}
481
482/* userclue */
483
484void owl_global_set_userclue(owl_global *g, int clue) {
485  g->userclue=clue;
486}
487
488void owl_global_add_userclue(owl_global *g, int clue) {
489  g->userclue|=clue;
490}
491
492int owl_global_get_userclue(owl_global *g) {
493  return(g->userclue);
494}
495
496int owl_global_is_userclue(owl_global *g, int clue) {
497  if (g->userclue & clue) return(1);
498  return(0);
499}
500
501/* viewwin */
502
503owl_viewwin *owl_global_get_viewwin(owl_global *g) {
504  return(&(g->vw));
505}
506
507
508/* vert offset */
509
510int owl_global_get_curmsg_vert_offset(owl_global *g) {
511  return(g->curmsg_vert_offset);
512}
513
514void owl_global_set_curmsg_vert_offset(owl_global *g, int i) {
515  g->curmsg_vert_offset=i;
516}
517
518/* startup args */
519
520void owl_global_set_startupargs(owl_global *g, int argc, char **argv) {
521  int i, len;
522
523  if (g->startupargs) owl_free(g->startupargs);
524 
525  len=0;
526  for (i=0; i<argc; i++) {
527    len+=strlen(argv[i])+5;
528  }
529  g->startupargs=owl_malloc(len+5);
530
531  strcpy(g->startupargs, "");
532  for (i=0; i<argc; i++) {
533    sprintf(g->startupargs + strlen(g->startupargs), "%s ", argv[i]);
534  }
535  g->startupargs[strlen(g->startupargs)-1]='\0';
536}
537
538char *owl_global_get_startupargs(owl_global *g) {
539  if (g->startupargs) return(g->startupargs);
540  return("");
541}
542
543/* history */
544
545owl_history *owl_global_get_msg_history(owl_global *g) {
546  return(&(g->msghist));
547}
548
549owl_history *owl_global_get_cmd_history(owl_global *g) {
550  return(&(g->cmdhist));
551}
552
553/* filterlist */
554
555owl_list *owl_global_get_filterlist(owl_global *g) {
556  return(&(g->filterlist));
557}
558
559owl_filter *owl_global_get_filter(owl_global *g, char *name) {
560  int i, j;
561  owl_filter *f;
562
563  j=owl_list_get_size(&(g->filterlist));
564  for (i=0; i<j; i++) {
565    f=owl_list_get_element(&(g->filterlist), i);
566    if (!strcmp(name, owl_filter_get_name(f))) {
567      return(f);
568    }
569  }
570  return(NULL);
571}
572
573void owl_global_add_filter(owl_global *g, owl_filter *f) {
574  owl_list_append_element(&(g->filterlist), f);
575}
576
577void owl_global_remove_filter(owl_global *g, char *name) {
578  int i, j;
579  owl_filter *f;
580
581  j=owl_list_get_size(&(g->filterlist));
582  for (i=0; i<j; i++) {
583    f=owl_list_get_element(&(g->filterlist), i);
584    if (!strcmp(name, owl_filter_get_name(f))) {
585      owl_filter_free(f);
586      owl_list_remove_element(&(g->filterlist), i);
587      break;
588    }
589  }
590}
591
592/* nextmsgid */
593
594int owl_global_get_nextmsgid(owl_global *g) {
595  return(g->nextmsgid++);
596}
597
598/* current view */
599
600owl_view *owl_global_get_current_view(owl_global *g) {
601  return(&(g->current_view));
602}
603
604owl_filterelement *owl_global_get_filterelement_true(owl_global *g) {
605  return(&(g->fe_true));
606}
607
608owl_filterelement *owl_global_get_filterelement_false(owl_global *g) {
609  return(&(g->fe_false));
610}
611
612owl_filterelement *owl_global_get_filterelement_null(owl_global *g) {
613  return(&(g->fe_null));
614}
615
616/* has colors */
617
618int owl_global_get_hascolors(owl_global *g) {
619  if (g->hascolors) return(1);
620  return(0);
621}
622
623/* color pairs */
624
625int owl_global_get_colorpairs(owl_global *g) {
626  return(g->colorpairs);
627}
628
629/* puntlist */
630
631owl_list *owl_global_get_puntlist(owl_global *g) {
632  return(&(g->puntlist));
633}
634
635int owl_global_message_is_puntable(owl_global *g, owl_message *m) {
636  owl_list *pl;
637  int i, j;
638
639  pl=owl_global_get_puntlist(g);
640  j=owl_list_get_size(pl);
641  for (i=0; i<j; i++) {
642    if (owl_filter_message_match(owl_list_get_element(pl, i), m)) return(1);
643  }
644  return(0);
645}
646
647int owl_global_should_followlast(owl_global *g) {
648  owl_view *v;
649 
650  if (!owl_global_is__followlast(g)) return(0);
651 
652  v=owl_global_get_current_view(g);
653 
654  if (owl_global_get_curmsg(g)==owl_view_get_size(v)-1) return(1);
655  return(0);
656}
657
658int owl_global_is_search_active(owl_global *g) {
659  if (g->searchactive) return(1);
660  return(0);
661}
662
663void owl_global_set_search_active(owl_global *g, char *string) {
664  g->searchactive=1;
665  if (g->searchstring != NULL) owl_free(g->searchstring);
666  g->searchstring=owl_strdup(string);
667}
668
669void owl_global_set_search_inactive(owl_global *g) {
670  g->searchactive=0;
671}
672
673char *owl_global_get_search_string(owl_global *g) {
674  if (g->searchstring==NULL) return("");
675  return(g->searchstring);
676}
677
678void owl_global_set_newmsgproc_pid(owl_global *g, int i) {
679  g->newmsgproc_pid=i;
680}
681
682int owl_global_get_newmsgproc_pid(owl_global *g) {
683  return(g->newmsgproc_pid);
684}
685
686void owl_global_add_to_malloced(owl_global *g, int i) {
687  g->malloced+=i;
688}
689
690void owl_global_add_to_freed(owl_global *g, int i) {
691  g->freed+=1;
692}
693
694int owl_global_get_malloced(owl_global *g) {
695  return(g->malloced);
696}
697
698int owl_global_get_freed(owl_global *g) {
699  return(g->freed);
700}
701
702int owl_global_get_meminuse(owl_global *g) {
703  return(g->malloced-g->freed);
704}
705
706/* AIM stuff */
707
708int owl_global_is_aimloggedin(owl_global *g)
709{
710  if (g->aim_loggedin) return(1);
711  return(0);
712}
713
714char *owl_global_get_aim_screenname(owl_global *g)
715{
716  if (owl_global_is_aimloggedin(g)) {
717    return (g->aim_screenname);
718  }
719  return("");
720}
721
722void owl_global_set_aimloggedin(owl_global *g, char *screenname)
723{
724  g->aim_loggedin=1;
725  if (g->aim_screenname) owl_free(g->aim_screenname);
726  g->aim_screenname=owl_strdup(screenname);
727}
728
729void owl_global_set_aimnologgedin(owl_global *g)
730{
731  g->aim_loggedin=0;
732}
733
734int owl_global_is_doaimevents(owl_global *g)
735{
736  if (g->aim_doprocessing) return(1);
737  return(0);
738}
739
740void owl_global_set_doaimevents(owl_global *g)
741{
742  g->aim_doprocessing=1;
743}
744
745void owl_global_set_no_doaimevents(owl_global *g)
746{
747  g->aim_doprocessing=0;
748}
749
750aim_session_t *owl_global_get_aimsess(owl_global *g)
751{
752  return(&(g->aimsess));
753}
754
755aim_conn_t *owl_global_get_bosconn(owl_global *g)
756{
757  return(&(g->bosconn));
758}
759
760void owl_global_set_bossconn(owl_global *g, aim_conn_t *conn)
761{
762  g->bosconn=*conn;
763}
764
765int owl_global_is_aimnop_time(owl_global *g)
766{
767  if (owl_timer_is_expired(&(g->aim_noop_timer))) return(1);
768  return(0);
769}
770
771void owl_global_aimnop_sent(owl_global *g)
772{
773  owl_timer_reset(&(g->aim_noop_timer));
774}
775
776owl_timer *owl_global_get_aim_login_timer(owl_global *g)
777{
778  return(&(g->aim_ignorelogin_timer));
779}
780
781/* message queue */
782
783void owl_global_messagequeue_addmsg(owl_global *g, owl_message *m)
784{
785  owl_list_append_element(&(g->messagequeue), m);
786}
787
788/* pop off the first message and return it.  Return NULL if the queue
789 * is empty.  The caller should free the message after using it, if
790 * necessary.
791 */
792owl_message *owl_global_messageuque_popmsg(owl_global *g)
793{
794  owl_message *out;
795
796  if (owl_list_get_size(&(g->messagequeue))==0) return(NULL);
797  out=owl_list_get_element(&(g->messagequeue), 0);
798  owl_list_remove_element(&(g->messagequeue), 0);
799  return(out);
800}
801
802int owl_global_messagequeue_pending(owl_global *g)
803{
804  if (owl_list_get_size(&(g->messagequeue))==0) return(0);
805  return(1);
806}
807
808owl_buddylist *owl_global_get_buddylist(owl_global *g)
809{
810  return(&(g->buddylist));
811}
812 
813/* style */
814
815/* Return the style with name 'name'.  If it does not exist return
816 * NULL */
817owl_style *owl_global_get_style_by_name(owl_global *g, char *name)
818{
819  return owl_dict_find_element(&(g->styledict), name);
820}
821
822/* creates a list and fills it in with keys.  duplicates the keys,
823 * so they will need to be freed by the caller. */
824int owl_global_get_style_names(owl_global *g, owl_list *l) {
825  return owl_dict_get_keys(&(g->styledict), l);
826}
827
828void owl_global_add_style(owl_global *g, owl_style *s)
829{
830  owl_dict_insert_element(&(g->styledict), owl_style_get_name(s), 
831                          s, (void(*)(void*))owl_style_free);
832}
833
834char *owl_global_get_response(owl_global *g)
835{
836  if (g->response==NULL) return("");
837  return(g->response);
838}
839
840void owl_global_set_response(owl_global *g, char *resp)
841{
842  if (g->response) owl_free(g->response);
843  g->response=owl_strdup(resp);
844}
845
846
847void owl_global_set_haveaim(owl_global *g)
848{
849  g->haveaim=1;
850}
851
852int owl_global_is_haveaim(owl_global *g)
853{
854  if (g->haveaim) return(1);
855  return(0);
856}
857
858void owl_global_set_havezephyr(owl_global *g)
859{
860  g->havezephyr=1;
861}
862
863int owl_global_is_havezephyr(owl_global *g)
864{
865  if (g->havezephyr) return(1);
866  return(0);
867}
868
869owl_timer *owl_global_get_aim_buddyinfo_timer(owl_global *g)
870{
871  return(&(g->aim_buddyinfo_timer));
872}
873
874owl_errqueue *owl_global_get_errqueue(owl_global *g)
875{
876  return(&(g->errqueue));
877}
878
879void owl_global_set_errsignal(owl_global *g, int signum, siginfo_t *siginfo)
880{
881  g->got_err_signal = signum;
882  if (siginfo) {
883    g->err_signal_info = *siginfo;
884  } else {
885    memset(&(g->err_signal_info), 0, sizeof(siginfo_t));
886  }
887}
888
889int owl_global_get_errsignal_and_clear(owl_global *g, siginfo_t *siginfo)
890{
891  int signum;
892  if (siginfo && g->got_err_signal) {
893    *siginfo = g->err_signal_info;
894  } 
895  signum = g->got_err_signal;
896  g->got_err_signal = 0;
897  return signum;
898}
899
900owl_timer *owl_global_get_zephyr_buddycheck_timer(owl_global *g)
901{
902  return(&(g->zephyr_buddycheck_timer));
903}
904
905owl_zbuddylist *owl_global_get_zephyr_buddylist(owl_global *g)
906{
907  return(&(g->zbuddies));
908}
909
910struct termios *owl_global_get_startup_tio(owl_global *g)
911{
912  return(&(g->startup_tio));
913}
914
915owl_list *owl_global_get_dispatchlist(owl_global *g)
916{
917  return &(g->dispatchlist);
918}
Note: See TracBrowser for help on using the repository browser.