[Initng-svn] r3989 - in initng/trunk: . plugins/bash_launcher plugins/history plugins/simple_launcher plugins/stcmd src tools
svn at initng.thinktux.net
svn at initng.thinktux.net
Tue May 2 01:54:46 CEST 2006
Author: jimmy
Date: Tue May 2 01:54:44 2006
New Revision: 3989
Modified:
initng/trunk/TODO
initng/trunk/plugins/bash_launcher/initng_bash_launcher.c
initng/trunk/plugins/history/initng_history.c
initng/trunk/plugins/ngc4/initng_ngc4.c
initng/trunk/plugins/ngc4/initng_ngc4.h
initng/trunk/plugins/ngc4/libngcclient.c
initng/trunk/plugins/simple_launcher/initng_simple_launcher.c
initng/trunk/plugins/stcmd/initng_stcmd.c
initng/trunk/src/initng_execute.c
initng/trunk/src/initng_execute.h
initng/trunk/src/initng_fd.c
initng/trunk/src/initng_fork.c
initng/trunk/src/initng_main.c
initng/trunk/src/initng_plugin.h
initng/trunk/src/initng_static_service_types.c
initng/trunk/tools/itool.c
Log:
Cleanup and indention.
Modified: initng/trunk/TODO
==============================================================================
--- initng/trunk/TODO (original)
+++ initng/trunk/TODO Tue May 2 01:54:44 2006
@@ -2,4 +2,12 @@
UP_CHECK hook is not ever checked or called, fix.
-Move all selinux stuff to an own selinux plugin.
\ No newline at end of file
+Move all selinux stuff to an own selinux plugin.
+
+add nge events, percentage, and kill notice, when a process dies nge shud know.
+
+Fix the xml parser.
+
+create ngc5 with an shiny new xml data backend.
+
+dbus work, for a dbusc plugin.
\ No newline at end of file
Modified: initng/trunk/plugins/bash_launcher/initng_bash_launcher.c
==============================================================================
--- initng/trunk/plugins/bash_launcher/initng_bash_launcher.c (original)
+++ initng/trunk/plugins/bash_launcher/initng_bash_launcher.c Tue May 2 01:54:44 2006
@@ -69,7 +69,8 @@
const char *script, const char *args);
-static int initng_bash(active_db_h * service, process_h * process, const char *exec_name)
+static int initng_bash(active_db_h * service, process_h * process,
+ const char *exec_name)
{
const char *e = NULL;
const char *args = NULL;
Modified: initng/trunk/plugins/history/initng_history.c
==============================================================================
--- initng/trunk/plugins/history/initng_history.c (original)
+++ initng/trunk/plugins/history/initng_history.c Tue May 2 01:54:44 2006
@@ -54,6 +54,7 @@
while_history_db_prev(current)
{
active_row *row = payload->p + (i * sizeof(active_row));
+
row->dt = ACTIVE_ROW;
/* if action is not set, it is probably a string logged in this db */
Modified: initng/trunk/plugins/ngc4/initng_ngc4.c
==============================================================================
--- initng/trunk/plugins/ngc4/initng_ngc4.c (original)
+++ initng/trunk/plugins/ngc4/initng_ngc4.c Tue May 2 01:54:44 2006
@@ -898,7 +898,8 @@
payload->s = sizeof(active_row);
memset(payload->p, 0, sizeof(active_row));
active_row *row = payload->p;
- row->dt=ACTIVE_ROW;
+
+ row->dt = ACTIVE_ROW;
/* argument required */
if (!arg || strlen(arg) < 2)
@@ -967,7 +968,8 @@
payload->s = sizeof(active_row);
memset(payload->p, 0, sizeof(active_row));
active_row *row = payload->p;
- row->dt=ACTIVE_ROW;
+
+ row->dt = ACTIVE_ROW;
/* argument required */
if (!arg || strlen(arg) < 2)
@@ -1024,7 +1026,7 @@
memset(payload->p, 0, sizeof(option_row));
option_row *row = payload->p;
- row->dt=OPTION_ROW;
+ row->dt = OPTION_ROW;
strncpy(row->n, arg, 100);
strcpy(row->d, "NOT_FOUND");
row->t = 0;
@@ -1056,8 +1058,8 @@
if (!current->opt_name)
continue;
-
- row->dt=OPTION_ROW;
+
+ row->dt = OPTION_ROW;
row->d[0] = '\0';
strncpy(row->n, current->opt_name, 100);
@@ -1110,19 +1112,19 @@
/* get on a entry */
state_row *row = payload->p + (i * sizeof(state_row));
-
+
/* set the datatype */
- row->dt=STATE_ROW;
+ row->dt = STATE_ROW;
/* copy name */
assert(current->state_name);
strncpy(row->name, current->state_name, 100);
/* copy description */
- if(current->state_desc)
+ if (current->state_desc)
strncpy(row->desc, current->state_desc, 200);
else
- row->desc[0]='\0';
+ row->desc[0] = '\0';
/* set is */
row->is = current->is;
@@ -1186,6 +1188,7 @@
while_active_db(current)
{
active_row *row = payload->p + (i * sizeof(active_row));
+
row->dt = ACTIVE_ROW;
if (current->current_state && current->current_state->state_name)
Modified: initng/trunk/plugins/ngc4/initng_ngc4.h
==============================================================================
--- initng/trunk/plugins/ngc4/initng_ngc4.h (original)
+++ initng/trunk/plugins/ngc4/initng_ngc4.h Tue May 2 01:54:44 2006
@@ -43,7 +43,7 @@
/* this is a structure for an help_row payload */
typedef struct
{
- data_type dt; /* == HELP_ROW */
+ data_type dt; /* == HELP_ROW */
char c;
char l[101];
e_com_type t;
@@ -54,7 +54,7 @@
/* this is a structure for an active_row payload */
typedef struct
{
- data_type dt; /* == ACTIVE_ROW */
+ data_type dt; /* == ACTIVE_ROW */
char state[101]; /* status, a word describing the status */
char name[101]; /* name of service */
struct timeval time_set; /* time status set */
@@ -65,7 +65,7 @@
/* this is a structor for a state description payload */
typedef struct
{
- data_type dt; /* == STATE_ROW */
+ data_type dt; /* == STATE_ROW */
char name[101];
e_is is;
char desc[201];
@@ -74,7 +74,7 @@
/* this is a structure for an option_row payload */
typedef struct
{
- data_type dt; /* == OPTION_ROW */
+ data_type dt; /* == OPTION_ROW */
char n[101];
e_dt t;
char o[101];
Modified: initng/trunk/plugins/ngc4/libngcclient.c
==============================================================================
--- initng/trunk/plugins/ngc4/libngcclient.c (original)
+++ initng/trunk/plugins/ngc4/libngcclient.c Tue May 2 01:54:44 2006
@@ -405,9 +405,9 @@
string = strdup("No payload.\n");
return (string);
}
-
+
/* look att the data type, first char */
- switch((data_type) ((int *)rep->payload)[0])
+ switch ((data_type) ((int *) rep->payload)[0])
{
case HELP_ROW:
string = ngc_hlp(rep, ansi);
@@ -422,7 +422,8 @@
string = ngc_state_entry(rep, ansi);
break;
default:
- printf("UNKWNOWN PAYLOAD: %i\n", (int) ((int *)rep->payload)[0]);
+ printf("UNKWNOWN PAYLOAD: %i\n",
+ (int) ((int *) rep->payload)[0]);
break;
}
break;
Modified: initng/trunk/plugins/simple_launcher/initng_simple_launcher.c
==============================================================================
--- initng/trunk/plugins/simple_launcher/initng_simple_launcher.c (original)
+++ initng/trunk/plugins/simple_launcher/initng_simple_launcher.c Tue May 2 01:54:44 2006
@@ -370,7 +370,8 @@
return (result);
}
-static int initng_s_launch(active_db_h * service, process_h * process, const char *exec_name)
+static int initng_s_launch(active_db_h * service, process_h * process,
+ const char *exec_name)
{
assert(service);
Modified: initng/trunk/plugins/stcmd/initng_stcmd.c
==============================================================================
--- initng/trunk/plugins/stcmd/initng_stcmd.c (original)
+++ initng/trunk/plugins/stcmd/initng_stcmd.c Tue May 2 01:54:44 2006
@@ -171,7 +171,7 @@
};
s_command RUN = { 'U', "run", TRUE_OR_FALSE_COMMAND, ADVANCHED_COMMAND, REQUIRES_OPT,
- {(void *) &cmd_run },
+ {(void *) &cmd_run},
"Simply run an exec with specified name, example ngc --run service/test:start"
};
@@ -553,49 +553,47 @@
ptype_h EXTERN_RUN = { "extern_arg", NULL };
static int cmd_run(char *arg)
{
- char * runtype = NULL;
- char * serv_name = NULL;
- active_db_h * service = NULL;
-
+ char *runtype = NULL;
+ char *serv_name = NULL;
+ active_db_h *service = NULL;
+
/* search for a ':' char in arg */
runtype = strchr(arg, ':');
- if(!runtype || runtype[0] != ':')
+ if (!runtype || runtype[0] != ':')
{
W_("Bad format: --run \"%s\"\n");
- return(FALSE);
+ return (FALSE);
}
-
+
/* if serv name is less then 2 chars */
- if(runtype - arg - 1 < 2)
+ if (runtype - arg - 1 < 2)
{
W_("Bad format: --run \"%s\"\n");
- return(FALSE);
+ return (FALSE);
}
/* skip the ':' char */
runtype++;
-
+
/* copy serv_name so we can put a '\0' to mark end */
- serv_name=i_strndup(arg, runtype-arg- 1);
-
- service=initng_active_db_find_by_name(serv_name);
- if(!service)
- {
- F_("Service \"%s\" was not found, trying to run.\n", serv_name);
- free(serv_name);
- return(FALSE);
- }
-
- /* wont need it anymore */
+ serv_name = i_strndup(arg, runtype - arg - 1);
+
+ service = initng_active_db_find_by_name(serv_name);
+ if (!service)
+ {
+ F_("Service \"%s\" was not found, trying to run.\n", serv_name);
free(serv_name);
-
- printf("Found service %s\n", service->name);
-
- if(initng_execute_launch(service, &EXTERN_RUN, runtype)!=TRUE)
- return(FALSE);
-
+ return (FALSE);
+ }
+
+ /* wont need it anymore */
+ free(serv_name);
+
+ if (initng_execute_launch(service, &EXTERN_RUN, runtype) != TRUE)
+ return (FALSE);
+
/* return happily */
- return(TRUE);
+ return (TRUE);
}
int module_init(int api_version)
Modified: initng/trunk/src/initng_execute.c
==============================================================================
--- initng/trunk/src/initng_execute.c (original)
+++ initng/trunk/src/initng_execute.c Tue May 2 01:54:44 2006
@@ -43,7 +43,8 @@
#include "initng_static_data_id.h"
#include "initng_plugin.h"
-int initng_execute_launch(active_db_h * service, ptype_h * type, const char *exec_name)
+int initng_execute_launch(active_db_h * service, ptype_h * type,
+ const char *exec_name)
{
s_call *current, *q = NULL;
process_h *process = NULL;
@@ -76,7 +77,7 @@
list_add(&process->list, &service->processes.list);
/* make sure we have a exec_name */
- if(!exec_name)
+ if (!exec_name)
exec_name = type->name;
/* walk the db with hooks */
Modified: initng/trunk/src/initng_execute.h
==============================================================================
--- initng/trunk/src/initng_execute.h (original)
+++ initng/trunk/src/initng_execute.h Tue May 2 01:54:44 2006
@@ -23,6 +23,7 @@
#include "initng_active_db.h"
#include "initng_process_db.h"
-int initng_execute_launch(active_db_h * service, ptype_h * type, const char * exec_name);
+int initng_execute_launch(active_db_h * service, ptype_h * type,
+ const char *exec_name);
#endif
Modified: initng/trunk/src/initng_fd.c
==============================================================================
--- initng/trunk/src/initng_fd.c (original)
+++ initng/trunk/src/initng_fd.c Tue May 2 01:54:44 2006
@@ -234,17 +234,17 @@
if (tmp)
{
p->buffer = tmp;
- p->buffer_allocated = 9000; /* shorted by 1000 chars */
- }
+ p->buffer_allocated = 9000; /* shorted by 1000 chars */
+ }
else
{
F_("realloc failed, possibly out of memory!\n");
}
-
+
/* Even if realloc failed, the buffer is still valid
and we've still reduced the length of its contents */
- p->buffer_len = 9000; /* shortened by 1000 chars */
- p->buffer[9000] = '\0'; /* shortened by 1000 chars */
+ p->buffer_len = 9000; /* shortened by 1000 chars */
+ p->buffer[9000] = '\0'; /* shortened by 1000 chars */
}
}
Modified: initng/trunk/src/initng_fork.c
==============================================================================
--- initng/trunk/src/initng_fork.c (original)
+++ initng/trunk/src/initng_fork.c Tue May 2 01:54:44 2006
@@ -95,42 +95,42 @@
#endif
- if(g.i_am != I_AM_UTILITY)
+ if (g.i_am != I_AM_UTILITY)
{
- /* TODO, comment this */
- if (g.i_am == I_AM_INIT)
- {
- ioctl(0, TIOCNOTTY, 0);
- setsid(); /* Run a program in a new session ??? */
- }
+ /* TODO, comment this */
+ if (g.i_am == I_AM_INIT)
+ {
+ ioctl(0, TIOCNOTTY, 0);
+ setsid(); /* Run a program in a new session ??? */
+ }
- /*
- * set up file descriptors, for local fork,
- * a fork in initng, should now receive any input, but stdout & stderr, should be sent
- * to process->out_pipe[], that is set up by pipe() #man 2 pipe
- * [0] for reading, and [1] for writing, as the pipe is for sending output
- * FROM the fork, to initng for handle, the input part should be closed here,
- * the other are mapped to STDOUT and STDERR.
- */
-
- /* close stdin/stdout/stderr */
- /*close(STDIN_FILENO); */
- close(STDOUT_FILENO);
- close(STDERR_FILENO);
-
- /* Duplicate stdout and stderr to the stdout[1] */
- dup2(process->out_pipe[1], STDOUT_FILENO);
- dup2(process->out_pipe[1], STDERR_FILENO);
-
- /* set stdin, stdout, and stderr, that is should not be closed, if this child do execve() */
- fcntl(STDIN_FILENO, F_SETFD, 0);
- fcntl(STDOUT_FILENO, F_SETFD, 0);
- fcntl(STDERR_FILENO, F_SETFD, 0);
-
- /* Close the sides of the pipes we don't need, as we're in fork we won't need this part. */
- if (process->out_pipe[0] > 0)
- close(process->out_pipe[0]);
- process->out_pipe[0] = -1;
+ /*
+ * set up file descriptors, for local fork,
+ * a fork in initng, should now receive any input, but stdout & stderr, should be sent
+ * to process->out_pipe[], that is set up by pipe() #man 2 pipe
+ * [0] for reading, and [1] for writing, as the pipe is for sending output
+ * FROM the fork, to initng for handle, the input part should be closed here,
+ * the other are mapped to STDOUT and STDERR.
+ */
+
+ /* close stdin/stdout/stderr */
+ /*close(STDIN_FILENO); */
+ close(STDOUT_FILENO);
+ close(STDERR_FILENO);
+
+ /* Duplicate stdout and stderr to the stdout[1] */
+ dup2(process->out_pipe[1], STDOUT_FILENO);
+ dup2(process->out_pipe[1], STDERR_FILENO);
+
+ /* set stdin, stdout, and stderr, that is should not be closed, if this child do execve() */
+ fcntl(STDIN_FILENO, F_SETFD, 0);
+ fcntl(STDOUT_FILENO, F_SETFD, 0);
+ fcntl(STDERR_FILENO, F_SETFD, 0);
+
+ /* Close the sides of the pipes we don't need, as we're in fork we won't need this part. */
+ if (process->out_pipe[0] > 0)
+ close(process->out_pipe[0]);
+ process->out_pipe[0] = -1;
}
Modified: initng/trunk/src/initng_main.c
==============================================================================
--- initng/trunk/src/initng_main.c (original)
+++ initng/trunk/src/initng_main.c Tue May 2 01:54:44 2006
@@ -449,7 +449,7 @@
}
}
#else
-#if 0 /* deadlocks sometimes due to libc locks; need to use direct syscalls */
+#if 0 /* deadlocks sometimes due to libc locks; need to use direct syscalls */
/* Fork a new process and dump core. Works reasonably well as we're not
using threads for anything. If we were, we'd need Google Coredumper */
{
Modified: initng/trunk/src/initng_plugin.h
==============================================================================
--- initng/trunk/src/initng_plugin.h (original)
+++ initng/trunk/src/initng_plugin.h Tue May 2 01:54:44 2006
@@ -50,7 +50,8 @@
void (*swatcher) (h_sys_state state);
int (*pipewatcher) (active_db_h * service, process_h * process,
char *buffer_pos);
- int (*launch) (active_db_h * service, process_h * process, const char *exec_name);
+ int (*launch) (active_db_h * service, process_h * process,
+ const char *exec_name);
int (*af_launcher) (active_db_h * service, process_h * process);
int (*handle_killed) (active_db_h * service, process_h * process);
void (*main) (void);
Modified: initng/trunk/src/initng_static_service_types.c
==============================================================================
--- initng/trunk/src/initng_static_service_types.c (original)
+++ initng/trunk/src/initng_static_service_types.c Tue May 2 01:54:44 2006
@@ -49,8 +49,9 @@
#include "initng_static_states.h"
-stype_h TYPE_CONTAINER = { "container", "This is an empty set that can be used as a container, and you can relate other services data to this one.",
-NULL, NULL, NULL };
+stype_h TYPE_CONTAINER = { "container", "This is an empty set that can be used as a container, and you can relate other services data to this one.",
+ NULL, NULL, NULL
+};
void initng_service_register_static_stypes(void)
{
Modified: initng/trunk/tools/itool.c
==============================================================================
--- initng/trunk/tools/itool.c (original)
+++ initng/trunk/tools/itool.c Tue May 2 01:54:44 2006
@@ -96,7 +96,7 @@
int main(int argc, char *argv[], char *env[])
{
/*printf("argc: %i argv[0]: %s argv[1]: %s argv[2]: %s\n", argc, argv[0],
- argv[1], argv[2]);*/
+ argv[1], argv[2]); */
/* initialise global variables */
initng_global_new(argc, argv, env, I_AM_UTILITY);
More information about the Initng-svn
mailing list