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