cmd.c
changeset 30 b60076874691
parent 29 5b0349cbc6a7
child 33 5052c1200b68
equal deleted inserted replaced
29:5b0349cbc6a7 30:b60076874691
    43 #define DESCRIPTION ( \
    43 #define DESCRIPTION ( \
    44 	"Sends output of command to buddy\n" \
    44 	"Sends output of command to buddy\n" \
    45 	"Recognizes options cmd_shell, cmd_redirect_stderr, cmd_header and cmd_header_inline\n" \
    45 	"Recognizes options cmd_shell, cmd_redirect_stderr, cmd_header and cmd_header_inline\n" \
    46 	"Provides command /cmd" )
    46 	"Provides command /cmd" )
    47 
    47 
    48 static module_info_t info_cmd_dev = {
    48 module_info_t info_cmd = {
    49 	.branch          = "dev",
    49 	.branch          = MCABBER_BRANCH,
    50 	.api             = 20,
    50 	.api             = MCABBER_API_VERSION,
    51 	.version         = PROJECT_VERSION,
    51 	.version         = PROJECT_VERSION,
    52 	.description     = DESCRIPTION,
    52 	.description     = DESCRIPTION,
    53 	.requires        = NULL,
    53 	.requires        = NULL,
    54 	.init            = mcmd_init,
    54 	.init            = mcmd_init,
    55 	.uninit          = mcmd_uninit,
    55 	.uninit          = mcmd_uninit,
    56 	.next            = NULL,
    56 	.next            = NULL,
    57 };
       
    58 
       
    59 module_info_t info_cmd = {
       
    60 	.branch          = "0.10.1",
       
    61 	.api             = 1,
       
    62 	.version         = PROJECT_VERSION,
       
    63 	.description     = DESCRIPTION,
       
    64 	.requires        = NULL,
       
    65 	.init            = mcmd_init,
       
    66 	.uninit          = mcmd_uninit,
       
    67 	.next            = &info_cmd_dev,
       
    68 };
    57 };
    69 
    58 
    70 typedef struct {
    59 typedef struct {
    71 	gchar      *jid;
    60 	gchar      *jid;
    72 	GString    *input;
    61 	GString    *input;
   230 	if (cb->channel)
   219 	if (cb->channel)
   231 		g_io_channel_unref (cb->channel);
   220 		g_io_channel_unref (cb->channel);
   232 	if (cb -> subject)
   221 	if (cb -> subject)
   233 		g_free (cb -> subject);
   222 		g_free (cb -> subject);
   234 	g_free (cb->jid);
   223 	g_free (cb->jid);
   235 	g_free (cb);
   224 	g_slice_free (cmd_cb_t, cb);
   236 }
   225 }
   237 
   226 
   238 static void do_cmd (char *arg)
   227 static void do_cmd (char *arg)
   239 {
   228 {
   240 	int         fd[2];
   229 	int         fd[2];
   305 			}
   294 			}
   306 			g_io_channel_set_close_on_unref (channel, TRUE);
   295 			g_io_channel_set_close_on_unref (channel, TRUE);
   307 		}
   296 		}
   308 
   297 
   309 		{
   298 		{
   310 			cmd_cb_t *cb = g_new (cmd_cb_t, 1);
   299 			cmd_cb_t *cb = g_slice_new (cmd_cb_t);
   311 
   300 
   312 			if (settings_opt_get_int ("cmd_header")) {
   301 			if (settings_opt_get_int ("cmd_header")) {
   313 				if (settings_opt_get_int ("cmd_header_inline") || is_room (jid)) {
   302 				if (settings_opt_get_int ("cmd_header_inline") || is_room (jid)) {
   314 					gchar *mesg = g_strdup_printf ("$ %s", arg);
   303 					gchar *mesg = g_strdup_printf ("$ %s", arg);
   315 					gchar *utf  = to_utf8 (mesg);
   304 					gchar *utf  = to_utf8 (mesg);
   361 		if (cb->source)
   350 		if (cb->source)
   362 			g_source_remove (cb->source);
   351 			g_source_remove (cb->source);
   363 		if (cb->channel)
   352 		if (cb->channel)
   364 			g_io_channel_unref (cb->channel);
   353 			g_io_channel_unref (cb->channel);
   365 		g_free (cb->jid);
   354 		g_free (cb->jid);
   366 		g_free (cb);
   355 		g_slice_free (cmd_cb_t, cb);
   367 	}
   356 	}
   368 
   357 
   369 	g_slist_free (cmd_channels);
   358 	g_slist_free (cmd_channels);
   370 }
   359 }
   371 
   360