[Initng-svn] r2314 - in initng: devtool plugins/dparser
plugins/iparser plugins/ngc2 plugins/reload
plugins/simple_launcher plugins/stcmd src
svn at initng.thinktux.net
svn at initng.thinktux.net
Fri Dec 2 21:40:25 CET 2005
Author: deac
Date: Fri Dec 2 21:40:24 2005
New Revision: 2314
Modified:
initng/devtool/test_parser.c
initng/plugins/dparser/initng_d_parser.c
initng/plugins/iparser/initng_i_parser.c
initng/plugins/ngc2/initng_ngc2.c
initng/plugins/reload/initng_reload.c
initng/plugins/simple_launcher/initng_simple_launcher.c
initng/plugins/stcmd/initng_stcmd.c
initng/plugins/stcmd/print_service.c
initng/src/initng_common.c
initng/src/initng_handler.c
initng/src/initng_load_module.c
initng/src/initng_service_cache.c
initng/src/initng_static_states.c
initng/src/initng_string_tools.c
initng/src/initng_string_tools.h
Log:
fix indent with indent.
Modified: initng/devtool/test_parser.c
==============================================================================
--- initng/devtool/test_parser.c (original)
+++ initng/devtool/test_parser.c Fri Dec 2 21:40:24 2005
@@ -77,7 +77,8 @@
static int check_circular = 0;
s_entry STATUS = { "status", INT, 6, NULL, "Status of testing." };
-s_entry CIRCULAR = { "circular", STRING, 8, NULL, "Name of curcular dependencied service." };
+s_entry CIRCULAR =
+ { "circular", STRING, 8, NULL, "Name of curcular dependencied service." };
int main(int argc, char *argv[], char *env[])
{
@@ -105,74 +106,75 @@
int i;
char *srv_name = i_strdup("default");
-
- for (i=1; i<argc; i++)
+
+ for (i = 1; i < argc; i++)
{
- int opt_type = 0;
- char *opt = argv[i];
+ int opt_type = 0;
+ char *opt = argv[i];
- if (strlen(opt)<=1)
- continue;
+ if (strlen(opt) <= 1)
+ continue;
- if (opt[0]=='-' && opt[1]=='-')
- {
- if (strlen(opt)==2)
- continue;
-
- opt_type = 1;
- opt += 2;
- }
- else if (opt[0]=='-')
- {
- opt_type = 2;
- opt++;
- }
-
- if (opt_type == 1)
- {
- if (strcmp(opt, "verbose") == 0)
- verbose = 1;
-
- if (strcmp(opt, "all") == 0)
- parse_all_files = 1;
-
- if (strcmp(opt, "no_summary") == 0)
- summary = 0;
-
- if (strcmp(opt, "check_circular") == 0)
- check_circular = 1;
-
- if (strcmp(opt, "print_each") == 0)
- print_each = 1;
-
- if (strcmp(opt, "print_dep_err") == 0)
- print_dep_err = 1;
- }
- else if (opt_type == 2)
- {
- if (strcmp(opt, "v") == 0)
- verbose = 1;
-
- if (strcmp(opt, "a") == 0)
- parse_all_files = 1;
-
- if (strcmp(opt, "s") == 0)
- summary = 0;
-
- if (strcmp(opt, "c") == 0)
- check_circular = 1;
-
- if (strcmp(opt, "p") == 0)
- print_each = 1;
-
- if (strcmp(opt, "d") == 0)
- print_dep_err = 1;
-
- } else
- {
- free(srv_name);
- srv_name = opt;
- }
+ if (opt[0] == '-' && opt[1] == '-')
+ {
+ if (strlen(opt) == 2)
+ continue;
+
+ opt_type = 1;
+ opt += 2;
+ }
+ else if (opt[0] == '-')
+ {
+ opt_type = 2;
+ opt++;
+ }
+
+ if (opt_type == 1)
+ {
+ if (strcmp(opt, "verbose") == 0)
+ verbose = 1;
+
+ if (strcmp(opt, "all") == 0)
+ parse_all_files = 1;
+
+ if (strcmp(opt, "no_summary") == 0)
+ summary = 0;
+
+ if (strcmp(opt, "check_circular") == 0)
+ check_circular = 1;
+
+ if (strcmp(opt, "print_each") == 0)
+ print_each = 1;
+
+ if (strcmp(opt, "print_dep_err") == 0)
+ print_dep_err = 1;
+ }
+ else if (opt_type == 2)
+ {
+ if (strcmp(opt, "v") == 0)
+ verbose = 1;
+
+ if (strcmp(opt, "a") == 0)
+ parse_all_files = 1;
+
+ if (strcmp(opt, "s") == 0)
+ summary = 0;
+
+ if (strcmp(opt, "c") == 0)
+ check_circular = 1;
+
+ if (strcmp(opt, "p") == 0)
+ print_each = 1;
+
+ if (strcmp(opt, "d") == 0)
+ print_dep_err = 1;
+
+ }
+ else
+ {
+ free(srv_name);
+ srv_name = opt;
+ }
}
if (parse_all_files == 1)
@@ -180,44 +182,48 @@
result = parse_all("system");
result &= parse_all("daemon");
result &= parse_all("net");
- //parse_all("debug");
- result &= parse_all("daemon/bluetooth");
+ //parse_all("debug");
+ result &= parse_all("daemon/bluetooth");
}
else
{
- result = load_service(srv_name,0);
- if (check_circular == 1)
- result &= check_deps(NULL,srv_name,0);
-
- if (summary==1)
- {
- if (result == NOT_OK)
- {
- printf("Service %s is failed because:\n",srv_name);
- while_service_db(current)
- {
- switch (service_db_get_int(&STATUS, current))
- {
- case PARSE_ERR:
- printf("%s has parsing errors or service file was not found\n",current->name);
- break;
- case CIRCULAR_ERR:
- printf("%s has circular dependency with %s\n",current->name,
- service_db_get_string(&CIRCULAR,current));
- break;
- case DEPEND_ERR:
- if (print_dep_err==1)
- printf("%s has one of its depends failed\n",current->name);
- break;
- default:
- break;
- };
- }
- }
- else
- printf("Service %s is ok.\n",srv_name);
- }
-
+ result = load_service(srv_name, 0);
+ if (check_circular == 1)
+ result &= check_deps(NULL, srv_name, 0);
+
+ if (summary == 1)
+ {
+ if (result == NOT_OK)
+ {
+ printf("Service %s is failed because:\n", srv_name);
+ while_service_db(current)
+ {
+ switch (service_db_get_int(&STATUS, current))
+ {
+ case PARSE_ERR:
+ printf
+ ("%s has parsing errors or service file was not found\n",
+ current->name);
+ break;
+ case CIRCULAR_ERR:
+ printf("%s has circular dependency with %s\n",
+ current->name,
+ service_db_get_string(&CIRCULAR, current));
+ break;
+ case DEPEND_ERR:
+ if (print_dep_err == 1)
+ printf("%s has one of its depends failed\n",
+ current->name);
+ break;
+ default:
+ break;
+ };
+ }
+ }
+ else
+ printf("Service %s is ok.\n", srv_name);
+ }
+
}
exit:
@@ -225,7 +231,7 @@
initng_unload_all_modules();
service_db_free_all();
initng_free();
- return (result==NOT_OK)?OK:NOT_OK;
+ return (result == NOT_OK) ? OK : NOT_OK;
}
static int parse_all(const char *dirname)
@@ -260,9 +266,9 @@
strncpy(tmp, e->d_name, i - 2);
tmp[i - 2] = '\0';
sprintf(tmp2, "%s/%s", dirname, tmp);
- result &= load_service(tmp2,0);
- if (check_circular==1)
- result &= check_deps(NULL, tmp2, 0);
+ result &= load_service(tmp2, 0);
+ if (check_circular == 1)
+ result &= check_deps(NULL, tmp2, 0);
}
closedir(d);
@@ -273,41 +279,41 @@
{
service_h *service = NULL;
service_h *tmp_service = NULL;
- char *string=NULL;
+ char *string = NULL;
int result = NOT_OK;
int srv_status;
int i;
if (verbose == 1)
{
- SPACE;
- printf("Probeparsing: %s\n", name);
+ SPACE;
+ printf("Probeparsing: %s\n", name);
}
service = parse_service(name);
if (!service)
{
/* unload all modules
- initng_unload_all_modules();
- initng_free();
- exit(2);
- */
- if (verbose == 1)
- {
- SPACE;
- printf("%s - failed\n",name);
- }
- service = service_db_new(name, &TYPE_SERVICE);
- if (service)
- {
- service_db_add(service);
- service_db_set_int(&STATUS, service, PARSE_ERR);
- }
- return result;
+ initng_unload_all_modules();
+ initng_free();
+ exit(2);
+ */
+ if (verbose == 1)
+ {
+ SPACE;
+ printf("%s - failed\n", name);
+ }
+ service = service_db_new(name, &TYPE_SERVICE);
+ if (service)
+ {
+ service_db_add(service);
+ service_db_set_int(&STATUS, service, PARSE_ERR);
+ }
+ return result;
}
if (print_each == 1)
- service_db_print_u(service, stdout, 1);
+ service_db_print_u(service, stdout, 1);
result = OK;
@@ -315,24 +321,26 @@
while ((string = service_db_get_next_string(&NEED, service, string)))
{
- tmp_service = service_db_find_by_name(string);
- if (!tmp_service || (srv_status = service_db_get_int(&STATUS, tmp_service))==0)
- result &= load_service(string, level+1);
- else
- result &= (srv_status>NOT_OK)?OK:NOT_OK;
+ tmp_service = service_db_find_by_name(string);
+ if (!tmp_service
+ || (srv_status = service_db_get_int(&STATUS, tmp_service)) == 0)
+ result &= load_service(string, level + 1);
+ else
+ result &= (srv_status > NOT_OK) ? OK : NOT_OK;
}
if (verbose == 1)
{
- SPACE;
- if (result==NOT_OK)
- printf("%s - failed\n",name);
- else
- printf("%s - ok\n",name);
+ SPACE;
+ if (result == NOT_OK)
+ printf("%s - failed\n", name);
+ else
+ printf("%s - ok\n", name);
}
- service_db_set_int(&STATUS, service, (result==NOT_OK)?DEPEND_ERR:OK);
+ service_db_set_int(&STATUS, service,
+ (result == NOT_OK) ? DEPEND_ERR : OK);
return result;
}
@@ -344,77 +352,82 @@
int status;
char **my_list;
char *string = NULL;
- int i,j;
+ int i, j;
service_h *service = service_db_find_by_name(dep);
- if (verbose==1)
+ if (verbose == 1)
{
- SPACE;
- printf("Checking: %s\n", dep);
+ SPACE;
+ printf("Checking: %s\n", dep);
}
if (!service)
- status = NOT_OK;
+ status = NOT_OK;
else
- status = service_db_get_int(&STATUS, service);
+ status = service_db_get_int(&STATUS, service);
if (status == CHECKED)
- result=OK;
+ result = OK;
if (status == OK)
{
- result = OK;
+ result = OK;
- my_list = (char **) initng_calloc(level + 2, sizeof(char *));
- my_list[level+1]=NULL;
+ my_list = (char **) initng_calloc(level + 2, sizeof(char *));
+ my_list[level + 1] = NULL;
- while ((string = service_db_get_next_string(&NEED, service, string)))
- {
- tmp_result = OK;
-
- for (j=0; dep_list && dep_list[j]; j++)
- {
- if (strcmp(string, dep_list[j])==0)
- {
- status = CIRCULAR_ERR;
- service_db_set_int(&STATUS, service, status);
- service_db_set_string(&CIRCULAR, service, i_strdup(string));
- if (verbose==1)
- {
- SPACE;
- printf("Service %s has circular dependency with %s\n", dep, string);
- }
- tmp_result = NOT_OK;
- break;
- }
- my_list[j]=dep_list[j];
- }
-
- if (tmp_result==OK)
- {
- my_list[j]=dep;
- tmp_result = check_deps(my_list, string, level+1);
- }
-
- result &= tmp_result;
- }
- free(my_list);
+ while ((string = service_db_get_next_string(&NEED, service, string)))
+ {
+ tmp_result = OK;
+
+ for (j = 0; dep_list && dep_list[j]; j++)
+ {
+ if (strcmp(string, dep_list[j]) == 0)
+ {
+ status = CIRCULAR_ERR;
+ service_db_set_int(&STATUS, service, status);
+ service_db_set_string(&CIRCULAR, service,
+ i_strdup(string));
+ if (verbose == 1)
+ {
+ SPACE;
+ printf("Service %s has circular dependency with %s\n",
+ dep, string);
+ }
+ tmp_result = NOT_OK;
+ break;
+ }
+ my_list[j] = dep_list[j];
+ }
+
+ if (tmp_result == OK)
+ {
+ my_list[j] = dep;
+ tmp_result = check_deps(my_list, string, level + 1);
+ }
+
+ result &= tmp_result;
+ }
+ free(my_list);
}
if (verbose == 1)
{
- SPACE;
- if (result==NOT_OK)
- printf("%s - failed\n",dep);
- else
- printf("%s - ok\n",dep);
+ SPACE;
+ if (result == NOT_OK)
+ printf("%s - failed\n", dep);
+ else
+ printf("%s - ok\n", dep);
}
- status = (result==OK)?CHECKED:((status!=CIRCULAR_ERR)?DEPEND_ERR:CIRCULAR_ERR);
+ status =
+ (result ==
+ OK) ? CHECKED : ((status !=
+ CIRCULAR_ERR) ? DEPEND_ERR : CIRCULAR_ERR);
if (service)
- service_db_set_int(&STATUS, service, status);
+ service_db_set_int(&STATUS, service, status);
return result;
}
Modified: initng/plugins/dparser/initng_d_parser.c
==============================================================================
--- initng/plugins/dparser/initng_d_parser.c (original)
+++ initng/plugins/dparser/initng_d_parser.c Fri Dec 2 21:40:24 2005
@@ -27,7 +27,7 @@
#include <fcntl.h>
#include <stdlib.h>
#include <assert.h>
- /*#include <dirent.h> *//* opendir() closedir() */
+ /*#include <dirent.h> *//* opendir() closedir() */
#include "../../src/initng_global.h"
#include "../../src/initng_string_tools.h"
Modified: initng/plugins/iparser/initng_i_parser.c
==============================================================================
--- initng/plugins/iparser/initng_i_parser.c (original)
+++ initng/plugins/iparser/initng_i_parser.c Fri Dec 2 21:40:24 2005
@@ -67,14 +67,15 @@
static int iint_parser(s_entry * type, char **value, char *va,
service_h * from_service);
-static int is_valid(char * string);
+static int is_valid(char *string);
-static int is_valid(char * string)
+static int is_valid(char *string)
{
int i;
- for (i=0; string[i]!=0; i++)
- if (string[i]<=32)
- return (FALSE);
+
+ for (i = 0; string[i] != 0; i++)
+ if (string[i] <= 32)
+ return (FALSE);
return (TRUE);
}
@@ -423,15 +424,16 @@
return (FALSE);
}
- if (!is_valid(father_name))
- {
- err_print_line(*to_parse, "Fater name contains invalid characters.");
- return (FALSE);
- }
+ if (!is_valid(father_name))
+ {
+ err_print_line(*to_parse,
+ "Fater name contains invalid characters.");
+ return (FALSE);
+ }
#ifdef DEBUG
- if(father_name)
- D_("Father is: %s, set from \"server : father\"\n", father_name);
+ if (father_name)
+ D_("Father is: %s, set from \"server : father\"\n", father_name);
#endif
/* service test : class { */
@@ -456,10 +458,10 @@
free(name);
if (father_name)
free(father_name);
- return (FALSE);
+ return (FALSE);
}
- /* create a service entry - if there exits an duplicate, skip to the end of section */
+ /* create a service entry - if there exits an duplicate, skip to the end of section */
if ((duplicate = service_db_find_by_exact_name(name)))
{
free(name);
@@ -467,127 +469,129 @@
free(father_name);
new_service = duplicate;
len = chars_to_end_of_this_stack(*to_parse);
- if (len == FALSE)
- return (FALSE);
+ if (len == FALSE)
+ return (FALSE);
- (*to_parse)+=len;
+ (*to_parse) += len;
}
else
{
- /* jump to first char after start tag and begin from there. */
- (*to_parse)++;
- /* service test : class { */
- /* | */
+ /* jump to first char after start tag and begin from there. */
+ (*to_parse)++;
+ /* service test : class { */
+ /* | */
new_service = service_db_new(name, type);
- /* FROM NOW, we should not free name or father_name, becouse its ADDED, and required */
+ /* FROM NOW, we should not free name or father_name, becouse its ADDED, and required */
- /* check so that it was allocated! */
- if (!new_service)
- {
- F_("Unable to allocate space for new service.\n");
- err_print_line(*to_parse,
- "Unable to allocate space for new service.");
- free(name);
- if (father_name)
- free(father_name);
- return (FALSE);
- }
-
- /* set the father to the service */
- if (father_name)
- {
- if (father)
- new_service->father = father;
- new_service->father_name = father_name;
- }
-
- /* set type if not set. */
- if (father)
- new_service->type = type;
-
- /* carry on until segment stop or eof, this will handle all lines in current section */
- while ((*to_parse)[0] != '\0' && (*to_parse)[0] != '}')
- {
- stype_h *t = NULL;
- stype_h *y = NULL;
-
- /* upgrade line pointer that print_line_error uses */
- g_pointer = (*to_parse);
- /* skip spaces and empty lines with them */
- JUMP_SPACES(*to_parse);
-
- /* check that this is not the end */
- if (!(*to_parse)[0])
- break;
-
- /* if the row is ending */
- if ((*to_parse)[0] == '\n' || (*to_parse)[0] == ';')
- {
- /* walk to next one */
- (*to_parse)++;
- continue;
- }
-
- /* skip lines with '#' */
- if ((*to_parse)[0] == '#')
- {
- REALLY_JUMP_TO_NEXT_ROW(*to_parse);
- continue;
- }
-
- /**** Check for subclasses ****/
- /* try to find the service type keyword */
- while_stypes(t)
- {
- /* look for matching keywords */
- if (st_cmp(to_parse, t->name))
- {
- y = t;
- break;
- }
- }
- /* if found */
- if (y)
- {
- /* parse it */
- if (!parse_service_line(to_parse, watch_for, NULL, y,
- filename, match, exact_match) == FALSE)
- {
- err_print_line(*to_parse, "Parse of service line failed!");
- service_db_free(new_service);
- new_service = NULL;
- return (FALSE);
- }
- JUMP_TO_NEXT_ROW(*to_parse);
- continue;
- }
-
- /* parse line - search for keywords in g.option_table */
- if (parse_opt(to_parse, type, new_service))
- {
- /* ok, this line is parsed, go to next */
- JUMP_TO_NEXT_ROW(*to_parse);
- continue;
- }
-
- /* Bad content, coud not be parsed */
- /* free and reset */
- service_db_free(new_service);
- new_service = NULL;
- return (FALSE);
- }
-
- service_db_set_string(&FROM_FILE, new_service, i_strdup(filename));
- /* add to service db */
- if (!service_db_add(new_service))
- {
- F_("Could not add service to service db!\n");
- service_db_free(new_service);
- new_service = NULL;
- return (FALSE);
- }
+ /* check so that it was allocated! */
+ if (!new_service)
+ {
+ F_("Unable to allocate space for new service.\n");
+ err_print_line(*to_parse,
+ "Unable to allocate space for new service.");
+ free(name);
+ if (father_name)
+ free(father_name);
+ return (FALSE);
+ }
+
+ /* set the father to the service */
+ if (father_name)
+ {
+ if (father)
+ new_service->father = father;
+ new_service->father_name = father_name;
+ }
+
+ /* set type if not set. */
+ if (father)
+ new_service->type = type;
+
+ /* carry on until segment stop or eof, this will handle all lines in current section */
+ while ((*to_parse)[0] != '\0' && (*to_parse)[0] != '}')
+ {
+ stype_h *t = NULL;
+ stype_h *y = NULL;
+
+ /* upgrade line pointer that print_line_error uses */
+ g_pointer = (*to_parse);
+ /* skip spaces and empty lines with them */
+ JUMP_SPACES(*to_parse);
+
+ /* check that this is not the end */
+ if (!(*to_parse)[0])
+ break;
+
+ /* if the row is ending */
+ if ((*to_parse)[0] == '\n' || (*to_parse)[0] == ';')
+ {
+ /* walk to next one */
+ (*to_parse)++;
+ continue;
+ }
+
+ /* skip lines with '#' */
+ if ((*to_parse)[0] == '#')
+ {
+ REALLY_JUMP_TO_NEXT_ROW(*to_parse);
+ continue;
+ }
+
+ /**** Check for subclasses ****/
+ /* try to find the service type keyword */
+ while_stypes(t)
+ {
+ /* look for matching keywords */
+ if (st_cmp(to_parse, t->name))
+ {
+ y = t;
+ break;
+ }
+ }
+ /* if found */
+ if (y)
+ {
+ /* parse it */
+ if (!parse_service_line(to_parse, watch_for, NULL, y,
+ filename, match,
+ exact_match) == FALSE)
+ {
+ err_print_line(*to_parse,
+ "Parse of service line failed!");
+ service_db_free(new_service);
+ new_service = NULL;
+ return (FALSE);
+ }
+ JUMP_TO_NEXT_ROW(*to_parse);
+ continue;
+ }
+
+ /* parse line - search for keywords in g.option_table */
+ if (parse_opt(to_parse, type, new_service))
+ {
+ /* ok, this line is parsed, go to next */
+ JUMP_TO_NEXT_ROW(*to_parse);
+ continue;
+ }
+
+ /* Bad content, coud not be parsed */
+ /* free and reset */
+ service_db_free(new_service);
+ new_service = NULL;
+ return (FALSE);
+ }
+
+ service_db_set_string(&FROM_FILE, new_service, i_strdup(filename));
+ /* add to service db */
+ if (!service_db_add(new_service))
+ {
+ F_("Could not add service to service db!\n");
+ service_db_free(new_service);
+ new_service = NULL;
+ return (FALSE);
+ }
}
if (strcmp(new_service->name, watch_for) == 0)
@@ -712,11 +716,12 @@
/* copy the string */
var_name = i_strndup(*where, var_len);
- if (!is_valid(var_name))
- {
- err_print_line(*where, "Variable name contains invalid characters.");
+ if (!is_valid(var_name))
+ {
+ err_print_line(*where,
+ "Variable name contains invalid characters.");
return (FALSE);
- }
+ }
(*where) += var_len;
/* Parsometer
@@ -728,7 +733,7 @@
if (ENDED(*where))
{
err_print_line(*where, "Line ended unexpectedly.");
- free(var_name);
+ free(var_name);
return (FALSE);
}
/* Parsometer
@@ -772,39 +777,39 @@
tmp = tmp->alias;
D_("option type %i, var_name: %s, opt_name: %s\n", tmp->opt_type,
- var_name?var_name:"(none)", current->opt_name);
+ var_name ? var_name : "(none)", current->opt_name);
/* now switch the opt_type */
switch (tmp->opt_type)
{
case STRING:
case VARIABLE_STRING:
- result = string_parser(current, where, var_name, srv);
- break;
+ result = string_parser(current, where, var_name, srv);
+ break;
case STRINGS:
case VARIABLE_STRINGS:
- result = strings_parser(current, where, var_name, srv);
- break;
+ result = strings_parser(current, where, var_name, srv);
+ break;
case SET:
case VARIABLE_SET:
- result = set_parser(current, where, var_name, srv);
- break;
+ result = set_parser(current, where, var_name, srv);
+ break;
case INT:
case VARIABLE_INT:
result = iint_parser(current, where, var_name, srv);
- break;
+ break;
default:
err_print_line(*where,
"Unknowun, or undefined type to parse!");
- result = FALSE;
- break;
+ result = FALSE;
+ break;
}
}
- if (result==FALSE)
+ if (result == FALSE)
{
- /* bail out if we did not find a match */
- err_print_line(*where, "Did not get a MATCH!");
+ /* bail out if we did not find a match */
+ err_print_line(*where, "Did not get a MATCH!");
}
return (result);
@@ -950,10 +955,10 @@
if ((*value)[len] != '}' && (*value)[len] != ';')
{
err_print_line(*value, "There should be an ; here.");
- if ((*value)[len] == '\n')
- F_("Its a *newline* instead.\n");
- else
- F_("Its a %c instead.\n", (*value)[len]);
+ if ((*value)[len] == '\n')
+ F_("Its a *newline* instead.\n");
+ else
+ F_("Its a %c instead.\n", (*value)[len]);
return (FALSE);
}
@@ -970,7 +975,7 @@
if (ENDED(*value))
{
err_print_line(*value, "Line ended unexpectedly.");
- free(to);
+ free(to);
return (FALSE);
}
/* Parsometer
Modified: initng/plugins/ngc2/initng_ngc2.c
==============================================================================
--- initng/plugins/ngc2/initng_ngc2.c (original)
+++ initng/plugins/ngc2/initng_ngc2.c Fri Dec 2 21:40:24 2005
@@ -141,8 +141,8 @@
/* use file descriptor, because fread hangs here? */
/*if (read(file_sock->_fileno, &header, sizeof(read_header)) <
- (signed) sizeof(read_header)) */
- if( fread( &header, sizeof header, 1, file_sock) < 1)
+ (signed) sizeof(read_header)) */
+ if (fread(&header, sizeof header, 1, file_sock) < 1)
{
D_("Could not read input.\n");
return;
Modified: initng/plugins/reload/initng_reload.c
==============================================================================
--- initng/plugins/reload/initng_reload.c (original)
+++ initng/plugins/reload/initng_reload.c Fri Dec 2 21:40:24 2005
@@ -180,8 +180,9 @@
continue;
}
- if (get_service(new_entry) == TRUE)
- new_entry->from_service = service_db_find_by_name(new_entry->name);
+ if (get_service(new_entry) == TRUE)
+ new_entry->from_service =
+ service_db_find_by_name(new_entry->name);
}
fclose(fil);
Modified: initng/plugins/simple_launcher/initng_simple_launcher.c
==============================================================================
--- initng/plugins/simple_launcher/initng_simple_launcher.c (original)
+++ initng/plugins/simple_launcher/initng_simple_launcher.c Fri Dec 2 21:40:24 2005
@@ -172,64 +172,64 @@
while ((exec =
active_db_get_string_var(&EXEC, process->pt->name, service)))
{
- char *exec_args = NULL;
- char *exec_t = NULL, *exec_args_t = NULL;
- size_t exec_c = 0;
- size_t exec_args_c = 0;
- char *argv0 = NULL;
- char **exec_argv = NULL;
- char **exec_args_argv = NULL;
- int i = 0;
- int result = FALSE;
-
- /* be aware that fix_variables() return is a malloc, and needs to be free */
+ char *exec_args = NULL;
+ char *exec_t = NULL, *exec_args_t = NULL;
+ size_t exec_c = 0;
+ size_t exec_args_c = 0;
+ char *argv0 = NULL;
+ char **exec_argv = NULL;
+ char **exec_args_argv = NULL;
+ int i = 0;
+ int result = FALSE;
+
+ /* be aware that fix_variables() return is a malloc, and needs to be free */
exec_t = fix_variables(exec, service);
-
+
/* argv-entries are pointer to exec_t[x] */
exec_argv = split_argv(exec_t, WHITESPACE, &exec_c);
- /* make sure we got something from the split */
+ /* make sure we got something from the split */
if (!exec_argv || !exec_argv[0])
{
D_("split_argv on exec returns NULL.\n");
- goto go_free;
+ goto go_free;
}
- /* if it not contains a full path */
- if(exec_argv[0][0]!='/')
- {
- argv0 = expand_exec(exec_argv[0]);
- if (!argv0)
- {
- D_("%s was not found in search path.\n", exec_argv[0]);
- goto go_free;
- }
- exec_argv[0] = argv0;
- }
+ /* if it not contains a full path */
+ if (exec_argv[0][0] != '/')
+ {
+ argv0 = expand_exec(exec_argv[0]);
+ if (!argv0)
+ {
+ D_("%s was not found in search path.\n", exec_argv[0]);
+ goto go_free;
+ }
+ exec_argv[0] = argv0;
+ }
/* exec_args should be parsed at the moment, too */
exec_args =
active_db_get_string_var(&EXEC_ARGS, process->pt->name, service);
if (exec_args)
{
- /* get some fixed variables, with ${VARIABLES} fixed, be aware that this is a new malloc and needs to be free() */
+ /* get some fixed variables, with ${VARIABLES} fixed, be aware that this is a new malloc and needs to be free() */
exec_args_t = fix_variables(exec_args, service);
-
- if(!exec_args_t)
- {
- W_("Failed to fix_variables: \"%s\"\n", exec_args);
- goto go_free;
- }
-
+
+ if (!exec_args_t)
+ {
+ W_("Failed to fix_variables: \"%s\"\n", exec_args);
+ goto go_free;
+ }
+
exec_args_argv =
split_argv(exec_args_t, WHITESPACE, &exec_args_c);
if (!exec_args_argv || !exec_args_argv[0])
{
D_("split_argv exec_args returns NULL.\n");
- goto go_free;
+ goto go_free;
}
- /* what does this part do ??? */
+ /* what does this part do ??? */
exec_argv =
(char **) initng_realloc(exec_argv,
(exec_c + exec_args_c +
@@ -239,51 +239,51 @@
exec_argv[i + exec_c] = NULL;
exec_c += exec_args_c;
-
- /* this have to exist */
+
+ /* this have to exist */
free(exec_args_argv);
- exec_args_argv=NULL;
+ exec_args_argv = NULL;
}
- /* try to execute, remember the result */
+ /* try to execute, remember the result */
result = simple_exec(process, service, exec_c, exec_argv);
- /* this is a fallback, that we can go to if anything fail */
-go_free:
- /* Start freeing */
- if(exec_t)
- {
- free(exec_t);
- exec_t=NULL;
- }
- if(exec_argv)
- {
- free(exec_argv);
- exec_argv=NULL;
- }
- if(argv0)
- {
- free(argv0);
- argv0=NULL;
- }
- if(exec_args_t)
- {
- free(exec_args_t);
- exec_args_t=NULL;
- }
-
- /* return if sucessfull */
+ /* this is a fallback, that we can go to if anything fail */
+ go_free:
+ /* Start freeing */
+ if (exec_t)
+ {
+ free(exec_t);
+ exec_t = NULL;
+ }
+ if (exec_argv)
+ {
+ free(exec_argv);
+ exec_argv = NULL;
+ }
+ if (argv0)
+ {
+ free(argv0);
+ argv0 = NULL;
+ }
+ if (exec_args_t)
+ {
+ free(exec_args_t);
+ exec_args_t = NULL;
+ }
+
+ /* return if sucessfull */
if (result == TRUE)
- return(TRUE);
-
- /* if something failed return false directly */
- if (result == FAIL)
- return(FALSE);
-
- /* continue the next otherwise */
+ return (TRUE);
+
+ /* if something failed return false directly */
+ if (result == FAIL)
+ return (FALSE);
+
+ /* continue the next otherwise */
}
- return(FALSE);
+ return (FALSE);
}
/* 2005-11-28 DEac-: char *e, char *ea => char **argv, size_t argc
Modified: initng/plugins/stcmd/initng_stcmd.c
==============================================================================
--- initng/plugins/stcmd/initng_stcmd.c (original)
+++ initng/plugins/stcmd/initng_stcmd.c Fri Dec 2 21:40:24 2005
@@ -138,7 +138,8 @@
{(void *) &cmd_unload_module},
"UnLoad Module"
};
-s_command PRINT_SERVICE_DB = { 'p', "print_service_db", PRINT_COMMAND, USES_OPT,
+s_command PRINT_SERVICE_DB =
+ { 'p', "print_service_db", PRINT_COMMAND, USES_OPT,
{(void *) &cmd_print_service_db},
"Print service_db"
};
Modified: initng/plugins/stcmd/print_service.c
==============================================================================
--- initng/plugins/stcmd/print_service.c (original)
+++ initng/plugins/stcmd/print_service.c Fri Dec 2 21:40:24 2005
@@ -39,7 +39,7 @@
static void service_db_print_u(service_h * s, FILE * fd, int intro);
static void active_db_print_u(active_h * s, FILE * fd, int intro);
-static void print_string_value(char * string, FILE * fd);
+static void print_string_value(char *string, FILE * fd);
/* P R I N T S E R V I C E */
@@ -57,15 +57,16 @@
}
/* there may be unprintable characters in string - should escape them when printing */
-static void print_string_value(char * string, FILE * fd)
+static void print_string_value(char *string, FILE * fd)
{
int i;
- for (i=0; string[i]!=0; i++)
+
+ for (i = 0; string[i] != 0; i++)
{
- if (IS_PRINTABLE(string[i]))
- fprintf(fd, "%c", string[i]);
- else
- fprintf(fd, "^%c", string[i]^0x40);
+ if (IS_PRINTABLE(string[i]))
+ fprintf(fd, "%c", string[i]);
+ else
+ fprintf(fd, "^%c", string[i] ^ 0x40);
}
}
@@ -104,8 +105,8 @@
continue;
}
fprintf(fd, " @@ %s:\t\"", tmp->type->opt_name);
- print_string_value(tmp->t.s, fd);
- fprintf(fd, "\"\n");
+ print_string_value(tmp->t.s, fd);
+ fprintf(fd, "\"\n");
continue;
case VARIABLE_STRING:
case VARIABLE_STRINGS:
@@ -115,8 +116,8 @@
continue;
}
fprintf(fd, " @@ %s %s:\t\"\n", tmp->type->opt_name, tmp->vn);
- print_string_value(tmp->t.s, fd);
- fprintf(fd, "\"\n");
+ print_string_value(tmp->t.s, fd);
+ fprintf(fd, "\"\n");
continue;
case INT:
fprintf(fd, " @@ %s:\t\"%i\"\n", tmp->type->opt_name,
Modified: initng/src/initng_common.c
==============================================================================
--- initng/src/initng_common.c (original)
+++ initng/src/initng_common.c Fri Dec 2 21:40:24 2005
@@ -64,8 +64,9 @@
/* if we got a match */
if ((g.Argv)[i][0] == '-')
{
- if (strcmp(name, (g.Argv)[i]+1)==0 || service_match(name, (g.Argv)[i]+1))
- return (TRUE);
+ if (strcmp(name, (g.Argv)[i] + 1) == 0
+ || service_match(name, (g.Argv)[i] + 1))
+ return (TRUE);
}
}
return (FALSE);
@@ -137,16 +138,16 @@
* any of the services being added to the active_db */
if (g.no_circular == 0)
{
- while_active_db(current)
- {
- if (active_db_dep_on_deep(a_new, current)
- && active_db_dep_on_deep(current, a_new))
- {
- F_("load_to_active(%s): not loading service %s, cause it has a circular dependency with %s\n", service_name, a_new->name, current->name);
- active_db_free(a_new);
- return NULL;
- }
- }
+ while_active_db(current)
+ {
+ if (active_db_dep_on_deep(a_new, current)
+ && active_db_dep_on_deep(current, a_new))
+ {
+ F_("load_to_active(%s): not loading service %s, cause it has a circular dependency with %s\n", service_name, a_new->name, current->name);
+ active_db_free(a_new);
+ return NULL;
+ }
+ }
}
/* return with pointer to service */
Modified: initng/src/initng_handler.c
==============================================================================
--- initng/src/initng_handler.c (original)
+++ initng/src/initng_handler.c Fri Dec 2 21:40:24 2005
@@ -263,9 +263,9 @@
if (!IS_UP(service_to_stop))
{
/*W_("Cant stop service %s, with status %s\n",
- service_to_stop->name, service_to_stop->a_state->state_name);*/
+ service_to_stop->name, service_to_stop->a_state->state_name); */
- /* why we should mark it as fail stopping if it's not running at all?!? */
+ /* why we should mark it as fail stopping if it's not running at all?!? */
mark_service(service_to_stop, &STOPPED);
return (TRUE);
}
Modified: initng/src/initng_load_module.c
==============================================================================
--- initng/src/initng_load_module.c (original)
+++ initng/src/initng_load_module.c Fri Dec 2 21:40:24 2005
@@ -416,13 +416,13 @@
/* check for files, ending with .so */
if (fnmatch("lib*.so", e->d_name, 0) == 0)
{
- module_name = i_strndup(e->d_name+3,strlen(e->d_name+3)-3);
+ module_name = i_strndup(e->d_name + 3, strlen(e->d_name + 3) - 3);
/* search the plugin name, for blacklisted */
if (service_blacklisted(module_name))
{
F_("Plugin %s blacklisted.\n", module_name);
- free(module_name);
+ free(module_name);
continue;
}
Modified: initng/src/initng_service_cache.c
==============================================================================
--- initng/src/initng_service_cache.c (original)
+++ initng/src/initng_service_cache.c Fri Dec 2 21:40:24 2005
@@ -98,7 +98,7 @@
/* we must clear pointers, otherwise this servise
* will not be added to list
- */
+ */
new_serv->list.prev = new_serv->list.next = NULL;
return (new_serv);
Modified: initng/src/initng_static_states.c
==============================================================================
--- initng/src/initng_static_states.c (original)
+++ initng/src/initng_static_states.c Fri Dec 2 21:40:24 2005
@@ -158,8 +158,8 @@
if (g.sys_state == STATE_STOPPING)
{
- mark_service(service_to_start, &STOPPED);
- return;
+ mark_service(service_to_start, &STOPPED);
+ return;
}
if (g.sys_state != STATE_STARTING && g.sys_state != STATE_UP)
Modified: initng/src/initng_string_tools.c
==============================================================================
--- initng/src/initng_string_tools.c (original)
+++ initng/src/initng_string_tools.c Fri Dec 2 21:40:24 2005
@@ -88,35 +88,36 @@
* @idea DEac-
* @author TheLich
*/
-char **split_argv(char *string, const char *delim, size_t *argc)
+char **split_argv(char *string, const char *delim, size_t * argc)
{
- int len,pos=0;
+ int len, pos = 0;
char **array = (char **) initng_calloc(1, sizeof(char *));
- size_t i=0;
-
+ size_t i = 0;
+
if (string)
{
- while (string[pos]!='\0')
- {
- len = strcspn(string+pos, delim);
- if (len!=0)
- {
- i++;
- array = (char **) initng_realloc(array, sizeof(char *) * (i+1));
- array[i-1]=string+pos;
- if (string[len+pos]!='\0')
- {
- string[len+pos]='\0';
- len++;
- }
- }
- else
- len = 1;
+ while (string[pos] != '\0')
+ {
+ len = strcspn(string + pos, delim);
+ if (len != 0)
+ {
+ i++;
+ array =
+ (char **) initng_realloc(array, sizeof(char *) * (i + 1));
+ array[i - 1] = string + pos;
+ if (string[len + pos] != '\0')
+ {
+ string[len + pos] = '\0';
+ len++;
+ }
+ }
+ else
+ len = 1;
- pos+=len;
- }
+ pos += len;
+ }
}
- array[i]=NULL;
+ array[i] = NULL;
*argc = i;
return array;
}
Modified: initng/src/initng_string_tools.h
==============================================================================
--- initng/src/initng_string_tools.h (original)
+++ initng/src/initng_string_tools.h Fri Dec 2 21:40:24 2005
@@ -58,7 +58,7 @@
/* to use with split_argv */
#define WHITESPACE " \t\n\r\v"
-char **split_argv(char *string, const char *delim, size_t *argc);
+char **split_argv(char *string, const char *delim, size_t * argc);
/* pattern searching */
int service_match(const char *string, const char *pattern);
More information about the Initng-svn
mailing list