[7d4fbcd] | 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 | |
---|
| 11 | #ifndef MAXHOSTNAMELEN |
---|
| 12 | #define MAXHOSTNAMELEN 256 |
---|
| 13 | #endif |
---|
| 14 | |
---|
| 15 | void owl_global_init(owl_global *g) { |
---|
| 16 | struct hostent *hent; |
---|
| 17 | char hostname[MAXHOSTNAMELEN]; |
---|
[ad15610] | 18 | char *cd; |
---|
[7d4fbcd] | 19 | |
---|
[8262340] | 20 | g->malloced=0; |
---|
| 21 | g->freed=0; |
---|
| 22 | |
---|
[7d4fbcd] | 23 | gethostname(hostname, MAXHOSTNAMELEN); |
---|
| 24 | hent=gethostbyname(hostname); |
---|
| 25 | if (!hent) { |
---|
[a8938c7] | 26 | g->thishost=owl_strdup("localhost"); |
---|
[7d4fbcd] | 27 | } else { |
---|
[a8938c7] | 28 | g->thishost=owl_strdup(hent->h_name); |
---|
[7d4fbcd] | 29 | } |
---|
| 30 | |
---|
[a999d9e] | 31 | g->context_stack = NULL; |
---|
| 32 | owl_global_push_context(g, OWL_CTX_STARTUP, NULL, NULL); |
---|
| 33 | |
---|
[7d4fbcd] | 34 | g->curmsg=0; |
---|
| 35 | g->topmsg=0; |
---|
[bd783db] | 36 | g->markedmsgid=-1; |
---|
[7d4fbcd] | 37 | g->needrefresh=1; |
---|
[a8938c7] | 38 | g->startupargs=NULL; |
---|
[7d4fbcd] | 39 | |
---|
| 40 | owl_variable_dict_setup(&(g->vars)); |
---|
| 41 | |
---|
| 42 | g->lines=LINES; |
---|
| 43 | g->cols=COLS; |
---|
| 44 | |
---|
| 45 | g->rightshift=0; |
---|
| 46 | |
---|
[38cc669] | 47 | g->tw = NULL; |
---|
[7d4fbcd] | 48 | |
---|
| 49 | owl_keyhandler_init(&g->kh); |
---|
| 50 | owl_keys_setup_keymaps(&g->kh); |
---|
| 51 | |
---|
[129e609] | 52 | owl_dict_create(&(g->filters)); |
---|
| 53 | g->filterlist = NULL; |
---|
[7d4fbcd] | 54 | owl_list_create(&(g->puntlist)); |
---|
[d09e5a1] | 55 | owl_list_create(&(g->messagequeue)); |
---|
[f1e629d] | 56 | owl_dict_create(&(g->styledict)); |
---|
[7d4fbcd] | 57 | g->curmsg_vert_offset=0; |
---|
| 58 | g->resizepending=0; |
---|
| 59 | g->direction=OWL_DIRECTION_DOWNWARDS; |
---|
| 60 | g->zaway=0; |
---|
| 61 | if (has_colors()) { |
---|
| 62 | g->hascolors=1; |
---|
| 63 | } |
---|
| 64 | g->colorpairs=COLOR_PAIRS; |
---|
[8fa9562] | 65 | owl_fmtext_init_colorpair_mgr(&(g->cpmgr)); |
---|
[7d4fbcd] | 66 | g->debug=OWL_DEBUG; |
---|
[41c9a96] | 67 | owl_regex_init(&g->search_re); |
---|
[7d4fbcd] | 68 | g->starttime=time(NULL); /* assumes we call init only a start time */ |
---|
[7f792c1] | 69 | g->lastinputtime=g->starttime; |
---|
[700c712] | 70 | g->newmsgproc_pid=0; |
---|
[61e79a9] | 71 | |
---|
[7d4fbcd] | 72 | owl_global_set_config_format(g, 0); |
---|
| 73 | owl_global_set_userclue(g, OWL_USERCLUE_NONE); |
---|
| 74 | owl_global_set_no_have_config(g); |
---|
[10b866d] | 75 | owl_history_init(&(g->msghist)); |
---|
| 76 | owl_history_init(&(g->cmdhist)); |
---|
[5a9f6fe] | 77 | owl_history_set_norepeats(&(g->cmdhist)); |
---|
[7d4fbcd] | 78 | g->nextmsgid=0; |
---|
| 79 | |
---|
| 80 | _owl_global_setup_windows(g); |
---|
| 81 | |
---|
| 82 | /* Fill in some variables which don't have constant defaults */ |
---|
| 83 | /* TODO: come back later and check passwd file first */ |
---|
[a8938c7] | 84 | g->homedir=owl_strdup(getenv("HOME")); |
---|
[7d4fbcd] | 85 | |
---|
[b363d83] | 86 | g->confdir = NULL; |
---|
| 87 | g->startupfile = NULL; |
---|
[ad15610] | 88 | cd = owl_sprintf("%s/%s", g->homedir, OWL_CONFIG_DIR); |
---|
[b363d83] | 89 | owl_global_set_confdir(g, cd); |
---|
| 90 | owl_free(cd); |
---|
| 91 | |
---|
[7d4fbcd] | 92 | owl_messagelist_create(&(g->msglist)); |
---|
| 93 | owl_mainwin_init(&(g->mw)); |
---|
| 94 | owl_popwin_init(&(g->pw)); |
---|
[d09e5a1] | 95 | |
---|
| 96 | g->aim_screenname=NULL; |
---|
[81655f8] | 97 | g->aim_screenname_for_filters=NULL; |
---|
[d09e5a1] | 98 | g->aim_loggedin=0; |
---|
[aa5f725] | 99 | owl_buddylist_init(&(g->buddylist)); |
---|
[b7bb454] | 100 | |
---|
[09489b89] | 101 | g->havezephyr=0; |
---|
| 102 | g->haveaim=0; |
---|
[b7bb454] | 103 | g->ignoreaimlogin=0; |
---|
[a352335c] | 104 | owl_global_set_no_doaimevents(g); |
---|
[ec6ff52] | 105 | |
---|
| 106 | owl_errqueue_init(&(g->errqueue)); |
---|
[c9e72d1] | 107 | g->got_err_signal=0; |
---|
[5a95b69] | 108 | |
---|
| 109 | owl_zbuddylist_create(&(g->zbuddies)); |
---|
[8e401cae] | 110 | |
---|
[f25812b] | 111 | g->zaldlist = NULL; |
---|
| 112 | g->pseudologin_notify = 0; |
---|
| 113 | |
---|
[8e401cae] | 114 | owl_obarray_init(&(g->obarray)); |
---|
[a387d12e] | 115 | |
---|
| 116 | owl_message_init_fmtext_cache(); |
---|
[df0138f] | 117 | owl_list_create(&(g->io_dispatch_list)); |
---|
[4f2166b] | 118 | owl_list_create(&(g->psa_list)); |
---|
[58d1f8a] | 119 | g->timerlist = NULL; |
---|
[adee9cc] | 120 | g->interrupted = FALSE; |
---|
[7d4fbcd] | 121 | } |
---|
| 122 | |
---|
[eb6cedc] | 123 | /* Called once perl has been initialized */ |
---|
| 124 | void owl_global_complete_setup(owl_global *g) |
---|
| 125 | { |
---|
| 126 | owl_cmddict_setup(&(g->cmds)); |
---|
| 127 | } |
---|
| 128 | |
---|
[8ae2de9] | 129 | /* If *pan does not exist, we create a new panel, otherwise we replace the |
---|
| 130 | window in *pan with win. |
---|
| 131 | |
---|
| 132 | libpanel PANEL objects cannot exist without owner a valid window. This |
---|
| 133 | maintains the invariant for _owl_global_setup_windows. */ |
---|
| 134 | void _owl_panel_set_window(PANEL **pan, WINDOW *win) |
---|
| 135 | { |
---|
| 136 | WINDOW *oldwin; |
---|
[b3adfb5] | 137 | |
---|
| 138 | if (win == NULL) { |
---|
| 139 | owl_function_debugmsg("_owl_panel_set_window: passed NULL win (failed to allocate?)\n"); |
---|
| 140 | endwin(); |
---|
| 141 | exit(50); |
---|
| 142 | } |
---|
| 143 | |
---|
[8ae2de9] | 144 | if (*pan) { |
---|
| 145 | oldwin = panel_window(*pan); |
---|
| 146 | replace_panel(*pan, win); |
---|
| 147 | delwin(oldwin); |
---|
| 148 | } else { |
---|
| 149 | *pan = new_panel(win); |
---|
| 150 | } |
---|
| 151 | } |
---|
| 152 | |
---|
[7d4fbcd] | 153 | void _owl_global_setup_windows(owl_global *g) { |
---|
[ecd5dc5] | 154 | int cols, typwin_lines; |
---|
[7d4fbcd] | 155 | |
---|
| 156 | cols=g->cols; |
---|
[ecd5dc5] | 157 | typwin_lines=owl_global_get_typwin_lines(g); |
---|
[7d4fbcd] | 158 | |
---|
| 159 | /* set the new window sizes */ |
---|
| 160 | g->recwinlines=g->lines-(typwin_lines+2); |
---|
[176d3443] | 161 | if (g->recwinlines<0) { |
---|
| 162 | /* gotta deal with this */ |
---|
| 163 | g->recwinlines=0; |
---|
[ecd5dc5] | 164 | } |
---|
[7d4fbcd] | 165 | |
---|
[176d3443] | 166 | owl_function_debugmsg("_owl_global_setup_windows: about to call newwin(%i, %i, 0, 0)\n", g->recwinlines, cols); |
---|
| 167 | |
---|
[7d4fbcd] | 168 | /* create the new windows */ |
---|
[b3adfb5] | 169 | _owl_panel_set_window(&g->recpan, newwin(g->recwinlines, cols, 0, 0)); |
---|
| 170 | _owl_panel_set_window(&g->seppan, newwin(1, cols, g->recwinlines, 0)); |
---|
| 171 | _owl_panel_set_window(&g->msgpan, newwin(1, cols, g->recwinlines+1, 0)); |
---|
| 172 | _owl_panel_set_window(&g->typpan, newwin(typwin_lines, cols, g->recwinlines+2, 0)); |
---|
| 173 | |
---|
[38cc669] | 174 | if (g->tw) |
---|
| 175 | owl_editwin_set_curswin(g->tw, owl_global_get_curs_typwin(g), typwin_lines, g->cols); |
---|
[b3adfb5] | 176 | |
---|
| 177 | idlok(owl_global_get_curs_typwin(g), FALSE); |
---|
| 178 | idlok(owl_global_get_curs_recwin(g), FALSE); |
---|
| 179 | idlok(owl_global_get_curs_sepwin(g), FALSE); |
---|
| 180 | idlok(owl_global_get_curs_msgwin(g), FALSE); |
---|
| 181 | |
---|
| 182 | nodelay(owl_global_get_curs_typwin(g), 1); |
---|
| 183 | keypad(owl_global_get_curs_typwin(g), TRUE); |
---|
| 184 | wmove(owl_global_get_curs_typwin(g), 0, 0); |
---|
| 185 | |
---|
| 186 | meta(owl_global_get_curs_typwin(g), TRUE); |
---|
[7d4fbcd] | 187 | } |
---|
| 188 | |
---|
| 189 | owl_context *owl_global_get_context(owl_global *g) { |
---|
[a999d9e] | 190 | if (!g->context_stack) |
---|
| 191 | return NULL; |
---|
| 192 | return g->context_stack->data; |
---|
| 193 | } |
---|
| 194 | |
---|
| 195 | static void owl_global_lookup_keymap(owl_global *g) { |
---|
| 196 | owl_context *c = owl_global_get_context(g); |
---|
| 197 | if (!c || !c->keymap) |
---|
| 198 | return; |
---|
| 199 | |
---|
| 200 | if (!owl_keyhandler_activate(owl_global_get_keyhandler(g), c->keymap)) { |
---|
| 201 | owl_function_error("Unable to activate keymap '%s'", c->keymap); |
---|
| 202 | } |
---|
[7d4fbcd] | 203 | } |
---|
[a999d9e] | 204 | |
---|
| 205 | void owl_global_push_context(owl_global *g, int mode, void *data, const char *keymap) { |
---|
| 206 | owl_context *c; |
---|
| 207 | if (!(mode & OWL_CTX_MODE_BITS)) |
---|
| 208 | mode |= OWL_CTX_INTERACTIVE; |
---|
| 209 | c = owl_malloc(sizeof *c); |
---|
| 210 | c->mode = mode; |
---|
| 211 | c->data = data; |
---|
| 212 | c->keymap = owl_strdup(keymap); |
---|
| 213 | g->context_stack = g_list_prepend(g->context_stack, c); |
---|
| 214 | owl_global_lookup_keymap(g); |
---|
| 215 | } |
---|
| 216 | |
---|
| 217 | void owl_global_pop_context(owl_global *g) { |
---|
| 218 | owl_context *c; |
---|
| 219 | if (!g->context_stack) |
---|
| 220 | return; |
---|
| 221 | c = owl_global_get_context(g); |
---|
| 222 | g->context_stack = g_list_delete_link(g->context_stack, |
---|
| 223 | g->context_stack); |
---|
| 224 | owl_free(c->keymap); |
---|
| 225 | owl_free(c); |
---|
| 226 | owl_global_lookup_keymap(g); |
---|
| 227 | } |
---|
| 228 | |
---|
[8742840] | 229 | int owl_global_get_lines(const owl_global *g) { |
---|
[7d4fbcd] | 230 | return(g->lines); |
---|
| 231 | } |
---|
| 232 | |
---|
[8742840] | 233 | int owl_global_get_cols(const owl_global *g) { |
---|
[7d4fbcd] | 234 | return(g->cols); |
---|
| 235 | } |
---|
| 236 | |
---|
[8742840] | 237 | int owl_global_get_recwin_lines(const owl_global *g) { |
---|
[7d4fbcd] | 238 | return(g->recwinlines); |
---|
| 239 | } |
---|
| 240 | |
---|
| 241 | /* curmsg */ |
---|
| 242 | |
---|
[8742840] | 243 | int owl_global_get_curmsg(const owl_global *g) { |
---|
[7d4fbcd] | 244 | return(g->curmsg); |
---|
| 245 | } |
---|
| 246 | |
---|
| 247 | void owl_global_set_curmsg(owl_global *g, int i) { |
---|
| 248 | g->curmsg=i; |
---|
| 249 | /* we will reset the vertical offset from here */ |
---|
| 250 | /* we might want to move this out to the functions later */ |
---|
| 251 | owl_global_set_curmsg_vert_offset(g, 0); |
---|
| 252 | } |
---|
| 253 | |
---|
| 254 | /* topmsg */ |
---|
| 255 | |
---|
[8742840] | 256 | int owl_global_get_topmsg(const owl_global *g) { |
---|
[7d4fbcd] | 257 | return(g->topmsg); |
---|
| 258 | } |
---|
| 259 | |
---|
| 260 | void owl_global_set_topmsg(owl_global *g, int i) { |
---|
| 261 | g->topmsg=i; |
---|
| 262 | } |
---|
| 263 | |
---|
[70110286] | 264 | /* markedmsgid */ |
---|
| 265 | |
---|
[8742840] | 266 | int owl_global_get_markedmsgid(const owl_global *g) { |
---|
[70110286] | 267 | return(g->markedmsgid); |
---|
| 268 | } |
---|
| 269 | |
---|
| 270 | void owl_global_set_markedmsgid(owl_global *g, int i) { |
---|
| 271 | g->markedmsgid=i; |
---|
| 272 | /* i; index of message in the current view. |
---|
[c08c70a] | 273 | const owl_message *m; |
---|
[70110286] | 274 | owl_view *v; |
---|
| 275 | |
---|
| 276 | v = owl_global_get_current_view(&g); |
---|
| 277 | m = owl_view_get_element(v, i); |
---|
| 278 | g->markedmsgid = m ? owl_message_get_id(m) : 0; |
---|
| 279 | */ |
---|
| 280 | } |
---|
| 281 | |
---|
[7d4fbcd] | 282 | /* windows */ |
---|
| 283 | |
---|
| 284 | owl_mainwin *owl_global_get_mainwin(owl_global *g) { |
---|
| 285 | return(&(g->mw)); |
---|
| 286 | } |
---|
| 287 | |
---|
| 288 | owl_popwin *owl_global_get_popwin(owl_global *g) { |
---|
| 289 | return(&(g->pw)); |
---|
| 290 | } |
---|
| 291 | |
---|
| 292 | /* msglist */ |
---|
| 293 | |
---|
| 294 | owl_messagelist *owl_global_get_msglist(owl_global *g) { |
---|
| 295 | return(&(g->msglist)); |
---|
| 296 | } |
---|
| 297 | |
---|
| 298 | /* keyhandler */ |
---|
| 299 | |
---|
| 300 | owl_keyhandler *owl_global_get_keyhandler(owl_global *g) { |
---|
| 301 | return(&(g->kh)); |
---|
| 302 | } |
---|
| 303 | |
---|
| 304 | /* curses windows */ |
---|
| 305 | |
---|
[8742840] | 306 | WINDOW *owl_global_get_curs_recwin(const owl_global *g) { |
---|
[b3adfb5] | 307 | return panel_window(g->recpan); |
---|
[7d4fbcd] | 308 | } |
---|
| 309 | |
---|
[8742840] | 310 | WINDOW *owl_global_get_curs_sepwin(const owl_global *g) { |
---|
[b3adfb5] | 311 | return panel_window(g->seppan); |
---|
[7d4fbcd] | 312 | } |
---|
| 313 | |
---|
[8742840] | 314 | WINDOW *owl_global_get_curs_msgwin(const owl_global *g) { |
---|
[b3adfb5] | 315 | return panel_window(g->msgpan); |
---|
[7d4fbcd] | 316 | } |
---|
| 317 | |
---|
[8742840] | 318 | WINDOW *owl_global_get_curs_typwin(const owl_global *g) { |
---|
[b3adfb5] | 319 | return panel_window(g->typpan); |
---|
[7d4fbcd] | 320 | } |
---|
| 321 | |
---|
| 322 | /* typwin */ |
---|
| 323 | |
---|
[8742840] | 324 | owl_editwin *owl_global_get_typwin(const owl_global *g) { |
---|
[a556caa] | 325 | return(g->tw); |
---|
[7d4fbcd] | 326 | } |
---|
| 327 | |
---|
| 328 | /* refresh */ |
---|
| 329 | |
---|
[8742840] | 330 | int owl_global_is_needrefresh(const owl_global *g) { |
---|
[7d4fbcd] | 331 | if (g->needrefresh==1) return(1); |
---|
| 332 | return(0); |
---|
| 333 | } |
---|
| 334 | |
---|
| 335 | void owl_global_set_needrefresh(owl_global *g) { |
---|
| 336 | g->needrefresh=1; |
---|
| 337 | } |
---|
| 338 | |
---|
| 339 | void owl_global_set_noneedrefresh(owl_global *g) { |
---|
| 340 | g->needrefresh=0; |
---|
| 341 | } |
---|
| 342 | |
---|
| 343 | /* variable dictionary */ |
---|
| 344 | |
---|
| 345 | owl_vardict *owl_global_get_vardict(owl_global *g) { |
---|
| 346 | return &(g->vars); |
---|
| 347 | } |
---|
| 348 | |
---|
| 349 | /* command dictionary */ |
---|
| 350 | |
---|
| 351 | owl_cmddict *owl_global_get_cmddict(owl_global *g) { |
---|
| 352 | return &(g->cmds); |
---|
| 353 | } |
---|
| 354 | |
---|
| 355 | /* rightshift */ |
---|
| 356 | |
---|
| 357 | void owl_global_set_rightshift(owl_global *g, int i) { |
---|
| 358 | g->rightshift=i; |
---|
| 359 | } |
---|
| 360 | |
---|
[8742840] | 361 | int owl_global_get_rightshift(const owl_global *g) { |
---|
[7d4fbcd] | 362 | return(g->rightshift); |
---|
| 363 | } |
---|
| 364 | |
---|
| 365 | /* typwin */ |
---|
| 366 | |
---|
[58d47ca] | 367 | owl_editwin *owl_global_set_typwin_active(owl_global *g, int style, owl_history *hist) { |
---|
[38cc669] | 368 | int d; |
---|
| 369 | d = owl_global_get_typewindelta(g); |
---|
[73eda8c] | 370 | if (d > 0 && style == OWL_EDITWIN_STYLE_MULTILINE) |
---|
[da466e0] | 371 | owl_function_resize_typwin(owl_global_get_typwin_lines(g) + d); |
---|
| 372 | |
---|
[38cc669] | 373 | g->tw = owl_editwin_new(owl_global_get_curs_typwin(g), |
---|
| 374 | owl_global_get_typwin_lines(g), |
---|
| 375 | g->cols, |
---|
| 376 | style, |
---|
| 377 | hist); |
---|
[58d47ca] | 378 | return g->tw; |
---|
[7d4fbcd] | 379 | } |
---|
| 380 | |
---|
| 381 | void owl_global_set_typwin_inactive(owl_global *g) { |
---|
[da466e0] | 382 | int d = owl_global_get_typewindelta(g); |
---|
[73eda8c] | 383 | if (d > 0 && owl_editwin_get_style(g->tw) == OWL_EDITWIN_STYLE_MULTILINE) |
---|
[da466e0] | 384 | owl_function_resize_typwin(owl_global_get_typwin_lines(g) - d); |
---|
| 385 | |
---|
[38cc669] | 386 | werase(owl_global_get_curs_typwin(g)); |
---|
| 387 | g->tw = NULL; |
---|
[7d4fbcd] | 388 | } |
---|
| 389 | |
---|
| 390 | /* resize */ |
---|
| 391 | |
---|
| 392 | void owl_global_set_resize_pending(owl_global *g) { |
---|
| 393 | g->resizepending=1; |
---|
| 394 | } |
---|
| 395 | |
---|
[8742840] | 396 | const char *owl_global_get_homedir(const owl_global *g) { |
---|
[a8938c7] | 397 | if (g->homedir) return(g->homedir); |
---|
| 398 | return("/"); |
---|
[7d4fbcd] | 399 | } |
---|
| 400 | |
---|
[8742840] | 401 | const char *owl_global_get_confdir(const owl_global *g) { |
---|
[b363d83] | 402 | if (g->confdir) return(g->confdir); |
---|
| 403 | return("/"); |
---|
| 404 | } |
---|
| 405 | |
---|
| 406 | /* |
---|
| 407 | * Setting this also sets startupfile to confdir/startup |
---|
| 408 | */ |
---|
[e19eb97] | 409 | void owl_global_set_confdir(owl_global *g, const char *cd) { |
---|
[27f6487] | 410 | owl_free(g->confdir); |
---|
[b363d83] | 411 | g->confdir = owl_strdup(cd); |
---|
[27f6487] | 412 | owl_free(g->startupfile); |
---|
[b363d83] | 413 | g->startupfile = owl_sprintf("%s/startup", cd); |
---|
| 414 | } |
---|
| 415 | |
---|
[8742840] | 416 | const char *owl_global_get_startupfile(const owl_global *g) { |
---|
[b363d83] | 417 | if(g->startupfile) return(g->startupfile); |
---|
| 418 | return("/"); |
---|
| 419 | } |
---|
| 420 | |
---|
[8742840] | 421 | int owl_global_get_direction(const owl_global *g) { |
---|
[7d4fbcd] | 422 | return(g->direction); |
---|
| 423 | } |
---|
| 424 | |
---|
| 425 | void owl_global_set_direction_downwards(owl_global *g) { |
---|
| 426 | g->direction=OWL_DIRECTION_DOWNWARDS; |
---|
| 427 | } |
---|
| 428 | |
---|
| 429 | void owl_global_set_direction_upwards(owl_global *g) { |
---|
| 430 | g->direction=OWL_DIRECTION_UPWARDS; |
---|
| 431 | } |
---|
| 432 | |
---|
| 433 | /* perl stuff */ |
---|
| 434 | |
---|
| 435 | void owl_global_set_perlinterp(owl_global *g, void *p) { |
---|
| 436 | g->perl=p; |
---|
| 437 | } |
---|
| 438 | |
---|
[8742840] | 439 | void *owl_global_get_perlinterp(const owl_global *g) { |
---|
[7d4fbcd] | 440 | return(g->perl); |
---|
| 441 | } |
---|
| 442 | |
---|
[8742840] | 443 | int owl_global_is_config_format(const owl_global *g) { |
---|
[7d4fbcd] | 444 | if (g->config_format) return(1); |
---|
| 445 | return(0); |
---|
| 446 | } |
---|
| 447 | |
---|
| 448 | void owl_global_set_config_format(owl_global *g, int state) { |
---|
| 449 | if (state==1) { |
---|
| 450 | g->config_format=1; |
---|
| 451 | } else { |
---|
| 452 | g->config_format=0; |
---|
| 453 | } |
---|
| 454 | } |
---|
| 455 | |
---|
| 456 | void owl_global_set_have_config(owl_global *g) { |
---|
| 457 | g->haveconfig=1; |
---|
| 458 | } |
---|
| 459 | |
---|
| 460 | void owl_global_set_no_have_config(owl_global *g) { |
---|
| 461 | g->haveconfig=0; |
---|
| 462 | } |
---|
| 463 | |
---|
| 464 | int owl_global_have_config(owl_global *g) { |
---|
| 465 | if (g->haveconfig) return(1); |
---|
| 466 | return(0); |
---|
| 467 | } |
---|
| 468 | |
---|
| 469 | void owl_global_resize(owl_global *g, int x, int y) { |
---|
| 470 | /* resize the screen. If x or y is 0 use the terminal size */ |
---|
| 471 | struct winsize size; |
---|
| 472 | |
---|
| 473 | if (!g->resizepending) return; |
---|
[8479494] | 474 | g->resizepending = 0; |
---|
[7d4fbcd] | 475 | |
---|
| 476 | if (!isendwin()) { |
---|
| 477 | endwin(); |
---|
| 478 | } |
---|
| 479 | |
---|
| 480 | /* get the new size */ |
---|
| 481 | ioctl(STDIN_FILENO, TIOCGWINSZ, &size); |
---|
| 482 | if (x==0) { |
---|
[054894e] | 483 | if (size.ws_row) { |
---|
| 484 | g->lines=size.ws_row; |
---|
| 485 | } else { |
---|
| 486 | g->lines=LINES; |
---|
| 487 | } |
---|
[7d4fbcd] | 488 | } else { |
---|
[054894e] | 489 | g->lines=x; |
---|
[7d4fbcd] | 490 | } |
---|
| 491 | |
---|
| 492 | if (y==0) { |
---|
[054894e] | 493 | if (size.ws_col) { |
---|
| 494 | g->cols=size.ws_col; |
---|
| 495 | } else { |
---|
| 496 | g->cols=COLS; |
---|
| 497 | } |
---|
[7d4fbcd] | 498 | } else { |
---|
| 499 | g->cols=y; |
---|
| 500 | } |
---|
| 501 | |
---|
[1bdffcb] | 502 | #ifdef HAVE_RESIZETERM |
---|
[74037d9] | 503 | resizeterm(size.ws_row, size.ws_col); |
---|
[1bdffcb] | 504 | #endif |
---|
[7d4fbcd] | 505 | |
---|
| 506 | /* re-initialize the windows */ |
---|
| 507 | _owl_global_setup_windows(g); |
---|
| 508 | |
---|
[f1e629d] | 509 | /* in case any styles rely on the current width */ |
---|
| 510 | owl_messagelist_invalidate_formats(owl_global_get_msglist(g)); |
---|
| 511 | |
---|
[c0f9e30] | 512 | /* recalculate the topmsg to make sure the current message is on |
---|
| 513 | * screen */ |
---|
| 514 | owl_function_calculate_topmsg(OWL_DIRECTION_NONE); |
---|
| 515 | |
---|
[7d4fbcd] | 516 | /* refresh stuff */ |
---|
| 517 | g->needrefresh=1; |
---|
| 518 | owl_mainwin_redisplay(&(g->mw)); |
---|
| 519 | sepbar(NULL); |
---|
[38cc669] | 520 | if (g->tw) |
---|
| 521 | owl_editwin_redisplay(g->tw); |
---|
[59ab8dd] | 522 | else |
---|
| 523 | werase(owl_global_get_curs_typwin(g)); |
---|
| 524 | |
---|
[8240bce] | 525 | owl_function_full_redisplay(); |
---|
[7d4fbcd] | 526 | |
---|
[ecd5dc5] | 527 | owl_function_debugmsg("New size is %i lines, %i cols.", size.ws_row, size.ws_col); |
---|
[7d4fbcd] | 528 | owl_function_makemsg(""); |
---|
| 529 | } |
---|
| 530 | |
---|
| 531 | /* debug */ |
---|
| 532 | |
---|
[8742840] | 533 | int owl_global_is_debug_fast(const owl_global *g) { |
---|
[7d4fbcd] | 534 | if (g->debug) return(1); |
---|
| 535 | return(0); |
---|
| 536 | } |
---|
| 537 | |
---|
| 538 | /* starttime */ |
---|
| 539 | |
---|
[8742840] | 540 | time_t owl_global_get_starttime(const owl_global *g) { |
---|
[7d4fbcd] | 541 | return(g->starttime); |
---|
| 542 | } |
---|
| 543 | |
---|
[8742840] | 544 | time_t owl_global_get_runtime(const owl_global *g) { |
---|
[7d4fbcd] | 545 | return(time(NULL)-g->starttime); |
---|
| 546 | } |
---|
| 547 | |
---|
[8742840] | 548 | time_t owl_global_get_lastinputtime(const owl_global *g) { |
---|
[7f792c1] | 549 | return(g->lastinputtime); |
---|
| 550 | } |
---|
| 551 | |
---|
[eebef19] | 552 | void owl_global_set_lastinputtime(owl_global *g, time_t time) { |
---|
| 553 | g->lastinputtime = time; |
---|
[7f792c1] | 554 | } |
---|
| 555 | |
---|
[8742840] | 556 | time_t owl_global_get_idletime(const owl_global *g) { |
---|
[7f792c1] | 557 | return(time(NULL)-g->lastinputtime); |
---|
| 558 | } |
---|
| 559 | |
---|
[8742840] | 560 | const char *owl_global_get_hostname(const owl_global *g) { |
---|
[a8938c7] | 561 | if (g->thishost) return(g->thishost); |
---|
| 562 | return(""); |
---|
[61e79a9] | 563 | } |
---|
| 564 | |
---|
[7d4fbcd] | 565 | /* userclue */ |
---|
| 566 | |
---|
| 567 | void owl_global_set_userclue(owl_global *g, int clue) { |
---|
| 568 | g->userclue=clue; |
---|
| 569 | } |
---|
| 570 | |
---|
| 571 | void owl_global_add_userclue(owl_global *g, int clue) { |
---|
| 572 | g->userclue|=clue; |
---|
| 573 | } |
---|
| 574 | |
---|
[8742840] | 575 | int owl_global_get_userclue(const owl_global *g) { |
---|
[7d4fbcd] | 576 | return(g->userclue); |
---|
| 577 | } |
---|
| 578 | |
---|
[8742840] | 579 | int owl_global_is_userclue(const owl_global *g, int clue) { |
---|
[7d4fbcd] | 580 | if (g->userclue & clue) return(1); |
---|
| 581 | return(0); |
---|
| 582 | } |
---|
| 583 | |
---|
| 584 | /* viewwin */ |
---|
| 585 | |
---|
| 586 | owl_viewwin *owl_global_get_viewwin(owl_global *g) { |
---|
| 587 | return(&(g->vw)); |
---|
| 588 | } |
---|
| 589 | |
---|
| 590 | |
---|
| 591 | /* vert offset */ |
---|
| 592 | |
---|
[8742840] | 593 | int owl_global_get_curmsg_vert_offset(const owl_global *g) { |
---|
[7d4fbcd] | 594 | return(g->curmsg_vert_offset); |
---|
| 595 | } |
---|
| 596 | |
---|
| 597 | void owl_global_set_curmsg_vert_offset(owl_global *g, int i) { |
---|
| 598 | g->curmsg_vert_offset=i; |
---|
| 599 | } |
---|
| 600 | |
---|
| 601 | /* startup args */ |
---|
| 602 | |
---|
[e19eb97] | 603 | void owl_global_set_startupargs(owl_global *g, int argc, const char *const *argv) { |
---|
[a8938c7] | 604 | int i, len; |
---|
| 605 | |
---|
| 606 | if (g->startupargs) owl_free(g->startupargs); |
---|
| 607 | |
---|
| 608 | len=0; |
---|
| 609 | for (i=0; i<argc; i++) { |
---|
[591e6aa7] | 610 | len+=strlen(argv[i])+5; |
---|
[a8938c7] | 611 | } |
---|
[34509d5] | 612 | g->startupargs=owl_malloc(len+5); |
---|
[7d4fbcd] | 613 | |
---|
| 614 | strcpy(g->startupargs, ""); |
---|
| 615 | for (i=0; i<argc; i++) { |
---|
[b9cb41b] | 616 | sprintf(g->startupargs + strlen(g->startupargs), "%s ", argv[i]); |
---|
[7d4fbcd] | 617 | } |
---|
| 618 | g->startupargs[strlen(g->startupargs)-1]='\0'; |
---|
| 619 | } |
---|
| 620 | |
---|
[8742840] | 621 | const char *owl_global_get_startupargs(const owl_global *g) { |
---|
[a8938c7] | 622 | if (g->startupargs) return(g->startupargs); |
---|
| 623 | return(""); |
---|
[7d4fbcd] | 624 | } |
---|
| 625 | |
---|
| 626 | /* history */ |
---|
| 627 | |
---|
[10b866d] | 628 | owl_history *owl_global_get_msg_history(owl_global *g) { |
---|
| 629 | return(&(g->msghist)); |
---|
| 630 | } |
---|
| 631 | |
---|
| 632 | owl_history *owl_global_get_cmd_history(owl_global *g) { |
---|
| 633 | return(&(g->cmdhist)); |
---|
[7d4fbcd] | 634 | } |
---|
| 635 | |
---|
| 636 | /* filterlist */ |
---|
[129e609] | 637 | typedef struct _owl_global_filter_ent { /* noproto */ |
---|
| 638 | owl_global *g; |
---|
| 639 | owl_filter *f; |
---|
| 640 | } owl_global_filter_ent; |
---|
[7d4fbcd] | 641 | |
---|
[8742840] | 642 | owl_filter *owl_global_get_filter(const owl_global *g, const char *name) { |
---|
[129e609] | 643 | owl_global_filter_ent *e = owl_dict_find_element(&(g->filters), name); |
---|
| 644 | if (e) return e->f; |
---|
| 645 | return NULL; |
---|
| 646 | } |
---|
[7d4fbcd] | 647 | |
---|
[5294cbf] | 648 | static void owl_global_delete_filter_ent(void *data) |
---|
| 649 | { |
---|
[129e609] | 650 | owl_global_filter_ent *e = data; |
---|
| 651 | e->g->filterlist = g_list_remove(e->g->filterlist, e->f); |
---|
| 652 | owl_filter_delete(e->f); |
---|
| 653 | owl_free(e); |
---|
[7d4fbcd] | 654 | } |
---|
| 655 | |
---|
| 656 | void owl_global_add_filter(owl_global *g, owl_filter *f) { |
---|
[129e609] | 657 | owl_global_filter_ent *e = owl_malloc(sizeof *e); |
---|
| 658 | e->g = g; |
---|
| 659 | e->f = f; |
---|
| 660 | |
---|
| 661 | owl_dict_insert_element(&(g->filters), owl_filter_get_name(f), |
---|
[5294cbf] | 662 | e, owl_global_delete_filter_ent); |
---|
[129e609] | 663 | g->filterlist = g_list_append(g->filterlist, f); |
---|
[7d4fbcd] | 664 | } |
---|
| 665 | |
---|
[e19eb97] | 666 | void owl_global_remove_filter(owl_global *g, const char *name) { |
---|
[129e609] | 667 | owl_global_filter_ent *e = owl_dict_remove_element(&(g->filters), name); |
---|
| 668 | if (e) |
---|
[5294cbf] | 669 | owl_global_delete_filter_ent(e); |
---|
[7d4fbcd] | 670 | } |
---|
| 671 | |
---|
| 672 | /* nextmsgid */ |
---|
| 673 | |
---|
| 674 | int owl_global_get_nextmsgid(owl_global *g) { |
---|
| 675 | return(g->nextmsgid++); |
---|
| 676 | } |
---|
| 677 | |
---|
| 678 | /* current view */ |
---|
| 679 | |
---|
| 680 | owl_view *owl_global_get_current_view(owl_global *g) { |
---|
| 681 | return(&(g->current_view)); |
---|
| 682 | } |
---|
| 683 | |
---|
| 684 | /* has colors */ |
---|
| 685 | |
---|
[8742840] | 686 | int owl_global_get_hascolors(const owl_global *g) { |
---|
[7d4fbcd] | 687 | if (g->hascolors) return(1); |
---|
| 688 | return(0); |
---|
| 689 | } |
---|
| 690 | |
---|
| 691 | /* color pairs */ |
---|
| 692 | |
---|
[8742840] | 693 | int owl_global_get_colorpairs(const owl_global *g) { |
---|
[7d4fbcd] | 694 | return(g->colorpairs); |
---|
| 695 | } |
---|
| 696 | |
---|
[8fa9562] | 697 | owl_colorpair_mgr *owl_global_get_colorpair_mgr(owl_global *g) { |
---|
| 698 | return(&(g->cpmgr)); |
---|
| 699 | } |
---|
| 700 | |
---|
[7d4fbcd] | 701 | /* puntlist */ |
---|
| 702 | |
---|
| 703 | owl_list *owl_global_get_puntlist(owl_global *g) { |
---|
| 704 | return(&(g->puntlist)); |
---|
| 705 | } |
---|
| 706 | |
---|
[c08c70a] | 707 | int owl_global_message_is_puntable(owl_global *g, const owl_message *m) { |
---|
[77bced3] | 708 | const owl_list *pl; |
---|
[7d4fbcd] | 709 | int i, j; |
---|
| 710 | |
---|
| 711 | pl=owl_global_get_puntlist(g); |
---|
| 712 | j=owl_list_get_size(pl); |
---|
| 713 | for (i=0; i<j; i++) { |
---|
| 714 | if (owl_filter_message_match(owl_list_get_element(pl, i), m)) return(1); |
---|
| 715 | } |
---|
| 716 | return(0); |
---|
| 717 | } |
---|
| 718 | |
---|
| 719 | int owl_global_should_followlast(owl_global *g) { |
---|
[9e5c9f3] | 720 | const owl_view *v; |
---|
[7d4fbcd] | 721 | |
---|
| 722 | if (!owl_global_is__followlast(g)) return(0); |
---|
| 723 | |
---|
| 724 | v=owl_global_get_current_view(g); |
---|
| 725 | |
---|
| 726 | if (owl_global_get_curmsg(g)==owl_view_get_size(v)-1) return(1); |
---|
| 727 | return(0); |
---|
| 728 | } |
---|
[1fd0b25] | 729 | |
---|
[8742840] | 730 | int owl_global_is_search_active(const owl_global *g) { |
---|
[41c9a96] | 731 | if (owl_regex_is_set(&g->search_re)) return(1); |
---|
[1fd0b25] | 732 | return(0); |
---|
| 733 | } |
---|
| 734 | |
---|
[89b2daf] | 735 | void owl_global_set_search_re(owl_global *g, const owl_regex *re) { |
---|
[41c9a96] | 736 | if (owl_regex_is_set(&g->search_re)) { |
---|
[5cbc929] | 737 | owl_regex_cleanup(&g->search_re); |
---|
[41c9a96] | 738 | owl_regex_init(&g->search_re); |
---|
| 739 | } |
---|
| 740 | if (re != NULL) |
---|
| 741 | owl_regex_copy(re, &g->search_re); |
---|
[1fd0b25] | 742 | } |
---|
| 743 | |
---|
[8742840] | 744 | const owl_regex *owl_global_get_search_re(const owl_global *g) { |
---|
[41c9a96] | 745 | return &g->search_re; |
---|
[1fd0b25] | 746 | } |
---|
[700c712] | 747 | |
---|
[0e5afa2] | 748 | void owl_global_set_newmsgproc_pid(owl_global *g, pid_t i) { |
---|
[700c712] | 749 | g->newmsgproc_pid=i; |
---|
| 750 | } |
---|
| 751 | |
---|
[0e5afa2] | 752 | pid_t owl_global_get_newmsgproc_pid(const owl_global *g) { |
---|
[700c712] | 753 | return(g->newmsgproc_pid); |
---|
| 754 | } |
---|
| 755 | |
---|
[d09e5a1] | 756 | /* AIM stuff */ |
---|
| 757 | |
---|
[8742840] | 758 | int owl_global_is_aimloggedin(const owl_global *g) |
---|
[6a415e9] | 759 | { |
---|
[d09e5a1] | 760 | if (g->aim_loggedin) return(1); |
---|
| 761 | return(0); |
---|
| 762 | } |
---|
| 763 | |
---|
[8742840] | 764 | const char *owl_global_get_aim_screenname(const owl_global *g) |
---|
[6a415e9] | 765 | { |
---|
[a352335c] | 766 | if (owl_global_is_aimloggedin(g)) { |
---|
| 767 | return (g->aim_screenname); |
---|
| 768 | } |
---|
| 769 | return(""); |
---|
[d09e5a1] | 770 | } |
---|
| 771 | |
---|
[8742840] | 772 | const char *owl_global_get_aim_screenname_for_filters(const owl_global *g) |
---|
[81655f8] | 773 | { |
---|
| 774 | if (owl_global_is_aimloggedin(g)) { |
---|
| 775 | return (g->aim_screenname_for_filters); |
---|
| 776 | } |
---|
| 777 | return(""); |
---|
| 778 | } |
---|
| 779 | |
---|
[e19eb97] | 780 | void owl_global_set_aimloggedin(owl_global *g, const char *screenname) |
---|
[6a415e9] | 781 | { |
---|
[65b2173] | 782 | char *sn_escaped; |
---|
[e19eb97] | 783 | const char *quote; |
---|
[d09e5a1] | 784 | g->aim_loggedin=1; |
---|
| 785 | if (g->aim_screenname) owl_free(g->aim_screenname); |
---|
[81655f8] | 786 | if (g->aim_screenname_for_filters) owl_free(g->aim_screenname_for_filters); |
---|
[d09e5a1] | 787 | g->aim_screenname=owl_strdup(screenname); |
---|
[81655f8] | 788 | sn_escaped = owl_text_quote(screenname, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH); |
---|
| 789 | quote = owl_getquoting(sn_escaped); |
---|
[9f4e3f8] | 790 | g->aim_screenname_for_filters=owl_sprintf("%s%s%s", quote, sn_escaped, quote); |
---|
[81655f8] | 791 | owl_free(sn_escaped); |
---|
[d09e5a1] | 792 | } |
---|
| 793 | |
---|
[6a415e9] | 794 | void owl_global_set_aimnologgedin(owl_global *g) |
---|
| 795 | { |
---|
[d09e5a1] | 796 | g->aim_loggedin=0; |
---|
| 797 | } |
---|
| 798 | |
---|
[8742840] | 799 | int owl_global_is_doaimevents(const owl_global *g) |
---|
[a352335c] | 800 | { |
---|
| 801 | if (g->aim_doprocessing) return(1); |
---|
| 802 | return(0); |
---|
| 803 | } |
---|
| 804 | |
---|
| 805 | void owl_global_set_doaimevents(owl_global *g) |
---|
| 806 | { |
---|
| 807 | g->aim_doprocessing=1; |
---|
| 808 | } |
---|
| 809 | |
---|
| 810 | void owl_global_set_no_doaimevents(owl_global *g) |
---|
| 811 | { |
---|
| 812 | g->aim_doprocessing=0; |
---|
| 813 | } |
---|
| 814 | |
---|
[6a415e9] | 815 | aim_session_t *owl_global_get_aimsess(owl_global *g) |
---|
| 816 | { |
---|
[d09e5a1] | 817 | return(&(g->aimsess)); |
---|
| 818 | } |
---|
| 819 | |
---|
[c15bbfb] | 820 | aim_conn_t *owl_global_get_bosconn(owl_global *g) |
---|
| 821 | { |
---|
| 822 | return(&(g->bosconn)); |
---|
| 823 | } |
---|
| 824 | |
---|
| 825 | void owl_global_set_bossconn(owl_global *g, aim_conn_t *conn) |
---|
[6a415e9] | 826 | { |
---|
[c15bbfb] | 827 | g->bosconn=*conn; |
---|
[d09e5a1] | 828 | } |
---|
| 829 | |
---|
| 830 | /* message queue */ |
---|
| 831 | |
---|
[6a415e9] | 832 | void owl_global_messagequeue_addmsg(owl_global *g, owl_message *m) |
---|
| 833 | { |
---|
[d09e5a1] | 834 | owl_list_append_element(&(g->messagequeue), m); |
---|
| 835 | } |
---|
| 836 | |
---|
| 837 | /* pop off the first message and return it. Return NULL if the queue |
---|
| 838 | * is empty. The caller should free the message after using it, if |
---|
| 839 | * necessary. |
---|
| 840 | */ |
---|
[13a3c1db] | 841 | owl_message *owl_global_messagequeue_popmsg(owl_global *g) |
---|
[6a415e9] | 842 | { |
---|
[d09e5a1] | 843 | owl_message *out; |
---|
| 844 | |
---|
| 845 | if (owl_list_get_size(&(g->messagequeue))==0) return(NULL); |
---|
| 846 | out=owl_list_get_element(&(g->messagequeue), 0); |
---|
| 847 | owl_list_remove_element(&(g->messagequeue), 0); |
---|
| 848 | return(out); |
---|
| 849 | } |
---|
| 850 | |
---|
[6a415e9] | 851 | int owl_global_messagequeue_pending(owl_global *g) |
---|
| 852 | { |
---|
[d09e5a1] | 853 | if (owl_list_get_size(&(g->messagequeue))==0) return(0); |
---|
| 854 | return(1); |
---|
| 855 | } |
---|
[aa5f725] | 856 | |
---|
[6a415e9] | 857 | owl_buddylist *owl_global_get_buddylist(owl_global *g) |
---|
| 858 | { |
---|
[aa5f725] | 859 | return(&(g->buddylist)); |
---|
| 860 | } |
---|
| 861 | |
---|
[bd3f232] | 862 | /* style */ |
---|
| 863 | |
---|
| 864 | /* Return the style with name 'name'. If it does not exist return |
---|
| 865 | * NULL */ |
---|
[8742840] | 866 | const owl_style *owl_global_get_style_by_name(const owl_global *g, const char *name) |
---|
[bd3f232] | 867 | { |
---|
[f1e629d] | 868 | return owl_dict_find_element(&(g->styledict), name); |
---|
| 869 | } |
---|
| 870 | |
---|
| 871 | /* creates a list and fills it in with keys. duplicates the keys, |
---|
| 872 | * so they will need to be freed by the caller. */ |
---|
[8742840] | 873 | int owl_global_get_style_names(const owl_global *g, owl_list *l) { |
---|
[f1e629d] | 874 | return owl_dict_get_keys(&(g->styledict), l); |
---|
[bd3f232] | 875 | } |
---|
| 876 | |
---|
[cf83b7a] | 877 | void owl_global_add_style(owl_global *g, owl_style *s) |
---|
| 878 | { |
---|
[f1fc47f] | 879 | /* |
---|
| 880 | * If we're redefining the current style, make sure to update |
---|
| 881 | * pointers to it. |
---|
| 882 | */ |
---|
| 883 | if(g->current_view.style |
---|
| 884 | && !strcmp(owl_style_get_name(g->current_view.style), |
---|
| 885 | owl_style_get_name(s))) |
---|
| 886 | g->current_view.style = s; |
---|
| 887 | owl_dict_insert_element(&(g->styledict), owl_style_get_name(s), |
---|
[516c27e] | 888 | s, (void (*)(void *))owl_style_delete); |
---|
[bd3f232] | 889 | } |
---|
[cf83b7a] | 890 | |
---|
[09489b89] | 891 | void owl_global_set_haveaim(owl_global *g) |
---|
| 892 | { |
---|
| 893 | g->haveaim=1; |
---|
| 894 | } |
---|
| 895 | |
---|
[8742840] | 896 | int owl_global_is_haveaim(const owl_global *g) |
---|
[09489b89] | 897 | { |
---|
| 898 | if (g->haveaim) return(1); |
---|
| 899 | return(0); |
---|
| 900 | } |
---|
| 901 | |
---|
[b7bb454] | 902 | void owl_global_set_ignore_aimlogin(owl_global *g) |
---|
| 903 | { |
---|
| 904 | g->ignoreaimlogin = 1; |
---|
| 905 | } |
---|
| 906 | |
---|
| 907 | void owl_global_unset_ignore_aimlogin(owl_global *g) |
---|
| 908 | { |
---|
| 909 | g->ignoreaimlogin = 0; |
---|
| 910 | } |
---|
| 911 | |
---|
[8742840] | 912 | int owl_global_is_ignore_aimlogin(const owl_global *g) |
---|
[b7bb454] | 913 | { |
---|
| 914 | return g->ignoreaimlogin; |
---|
| 915 | } |
---|
| 916 | |
---|
[09489b89] | 917 | void owl_global_set_havezephyr(owl_global *g) |
---|
| 918 | { |
---|
| 919 | g->havezephyr=1; |
---|
| 920 | } |
---|
| 921 | |
---|
[8742840] | 922 | int owl_global_is_havezephyr(const owl_global *g) |
---|
[09489b89] | 923 | { |
---|
| 924 | if (g->havezephyr) return(1); |
---|
| 925 | return(0); |
---|
| 926 | } |
---|
[de03334] | 927 | |
---|
[ec6ff52] | 928 | owl_errqueue *owl_global_get_errqueue(owl_global *g) |
---|
| 929 | { |
---|
| 930 | return(&(g->errqueue)); |
---|
| 931 | } |
---|
[c9e72d1] | 932 | |
---|
| 933 | void owl_global_set_errsignal(owl_global *g, int signum, siginfo_t *siginfo) |
---|
| 934 | { |
---|
| 935 | g->got_err_signal = signum; |
---|
| 936 | if (siginfo) { |
---|
| 937 | g->err_signal_info = *siginfo; |
---|
| 938 | } else { |
---|
[7892963] | 939 | siginfo_t si; |
---|
| 940 | memset(&si, 0, sizeof(si)); |
---|
| 941 | g->err_signal_info = si; |
---|
[c9e72d1] | 942 | } |
---|
| 943 | } |
---|
| 944 | |
---|
| 945 | int owl_global_get_errsignal_and_clear(owl_global *g, siginfo_t *siginfo) |
---|
| 946 | { |
---|
| 947 | int signum; |
---|
| 948 | if (siginfo && g->got_err_signal) { |
---|
| 949 | *siginfo = g->err_signal_info; |
---|
| 950 | } |
---|
| 951 | signum = g->got_err_signal; |
---|
| 952 | g->got_err_signal = 0; |
---|
| 953 | return signum; |
---|
| 954 | } |
---|
| 955 | |
---|
[5a95b69] | 956 | |
---|
| 957 | owl_zbuddylist *owl_global_get_zephyr_buddylist(owl_global *g) |
---|
| 958 | { |
---|
| 959 | return(&(g->zbuddies)); |
---|
| 960 | } |
---|
[8232149] | 961 | |
---|
[f25812b] | 962 | GList **owl_global_get_zaldlist(owl_global *g) |
---|
| 963 | { |
---|
| 964 | return &(g->zaldlist); |
---|
| 965 | } |
---|
| 966 | |
---|
| 967 | int owl_global_get_pseudologin_notify(owl_global *g) |
---|
| 968 | { |
---|
| 969 | return g->pseudologin_notify; |
---|
| 970 | } |
---|
| 971 | |
---|
| 972 | void owl_global_set_pseudologin_notify(owl_global *g, int notify) |
---|
| 973 | { |
---|
| 974 | g->pseudologin_notify = notify; |
---|
| 975 | } |
---|
| 976 | |
---|
[8232149] | 977 | struct termios *owl_global_get_startup_tio(owl_global *g) |
---|
| 978 | { |
---|
| 979 | return(&(g->startup_tio)); |
---|
| 980 | } |
---|
[8e401cae] | 981 | |
---|
[e19eb97] | 982 | const char * owl_global_intern(owl_global *g, const char * string) |
---|
[8e401cae] | 983 | { |
---|
| 984 | return owl_obarray_insert(&(g->obarray), string); |
---|
| 985 | } |
---|
[9c7a701] | 986 | |
---|
[df0138f] | 987 | owl_list *owl_global_get_io_dispatch_list(owl_global *g) |
---|
| 988 | { |
---|
| 989 | return &(g->io_dispatch_list); |
---|
| 990 | } |
---|
| 991 | |
---|
[4f2166b] | 992 | owl_list *owl_global_get_psa_list(owl_global *g) |
---|
| 993 | { |
---|
| 994 | return &(g->psa_list); |
---|
| 995 | } |
---|
| 996 | |
---|
[58d1f8a] | 997 | GList **owl_global_get_timerlist(owl_global *g) |
---|
[b7bb454] | 998 | { |
---|
[58d1f8a] | 999 | return &(g->timerlist); |
---|
[b7bb454] | 1000 | } |
---|
[adee9cc] | 1001 | |
---|
[8742840] | 1002 | int owl_global_is_interrupted(const owl_global *g) { |
---|
[0cb6c26] | 1003 | return g->interrupted; |
---|
[adee9cc] | 1004 | } |
---|
| 1005 | |
---|
| 1006 | void owl_global_set_interrupted(owl_global *g) { |
---|
| 1007 | g->interrupted = 1; |
---|
| 1008 | } |
---|
| 1009 | |
---|
| 1010 | void owl_global_unset_interrupted(owl_global *g) { |
---|
| 1011 | g->interrupted = 0; |
---|
| 1012 | } |
---|