source: global.c @ 10d67d5

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