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