Changeset 9835b7a
- Timestamp:
- May 30, 2011, 7:51:13 PM (14 years ago)
- Parents:
- 259e60a8 (diff), 1081d0f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Files:
-
- 1 added
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
Makefile.am
rce35060 r3535a6e 45 45 aim.c buddy.c buddylist.c style.c errqueue.c \ 46 46 zbuddylist.c popexec.c select.c wcwidth.c \ 47 glib_compat.c mainpanel.c msgwin.c sepbar.c editcontext.c 47 glib_compat.c mainpanel.c msgwin.c sepbar.c editcontext.c signal.c 48 48 49 49 NORMAL_SRCS = filterproc.c window.c windowcb.c -
aim.c
r3472845 rdc1edbd 446 446 } 447 447 448 int owl_aim_process_events(void) 449 { 450 aim_session_t *aimsess; 448 int owl_aim_process_events(aim_session_t *aimsess) 449 { 451 450 aim_conn_t *waitingconn = NULL; 452 451 struct timeval tv; … … 454 453 struct owlfaim_priv *priv; 455 454 456 aimsess=owl_global_get_aimsess(&g);457 455 priv = aimsess->aux_data; 458 456 … … 1795 1793 } 1796 1794 1797 void owl_process_aim(void) 1798 { 1799 if (owl_global_is_doaimevents(&g)) { 1800 owl_aim_process_events(); 1801 } 1802 } 1795 typedef struct _owl_aim_event_source { /*noproto*/ 1796 GSource source; 1797 aim_session_t *sess; 1798 GPtrArray *fds; 1799 } owl_aim_event_source; 1800 1801 static void truncate_pollfd_list(owl_aim_event_source *event_source, int len) 1802 { 1803 GPollFD *fd; 1804 int i; 1805 if (len < event_source->fds->len) 1806 owl_function_debugmsg("Truncating AIM PollFDs to %d, was %d", len, event_source->fds->len); 1807 for (i = len; i < event_source->fds->len; i++) { 1808 fd = event_source->fds->pdata[i]; 1809 g_source_remove_poll(&event_source->source, fd); 1810 g_free(fd); 1811 } 1812 g_ptr_array_remove_range(event_source->fds, len, event_source->fds->len - len); 1813 } 1814 1815 static gboolean owl_aim_event_source_prepare(GSource *source, int *timeout) 1816 { 1817 owl_aim_event_source *event_source = (owl_aim_event_source*)source; 1818 aim_conn_t *cur; 1819 GPollFD *fd; 1820 int i; 1821 1822 /* AIM HACK: 1823 * 1824 * The problem - I'm not sure where to hook into the owl/faim 1825 * interface to keep track of when the AIM socket(s) open and 1826 * close. In particular, the bosconn thing throws me off. So, 1827 * rather than register particular dispatchers for AIM, I look up 1828 * the relevant FDs and add them to select's watch lists, then 1829 * check for them individually before moving on to the other 1830 * dispatchers. --asedeno 1831 */ 1832 i = 0; 1833 for (cur = event_source->sess->connlist; cur; cur = cur->next) { 1834 if (cur->fd != -1) { 1835 /* Add new GPollFDs as necessary. */ 1836 if (i == event_source->fds->len) { 1837 fd = g_new0(GPollFD, 1); 1838 g_ptr_array_add(event_source->fds, fd); 1839 g_source_add_poll(source, fd); 1840 owl_function_debugmsg("Allocated new AIM PollFD, len = %d", event_source->fds->len); 1841 } 1842 fd = event_source->fds->pdata[i]; 1843 fd->fd = cur->fd; 1844 fd->events |= G_IO_IN | G_IO_HUP | G_IO_ERR; 1845 if (cur->status & AIM_CONN_STATUS_INPROGRESS) { 1846 /* Yes, we're checking writable sockets here. Without it, AIM 1847 login is really slow. */ 1848 fd->events |= G_IO_OUT; 1849 } 1850 i++; 1851 } 1852 } 1853 /* If the number of GPollFDs went down, clean up. */ 1854 truncate_pollfd_list(event_source, i); 1855 1856 *timeout = -1; 1857 return FALSE; 1858 } 1859 1860 static gboolean owl_aim_event_source_check(GSource *source) 1861 { 1862 owl_aim_event_source *event_source = (owl_aim_event_source*)source; 1863 int i; 1864 1865 for (i = 0; i < event_source->fds->len; i++) { 1866 GPollFD *fd = event_source->fds->pdata[i]; 1867 if (fd->revents & fd->events) 1868 return TRUE; 1869 } 1870 return FALSE; 1871 } 1872 1873 static gboolean owl_aim_event_source_dispatch(GSource *source, GSourceFunc callback, gpointer user_data) 1874 { 1875 owl_aim_event_source *event_source = (owl_aim_event_source*)source; 1876 owl_aim_process_events(event_source->sess); 1877 return TRUE; 1878 } 1879 1880 static void owl_aim_event_source_finalize(GSource *source) 1881 { 1882 owl_aim_event_source *event_source = (owl_aim_event_source*)source; 1883 truncate_pollfd_list(event_source, 0); 1884 g_ptr_array_free(event_source->fds, TRUE); 1885 } 1886 1887 static GSourceFuncs aim_event_funcs = { 1888 owl_aim_event_source_prepare, 1889 owl_aim_event_source_check, 1890 owl_aim_event_source_dispatch, 1891 owl_aim_event_source_finalize, 1892 }; 1893 1894 GSource *owl_aim_event_source_new(aim_session_t *sess) 1895 { 1896 GSource *source; 1897 owl_aim_event_source *event_source; 1898 1899 source = g_source_new(&aim_event_funcs, sizeof(owl_aim_event_source)); 1900 event_source = (owl_aim_event_source *)source; 1901 event_source->sess = sess; 1902 /* TODO: When we depend on glib 2.22+, use g_ptr_array_new_with_free_func. */ 1903 event_source->fds = g_ptr_array_new(); 1904 return source; 1905 } -
cmd.c
r6a71113 r4c7c21f 12 12 13 13 int owl_cmddict_setup(owl_cmddict *cd) { 14 if (0 != owl_cmddict_init(cd)) return(-1);14 owl_cmddict_init(cd); 15 15 if (0 != owl_cmddict_add_from_list(cd, commands_to_init)) return(-1); 16 16 return(0); 17 17 } 18 18 19 int owl_cmddict_init(owl_cmddict *cd) { 20 if (owl_dict_create(cd)) return(-1); 21 return(0); 19 void owl_cmddict_init(owl_cmddict *cd) { 20 owl_dict_create(cd); 22 21 } 23 22 … … 135 134 void owl_cmd_cleanup(owl_cmd *cmd) 136 135 { 137 if (cmd->name)g_free(cmd->name);138 if (cmd->summary)g_free(cmd->summary);139 if (cmd->usage)g_free(cmd->usage);140 if (cmd->description)g_free(cmd->description);141 if (cmd->cmd_aliased_to)g_free(cmd->cmd_aliased_to);136 g_free(cmd->name); 137 g_free(cmd->summary); 138 g_free(cmd->usage); 139 g_free(cmd->description); 140 g_free(cmd->cmd_aliased_to); 142 141 if (cmd->cmd_perl) owl_perlconfig_cmd_cleanup(cmd); 143 142 } -
commands.c
rc809f5e r697221f 281 281 OWLCMD_ARGS("punt", owl_command_punt, OWL_CTX_ANY, 282 282 "suppress an arbitrary filter", 283 "punt <filter- text>",284 "punt <filter-text (multiple words)> \n"283 "punt <filter-name>\n" 284 "punt <filter-text (multiple words)>", 285 285 "The punt command will suppress messages to the specified\n" 286 286 "filter\n\n" … … 289 289 OWLCMD_ARGS("unpunt", owl_command_unpunt, OWL_CTX_ANY, 290 290 "remove an entry from the punt list", 291 "unpunt < filter-text>\n"292 "unpunt <filter- text>\n"293 "unpunt < number>\n",291 "unpunt <number>\n" 292 "unpunt <filter-name>\n" 293 "unpunt <filter-text (multiple words)>", 294 294 "The unpunt command will remove an entry from the puntlist.\n" 295 "The first two forms correspond to the firsttwo forms of the :punt\n"296 "command. The latter allows you to remove a specific entry from the\n"295 "The last two forms correspond to the two forms of the :punt\n" 296 "command. The first allows you to remove a specific entry from\n" 297 297 "the list (see :show zpunts)\n\n" 298 298 "SEE ALSO: punt, zpunt, zunpunt, show zpunts\n"), … … 1288 1288 } 1289 1289 owl_function_nextmsg_full(filter, skip_deleted, last_if_none); 1290 if (filter)g_free(filter);1290 g_free(filter); 1291 1291 return(NULL); 1292 1292 } … … 1318 1318 } 1319 1319 owl_function_prevmsg_full(filter, skip_deleted, first_if_none); 1320 if (filter)g_free(filter);1320 g_free(filter); 1321 1321 return(NULL); 1322 1322 } … … 1691 1691 commands = g_strsplit_set(newbuff, ";", 0); 1692 1692 for (i = 0; commands[i] != NULL; i++) { 1693 if (lastrv) { 1694 g_free(lastrv); 1695 } 1693 g_free(lastrv); 1696 1694 lastrv = owl_function_command(commands[i]); 1697 1695 } … … 2466 2464 owl_list * fl; 2467 2465 owl_filter * f; 2468 char * text;2469 2466 int i; 2470 2467 … … 2482 2479 return; 2483 2480 } else { 2484 owl_function_ error("No such filter number: %d", i+1);2481 owl_function_makemsg("No such filter number: %d.", i+1); 2485 2482 } 2486 2483 } 2487 text = owl_string_build_quoted("filter %q", argv[1]); 2488 owl_function_punt(text, unpunt); 2489 g_free(text); 2484 const char *filter[] = {"filter", argv[1]}; 2485 owl_function_punt(2, filter, unpunt); 2490 2486 } else { 2491 owl_function_punt(skiptokens(buff, 1), unpunt); 2487 /* Pass in argv[1]..argv[argc-1]. */ 2488 owl_function_punt(argc - 1, argv + 1, unpunt); 2492 2489 } 2493 2490 } -
configure.ac
r64c829a rf97c1a6 115 115 116 116 dnl Add CFLAGS and LIBS for glib-2.0 117 PKG_CHECK_MODULES(GLIB,[glib-2.0 >= 2.12 gobject-2.0 ])117 PKG_CHECK_MODULES(GLIB,[glib-2.0 >= 2.12 gobject-2.0 gthread-2.0]) 118 118 119 119 AC_MSG_NOTICE([Adding glib-2.0 CFLAGS ${GLIB_CFLAGS}]) -
dict.c
rf25df21 r4c7c21f 15 15 #define GROWBY 3 / 2 16 16 17 intowl_dict_create(owl_dict *d) {17 void owl_dict_create(owl_dict *d) { 18 18 d->size=0; 19 19 d->els=g_new(owl_dict_el, INITSIZE); 20 20 d->avail=INITSIZE; 21 if (d->els==NULL) return(-1);22 return(0);23 21 } 24 22 … … 60 58 /* Appends dictionary keys to a list. Duplicates the keys, 61 59 * so they will need to be freed by the caller. */ 62 intowl_dict_get_keys(const owl_dict *d, owl_list *l) {60 void owl_dict_get_keys(const owl_dict *d, owl_list *l) { 63 61 int i; 64 char *dupk;65 62 for (i=0; i<d->size; i++) { 66 if ((dupk = g_strdup(d->els[i].k)) == NULL) return(-1); 67 owl_list_append_element(l, dupk); 63 owl_list_append_element(l, g_strdup(d->els[i].k)); 68 64 } 69 return(0);70 65 } 71 66 … … 84 79 { 85 80 int pos, found; 86 char *dupk;87 81 found = _owl_dict_find_pos(d, k, &pos); 88 82 if (found && delete_on_replace) { … … 99 93 if (d->els==NULL) return(-1); 100 94 } 101 if ((dupk = g_strdup(k)) == NULL) return(-1);102 95 if (pos!=d->size) { 103 96 /* shift forward to leave us a slot */ … … 106 99 } 107 100 d->size++; 108 d->els[pos].k = dupk;101 d->els[pos].k = g_strdup(k); 109 102 d->els[pos].v = v; 110 103 return(0); -
editwin.c
r47e0a6a r3b8a563 317 317 } 318 318 319 if (locktext) 320 g_free(locktext); 319 g_free(locktext); 321 320 322 321 oe_set_index(e, lock); -
filterproc.c
rd564c3d re2cc848 17 17 int err = 0; 18 18 struct pollfd fds[2]; 19 struct sigaction sig = {.sa_handler = SIG_IGN}, old;20 19 21 20 fcntl(rfd, F_SETFL, O_NONBLOCK | fcntl(rfd, F_GETFL)); … … 27 26 fds[1].events = POLLOUT; 28 27 29 sigaction(SIGPIPE, &sig, &old);30 31 28 while(1) { 32 29 if(out && *out) { … … 67 64 68 65 *in = g_string_free(str, err < 0); 69 sigaction(SIGPIPE, &old, NULL);70 66 return err; 71 67 } -
functions.c
r1081d0f r259e60a8 32 32 char *rv; 33 33 rv=owl_function_command(cmdbuff); 34 if (rv)g_free(rv);34 g_free(rv); 35 35 } 36 36 … … 453 453 454 454 if (rv || status) { 455 if(cryptmsg)g_free(cryptmsg);455 g_free(cryptmsg); 456 456 g_free(old_msg); 457 457 owl_function_error("Error in zcrypt, possibly no key found. Message not sent."); … … 991 991 /* execute the commands in shutdown */ 992 992 ret = owl_perlconfig_execute("BarnOwl::Hooks::_shutdown();"); 993 if (ret)g_free(ret);993 g_free(ret); 994 994 995 995 /* signal our child process, if any */ … … 2347 2347 done: 2348 2348 g_free(class); 2349 if (instance) { 2350 g_free(instance); 2351 } 2349 g_free(instance); 2352 2350 return(filtname); 2353 2351 } … … 2772 2770 void owl_function_zpunt(const char *class, const char *inst, const char *recip, int direction) 2773 2771 { 2774 G String *buf;2772 GPtrArray *argv; 2775 2773 char *quoted; 2776 2774 2777 buf = g_string_new("");2775 argv = g_ptr_array_new(); 2778 2776 if (!strcmp(class, "*")) { 2779 g_string_append(buf, "class .*"); 2777 g_ptr_array_add(argv, g_strdup("class")); 2778 g_ptr_array_add(argv, g_strdup(".*")); 2780 2779 } else { 2781 2780 quoted=owl_text_quote(class, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH); 2782 owl_string_appendf_quoted(buf, "class ^(un)*%q(\\.d)*$", quoted); 2781 g_ptr_array_add(argv, g_strdup("class")); 2782 g_ptr_array_add(argv, g_strdup_printf("^(un)*%s(\\.d)*$", quoted)); 2783 2783 g_free(quoted); 2784 2784 } 2785 2785 if (!strcmp(inst, "*")) { 2786 g_string_append(buf, " and instance .*"); 2786 g_ptr_array_add(argv, g_strdup("and")); 2787 g_ptr_array_add(argv, g_strdup("instance")); 2788 g_ptr_array_add(argv, g_strdup(".*")); 2787 2789 } else { 2788 2790 quoted=owl_text_quote(inst, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH); 2789 owl_string_appendf_quoted(buf, " and instance ^(un)*%q(\\.d)*$", quoted); 2791 g_ptr_array_add(argv, g_strdup("and")); 2792 g_ptr_array_add(argv, g_strdup("instance")); 2793 g_ptr_array_add(argv, g_strdup_printf("^(un)*%s(\\.d)*$", quoted)); 2790 2794 g_free(quoted); 2791 2795 } 2792 2796 if (!strcmp(recip, "*")) { 2793 /* g_string_append(buf, "");*/2797 /* nothing */ 2794 2798 } else { 2795 2799 if(!strcmp(recip, "%me%")) { … … 2797 2801 } 2798 2802 quoted=owl_text_quote(recip, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH); 2799 owl_string_appendf_quoted(buf, " and recipient ^%q$", quoted); 2803 g_ptr_array_add(argv, g_strdup("and")); 2804 g_ptr_array_add(argv, g_strdup("recipient")); 2805 g_ptr_array_add(argv, g_strdup_printf("^%s$", quoted)); 2800 2806 g_free(quoted); 2801 2807 } 2802 2808 2803 owl_function_punt(buf->str, direction); 2804 g_string_free(buf, true); 2805 } 2806 2807 void owl_function_punt(const char *filter, int direction) 2809 owl_function_punt(argv->len, (const char *const*) argv->pdata, direction); 2810 g_ptr_array_foreach(argv, (GFunc)g_free, NULL); 2811 g_ptr_array_free(argv, true); 2812 } 2813 2814 void owl_function_punt(int argc, const char *const *argv, int direction) 2808 2815 { 2809 2816 owl_filter *f; … … 2813 2820 2814 2821 /* first, create the filter */ 2815 owl_function_debugmsg("About to filter %s", filter); 2816 f = owl_filter_new_fromstring("punt-filter", filter); 2822 f = owl_filter_new("punt-filter", argc, argv); 2817 2823 if (f == NULL) { 2818 2824 owl_function_error("Error creating filter for zpunt"); … … 2841 2847 } 2842 2848 2843 owl_function_debugmsg("punting");2844 /* If we're punting, add the filter to the global punt list */2845 if (direction==0) {2849 if (direction == 0) { 2850 owl_function_debugmsg("punting"); 2851 /* If we're punting, add the filter to the global punt list */ 2846 2852 owl_list_append_element(fl, f); 2847 } 2853 } else if (direction == 1) { 2854 owl_function_makemsg("No matching punt filter"); 2855 } 2848 2856 } 2849 2857 … … 2982 2990 i--; 2983 2991 } 2984 owl_function_mask_sigint(NULL); 2985 if(owl_global_is_interrupted(&g)) { 2986 owl_global_unset_interrupted(&g); 2987 owl_function_unmask_sigint(NULL); 2992 if (owl_global_take_interrupt(&g)) { 2988 2993 owl_function_makemsg("Search interrupted!"); 2989 2994 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 2990 2995 return; 2991 2996 } 2992 owl_function_unmask_sigint(NULL);2993 2997 } 2994 2998 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); … … 3073 3077 ret=ZLocateUser(zstr(user), &numlocs, ZAUTH); 3074 3078 3075 owl_function_mask_sigint(NULL); 3076 if(owl_global_is_interrupted(&g)) { 3079 if (owl_global_take_interrupt(&g)) { 3077 3080 interrupted = 1; 3078 owl_global_unset_interrupted(&g);3079 owl_function_unmask_sigint(NULL);3080 3081 owl_function_makemsg("Interrupted!"); 3081 3082 break; 3082 3083 } 3083 3084 owl_function_unmask_sigint(NULL);3085 3084 3086 3085 if (ret!=ZERR_NONE) { … … 3243 3242 filename=owl_global_get_startupfile(&g); 3244 3243 3245 /* delete earlier copies */ 3246 owl_util_file_deleteline(filename, buff, 1); 3244 /* delete earlier copies, if the file exists */ 3245 if (g_file_test(filename, G_FILE_TEST_EXISTS)) 3246 owl_util_file_deleteline(filename, buff, 1); 3247 3247 3248 3248 file=fopen(filename, "a"); … … 3487 3487 } 3488 3488 3489 void owl_function_mask_sigint(sigset_t *oldmask) {3490 sigset_t intr;3491 3492 sigemptyset(&intr);3493 sigaddset(&intr, SIGINT);3494 sigprocmask(SIG_BLOCK, &intr, oldmask);3495 }3496 3497 void owl_function_unmask_sigint(sigset_t *oldmask) {3498 sigset_t intr;3499 3500 sigemptyset(&intr);3501 sigaddset(&intr, SIGINT);3502 sigprocmask(SIG_UNBLOCK, &intr, oldmask);3503 }3504 3505 3489 void _owl_function_mark_message(const owl_message *m) 3506 3490 { -
global.c
r7b4f3be rf97c1a6 16 16 17 17 g_type_init(); 18 g_thread_init(NULL); 19 20 owl_select_init(); 18 21 19 22 g->lines=LINES; … … 95 98 96 99 owl_errqueue_init(&(g->errqueue)); 97 g->got_err_signal=0;98 100 99 101 owl_zbuddylist_create(&(g->zbuddies)); … … 104 106 owl_message_init_fmtext_cache(); 105 107 owl_list_create(&(g->io_dispatch_list)); 106 owl_list_create(&(g->psa_list));107 108 g->timerlist = NULL; 108 g->interrupted = FALSE;109 109 g->kill_buffer = NULL; 110 111 g->interrupt_count = 0; 112 g->interrupt_lock = g_mutex_new(); 110 113 } 111 114 … … 344 347 345 348 void owl_global_set_resize_pending(owl_global *g) { 346 g->resizepending =1;349 g->resizepending = true; 347 350 } 348 351 … … 444 447 /* resize the screen. If lines or cols is 0 use the terminal size */ 445 448 if (!g->resizepending) return; 446 g->resizepending = 0;449 g->resizepending = false; 447 450 448 451 owl_global_get_terminal_size(&g->lines, &g->cols); … … 505 508 506 509 void owl_global_set_startupargs(owl_global *g, int argc, char **argv) { 507 if (g->startupargs)g_free(g->startupargs);510 g_free(g->startupargs); 508 511 g->startupargs = g_strjoinv(" ", argv); 509 512 } … … 676 679 } 677 680 678 int owl_global_is_doaimevents(const owl_global *g) 679 { 680 if (g->aim_doprocessing) return(1); 681 return(0); 681 bool owl_global_is_doaimevents(const owl_global *g) 682 { 683 return g->aim_event_source != NULL; 682 684 } 683 685 684 686 void owl_global_set_doaimevents(owl_global *g) 685 687 { 686 g->aim_doprocessing=1; 688 if (g->aim_event_source) 689 return; 690 g->aim_event_source = owl_aim_event_source_new(owl_global_get_aimsess(g)); 691 g_source_attach(g->aim_event_source, NULL); 687 692 } 688 693 689 694 void owl_global_set_no_doaimevents(owl_global *g) 690 695 { 691 g->aim_doprocessing=0; 696 if (!g->aim_event_source) 697 return; 698 g_source_destroy(g->aim_event_source); 699 g_source_unref(g->aim_event_source); 700 g->aim_event_source = NULL; 692 701 } 693 702 … … 747 756 } 748 757 749 intowl_global_get_style_names(const owl_global *g, owl_list *l) {750 returnowl_dict_get_keys(&(g->styledict), l);758 void owl_global_get_style_names(const owl_global *g, owl_list *l) { 759 owl_dict_get_keys(&(g->styledict), l); 751 760 } 752 761 … … 807 816 } 808 817 809 void owl_global_set_errsignal(owl_global *g, int signum, siginfo_t *siginfo)810 {811 g->got_err_signal = signum;812 if (siginfo) {813 g->err_signal_info = *siginfo;814 } else {815 siginfo_t si;816 memset(&si, 0, sizeof(si));817 g->err_signal_info = si;818 }819 }820 821 int owl_global_get_errsignal_and_clear(owl_global *g, siginfo_t *siginfo)822 {823 int signum;824 if (siginfo && g->got_err_signal) {825 *siginfo = g->err_signal_info;826 }827 signum = g->got_err_signal;828 g->got_err_signal = 0;829 return signum;830 }831 832 833 818 owl_zbuddylist *owl_global_get_zephyr_buddylist(owl_global *g) 834 819 { … … 861 846 } 862 847 863 owl_list *owl_global_get_psa_list(owl_global *g)864 {865 return &(g->psa_list);866 }867 868 848 GList **owl_global_get_timerlist(owl_global *g) 869 849 { 870 850 return &(g->timerlist); 871 }872 873 int owl_global_is_interrupted(const owl_global *g) {874 return g->interrupted;875 }876 877 void owl_global_set_interrupted(owl_global *g) {878 g->interrupted = 1;879 }880 881 void owl_global_unset_interrupted(owl_global *g) {882 g->interrupted = 0;883 851 } 884 852 … … 948 916 g->kill_buffer = g_strndup(kill, len); 949 917 } 918 919 void owl_global_add_interrupt(owl_global *g) { 920 /* TODO: This can almost certainly be done with atomic 921 * operations. Whatever. */ 922 g_mutex_lock(g->interrupt_lock); 923 g->interrupt_count++; 924 g_mutex_unlock(g->interrupt_lock); 925 } 926 927 bool owl_global_take_interrupt(owl_global *g) { 928 bool ans = false; 929 g_mutex_lock(g->interrupt_lock); 930 if (g->interrupt_count > 0) { 931 ans = true; 932 g->interrupt_count--; 933 } 934 g_mutex_unlock(g->interrupt_lock); 935 return ans; 936 } -
keybinding.c
rd07af84 r3b8a563 69 69 void owl_keybinding_delete(owl_keybinding *kb) 70 70 { 71 if (kb->keys)g_free(kb->keys);72 if (kb->desc)g_free(kb->desc);73 if (kb->command)g_free(kb->command);71 g_free(kb->keys); 72 g_free(kb->desc); 73 g_free(kb->command); 74 74 g_free(kb); 75 75 } -
keymap.c
r47e0a6a r4c7c21f 9 9 { 10 10 if (!name || !desc) return(-1); 11 if ((km->name = g_strdup(name)) == NULL) return(-1);12 if ((km->desc = g_strdup(desc)) == NULL) return(-1);13 if (0 != owl_list_create(&km->bindings)) return(-1);11 km->name = g_strdup(name); 12 km->desc = g_strdup(desc); 13 owl_list_create(&km->bindings); 14 14 km->parent = NULL; 15 15 km->default_fn = default_fn; … … 179 179 /* NOTE: keyhandler has private access to the internals of keymap */ 180 180 181 intowl_keyhandler_init(owl_keyhandler *kh)182 { 183 if (0 != owl_dict_create(&kh->keymaps)) return(-1);181 void owl_keyhandler_init(owl_keyhandler *kh) 182 { 183 owl_dict_create(&kh->keymaps); 184 184 kh->active = NULL; 185 185 owl_keyhandler_reset(kh); 186 return(0);187 186 } 188 187 -
list.c
rddbbcffa rfda61d3 5 5 #define GROWBY 3 / 2 6 6 7 intowl_list_create(owl_list *l)7 void owl_list_create(owl_list *l) 8 8 { 9 9 l->size=0; 10 10 l->list=g_new(void *, INITSIZE); 11 11 l->avail=INITSIZE; 12 if (l->list==NULL) return(-1);13 return(0);14 12 } 15 13 -
owl.c
r9efa5bd r6476c0e 160 160 * was ignored due to user settings or otherwise. 161 161 */ 162 int owl_process_message(owl_message *m) {162 static int owl_process_message(owl_message *m) { 163 163 const owl_filter *f; 164 164 /* if this message it on the puntlist, nuke it and continue */ … … 245 245 } 246 246 247 static gboolean owl_process_messages_prepare(GSource *source, int *timeout) { 248 *timeout = -1; 249 return owl_global_messagequeue_pending(&g); 250 } 251 252 static gboolean owl_process_messages_check(GSource *source) { 253 return owl_global_messagequeue_pending(&g); 254 } 255 247 256 /* 248 257 * Process any new messages we have waiting in the message queue. 249 * Returns 1 if any messages were added to the message list, and 0 otherwise.250 258 */ 251 int owl_process_messages(owl_ps_action *d, void *p) 252 { 259 static gboolean owl_process_messages_dispatch(GSource *source, GSourceFunc callback, gpointer user_data) { 253 260 int newmsgs=0; 254 261 int followlast = owl_global_should_followlast(&g); … … 274 281 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 275 282 } 276 return newmsgs; 283 return TRUE; 284 } 285 286 static GSourceFuncs owl_process_messages_funcs = { 287 owl_process_messages_prepare, 288 owl_process_messages_check, 289 owl_process_messages_dispatch, 290 NULL 291 }; 292 293 void owl_process_input_char(owl_input j) 294 { 295 int ret; 296 297 owl_global_set_lastinputtime(&g, time(NULL)); 298 ret = owl_keyhandler_process(owl_global_get_keyhandler(&g), j); 299 if (ret!=0 && ret!=1) { 300 owl_function_makemsg("Unable to handle keypress"); 301 } 277 302 } 278 303 … … 334 359 } 335 360 336 void sig_handler(int sig, siginfo_t *si, void *data) 337 { 338 if (sig==SIGWINCH) { 339 /* we can't inturrupt a malloc here, so it just sets a flag 340 * schedulding a resize for later 341 */ 361 static void sig_handler_main_thread(void *data) { 362 int sig = GPOINTER_TO_INT(data); 363 364 owl_function_debugmsg("Got signal %d", sig); 365 if (sig == SIGWINCH) { 342 366 owl_function_resize(); 343 } else if (sig==SIGPIPE || sig==SIGCHLD) { 344 /* Set a flag and some info that we got the sigpipe 345 * so we can record that we got it and why... */ 346 owl_global_set_errsignal(&g, sig, si); 347 } else if (sig==SIGTERM || sig==SIGHUP) { 367 } else if (sig == SIGTERM || sig == SIGHUP) { 348 368 owl_function_quit(); 349 } 350 } 351 352 void sigint_handler(int sig, siginfo_t *si, void *data) 353 { 354 owl_global_set_interrupted(&g); 355 } 356 357 static int owl_errsignal_pre_select_action(owl_ps_action *a, void *data) 358 { 359 siginfo_t si; 360 int signum; 361 if ((signum = owl_global_get_errsignal_and_clear(&g, &si)) > 0) { 362 owl_function_error("Got unexpected signal: %d %s (code: %d band: %ld errno: %d)", 363 signum, signum==SIGPIPE?"SIGPIPE":"SIG????", 364 si.si_code, si.si_band, si.si_errno); 365 } 366 return 0; 367 } 369 } else if (sig == SIGINT && owl_global_take_interrupt(&g)) { 370 owl_input in; 371 in.ch = in.uch = owl_global_get_startup_tio(&g)->c_cc[VINTR]; 372 owl_process_input_char(in); 373 } 374 } 375 376 static void sig_handler(const siginfo_t *siginfo, void *data) { 377 /* If it was an interrupt, set a flag so we can handle it earlier if 378 * needbe. sig_handler_main_thread will check the flag to make sure 379 * no one else took it. */ 380 if (siginfo->si_signo == SIGINT) { 381 owl_global_add_interrupt(&g); 382 } 383 /* Send a message to the main thread. */ 384 owl_select_post_task(sig_handler_main_thread, 385 GINT_TO_POINTER(siginfo->si_signo), NULL); 386 } 387 388 #define CHECK_RESULT(s, syscall) \ 389 G_STMT_START { \ 390 if ((syscall) != 0) { \ 391 perror((s)); \ 392 exit(1); \ 393 } \ 394 } G_STMT_END 368 395 369 396 void owl_register_signal_handlers(void) { 370 struct sigaction sigact; 371 372 /* signal handler */ 373 /*sigact.sa_handler=sig_handler;*/ 374 sigact.sa_sigaction=sig_handler; 375 sigemptyset(&sigact.sa_mask); 376 sigact.sa_flags=SA_SIGINFO; 377 sigaction(SIGWINCH, &sigact, NULL); 378 sigaction(SIGALRM, &sigact, NULL); 379 sigaction(SIGPIPE, &sigact, NULL); 380 sigaction(SIGTERM, &sigact, NULL); 381 sigaction(SIGHUP, &sigact, NULL); 382 383 sigact.sa_sigaction=sigint_handler; 384 sigaction(SIGINT, &sigact, NULL); 397 struct sigaction sig_ignore = { .sa_handler = SIG_IGN }; 398 struct sigaction sig_default = { .sa_handler = SIG_DFL }; 399 sigset_t sigset; 400 int ret, i; 401 const int signals[] = { SIGABRT, SIGBUS, SIGCHLD, SIGFPE, SIGHUP, SIGILL, 402 SIGINT, SIGQUIT, SIGSEGV, SIGTERM, SIGWINCH }; 403 404 /* Sanitize our signals; the mask and dispositions from our parent 405 * aren't really useful. Signal list taken from equivalent code in 406 * Chromium. */ 407 CHECK_RESULT("sigemptyset", sigemptyset(&sigset)); 408 if ((ret = pthread_sigmask(SIG_SETMASK, &sigset, NULL)) != 0) { 409 errno = ret; 410 perror("pthread_sigmask"); 411 } 412 for (i = 0; i < G_N_ELEMENTS(signals); i++) { 413 CHECK_RESULT("sigaction", sigaction(signals[i], &sig_default, NULL)); 414 } 415 416 /* Turn off SIGPIPE; we check the return value of write. */ 417 CHECK_RESULT("sigaction", sigaction(SIGPIPE, &sig_ignore, NULL)); 418 419 /* Register some signals with the signal thread. */ 420 CHECK_RESULT("sigaddset", sigaddset(&sigset, SIGWINCH)); 421 CHECK_RESULT("sigaddset", sigaddset(&sigset, SIGTERM)); 422 CHECK_RESULT("sigaddset", sigaddset(&sigset, SIGHUP)); 423 CHECK_RESULT("sigaddset", sigaddset(&sigset, SIGINT)); 424 owl_signal_init(&sigset, sig_handler, NULL); 385 425 } 386 426 … … 424 464 } 425 465 bread = read(rfd, buf, navail); 426 if (buf[navail-1] != '\0') { 427 buf[navail] = '\0'; 428 } 429 430 err = g_strdup_printf("[stderr]\n%s", buf); 466 if (bread == -1) 467 return; 468 469 err = g_strdup_printf("[stderr]\n%.*s", bread, buf); 431 470 432 471 owl_function_log_err(err); … … 435 474 436 475 #endif /* OWL_STDERR_REDIR */ 437 438 static int owl_refresh_pre_select_action(owl_ps_action *a, void *data)439 {440 owl_colorpair_mgr *cpmgr;441 442 /* if a resize has been scheduled, deal with it */443 owl_global_check_resize(&g);444 /* update the terminal if we need to */445 owl_window_redraw_scheduled();446 /* On colorpair shortage, reset and redraw /everything/. NOTE: if we447 * still overflow, this be useless work. With 8-colors, we get 64448 * pairs. With 256-colors, we get 32768 pairs with ext-colors449 * support and 256 otherwise. */450 cpmgr = owl_global_get_colorpair_mgr(&g);451 if (cpmgr->overflow) {452 owl_function_debugmsg("colorpairs: used all %d pairs; reset pairs and redraw.",453 owl_util_get_colorpairs());454 owl_fmtext_reset_colorpairs(cpmgr);455 owl_function_full_redisplay();456 owl_window_redraw_scheduled();457 }458 return 0;459 }460 461 476 462 477 int main(int argc, char **argv, char **env) … … 468 483 const char *dir; 469 484 owl_options opts; 485 GSource *source; 470 486 471 487 if (!GLIB_CHECK_VERSION (2, 12, 0)) … … 482 498 g.load_initial_subs = opts.load_initial_subs; 483 499 484 owl_register_signal_handlers();485 500 owl_start_curses(); 486 501 … … 494 509 owl_global_set_haveaim(&g); 495 510 511 owl_register_signal_handlers(); 512 496 513 /* register STDIN dispatch; throw away return, we won't need it */ 497 514 owl_select_add_io_dispatch(STDIN_FILENO, OWL_IO_READ, &owl_process_input, NULL, NULL); … … 552 569 owl_function_debugmsg("startup: executing perl startup, if applicable"); 553 570 perlout = owl_perlconfig_execute("BarnOwl::Hooks::_startup();"); 554 if (perlout)g_free(perlout);571 g_free(perlout); 555 572 556 573 /* welcome message */ … … 585 602 owl_global_push_context(&g, OWL_CTX_INTERACTIVE|OWL_CTX_RECV, NULL, "recv", NULL); 586 603 587 owl_select_add_pre_select_action(owl_refresh_pre_select_action, NULL, NULL); 588 owl_select_add_pre_select_action(owl_process_messages, NULL, NULL); 589 owl_select_add_pre_select_action(owl_errsignal_pre_select_action, NULL, NULL); 604 source = owl_window_redraw_source_new(); 605 g_source_attach(source, NULL); 606 g_source_unref(source); 607 608 source = g_source_new(&owl_process_messages_funcs, sizeof(GSource)); 609 g_source_attach(source, NULL); 610 g_source_unref(source); 590 611 591 612 owl_function_debugmsg("startup: entering main loop"); … … 594 615 /* Shut down everything. */ 595 616 owl_zephyr_shutdown(); 617 owl_signal_shutdown(); 596 618 owl_shutdown_curses(); 597 619 return 0; -
owl.h
rede073c r33b6431b 548 548 int fd; /* FD to watch for dispatch. */ 549 549 int mode; 550 bool valid; 550 551 int needs_gc; 551 552 void (*callback)(const struct _owl_io_dispatch *, void *); /* C function to dispatch to. */ 552 553 void (*destroy)(const struct _owl_io_dispatch *); /* Destructor */ 553 554 void *data; 555 GPollFD pollfd; 554 556 } owl_io_dispatch; 555 556 typedef struct _owl_ps_action {557 int needs_gc;558 int (*callback)(struct _owl_ps_action *, void *);559 void (*destroy)(struct _owl_ps_action *);560 void *data;561 } owl_ps_action;562 557 563 558 typedef struct _owl_popexec { … … 568 563 const owl_io_dispatch *dispatch; 569 564 } owl_popexec; 570 571 typedef struct _OwlGlobalNotifier OwlGlobalNotifier;572 565 573 566 typedef struct _owl_global { … … 595 588 gulong typwin_erase_id; 596 589 int rightshift; 597 volatile sig_atomic_tresizepending;590 bool resizepending; 598 591 char *homedir; 599 592 char *confdir; … … 618 611 aim_conn_t bosconn; 619 612 int aim_loggedin; /* true if currently logged into AIM */ 620 int aim_doprocessing; /* true if we should process AIM events (like pending login)*/613 GSource *aim_event_source; /* where we get our AIM events from */ 621 614 char *aim_screenname; /* currently logged in AIM screen name */ 622 615 char *aim_screenname_for_filters; /* currently logged in AIM screen name */ … … 628 621 int haveaim; 629 622 int ignoreaimlogin; 630 volatile sig_atomic_t got_err_signal; /* 1 if we got an unexpected signal */631 volatile siginfo_t err_signal_info;632 623 owl_zbuddylist zbuddies; 633 624 GList *zaldlist; … … 635 626 struct termios startup_tio; 636 627 owl_list io_dispatch_list; 637 owl_list psa_list;638 628 GList *timerlist; 639 629 owl_timer *aim_nop_timer; 640 630 int load_initial_subs; 641 volatile sig_atomic_t interrupted;642 631 FILE *debug_file; 643 632 char *kill_buffer; 633 int interrupt_count; 634 GMutex *interrupt_lock; 644 635 } owl_global; 645 636 -
perlconfig.c
rf2d71cfa r3b8a563 467 467 :"BarnOwl::_receive_msg_legacy_wrap", m); 468 468 } 469 if (ptr)g_free(ptr);469 g_free(ptr); 470 470 } 471 471 … … 478 478 :"BarnOwl::Hooks::_new_msg", m); 479 479 } 480 if (ptr)g_free(ptr);480 g_free(ptr); 481 481 } 482 482 -
perlglue.xs
r6a71113 r3b8a563 57 57 RETVAL 58 58 CLEANUP: 59 if (rv)g_free(rv);59 g_free(rv); 60 60 61 61 SV * … … 114 114 RETVAL 115 115 CLEANUP: 116 if (rv)g_free(rv);116 g_free(rv); 117 117 118 118 const utf8 * … … 141 141 RETVAL 142 142 CLEANUP: 143 if (rv)g_free(rv);143 g_free(rv); 144 144 145 145 void … … 324 324 RETVAL 325 325 CLEANUP: 326 if (rv) 327 g_free(rv); 326 g_free(rv); 328 327 329 328 void -
select.c
rfb96152 r33b6431b 1 1 #include "owl.h" 2 #include <sys/stat.h> 3 2 3 static GMainLoop *loop = NULL; 4 static GMainContext *context; 4 5 static int dispatch_active = 0; 5 static int psa_active = 0; 6 static int loop_active = 0; 7 8 int _owl_select_timer_cmp(const owl_timer *t1, const owl_timer *t2) { 6 7 static GSource *owl_timer_source; 8 static GSource *owl_io_dispatch_source; 9 10 static int _owl_select_timer_cmp(const owl_timer *t1, const owl_timer *t2) { 9 11 return t1->time - t2->time; 10 }11 12 int _owl_select_timer_eq(const owl_timer *t1, const owl_timer *t2) {13 return t1 == t2;14 12 } 15 13 … … 44 42 } 45 43 46 void owl_select_process_timers(struct timespec *timeout) 47 { 48 time_t now = time(NULL); 49 GList **timers = owl_global_get_timerlist(&g); 50 44 static gboolean owl_timer_prepare(GSource *source, int *timeout) { 45 GList **timers = owl_global_get_timerlist(&g); 46 GTimeVal now; 47 48 /* TODO: In the far /far/ future, g_source_get_time is what the cool 49 * kids use to get system monotonic time. */ 50 g_source_get_current_time(source, &now); 51 52 /* FIXME: bother with millisecond accuracy now that we can? */ 53 if (*timers) { 54 owl_timer *t = (*timers)->data; 55 *timeout = t->time - now.tv_sec; 56 if (*timeout <= 0) { 57 *timeout = 0; 58 return TRUE; 59 } 60 if (*timeout > 60 * 1000) 61 *timeout = 60 * 1000; 62 } else { 63 *timeout = 60 * 1000; 64 } 65 return FALSE; 66 } 67 68 static gboolean owl_timer_check(GSource *source) { 69 GList **timers = owl_global_get_timerlist(&g); 70 GTimeVal now; 71 72 /* TODO: In the far /far/ future, g_source_get_time is what the cool 73 * kids use to get system monotonic time. */ 74 g_source_get_current_time(source, &now); 75 76 /* FIXME: bother with millisecond accuracy now that we can? */ 77 if (*timers) { 78 owl_timer *t = (*timers)->data; 79 return t->time >= now.tv_sec; 80 } 81 return FALSE; 82 } 83 84 85 static gboolean owl_timer_dispatch(GSource *source, GSourceFunc callback, gpointer user_data) { 86 GList **timers = owl_global_get_timerlist(&g); 87 GTimeVal now; 88 89 /* TODO: In the far /far/ future, g_source_get_time is what the cool 90 * kids use to get system monotonic time. */ 91 g_source_get_current_time(source, &now); 92 93 /* FIXME: bother with millisecond accuracy now that we can? */ 51 94 while(*timers) { 52 95 owl_timer *t = (*timers)->data; 53 96 int remove = 0; 54 97 55 if(t->time > now )98 if(t->time > now.tv_sec) 56 99 break; 57 100 58 101 /* Reschedule if appropriate */ 59 102 if(t->interval > 0) { 60 t->time = now + t->interval;103 t->time = now.tv_sec + t->interval; 61 104 *timers = g_list_remove(*timers, t); 62 105 *timers = g_list_insert_sorted(*timers, t, … … 72 115 } 73 116 } 74 75 if(*timers) { 76 owl_timer *t = (*timers)->data; 77 timeout->tv_sec = t->time - now; 78 if (timeout->tv_sec > 60) 79 timeout->tv_sec = 60; 80 } else { 81 timeout->tv_sec = 60; 82 } 83 84 timeout->tv_nsec = 0; 85 } 86 87 static const owl_io_dispatch *owl_select_find_io_dispatch_by_fd(const int fd) 117 return TRUE; 118 } 119 120 static GSourceFuncs owl_timer_funcs = { 121 owl_timer_prepare, 122 owl_timer_check, 123 owl_timer_dispatch, 124 NULL 125 }; 126 127 /* Returns the valid owl_io_dispatch for a given file descriptor. */ 128 static owl_io_dispatch *owl_select_find_valid_io_dispatch_by_fd(const int fd) 88 129 { 89 130 int i, len; … … 94 135 for(i = 0; i < len; i++) { 95 136 d = owl_list_get_element(dl, i); 96 if (d->fd == fd ) return d;137 if (d->fd == fd && d->valid) return d; 97 138 } 98 139 return NULL; … … 113 154 } 114 155 return -1; 156 } 157 158 static void owl_select_invalidate_io_dispatch(owl_io_dispatch *d) 159 { 160 if (d == NULL || !d->valid) 161 return; 162 d->valid = false; 163 g_source_remove_poll(owl_io_dispatch_source, &d->pollfd); 115 164 } 116 165 … … 126 175 d->needs_gc = 1; 127 176 else { 177 owl_select_invalidate_io_dispatch(d); 128 178 owl_list_remove_element(dl, elt); 129 179 if (d->destroy) … … 135 185 } 136 186 137 void owl_select_io_dispatch_gc(void)187 static void owl_select_io_dispatch_gc(void) 138 188 { 139 189 int i; … … 153 203 } 154 204 155 /* Each FD may have at most one dispatcher.205 /* Each FD may have at most one valid dispatcher. 156 206 * If a new dispatch is added for an FD, the old one is removed. 157 207 * mode determines what types of events are watched for, and may be any combination of: … … 162 212 owl_io_dispatch *d = g_new(owl_io_dispatch, 1); 163 213 owl_list *dl = owl_global_get_io_dispatch_list(&g); 214 owl_io_dispatch *other; 164 215 165 216 d->fd = fd; 217 d->valid = true; 166 218 d->needs_gc = 0; 167 219 d->mode = mode; … … 170 222 d->data = data; 171 223 172 owl_select_remove_io_dispatch(owl_select_find_io_dispatch_by_fd(fd)); 224 /* TODO: Allow changing fd and mode in the middle? Probably don't care... */ 225 d->pollfd.fd = fd; 226 d->pollfd.events = 0; 227 if (d->mode & OWL_IO_READ) 228 d->pollfd.events |= G_IO_IN | G_IO_HUP | G_IO_ERR; 229 if (d->mode & OWL_IO_WRITE) 230 d->pollfd.events |= G_IO_OUT | G_IO_ERR; 231 if (d->mode & OWL_IO_EXCEPT) 232 d->pollfd.events |= G_IO_PRI | G_IO_ERR; 233 g_source_add_poll(owl_io_dispatch_source, &d->pollfd); 234 235 236 other = owl_select_find_valid_io_dispatch_by_fd(fd); 237 if (other) 238 owl_select_invalidate_io_dispatch(other); 173 239 owl_list_append_element(dl, d); 174 240 … … 176 242 } 177 243 178 int owl_select_prepare_io_dispatch_fd_sets(fd_set *rfds, fd_set *wfds, fd_set *efds) { 179 int i, len, max_fd; 180 owl_io_dispatch *d; 181 owl_list *dl = owl_global_get_io_dispatch_list(&g); 182 183 max_fd = 0; 244 static gboolean owl_io_dispatch_prepare(GSource *source, int *timeout) { 245 *timeout = -1; 246 return FALSE; 247 } 248 249 static gboolean owl_io_dispatch_check(GSource *source) { 250 int i, len; 251 const owl_list *dl; 252 253 dl = owl_global_get_io_dispatch_list(&g); 254 len = owl_list_get_size(dl); 255 for(i = 0; i < len; i++) { 256 owl_io_dispatch *d = owl_list_get_element(dl, i); 257 if (!d->valid) continue; 258 if (d->pollfd.revents & G_IO_NVAL) { 259 owl_function_debugmsg("Pruning defunct dispatch on fd %d.", d->fd); 260 owl_select_invalidate_io_dispatch(d); 261 } 262 if (d->pollfd.revents & d->pollfd.events) 263 return TRUE; 264 } 265 return FALSE; 266 } 267 268 static gboolean owl_io_dispatch_dispatch(GSource *source, GSourceFunc callback, gpointer user_data) { 269 int i, len; 270 const owl_list *dl; 271 272 dispatch_active = 1; 273 dl = owl_global_get_io_dispatch_list(&g); 184 274 len = owl_list_get_size(dl); 185 275 for (i = 0; i < len; i++) { 186 d = owl_list_get_element(dl, i); 187 if (d->mode & (OWL_IO_READ | OWL_IO_WRITE | OWL_IO_EXCEPT)) { 188 if (max_fd < d->fd) max_fd = d->fd; 189 if (d->mode & OWL_IO_READ) FD_SET(d->fd, rfds); 190 if (d->mode & OWL_IO_WRITE) FD_SET(d->fd, wfds); 191 if (d->mode & OWL_IO_EXCEPT) FD_SET(d->fd, efds); 192 } 193 } 194 return max_fd + 1; 195 } 196 197 void owl_select_io_dispatch(const fd_set *rfds, const fd_set *wfds, const fd_set *efds, const int max_fd) 198 { 199 int i, len; 200 owl_io_dispatch *d; 201 owl_list *dl = owl_global_get_io_dispatch_list(&g); 202 203 dispatch_active = 1; 204 len = owl_list_get_size(dl); 205 for (i = 0; i < len; i++) { 206 d = owl_list_get_element(dl, i); 207 if (d->fd < max_fd && d->callback != NULL && 208 ((d->mode & OWL_IO_READ && FD_ISSET(d->fd, rfds)) || 209 (d->mode & OWL_IO_WRITE && FD_ISSET(d->fd, wfds)) || 210 (d->mode & OWL_IO_EXCEPT && FD_ISSET(d->fd, efds)))) { 276 owl_io_dispatch *d = owl_list_get_element(dl, i); 277 if (!d->valid) continue; 278 if ((d->pollfd.revents & d->pollfd.events) && d->callback != NULL) { 211 279 d->callback(d, d->data); 212 280 } … … 214 282 dispatch_active = 0; 215 283 owl_select_io_dispatch_gc(); 216 } 284 285 return TRUE; 286 } 287 288 static GSourceFuncs owl_io_dispatch_funcs = { 289 owl_io_dispatch_prepare, 290 owl_io_dispatch_check, 291 owl_io_dispatch_dispatch, 292 NULL 293 }; 217 294 218 295 int owl_select_add_perl_io_dispatch(int fd, int mode, SV *cb) 219 296 { 220 const owl_io_dispatch *d = owl_select_find_ io_dispatch_by_fd(fd);297 const owl_io_dispatch *d = owl_select_find_valid_io_dispatch_by_fd(fd); 221 298 if (d != NULL && d->callback != owl_perlconfig_io_dispatch) { 222 299 /* Don't mess with non-perl dispatch functions from here. */ 223 300 return 1; 224 301 } 302 /* Also remove any invalidated perl dispatch functions that may have 303 * stuck around. */ 304 owl_select_remove_perl_io_dispatch(fd); 225 305 owl_select_add_io_dispatch(fd, mode, owl_perlconfig_io_dispatch, owl_perlconfig_io_dispatch_destroy, cb); 226 306 return 0; 227 307 } 228 308 309 static owl_io_dispatch *owl_select_find_perl_io_dispatch(int fd) 310 { 311 int i, len; 312 const owl_list *dl; 313 owl_io_dispatch *d; 314 dl = owl_global_get_io_dispatch_list(&g); 315 len = owl_list_get_size(dl); 316 for(i = 0; i < len; i++) { 317 d = owl_list_get_element(dl, i); 318 if (d->fd == fd && d->callback == owl_perlconfig_io_dispatch) 319 return d; 320 } 321 return NULL; 322 } 323 229 324 int owl_select_remove_perl_io_dispatch(int fd) 230 325 { 231 const owl_io_dispatch *d = owl_select_find_io_dispatch_by_fd(fd);232 if (d != NULL && d->callback == owl_perlconfig_io_dispatch) {326 owl_io_dispatch *d = owl_select_find_perl_io_dispatch(fd); 327 if (d != NULL) { 233 328 /* Only remove perl io dispatchers from here. */ 234 329 owl_select_remove_io_dispatch(d); … … 238 333 } 239 334 240 int owl_select_aim_hack(fd_set *rfds, fd_set *wfds) 241 { 242 aim_conn_t *cur; 243 aim_session_t *sess; 244 int max_fd; 245 246 max_fd = 0; 247 sess = owl_global_get_aimsess(&g); 248 for (cur = sess->connlist; cur; cur = cur->next) { 249 if (cur->fd != -1) { 250 FD_SET(cur->fd, rfds); 251 if (cur->status & AIM_CONN_STATUS_INPROGRESS) { 252 /* Yes, we're checking writable sockets here. Without it, AIM 253 login is really slow. */ 254 FD_SET(cur->fd, wfds); 255 } 256 257 if (cur->fd > max_fd) 258 max_fd = cur->fd; 259 } 260 } 261 return max_fd; 262 } 263 264 void owl_process_input_char(owl_input j) 265 { 266 int ret; 267 268 owl_global_set_lastinputtime(&g, time(NULL)); 269 ret = owl_keyhandler_process(owl_global_get_keyhandler(&g), j); 270 if (ret!=0 && ret!=1) { 271 owl_function_makemsg("Unable to handle keypress"); 272 } 273 } 274 275 void owl_select_mask_signals(sigset_t *oldmask) { 276 sigset_t set; 277 278 sigemptyset(&set); 279 sigaddset(&set, SIGWINCH); 280 sigaddset(&set, SIGALRM); 281 sigaddset(&set, SIGPIPE); 282 sigaddset(&set, SIGTERM); 283 sigaddset(&set, SIGHUP); 284 sigaddset(&set, SIGINT); 285 sigprocmask(SIG_BLOCK, &set, oldmask); 286 } 287 288 void owl_select_handle_intr(sigset_t *restore) 289 { 290 owl_input in; 291 292 owl_global_unset_interrupted(&g); 293 294 sigprocmask(SIG_SETMASK, restore, NULL); 295 296 in.ch = in.uch = owl_global_get_startup_tio(&g)->c_cc[VINTR]; 297 owl_process_input_char(in); 298 } 299 300 owl_ps_action *owl_select_add_pre_select_action(int (*cb)(owl_ps_action *, void *), void (*destroy)(owl_ps_action *), void *data) 301 { 302 owl_ps_action *a = g_new(owl_ps_action, 1); 303 owl_list *psa_list = owl_global_get_psa_list(&g); 304 a->needs_gc = 0; 305 a->callback = cb; 306 a->destroy = destroy; 307 a->data = data; 308 owl_list_append_element(psa_list, a); 309 return a; 310 } 311 312 void owl_select_psa_gc(void) 313 { 314 int i; 315 owl_list *psa_list; 316 owl_ps_action *a; 317 318 psa_list = owl_global_get_psa_list(&g); 319 for (i = owl_list_get_size(psa_list) - 1; i >= 0; i--) { 320 a = owl_list_get_element(psa_list, i); 321 if (a->needs_gc) { 322 owl_list_remove_element(psa_list, i); 323 if (a->destroy) { 324 a->destroy(a); 325 } 326 g_free(a); 327 } 328 } 329 } 330 331 void owl_select_remove_pre_select_action(owl_ps_action *a) 332 { 333 a->needs_gc = 1; 334 if (!psa_active) 335 owl_select_psa_gc(); 336 } 337 338 int owl_select_do_pre_select_actions(void) 339 { 340 int i, len, ret; 341 owl_list *psa_list; 342 343 psa_active = 1; 344 ret = 0; 345 psa_list = owl_global_get_psa_list(&g); 346 len = owl_list_get_size(psa_list); 347 for (i = 0; i < len; i++) { 348 owl_ps_action *a = owl_list_get_element(psa_list, i); 349 if (a->callback != NULL && a->callback(a, a->data)) { 350 ret = 1; 351 } 352 } 353 psa_active = 0; 354 owl_select_psa_gc(); 355 return ret; 356 } 357 358 static void owl_select_prune_bad_fds(void) { 359 owl_list *dl = owl_global_get_io_dispatch_list(&g); 360 int len, i; 361 struct stat st; 362 owl_io_dispatch *d; 363 364 len = owl_list_get_size(dl); 365 for (i = 0; i < len; i++) { 366 d = owl_list_get_element(dl, i); 367 if (fstat(d->fd, &st) < 0 && errno == EBADF) { 368 owl_function_debugmsg("Pruning defunct dispatch on fd %d.", d->fd); 369 d->needs_gc = 1; 370 } 371 } 372 owl_select_io_dispatch_gc(); 373 } 374 375 void owl_select(void) 376 { 377 int i, max_fd, max_fd2, aim_done, ret; 378 fd_set r; 379 fd_set w; 380 fd_set e; 381 fd_set aim_rfds, aim_wfds; 382 struct timespec timeout; 383 sigset_t mask; 384 385 owl_select_process_timers(&timeout); 386 387 owl_select_mask_signals(&mask); 388 389 if(owl_global_is_interrupted(&g)) { 390 owl_select_handle_intr(&mask); 391 return; 392 } 393 FD_ZERO(&r); 394 FD_ZERO(&w); 395 FD_ZERO(&e); 396 397 max_fd = owl_select_prepare_io_dispatch_fd_sets(&r, &w, &e); 398 399 /* AIM HACK: 400 * 401 * The problem - I'm not sure where to hook into the owl/faim 402 * interface to keep track of when the AIM socket(s) open and 403 * close. In particular, the bosconn thing throws me off. So, 404 * rather than register particular dispatchers for AIM, I look up 405 * the relevant FDs and add them to select's watch lists, then 406 * check for them individually before moving on to the other 407 * dispatchers. --asedeno 408 */ 409 aim_done = 1; 410 FD_ZERO(&aim_rfds); 411 FD_ZERO(&aim_wfds); 412 if (owl_global_is_doaimevents(&g)) { 413 aim_done = 0; 414 max_fd2 = owl_select_aim_hack(&aim_rfds, &aim_wfds); 415 if (max_fd < max_fd2) max_fd = max_fd2; 416 for(i = 0; i <= max_fd2; i++) { 417 if (FD_ISSET(i, &aim_rfds)) { 418 FD_SET(i, &r); 419 FD_SET(i, &e); 420 } 421 if (FD_ISSET(i, &aim_wfds)) { 422 FD_SET(i, &w); 423 FD_SET(i, &e); 424 } 425 } 426 } 427 /* END AIM HACK */ 428 429 if (owl_select_do_pre_select_actions()) { 430 timeout.tv_sec = 0; 431 timeout.tv_nsec = 0; 432 } 433 434 ret = pselect(max_fd+1, &r, &w, &e, &timeout, &mask); 435 436 if(ret < 0) { 437 if (errno == EINTR) { 438 if(owl_global_is_interrupted(&g)) { 439 owl_select_handle_intr(NULL); 440 } 441 } else if (errno == EBADF) { 442 /* Perl must have closed an fd on us without removing it first. */ 443 owl_select_prune_bad_fds(); 444 } 445 sigprocmask(SIG_SETMASK, &mask, NULL); 446 return; 447 } 448 449 sigprocmask(SIG_SETMASK, &mask, NULL); 450 451 if(ret > 0) { 452 /* AIM HACK: process all AIM events at once. */ 453 for(i = 0; !aim_done && i <= max_fd; i++) { 454 if (FD_ISSET(i, &r) || FD_ISSET(i, &w) || FD_ISSET(i, &e)) { 455 if (FD_ISSET(i, &aim_rfds) || FD_ISSET(i, &aim_wfds)) { 456 owl_process_aim(); 457 aim_done = 1; 458 } 459 } 460 } 461 owl_select_io_dispatch(&r, &w, &e, max_fd); 462 } 335 void owl_select_init(void) 336 { 337 owl_timer_source = g_source_new(&owl_timer_funcs, sizeof(GSource)); 338 g_source_attach(owl_timer_source, NULL); 339 340 owl_io_dispatch_source = g_source_new(&owl_io_dispatch_funcs, sizeof(GSource)); 341 g_source_attach(owl_io_dispatch_source, NULL); 463 342 } 464 343 465 344 void owl_select_run_loop(void) 466 345 { 467 loop_active = 1; 468 while (loop_active) { 469 owl_select(); 470 } 346 context = g_main_context_default(); 347 loop = g_main_loop_new(context, FALSE); 348 g_main_loop_run(loop); 471 349 } 472 350 473 351 void owl_select_quit_loop(void) 474 352 { 475 loop_active = 0; 476 } 353 if (loop) { 354 g_main_loop_quit(loop); 355 loop = NULL; 356 } 357 } 358 359 typedef struct _owl_task { /*noproto*/ 360 void (*cb)(void *); 361 void *cbdata; 362 void (*destroy_cbdata)(void *); 363 } owl_task; 364 365 static gboolean _run_task(gpointer data) 366 { 367 owl_task *t = data; 368 if (t->cb) 369 t->cb(t->cbdata); 370 return FALSE; 371 } 372 373 static void _destroy_task(void *data) 374 { 375 owl_task *t = data; 376 if (t->destroy_cbdata) 377 t->destroy_cbdata(t->cbdata); 378 g_free(t); 379 } 380 381 void owl_select_post_task(void (*cb)(void*), void *cbdata, void (*destroy_cbdata)(void*)) 382 { 383 GSource *source = g_idle_source_new(); 384 owl_task *t = g_new0(owl_task, 1); 385 t->cb = cb; 386 t->cbdata = cbdata; 387 t->destroy_cbdata = destroy_cbdata; 388 g_source_set_priority(source, G_PRIORITY_DEFAULT); 389 g_source_set_callback(source, _run_task, t, _destroy_task); 390 g_source_attach(source, context); 391 g_source_unref(source); 392 } -
sepbar.c
r044f19f r6eb3ed9 16 16 int x, y, i; 17 17 const char *foo, *appendtosepbar; 18 int cur_numlines, cur_totallines; 18 19 19 20 ml=owl_global_get_msglist(&g); … … 50 51 wattron(sepwin, A_REVERSE); 51 52 52 if (owl_mainwin_is_curmsg_truncated(owl_global_get_mainwin(&g))) {53 getyx(sepwin, y, x);54 wmove(sepwin, y, x+2);55 wattron(sepwin, A_BOLD);56 waddstr(sepwin, " <truncated> ");57 wattroff(sepwin, A_BOLD);58 }59 60 53 i=owl_mainwin_get_last_msg(owl_global_get_mainwin(&g)); 61 54 if ((i != -1) && … … 90 83 } 91 84 85 if (owl_mainwin_is_curmsg_truncated(owl_global_get_mainwin(&g))) { 86 getyx(sepwin, y, x); 87 wmove(sepwin, y, x+2); 88 wattron(sepwin, A_BOLD); 89 cur_numlines = owl_global_get_curmsg_vert_offset(&g) + 1; 90 cur_totallines = owl_message_get_numlines(owl_view_get_element(v, owl_global_get_curmsg(&g))); 91 wprintw(sepwin, " <truncated: %d/%d> ", cur_numlines, cur_totallines); 92 wattroff(sepwin, A_BOLD); 93 } 94 92 95 if (owl_global_get_curmsg_vert_offset(&g)) { 93 96 getyx(sepwin, y, x); -
tester.c
rf25df21 r4c7c21f 233 233 234 234 printf("# BEGIN testing owl_dict\n"); 235 FAIL_UNLESS("create", 0==owl_dict_create(&d));235 owl_dict_create(&d); 236 236 FAIL_UNLESS("insert b", 0==owl_dict_insert_element(&d, "b", bv, owl_dict_noop_delete)); 237 237 FAIL_UNLESS("insert d", 0==owl_dict_insert_element(&d, "d", dv, owl_dict_noop_delete)); … … 249 249 FAIL_UNLESS("get_size", 3==owl_dict_get_size(&d)); 250 250 owl_list_create(&l); 251 FAIL_UNLESS("get_keys", 0==owl_dict_get_keys(&d, &l));251 owl_dict_get_keys(&d, &l); 252 252 FAIL_UNLESS("get_keys result size", 3==owl_list_get_size(&l)); 253 253 -
variable.c
rf203cad r4c7c21f 559 559 int owl_variable_dict_setup(owl_vardict *vd) { 560 560 owl_variable *var, *cur; 561 if (owl_dict_create(vd)) return(-1);561 owl_dict_create(vd); 562 562 for (var = variables_to_init; var->name != NULL; var++) { 563 563 cur = g_new(owl_variable, 1); … … 641 641 642 642 void owl_variable_update(owl_variable *var, const char *summary, const char *desc) { 643 if(var->summary)g_free(var->summary);643 g_free(var->summary); 644 644 var->summary = g_strdup(summary); 645 if(var->description)g_free(var->description);645 g_free(var->description); 646 646 var->description = g_strdup(desc); 647 647 } … … 651 651 if(old) { 652 652 owl_variable_update(old, summ, desc); 653 if(old->pval_default)g_free(old->pval_default);653 g_free(old->pval_default); 654 654 old->pval_default = g_strdup(initval); 655 655 } else { … … 944 944 void owl_variable_delete_default(owl_variable *v) 945 945 { 946 if (v->val)g_free(v->val);946 g_free(v->val); 947 947 } 948 948 … … 1076 1076 if (!v->validate_fn(v, newval)) return(-1); 1077 1077 } 1078 if (v->val)g_free(v->val);1078 g_free(v->val); 1079 1079 v->val = g_strdup(newval); 1080 1080 return(0); -
view.c
rd4927a7 r3b8a563 160 160 { 161 161 owl_list_cleanup(&v->ml.list, NULL); 162 if (v->name)g_free(v->name);162 g_free(v->name); 163 163 } -
window.c
rb31f1c9 rf97c1a6 524 524 owl_window_set_position(w, nlines, ncols, w->begin_y, w->begin_x); 525 525 } 526 527 /** Redrawing main loop hooks **/ 528 529 static bool _owl_window_should_redraw(void) { 530 return g.resizepending || owl_window_get_screen()->dirty_subtree; 531 } 532 533 static gboolean _owl_window_redraw_prepare(GSource *source, int *timeout) { 534 *timeout = -1; 535 return _owl_window_should_redraw(); 536 } 537 538 static gboolean _owl_window_redraw_check(GSource *source) { 539 return _owl_window_should_redraw(); 540 } 541 542 static gboolean _owl_window_redraw_dispatch(GSource *source, GSourceFunc callback, gpointer user_data) { 543 owl_colorpair_mgr *cpmgr; 544 545 /* if a resize has been scheduled, deal with it */ 546 owl_global_check_resize(&g); 547 /* update the terminal if we need to */ 548 owl_window_redraw_scheduled(); 549 /* On colorpair shortage, reset and redraw /everything/. NOTE: if we 550 * still overflow, this be useless work. With 8-colors, we get 64 551 * pairs. With 256-colors, we get 32768 pairs with ext-colors 552 * support and 256 otherwise. */ 553 cpmgr = owl_global_get_colorpair_mgr(&g); 554 if (cpmgr->overflow) { 555 owl_function_debugmsg("colorpairs: used all %d pairs; reset pairs and redraw.", 556 owl_util_get_colorpairs()); 557 owl_fmtext_reset_colorpairs(cpmgr); 558 owl_function_full_redisplay(); 559 owl_window_redraw_scheduled(); 560 } 561 return TRUE; 562 } 563 564 static GSourceFuncs redraw_funcs = { 565 _owl_window_redraw_prepare, 566 _owl_window_redraw_check, 567 _owl_window_redraw_dispatch, 568 NULL 569 }; 570 571 GSource *owl_window_redraw_source_new(void) { 572 GSource *source; 573 source = g_source_new(&redraw_funcs, sizeof(GSource)); 574 /* TODO: priority?? */ 575 return source; 576 } -
window.h
r38e2250 r4cc49bc 72 72 void owl_window_resize(owl_window *w, int nlines, int ncols); 73 73 74 GSource *owl_window_redraw_source_new(void); 75 74 76 /* Standard callback functions in windowcb.c */ 75 77 -
zcrypt.c
r1dd285b r3b8a563 476 476 477 477 for(i = 0; i < MAX_SEARCH; i++) { 478 if(varname[i] != NULL) { 479 g_free(varname[i]); 480 } 481 } 482 483 if(filename != NULL) { 484 g_free(filename); 485 } 478 g_free(varname[i]); 479 } 480 481 g_free(filename); 486 482 487 483 return keyfile; … … 773 769 err = call_filter("gpg", argv, in, &out, &status); 774 770 if(err || status) { 775 if(out)g_free(out);771 g_free(out); 776 772 return FALSE; 777 773 } … … 856 852 err = call_filter("gpg", argv, in, &out, &status); 857 853 if(err || status) { 858 if(out)g_free(out);854 g_free(out); 859 855 return FALSE; 860 856 } -
zephyr.c
rf203cad rb848e30 8 8 9 9 #ifdef HAVE_LIBZEPHYR 10 static GSource *owl_zephyr_event_source_new(int fd); 11 12 static gboolean owl_zephyr_event_prepare(GSource *source, int *timeout); 13 static gboolean owl_zephyr_event_check(GSource *source); 14 static gboolean owl_zephyr_event_dispatch(GSource *source, GSourceFunc callback, gpointer user_data); 15 10 16 static GList *deferred_subs = NULL; 11 17 … … 16 22 17 23 Code_t ZResetAuthentication(void); 24 25 static GSourceFuncs zephyr_event_funcs = { 26 owl_zephyr_event_prepare, 27 owl_zephyr_event_check, 28 owl_zephyr_event_dispatch, 29 NULL 30 }; 18 31 #endif 19 32 … … 84 97 Code_t code; 85 98 char *perl; 99 GSource *event_source; 86 100 87 101 owl_select_remove_io_dispatch(d); … … 99 113 } 100 114 101 owl_select_add_io_dispatch(ZGetFD(), OWL_IO_READ|OWL_IO_EXCEPT, &owl_zephyr_process_events, NULL, NULL); 115 event_source = owl_zephyr_event_source_new(ZGetFD()); 116 g_source_attach(event_source, NULL); 117 g_source_unref(event_source); 102 118 103 119 owl_global_set_havezephyr(&g); … … 127 143 perl = owl_perlconfig_execute("BarnOwl::Zephyr::_zephyr_startup()"); 128 144 g_free(perl); 129 130 owl_select_add_pre_select_action(owl_zephyr_pre_select_action, NULL, NULL);131 145 } 132 146 … … 180 194 if((code = ZPending()) < 0) { 181 195 owl_function_debugmsg("Error (%s) in ZPending()\n", 196 error_message(code)); 197 return 0; 198 } 199 return code; 200 } 201 #endif 202 return 0; 203 } 204 205 int owl_zephyr_zqlength(void) 206 { 207 #ifdef HAVE_LIBZEPHYR 208 Code_t code; 209 if(owl_global_is_havezephyr(&g)) { 210 if((code = ZQLength()) < 0) { 211 owl_function_debugmsg("Error (%s) in ZQLength()\n", 182 212 error_message(code)); 183 213 return 0; … … 417 447 return 0; 418 448 } 419 if (buffer) 420 g_free(buffer); 449 g_free(buffer); 421 450 422 451 return owl_zephyr_loadsubs_helper(subs, count); … … 1422 1451 #define OWL_MAX_ZEPHYRGRAMS_TO_PROCESS 20 1423 1452 1453 #ifdef HAVE_LIBZEPHYR 1424 1454 static int _owl_zephyr_process_events(void) 1425 1455 { 1426 1456 int zpendcount=0; 1427 #ifdef HAVE_LIBZEPHYR1428 1457 ZNotice_t notice; 1429 1458 Code_t code; … … 1466 1495 } 1467 1496 } 1468 #endif1469 1497 return zpendcount; 1470 1498 } 1471 1499 1472 void owl_zephyr_process_events(const owl_io_dispatch *d, void *data) 1473 { 1500 typedef struct { /*noproto*/ 1501 GSource source; 1502 GPollFD poll_fd; 1503 } owl_zephyr_event_source; 1504 1505 static GSource *owl_zephyr_event_source_new(int fd) { 1506 GSource *source; 1507 owl_zephyr_event_source *event_source; 1508 1509 source = g_source_new(&zephyr_event_funcs, sizeof(owl_zephyr_event_source)); 1510 event_source = (owl_zephyr_event_source*) source; 1511 event_source->poll_fd.fd = fd; 1512 event_source->poll_fd.events = G_IO_IN | G_IO_HUP | G_IO_PRI | G_IO_ERR; 1513 g_source_add_poll(source, &event_source->poll_fd); 1514 1515 return source; 1516 } 1517 1518 static gboolean owl_zephyr_event_prepare(GSource *source, int *timeout) { 1519 *timeout = -1; 1520 return owl_zephyr_zqlength() > 0; 1521 } 1522 1523 static gboolean owl_zephyr_event_check(GSource *source) { 1524 owl_zephyr_event_source *event_source = (owl_zephyr_event_source*)source; 1525 if (event_source->poll_fd.revents & event_source->poll_fd.events) 1526 return owl_zephyr_zpending() > 0; 1527 return FALSE; 1528 } 1529 1530 static gboolean owl_zephyr_event_dispatch(GSource *source, GSourceFunc callback, gpointer user_data) { 1474 1531 _owl_zephyr_process_events(); 1475 } 1476 1477 int owl_zephyr_pre_select_action(owl_ps_action *a, void *p) 1478 { 1479 return _owl_zephyr_process_events(); 1480 } 1532 return TRUE; 1533 } 1534 #endif -
zwrite.c
r3f52e14 r3b8a563 185 185 void owl_zwrite_set_message_raw(owl_zwrite *z, const char *msg) 186 186 { 187 if (z->message)g_free(z->message);187 g_free(z->message); 188 188 z->message = owl_validate_utf8(msg); 189 189 } … … 195 195 char *tmp = NULL, *tmp2; 196 196 197 if (z->message)g_free(z->message);197 g_free(z->message); 198 198 199 199 j=owl_list_get_size(&(z->recips)); … … 289 289 void owl_zwrite_set_opcode(owl_zwrite *z, const char *opcode) 290 290 { 291 if (z->opcode)g_free(z->opcode);291 g_free(z->opcode); 292 292 z->opcode=owl_validate_utf8(opcode); 293 293 } … … 306 306 void owl_zwrite_set_zsig(owl_zwrite *z, const char *zsig) 307 307 { 308 if(z->zsig)g_free(z->zsig);308 g_free(z->zsig); 309 309 z->zsig = g_strdup(zsig); 310 310 } … … 353 353 { 354 354 owl_list_cleanup(&(z->recips), &g_free); 355 if (z->cmd)g_free(z->cmd);356 if (z->zwriteline)g_free(z->zwriteline);357 if (z->class)g_free(z->class);358 if (z->inst)g_free(z->inst);359 if (z->opcode)g_free(z->opcode);360 if (z->realm)g_free(z->realm);361 if (z->message)g_free(z->message);362 if (z->zsig)g_free(z->zsig);355 g_free(z->cmd); 356 g_free(z->zwriteline); 357 g_free(z->class); 358 g_free(z->inst); 359 g_free(z->opcode); 360 g_free(z->realm); 361 g_free(z->message); 362 g_free(z->zsig); 363 363 } 364 364
Note: See TracChangeset
for help on using the changeset viewer.