env.c
changeset 11 dc7bcc0fa5e1
parent 5 da2fdd072650
child 12 14cd74b518ea
equal deleted inserted replaced
10:ee45895bc62a 11:dc7bcc0fa5e1
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
    19  * USA
    19  * USA
    20  */
    20  */
    21 
    21 
    22 #include <glib.h>
    22 #include <glib.h>
    23 #include <gmodule.h>
       
    24 #include <string.h>
    23 #include <string.h>
    25 #include <stdlib.h>
    24 #include <stdlib.h>
    26 #include <unistd.h>
    25 #include <unistd.h>
    27 #include <errno.h>
    26 #include <errno.h>
    28 
    27 
    29 #include <mcabber/utils.h>
    28 #include <mcabber/utils.h>
    30 #include <mcabber/compl.h>
    29 #include <mcabber/compl.h>
    31 #include <mcabber/logprint.h>
    30 #include <mcabber/logprint.h>
       
    31 #include <mcabber/modules.h>
       
    32 
       
    33 static void env_load   (void);
       
    34 static void env_unload (void);
       
    35 
       
    36 module_info_t info_env = {
       
    37 	.mcabber_version = "0.10.0",
       
    38 	.requires        = NULL,
       
    39 	.init            = env_load,
       
    40 	.uninit          = env_unload,
       
    41 };
    32 
    42 
    33 extern char **environ;
    43 extern char **environ;
    34 
    44 
    35 // /env [option [= [value]]]
    45 // /env [option [= [value]]]
    36 static void do_env (char *arg)
    46 static void do_env (char *arg)
   128 			scr_LogPrint (LPRINT_NORMAL, "%s", cwd);
   138 			scr_LogPrint (LPRINT_NORMAL, "%s", cwd);
   129 	} else if (chdir (arg) == -1) // set
   139 	} else if (chdir (arg) == -1) // set
   130 		scr_LogPrint (LPRINT_NORMAL, "Cannot change current working directory: %s.", strerror (errno));
   140 		scr_LogPrint (LPRINT_NORMAL, "Cannot change current working directory: %s.", strerror (errno));
   131 }
   141 }
   132 
   142 
   133 const gchar *g_module_check_init(GModule *module)
   143 static void env_load (void)
   134 {
   144 {
   135 	// command
   145 	// command
   136 	cmd_add ("env", "", 0, 0, do_env, NULL);
   146 	cmd_add ("env", "", 0, 0, do_env, NULL);
   137 	cmd_add ("cd", "", COMPL_FILENAME, 0, do_cd, NULL);
   147 	cmd_add ("cd", "", COMPL_FILENAME, 0, do_cd, NULL);
   138 
       
   139 	return NULL;
       
   140 }
   148 }
   141 
   149 
   142 void g_module_unload(GModule *module)
   150 static void env_unload (void)
   143 {
   151 {
   144 	// command
   152 	// command
   145 	cmd_del ("cd");
   153 	cmd_del ("cd");
   146 	cmd_del ("env");
   154 	cmd_del ("env");
   147 }
   155 }