Changeset fc625fb
- Timestamp:
- Jun 22, 2011, 3:45:52 PM (13 years ago)
- Parents:
- b343c2c (diff), 6376af1 (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:
-
- 2 deleted
- 46 edited
Legend:
- Unmodified
- Added
- Removed
-
functions.c
rb343c2c rfc625fb 3156 3156 } 3157 3157 3158 /* if it exited, fork & execa new one */3158 /* if it exited, spawn a new one */ 3159 3159 if (owl_global_get_newmsgproc_pid(&g)==0) { 3160 pid_t i;3161 3160 int myargc; 3162 i=fork(); 3163 if (i) { 3164 /* parent set the child's pid */ 3165 owl_global_set_newmsgproc_pid(&g, i); 3166 owl_function_debugmsg("I'm the parent and I started a new newmsgproc with pid %i", i); 3167 } else { 3168 /* child exec's the program */ 3169 char **parsed; 3170 parsed=owl_parseline(owl_global_get_newmsgproc(&g), &myargc); 3171 if (myargc < 0) { 3172 owl_function_debugmsg("Could not parse newmsgproc '%s': unbalanced quotes?", owl_global_get_newmsgproc(&g)); 3173 } 3174 if (myargc <= 0) { 3175 _exit(127); 3176 } 3177 owl_function_debugmsg("About to exec \"%s\" with %d arguments", parsed[0], myargc); 3178 3179 execvp(parsed[0], parsed); 3180 3181 3182 /* was there an error exec'ing? */ 3183 owl_function_debugmsg("Cannot run newmsgproc '%s': cannot exec '%s': %s", 3184 owl_global_get_newmsgproc(&g), parsed[0], strerror(errno)); 3185 _exit(127); 3161 char **argv = owl_parseline(owl_global_get_newmsgproc(&g), &myargc); 3162 if (myargc < 0) { 3163 owl_function_debugmsg("Could not parse newmsgproc '%s': unbalanced quotes?", 3164 owl_global_get_newmsgproc(&g)); 3165 } else if (myargc > 0) { 3166 /* Spawn the child. */ 3167 pid_t pid; 3168 GError *error = NULL; 3169 owl_function_debugmsg("About to exec \"%s\" with %d arguments", argv[0], myargc); 3170 if (g_spawn_async(NULL, argv, NULL, 3171 G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, 3172 NULL, NULL, &pid, &error)) { 3173 owl_global_set_newmsgproc_pid(&g, pid); 3174 owl_function_debugmsg("I'm the parent and I started a new newmsgproc with pid %i", pid); 3175 } else { 3176 owl_function_debugmsg("Cannot run newmsgproc '%s': %s", 3177 owl_global_get_newmsgproc(&g), error->message); 3178 g_error_free(error); 3179 } 3186 3180 } 3181 g_strfreev(argv); 3187 3182 } 3188 3183 } -
Makefile.am
r3535a6e r4f746f8 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.cmainpanel.c msgwin.c sepbar.c editcontext.c signal.c47 mainpanel.c msgwin.c sepbar.c editcontext.c signal.c 48 48 49 49 NORMAL_SRCS = filterproc.c window.c windowcb.c -
README
r13ee8f2 r9179fd7 19 19 20 20 AnyEvent 21 Glib 21 22 PAR 22 23 Net::DNS -
aim.c
rdc1edbd rd427f08 113 113 } 114 114 115 void owl_aim_send_nop(owl_timer *t, void *data) { 116 if(owl_global_is_doaimevents(&g)) { 117 aim_session_t *sess = owl_global_get_aimsess(&g); 118 aim_flap_nop(sess, aim_getconn_type(sess, AIM_CONN_TYPE_BOS)); 119 } 115 gboolean owl_aim_send_nop(gpointer data) { 116 owl_global *g = data; 117 if (owl_global_is_doaimevents(g)) { 118 aim_session_t *sess = owl_global_get_aimsess(g); 119 aim_flap_nop(sess, aim_getconn_type(sess, AIM_CONN_TYPE_BOS)); 120 } 121 return TRUE; 120 122 } 121 123 … … 183 185 owl_function_debugmsg("owl_aim_login: connecting"); 184 186 185 g.aim_nop_timer = owl_select_add_timer("owl_aim_send_nop", 30, 30, owl_aim_send_nop, NULL, NULL);187 g.aim_nop_timer = g_timeout_add_seconds(30, owl_aim_send_nop, &g); 186 188 187 189 return(0); 188 190 } 189 191 190 static void owl_aim_unset_ignorelogin(owl_timer *t, void *data) 191 { 192 owl_global_unset_ignore_aimlogin(&g); 192 static gboolean owl_aim_unset_ignorelogin(void *data) 193 { 194 owl_global *g = data; 195 owl_global_unset_ignore_aimlogin(g); 196 return FALSE; /* only run once. */ 193 197 } 194 198 … … 209 213 /* start the ingorelogin timer */ 210 214 owl_global_set_ignore_aimlogin(&g); 211 owl_select_add_timer("owl_aim_unset_ignorelogin", 212 owl_global_get_aim_ignorelogin_timer(&g), 213 0, owl_aim_unset_ignorelogin, NULL, NULL); 215 g_timeout_add_seconds(owl_global_get_aim_ignorelogin_timer(&g), 216 owl_aim_unset_ignorelogin, &g); 214 217 215 218 /* aim_ssi_setpresence(owl_global_get_aimsess(&g), 0x00000400); */ … … 225 228 owl_global_set_aimnologgedin(&g); 226 229 owl_global_set_no_doaimevents(&g); 227 owl_select_remove_timer(g.aim_nop_timer); 230 if (g.aim_nop_timer) { 231 g_source_remove(g.aim_nop_timer); 232 g.aim_nop_timer = 0; 233 } 228 234 } 229 235 … … 244 250 owl_global_set_aimnologgedin(&g); 245 251 owl_global_set_no_doaimevents(&g); 246 owl_select_remove_timer(g.aim_nop_timer); 252 if (g.aim_nop_timer) { 253 g_source_remove(g.aim_nop_timer); 254 g.aim_nop_timer = 0; 255 } 247 256 } 248 257 … … 428 437 429 438 /* caller must free the return */ 430 char *owl_aim_normalize_screenname(const char *in)439 G_GNUC_WARN_UNUSED_RESULT char *owl_aim_normalize_screenname(const char *in) 431 440 { 432 441 char *out; -
barnowl
rde18326 rb14f8cb 7 7 EXE="$0.bin" 8 8 9 if ! test-x "$EXE"; then9 if test ! -x "$EXE"; then 10 10 echo "Cannot find barnowl.bin" >&2 11 11 exit 1 12 12 fi 13 13 14 export BARNOWL_DATA_DIR="$SRCDIR/perl/" 15 export BARNOWL_BIN_DIR="$SRCDIR/" 14 BARNOWL_DATA_DIR="$SRCDIR/perl/" 15 BARNOWL_BIN_DIR="$SRCDIR/" 16 export BARNOWL_DATA_DIR 17 export BARNOWL_BIN_DIR 16 18 exec "$EXE" "$@" -
cmd.c
r4c7c21f rd427f08 5 5 #include "owl.h" 6 6 7 extern const owl_cmd commands_to_init[];8 9 7 /**************************************************************************/ 10 8 /***************************** COMMAND DICT *******************************/ 11 9 /**************************************************************************/ 12 10 13 int owl_cmddict_setup(owl_cmddict *cd) { 11 void owl_cmddict_setup(owl_cmddict *cd) 12 { 14 13 owl_cmddict_init(cd); 15 if (0 != owl_cmddict_add_from_list(cd, commands_to_init)) return(-1); 16 return(0); 14 owl_cmd_add_defaults(cd); 17 15 } 18 16 … … 22 20 23 21 /* for bulk initialization at startup */ 24 int owl_cmddict_add_from_list(owl_cmddict *cd, const owl_cmd *cmds) { 22 void owl_cmddict_add_from_list(owl_cmddict *cd, const owl_cmd *cmds) 23 { 25 24 const owl_cmd *cur; 26 int ret = 0;27 25 for (cur = cmds; cur->name != NULL; cur++) { 28 ret = owl_cmddict_add_cmd(cd, cur); 29 if (ret < 0) break; 30 } 31 return ret; 26 owl_cmddict_add_cmd(cd, cur); 27 } 32 28 } 33 29 … … 41 37 42 38 /* creates a new command alias */ 43 intowl_cmddict_add_alias(owl_cmddict *cd, const char *alias_from, const char *alias_to) {39 void owl_cmddict_add_alias(owl_cmddict *cd, const char *alias_from, const char *alias_to) { 44 40 owl_cmd *cmd; 45 41 cmd = g_new(owl_cmd, 1); … … 47 43 owl_perlconfig_new_command(cmd->name); 48 44 owl_dict_insert_element(cd, cmd->name, cmd, (void (*)(void *))owl_cmd_delete); 49 return(0);50 45 } 51 46 … … 60 55 } 61 56 62 char *_owl_cmddict_execute(const owl_cmddict *cd, const owl_context *ctx, const char *const *argv, int argc, const char *buff) { 57 /* caller must free the return */ 58 G_GNUC_WARN_UNUSED_RESULT char *_owl_cmddict_execute(const owl_cmddict *cd, const owl_context *ctx, const char *const *argv, int argc, const char *buff) 59 { 63 60 char *retval = NULL; 64 61 const owl_cmd *cmd; … … 75 72 } 76 73 77 char *owl_cmddict_execute(const owl_cmddict *cd, const owl_context *ctx, const char *cmdbuff) { 74 /* caller must free the return */ 75 G_GNUC_WARN_UNUSED_RESULT char *owl_cmddict_execute(const owl_cmddict *cd, const owl_context *ctx, const char *cmdbuff) 76 { 78 77 char **argv; 79 78 int argc; … … 97 96 } 98 97 99 char *owl_cmddict_execute_argv(const owl_cmddict *cd, const owl_context *ctx, const char *const *argv, int argc) { 98 /* caller must free the return */ 99 G_GNUC_WARN_UNUSED_RESULT char *owl_cmddict_execute_argv(const owl_cmddict *cd, const owl_context *ctx, const char *const *argv, int argc) 100 { 100 101 char *buff; 101 102 char *retval = NULL; … … 124 125 } 125 126 126 intowl_cmd_create_alias(owl_cmd *cmd, const char *name, const char *aliased_to) {127 void owl_cmd_create_alias(owl_cmd *cmd, const char *name, const char *aliased_to) { 127 128 memset(cmd, 0, sizeof(owl_cmd)); 128 129 cmd->name = g_strdup(name); 129 130 cmd->cmd_aliased_to = g_strdup(aliased_to); 130 131 cmd->summary = g_strdup_printf("%s%s", OWL_CMD_ALIAS_SUMMARY_PREFIX, aliased_to); 131 return(0);132 132 } 133 133 … … 153 153 } 154 154 155 char *owl_cmd_execute(const owl_cmd *cmd, const owl_cmddict *cd, const owl_context *ctx, int argc, const char *const *argv, const char *cmdbuff) { 155 /* caller must free the result */ 156 G_GNUC_WARN_UNUSED_RESULT char *owl_cmd_execute(const owl_cmd *cmd, const owl_cmddict *cd, const owl_context *ctx, int argc, const char *const *argv, const char *cmdbuff) 157 { 156 158 static int alias_recurse_depth = 0; 157 159 int ival=0; … … 226 228 227 229 /* returns a summary line describing this keymap. the caller must free. */ 228 char *owl_cmd_describe(const owl_cmd *cmd) { 230 G_GNUC_WARN_UNUSED_RESULT char *owl_cmd_describe(const owl_cmd *cmd) 231 { 229 232 if (!cmd || !cmd->name || !cmd->summary) return NULL; 230 233 return g_strdup_printf("%-25s - %s", cmd->name, cmd->summary); -
commands.c
r697221f rd427f08 8 8 /* fn is "char *foo(int argc, const char *const *argv, const char *buff)" */ 9 9 #define OWLCMD_ARGS(name, fn, ctx, summary, usage, description) \ 10 { name, summary, usage, description, ctx, \10 { g_strdup(name), g_strdup(summary), g_strdup(usage), g_strdup(description), ctx, \ 11 11 NULL, fn, NULL, NULL, NULL, NULL, NULL, NULL } 12 12 13 13 /* fn is "void foo(void)" */ 14 14 #define OWLCMD_VOID(name, fn, ctx, summary, usage, description) \ 15 { name, summary, usage, description, ctx, \15 { g_strdup(name), g_strdup(summary), g_strdup(usage), g_strdup(description), ctx, \ 16 16 NULL, NULL, fn, NULL, NULL, NULL, NULL, NULL } 17 17 18 18 /* fn is "void foo(int)" */ 19 19 #define OWLCMD_INT(name, fn, ctx, summary, usage, description) \ 20 { name, summary, usage, description, ctx, \20 { g_strdup(name), g_strdup(summary), g_strdup(usage), g_strdup(description), ctx, \ 21 21 NULL, NULL, NULL, fn, NULL, NULL, NULL, NULL } 22 22 23 23 #define OWLCMD_ALIAS(name, actualname) \ 24 { name, OWL_CMD_ALIAS_SUMMARY_PREFIX actualname, "", "", OWL_CTX_ANY, \25 actualname, NULL, NULL, NULL, NULL, NULL, NULL, NULL }24 { g_strdup(name), g_strdup(OWL_CMD_ALIAS_SUMMARY_PREFIX actualname), g_strdup(""), g_strdup(""), OWL_CTX_ANY, \ 25 g_strdup(actualname), NULL, NULL, NULL, NULL, NULL, NULL, NULL } 26 26 27 27 /* fn is "char *foo(void *ctx, int argc, const char *const *argv, const char *buff)" */ 28 28 #define OWLCMD_ARGS_CTX(name, fn, ctx, summary, usage, description) \ 29 { name, summary, usage, description, ctx, \29 { g_strdup(name), g_strdup(summary), g_strdup(usage), g_strdup(description), ctx, \ 30 30 NULL, NULL, NULL, NULL, ((char*(*)(void*,int,const char*const *,const char*))fn), NULL, NULL, NULL } 31 31 32 32 /* fn is "void foo(void)" */ 33 33 #define OWLCMD_VOID_CTX(name, fn, ctx, summary, usage, description) \ 34 { name, summary, usage, description, ctx, \34 { g_strdup(name), g_strdup(summary), g_strdup(usage), g_strdup(description), ctx, \ 35 35 NULL, NULL, NULL, NULL, NULL, ((void(*)(void*))(fn)), NULL, NULL } 36 36 37 37 /* fn is "void foo(int)" */ 38 38 #define OWLCMD_INT_CTX(name, fn, ctx, summary, usage, description) \ 39 { name, summary, usage, description, ctx, \39 { g_strdup(name), g_strdup(summary), g_strdup(usage), g_strdup(description), ctx, \ 40 40 NULL, NULL, NULL, NULL, NULL, NULL, ((void(*)(void*,int))fn), NULL } 41 41 42 42 43 const owl_cmd commands_to_init[] 44 = { 43 void owl_cmd_add_defaults(owl_cmddict *cd) 44 { 45 owl_cmd commands_to_init[] = { 46 45 47 OWLCMD_ARGS("zlog", owl_command_zlog, OWL_CTX_ANY, 46 48 "send a login or logout notification", … … 654 656 "show subscriptions / show subs\n" 655 657 "show terminal\n" 656 "show timers\n"657 658 "show variables\n" 658 659 "show variable <variable>\n" … … 1037 1038 { NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL } 1038 1039 1039 }; 1040 }; 1041 1042 owl_cmddict_add_from_list(cd, commands_to_init); 1043 owl_cmd *cmd; 1044 for (cmd = commands_to_init; cmd->name != NULL; cmd++) 1045 owl_cmd_cleanup(cmd); 1046 } 1040 1047 1041 1048 void owl_command_info(void) … … 1366 1373 } 1367 1374 1368 char *owl_command_smartfilter(int argc, const char *const *argv, const char *buff)1375 G_GNUC_WARN_UNUSED_RESULT char *owl_command_smartfilter(int argc, const char *const *argv, const char *buff) 1369 1376 { 1370 1377 char *filtname = NULL; … … 1406 1413 } 1407 1414 1408 char *owl_command_get_shift(int argc, const char *const *argv, const char *buff)1415 G_GNUC_WARN_UNUSED_RESULT char *owl_command_get_shift(int argc, const char *const *argv, const char *buff) 1409 1416 { 1410 1417 if(argc != 1) … … 1637 1644 1638 1645 1639 char *owl_command_exec(int argc, const char *const *argv, const char *buff)1646 G_GNUC_WARN_UNUSED_RESULT char *owl_command_exec(int argc, const char *const *argv, const char *buff) 1640 1647 { 1641 1648 return owl_function_exec(argc, argv, buff, OWL_OUTPUT_RETURN); 1642 1649 } 1643 1650 1644 char *owl_command_pexec(int argc, const char *const *argv, const char *buff)1651 G_GNUC_WARN_UNUSED_RESULT char *owl_command_pexec(int argc, const char *const *argv, const char *buff) 1645 1652 { 1646 1653 return owl_function_exec(argc, argv, buff, OWL_OUTPUT_POPUP); 1647 1654 } 1648 1655 1649 char *owl_command_aexec(int argc, const char *const *argv, const char *buff)1656 G_GNUC_WARN_UNUSED_RESULT char *owl_command_aexec(int argc, const char *const *argv, const char *buff) 1650 1657 { 1651 1658 return owl_function_exec(argc, argv, buff, OWL_OUTPUT_ADMINMSG); 1652 1659 } 1653 1660 1654 char *owl_command_perl(int argc, const char *const *argv, const char *buff)1661 G_GNUC_WARN_UNUSED_RESULT char *owl_command_perl(int argc, const char *const *argv, const char *buff) 1655 1662 { 1656 1663 return owl_function_perl(argc, argv, buff, OWL_OUTPUT_RETURN); 1657 1664 } 1658 1665 1659 char *owl_command_pperl(int argc, const char *const *argv, const char *buff)1666 G_GNUC_WARN_UNUSED_RESULT char *owl_command_pperl(int argc, const char *const *argv, const char *buff) 1660 1667 { 1661 1668 return owl_function_perl(argc, argv, buff, OWL_OUTPUT_POPUP); 1662 1669 } 1663 1670 1664 char *owl_command_aperl(int argc, const char *const *argv, const char *buff)1671 G_GNUC_WARN_UNUSED_RESULT char *owl_command_aperl(int argc, const char *const *argv, const char *buff) 1665 1672 { 1666 1673 return owl_function_perl(argc, argv, buff, OWL_OUTPUT_ADMINMSG); 1667 1674 } 1668 1675 1669 char *owl_command_multi(int argc, const char *const *argv, const char *buff)1676 G_GNUC_WARN_UNUSED_RESULT char *owl_command_multi(int argc, const char *const *argv, const char *buff) 1670 1677 { 1671 1678 char *lastrv = NULL, *newbuff; … … 2225 2232 } else if (!strcmp(argv[1], "styles")) { 2226 2233 owl_function_show_styles(); 2227 } else if (!strcmp(argv[1], "timers")) {2228 owl_function_show_timers();2229 2234 } else if (!strcmp(argv[1], "subs") || !strcmp(argv[1], "subscriptions")) { 2230 2235 owl_function_getsubs(); … … 2589 2594 } 2590 2595 2591 char *owl_command_getstyle(int argc, const char *const *argv, const char *buff)2596 G_GNUC_WARN_UNUSED_RESULT char *owl_command_getstyle(int argc, const char *const *argv, const char *buff) 2592 2597 { 2593 2598 const char *stylename; … … 2633 2638 } 2634 2639 2635 char *owl_command_with_history(int argc, const char *const *argv, const char *buff)2640 G_GNUC_WARN_UNUSED_RESULT char *owl_command_with_history(int argc, const char *const *argv, const char *buff) 2636 2641 { 2637 2642 owl_history *hist; -
configure.ac
rf97c1a6 r4f746f8 8 8 9 9 AC_PROG_CC 10 AC_PROG_CC_C99 10 11 11 12 AC_ARG_WITH([stack-protector], … … 80 81 AC_HEADER_STDC 81 82 AC_HEADER_SYS_WAIT 82 AC_HEADER_STDBOOL 83 AC_CHECK_HEADERS(strings.h sys/ioctl.h sys/filio.h unistd.h) 83 AC_CHECK_HEADERS(stdbool.h strings.h sys/ioctl.h sys/filio.h unistd.h) 84 84 85 85 dnl Add CFLAGS for embeded perl … … 115 115 116 116 dnl Add CFLAGS and LIBS for glib-2.0 117 PKG_CHECK_MODULES(GLIB,[glib-2.0 >= 2.1 2gobject-2.0 gthread-2.0])117 PKG_CHECK_MODULES(GLIB,[glib-2.0 >= 2.16 gobject-2.0 gthread-2.0]) 118 118 119 119 AC_MSG_NOTICE([Adding glib-2.0 CFLAGS ${GLIB_CFLAGS}]) … … 130 130 AX_CFLAGS_WARN_ALL([AM_CFLAGS]) 131 131 AX_C_CHECK_FLAG([-Wstrict-prototypes],[],[],[AM_CFLAGS="$AM_CFLAGS -Wstrict-prototypes"]) 132 AX_C_CHECK_FLAG([-Wwrite-strings],[],[],[AM_CFLAGS="$AM_CFLAGS -Wwrite-strings"]) 132 133 133 134 dnl Shut gcc up about zero-length format strings; the warning's apparently for … … 143 144 test "$HAVE_DES_ECB_ENCRYPT"]) 144 145 145 AM_CFLAGS="$AM_CFLAGS -D_XOPEN_SOURCE= 500"146 AM_CFLAGS="$AM_CFLAGS -D_XOPEN_SOURCE=600" 146 147 dnl Define _BSD_SOURCE because zephyr needs caddr_t. 147 148 AM_CFLAGS="$AM_CFLAGS -D_BSD_SOURCE" -
context.c
rd4927a7 rd427f08 6 6 7 7 /* TODO: dependency from owl_context -> owl_window is annoying. */ 8 owl_context *owl_context_new(int mode, void *data, const char *keymap, owl_window *cursor)8 G_GNUC_WARN_UNUSED_RESULT owl_context *owl_context_new(int mode, void *data, const char *keymap, owl_window *cursor) 9 9 { 10 10 owl_context *c; -
dict.c
r4c7c21f rd427f08 107 107 /* Doesn't free the value of the element, but does 108 108 * return it so the caller can free it. */ 109 void *owl_dict_remove_element(owl_dict *d, const char *k) { 109 G_GNUC_WARN_UNUSED_RESULT void *owl_dict_remove_element(owl_dict *d, const char *k) 110 { 110 111 int i; 111 112 int pos, found; -
editcontext.c
r4a41f16 rd427f08 8 8 } 9 9 10 owl_context *owl_editcontext_new(int mode, owl_editwin *e, const char *keymap, void (*deactivate_cb)(owl_context*), void *cbdata)10 G_GNUC_WARN_UNUSED_RESULT owl_context *owl_editcontext_new(int mode, owl_editwin *e, const char *keymap, void (*deactivate_cb)(owl_context*), void *cbdata) 11 11 { 12 12 owl_context *ctx = owl_context_new(mode, owl_editwin_ref(e), keymap, -
editwin.c
r3b8a563 rd427f08 61 61 static const char *oe_copy_buf(owl_editwin *e, const char *buf, int len); 62 62 static int oe_copy_region(owl_editwin *e); 63 static char *oe_chunk(owl_editwin *e, int start, int end);63 static G_GNUC_WARN_UNUSED_RESULT char *oe_chunk(owl_editwin *e, int start, int end); 64 64 static void oe_destroy_cbdata(owl_editwin *e); 65 65 static void oe_dirty(owl_editwin *e); … … 70 70 #define WHITESPACE " \n\t" 71 71 72 static owl_editwin *owl_editwin_allocate(void)72 static G_GNUC_WARN_UNUSED_RESULT owl_editwin *owl_editwin_allocate(void) 73 73 { 74 74 owl_editwin *e = g_new0(owl_editwin, 1); … … 142 142 } 143 143 144 owl_editwin *owl_editwin_new(owl_window *win, int winlines, int wincols, int style, owl_history *hist)144 G_GNUC_WARN_UNUSED_RESULT owl_editwin *owl_editwin_new(owl_window *win, int winlines, int wincols, int style, owl_history *hist) 145 145 { 146 146 owl_editwin *e = owl_editwin_allocate(); … … 1369 1369 } 1370 1370 1371 char *owl_editwin_get_region(owl_editwin *e)1371 G_GNUC_WARN_UNUSED_RESULT char *owl_editwin_get_region(owl_editwin *e) 1372 1372 { 1373 1373 int start, end; … … 1388 1388 } 1389 1389 1390 static char *oe_chunk(owl_editwin *e, int start, int end)1390 static G_GNUC_WARN_UNUSED_RESULT char *oe_chunk(owl_editwin *e, int start, int end) 1391 1391 { 1392 1392 char *p; -
filter.c
re56303f rd427f08 200 200 201 201 202 char *owl_filter_print(const owl_filter *f)202 char G_GNUC_WARN_UNUSED_RESULT *owl_filter_print(const owl_filter *f) 203 203 { 204 204 GString *out = g_string_new(""); -
fmtext.c
r7b4f3be rd427f08 171 171 * freeing the return 172 172 */ 173 char *owl_fmtext_print_plain(const owl_fmtext *f)173 char G_GNUC_WARN_UNUSED_RESULT *owl_fmtext_print_plain(const owl_fmtext *f) 174 174 { 175 175 return owl_strip_format_chars(f->buff->str); -
global.c
rf97c1a6 rd427f08 105 105 106 106 owl_message_init_fmtext_cache(); 107 owl_list_create(&(g->io_dispatch_list));108 g->timerlist = NULL;109 107 g->kill_buffer = NULL; 110 108 … … 175 173 /* Pops the current context from the context stack and returns it. Caller is 176 174 * responsible for freeing. */ 177 owl_context *owl_global_pop_context_no_delete(owl_global *g) { 175 G_GNUC_WARN_UNUSED_RESULT owl_context *owl_global_pop_context_no_delete(owl_global *g) 176 { 178 177 owl_context *c; 179 178 if (!g->context_stack) … … 727 726 * necessary. 728 727 */ 729 owl_message *owl_global_messagequeue_popmsg(owl_global *g)728 owl_message G_GNUC_WARN_UNUSED_RESULT *owl_global_messagequeue_popmsg(owl_global *g) 730 729 { 731 730 owl_message *out; … … 839 838 { 840 839 return(&(g->startup_tio)); 841 }842 843 owl_list *owl_global_get_io_dispatch_list(owl_global *g)844 {845 return &(g->io_dispatch_list);846 }847 848 GList **owl_global_get_timerlist(owl_global *g)849 {850 return &(g->timerlist);851 840 } 852 841 -
keybinding.c
r3b8a563 rd427f08 14 14 15 15 /* sets up a new keybinding for a command */ 16 owl_keybinding *owl_keybinding_new(const char *keyseq, const char *command, void (*function_fn)(void), const char *desc)16 G_GNUC_WARN_UNUSED_RESULT owl_keybinding *owl_keybinding_new(const char *keyseq, const char *command, void (*function_fn)(void), const char *desc) 17 17 { 18 18 owl_keybinding *kb = g_new(owl_keybinding, 1); … … 85 85 } 86 86 87 char *owl_keybinding_stack_tostring(int *j, int len)87 G_GNUC_WARN_UNUSED_RESULT char *owl_keybinding_stack_tostring(int *j, int len) 88 88 { 89 89 GString *string; … … 100 100 } 101 101 102 char *owl_keybinding_tostring(const owl_keybinding *kb)102 G_GNUC_WARN_UNUSED_RESULT char *owl_keybinding_tostring(const owl_keybinding *kb) 103 103 { 104 104 return owl_keybinding_stack_tostring(kb->keys, kb->len); -
keymap.c
r4c7c21f rd427f08 51 51 } 52 52 } 53 return owl_list_append_element(&km->bindings, kb);54 53 owl_list_append_element(&km->bindings, kb); 54 return 0; 55 55 } 56 56 … … 80 80 81 81 /* returns a summary line describing this keymap. the caller must free. */ 82 char *owl_keymap_summary(const owl_keymap *km)82 G_GNUC_WARN_UNUSED_RESULT char *owl_keymap_summary(const owl_keymap *km) 83 83 { 84 84 if (!km || !km->name || !km->desc) return NULL; -
keypress.c
rd07af84 rd427f08 129 129 /* OWL_META is definied in owl.h */ 130 130 131 char *owl_keypress_tostring(int j, int esc)131 char G_GNUC_WARN_UNUSED_RESULT *owl_keypress_tostring(int j, int esc) 132 132 { 133 133 GString *kb; -
libfaim/aim.h
r63de71c rfe73d0c 18 18 19 19 #include "config.h" 20 #ifdef HAVE_STDBOOL_H21 20 #include <stdbool.h> 22 #else23 #ifndef HAVE__BOOL24 #define _Bool signed char25 #endif26 #define bool _Bool27 #define false 028 #define true 129 #define __bool_true_false_are_defined 130 #endif /* HAVE_STDBOOL_H */31 21 32 22 #include <stdio.h> -
list.c
rfda61d3 rd427f08 53 53 } 54 54 55 intowl_list_append_element(owl_list *l, void *element)55 void owl_list_append_element(owl_list *l, void *element) 56 56 { 57 returnowl_list_insert_element(l, l->size, element);57 owl_list_insert_element(l, l->size, element); 58 58 } 59 59 60 intowl_list_prepend_element(owl_list *l, void *element)60 void owl_list_prepend_element(owl_list *l, void *element) 61 61 { 62 returnowl_list_insert_element(l, 0, element);62 owl_list_insert_element(l, 0, element); 63 63 } 64 64 -
logging.c
rcc305b5 rd427f08 80 80 } 81 81 82 char *owl_log_zephyr(const owl_message *m) { 82 G_GNUC_WARN_UNUSED_RESULT char *owl_log_zephyr(const owl_message *m) 83 { 83 84 char *tmp = NULL; 84 85 GString *buffer = NULL; … … 103 104 } 104 105 105 char *owl_log_aim(const owl_message *m) { 106 G_GNUC_WARN_UNUSED_RESULT char *owl_log_aim(const owl_message *m) 107 { 106 108 GString *buffer = NULL; 107 109 buffer = g_string_new(""); … … 120 122 } 121 123 122 char *owl_log_jabber(const owl_message *m) { 124 G_GNUC_WARN_UNUSED_RESULT char *owl_log_jabber(const owl_message *m) 125 { 123 126 GString *buffer = NULL; 124 127 buffer = g_string_new(""); … … 132 135 } 133 136 134 char *owl_log_generic(const owl_message *m) { 137 G_GNUC_WARN_UNUSED_RESULT char *owl_log_generic(const owl_message *m) 138 { 135 139 GString *buffer; 136 140 buffer = g_string_new(""); -
message.c
r259e60a8 rd427f08 580 580 581 581 /* caller must free return value. */ 582 char *owl_message_get_cc(const owl_message *m)582 G_GNUC_WARN_UNUSED_RESULT char *owl_message_get_cc(const owl_message *m) 583 583 { 584 584 const char *cur; … … 597 597 598 598 /* caller must free return value */ 599 G List *owl_message_get_cc_without_recipient(const owl_message *m)599 G_GNUC_WARN_UNUSED_RESULT GList *owl_message_get_cc_without_recipient(const owl_message *m) 600 600 { 601 601 char *cc, *shortuser, *recip; -
messagelist.c
r66a8cd6 rd427f08 42 42 } 43 43 44 intowl_messagelist_append_element(owl_messagelist *ml, void *element)44 void owl_messagelist_append_element(owl_messagelist *ml, void *element) 45 45 { 46 return(owl_list_append_element(&(ml->list), element));46 owl_list_append_element(&ml->list, element); 47 47 } 48 48 -
owl.c
rcc305b5 r2244836 302 302 } 303 303 304 void owl_process_input(const owl_io_dispatch *d, void *data)304 gboolean owl_process_input(GIOChannel *source, GIOCondition condition, void *data) 305 305 { 306 owl_global *g = data; 306 307 owl_input j; 307 308 308 309 while (1) { 309 j.ch = wgetch(g .input_pad);310 if (j.ch == ERR) return ;310 j.ch = wgetch(g->input_pad); 311 if (j.ch == ERR) return TRUE; 311 312 312 313 j.uch = '\0'; … … 330 331 331 332 for (i = 1; i < bytes; i++) { 332 int tmp = wgetch(g .input_pad);333 int tmp = wgetch(g->input_pad); 333 334 /* If what we got was not a byte, or not a continuation byte */ 334 335 if (tmp > 0xff || !(tmp & 0x80 && ~tmp & 0x40)) { … … 357 358 owl_process_input_char(j); 358 359 } 360 return TRUE; 359 361 } 360 362 … … 448 450 449 451 /* Sends stderr (read from rfd) messages to the error console */ 450 void stderr_redirect_handler(const owl_io_dispatch *d, void *data)452 gboolean stderr_redirect_handler(GIOChannel *source, GIOCondition condition, void *data) 451 453 { 452 454 int navail, bread; 453 455 char buf[4096]; 454 int rfd = d->fd;456 int rfd = g_io_channel_unix_get_fd(source); 455 457 char *err; 456 458 457 if (rfd<0) return; 459 /* TODO: Use g_io_channel_read_line? We'd have to be careful about 460 * blocking on the read. */ 461 462 if (rfd<0) return TRUE; 458 463 if (-1 == ioctl(rfd, FIONREAD, &navail)) { 459 return ;464 return TRUE; 460 465 } 461 466 /*owl_function_debugmsg("stderr_redirect: navail = %d\n", navail);*/ 462 if (navail <= 0) return ;467 if (navail <= 0) return TRUE; 463 468 if (navail > sizeof(buf)-1) { 464 469 navail = sizeof(buf)-1; … … 466 471 bread = read(rfd, buf, navail); 467 472 if (bread == -1) 468 return ;473 return TRUE; 469 474 470 475 err = g_strdup_printf("[stderr]\n%.*s", bread, buf); … … 472 477 owl_function_log_err(err); 473 478 g_free(err); 479 return TRUE; 474 480 } 475 481 … … 485 491 owl_options opts; 486 492 GSource *source; 487 488 if (!GLIB_CHECK_VERSION (2, 12, 0)) 489 g_error ("GLib version 2.12.0 or above is needed."); 493 GIOChannel *channel; 490 494 491 495 argc_copy = argc; … … 513 517 514 518 /* register STDIN dispatch; throw away return, we won't need it */ 515 owl_select_add_io_dispatch(STDIN_FILENO, OWL_IO_READ, &owl_process_input, NULL, NULL); 519 channel = g_io_channel_unix_new(STDIN_FILENO); 520 g_io_add_watch(channel, G_IO_IN | G_IO_HUP | G_IO_ERR, &owl_process_input, &g); 521 g_io_channel_unref(channel); 516 522 owl_zephyr_initialize(); 517 523 … … 519 525 /* Do this only after we've started curses up... */ 520 526 owl_function_debugmsg("startup: doing stderr redirection"); 521 owl_select_add_io_dispatch(stderr_replace(), OWL_IO_READ, &stderr_redirect_handler, NULL, NULL); 527 channel = g_io_channel_unix_new(stderr_replace()); 528 g_io_add_watch(channel, G_IO_IN | G_IO_HUP | G_IO_ERR, &stderr_redirect_handler, NULL); 529 g_io_channel_unref(channel); 522 530 #endif 523 531 -
owl.h
r33b6431b rd427f08 14 14 #include "compat/compat.h" 15 15 16 #ifdef HAVE_STDBOOL_H17 16 #include <stdbool.h> 18 #else19 #ifndef HAVE__BOOL20 #define _Bool signed char21 #endif22 #define bool _Bool23 #define false 024 #define true 125 #define __bool_true_false_are_defined 126 #endif /* HAVE_STDBOOL_H */27 17 28 18 #ifndef OWL_PERL 19 #define NCURSES_ENABLE_STDBOOL_H 1 29 20 #include <curses.h> 30 21 #include <panel.h> … … 130 121 #define OWL_MESSAGE_DIRECTION_IN 1 131 122 #define OWL_MESSAGE_DIRECTION_OUT 2 132 133 #define OWL_IO_READ 1134 #define OWL_IO_WRITE 2135 #define OWL_IO_EXCEPT 4136 123 137 124 #define OWL_DIRECTION_NONE 0 … … 242 229 void *pval_default; /* for types other and string */ 243 230 int ival_default; /* for types int and bool */ 244 c har *validsettings;/* documentation of valid settings */231 const char *validsettings; /* documentation of valid settings */ 245 232 char *summary; /* summary of usage */ 246 233 char *description; /* detailed description */ … … 264 251 * WARNING: this approach is hard to make 265 252 * thread-safe... */ 266 char *(*get_tostring_fn)(const struct _owl_variable *v, const void *val);253 char G_GNUC_WARN_UNUSED_RESULT *(*get_tostring_fn)(const struct _owl_variable *v, const void *val); 267 254 /* converts val to a string; 268 255 * caller must free the result */ … … 326 313 327 314 /* These don't take any context */ 328 char *(*cmd_args_fn)(int argc, const char *const *argv, const char *buff);315 char G_GNUC_WARN_UNUSED_RESULT *(*cmd_args_fn)(int argc, const char *const *argv, const char *buff); 329 316 /* takes argv and the full command as buff. 330 317 * caller must free return value if !NULL */ … … 333 320 334 321 /* The following also take the active context if it's valid */ 335 char *(*cmd_ctxargs_fn)(void *ctx, int argc, const char *const *argv, const char *buff);322 char G_GNUC_WARN_UNUSED_RESULT *(*cmd_ctxargs_fn)(void *ctx, int argc, const char *const *argv, const char *buff); 336 323 /* takes argv and the full command as buff. 337 324 * caller must free return value if !NULL */ … … 526 513 } owl_zbuddylist; 527 514 528 typedef struct _owl_timer {529 time_t time;530 int interval;531 void (*callback)(struct _owl_timer *, void *);532 void (*destroy)(struct _owl_timer *);533 void *data;534 char *name;535 } owl_timer;536 537 515 typedef struct _owl_errqueue { 538 516 owl_list errlist; … … 545 523 } owl_colorpair_mgr; 546 524 547 typedef struct _owl_io_dispatch {548 int fd; /* FD to watch for dispatch. */549 int mode;550 bool valid;551 int needs_gc;552 void (*callback)(const struct _owl_io_dispatch *, void *); /* C function to dispatch to. */553 void (*destroy)(const struct _owl_io_dispatch *); /* Destructor */554 void *data;555 GPollFD pollfd;556 } owl_io_dispatch;557 558 525 typedef struct _owl_popexec { 559 526 int refcount; … … 561 528 int winactive; 562 529 pid_t pid; /* or 0 if it has terminated */ 563 const owl_io_dispatch *dispatch;530 guint io_watch; 564 531 } owl_popexec; 565 532 … … 625 592 int pseudologin_notify; 626 593 struct termios startup_tio; 627 owl_list io_dispatch_list; 628 GList *timerlist; 629 owl_timer *aim_nop_timer; 594 guint aim_nop_timer; 630 595 int load_initial_subs; 631 596 FILE *debug_file; -
perl/lib/BarnOwl.pm
rf2d71cfa rbcde7926 29 29 use lib(get_config_dir() . "/lib"); 30 30 31 use Glib; 32 use AnyEvent; 33 31 34 use BarnOwl::Hook; 32 35 use BarnOwl::Hooks; … … 38 41 use BarnOwl::Completion; 39 42 use BarnOwl::Help; 40 use BarnOwl::AnyEvent;41 42 unshift @AnyEvent::REGISTRY, [BarnOwl => BarnOwl::AnyEvent::];43 require AnyEvent;44 43 45 44 use List::Util qw(max); … … 167 166 read from C<FD>. 168 167 169 C<add_dispatch> has been deprecated in favor of C<add_io_dispatch>, 170 and is now a wrapper for it called with C<mode> set to C<'r'>. 168 C<add_dispatch> has been deprecated in favor of C<AnyEvent>, and is 169 now a wrapper for C<add_io_dispatch> called with C<mode> set to 170 C<'r'>. 171 171 172 172 =cut … … 182 182 Remove a file descriptor previously registered via C<add_dispatch> 183 183 184 C<remove_dispatch> has been deprecated in favor of 185 C<remove_io_dispatch>. 184 C<remove_dispatch> has been deprecated in favor of C<AnyEvent>. 186 185 187 186 =cut … … 198 197 registered, the old one is removed. 199 198 200 =cut 199 C<add_io_dispatch> has been deprecated in favor of C<AnyEvent>. 200 201 =cut 202 203 our %_io_dispatches; 201 204 202 205 sub add_io_dispatch { … … 204 207 my $modeStr = shift; 205 208 my $cb = shift; 206 my $mode = 0; 207 208 $mode |= 0x1 if ($modeStr =~ /r/i); # Read 209 $mode |= 0x2 if ($modeStr =~ /w/i); # Write 210 if ($mode) { 211 $mode |= 0x4; # Exceptional 212 BarnOwl::Internal::add_io_dispatch($fd, $mode, $cb); 209 my @modes; 210 211 push @modes, 'r' if $modeStr =~ /r/i; # Read 212 push @modes, 'w' if $modeStr =~ /w/i; # Write 213 if (@modes) { 214 BarnOwl::remove_io_dispatch($fd); 215 for my $mode (@modes) { 216 push @{$_io_dispatches{$fd}}, AnyEvent->io(fh => $fd, 217 poll => $mode, 218 cb => $cb); 219 } 213 220 } else { 214 221 die("Invalid I/O Dispatch mode: $modeStr"); … … 219 226 220 227 Remove a file descriptor previously registered via C<add_io_dispatch> 228 229 C<remove_io_dispatch> has been deprecated in favor of C<AnyEvent>. 230 231 =cut 232 233 sub remove_io_dispatch { 234 my $fd = shift; 235 undef $_ foreach @{$_io_dispatches{$fd}}; 236 delete $_io_dispatches{$fd}; 237 } 221 238 222 239 =head2 create_style NAME OBJECT -
perl/lib/BarnOwl/Complete/Client.pm
rc6adf17 r58f4fb2 37 37 subs => undef, 38 38 terminal => undef, 39 timers => undef,40 39 variables => undef, 41 40 variable => \&complete_variable, -
perl/lib/BarnOwl/Timer.pm
rc6adf17 r074bdaa 3 3 4 4 package BarnOwl::Timer; 5 6 use AnyEvent; 5 7 6 8 sub new { … … 13 15 my $self = {cb => $cb}; 14 16 15 my $name = $args->{name};16 $name = "(unnamed)" unless defined $name;17 18 17 bless($self, $class); 19 18 20 $self->{timer} = BarnOwl::Internal::add_timer($args->{after} || 0, 21 $args->{interval} || 0, 22 $self, 23 $name); 19 $self->{timer} = AnyEvent->timer(%$args); 24 20 return $self; 25 21 } … … 27 23 sub stop { 28 24 my $self = shift; 29 if(defined($self->{timer})) { 30 BarnOwl::Internal::remove_timer($self->{timer}); 31 undef $self->{timer}; 32 } 25 undef $self->{timer}; 33 26 } 34 27 -
perl/modules/Jabber/lib/BarnOwl/Message/Jabber.pm
rb401ef2 ra27acf7 161 161 my ($recip, $account, $subject) = @_; 162 162 if (defined $recip) { 163 my @cmd = ('jwrite', $recip,'-a', $account);163 my @cmd = ('jwrite', '-a', $account); 164 164 if (defined $subject) { 165 165 push @cmd, '-s', $subject; 166 166 } 167 push @cmd, '--', $recip; 167 168 return BarnOwl::quote(@cmd); 168 169 } else { -
perlconfig.c
r3b8a563 rd427f08 23 23 24 24 25 SV *owl_new_sv(const char * str)25 G_GNUC_WARN_UNUSED_RESULT SV *owl_new_sv(const char * str) 26 26 { 27 27 SV *ret = newSVpv(str, 0); … … 36 36 } 37 37 38 AV *owl_new_av(const owl_list *l, SV *(*to_sv)(const void *))38 G_GNUC_WARN_UNUSED_RESULT AV *owl_new_av(const owl_list *l, SV *(*to_sv)(const void *)) 39 39 { 40 40 AV *ret; … … 52 52 } 53 53 54 HV *owl_new_hv(const owl_dict *d, SV *(*to_sv)(const void *))54 G_GNUC_WARN_UNUSED_RESULT HV *owl_new_hv(const owl_dict *d, SV *(*to_sv)(const void *)) 55 55 { 56 56 HV *ret; … … 75 75 } 76 76 77 SV *owl_perlconfig_message2hashref(const owl_message *m)77 G_GNUC_WARN_UNUSED_RESULT SV *owl_perlconfig_message2hashref(const owl_message *m) 78 78 { 79 79 HV *h, *stash; … … 165 165 } 166 166 167 SV *owl_perlconfig_curmessage2hashref(void)167 G_GNUC_WARN_UNUSED_RESULT SV *owl_perlconfig_curmessage2hashref(void) 168 168 { 169 169 int curmsg; … … 183 183 This has been somewhat addressed, but is still not lossless. 184 184 */ 185 owl_message *owl_perlconfig_hashref2message(SV *msg)185 G_GNUC_WARN_UNUSED_RESULT owl_message *owl_perlconfig_hashref2message(SV *msg) 186 186 { 187 187 owl_message * m; … … 215 215 owl_message_set_zwriteline(m, val); 216 216 } else if (!strcmp(key, "time")) { 217 g_free(m->timestr); 217 218 m->timestr = g_strdup(val); 218 219 strptime(val, "%a %b %d %T %Y", &tm); … … 250 251 /* Calls in a scalar context, passing it a hash reference. 251 252 If return value is non-null, caller must free. */ 252 char *owl_perlconfig_call_with_message(const char *subname, const owl_message *m)253 G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_call_with_message(const char *subname, const owl_message *m) 253 254 { 254 255 dSP ; … … 299 300 If the return value is non-null, the caller must free it. 300 301 */ 301 char * owl_perlconfig_message_call_method(const owl_message *m, const char *method, int argc, const char **argv)302 G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_message_call_method(const owl_message *m, const char *method, int argc, const char **argv) 302 303 { 303 304 dSP; … … 348 349 } 349 350 350 351 char *owl_perlconfig_initperl(const char * file, int *Pargc, char ***Pargv, char ***Penv)351 /* caller must free result, if not NULL */ 352 G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_initperl(const char *file, int *Pargc, char ***Pargv, char ***Penv) 352 353 { 353 354 int ret; … … 435 436 436 437 /* caller is responsible for freeing returned string */ 437 char *owl_perlconfig_execute(const char *line)438 G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_execute(const char *line) 438 439 { 439 440 STRLEN len; … … 492 493 PUTBACK; 493 494 494 call_pv("BarnOwl::Hooks::_new_command", G_ SCALAR|G_VOID|G_EVAL);495 call_pv("BarnOwl::Hooks::_new_command", G_VOID|G_EVAL); 495 496 496 497 SPAGAIN; … … 504 505 } 505 506 506 char *owl_perlconfig_perlcmd(const owl_cmd *cmd, int argc, const char *const *argv) 507 /* caller must free the result */ 508 G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_perlcmd(const owl_cmd *cmd, int argc, const char *const *argv) 507 509 { 508 510 int i, count; … … 547 549 } 548 550 549 void owl_perlconfig_io_dispatch_destroy(const owl_io_dispatch *d)550 {551 SvREFCNT_dec(d->data);552 }553 554 551 void owl_perlconfig_edit_callback(owl_editwin *e) 555 552 { … … 586 583 SvREFCNT_dec(v); 587 584 } 588 589 void owl_perlconfig_io_dispatch(const owl_io_dispatch *d, void *data)590 {591 SV *cb = data;592 dSP;593 if(cb == NULL) {594 owl_function_error("Perl callback is NULL!");595 return;596 }597 598 ENTER;599 SAVETMPS;600 601 PUSHMARK(SP);602 PUTBACK;603 604 call_sv(cb, G_DISCARD|G_EVAL);605 606 if(SvTRUE(ERRSV)) {607 owl_function_error("%s", SvPV_nolen(ERRSV));608 }609 610 FREETMPS;611 LEAVE;612 }613 614 void owl_perlconfig_perl_timer(owl_timer *t, void *data)615 {616 dSP;617 SV *obj = data;618 619 if(!SvROK(obj)) {620 return;621 }622 623 ENTER;624 SAVETMPS;625 626 PUSHMARK(SP);627 XPUSHs(obj);628 PUTBACK;629 630 call_method("do_callback", G_DISCARD|G_EVAL);631 632 SPAGAIN;633 634 if (SvTRUE(ERRSV)) {635 owl_function_error("Error in callback: '%s'", SvPV_nolen(ERRSV));636 sv_setsv (ERRSV, &PL_sv_undef);637 }638 639 PUTBACK;640 FREETMPS;641 LEAVE;642 }643 644 void owl_perlconfig_perl_timer_destroy(owl_timer *t)645 {646 if(SvOK((SV*)t->data)) {647 SvREFCNT_dec((SV*)t->data);648 }649 } -
perlglue.xs
r3b8a563 rbcde7926 326 326 g_free(rv); 327 327 328 void329 remove_io_dispatch(fd)330 int fd331 CODE:332 owl_select_remove_perl_io_dispatch(fd);333 334 328 AV* 335 329 all_filters() … … 507 501 ival); 508 502 509 void510 add_io_dispatch(fd, mode, cb)511 int fd512 int mode513 SV * cb514 CODE:515 owl_select_add_perl_io_dispatch(fd, mode, newSVsv(cb));516 517 IV518 add_timer(after, interval, cb, name = NULL)519 int after520 int interval521 SV *cb522 const char *name523 PREINIT:524 SV *ref;525 owl_timer *t;526 CODE:527 ref = sv_rvweaken(newSVsv(cb));528 t = owl_select_add_timer(name,529 after,530 interval,531 owl_perlconfig_perl_timer,532 owl_perlconfig_perl_timer_destroy,533 ref);534 owl_function_debugmsg("Created timer %s: %p", t->name ? t->name : "(unnamed)", t);535 RETVAL = (IV)t;536 OUTPUT:537 RETVAL538 539 void540 remove_timer(timer)541 IV timer542 PREINIT:543 owl_timer *t;544 CODE:545 t = (owl_timer*)timer;546 owl_function_debugmsg("Freeing timer %s: %p", t->name ? t->name : "(unnamed)", t);547 owl_select_remove_timer(t);548 549 503 MODULE = BarnOwl PACKAGE = BarnOwl::Editwin 550 504 -
popexec.c
r47e0a6a re146cd7 16 16 int pipefds[2], child_write_fd, parent_read_fd; 17 17 pid_t pid; 18 GIOChannel *channel; 18 19 19 20 if (owl_global_get_popwin(&g) || owl_global_get_viewwin(&g)) { … … 54 55 pe->pid=pid; 55 56 pe->winactive=1; 56 pe->dispatch = owl_select_add_io_dispatch(parent_read_fd, OWL_IO_READ|OWL_IO_EXCEPT, &owl_popexec_inputhandler, &owl_popexec_delete_dispatch, pe); 57 channel = g_io_channel_unix_new(parent_read_fd); 58 g_io_channel_set_close_on_unref(channel, TRUE); 59 pe->io_watch = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, 60 G_IO_IN | G_IO_ERR | G_IO_HUP, 61 owl_popexec_inputhandler, pe, 62 (GDestroyNotify)owl_popexec_unref); 63 g_io_channel_unref(channel); 57 64 pe->refcount++; 58 65 } else { … … 75 82 } 76 83 77 void owl_popexec_inputhandler(const owl_io_dispatch *d, void *data)84 gboolean owl_popexec_inputhandler(GIOChannel *source, GIOCondition condition, void *data) 78 85 { 79 86 owl_popexec *pe = data; … … 81 88 char *buf; 82 89 int status; 90 int fd = g_io_channel_unix_get_fd(source); 83 91 84 if (!pe) return; 92 /* TODO: Reading from GIOChannel may be more convenient. */ 93 94 if (!pe) return FALSE; 85 95 86 96 /* If pe->winactive is 0 then the vwin has closed. … … 96 106 /* the viewwin has closed */ 97 107 if (!pe->pid && !pe->winactive) { 98 owl_select_remove_io_dispatch(d); 99 pe->dispatch = NULL; 100 return; 108 pe->io_watch = 0; 109 return FALSE; 101 110 } 102 111 103 if (0 != (rv_navail = ioctl( d->fd, FIONREAD, &navail))) {112 if (0 != (rv_navail = ioctl(fd, FIONREAD, &navail))) { 104 113 owl_function_debugmsg("ioctl error"); 105 114 } … … 113 122 owl_viewwin_append_text(pe->vwin, "\n"); 114 123 } 115 owl_select_remove_io_dispatch(d); 116 pe->dispatch = NULL; 117 return; 124 pe->io_watch = 0; 125 return FALSE; 118 126 } 119 127 120 if ( d->fd<0 || !pe->pid || !pe->winactive || rv_navail) {128 if (fd<0 || !pe->pid || !pe->winactive || rv_navail) { 121 129 owl_function_error("popexec should not have reached this point"); 122 return ;130 return FALSE; 123 131 } 124 132 125 if (navail<=0) return ;133 if (navail<=0) return TRUE; 126 134 if (navail>1024) { navail = 1024; } 127 135 buf = g_new(char, navail+1); 128 136 owl_function_debugmsg("about to read %d", navail); 129 bread = read( d->fd, buf, navail);137 bread = read(fd, buf, navail); 130 138 if (bread<0) { 131 139 perror("read"); … … 140 148 } 141 149 g_free(buf); 142 143 } 144 145 void owl_popexec_delete_dispatch(const owl_io_dispatch *d) 146 { 147 owl_popexec *pe = d->data; 148 close(d->fd); 149 owl_popexec_unref(pe); 150 return TRUE; 150 151 } 151 152 … … 156 157 157 158 pe->winactive = 0; 158 if (pe-> dispatch) {159 owl_select_remove_io_dispatch(pe->dispatch);160 pe-> dispatch = NULL;159 if (pe->io_watch) { 160 g_source_remove(pe->io_watch); 161 pe->io_watch = 0; 161 162 } 162 163 if (pe->pid) { -
popwin.c
rddbbcffa rd427f08 1 1 #include "owl.h" 2 2 3 owl_popwin *owl_popwin_new(void)3 G_GNUC_WARN_UNUSED_RESULT owl_popwin *owl_popwin_new(void) 4 4 { 5 5 owl_popwin *pw = g_new0(owl_popwin, 1); -
regex.c
rd4927a7 rd427f08 39 39 { 40 40 char *quoted; 41 int ret; 41 42 42 quoted =owl_text_quote(string, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);43 owl_regex_create(re, quoted);43 quoted = owl_text_quote(string, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH); 44 ret = owl_regex_create(re, quoted); 44 45 g_free(quoted); 45 return (0);46 return ret; 46 47 } 47 48 -
scripts/locker-build
r0fd5bd5 r4f5e38f 102 102 esac 103 103 104 C FLAGS="-I$BARNOWL/include" \105 LDFLAGS="-L$BARNOWL/lib $opt_rpath$BARNOWL/lib" \104 CPPFLAGS="-I$BARNOWL/include -I/usr/athena/include" \ 105 LDFLAGS="-L$BARNOWL/lib -L/usr/athena/lib $opt_rpath$BARNOWL/lib" \ 106 106 ./configure --exec-prefix="/mit/barnowl/arch/$ATHENA_SYS" \ 107 107 --prefix="/mit/barnowl/builds/barnowl-$VERS" --mandir=/mit/barnowl/man \ -
select.c
r44976fe r84a071f 2 2 3 3 static GMainLoop *loop = NULL; 4 static GMainContext *main_context;5 static int dispatch_active = 0;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) {11 return t1->time - t2->time;12 }13 14 owl_timer *owl_select_add_timer(const char* name, int after, int interval, void (*cb)(owl_timer *, void *), void (*destroy)(owl_timer*), void *data)15 {16 owl_timer *t = g_new(owl_timer, 1);17 GList **timers = owl_global_get_timerlist(&g);18 19 t->time = time(NULL) + after;20 t->interval = interval;21 t->callback = cb;22 t->destroy = destroy;23 t->data = data;24 t->name = name ? g_strdup(name) : NULL;25 26 *timers = g_list_insert_sorted(*timers, t,27 (GCompareFunc)_owl_select_timer_cmp);28 return t;29 }30 31 void owl_select_remove_timer(owl_timer *t)32 {33 GList **timers = owl_global_get_timerlist(&g);34 if (t && g_list_find(*timers, t)) {35 *timers = g_list_remove(*timers, t);36 if(t->destroy) {37 t->destroy(t);38 }39 g_free(t->name);40 g_free(t);41 }42 }43 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 cool49 * 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 cool73 * 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 cool90 * 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? */94 while(*timers) {95 owl_timer *t = (*timers)->data;96 int remove = 0;97 98 if(t->time > now.tv_sec)99 break;100 101 /* Reschedule if appropriate */102 if(t->interval > 0) {103 t->time = now.tv_sec + t->interval;104 *timers = g_list_remove(*timers, t);105 *timers = g_list_insert_sorted(*timers, t,106 (GCompareFunc)_owl_select_timer_cmp);107 } else {108 remove = 1;109 }110 111 /* Do the callback */112 t->callback(t, t->data);113 if(remove) {114 owl_select_remove_timer(t);115 }116 }117 return TRUE;118 }119 120 static GSourceFuncs owl_timer_funcs = {121 owl_timer_prepare,122 owl_timer_check,123 owl_timer_dispatch,124 NULL125 };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)129 {130 int i, len;131 const owl_list *dl;132 owl_io_dispatch *d;133 dl = owl_global_get_io_dispatch_list(&g);134 len = owl_list_get_size(dl);135 for(i = 0; i < len; i++) {136 d = owl_list_get_element(dl, i);137 if (d->fd == fd && d->valid) return d;138 }139 return NULL;140 }141 142 static int owl_select_find_io_dispatch(const owl_io_dispatch *in)143 {144 int i, len;145 const owl_list *dl;146 147 if (in != NULL) {148 dl = owl_global_get_io_dispatch_list(&g);149 len = owl_list_get_size(dl);150 for(i = 0; i < len; i++) {151 const owl_io_dispatch *d = owl_list_get_element(dl, i);152 if (d == in) return i;153 }154 }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);164 }165 166 void owl_select_remove_io_dispatch(const owl_io_dispatch *in)167 {168 int elt;169 if (in != NULL) {170 elt = owl_select_find_io_dispatch(in);171 if (elt != -1) {172 owl_list *dl = owl_global_get_io_dispatch_list(&g);173 owl_io_dispatch *d = owl_list_get_element(dl, elt);174 if (dispatch_active)175 d->needs_gc = 1;176 else {177 owl_select_invalidate_io_dispatch(d);178 owl_list_remove_element(dl, elt);179 if (d->destroy)180 d->destroy(d);181 g_free(d);182 }183 }184 }185 }186 187 static void owl_select_io_dispatch_gc(void)188 {189 int i;190 owl_list *dl;191 192 dl = owl_global_get_io_dispatch_list(&g);193 /*194 * Count down so we aren't set off by removing items from the list195 * during the iteration.196 */197 for(i = owl_list_get_size(dl) - 1; i >= 0; i--) {198 owl_io_dispatch *d = owl_list_get_element(dl, i);199 if(d->needs_gc) {200 owl_select_remove_io_dispatch(d);201 }202 }203 }204 205 /* Each FD may have at most one valid dispatcher.206 * If a new dispatch is added for an FD, the old one is removed.207 * mode determines what types of events are watched for, and may be any combination of:208 * OWL_IO_READ, OWL_IO_WRITE, OWL_IO_EXCEPT209 */210 const owl_io_dispatch *owl_select_add_io_dispatch(int fd, int mode, void (*cb)(const owl_io_dispatch *, void *), void (*destroy)(const owl_io_dispatch *), void *data)211 {212 owl_io_dispatch *d = g_new(owl_io_dispatch, 1);213 owl_list *dl = owl_global_get_io_dispatch_list(&g);214 owl_io_dispatch *other;215 216 d->fd = fd;217 d->valid = true;218 d->needs_gc = 0;219 d->mode = mode;220 d->callback = cb;221 d->destroy = destroy;222 d->data = data;223 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);239 owl_list_append_element(dl, d);240 241 return d;242 }243 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);274 len = owl_list_get_size(dl);275 for (i = 0; i < len; i++) {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) {279 d->callback(d, d->data);280 }281 }282 dispatch_active = 0;283 owl_select_io_dispatch_gc();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 NULL293 };294 295 int owl_select_add_perl_io_dispatch(int fd, int mode, SV *cb)296 {297 const owl_io_dispatch *d = owl_select_find_valid_io_dispatch_by_fd(fd);298 if (d != NULL && d->callback != owl_perlconfig_io_dispatch) {299 /* Don't mess with non-perl dispatch functions from here. */300 return 1;301 }302 /* Also remove any invalidated perl dispatch functions that may have303 * stuck around. */304 owl_select_remove_perl_io_dispatch(fd);305 owl_select_add_io_dispatch(fd, mode, owl_perlconfig_io_dispatch, owl_perlconfig_io_dispatch_destroy, cb);306 return 0;307 }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 324 int owl_select_remove_perl_io_dispatch(int fd)325 {326 owl_io_dispatch *d = owl_select_find_perl_io_dispatch(fd);327 if (d != NULL) {328 /* Only remove perl io dispatchers from here. */329 owl_select_remove_io_dispatch(d);330 return 0;331 }332 return 1;333 }334 4 335 5 void owl_select_init(void) 336 6 { 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);342 7 } 343 8 344 9 void owl_select_run_loop(void) 345 10 { 346 main_context = g_main_context_default(); 347 loop = g_main_loop_new(main_context, FALSE); 11 loop = g_main_loop_new(NULL, FALSE); 348 12 g_main_loop_run(loop); 349 13 } … … 353 17 if (loop) { 354 18 g_main_loop_quit(loop); 19 g_main_loop_unref(loop); 355 20 loop = NULL; 356 21 } -
tester.c
r4c7c21f r4e37d56 32 32 char *perlerr; 33 33 int status = 0; 34 SCREEN *screen; 34 35 35 36 if (argc <= 1) { … … 41 42 wnull = fopen("/dev/null", "w"); 42 43 rnull = fopen("/dev/null", "r"); 43 newterm("xterm", wnull, rnull);44 screen = newterm("xterm", wnull, rnull); 44 45 /* initialize global structures */ 45 46 owl_global_init(&g); … … 91 92 /* probably not necessary, but tear down the screen */ 92 93 endwin(); 94 delscreen(screen); 93 95 fclose(rnull); 94 96 fclose(wnull); … … 218 220 owl_string_appendf_quoted(g, "%q foo %q%q %s %", "hello", "world is", "can't"); 219 221 FAIL_UNLESS("owl_string_appendf", 220 !strcmp(g _string_free(g, false),221 "hello foo 'world is'\"can't\" %s %"));222 !strcmp(g->str, "hello foo 'world is'\"can't\" %s %")); 223 g_string_free(g, true); 222 224 223 225 /* if (numfailed) printf("*** WARNING: failures encountered with owl_util\n"); */ … … 230 232 owl_list l; 231 233 int numfailed=0; 232 char *av="aval", *bv="bval", *cv="cval", *dv="dval"; 234 char *av = g_strdup("aval"), *bv = g_strdup("bval"), *cv = g_strdup("cval"), 235 *dv = g_strdup("dval"); 233 236 234 237 printf("# BEGIN testing owl_dict\n"); … … 259 262 owl_list_cleanup(&l, g_free); 260 263 owl_dict_cleanup(&d, NULL); 264 265 g_free(av); 266 g_free(bv); 267 g_free(cv); 268 g_free(dv); 261 269 262 270 /* if (numfailed) printf("*** WARNING: failures encountered with owl_dict\n"); */ -
text.c
r7865479 rd427f08 7 7 /* Returns a copy of 'in' with each line indented 'n' 8 8 * characters. Result must be freed with g_free. */ 9 char *owl_text_indent(const char *in, int n)9 G_GNUC_WARN_UNUSED_RESULT char *owl_text_indent(const char *in, int n) 10 10 { 11 11 const char *ptr1, *ptr2, *last; … … 48 48 49 49 /* caller must free the return */ 50 char *owl_text_htmlstrip(const char *in)50 G_GNUC_WARN_UNUSED_RESULT char *owl_text_htmlstrip(const char *in) 51 51 { 52 52 const char *ptr1, *end, *ptr2, *ptr3; … … 129 129 130 130 /* Caller must free return */ 131 char *owl_text_expand_tabs(const char *in)131 G_GNUC_WARN_UNUSED_RESULT char *owl_text_expand_tabs(const char *in) 132 132 { 133 133 int len = 0; … … 188 188 189 189 /* caller must free the return */ 190 char *owl_text_wordwrap(const char *in, int col)190 G_GNUC_WARN_UNUSED_RESULT char *owl_text_wordwrap(const char *in, int col) 191 191 { 192 192 char *out; … … 269 269 * Caller must free returned string. 270 270 */ 271 char *owl_text_substitute(const char *in, const char *from, const char *to)271 G_GNUC_WARN_UNUSED_RESULT char *owl_text_substitute(const char *in, const char *from, const char *to) 272 272 { 273 273 char **split = g_strsplit(in, from, 0), *out; … … 284 284 * On success returns the string, on error returns NULL. 285 285 */ 286 char *owl_text_quote(const char *in, const char *toquote, const char *quotestr)286 G_GNUC_WARN_UNUSED_RESULT char *owl_text_quote(const char *in, const char *toquote, const char *quotestr) 287 287 { 288 288 int i, x, r, place, escape; -
util.c
r9efa5bd rd427f08 35 35 * duplicate slashes are removed. Caller must free the return. 36 36 */ 37 char *owl_util_makepath(const char *in)37 G_GNUC_WARN_UNUSED_RESULT char *owl_util_makepath(const char *in) 38 38 { 39 39 int i, j, x; … … 102 102 to -1, argv will be NULL and the caller does not need to free anything. The 103 103 returned vector is NULL-terminated. */ 104 char **owl_parseline(const char *line, int *argc)104 G_GNUC_WARN_UNUSED_RESULT char **owl_parseline(const char *line, int *argc) 105 105 { 106 106 GPtrArray *argv; … … 245 245 } 246 246 247 char *owl_string_build_quoted(const char *tmpl, ...)247 G_GNUC_WARN_UNUSED_RESULT char *owl_string_build_quoted(const char *tmpl, ...) 248 248 { 249 249 GString *buf = g_string_new(""); … … 257 257 /* Returns a quoted version of arg suitable for placing in a 258 258 * command-line. Result should be freed with g_free. */ 259 char *owl_arg_quote(const char *arg)259 G_GNUC_WARN_UNUSED_RESULT char *owl_arg_quote(const char *arg) 260 260 { 261 261 GString *buf = g_string_new("");; … … 265 265 266 266 /* caller must free the return */ 267 char *owl_util_minutes_to_timestr(int in)267 G_GNUC_WARN_UNUSED_RESULT char *owl_util_minutes_to_timestr(int in) 268 268 { 269 269 int days, hours; … … 331 331 332 332 /* Get the default tty name. Caller must free the return */ 333 char *owl_util_get_default_tty(void)333 G_GNUC_WARN_UNUSED_RESULT char *owl_util_get_default_tty(void) 334 334 { 335 335 const char *tmp; … … 353 353 * return. 354 354 */ 355 char *owl_util_stripnewlines(const char *in)355 G_GNUC_WARN_UNUSED_RESULT char *owl_util_stripnewlines(const char *in) 356 356 { 357 357 … … 384 384 * Error conditions are the same as g_file_read_link. 385 385 */ 386 gchar *owl_util_recursive_resolve_link(const char *filename)386 G_GNUC_WARN_UNUSED_RESULT gchar *owl_util_recursive_resolve_link(const char *filename) 387 387 { 388 388 gchar *last_path = g_strdup(filename); … … 455 455 g_free(newfile); 456 456 fclose(old); 457 free(actual_filename);457 g_free(actual_filename); 458 458 return -1; 459 459 } … … 466 466 g_free(newfile); 467 467 fclose(old); 468 free(actual_filename);468 g_free(actual_filename); 469 469 return -1; 470 470 } … … 511 511 The caller is responsible for freeing the allocated string. 512 512 */ 513 char * owl_util_baseclass(const char *class)513 G_GNUC_WARN_UNUSED_RESULT char *owl_util_baseclass(const char *class) 514 514 { 515 515 char *start, *end; … … 546 546 547 547 /* Strips format characters from a valid utf-8 string. Returns the 548 empty string if 'in' does not validate. */549 char *owl_strip_format_chars(const char *in)548 empty string if 'in' does not validate. Caller must free the return. */ 549 G_GNUC_WARN_UNUSED_RESULT char *owl_strip_format_chars(const char *in) 550 550 { 551 551 char *r; … … 584 584 * out characters in Unicode Plane 16, as we use that plane internally 585 585 * for formatting. 586 */ 587 char * owl_validate_or_convert(const char *in) 586 * Caller must free the return. 587 */ 588 G_GNUC_WARN_UNUSED_RESULT char *owl_validate_or_convert(const char *in) 588 589 { 589 590 if (g_utf8_validate(in, -1, NULL)) { … … 599 600 * Validate 'in' as UTF-8, and either return a copy of it, or an empty 600 601 * string if it is invalid utf-8. 601 */ 602 char * owl_validate_utf8(const char *in) 602 * Caller must free the return. 603 */ 604 G_GNUC_WARN_UNUSED_RESULT char *owl_validate_utf8(const char *in) 603 605 { 604 606 char *out; … … 632 634 } 633 635 634 char *owl_escape_highbit(const char *str) 636 /* caller must free the return */ 637 G_GNUC_WARN_UNUSED_RESULT char *owl_escape_highbit(const char *str) 635 638 { 636 639 GString *out = g_string_new(""); … … 695 698 696 699 /* Read the rest of the input available in fp into a string. */ 697 char *owl_slurp(FILE *fp)700 G_GNUC_WARN_UNUSED_RESULT char *owl_slurp(FILE *fp) 698 701 { 699 702 char *buf = NULL; -
variable.c
r4c7c21f rd427f08 7 7 8 8 #define OWLVAR_BOOL(name,default,summary,description) \ 9 { name, OWL_VARIABLE_BOOL, NULL, default, "on,off", summary,description, NULL, \9 { g_strdup(name), OWL_VARIABLE_BOOL, NULL, default, "on,off", g_strdup(summary), g_strdup(description), NULL, \ 10 10 NULL, NULL, NULL, NULL, NULL, NULL } 11 11 12 12 #define OWLVAR_BOOL_FULL(name,default,summary,description,validate,set,get) \ 13 { name, OWL_VARIABLE_BOOL, NULL, default, "on,off", summary,description, NULL, \13 { g_strdup(name), OWL_VARIABLE_BOOL, NULL, default, "on,off", g_strdup(summary), g_strdup(description), NULL, \ 14 14 validate, set, NULL, get, NULL, NULL } 15 15 16 16 #define OWLVAR_INT(name,default,summary,description) \ 17 { name, OWL_VARIABLE_INT, NULL, default, "<int>", summary,description, NULL, \17 { g_strdup(name), OWL_VARIABLE_INT, NULL, default, "<int>", g_strdup(summary), g_strdup(description), NULL, \ 18 18 NULL, NULL, NULL, NULL, NULL, NULL } 19 19 20 20 #define OWLVAR_INT_FULL(name,default,summary,description,validset,validate,set,get) \ 21 { name, OWL_VARIABLE_INT, NULL, default, validset, summary,description, NULL, \21 { g_strdup(name), OWL_VARIABLE_INT, NULL, default, validset, g_strdup(summary), g_strdup(description), NULL, \ 22 22 validate, set, NULL, get, NULL, NULL } 23 23 24 24 #define OWLVAR_PATH(name,default,summary,description) \ 25 { name, OWL_VARIABLE_STRING, default, 0, "<path>", summary,description, NULL, \25 { g_strdup(name), OWL_VARIABLE_STRING, g_strdup(default), 0, "<path>", g_strdup(summary), g_strdup(description), NULL, \ 26 26 NULL, NULL, NULL, NULL, NULL, NULL } 27 27 28 28 #define OWLVAR_STRING(name,default,summary,description) \ 29 { name, OWL_VARIABLE_STRING, default, 0, "<string>", summary,description, NULL, \29 { g_strdup(name), OWL_VARIABLE_STRING, g_strdup(default), 0, "<string>", g_strdup(summary), g_strdup(description), NULL, \ 30 30 NULL, NULL, NULL, NULL, NULL, NULL } 31 31 32 32 #define OWLVAR_STRING_FULL(name,default,validset,summary,description,validate,set,get) \ 33 { name, OWL_VARIABLE_STRING, default, 0, validset, summary,description, NULL, \33 { g_strdup(name), OWL_VARIABLE_STRING, g_strdup(default), 0, validset, g_strdup(summary), g_strdup(description), NULL, \ 34 34 validate, set, NULL, get, NULL, NULL } 35 35 … … 38 38 * correspond to the values that may be specified. */ 39 39 #define OWLVAR_ENUM(name,default,summary,description,validset) \ 40 { name, OWL_VARIABLE_INT, NULL, default, validset, summary,description, NULL, \40 { g_strdup(name), OWL_VARIABLE_INT, NULL, default, validset, g_strdup(summary), g_strdup(description), NULL, \ 41 41 owl_variable_enum_validate, \ 42 42 NULL, owl_variable_enum_set_fromstring, \ … … 45 45 46 46 #define OWLVAR_ENUM_FULL(name,default,summary,description,validset,validate, set, get) \ 47 { name, OWL_VARIABLE_INT, NULL, default, validset, summary,description, NULL, \47 { g_strdup(name), OWL_VARIABLE_INT, NULL, default, validset, g_strdup(summary), g_strdup(description), NULL, \ 48 48 validate, \ 49 49 set, owl_variable_enum_set_fromstring, \ … … 51 51 NULL } 52 52 53 static owl_variable variables_to_init[] = { 53 int owl_variable_add_defaults(owl_vardict *vd) 54 { 55 owl_variable variables_to_init[] = { 54 56 55 57 OWLVAR_STRING( "personalbell" /* %OwlVarStub */, "off", … … 439 441 NULL, NULL, NULL, NULL, NULL, NULL } 440 442 441 }; 443 }; 444 445 int ret = owl_variable_dict_add_from_list(vd, variables_to_init); 446 owl_variable *var; 447 for (var = variables_to_init; var->name != NULL; var++) 448 owl_variable_cleanup(var); 449 return ret; 450 } 442 451 443 452 /**************************************************************************/ … … 495 504 int owl_variable_pseudologins_set(owl_variable *v, const void *newval) 496 505 { 497 static owl_timer *timer = NULL;506 static guint timer = 0; 498 507 if (newval) { 499 508 if (*(const int*)newval == 1) { 500 509 owl_function_zephyr_buddy_check(0); 501 if (timer == NULL) { 502 timer = owl_select_add_timer("owl_zephyr_buddycheck_timer", 503 180, 180, owl_zephyr_buddycheck_timer, NULL, NULL); 510 if (timer == 0) { 511 timer = g_timeout_add_seconds(180, owl_zephyr_buddycheck_timer, NULL); 504 512 } 505 513 } else { 506 if (timer != NULL) {507 owl_select_remove_timer(timer);508 timer = NULL;514 if (timer != 0) { 515 g_source_remove(timer); 516 timer = 0; 509 517 } 510 518 } … … 558 566 559 567 int owl_variable_dict_setup(owl_vardict *vd) { 568 owl_dict_create(vd); 569 return owl_variable_add_defaults(vd); 570 } 571 572 int owl_variable_dict_add_from_list(owl_vardict *vd, owl_variable *variables_to_init) 573 { 560 574 owl_variable *var, *cur; 561 owl_dict_create(vd);562 575 for (var = variables_to_init; var->name != NULL; var++) { 563 576 cur = g_new(owl_variable, 1); … … 584 597 if (!cur->delete_fn) 585 598 cur->delete_fn = owl_variable_delete_default; 599 cur->pval_default = g_strdup(var->pval_default); 586 600 cur->set_fn(cur, cur->pval_default); 587 601 break; … … 632 646 } 633 647 634 owl_variable * owl_variable_newvar(const char *name, const char *summary, const char * description) { 648 G_GNUC_WARN_UNUSED_RESULT owl_variable *owl_variable_newvar(const char *name, const char *summary, const char *description) 649 { 635 650 owl_variable * var = g_new0(owl_variable, 1); 636 651 var->name = g_strdup(name); … … 718 733 } 719 734 720 void owl_variable_ delete(owl_variable *v)735 void owl_variable_cleanup(owl_variable *v) 721 736 { 722 737 if (v->delete_fn) v->delete_fn(v); … … 724 739 g_free(v->summary); 725 740 g_free(v->description); 741 if (v->type == OWL_VARIABLE_STRING) 742 g_free(v->pval_default); 743 } 744 745 void owl_variable_delete(owl_variable *v) 746 { 747 owl_variable_cleanup(v); 726 748 g_free(v); 727 749 } … … 803 825 } 804 826 805 char *owl_variable_get_tostring(const owl_vardict *d, const char *name) { 827 G_GNUC_WARN_UNUSED_RESULT char *owl_variable_get_tostring(const owl_vardict *d, const char *name) 828 { 806 829 owl_variable *v; 807 830 if (!name) return NULL; … … 811 834 } 812 835 813 char *owl_variable_get_default_tostring(const owl_vardict *d, const char *name) { 836 G_GNUC_WARN_UNUSED_RESULT char *owl_variable_get_default_tostring(const owl_vardict *d, const char *name) 837 { 814 838 owl_variable *v; 815 839 if (!name) return NULL; … … 971 995 } 972 996 973 char *owl_variable_bool_get_tostring_default(const owl_variable *v, const void *val) { 997 G_GNUC_WARN_UNUSED_RESULT char *owl_variable_bool_get_tostring_default(const owl_variable *v, const void *val) 998 { 974 999 if (val == NULL) { 975 1000 return g_strdup("<null>"); … … 1006 1031 } 1007 1032 1008 char *owl_variable_int_get_tostring_default(const owl_variable *v, const void *val) { 1033 G_GNUC_WARN_UNUSED_RESULT char *owl_variable_int_get_tostring_default(const owl_variable *v, const void *val) 1034 { 1009 1035 if (val == NULL) { 1010 1036 return g_strdup("<null>"); … … 1045 1071 } 1046 1072 1047 char *owl_variable_enum_get_tostring(const owl_variable *v, const void *val) { 1073 G_GNUC_WARN_UNUSED_RESULT char *owl_variable_enum_get_tostring(const owl_variable *v, const void *val) 1074 { 1048 1075 char **enums; 1049 1076 int nenums, i; … … 1085 1112 } 1086 1113 1087 char *owl_variable_string_get_tostring_default(const owl_variable *v, const void *val) { 1114 G_GNUC_WARN_UNUSED_RESULT char *owl_variable_string_get_tostring_default(const owl_variable *v, const void *val) 1115 { 1088 1116 if (val == NULL) { 1089 1117 return g_strdup("<null>"); -
viewwin.c
r4fd211f rd427f08 12 12 * will be used by the viewwin 13 13 */ 14 owl_viewwin *owl_viewwin_new_text(owl_window *win, const char *text)14 G_GNUC_WARN_UNUSED_RESULT owl_viewwin *owl_viewwin_new_text(owl_window *win, const char *text) 15 15 { 16 16 owl_viewwin *v = g_new0(owl_viewwin, 1); … … 34 34 * will be used by the viewwin 35 35 */ 36 owl_viewwin *owl_viewwin_new_fmtext(owl_window *win, const owl_fmtext *fmtext)36 G_GNUC_WARN_UNUSED_RESULT owl_viewwin *owl_viewwin_new_fmtext(owl_window *win, const owl_fmtext *fmtext) 37 37 { 38 38 char *text; … … 237 237 } 238 238 239 owl_editwin *owl_viewwin_set_typwin_active(owl_viewwin *v, owl_history *hist) {239 G_GNUC_WARN_UNUSED_RESULT owl_editwin *owl_viewwin_set_typwin_active(owl_viewwin *v, owl_history *hist) { 240 240 int lines, cols; 241 241 owl_editwin *cmdline; -
window.c
rf97c1a6 rd427f08 569 569 }; 570 570 571 GSource *owl_window_redraw_source_new(void) { 571 G_GNUC_WARN_UNUSED_RESULT GSource *owl_window_redraw_source_new(void) 572 { 572 573 GSource *source; 573 574 source = g_source_new(&redraw_funcs, sizeof(GSource)); -
window.h
r4cc49bc rfe73d0c 5 5 #include <glib-object.h> 6 6 7 #ifdef HAVE_STDBOOL_H8 7 #include <stdbool.h> 9 #else10 #ifndef HAVE__BOOL11 #define _Bool signed char12 #endif13 #define bool _Bool14 #define false 015 #define true 116 #define __bool_true_false_are_defined 117 #endif /* HAVE_STDBOOL_H */18 8 19 9 G_BEGIN_DECLS -
zcrypt.c
r3b8a563 rd427f08 11 11 #include <unistd.h> 12 12 #include <sys/types.h> 13 #include <zephyr/zephyr.h>14 13 #include <glib.h> 15 14 #include <string.h> … … 54 53 } ZWRITEOPTIONS; 55 54 56 char *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance);55 G_GNUC_WARN_UNUSED_RESULT char *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance); 57 56 int ParseCryptSpec(const char *spec, const char **keyfile); 58 char *BuildArgString(char **argv, int start, int end);59 char *read_keystring(const char *keyfile);57 G_GNUC_WARN_UNUSED_RESULT char *BuildArgString(char **argv, int start, int end); 58 G_GNUC_WARN_UNUSED_RESULT char *read_keystring(const char *keyfile); 60 59 61 60 int do_encrypt(int zephyr, const char *class, const char *instance, … … 365 364 /* Build a space-separated string from argv from elements between start * 366 365 * and end - 1. malloc()'s the returned string. */ 367 char *BuildArgString(char **argv, int start, int end)366 G_GNUC_WARN_UNUSED_RESULT char *BuildArgString(char **argv, int start, int end) 368 367 { 369 368 int len = 1; … … 402 401 #define MAX_SEARCH 3 403 402 /* Find the class/instance in the .crypt-table */ 404 char *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance)403 G_GNUC_WARN_UNUSED_RESULT char *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance) 405 404 { 406 405 char *keyfile = NULL; … … 580 579 } 581 580 582 char *slurp_stdin(int ignoredot, int *length) {581 G_GNUC_WARN_UNUSED_RESULT char *slurp_stdin(int ignoredot, int *length) { 583 582 char *buf; 584 583 char *inptr; … … 612 611 } 613 612 614 char *GetInputBuffer(ZWRITEOPTIONS *zoptions, int *length) {613 G_GNUC_WARN_UNUSED_RESULT char *GetInputBuffer(ZWRITEOPTIONS *zoptions, int *length) { 615 614 char *buf; 616 615 … … 638 637 } 639 638 640 char *read_keystring(const char *keyfile) {639 G_GNUC_WARN_UNUSED_RESULT char *read_keystring(const char *keyfile) { 641 640 char *keystring; 642 641 FILE *fkey = fopen(keyfile, "r"); -
zephyr.c
rb848e30 rd427f08 48 48 struct sockaddr_in sin; 49 49 ZNotice_t req; 50 GIOChannel *channel; 50 51 51 52 /* … … 91 92 } 92 93 93 owl_select_add_io_dispatch(ZGetFD(), OWL_IO_READ|OWL_IO_EXCEPT, &owl_zephyr_finish_initialization, NULL, NULL); 94 } 95 96 void owl_zephyr_finish_initialization(const owl_io_dispatch *d, void *data) { 94 channel = g_io_channel_unix_new(ZGetFD()); 95 g_io_add_watch(channel, G_IO_IN | G_IO_ERR | G_IO_HUP, 96 &owl_zephyr_finish_initialization, NULL); 97 g_io_channel_unref(channel); 98 } 99 100 gboolean owl_zephyr_finish_initialization(GIOChannel *source, GIOCondition condition, void *data) { 97 101 Code_t code; 98 102 char *perl; 99 103 GSource *event_source; 100 104 101 owl_select_remove_io_dispatch(d);102 103 105 ZClosePort(); 104 106 105 107 if ((code = ZInitialize()) != ZERR_NONE) { 106 108 owl_function_error("Initializing Zephyr: %s", error_message(code)); 107 return ;109 return FALSE; 108 110 } 109 111 110 112 if ((code = ZOpenPort(NULL)) != ZERR_NONE) { 111 113 owl_function_error("Initializing Zephyr: %s", error_message(code)); 112 return ;114 return FALSE; 113 115 } 114 116 … … 143 145 perl = owl_perlconfig_execute("BarnOwl::Zephyr::_zephyr_startup()"); 144 146 g_free(perl); 147 return FALSE; 145 148 } 146 149 … … 521 524 */ 522 525 #ifdef HAVE_LIBZEPHYR 523 char *owl_zephyr_get_field(const ZNotice_t *n, int j)526 G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_field(const ZNotice_t *n, int j) 524 527 { 525 528 int i, count, save; … … 549 552 } 550 553 551 char *owl_zephyr_get_field_as_utf8(const ZNotice_t *n, int j)554 G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_field_as_utf8(const ZNotice_t *n, int j) 552 555 { 553 556 int i, count, save; … … 581 584 } 582 585 #else 583 char *owl_zephyr_get_field(void *n, int j)586 G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_field(void *n, int j) 584 587 { 585 588 return(g_strdup("")); 586 589 } 587 char *owl_zephyr_get_field_as_utf8(void *n, int j)590 G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_field_as_utf8(void *n, int j) 588 591 { 589 592 return owl_zephyr_get_field(n, j); … … 618 621 * caller must free the return 619 622 */ 620 char *owl_zephyr_get_message(const ZNotice_t *n, const owl_message *m)623 G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_message(const ZNotice_t *n, const owl_message *m) 621 624 { 622 625 #define OWL_NFIELDS 5 … … 939 942 #endif 940 943 941 char *owl_zephyr_zlocate(const char *user, int auth)944 G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_zlocate(const char *user, int auth) 942 945 { 943 946 #ifdef HAVE_LIBZEPHYR … … 1039 1042 1040 1043 /* caller must free the return */ 1041 char *owl_zephyr_makesubline(const char *class, const char *inst, const char *recip)1044 G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_makesubline(const char *class, const char *inst, const char *recip) 1042 1045 { 1043 1046 return g_strdup_printf("%s,%s,%s\n", class, inst, !strcmp(recip, "") ? "*" : recip); … … 1119 1122 * free the return. 1120 1123 */ 1121 char *owl_zephyr_getsubs(void)1124 G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_getsubs(void) 1122 1125 { 1123 1126 #ifdef HAVE_LIBZEPHYR … … 1239 1242 * The caller must free the return 1240 1243 */ 1241 char *short_zuser(const char *in)1244 G_GNUC_WARN_UNUSED_RESULT char *short_zuser(const char *in) 1242 1245 { 1243 1246 char *ptr = strrchr(in, '@'); … … 1251 1254 * The caller must free the return. 1252 1255 */ 1253 char *long_zuser(const char *in)1256 G_GNUC_WARN_UNUSED_RESULT char *long_zuser(const char *in) 1254 1257 { 1255 1258 char *ptr = strrchr(in, '@'); … … 1279 1282 * caller must free the return. 1280 1283 */ 1281 char *owl_zephyr_smartstripped_user(const char *in)1284 G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_smartstripped_user(const char *in) 1282 1285 { 1283 1286 char *slash, *dot, *realm, *out; … … 1432 1435 #endif 1433 1436 1434 void owl_zephyr_buddycheck_timer(owl_timer *t,void *data)1437 gboolean owl_zephyr_buddycheck_timer(void *data) 1435 1438 { 1436 1439 if (owl_global_is_pseudologins(&g)) { … … 1440 1443 owl_function_debugmsg("Warning: owl_zephyr_buddycheck_timer call pointless; timer should have been disabled"); 1441 1444 } 1445 return TRUE; 1442 1446 } 1443 1447 … … 1510 1514 event_source = (owl_zephyr_event_source*) source; 1511 1515 event_source->poll_fd.fd = fd; 1512 event_source->poll_fd.events = G_IO_IN | G_IO_HUP | G_IO_ PRI | G_IO_ERR;1516 event_source->poll_fd.events = G_IO_IN | G_IO_HUP | G_IO_ERR; 1513 1517 g_source_add_poll(source, &event_source->poll_fd); 1514 1518 -
zwrite.c
r3b8a563 rd427f08 5 5 #include "owl.h" 6 6 7 owl_zwrite *owl_zwrite_new(const char *line)7 G_GNUC_WARN_UNUSED_RESULT owl_zwrite *owl_zwrite_new(const char *line) 8 8 { 9 9 owl_zwrite *z = g_new(owl_zwrite, 1); … … 15 15 } 16 16 17 int owl_zwrite_create_from_line(owl_zwrite *z, const char *line)17 G_GNUC_WARN_UNUSED_RESULT int owl_zwrite_create_from_line(owl_zwrite *z, const char *line) 18 18 { 19 19 int argc, badargs, myargc; … … 321 321 322 322 /* Caller must free the result. */ 323 char *owl_zwrite_get_recip_n_with_realm(const owl_zwrite *z, int n)323 G_GNUC_WARN_UNUSED_RESULT char *owl_zwrite_get_recip_n_with_realm(const owl_zwrite *z, int n) 324 324 { 325 325 if (z->realm[0]) { … … 370 370 * If not a CC, only the recip_index'th user will be replied to. 371 371 */ 372 char *owl_zwrite_get_replyline(const owl_zwrite *z, int recip_index)372 G_GNUC_WARN_UNUSED_RESULT char *owl_zwrite_get_replyline(const owl_zwrite *z, int recip_index) 373 373 { 374 374 /* Match ordering in zwrite help. */
Note: See TracChangeset
for help on using the changeset viewer.