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