[Initng-svn] r1947 - in initng: plugins/depend plugins/dparser
plugins/envparser plugins/find plugins/history
plugins/iparser plugins/last plugins/ngc2 plugins/pause
plugins/reload plugins/splash plugins/stcmd src tools
svn at initng.thinktux.net
svn at initng.thinktux.net
Sun Nov 6 16:01:20 CET 2005
Author: jimmy
Date: Sun Nov 6 16:01:18 2005
New Revision: 1947
Modified:
initng/plugins/depend/initng_depend.c
initng/plugins/dparser/initng_d_parser.c
initng/plugins/envparser/initng_envparser.c
initng/plugins/find/initng_find.c
initng/plugins/history/initng_history.c
initng/plugins/iparser/initng_i_parser.c
initng/plugins/last/initng_last.c
initng/plugins/ngc2/ngc2.c
initng/plugins/pause/initng_pause.c
initng/plugins/reload/initng_reload.c
initng/plugins/reload/initng_reload.h
initng/plugins/splash/initng_splash.c
initng/plugins/stcmd/initng_stcmd.c
initng/src/initng_active_db.c
initng/src/initng_common.c
initng/src/initng_execute.c
initng/src/initng_fd.c
initng/src/initng_fork.c
initng/src/initng_global.c
initng/src/initng_handler.c
initng/src/initng_main.c
initng/src/initng_string_tools.c
initng/src/initng_struct_data.c
initng/src/main.c
initng/tools/install_service.c
Log:
Full indention.
Modified: initng/plugins/depend/initng_depend.c
==============================================================================
--- initng/plugins/depend/initng_depend.c (original)
+++ initng/plugins/depend/initng_depend.c Sun Nov 6 16:01:18 2005
@@ -38,6 +38,7 @@
static int dep_on(active_h * service, active_h * check)
{
char *string = NULL;
+
assert(service);
assert(check);
Modified: initng/plugins/dparser/initng_d_parser.c
==============================================================================
--- initng/plugins/dparser/initng_d_parser.c (original)
+++ initng/plugins/dparser/initng_d_parser.c Sun Nov 6 16:01:18 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_string_tools.h"
#include "../../src/initng_service_cache.h"
Modified: initng/plugins/envparser/initng_envparser.c
==============================================================================
--- initng/plugins/envparser/initng_envparser.c (original)
+++ initng/plugins/envparser/initng_envparser.c Sun Nov 6 16:01:18 2005
@@ -44,7 +44,7 @@
char *file = NULL;
char *file_content = NULL;
char *point = NULL;
-
+
assert(s);
/* go to last row on this array */
Modified: initng/plugins/find/initng_find.c
==============================================================================
--- initng/plugins/find/initng_find.c (original)
+++ initng/plugins/find/initng_find.c Sun Nov 6 16:01:18 2005
@@ -55,42 +55,42 @@
assert(service);
path = opendir(INITNG_ROOT "/system");
- if(path)
+ if (path)
{
- while ((dir_e = readdir(path)))
- {
- if (strstr(dir_e->d_name, service))
+ while ((dir_e = readdir(path)))
{
- strcpy(t, "system/");
- strcat(t, service);
- W_("Service shud be system/%s\n", service);
- if ((tmp = parse_service(t)))
- return (tmp);
+ if (strstr(dir_e->d_name, service))
+ {
+ strcpy(t, "system/");
+ strcat(t, service);
+ W_("Service shud be system/%s\n", service);
+ if ((tmp = parse_service(t)))
+ return (tmp);
- }
+ }
+ }
+ closedir(path);
}
- closedir(path);
- }
-
+
path = opendir(INITNG_ROOT "/daemon");
- if(path)
+ if (path)
{
- while ((dir_e = readdir(path)))
- {
- if (strstr(dir_e->d_name, service))
+ while ((dir_e = readdir(path)))
{
- strcpy(t, "daemon/");
- strcat(t, service);
- W_("Service shud be daemon/%s\n", service);
-
- if ((tmp = parse_service(t)))
- return (tmp);
+ if (strstr(dir_e->d_name, service))
+ {
+ strcpy(t, "daemon/");
+ strcat(t, service);
+ W_("Service shud be daemon/%s\n", service);
+
+ if ((tmp = parse_service(t)))
+ return (tmp);
+ }
}
+ closedir(path);
}
- closedir(path);
- }
-
+
return (NULL);
}
Modified: initng/plugins/history/initng_history.c
==============================================================================
--- initng/plugins/history/initng_history.c (original)
+++ initng/plugins/history/initng_history.c Sun Nov 6 16:01:18 2005
@@ -235,22 +235,22 @@
}
else
{
- /* reset so that *OUTPUT* will be shown again */
- latest = NULL;
-
- /* switch the action type */
+ /* reset so that *OUTPUT* will be shown again */
+ latest = NULL;
+
+ /* switch the action type */
switch (current->action)
{
- case LOADING:
+ case LOADING:
case DONE:
case RUNNING:
case STARTING:
- case STOP_MARKED:
+ case STOP_MARKED:
case STOPPED:
- case FAIL_STOPPING:
- case STOP_DEP_FAILED:
- case FAIL_STARTING:
- case START_DEP_FAILED:
+ case FAIL_STOPPING:
+ case STOP_DEP_FAILED:
+ case FAIL_STARTING:
+ case START_DEP_FAILED:
fprintf(fd, " %.2i:%.2i:%.2i %20s : %s\n", ts->tm_hour,
ts->tm_min, ts->tm_sec, name,
active_db_get_status_string(current->action));
Modified: initng/plugins/iparser/initng_i_parser.c
==============================================================================
--- initng/plugins/iparser/initng_i_parser.c (original)
+++ initng/plugins/iparser/initng_i_parser.c Sun Nov 6 16:01:18 2005
@@ -43,8 +43,9 @@
static void print_line(char *from);
static service_h *parse_file(char *filename, char *watch_for);
static int parse_service_line(char **to_parse, char *watch_for,
- service_h * father, e_type type,
- char *filename, service_h **match, service_h **exact_match);
+ service_h * father, e_type type,
+ char *filename, service_h ** match,
+ service_h ** exact_match);
static int parse_opt(char **where, e_type type, service_h * srv);
static int set_parser(s_entry * type, char **value, service_h * from_service);
@@ -147,6 +148,7 @@
{
/* Complain a bit */
char *line = i_strndup(from, strcspn(from, "\n\0"));
+
D_("%s\n", line);
free(line);
}
@@ -155,7 +157,7 @@
static service_h *parse_file(char *filename, char *watch_for)
{
char *file, *orig;
- e_type t=TYPE_UNKNOWN;
+ e_type t = TYPE_UNKNOWN;
service_h *match = NULL;
service_h *exact_match = NULL;
@@ -190,40 +192,40 @@
/* if this row has keyword service */
if (st_cmp(&file, "service"))
- t=TYPE_SERVICE;
+ t = TYPE_SERVICE;
else if (st_cmp(&file, "class"))
- t=TYPE_CLASS;
+ t = TYPE_CLASS;
else if (st_cmp(&file, "daemon"))
- t=TYPE_DAEMON;
+ t = TYPE_DAEMON;
else if (st_cmp(&file, "virtual"))
- t=TYPE_VIRTUAL;
-
+ t = TYPE_VIRTUAL;
+
+
+ if (t != TYPE_UNKNOWN)
+ {
+ if (parse_service_line(&file, watch_for, NULL, t,
+ filename, &match, &exact_match) == TRUE)
+ {
+ /* if we found RIGHT what we wanted */
+ if (exact_match)
+ {
+ free(orig);
+ return (exact_match);
+ }
+
+ JUMP_TO_NEXT_ROW(file);
+ continue;
+ }
+ }
+
+ /* else BAIL OUT */
- if(t!=TYPE_UNKNOWN)
- {
- if(parse_service_line(&file, watch_for, NULL, t,
- filename, &match, &exact_match)==TRUE)
- {
- /* if we found RIGHT what we wanted */
- if(exact_match)
- {
- free(orig);
- return(exact_match);
- }
-
- JUMP_TO_NEXT_ROW(file);
- continue;
- }
- }
-
- /* else BAIL OUT */
-
- F_("PARSE ERROR parse_file(%s): ", watch_for);
- print_line(file);
- F_("sleeping 2 seconds, then ABORT......\n");
- sleep(2);
- free(orig);
- return(NULL);
+ F_("PARSE ERROR parse_file(%s): ", watch_for);
+ print_line(file);
+ F_("sleeping 2 seconds, then ABORT......\n");
+ sleep(2);
+ free(orig);
+ return (NULL);
} /* end while */
free(orig);
@@ -236,8 +238,9 @@
static int parse_service_line(char **to_parse, char *watch_for,
- service_h * father, e_type type,
- char *filename, service_h **match, service_h **exact_match)
+ service_h * father, e_type type,
+ char *filename, service_h ** match,
+ service_h ** exact_match)
{
char *name = NULL;
char *father_name = NULL;
@@ -372,19 +375,19 @@
{
/* skip spaces and empty lines with them */
JUMP_SPACES(*to_parse);
-
- /* check that this is not the end */
- if((*to_parse)[0]=='\0')
- continue;
-
- /* if the row is ending */
- if((*to_parse)[0]=='\n' || (*to_parse)[0]==';')
- {
- /* walk to next one */
- (*to_parse)++;
- continue;
- }
-
+
+ /* check that this is not the end */
+ if ((*to_parse)[0] == '\0')
+ continue;
+
+ /* 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] == '#')
{
@@ -397,9 +400,9 @@
/* if this row has keyword service */
if (st_cmp(to_parse, "service") == TRUE)
{
- if(parse_service_line(to_parse, watch_for, NULL, TYPE_SERVICE,
- filename, match, exact_match)==FALSE)
- return(FALSE);
+ if (parse_service_line(to_parse, watch_for, NULL, TYPE_SERVICE,
+ filename, match, exact_match) == FALSE)
+ return (FALSE);
JUMP_TO_NEXT_ROW(*to_parse);
continue;
}
@@ -420,18 +423,20 @@
if (st_cmp(to_parse, "class") == TRUE)
{
if (parse_service_line(to_parse, watch_for, NULL, TYPE_CLASS,
- filename, match, exact_match)==FALSE)
- return(FALSE);
+ filename, match, exact_match) == FALSE)
+ 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)) {
- if(new_service) service_db_free(new_service);
- return(FALSE);
- }
-
+ if (!parse_opt(to_parse, type, new_service))
+ {
+ if (new_service)
+ service_db_free(new_service);
+ return (FALSE);
+ }
+
/* ok, this line is parsed, go to next */
JUMP_TO_NEXT_ROW(*to_parse);
}
@@ -451,22 +456,22 @@
service_db_free(new_service);
return (FALSE);
}
-
- if(strcmp(new_service->name, watch_for)==0)
+
+ if (strcmp(new_service->name, watch_for) == 0)
{
- D_("Found EXACT match: %s\n", new_service->name);
- (*exact_match)=new_service;
- return(TRUE);
+ D_("Found EXACT match: %s\n", new_service->name);
+ (*exact_match) = new_service;
+ return (TRUE);
}
-
+
/* check if this is the service we are looking for. */
- if (service_match(watch_for, new_service->name)==TRUE)
+ if (service_match(watch_for, new_service->name) == TRUE)
{
- D_("Found :%s\n", new_service->name);
- (*match)=new_service;
- return(TRUE);
+ D_("Found :%s\n", new_service->name);
+ (*match) = new_service;
+ return (TRUE);
}
-
+
D_("No match\n");
/* return null if not */
return (TRUE);
@@ -478,10 +483,11 @@
{
s_entry *current = NULL;
char *opt_name = NULL;
- int opt_len=0;
+ int opt_len = 0;
int w_l = 0;
int result = FALSE;
int multiline = FALSE;
+
D_("parse_opt: ");
print_line(*where);
@@ -517,51 +523,53 @@
/* detect if it is a multi line option */
{
- int i;
- for(i=0; i<w_l; i++)
- {
- switch((*where)[i])
- {
- /* this idicates that it ends */
- case '\n':
- case ';':
- case '\0':
- multiline=FALSE;
- i=w_l+1; /* stops the for loop */
- break;
- /* this indicates that option will be in more rows */
- case '{':
- multiline=TRUE;
- i=w_l+1; /* stops the for loop */
- break;
- }
- }
+ int i;
+
+ for (i = 0; i < w_l; i++)
+ {
+ switch ((*where)[i])
+ {
+ /* this idicates that it ends */
+ case '\n':
+ case ';':
+ case '\0':
+ multiline = FALSE;
+ i = w_l + 1; /* stops the for loop */
+ break;
+ /* this indicates that option will be in more rows */
+ case '{':
+ multiline = TRUE;
+ i = w_l + 1; /* stops the for loop */
+ break;
+ }
+ }
}
-
+
/* get option name and strip all blanks from it */
- opt_name = initng_calloc(w_l+2, sizeof(char));
+ opt_name = initng_calloc(w_l + 2, sizeof(char));
{
- int i;
- int j=0;
- for(i=0; i<=w_l; i++)
- {
- switch((*where)[i])
- {
- case ' ':
- case '\t':
- continue;
- case '\n':
- case ';':
- i=w_l+1;
- continue;
- }
- opt_name[j++]=(*where)[i];
- }
- opt_name[j]='\0';
+ int i;
+ int j = 0;
+
+ for (i = 0; i <= w_l; i++)
+ {
+ switch ((*where)[i])
+ {
+ case ' ':
+ case '\t':
+ continue;
+ case '\n':
+ case ';':
+ i = w_l + 1;
+ continue;
+ }
+ opt_name[j++] = (*where)[i];
+ }
+ opt_name[j] = '\0';
}
/* we save this, so we dont need to count this every while below */
- opt_len=strlen(opt_name);
-
+ opt_len = strlen(opt_name);
+
/* walk the option db */
while_option_db(current)
{
@@ -623,41 +631,46 @@
while (tmp->opt_type == ALIAS && tmp->alias)
tmp = tmp->alias;
- if(multiline)
- {
- if(tmp->opt_type==MULTILINE_STRING) {
- result = script_parser(current, where, srv);
- } else {
- D_("Option is contains a '{' but is not a MULTILINE_STRING!\n");
- continue;
- }
- } else {
- /* now switch the opt_type */
- switch (tmp->opt_type)
+ if (multiline)
{
- case STRING:
- result = string_parser(current, where, srv);
- break;
- case STRINGS:
- result = strings_parser(current, where, srv);
- break;
- case MULTILINE_STRING:
+ if (tmp->opt_type == MULTILINE_STRING)
+ {
result = script_parser(current, where, srv);
- break;
- case SET:
- result = set_parser(current, where, srv);
- break;
- case UNSET:
- result = unset_parser(current, where, srv);
- break;
- case INT:
- result = int_parser(current, where, srv);
- break;
- default:
- F_("Unknowun, or undefined type to parse!\n");
+ }
+ else
+ {
+ D_("Option is contains a '{' but is not a MULTILINE_STRING!\n");
continue;
+ }
+ }
+ else
+ {
+ /* now switch the opt_type */
+ switch (tmp->opt_type)
+ {
+ case STRING:
+ result = string_parser(current, where, srv);
+ break;
+ case STRINGS:
+ result = strings_parser(current, where, srv);
+ break;
+ case MULTILINE_STRING:
+ result = script_parser(current, where, srv);
+ break;
+ case SET:
+ result = set_parser(current, where, srv);
+ break;
+ case UNSET:
+ result = unset_parser(current, where, srv);
+ break;
+ case INT:
+ result = int_parser(current, where, srv);
+ break;
+ default:
+ F_("Unknowun, or undefined type to parse!\n");
+ continue;
+ }
}
- }
}
free(opt_name);
Modified: initng/plugins/last/initng_last.c
==============================================================================
--- initng/plugins/last/initng_last.c (original)
+++ initng/plugins/last/initng_last.c Sun Nov 6 16:01:18 2005
@@ -61,10 +61,10 @@
if (current == service)
continue;
- /* ignore runlevels */
- /* TODO 20051105 SaTaN0rX: i do not know why i need to check for this */
- if (current->type == TYPE_RUNLEVEL)
- continue;
+ /* ignore runlevels */
+ /* TODO 20051105 SaTaN0rX: i do not know why i need to check for this */
+ if (current->type == TYPE_RUNLEVEL)
+ continue;
/* if this service also shud be started last, continue */
if (active_db_is(&LAST, current))
Modified: initng/plugins/ngc2/ngc2.c
==============================================================================
--- initng/plugins/ngc2/ngc2.c (original)
+++ initng/plugins/ngc2/ngc2.c Sun Nov 6 16:01:18 2005
@@ -163,9 +163,10 @@
/* if we are reloading initng, we wont have an answ from it, so don't fetch any */
if (header.c == 'c')
- {
- printf("Can't give you feedback if reloading of initng succeeds or not.\n");
- exit(0);
+ {
+ printf
+ ("Can't give you feedback if reloading of initng succeeds or not.\n");
+ exit(0);
}
/* FETCH THE RESULT */
Modified: initng/plugins/pause/initng_pause.c
==============================================================================
--- initng/plugins/pause/initng_pause.c (original)
+++ initng/plugins/pause/initng_pause.c Sun Nov 6 16:01:18 2005
@@ -46,7 +46,7 @@
D_(" %s ", s->name);
- if (p->pt == T_START || p->pt==T_DAEMON)
+ if (p->pt == T_START || p->pt == T_DAEMON)
{
/* delay execution a bit */
if ((t = active_db_get_int(&U_U_DELAY, s)) > 0)
Modified: initng/plugins/reload/initng_reload.c
==============================================================================
--- initng/plugins/reload/initng_reload.c (original)
+++ initng/plugins/reload/initng_reload.c Sun Nov 6 16:01:18 2005
@@ -80,31 +80,33 @@
new_entry->type = entry.type;
new_entry->time_got_status = entry.time_got_status;
- /* walk thru all processes */
- pnr=0;
- while(entry.process[pnr].ptype != T_UNKNOWN && pnr < MAX_PROCESSES)
- {
- /* allocate the process */
+ /* walk thru all processes */
+ pnr = 0;
+ while (entry.process[pnr].ptype != T_UNKNOWN && pnr < MAX_PROCESSES)
+ {
+ /* allocate the process */
process = process_db_new(entry.process[pnr].ptype);
- if(!process) continue;
-
- /* fill the data */
- process->pid = entry.process[pnr].pid;
- process->out_pipe[0] = entry.process[pnr].stdout1;
- process->out_pipe[1] = entry.process[pnr].stdout2;
- process->r_code = entry.process[pnr].rcode;
-
- /* allocate a new output buffer for this process */
- process->buffer_pos=0;
- process->buffer=NULL;
-
- /* add this process to the list */
- list_add(&process->list, &new_entry->processes.list);
-
- printf("Added process type %i to %s\n", process->pt, new_entry->name);
-
- pnr++;
- }
+ if (!process)
+ continue;
+
+ /* fill the data */
+ process->pid = entry.process[pnr].pid;
+ process->out_pipe[0] = entry.process[pnr].stdout1;
+ process->out_pipe[1] = entry.process[pnr].stdout2;
+ process->r_code = entry.process[pnr].rcode;
+
+ /* allocate a new output buffer for this process */
+ process->buffer_pos = 0;
+ process->buffer = NULL;
+
+ /* add this process to the list */
+ list_add(&process->list, &new_entry->processes.list);
+
+ printf("Added process type %i to %s\n", process->pt,
+ new_entry->name);
+
+ pnr++;
+ }
i = 0;
while (entry.data[i].opt_type)
@@ -156,7 +158,7 @@
data_save_struct entry;
process_h *process = NULL;
int i;
- int pnr=0;
+ int pnr = 0;
s_data *c_d = NULL;
(void) arg;
@@ -178,19 +180,19 @@
/* collet some proceses */
process = NULL;
- pnr=0;
+ pnr = 0;
while_processes(process, current)
{
- entry.process[pnr].ptype = process->pt;
- entry.process[pnr].pid = process->pid;
- entry.process[pnr].stdout1 = process->out_pipe[0];
- entry.process[pnr].stdout2 = process->out_pipe[1];
- entry.process[pnr].rcode = process->r_code;
- pnr++;
- if(pnr >= MAX_PROCESSES)
- break;
+ entry.process[pnr].ptype = process->pt;
+ entry.process[pnr].pid = process->pid;
+ entry.process[pnr].stdout1 = process->out_pipe[0];
+ entry.process[pnr].stdout2 = process->out_pipe[1];
+ entry.process[pnr].rcode = process->r_code;
+ pnr++;
+ if (pnr >= MAX_PROCESSES)
+ break;
}
- entry.process[pnr].ptype = T_UNKNOWN;
+ entry.process[pnr].ptype = T_UNKNOWN;
/* reset data */
for (i = 0; i < MAX_ENTRYS_FOR_SERVICE; i++)
Modified: initng/plugins/reload/initng_reload.h
==============================================================================
--- initng/plugins/reload/initng_reload.h (original)
+++ initng/plugins/reload/initng_reload.h Sun Nov 6 16:01:18 2005
@@ -64,7 +64,7 @@
/* struct with some processes */
r_process process[MAX_PROCESSES];
-
+
/* struct with some data */
r_d_e data[MAX_ENTRYS_FOR_SERVICE + 1];
} data_save_struct;
Modified: initng/plugins/splash/initng_splash.c
==============================================================================
--- initng/plugins/splash/initng_splash.c (original)
+++ initng/plugins/splash/initng_splash.c Sun Nov 6 16:01:18 2005
@@ -190,10 +190,10 @@
* splash_type == SPLASHY || splash_type == BOOTSPLASH
*/
- if (splash_type == SPLASHY)
- fprintf(fd, "progress %d\n", percent);
- else
- fprintf(fd, "show %d\n", (65535 * percent) / 100);
+ if (splash_type == SPLASHY)
+ fprintf(fd, "progress %d\n", percent);
+ else
+ fprintf(fd, "show %d\n", (65535 * percent) / 100);
/*
* see if X11 is starting
*/
@@ -208,19 +208,19 @@
service->a_status == DONE || percent == 100)
{
/* X11 is being started or runs, or we have reached 100% */
- if (splash_type == SPLASHY)
- {
- fprintf(fd, "progress 99\n");
- fprintf(fd, "allowchvt\n"); //do we need this?
- fprintf(fd, "exit\n"); //terminate splasy
- //Now we should switch to the terminal X start on -but how canwe find out
- //which terminal it is?
- }
- else
- {
- fprintf(fd, "show 65535\n");
- fprintf(fd, "master\n");
- }
+ if (splash_type == SPLASHY)
+ {
+ fprintf(fd, "progress 99\n");
+ fprintf(fd, "allowchvt\n"); //do we need this?
+ fprintf(fd, "exit\n"); //terminate splasy
+ //Now we should switch to the terminal X start on -but how canwe find out
+ //which terminal it is?
+ }
+ else
+ {
+ fprintf(fd, "show 65535\n");
+ fprintf(fd, "master\n");
+ }
}
}
Modified: initng/plugins/stcmd/initng_stcmd.c
==============================================================================
--- initng/plugins/stcmd/initng_stcmd.c (original)
+++ initng/plugins/stcmd/initng_stcmd.c Sun Nov 6 16:01:18 2005
@@ -284,7 +284,7 @@
service_h *s;
/* if no arg, or empty arg set, remove all content */
- if(!arg || strlen(arg) < 2)
+ if (!arg || strlen(arg) < 2)
{
D_("Clearing complete db.\n");
service_db_free_all();
@@ -294,8 +294,8 @@
s = service_db_find_in_name(arg);
if (!s)
{
- F_("Did not find service %s to release cache for!\n", arg);
- return (FALSE);
+ F_("Did not find service %s to release cache for!\n", arg);
+ return (FALSE);
}
D_("removing service data for %s!\n", arg);
Modified: initng/src/initng_active_db.c
==============================================================================
--- initng/src/initng_active_db.c (original)
+++ initng/src/initng_active_db.c Sun Nov 6 16:01:18 2005
@@ -47,6 +47,7 @@
active_h *active_db_find_by_exact_name(const char *service)
{
active_h *current = NULL;
+
D_("(%s);", service);
assert(service);
@@ -76,17 +77,17 @@
D_("(%s);", service);
/* first give the exact find a shot */
- if((current = active_db_find_by_exact_name(service)))
- return(current);
+ if ((current = active_db_find_by_exact_name(service)))
+ return (current);
/* walk the active db and compere */
- current=NULL;
+ current = NULL;
while_active_db(current)
{
assert(current->name);
/* then try to find alike name */
- if(service_match(current->name, service))
- return(current);
+ if (service_match(current->name, service))
+ return (current);
}
@@ -102,29 +103,30 @@
{
active_h *current = NULL;
char *copy = NULL;
- int i=0;
+ int i = 0;
+
assert(service);
D_("(%s);", service);
-
+
/* first search by name */
if ((current = active_db_find_by_name(service)))
- return(current);
+ return (current);
/* remove starting wildcards */
- while(service[0]=='*' || service[0]=='?')
- service++;
+ while (service[0] == '*' || service[0] == '?')
+ service++;
- copy=i_strdup(service);
+ copy = i_strdup(service);
assert(copy);
-
+
/* remove last wildcards */
- for(i=0; copy[i] ; i++)
+ for (i = 0; copy[i]; i++)
{
- if(copy[i]=='*' || copy[i]=='?')
- copy[i]='\0';
+ if (copy[i] == '*' || copy[i] == '?')
+ copy[i] = '\0';
}
-
+
/* then search for a word match */
current = NULL;
while_active_db(current)
@@ -134,12 +136,12 @@
if (strstr(current->name, copy))
{
D_("Warning, the return is not an exact match!\n");
- free(copy);
+ free(copy);
return (current); /* return it */
}
}
free(copy);
-
+
/* did not find any */
return NULL;
}
@@ -274,12 +276,12 @@
d_remove_all(&pf->data.list);
/* remove file cache of entry if present, so we got a fresh read from file when this service is restarted */
- if(pf->from_service)
+ if (pf->from_service)
{
- /* remove from cache list */
- list_del(&pf->from_service->list);
- /* free entry */
- service_db_free(pf->from_service);
+ /* remove from cache list */
+ list_del(&pf->from_service->list);
+ /* free entry */
+ service_db_free(pf->from_service);
}
/* free service name */
@@ -382,13 +384,13 @@
/* count almost all */
switch (current->a_status)
{
- /* dont count stopped services. */
+ /* dont count stopped services. */
case FAIL_STARTING:
case FAIL_STOPPING:
case START_DEP_FAILED:
case STOP_DEP_FAILED:
case STOPPED:
- case FREEING:
+ case FREEING:
break;
default:
counter++;
Modified: initng/src/initng_common.c
==============================================================================
--- initng/src/initng_common.c (original)
+++ initng/src/initng_common.c Sun Nov 6 16:01:18 2005
@@ -387,9 +387,9 @@
/* this will make all services, that depend of this to stop, DEP_FAILED_TO_STOP */
if (service->a_status == FAIL_STOPPING)
{
- /* we might wanna stop services, even if a stop depended service wont stop */
+ /* we might wanna stop services, even if a stop depended service wont stop */
#ifdef DEP_FAIL_TO_STOP
- dep_failed_to_stop(service);
+ dep_failed_to_stop(service);
#endif
check_sys_state_up();
}
Modified: initng/src/initng_execute.c
==============================================================================
--- initng/src/initng_execute.c (original)
+++ initng/src/initng_execute.c Sun Nov 6 16:01:18 2005
@@ -206,7 +206,8 @@
env[nr++] = NULL;
- if(s) {
+ if (s)
+ {
s_call *current, *safe = NULL;
while_call_db_safe(current, safe)
Modified: initng/src/initng_fd.c
==============================================================================
--- initng/src/initng_fd.c (original)
+++ initng/src/initng_fd.c Sun Nov 6 16:01:18 2005
@@ -82,53 +82,56 @@
int initng_process_readpipe_read(active_h * service, process_h * p,
int flush_buffer)
{
- int len = 0; /* lenght of data read */
+ int len = 0; /* lenght of data read */
S_;
-
+
/* check if buffer exits, or have to be created */
- if(!p->buffer)
+ if (!p->buffer)
{
- /* allocate space for the buffer */
- p->buffer=initng_calloc(MAX_BUFFER + 1, sizeof(char));
- p->buffer_pos = 0;
+ /* allocate space for the buffer */
+ p->buffer = initng_calloc(MAX_BUFFER + 1, sizeof(char));
+ p->buffer_pos = 0;
}
/* read data from process, and continue again after a interrupt */
do
{
errno = 0;
- /* can max read MAX_BUFFER (once allocated) - len (all currently read) - buffer_pos */
- if((MAX_BUFFER - len - p->buffer_pos)<1)
- {
- F_("Cant read more, buffer is out!\n");
- break;
- }
- len += read(p->out_pipe[0], &p->buffer[p->buffer_pos], (MAX_BUFFER - len - p->buffer_pos));
+ /* can max read MAX_BUFFER (once allocated) - len (all currently read) - buffer_pos */
+ if ((MAX_BUFFER - len - p->buffer_pos) < 1)
+ {
+ F_("Cant read more, buffer is out!\n");
+ break;
+ }
+ len +=
+ read(p->out_pipe[0], &p->buffer[p->buffer_pos],
+ (MAX_BUFFER - len - p->buffer_pos));
}
while (errno == EINTR);
/* make sure we got something */
- if (len < 1) return(len);
+ if (len < 1)
+ return (len);
/* if we got something. */
-
+
/* null the end to make sure */
p->buffer[p->buffer_pos + len] = '\0';
/* if max buffer is reached, make sure it flushes it */
if (p->buffer_pos + len >= MAX_BUFFER)
- flush_buffer = TRUE;
+ flush_buffer = TRUE;
/* let all plugin take part of data */
initng_plugin_readpipe(service, len, p, flush_buffer);
-
+
/* increase the buffer possision */
if (flush_buffer)
- p->buffer_pos = 0;
+ p->buffer_pos = 0;
else
- p->buffer_pos = p->buffer_pos + len;
-
+ p->buffer_pos = p->buffer_pos + len;
+
/* return lenght of data read */
return (len);
}
@@ -156,7 +159,7 @@
/* get data from process, it return lenght of data got */
len = initng_process_readpipe_read(service, p, flush_buffer);
-
+
if (!flush_buffer)
{
/* We have an error other than EAGAIN, set flush_buffer */
@@ -166,8 +169,8 @@
F_("Error reading from pipe for %s (%s)\n", service->name,
strerror(errno));
}
-
- /* Why flush buffer if we got nothing to read? */
+
+ /* Why flush buffer if we got nothing to read? */
/* End of file */
if (len == 0)
flush_buffer = TRUE;
Modified: initng/src/initng_fork.c
==============================================================================
--- initng/src/initng_fork.c (original)
+++ initng/src/initng_fork.c Sun Nov 6 16:01:18 2005
@@ -63,10 +63,11 @@
}
/* alloc buffer */
- if (process->buffer) {
+ if (process->buffer)
+ {
free(process->buffer);
- process->buffer=NULL;
- process->buffer_pos = 0;
+ process->buffer = NULL;
+ process->buffer_pos = 0;
}
Modified: initng/src/initng_global.c
==============================================================================
--- initng/src/initng_global.c (original)
+++ initng/src/initng_global.c Sun Nov 6 16:01:18 2005
@@ -35,7 +35,7 @@
void initng_new(int argc, char *argv[], char *env[])
{
int i;
-
+
assert(argv);
assert(env);
@@ -44,11 +44,11 @@
g.Argv0 = argv[0];
g.Argv = (char **) initng_calloc(argc + 1, sizeof(char *));
assert(g.Argv);
-
+
for (i = 0; i < argc; i++)
{
g.Argv[i] = i_strdup(argv[i]);
- assert(g.Argv[i]);
+ assert(g.Argv[i]);
}
g.Argv[argc] = NULL;
Modified: initng/src/initng_handler.c
==============================================================================
--- initng/src/initng_handler.c (original)
+++ initng/src/initng_handler.c Sun Nov 6 16:01:18 2005
@@ -549,8 +549,8 @@
switch (current->a_status)
{
case STOPPED:
-
- /* no need to wait on failing services, before stopping */
+
+ /* no need to wait on failing services, before stopping */
case START_DEP_FAILED:
case STOP_DEP_FAILED:
case FAIL_STARTING:
Modified: initng/src/initng_main.c
==============================================================================
--- initng/src/initng_main.c (original)
+++ initng/src/initng_main.c Sun Nov 6 16:01:18 2005
@@ -131,7 +131,7 @@
{
char *argv[] = { i_strdup("sulogin"), NULL };
- execve("/sbin/sulogin", argv, environ); /* launch sulogin */
+ execve("/sbin/sulogin", argv, environ); /* launch sulogin */
}
if (sulogin_pid > 0)
@@ -289,8 +289,9 @@
#ifdef DEBUG
/* if we exit the program before sulogin, we wont be able to gdb initng */
- /*su_login();*/
- printf("Initng segfaulted, will wait in 120 seconds for you to start a gdb, before execve(/sbin/initng-segfault);\n");
+ /*su_login(); */
+ printf
+ ("Initng segfaulted, will wait in 120 seconds for you to start a gdb, before execve(/sbin/initng-segfault);\n");
sleep(120);
#endif
Modified: initng/src/initng_string_tools.c
==============================================================================
--- initng/src/initng_string_tools.c (original)
+++ initng/src/initng_string_tools.c Sun Nov 6 16:01:18 2005
@@ -52,7 +52,7 @@
char *s;
assert(buf);
-
+
for (s = buf; *s; s++)
if (*s == '\n' || *s == ',' || *s == ';' || *s == ' ')
n++;
@@ -87,7 +87,7 @@
{
int i = 0;
int stacks = 1;
-
+
assert(string);
while (string[i] != '\0')
@@ -116,9 +116,9 @@
assert(to_cmp);
assert(string);
-
+
chars = strlen(to_cmp);
-
+
/* skip beginning first spaces */
JUMP_SPACES(*string)
/* this might be an "comp pare" */
@@ -146,7 +146,7 @@
int i = 0;
assert(string);
-
+
/* skip beginning first spaces */
JUMP_SPACES(*string);
@@ -190,7 +190,7 @@
int i = 0;
assert(string);
-
+
/* count tokens */
if ((*string)[0] == '"')
{
@@ -226,7 +226,7 @@
int i = 0;
assert(string);
-
+
/* go to end */
while (string[i] != '\0')
i++;
@@ -246,7 +246,7 @@
int i = 0;
assert(string);
-
+
/* go to end */
while (string[i] != '\0')
i++;
@@ -266,7 +266,7 @@
int i = 0;
assert(string);
-
+
/* stand on last char */
while ((*string)[i] != '\0')
i++;
@@ -295,11 +295,11 @@
assert(string);
assert(pattern);
-
+
/* do pattern matching only if service name does not contain wildcards */
if (strchr(string, '*') || strchr(string, '?'))
{
- F_("The string contains wildcards!\n");
+ F_("The string contains wildcards!\n");
return (FALSE);
}
@@ -309,7 +309,7 @@
if (fnmatch(pattern, string, FNM_CASEFOLD) == 0)
{
- /* found */
+ /* found */
return (TRUE);
}
}
@@ -326,7 +326,7 @@
free(service_mask);
return (TRUE);
}
-
+
/* did not find any */
free(service_mask);
return (FALSE);
Modified: initng/src/initng_struct_data.c
==============================================================================
--- initng/src/initng_struct_data.c (original)
+++ initng/src/initng_struct_data.c Sun Nov 6 16:01:18 2005
@@ -183,8 +183,7 @@
if (type->opt_type != STRING && type->opt_type != MULTILINE_STRING)
{
- F_(" \"%s\" is not an STRING || MULTILINE_STRING type, sleeping 1 sek ..",
- type->opt_name);
+ F_(" \"%s\" is not an STRING || MULTILINE_STRING type, sleeping 1 sek ..", type->opt_name);
sleep(1);
return;
}
Modified: initng/src/main.c
==============================================================================
--- initng/src/main.c (original)
+++ initng/src/main.c Sun Nov 6 16:01:18 2005
@@ -51,83 +51,83 @@
#include "initng_fd.h"
static void setup_console(void)
- {
- int fd; /* /dev/console */
- struct termios tty;
+{
+ int fd; /* /dev/console */
+ struct termios tty;
- D_("MAIN_SET_I_AM_INIT_STUFF\n");
+ D_("MAIN_SET_I_AM_INIT_STUFF\n");
- /* set console loglevel */
- klogctl(8, NULL, 1);
+ /* set console loglevel */
+ klogctl(8, NULL, 1);
- /* enable generation of core files */
- {
- struct rlimit c = { 1000000, 100000 };
- setrlimit(RLIMIT_CORE, &c);
- }
+ /* enable generation of core files */
+ {
+ struct rlimit c = { 1000000, 100000 };
+ setrlimit(RLIMIT_CORE, &c);
+ }
- reboot(RB_DISABLE_CAD); /* Disable Ctrl + Alt + Delete */
+ reboot(RB_DISABLE_CAD); /* Disable Ctrl + Alt + Delete */
- /* Try to open the console, but don't control it */
- if ((fd = open("/dev/console", O_RDWR | O_NOCTTY)) > 0)
- {
- D_("Opened /dev/console. Setting terminal options.\n");
- ioctl(fd, KDSIGACCEPT, SIGWINCH); /* Accept signals from 'kbd' */
- close(fd); /* Like Ctrl + Alt + Delete signal? */
- }
- else
- {
- D_("Failed to open /dev/console. Setting options anyway.\n");
- ioctl(0, KDSIGACCEPT, SIGWINCH); /* Accept signals from 'kbd' */
- }
+ /* Try to open the console, but don't control it */
+ if ((fd = open("/dev/console", O_RDWR | O_NOCTTY)) > 0)
+ {
+ D_("Opened /dev/console. Setting terminal options.\n");
+ ioctl(fd, KDSIGACCEPT, SIGWINCH); /* Accept signals from 'kbd' */
+ close(fd); /* Like Ctrl + Alt + Delete signal? */
+ }
+ else
+ {
+ D_("Failed to open /dev/console. Setting options anyway.\n");
+ ioctl(0, KDSIGACCEPT, SIGWINCH); /* Accept signals from 'kbd' */
+ }
- /* TODO: this block may be incorrect or incomplete */
- /* Q: What does this block really do? */
+ /* TODO: this block may be incorrect or incomplete */
+ /* Q: What does this block really do? */
- /*
- * TODO: /dev/console may still be open from before. Also, if it
- * fails to open, why try to finish the block?
- */
- if ((fd = open("/dev/console", O_RDWR | O_NOCTTY)) < 0)
- {
- F_("main(): can't open /dev/console.\n");
- }
+ /*
+ * TODO: /dev/console may still be open from before. Also, if it
+ * fails to open, why try to finish the block?
+ */
+ if ((fd = open("/dev/console", O_RDWR | O_NOCTTY)) < 0)
+ {
+ F_("main(): can't open /dev/console.\n");
+ }
- (void) tcgetattr(fd, &tty);
+ (void) tcgetattr(fd, &tty);
- tty.c_cflag &= CBAUD | CBAUDEX | CSIZE | CSTOPB | PARENB | PARODD;
- tty.c_cflag |= HUPCL | CLOCAL | CREAD;
+ tty.c_cflag &= CBAUD | CBAUDEX | CSIZE | CSTOPB | PARENB | PARODD;
+ tty.c_cflag |= HUPCL | CLOCAL | CREAD;
- tty.c_cc[VINTR] = 3; /* ctrl('c') */
- tty.c_cc[VQUIT] = 28; /* ctrl('\\') */
- tty.c_cc[VERASE] = 127;
- tty.c_cc[VKILL] = 24; /* ctrl('x') */
- tty.c_cc[VEOF] = 4; /* ctrl('d') */
- tty.c_cc[VTIME] = 0;
- tty.c_cc[VMIN] = 1;
- tty.c_cc[VSTART] = 17; /* ctrl('q') */
- tty.c_cc[VSTOP] = 19; /* ctrl('s') */
- tty.c_cc[VSUSP] = 26; /* ctrl('z') */
-
- /*
- * Set pre and post processing
- */
- tty.c_iflag = IGNPAR | ICRNL | IXON | IXANY;
- tty.c_oflag = OPOST | ONLCR;
- tty.c_lflag = ISIG | ICANON | ECHO | ECHOCTL | ECHOPRT | ECHOKE;
-
- /*
- * Now set the terminal line.
- * We don't care about non-transmitted output data
- * and non-read input data.
- */
- (void) tcsetattr(fd, TCSANOW, &tty);
- (void) tcflush(fd, TCIOFLUSH);
- (void) close(fd);
+ tty.c_cc[VINTR] = 3; /* ctrl('c') */
+ tty.c_cc[VQUIT] = 28; /* ctrl('\\') */
+ tty.c_cc[VERASE] = 127;
+ tty.c_cc[VKILL] = 24; /* ctrl('x') */
+ tty.c_cc[VEOF] = 4; /* ctrl('d') */
+ tty.c_cc[VTIME] = 0;
+ tty.c_cc[VMIN] = 1;
+ tty.c_cc[VSTART] = 17; /* ctrl('q') */
+ tty.c_cc[VSTOP] = 19; /* ctrl('s') */
+ tty.c_cc[VSUSP] = 26; /* ctrl('z') */
+
+ /*
+ * Set pre and post processing
+ */
+ tty.c_iflag = IGNPAR | ICRNL | IXON | IXANY;
+ tty.c_oflag = OPOST | ONLCR;
+ tty.c_lflag = ISIG | ICANON | ECHO | ECHOCTL | ECHOPRT | ECHOKE;
+
+ /*
+ * Now set the terminal line.
+ * We don't care about non-transmitted output data
+ * and non-read input data.
+ */
+ (void) tcsetattr(fd, TCSANOW, &tty);
+ (void) tcflush(fd, TCIOFLUSH);
+ (void) close(fd);
- }
+}
/*
@@ -157,27 +157,27 @@
/* set i_am_init if pid == 1 */
if (getpid() == 1)
g.i_am_init = TRUE;
-
+
/* parse all options, set in argv */
initng_parse_argv(argv);
-
+
/* if this is real init */
if (g.i_am_init)
{
- /* when last service stoped, offer a sulogin */
+ /* when last service stoped, offer a sulogin */
g.when_out = THEN_SULOGIN;
g.runlevel = i_strdup("default");
- if(!g.hot_reload)
- {
- /* static function abowe, initziates the system */
- setup_console();
- }
+ if (!g.hot_reload)
+ {
+ /* static function abowe, initziates the system */
+ setup_console();
+ }
}
else
{
- /* when last service stoped, quit initng */
+ /* when last service stoped, quit initng */
g.when_out = THEN_QUIT;
g.runlevel = i_strdup("fake-default");
}
Modified: initng/tools/install_service.c
==============================================================================
--- initng/tools/install_service.c (original)
+++ initng/tools/install_service.c Sun Nov 6 16:01:18 2005
@@ -30,7 +30,7 @@
#include <sys/types.h>
#include <sys/wait.h>
-/*#define DEBUG*/
+/*#define DEBUG */
#ifdef DEBUG
#define D_(fmt,...) printf(fmt, ## __VA_ARGS__)
@@ -137,33 +137,37 @@
}
return NULL;
}
+
#if 0
static int keyword_in_row(const char *key, const char *row)
{
char *tmp;
- char *st=strndup(row, strcspn(row, "\n\0;"));
+ char *st = strndup(row, strcspn(row, "\n\0;"));
+
tmp = strstr(st, key);
printf("checking for %s in %s\n", key, st);
free(st);
- if(tmp) return(TRUE);
- return(FALSE);
+ if (tmp)
+ return (TRUE);
+ return (FALSE);
}
#endif
int main(int argc, char **argv)
{
int i = 1;
-
- FILE* in;
- FILE* out = NULL;
-
- const char* distro = NULL;
- const char* infile = NULL;
- const char* outfile = NULL;
+
+ FILE *in;
+ FILE *out = NULL;
+
+ const char *distro = NULL;
+ const char *infile = NULL;
+ const char *outfile = NULL;
+
#define LINE_LEN 1000
char line[LINE_LEN];
char exec_buffer[100000];
-
+
#define IF_BLOCK 1
#define EXEC_BLOCK 2
int in_block = 0;
@@ -171,7 +175,7 @@
int if_block_print_out = 0;
int distro_len = -1;
-
+
/* check cmdline for set distribution */
while (argv[i])
@@ -210,16 +214,17 @@
}
distro_len = strlen(distro);
fprintf(stderr, "Distribution set: \"%s\"\n", distro);
-
+
/* open input for writing */
if (!infile)
{
fprintf(stderr, "You have to set input file with -i\n");
exit(1);
}
- if (!(in = fopen(infile, "r"))){
- fprintf(stderr, "could not open input file!\n");
- exit(1);
+ if (!(in = fopen(infile, "r")))
+ {
+ fprintf(stderr, "could not open input file!\n");
+ exit(1);
}
/* open output for writing */
@@ -228,120 +233,153 @@
if (strstr(infile, ".ii"))
{
outfile = strndup(infile, strlen(infile) - 1);
- } else {
+ }
+ else
+ {
fprintf(stderr, "out with -o not set, defaulting to stdout.\n");
out = stdout;
- }
+ }
}
- if (!out && !(out = fopen(outfile, "w"))){
- fprintf(stderr, "could not open output file!\n");
- exit(1);
+ if (!out && !(out = fopen(outfile, "w")))
+ {
+ fprintf(stderr, "could not open output file!\n");
+ exit(1);
}
/* main loop */
while (1)
{
fgets(line, LINE_LEN, in);
- if (feof(in))
+ if (feof(in))
break;
- if (! in_block && line[0] != '#') {
- fprintf(out, "%s", line);
- continue; /* read next line */
- }
-
-/*the string "balh" must be the FIRST parameter, but his improves perf a little bit */
+ if (!in_block && line[0] != '#')
+ {
+ fprintf(out, "%s", line);
+ continue; /* read next line */
+ }
+
+ /*the string "balh" must be the FIRST parameter, but his improves perf a little bit */
#define MATCH(PATTERN, LINE) (strncmp(PATTERN, LINE, sizeof(PATTERN) - 1) == 0)
-
- /* either in_block != 0 or line started with '#' */
- if (! in_block) {
- if (MATCH("#exec", line)){
- D_("found #exec \n");
- exec_buffer[0] = '\0';
+
+ /* either in_block != 0 or line started with '#' */
+ if (!in_block)
+ {
+ if (MATCH("#exec", line))
+ {
+ D_("found #exec \n");
+ exec_buffer[0] = '\0';
in_block = EXEC_BLOCK;
- continue;
- } else if (MATCH("#ifd", line)) {
+ continue;
+ }
+ else if (MATCH("#ifd", line))
+ {
D_("found #ifd\n");
- in_block = IF_BLOCK;
- if_block_print_out = 0;
- if_block_processed = 0;
- if (strstr(line, distro)) {
+ in_block = IF_BLOCK;
+ if_block_print_out = 0;
+ if_block_processed = 0;
+ if (strstr(line, distro))
+ {
/* TODO: better matchin than strstr */
D_("actual distro %s matches line %s", distro, line);
- if_block_print_out = 1;
- if_block_processed = 1;
- }
- continue;
- } else {
+ if_block_print_out = 1;
+ if_block_processed = 1;
+ }
+ continue;
+ }
+ else
+ {
/* line started with a '#', but we are not in_block, and the line was neither
- * #ifd nor #exec. so it's a comment.
- */
- if (MATCH("#elsed", line) ||
- MATCH("#endd", line) ||
- MATCH("#endexec", line)){
- fprintf(stderr, "WARNING: found #elsed, #end or #endexec, but not in BLOCK!\n");
- /* exit here ??? */
- }
- /* this is a comment so print it */
- fprintf(out, "%s", line);
- continue; /* read next line */
- }
- }
+ * #ifd nor #exec. so it's a comment.
+ */
+ if (MATCH("#elsed", line) ||
+ MATCH("#endd", line) || MATCH("#endexec", line))
+ {
+ fprintf(stderr,
+ "WARNING: found #elsed, #end or #endexec, but not in BLOCK!\n");
+ /* exit here ??? */
+ }
+ /* this is a comment so print it */
+ fprintf(out, "%s", line);
+ continue; /* read next line */
+ }
+ }
/* ok, we are in a block */
- if (in_block == IF_BLOCK) {
- if (if_block_print_out){
- /*if the block should be printed up to now */
- if (MATCH("#endd", line) || MATCH("#elsed", line)) {
- /* elsed or endd, but this section should be printed => stop printing */
- if_block_print_out = 0;
- /* endd => in_block = 0; */
- if (MATCH("#endd", line))
+ if (in_block == IF_BLOCK)
+ {
+ if (if_block_print_out)
+ {
+ /*if the block should be printed up to now */
+ if (MATCH("#endd", line) || MATCH("#elsed", line))
+ {
+ /* elsed or endd, but this section should be printed => stop printing */
+ if_block_print_out = 0;
+ /* endd => in_block = 0; */
+ if (MATCH("#endd", line))
in_block = 0;
- continue;
- } else {
+ continue;
+ }
+ else
+ {
/* in if block that should be printed => print it */
fprintf(out, "%s", line);
- continue;
- }
-
- } else {
+ continue;
+ }
+
+ }
+ else
+ {
/* if block that should not be printed: check for elsed, endd */
- if (MATCH("#elsed", line)){
+ if (MATCH("#elsed", line))
+ {
D_("found #elsed\n");
- /* now we need to check if there is some distro specified */
- if (strlen(line) == sizeof("#elsed\n") - 1) {
+ /* now we need to check if there is some distro specified */
+ if (strlen(line) == sizeof("#elsed\n") - 1)
+ {
/*no distro specified */
- if (!if_block_processed) {
- /* this if block has not yet been processed, so print this one */
- if_block_print_out = 1;
- }
- continue;
- } else { /* #elsed blahblah */
- if (strstr(line, distro)) {
- /* TODO: better matching than strstr */
- if_block_print_out = 1;
- if_block_processed = 1;
- continue;
- }
- }
- } else if (MATCH("#endd", line)) {
- in_block = 0;
- continue;
- } else
- continue;
- }
- } else {
+ if (!if_block_processed)
+ {
+ /* this if block has not yet been processed, so print this one */
+ if_block_print_out = 1;
+ }
+ continue;
+ }
+ else
+ { /* #elsed blahblah */
+ if (strstr(line, distro))
+ {
+ /* TODO: better matching than strstr */
+ if_block_print_out = 1;
+ if_block_processed = 1;
+ continue;
+ }
+ }
+ }
+ else if (MATCH("#endd", line))
+ {
+ in_block = 0;
+ continue;
+ }
+ else
+ continue;
+ }
+ }
+ else
+ {
/* in_block == EXEC_BLOCK */
- if (MATCH("#endexec", line)) {
+ if (MATCH("#endexec", line))
+ {
printf("found #endexec\n");
- /* Do the exec shit*/
- fprintf(out, "%s", do_exec(exec_buffer, strlen(exec_buffer)));
- in_block = 0;
- continue;
- } else {
+ /* Do the exec shit */
+ fprintf(out, "%s", do_exec(exec_buffer, strlen(exec_buffer)));
+ in_block = 0;
+ continue;
+ }
+ else
+ {
strcat(exec_buffer, line);
- continue;
- }
- }
+ continue;
+ }
+ }
}
fclose(in);
fclose(out);
More information about the Initng-svn
mailing list