source: global.c @ 228326a

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