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