templatecmd.c
changeset 17 82331654a753
parent 16 e7c65942ce5c
equal deleted inserted replaced
16:e7c65942ce5c 17:82331654a753
    31 void tcmd_init (void);
    31 void tcmd_init (void);
    32 void tcmd_uninit (void);
    32 void tcmd_uninit (void);
    33 
    33 
    34 #define DESCRIPTION ( "Templated commands\nProvides command /templatecmd (and any commands, you define with it)" )
    34 #define DESCRIPTION ( "Templated commands\nProvides command /templatecmd (and any commands, you define with it)" )
    35 
    35 
    36 static module_info_t info_templatecmd_dev = {
    36 module_info_t info_templatecmd = {
    37 	.branch      = "dev",
    37 	.branch      = MCABBER_BRANCH,
    38 	.api         = 20,
    38 	.api         = MCABBER_API_VERSION,
    39 	.version     = PROJECT_VERSION,
    39 	.version     = PROJECT_VERSION,
    40 	.description = DESCRIPTION,
    40 	.description = DESCRIPTION,
    41 	.requires    = NULL,
    41 	.requires    = NULL,
    42 	.init        = tcmd_init,
    42 	.init        = tcmd_init,
    43 	.uninit      = tcmd_uninit,
    43 	.uninit      = tcmd_uninit,
    44 	.next        = NULL,
    44 	.next        = NULL,
    45 };
    45 };
    46 
    46 
    47 module_info_t info_templatecmd = {
       
    48 	.branch      = "0.10.1",
       
    49 	.api         = 1,
       
    50 	.version     = PROJECT_VERSION,
       
    51 	.description = DESCRIPTION,
       
    52 	.requires    = NULL,
       
    53 	.init        = tcmd_init,
       
    54 	.uninit      = tcmd_uninit,
       
    55 	.next        = &info_templatecmd_dev,
       
    56 };
       
    57 
       
    58 typedef struct {
    47 typedef struct {
    59 	gchar    *name;
    48 	gchar    *name;
    60 #ifdef MCABBER_API_HAVE_CMD_ID
    49 #ifdef MCABBER_API_HAVE_CMD_ID
    61 	gpointer  id;
    50 	gpointer  id;
    62 #endif
    51 #endif
   182 						cmd_del (template_command -> id);
   171 						cmd_del (template_command -> id);
   183 #endif
   172 #endif
   184 					template_commands = g_slist_remove (template_commands, template_command);
   173 					template_commands = g_slist_remove (template_commands, template_command);
   185 					g_free (template_command -> name);
   174 					g_free (template_command -> name);
   186 					g_free (template_command -> template);
   175 					g_free (template_command -> template);
   187 					g_free (template_command);
   176 					g_slice_free (tcmd_t, template_command);
   188 				}
   177 				}
   189 				return;
   178 				return;
   190 			}
   179 			}
   191 
   180 
   192 			if (!template_command) {
   181 			if (!template_command) {
   193 				template_command = g_new (tcmd_t, 1);
   182 				template_command = g_slice_new (tcmd_t);
   194 				template_command -> name = g_strndup (arg, len);
   183 				template_command -> name = g_strndup (arg, len);
   195 			} else
   184 			} else
   196 				g_free (template_command -> template);
   185 				g_free (template_command -> template);
   197 
   186 
   198 			template_command -> template = g_strdup (astart);
   187 			template_command -> template = g_strdup (astart);
   264 		if (template_command -> id)
   253 		if (template_command -> id)
   265 			cmd_del (template_command -> id);
   254 			cmd_del (template_command -> id);
   266 #endif
   255 #endif
   267 		g_free (template_command -> name);
   256 		g_free (template_command -> name);
   268 		g_free (template_command -> template);
   257 		g_free (template_command -> template);
   269 		g_free (template_command);
   258 		g_slice_free (tcmd_t, template_command);
   270 	}
   259 	}
   271 
   260 
   272 	g_slist_free (template_commands);
   261 	g_slist_free (template_commands);
   273 }
   262 }
   274 
   263