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