Browse Source

Move __ptype_ARGS creation to load_scheme function

Serj Kalichev 9 years ago
parent
commit
5fd9ad0c8a
4 changed files with 18 additions and 9 deletions
  1. 1 0
      .gitignore
  2. 10 0
      clish/shell/shell_dump.c
  3. 0 9
      clish/shell/shell_new.c
  4. 7 0
      clish/shell/shell_xml.c

+ 1 - 0
.gitignore

@@ -40,6 +40,7 @@
 /bin/konf
 /bin/konfd
 /bin/sigexec
+/bin/xml2c
 
 # Docs
 /doc/*.html

+ 10 - 0
clish/shell/shell_dump.c

@@ -56,6 +56,16 @@ void clish_shell_xml2c(clish_shell_t *this)
 	clish_var_t *var;
 	lub_bintree_iterator_t iter;
 
+	printf("#include \"private.h\"\n"
+		"#include \"lub/string.h\"\n"
+		"#include <stdlib.h>\n"
+		"#include <string.h>\n"
+		"#include <assert.h>\n"
+		"#include <errno.h>\n"
+		"#include <sys/types.h>\n"
+		"\n"
+		);
+
 	printf("int clish_shell_load_scheme(clish_shell_t *shell, const char *xml_path)\n"
 		"{\n\n");
 

+ 0 - 9
clish/shell/shell_new.c

@@ -77,15 +77,6 @@ static void clish_shell_init(clish_shell_t * this,
 	this->user = lub_db_getpwuid(getuid()); /* Get user information */
 	this->default_plugin = BOOL_TRUE; /* Load default plugin by default */
 
-	/* Create internal ptypes and params */
-	/* Args */
-	tmp_ptype = clish_shell_find_create_ptype(this,
-		"__ptype_ARGS",
-		"Arguments", "[^\\\\]+",
-		CLISH_PTYPE_REGEXP,
-		CLISH_PTYPE_NONE);
-	assert(tmp_ptype);
-
 	/* Push non-NULL istream */
 	if (istream)
 		clish_shell_push_fd(this, istream, stop_on_error);

+ 7 - 0
clish/shell/shell_xml.c

@@ -81,6 +81,13 @@ int clish_shell_load_scheme(clish_shell_t *this, const char *xml_path)
 	char *saveptr = NULL;
 	int res = 0;
 
+	/* Precreate internal PTYPEs */
+	clish_shell_find_create_ptype(this,
+		"__ptype_ARGS",
+		"Arguments", "[^\\\\]+",
+		CLISH_PTYPE_REGEXP,
+		CLISH_PTYPE_NONE);
+
 	/* use the default path */
 	if (!path)
 		path = default_path;