[Initng-svn] r3659 - in initng/trunk: . devtool plugins/also
plugins/bash_launcher plugins/chdir plugins/chroot
plugins/conflict plugins/critical plugins/daemon
plugins/dbus_event plugins/debug_commands plugins/envparser
plugins/find plugins/fstat plugins/history plugins/idleprobe
plugins/initctl plugins/iparser plugins/last plugins/limit
plugins/lockfile plugins/logfile plugins/netprobe
plugins/ngc4 plugins/nge plugins/pause plugins/reload
plugins/renice plugins/rlparser plugins/runlevel
plugins/service plugins/simple_launcher plugins/stdout
plugins/suid plugins/syncron src
svn at initng.thinktux.net
svn at initng.thinktux.net
Tue Apr 4 04:04:16 CEST 2006
Author: jimmy
Date: Tue Apr 4 04:04:13 2006
New Revision: 3659
Modified:
initng/trunk/devtool/test_parser.c
initng/trunk/link_install.sh
initng/trunk/plugins/also/initng_also.c
initng/trunk/plugins/bash_launcher/initng_bash_launcher.c
initng/trunk/plugins/chdir/initng_chdir.c
initng/trunk/plugins/chroot/initng_chroot.c
initng/trunk/plugins/conflict/initng_conflict.c
initng/trunk/plugins/critical/initng_critical.c
initng/trunk/plugins/daemon/initng_daemon.c
initng/trunk/plugins/dbus_event/dbus_nge.c
initng/trunk/plugins/dbus_event/initng_dbusevent.c
initng/trunk/plugins/debug_commands/print_service.c
initng/trunk/plugins/envparser/initng_envparser.c
initng/trunk/plugins/find/initng_find.c
initng/trunk/plugins/fstat/initng_fstat.c
initng/trunk/plugins/history/initng_history.c
initng/trunk/plugins/idleprobe/initng_idleprobe.c
initng/trunk/plugins/initctl/initng_initctl.c
initng/trunk/plugins/iparser/initng_i_parser.c
initng/trunk/plugins/last/initng_last.c
initng/trunk/plugins/limit/initng_limit.c
initng/trunk/plugins/lockfile/initng_lockfile.c
initng/trunk/plugins/logfile/initng_logfile.c
initng/trunk/plugins/netprobe/initng_netprobe.c
initng/trunk/plugins/ngc4/initng_ngc4.c
initng/trunk/plugins/ngc4/initng_ngc4.h
initng/trunk/plugins/ngc4/libngcclient.c
initng/trunk/plugins/ngc4/ngc4.c
initng/trunk/plugins/nge/initng_nge.c
initng/trunk/plugins/nge/libngeclient.c
initng/trunk/plugins/pause/initng_pause.c
initng/trunk/plugins/reload/initng_reload.c
initng/trunk/plugins/renice/initng_renice.c
initng/trunk/plugins/rlparser/initng_rl_parser.c
initng/trunk/plugins/runlevel/initng_runlevel.c
initng/trunk/plugins/service/initng_service.c
initng/trunk/plugins/simple_launcher/initng_simple_launcher.c
initng/trunk/plugins/stdout/initng_stdout.c
initng/trunk/plugins/suid/initng_suid.c
initng/trunk/plugins/syncron/initng_syncron.c
initng/trunk/src/initng_active_db.c
initng/trunk/src/initng_active_db.h
initng/trunk/src/initng_common.c
initng/trunk/src/initng_depend.c
initng/trunk/src/initng_env_variable.c
initng/trunk/src/initng_fd.c
initng/trunk/src/initng_global.c
initng/trunk/src/initng_global.h
initng/trunk/src/initng_handler.c
initng/trunk/src/initng_plugin.h
initng/trunk/src/initng_plugin_callers.c
initng/trunk/src/initng_service_cache.c
initng/trunk/src/initng_service_cache.h
initng/trunk/src/initng_service_data_types.c
initng/trunk/src/initng_service_data_types.h
initng/trunk/src/initng_struct_data.c
initng/trunk/src/initng_struct_data.h
Log:
rewritten initng_struct_data.c to work more generic and more optimized.
This commit will probably introduce some new bugs.. :-)
Modified: initng/trunk/devtool/test_parser.c
==============================================================================
--- initng/trunk/devtool/test_parser.c (original)
+++ initng/trunk/devtool/test_parser.c Tue Apr 4 04:04:13 2006
@@ -198,7 +198,7 @@
printf("Service %s is failed because:\n", srv_name);
while_service_cache(current)
{
- switch (initng_service_cache_get_int(&STATUS, current))
+ switch (get_int(&STATUS, current))
{
case PARSE_ERR:
printf("%s has parsing errors or service file was not found\n", current->name);
@@ -206,8 +206,7 @@
case CIRCULAR_ERR:
printf("%s has circular dependency with %s\n",
current->name,
- initng_service_cache_get_string(&CIRCULAR,
- current));
+ get_string(&CIRCULAR, current));
break;
case DEPEND_ERR:
if (print_dep_err == 1)
@@ -308,7 +307,7 @@
if (service)
{
initng_service_cache_add(service);
- initng_service_cache_set_int(&STATUS, service, PARSE_ERR);
+ set_int(&STATUS, service, PARSE_ERR);
}
return result;
}
@@ -323,15 +322,13 @@
result = OK;
- initng_service_cache_set_int(&STATUS, service, OK);
+ set_int(&STATUS, service, OK);
+ s_data *itt = NULL;
- while ((string =
- initng_service_cache_get_next_string(&NEED, service, string)))
+ while ((string = get_next_string(&NEED, service, &itt)))
{
tmp_service = initng_service_cache_find_by_name(string);
- if (!tmp_service
- || (srv_status =
- initng_service_cache_get_int(&STATUS, tmp_service)) == 0)
+ if (!tmp_service || (srv_status = get_int(&STATUS, tmp_service)) == 0)
result &= load_service(string, level + 1);
else
result &= (srv_status > NOT_OK) ? OK : NOT_OK;
@@ -347,8 +344,7 @@
printf("%s - ok\n", name);
}
- initng_service_cache_set_int(&STATUS, service,
- (result == NOT_OK) ? DEPEND_ERR : OK);
+ set_int(&STATUS, service, (result == NOT_OK) ? DEPEND_ERR : OK);
return result;
}
@@ -372,21 +368,21 @@
if (!service)
status = NOT_OK;
else
- status = initng_service_cache_get_int(&STATUS, service);
+ status = get_int(&STATUS, service);
if (status == CHECKED)
result = OK;
if (status == OK)
{
+ s_data *itt = NULL;
result = OK;
my_list = (const char **) i_calloc(level + 2, sizeof(char *));
my_list[level + 1] = NULL;
- while ((string =
- initng_service_cache_get_next_string(&NEED, service, string)))
+ while ((string = get_next_string(&NEED, service, &itt)))
{
tmp_result = OK;
@@ -395,9 +391,8 @@
if (strcmp(string, dep_list[j]) == 0)
{
status = CIRCULAR_ERR;
- initng_service_cache_set_int(&STATUS, service, status);
- initng_service_cache_set_string(&CIRCULAR, service,
- i_strdup(string));
+ set_int(&STATUS, service, status);
+ set_string(&CIRCULAR, service, i_strdup(string));
if (verbose == 1)
{
SPACE;
@@ -435,7 +430,7 @@
CIRCULAR_ERR) ? DEPEND_ERR : CIRCULAR_ERR);
if (service)
- initng_service_cache_set_int(&STATUS, service, status);
+ set_int(&STATUS, service, status);
return result;
}
Modified: initng/trunk/link_install.sh
==============================================================================
--- initng/trunk/link_install.sh (original)
+++ initng/trunk/link_install.sh Tue Apr 4 04:04:13 2006
@@ -31,14 +31,18 @@
for i in `find plugins -name *so -printf "%f "`; do
ln -s -f ${INITNG_DIR}/`find plugins -name $i` /lib/initng/$i
done
-ln -s -f ${INITNG_DIR}/plugins/ngc2/ngc /sbin/ngc
-ln -s -f ${INITNG_DIR}/plugins/ngc2/ngdc /sbin/ngdc
-ln -s -f ${INITNG_DIR}/plugins/ngc2/ngstart /sbin/ngstart
-ln -s -f ${INITNG_DIR}/plugins/ngc2/ngstop /sbin/ngstop
-ln -s -f ${INITNG_DIR}/plugins/ngc2/ngzap /sbin/ngzap
-ln -s -f ${INITNG_DIR}/plugins/ngc2/ngrestart /sbin/ngrestart
-ln -s -f ${INITNG_DIR}/plugins/ngc2/ngreboot /sbin/ngreboot
-ln -s -f ${INITNG_DIR}/plugins/ngc2/nghalt /sbin/nghalt
-ln -s -f ${INITNG_DIR}/plugins/ngc2/ngstatus /sbin/ngstatus
+
+NGC4_LINK_SBIN="ngc ngdc ngstart ngstop ngzap ngrestart ngreboot nghalt ngstatus"
+for i in $NGC4_LINK_SBIN; do
+ echo "${INITNG_DIR}/plugins/ngc4/$i --> /sbin/$i"
+ ln -s -f ${INITNG_DIR}/plugins/ngc4/.libs/ngc /sbin/$i
+done
+
+
+ln -s -f ${INITNG_DIR}/plugins/nge/nge /sbin/nge
+ln -s -f ${INITNG_DIR}/plugins/nge/nge_raw /sbin/nge_raw
+ln -s -f ${INITNG_DIR}/plugins/nge/ngde /sbin/ngde
+
+rm /lib/initng/*client.so
exit 0
exit 1
Modified: initng/trunk/plugins/also/initng_also.c
==============================================================================
--- initng/trunk/plugins/also/initng_also.c (original)
+++ initng/trunk/plugins/also/initng_also.c Tue Apr 4 04:04:13 2006
@@ -53,8 +53,9 @@
if (IS_STARTING(service))
{
tmp = NULL;
- while ((tmp =
- initng_active_db_get_next_string(&ALSO_START, service, tmp)))
+ s_data *itt = NULL;
+
+ while ((tmp = get_next_string(&ALSO_START, service, &itt)))
{
char *fixed = NULL;
@@ -89,8 +90,9 @@
{
/* Handle ALSO_STOP */
tmp = NULL;
- while ((tmp =
- initng_active_db_get_next_string(&ALSO_STOP, service, tmp)))
+ s_data *itt = NULL;
+
+ while ((tmp = get_next_string(&ALSO_STOP, service, &itt)))
{
char *fixed = NULL;
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 Apr 4 04:04:13 2006
@@ -72,15 +72,11 @@
assert(service->name);
/* WE ARE EXECUTING A START MULTILINE_STRING */
- if (!
- (e =
- initng_active_db_get_string_var(&SCRIPT, process->pt->name,
- service)))
+ if (!(e = get_string_var(&SCRIPT, process->pt->name, service)))
return (FALSE);
/* get the arguments if any */
- args = initng_active_db_get_string_var(&SCRIPT_OPT, process->pt->name,
- service);
+ args = get_string_var(&SCRIPT_OPT, process->pt->name, service);
/*D_("initng_bash(%s, %s, %s);\n", service->name, e, args); */
return (bash_exec(process, service, e, args));
Modified: initng/trunk/plugins/chdir/initng_chdir.c
==============================================================================
--- initng/trunk/plugins/chdir/initng_chdir.c (original)
+++ initng/trunk/plugins/chdir/initng_chdir.c Tue Apr 4 04:04:13 2006
@@ -47,7 +47,7 @@
assert(p);
D_("do_chdir!\n");
- if (!(tmp = initng_active_db_get_string(&CHDIR, s)))
+ if (!(tmp = get_string(&CHDIR, s)))
{
D_("CHDIR not set!\n");
return (TRUE);
Modified: initng/trunk/plugins/chroot/initng_chroot.c
==============================================================================
--- initng/trunk/plugins/chroot/initng_chroot.c (original)
+++ initng/trunk/plugins/chroot/initng_chroot.c Tue Apr 4 04:04:13 2006
@@ -47,7 +47,7 @@
assert(p);
D_("do_suid!\n");
- if (!(tmp = initng_active_db_get_string(&CHROOT, s)))
+ if (!(tmp = get_string(&CHROOT, s)))
{
D_("SUID not set!\n");
return (TRUE);
Modified: initng/trunk/plugins/conflict/initng_conflict.c
==============================================================================
--- initng/trunk/plugins/conflict/initng_conflict.c (original)
+++ initng/trunk/plugins/conflict/initng_conflict.c Tue Apr 4 04:04:13 2006
@@ -42,6 +42,7 @@
static int check_conflict(active_db_h * service)
{
const char *conflict_entry = NULL;
+ s_data *itt = NULL;
assert(service);
assert(service->name);
@@ -51,9 +52,7 @@
return (TRUE);
/* make sure the conflict entry is set */
- while ((conflict_entry =
- initng_active_db_get_next_string(&CONFLICT, service,
- conflict_entry)))
+ while ((conflict_entry = get_next_string(&CONFLICT, service, &itt)))
{
active_db_h *s = NULL;
Modified: initng/trunk/plugins/critical/initng_critical.c
==============================================================================
--- initng/trunk/plugins/critical/initng_critical.c (original)
+++ initng/trunk/plugins/critical/initng_critical.c Tue Apr 4 04:04:13 2006
@@ -47,7 +47,7 @@
if (!IS_FAILED(service))
return (TRUE);
- if (!initng_active_db_is(&CRITICAL, service))
+ if (!is(&CRITICAL, service))
return (TRUE);
F_("Service %s failed, this is critical, going su_login!!\n",
Modified: initng/trunk/plugins/daemon/initng_daemon.c
==============================================================================
--- initng/trunk/plugins/daemon/initng_daemon.c (original)
+++ initng/trunk/plugins/daemon/initng_daemon.c Tue Apr 4 04:04:13 2006
@@ -589,7 +589,7 @@
* If pidof is set, check that there is no
* existing running daemon in here.
*/
- if (initng_active_db_is(&PIDOF, daemon))
+ if (is(&PIDOF, daemon))
{
pid_t pid = 0;
@@ -638,15 +638,14 @@
/* if PIDFILE or PIDOF set, put daemon in WAIT_FOR_PIDFILE_STATE */
- if (initng_active_db_is(&PIDFILE, daemon) ||
- initng_active_db_is(&PIDOF, daemon))
+ if (is(&PIDFILE, daemon) || is(&PIDOF, daemon))
{
initng_common_mark_service(daemon, &DAEMON_WAIT_FOR_PID_FILE);
return;
};
/* If daemon is a forking one, let it stay DAEMON_LAUNCH */
- if (initng_active_db_is(&FORKS, daemon))
+ if (is(&FORKS, daemon))
{
D_("FORKS is set, will wait for return.\n");
return;
@@ -775,10 +774,10 @@
int respawn_pause = DEFAULT_RESPAWN_PAUSE;
/* if RESPAWN_PAUSE set */
- if (initng_active_db_is(&RESPAWN_PAUSE, service))
+ if (is(&RESPAWN_PAUSE, service))
{
/* get it */
- respawn_pause = initng_active_db_get_int(&RESPAWN_PAUSE, service);
+ respawn_pause = get_int(&RESPAWN_PAUSE, service);
}
D_("Will sleep %i seconds before respawning!\n", respawn_pause);
@@ -802,7 +801,7 @@
int timeout;
/* get the TERM_TIMEOUT */
- timeout = initng_active_db_get_int(&TERM_TIMEOUT, daemon);
+ timeout = get_int(&TERM_TIMEOUT, daemon);
/* Make sure we got an value */
if (timeout == 0)
@@ -871,7 +870,7 @@
* Youst run if we checks for PID FILE
*/
if (daemon->current_state == &DAEMON_WAIT_FOR_PID_FILE &&
- initng_active_db_is(&FORKS, daemon))
+ is(&FORKS, daemon))
{
try_get_pid(daemon);
return;
@@ -892,7 +891,7 @@
*/
/* TODO MAKE UP_ON_FAILURE more universal */
- if (process->r_code && !initng_active_db_is(&DAEMON_FAIL_OK, daemon))
+ if (process->r_code && !is(&DAEMON_FAIL_OK, daemon))
{
initng_common_mark_service(daemon, &DAEMON_FAIL_STARTING);
@@ -1109,7 +1108,7 @@
const char *pidof;
char *pidof_fixed = NULL;
- pidof = initng_active_db_get_string(&PIDOF, s);
+ pidof = get_string(&PIDOF, s);
if (!pidof)
return (-1);
@@ -1129,9 +1128,10 @@
pid_t pid;
const char *pidfile = NULL;
char *pidfile_fixed = NULL;
+ s_data *itt = NULL;
/* get the pidfile */
- while ((pidfile = initng_active_db_get_next_string(&PIDFILE, s, pidfile)))
+ while ((pidfile = get_next_string(&PIDFILE, s, &itt)))
{
/* fix the variables in the string */
pidfile_fixed = fix_variables(pidfile, s);
@@ -1166,9 +1166,10 @@
{
const char *pidfile = NULL;
char *pidfile_fixed = NULL;
+ s_data *itt = NULL;
/* ok, search for pidfiles */
- while ((pidfile = initng_active_db_get_next_string(&PIDFILE, s, pidfile)))
+ while ((pidfile = get_next_string(&PIDFILE, s, &itt)))
{
if (pidfile)
{
@@ -1204,9 +1205,9 @@
static int check_valid_pidfile_path(service_cache_h * s)
{
const char *pidfile = NULL;
+ s_data *itt = NULL;
- while ((pidfile =
- initng_service_cache_get_next_string(&PIDFILE, s, pidfile)))
+ while ((pidfile = get_next_string(&PIDFILE, s, &itt)))
{
if (pidfile && pidfile[0] != '/' && pidfile[0] != '$')
{
@@ -1241,22 +1242,21 @@
return (FALSE);
/* check if the service have respawn enabled */
- if (!initng_active_db_is(&RESPAWN, service))
+ if (!is(&RESPAWN, service))
{
D_("Service %s doesn't have RESPAWN flag set, won't respawn!\n");
return (FALSE);
}
/* get times */
- if (initng_active_db_is(&INTERNAL_LAST_RESPAWN, service))
- last = (time_t) initng_active_db_get_int(&INTERNAL_LAST_RESPAWN,
- service);
+ if (is(&INTERNAL_LAST_RESPAWN, service))
+ last = (time_t) get_int(&INTERNAL_LAST_RESPAWN, service);
D_("Now: %i , Last: %i\n", g.now.tv_sec, last);
/* get respawn_rate if set */
- if (initng_active_db_is(&RESPAWN_RATE, service))
+ if (is(&RESPAWN_RATE, service))
{
- respawn_rate = initng_active_db_get_int(&RESPAWN_RATE, service);
+ respawn_rate = get_int(&RESPAWN_RATE, service);
}
/* make sure it wont respawn to often */
@@ -1276,8 +1276,7 @@
}
/* set the next INTERNAL_LAST_RESPAWN no to use. */
- initng_active_db_set_int(&INTERNAL_LAST_RESPAWN, service,
- (int) g.now.tv_sec);
+ set_int(&INTERNAL_LAST_RESPAWN, service, (int) g.now.tv_sec);
initng_common_mark_service(service, &DAEMON_WAIT_RESP_TOUT);
return (TRUE);
@@ -1293,7 +1292,7 @@
D_("Trying to get pid of %s\n", s->name);
/* Try get the pid from PIDOF is set */
- if (initng_active_db_is(&PIDOF, s))
+ if (is(&PIDOF, s))
{
D_("getting pid by PIDOF!\n");
/* get pid by process name */
@@ -1301,7 +1300,7 @@
D_("result : %d\n", pid);
}
/* Try get the pid from PIDFILE if set */
- else if (initng_active_db_is(&PIDFILE, s))
+ else if (is(&PIDFILE, s))
{
D_("getting pid by PIDFILE!\n");
pid = get_pidfile(s);
@@ -1333,7 +1332,7 @@
/* finally set the new pid - but not if forks=no, because
that can cause problems */
- if (initng_active_db_is(&FORKS, s))
+ if (is(&FORKS, s))
p->pid = pid;
/* check with up_check */
Modified: initng/trunk/plugins/dbus_event/dbus_nge.c
==============================================================================
--- initng/trunk/plugins/dbus_event/dbus_nge.c (original)
+++ initng/trunk/plugins/dbus_event/dbus_nge.c Tue Apr 4 04:04:13 2006
@@ -48,7 +48,7 @@
}
/* add a rule for which messages we want to see */
- dbus_bus_add_match(conn, "type='signal',interface='"INTERFACE"'", &err); /* see signals from the given interface */
+ dbus_bus_add_match(conn, "type='signal',interface='" INTERFACE "'", &err); /* see signals from the given interface */
dbus_connection_flush(conn);
if (dbus_error_is_set(&err))
{
@@ -74,159 +74,160 @@
if (dbus_message_is_signal(msg, INTERFACE, "astatus_change"))
{
- char * service = NULL;
- int is = 0;
- char * state = NULL;
+ char *service = NULL;
+ int is = 0;
+ char *state = NULL;
/* read the parameters */
if (!dbus_message_iter_init(msg, &args))
fprintf(stderr, "Message Has No Parameters\n");
-
- /* First interator is a string with service name*/
- if(dbus_message_iter_get_arg_type(&args)!=DBUS_TYPE_STRING)
- exit(1);
-
- dbus_message_iter_get_basic(&args, &service);
-
- /* go to next iter */
- if(!dbus_message_iter_next(&args))
- exit(1);
-
- /* Second value is an int */
- if(dbus_message_iter_get_arg_type(&args)!=DBUS_TYPE_INT32)
- exit(1);
-
- dbus_message_iter_get_basic(&args, &is);
-
- /* go to next iter */
- if(!dbus_message_iter_next(&args))
- exit(1);
-
- /* Third arg is a string, with state name */
- if(dbus_message_iter_get_arg_type(&args)!=DBUS_TYPE_STRING)
- exit(1);
-
- dbus_message_iter_get_basic(&args, &state);
-
-
- printf(" astatus_change service: \"%s\" is: \"%i\" state: \"%s\"\n", service, is, state);
- }
+
+ /* First interator is a string with service name */
+ if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_STRING)
+ exit(1);
+
+ dbus_message_iter_get_basic(&args, &service);
+
+ /* go to next iter */
+ if (!dbus_message_iter_next(&args))
+ exit(1);
+
+ /* Second value is an int */
+ if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_INT32)
+ exit(1);
+
+ dbus_message_iter_get_basic(&args, &is);
+
+ /* go to next iter */
+ if (!dbus_message_iter_next(&args))
+ exit(1);
+
+ /* Third arg is a string, with state name */
+ if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_STRING)
+ exit(1);
+
+ dbus_message_iter_get_basic(&args, &state);
+
+
+ printf(" astatus_change service: \"%s\" is: \"%i\" state: \"%s\"\n", service, is, state);
+ }
if (dbus_message_is_signal(msg, INTERFACE, "system_state_change"))
{
- int sys_state = 0;
+ int sys_state = 0;
/* read the parameters */
if (!dbus_message_iter_init(msg, &args))
fprintf(stderr, "Message Has No Parameters\n");
-
- /* Second value is an int */
- if(dbus_message_iter_get_arg_type(&args)!=DBUS_TYPE_INT32)
- exit(1);
-
-
- printf(" system_state_change state: %i\n", sys_state);
- }
-
+
+ /* Second value is an int */
+ if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_INT32)
+ exit(1);
+
+
+ printf(" system_state_change state: %i\n", sys_state);
+ }
+
if (dbus_message_is_signal(msg, INTERFACE, "system_output"))
{
- char * service = NULL;
- char * process = NULL;
- char * output = NULL;
+ char *service = NULL;
+ char *process = NULL;
+ char *output = NULL;
/* read the parameters */
if (!dbus_message_iter_init(msg, &args))
fprintf(stderr, "Message Has No Parameters\n");
-
- /* First interator is a string with service name*/
- if(dbus_message_iter_get_arg_type(&args)!=DBUS_TYPE_STRING)
- exit(1);
-
- dbus_message_iter_get_basic(&args, &service);
-
- /* go to next iter */
- if(!dbus_message_iter_next(&args))
- exit(1);
-
- if(dbus_message_iter_get_arg_type(&args)!=DBUS_TYPE_STRING)
- exit(1);
-
- dbus_message_iter_get_basic(&args, &process);
-
- /* go to next iter */
- if(!dbus_message_iter_next(&args))
- exit(1);
-
- if(dbus_message_iter_get_arg_type(&args)!=DBUS_TYPE_STRING)
- exit(1);
-
- dbus_message_iter_get_basic(&args, &output);
-
-
- printf(" system_output service: %s process: %s \n%s\n", service, process, output);
- }
+
+ /* First interator is a string with service name */
+ if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_STRING)
+ exit(1);
+
+ dbus_message_iter_get_basic(&args, &service);
+
+ /* go to next iter */
+ if (!dbus_message_iter_next(&args))
+ exit(1);
+
+ if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_STRING)
+ exit(1);
+
+ dbus_message_iter_get_basic(&args, &process);
+
+ /* go to next iter */
+ if (!dbus_message_iter_next(&args))
+ exit(1);
+
+ if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_STRING)
+ exit(1);
+
+ dbus_message_iter_get_basic(&args, &output);
+
+
+ printf(" system_output service: %s process: %s \n%s\n", service,
+ process, output);
+ }
if (dbus_message_is_signal(msg, INTERFACE, "print_error"))
{
- int mt = 0;
- char * file = NULL;
- char * func = NULL;
- int line = 0;
- char * message = NULL;
+ int mt = 0;
+ char *file = NULL;
+ char *func = NULL;
+ int line = 0;
+ char *message = NULL;
/* read the parameters */
if (!dbus_message_iter_init(msg, &args))
fprintf(stderr, "Message Has No Parameters\n");
-
- if(dbus_message_iter_get_arg_type(&args)!=DBUS_TYPE_INT32)
- exit(1);
-
- dbus_message_iter_get_basic(&args, &mt);
-
- /* go to next iter */
- if(!dbus_message_iter_next(&args))
- exit(1);
-
- if(dbus_message_iter_get_arg_type(&args)!=DBUS_TYPE_STRING)
- exit(1);
-
- dbus_message_iter_get_basic(&args, &file);
-
- /* go to next iter */
- if(!dbus_message_iter_next(&args))
- exit(1);
-
- if(dbus_message_iter_get_arg_type(&args)!=DBUS_TYPE_STRING)
- exit(1);
-
- dbus_message_iter_get_basic(&args, &func);
-
- /* go to next iter */
- if(!dbus_message_iter_next(&args))
- exit(1);
-
- if(dbus_message_iter_get_arg_type(&args)!=DBUS_TYPE_INT32)
- exit(1);
-
- dbus_message_iter_get_basic(&args, &line);
-
- /* go to next iter */
- if(!dbus_message_iter_next(&args))
- exit(1);
-
- if(dbus_message_iter_get_arg_type(&args)!=DBUS_TYPE_STRING)
- exit(1);
-
- dbus_message_iter_get_basic(&args, &message);
-
- printf(" system_output service: mt: %i file: %s func: %s line: %i\n%s\n", mt, file, func, line, message);
- }
+
+ if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_INT32)
+ exit(1);
+
+ dbus_message_iter_get_basic(&args, &mt);
+
+ /* go to next iter */
+ if (!dbus_message_iter_next(&args))
+ exit(1);
+
+ if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_STRING)
+ exit(1);
+
+ dbus_message_iter_get_basic(&args, &file);
+
+ /* go to next iter */
+ if (!dbus_message_iter_next(&args))
+ exit(1);
+
+ if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_STRING)
+ exit(1);
+
+ dbus_message_iter_get_basic(&args, &func);
+
+ /* go to next iter */
+ if (!dbus_message_iter_next(&args))
+ exit(1);
+
+ if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_INT32)
+ exit(1);
+
+ dbus_message_iter_get_basic(&args, &line);
+
+ /* go to next iter */
+ if (!dbus_message_iter_next(&args))
+ exit(1);
+
+ if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_STRING)
+ exit(1);
+
+ dbus_message_iter_get_basic(&args, &message);
+
+ printf(" system_output service: mt: %i file: %s func: %s line: %i\n%s\n", mt, file, func, line, message);
+ }
/* free the message */
dbus_message_unref(msg);
}
-
+
/* close the connection */
dbus_connection_close(conn);
}
Modified: initng/trunk/plugins/dbus_event/initng_dbusevent.c
==============================================================================
--- initng/trunk/plugins/dbus_event/initng_dbusevent.c (original)
+++ initng/trunk/plugins/dbus_event/initng_dbusevent.c Tue Apr 4 04:04:13 2006
@@ -71,12 +71,12 @@
static int print_error(e_mt mt, const char *file, const char *func, int line,
const char *format, va_list arg);
-static dbus_bool_t add_dbus_watch(DBusWatch *watch, void* data);
-static void rem_dbus_watch(DBusWatch *watch, void* data);
-static void toggled_dbus_watch (DBusWatch *watch, void *data);
+static dbus_bool_t add_dbus_watch(DBusWatch * watch, void *data);
+static void rem_dbus_watch(DBusWatch * watch, void *data);
+static void toggled_dbus_watch(DBusWatch * watch, void *data);
static void fdw_callback(f_module_h * from, e_fdw what);
-static void free_dbus_watch_data (void *data);
+static void free_dbus_watch_data(void *data);
DBusConnection *conn;
@@ -88,49 +88,53 @@
/* ------ DBus Watch Handling --------
- NOTE: if any of the F_, D_ etc macros are called during execution of these
- functions, bad things happen as these call DBus functions and the DBus
- code is *not* reentrant */
+ NOTE: if any of the F_, D_ etc macros are called during execution of these
+ functions, bad things happen as these call DBus functions and the DBus
+ code is *not* reentrant */
-static dbus_bool_t add_dbus_watch(DBusWatch *watch, void* data)
+static dbus_bool_t add_dbus_watch(DBusWatch * watch, void *data)
{
initng_dbus_watch *w = i_calloc(1, sizeof(initng_dbus_watch));
- if(w == NULL) {
- printf("Memory allocation failed\n"); return FALSE;
+
+ if (w == NULL)
+ {
+ printf("Memory allocation failed\n");
+ return FALSE;
}
w->fdw.fds = dbus_watch_get_fd(watch);
w->fdw.call_module = fdw_callback;
- w->dbus = watch; w->fdw.what = 0;
+ w->dbus = watch;
+ w->fdw.what = 0;
dbus_watch_set_data(watch, w, free_dbus_watch_data);
- toggled_dbus_watch(watch, data); /* to set initial state */
+ toggled_dbus_watch(watch, data); /* to set initial state */
initng_plugin_hook_add(&g.FDWATCHERS, 30, &w->fdw);
return TRUE;
}
-static void rem_dbus_watch(DBusWatch *watch, void* data)
+static void rem_dbus_watch(DBusWatch * watch, void *data)
{
/* initng_dbus_watch *w = dbus_watch_get_data(watch);
- if(w != NULL) free_dbus_watch_data(w); */
+ if(w != NULL) free_dbus_watch_data(w); */
}
-static void toggled_dbus_watch (DBusWatch *watch, void *data)
+static void toggled_dbus_watch(DBusWatch * watch, void *data)
{
initng_dbus_watch *w = dbus_watch_get_data(watch);
w->fdw.what = 0;
- if(dbus_watch_get_enabled(watch))
+ if (dbus_watch_get_enabled(watch))
{
int flags = dbus_watch_get_flags(watch);
- if(flags & DBUS_WATCH_READABLE)
+ if (flags & DBUS_WATCH_READABLE)
w->fdw.what |= FDW_READ;
- if(flags & DBUS_WATCH_WRITABLE)
+ if (flags & DBUS_WATCH_WRITABLE)
w->fdw.what |= FDW_WRITE;
w->fdw.what |= FDW_ERROR;
@@ -138,27 +142,29 @@
}
-static void free_dbus_watch_data (void *data)
+static void free_dbus_watch_data(void *data)
{
initng_dbus_watch *w = data;
+
assert(w);
- initng_plugin_hook_del(&g.FDWATCHERS, &(w->fdw)); free(w);
+ initng_plugin_hook_del(&g.FDWATCHERS, &(w->fdw));
+ free(w);
}
static void fdw_callback(f_module_h * from, e_fdw what)
{
- initng_dbus_watch *w = (initng_dbus_watch*) from;
+ initng_dbus_watch *w = (initng_dbus_watch *) from;
int flgs = 0;
/* TODO - handle DBUS_WATCH_HANGUP ? */
- if(what & FDW_READ)
+ if (what & FDW_READ)
flgs |= DBUS_WATCH_READABLE;
- if(what & FDW_WRITE)
+ if (what & FDW_WRITE)
flgs |= DBUS_WATCH_WRITABLE;
- if(what & FDW_ERROR)
+ if (what & FDW_ERROR)
flgs |= DBUS_WATCH_ERROR;
dbus_watch_handle(w->dbus, flgs);
@@ -170,40 +176,44 @@
{
DBusMessage *msg;
dbus_uint32_t serial = 0;
-
+
/* these values will be send */
- const char * service_name = service->name;
+ const char *service_name = service->name;
int is = service->current_state->is;
- const char * state_name = service->current_state->state_name;
+ const char *state_name = service->current_state->state_name;
- if(conn == NULL) return(TRUE);
+ if (conn == NULL)
+ return (TRUE);
- D_("Sending signal with value \"%.10s\" %i \"%.10s\"\n", service_name, is, state_name);
+ D_("Sending signal with value \"%.10s\" %i \"%.10s\"\n", service_name, is,
+ state_name);
/* create a signal & check for errors */
- msg = dbus_message_new_signal(OBJECT, /* object name of the signal */
- INTERFACE, /* interface name of the signal */
- "astatus_change"); /* name of the signal */
+ msg = dbus_message_new_signal(OBJECT, /* object name of the signal */
+ INTERFACE, /* interface name of the signal */
+ "astatus_change"); /* name of the signal */
if (NULL == msg)
{
F_("Unable to create ne dbus signal\n");
- return(TRUE);
+ return (TRUE);
}
/* Append some arguments to the call */
- if(!dbus_message_append_args(msg, DBUS_TYPE_STRING, &service_name, DBUS_TYPE_INT32, &is, DBUS_TYPE_STRING, &state_name, DBUS_TYPE_INVALID))
+ if (!dbus_message_append_args
+ (msg, DBUS_TYPE_STRING, &service_name, DBUS_TYPE_INT32, &is,
+ DBUS_TYPE_STRING, &state_name, DBUS_TYPE_INVALID))
{
F_("Unable to append args to dbus signal!\n");
- return(TRUE);
+ return (TRUE);
}
-
-
+
+
/* send the message and flush the connection */
if (!dbus_connection_send(conn, msg, &serial))
{
F_("Unable to send dbus signal!\n");
- return(TRUE);
+ return (TRUE);
}
// dbus_connection_flush(conn);
@@ -211,20 +221,21 @@
/* free the message */
dbus_message_unref(msg);
-
- return(TRUE);
+
+ return (TRUE);
}
static void system_state_change(e_is state)
{
DBusMessage *msg;
dbus_uint32_t serial = 0;
-
- if(conn == NULL) return;
+
+ if (conn == NULL)
+ return;
/* create a signal & check for errors */
- msg = dbus_message_new_signal(OBJECT, /* object name of the signal */
- INTERFACE, /* interface name of the signal */
+ msg = dbus_message_new_signal(OBJECT, /* object name of the signal */
+ INTERFACE, /* interface name of the signal */
"system_state_change"); /* name of the signal */
if (NULL == msg)
{
@@ -234,13 +245,14 @@
/* Append some arguments to the call */
- if(!dbus_message_append_args(msg, DBUS_TYPE_INT32, &state, DBUS_TYPE_INVALID))
+ if (!dbus_message_append_args
+ (msg, DBUS_TYPE_INT32, &state, DBUS_TYPE_INVALID))
{
F_("Unable to append args to dbus signal!\n");
return;
}
-
-
+
+
/* send the message and flush the connection */
if (!dbus_connection_send(conn, msg, &serial))
{
@@ -261,35 +273,38 @@
{
DBusMessage *msg;
dbus_uint32_t serial = 0;
- const char * service_name = service->name;
- const char * process_name = process->pt->name;
+ const char *service_name = service->name;
+ const char *process_name = process->pt->name;
- if(conn == NULL) return(TRUE);
+ if (conn == NULL)
+ return (TRUE);
/* create a signal & check for errors */
- msg = dbus_message_new_signal(OBJECT, /* object name of the signal */
- INTERFACE, /* interface name of the signal */
- "system_output"); /* name of the signal */
+ msg = dbus_message_new_signal(OBJECT, /* object name of the signal */
+ INTERFACE, /* interface name of the signal */
+ "system_output"); /* name of the signal */
if (NULL == msg)
{
F_("Unable to create new dbus signal\n");
- return(TRUE);
+ return (TRUE);
}
/* Append some arguments to the call */
- if(!dbus_message_append_args(msg, DBUS_TYPE_STRING, &service_name, DBUS_TYPE_STRING, &process_name, DBUS_TYPE_STRING, &output, DBUS_TYPE_INVALID))
+ if (!dbus_message_append_args
+ (msg, DBUS_TYPE_STRING, &service_name, DBUS_TYPE_STRING,
+ &process_name, DBUS_TYPE_STRING, &output, DBUS_TYPE_INVALID))
{
F_("Unable to append args to dbus signal!\n");
- return(TRUE);
+ return (TRUE);
}
-
-
+
+
/* send the message and flush the connection */
if (!dbus_connection_send(conn, msg, &serial))
{
F_("Unable to send dbus signal!\n");
- return(TRUE);
+ return (TRUE);
}
//dbus_connection_flush(conn);
@@ -297,7 +312,7 @@
dbus_message_unref(msg);
D_("Dbus Signal Sent\n");
- return(TRUE);
+ return (TRUE);
}
static int print_error(e_mt mt, const char *file, const char *func,
@@ -306,35 +321,40 @@
DBusMessage *msg;
dbus_uint32_t serial = 0;
- if(conn == NULL) return(TRUE);
+ if (conn == NULL)
+ return (TRUE);
/* create a signal & check for errors */
- msg = dbus_message_new_signal(OBJECT, /* object name of the signal */
- INTERFACE, /* interface name of the signal */
+ msg = dbus_message_new_signal(OBJECT, /* object name of the signal */
+ INTERFACE, /* interface name of the signal */
"print_error"); /* name of the signal */
if (NULL == msg)
{
F_("Unable to create new dbus signal\n");
- return(TRUE);
+ return (TRUE);
}
/* compose the message */
char *message = i_calloc(1001, sizeof(char));
+
vsnprintf(message, 1000, format, arg);
/* Append some arguments to the call */
- if(!dbus_message_append_args(msg, DBUS_TYPE_INT32, &mt, DBUS_TYPE_STRING, &file, DBUS_TYPE_STRING, &func, DBUS_TYPE_INT32, &line, DBUS_TYPE_STRING, &message, DBUS_TYPE_INVALID))
+ if (!dbus_message_append_args
+ (msg, DBUS_TYPE_INT32, &mt, DBUS_TYPE_STRING, &file, DBUS_TYPE_STRING,
+ &func, DBUS_TYPE_INT32, &line, DBUS_TYPE_STRING, &message,
+ DBUS_TYPE_INVALID))
{
F_("Unable to append args to dbus signal!\n");
- return(TRUE);
+ return (TRUE);
}
-
-
+
+
/* send the message and flush the connection */
if (!dbus_connection_send(conn, msg, &serial))
{
F_("Unable to send dbus signal!\n");
- return(TRUE);
+ return (TRUE);
}
//dbus_connection_flush(conn);
@@ -343,7 +363,7 @@
free(message);
D_("Dbus Signal Sent\n");
- return(TRUE);
+ return (TRUE);
}
@@ -353,16 +373,16 @@
static void check_socket(int signal)
{
/* only react on a SIGHUP signal */
- if(signal!=SIGHUP)
- return;
-
+ if (signal != SIGHUP)
+ return;
+
/* close if open */
- if(conn)
+ if (conn)
{
- dbus_connection_close(conn);
- conn=NULL;
+ dbus_connection_close(conn);
+ conn = NULL;
}
-
+
/* and open again */
connect_to_dbus();
}
@@ -395,21 +415,21 @@
/* register our name on the bus, and check for errors */
ret = dbus_bus_request_name(conn, SOURCE_REQUEST,
DBUS_NAME_FLAG_REPLACE_EXISTING, &err);
-
+
/* Make sure no error is set */
if (dbus_error_is_set(&err))
{
F_("Name Error (%s)\n", err.message);
dbus_error_free(&err);
}
-
+
/* IF this is set, initng is the owner of initng.signal.source */
/*if ( ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
printf("Could not gain PRIMARY_OWNER of "SOURCE_REQUEST"\n");
return(FALSE);
- }*/
+ } */
- return(TRUE);
+ return (TRUE);
}
int module_init(int api_version)
@@ -422,7 +442,7 @@
}
connect_to_dbus();
-
+
/* add the hooks we are monitoring */
initng_plugin_hook_add(&g.SIGNAL, 50, &check_socket);
initng_plugin_hook_add(&g.ASTATUS_CHANGE, 50, &astatus_change);
@@ -440,11 +460,12 @@
void module_unload(void)
{
- if(conn != NULL)
+ if (conn != NULL)
{
- dbus_connection_close(conn); conn = NULL;
+ dbus_connection_close(conn);
+ conn = NULL;
}
-
+
initng_plugin_hook_del(&g.SIGNAL, &check_socket);
initng_plugin_hook_del(&g.ASTATUS_CHANGE, &astatus_change);
initng_plugin_hook_del(&g.SWATCHERS, &system_state_change);
Modified: initng/trunk/plugins/debug_commands/print_service.c
==============================================================================
--- initng/trunk/plugins/debug_commands/print_service.c (original)
+++ initng/trunk/plugins/debug_commands/print_service.c Tue Apr 4 04:04:13 2006
@@ -76,6 +76,67 @@
}
}
+static void print_sdata(s_data * tmp, char **string)
+{
+ if (!tmp->type)
+ return;
+ switch (tmp->type->opt_type)
+ {
+ case STRING:
+ case STRINGS:
+ if (!tmp->t.s)
+ {
+ F_("empty value!\n");
+ return;
+ }
+ mprintf(string, " @@ %-24s : \"", tmp->type->opt_name);
+
+ print_string_value(tmp->t.s, string);
+ mprintf(string, "\"\n");
+ return;
+ case VARIABLE_STRING:
+ case VARIABLE_STRINGS:
+ if (!tmp->t.s)
+ {
+ F_("empty value!\n");
+ return;
+ }
+ if (tmp->vn)
+ mprintf(string, " @@ %-13s %-10s : \"", tmp->type->opt_name,
+ tmp->vn);
+ else
+ mprintf(string, " @@ %-13s %-10s : \"", tmp->type->opt_name,
+ tmp->vn);
+
+ print_string_value(tmp->t.s, string);
+ mprintf(string, "\"\n");
+ return;
+ case INT:
+ mprintf(string, " @@ %-24s : \"%i\"\n", tmp->type->opt_name,
+ tmp->t.i);
+ return;
+ case VARIABLE_INT:
+ mprintf(string, " @@ %-13s %-10s : \"%i\"\n", tmp->type->opt_name,
+ tmp->vn, tmp->t.i);
+ return;
+ case SET:
+ mprintf(string, " @@ %-24s\n", tmp->type->opt_name);
+ return;
+ case VARIABLE_SET:
+ mprintf(string, " @@ %-13s %-10s\n", tmp->type->opt_name,
+ tmp->vn);
+ return;
+ case ALIAS:
+ mprintf(string, " @@ ALIAS %-24s\n", tmp->type->opt_name);
+ return;
+ default:
+ return;
+ }
+
+}
+
+
+
static void service_db_print_u(service_cache_h * s, char **string)
{
/*data path */
@@ -93,57 +154,11 @@
mprintf(string, "\"\n");
}
- mprintf(string, " ------------------------ \n");
+ mprintf(string, " ---------------------------------- \n");
- list_for_each_entry(tmp, &s->data.list, list)
+ list_for_each_entry(tmp, &s->data.head.list, list)
{
- if (!tmp->type)
- continue;
- switch (tmp->type->opt_type)
- {
- case STRING:
- case STRINGS:
- if (!tmp->t.s)
- {
- F_("empty value!\n");
- continue;
- }
- mprintf(string, " @@ %s:\t\"", tmp->type->opt_name);
- print_string_value(tmp->t.s, string);
- mprintf(string, "\"\n");
- continue;
- case VARIABLE_STRING:
- case VARIABLE_STRINGS:
- if (!tmp->t.s)
- {
- F_("empty value!\n");
- continue;
- }
- mprintf(string, " @@ %s \"%s\" : \"", tmp->type->opt_name,
- tmp->vn);
- print_string_value(tmp->t.s, string);
- mprintf(string, "\"\n");
- continue;
- case INT:
- mprintf(string, " @@ %s:\t\"%i\"\n", tmp->type->opt_name,
- tmp->t.i);
- continue;
- case VARIABLE_INT:
- mprintf(string, " @@ %s %s:\t\"%i\"\n", tmp->type->opt_name,
- tmp->vn, tmp->t.i);
- continue;
- case SET:
- mprintf(string, " @@ %s\n", tmp->type->opt_name);
- continue;
- case VARIABLE_SET:
- mprintf(string, " @@ %s %s\n", tmp->type->opt_name, tmp->vn);
- continue;
- case ALIAS:
- mprintf(string, " @@ ALIAS %s\n", tmp->type->opt_name);
- continue;
- default:
- continue;
- }
+ print_sdata(tmp, string);
}
/* if father with data exits, print it */
@@ -193,6 +208,8 @@
}
+
+
static void active_db_print_u(active_db_h * s, char **string)
{
/*data path */
@@ -239,71 +256,17 @@
mprintf(string, "\tactive_db opts:\n");
- list_for_each_entry(tmp, &(s->data.list), list)
+ list_for_each_entry(tmp, &(s->data.head.list), list)
{
- if (tmp->type)
- {
- switch (tmp->type->opt_type)
- {
- case STRING:
- case STRINGS:
-
- if (!tmp->t.s)
- break;
- mprintf(string, "\t\t@@ %s:\t\"%.40s ...\"\n",
- tmp->type->opt_name, tmp->t.s);
- break;
-
- case INT:
- mprintf(string, "\t\t@@ %s:\t\"%i\"\n",
- tmp->type->opt_name, tmp->t.i);
- break;
-
- case SET:
- mprintf(string, "\t\t@@ %s\n", tmp->type->opt_name);
- break;
-
- default:
- break;
-
- }
- }
}
if (s->from_service)
{
mprintf(string, "\tservice_db opts:\n");
tmp = NULL;
- list_for_each_entry(tmp, &(s->from_service->data.list), list)
+ list_for_each_entry(tmp, &(s->from_service->data.head.list), list)
{
- if (tmp->type)
- {
- switch (tmp->type->opt_type)
- {
- case STRING:
- case STRINGS:
- case VARIABLE_STRING:
- case VARIABLE_STRINGS:
-
- if (!tmp->t.s)
- break;
- mprintf(string, "\t\t@@ %s:\t\"%.40s ...\"\n",
- tmp->type->opt_name, tmp->t.s);
- break;
-
- case INT:
- case VARIABLE_INT:
- mprintf(string, "\t\t@@ %s:\t\"%i\"\n",
- tmp->type->opt_name, tmp->t.i);
- break;
- case SET:
- case VARIABLE_SET:
- mprintf(string, "\t\t@@ %s\n", tmp->type->opt_name);
- break;
- default:
- break;
- }
- }
+ print_sdata(tmp, string);
}
}
}
Modified: initng/trunk/plugins/envparser/initng_envparser.c
==============================================================================
--- initng/trunk/plugins/envparser/initng_envparser.c (original)
+++ initng/trunk/plugins/envparser/initng_envparser.c Tue Apr 4 04:04:13 2006
@@ -48,23 +48,25 @@
static int env_parser(service_cache_h * s)
{
const char *file = NULL;
+ s_data *itt = NULL;
assert(s);
/* make sure the env_file is set */
- if (!initng_service_cache_is(&ENV_FILE, s))
+ if (!is(&ENV_FILE, s))
return (TRUE);
+ /* TODO, put this into one while loop */
+
/* Parse all ENV_FILE's */
- while ((file = initng_service_cache_get_next_string(&ENV_FILE, s, file)))
+ while ((file = get_next_string(&ENV_FILE, s, &itt)))
{
parse_file(file, s);
}
+ itt = NULL;
/* Parse all, and stop if files don't exits, or not parseable */
- while ((file =
- initng_service_cache_get_next_string(&ENV_FILE_REQUIRED, s,
- file)))
+ while ((file = get_next_string(&ENV_FILE_REQUIRED, s, &itt)))
{
if (parse_file(file, s) == FALSE)
return (FALSE);
@@ -181,18 +183,18 @@
point += i;
/* add to service cache */
- if (initng_service_cache_is_var(&ENV, vn, s))
+ if (is_var(&ENV, vn, s))
{
- const char *oldval = initng_service_cache_get_string_var(&ENV, vn,
- s);
+ const char *oldval = get_string_var(&ENV, vn,
+ s);
char *fixed = fix_redefined_variable(vn, oldval, vv);
free(vv);
- initng_service_cache_set_string_var(&ENV, vn, s, fixed);
+ set_string_var(&ENV, vn, s, fixed);
}
else
{
- initng_service_cache_set_string_var(&ENV, vn, s, vv);
+ set_string_var(&ENV, vn, s, vv);
}
/* go to next row and parse */
Modified: initng/trunk/plugins/find/initng_find.c
==============================================================================
--- initng/trunk/plugins/find/initng_find.c (original)
+++ initng/trunk/plugins/find/initng_find.c Tue Apr 4 04:04:13 2006
@@ -30,7 +30,7 @@
#include <sys/types.h>
#include <errno.h>
#include <dirent.h>
- /*#include <dirent.h> *//* opendir() closedir() */
+ /*#include <dirent.h> *//* opendir() closedir() */
#include <initng_global.h>
#include <initng_string_tools.h>
@@ -51,8 +51,8 @@
struct dirent *dir_e;
struct stat fstat;
char file[101];
-
- /*printf("search_dir: %s for %s\n", dir, for_service);*/
+
+ /*printf("search_dir: %s for %s\n", dir, for_service); */
path = opendir(dir);
if (!path)
@@ -61,62 +61,63 @@
/* Walk thru all files in dir */
while ((dir_e = readdir(path)))
{
- /* skip dirs/files starting with a . */
- if(dir_e->d_name[0]=='.')
- continue;
-
-
- /* set up full path */
- strncpy(file, dir, 40);
- strcat(file, "/");
- strcat(file, dir_e->d_name);
-
-
-
- /* get the stat of that file */
- if (stat(file, &fstat) != 0)
- {
- printf("File %s failed stat errno: %s\n", file, strerror(errno));
- continue;
- }
-
- /* if it is a dir */
- if(S_ISDIR(fstat.st_mode))
- {
- /* Cal ur self function with that dir */
- tmp=search_dir(for_service, file);
- if(tmp)
- return(tmp);
-
- /* continue while loop */
- continue;
- }
-
- /* if it is a file */
- if(S_ISREG(fstat.st_mode))
- {
- /* check if it contains the keyword we are looking for */
- if (!strstr(file, for_service))
- continue;
-
- {
- /* cut the initiating "/etc/initng/" */
- char * s = file + ((strlen(INITNG_ROOT)+1) * sizeof(char));
-
- /* cut the ending ".i" */
- int i=0;
- while(s[i] && s[i]!='.')
- i++;
- s[i]='\0';
-
- W_("Service should be \"%s\"\n", s, for_service);
- if ((tmp = initng_common_parse_service(s)))
- {
- closedir(path);
- return (tmp);
- }
- }
- }
+ /* skip dirs/files starting with a . */
+ if (dir_e->d_name[0] == '.')
+ continue;
+
+
+ /* set up full path */
+ strncpy(file, dir, 40);
+ strcat(file, "/");
+ strcat(file, dir_e->d_name);
+
+
+
+ /* get the stat of that file */
+ if (stat(file, &fstat) != 0)
+ {
+ printf("File %s failed stat errno: %s\n", file, strerror(errno));
+ continue;
+ }
+
+ /* if it is a dir */
+ if (S_ISDIR(fstat.st_mode))
+ {
+ /* Cal ur self function with that dir */
+ tmp = search_dir(for_service, file);
+ if (tmp)
+ return (tmp);
+
+ /* continue while loop */
+ continue;
+ }
+
+ /* if it is a file */
+ if (S_ISREG(fstat.st_mode))
+ {
+ /* check if it contains the keyword we are looking for */
+ if (!strstr(file, for_service))
+ continue;
+
+ {
+ /* cut the initiating "/etc/initng/" */
+ char *s = file + ((strlen(INITNG_ROOT) + 1) * sizeof(char));
+
+ /* cut the ending ".i" */
+ int i = 0;
+
+ while (s[i] && s[i] != '.')
+ i++;
+ s[i] = '\0';
+
+ W_("Service should be \"%s\"\n", s, for_service);
+ if ((tmp = initng_common_parse_service(s)))
+ {
+ closedir(path);
+ return (tmp);
+ }
+ }
+ }
}
closedir(path);
return (NULL);
@@ -133,25 +134,25 @@
/* Try get by alias file */
{
- char *alias_name = NULL;
-
- /* try get from alias file */
- if ((alias_name = get_find_alias(service)))
- {
- /* also try to find a service with that name */
- tmp = initng_common_parse_service(alias_name);
- free(alias_name);
-
- if(tmp)
- return (tmp);
- }
+ char *alias_name = NULL;
+
+ /* try get from alias file */
+ if ((alias_name = get_find_alias(service)))
+ {
+ /* also try to find a service with that name */
+ tmp = initng_common_parse_service(alias_name);
+ free(alias_name);
+
+ if (tmp)
+ return (tmp);
+ }
}
/* Never try to find a service with a '/' in the name, it already have a path */
if (strstr(service, "/"))
{
- printf("This is a full path, nothing to search on.\n");
- return(NULL);
+ printf("This is a full path, nothing to search on.\n");
+ return (NULL);
}
/* browser initng root, in searching for a file matching service name */
Modified: initng/trunk/plugins/fstat/initng_fstat.c
==============================================================================
--- initng/trunk/plugins/fstat/initng_fstat.c (original)
+++ initng/trunk/plugins/fstat/initng_fstat.c Tue Apr 4 04:04:13 2006
@@ -48,10 +48,10 @@
static int check_files_to_exist(active_db_h * service)
{
const char *file = NULL;
+ s_data *itt = NULL;
struct stat file_stat;
- while ((file =
- initng_active_db_get_next_string(&FILES_TO_EXIST, service, file)))
+ while ((file = get_next_string(&FILES_TO_EXIST, service, &itt)))
{
D_("Service %s need file %s to exist\n", service->name, file);
if (stat(file, &file_stat) != 0)
@@ -73,11 +73,11 @@
static int check_files_to_exist_after(active_db_h * service)
{
const char *file = NULL;
+ s_data *itt = NULL;
+
struct stat file_stat;
- while ((file =
- initng_active_db_get_next_string(&FILES_TO_EXIST_AFTER, service,
- file)))
+ while ((file = get_next_string(&FILES_TO_EXIST_AFTER, service, &itt)))
{
D_("Service %s need file %s before it can be set to RUNNING\n",
service->name, file);
Modified: initng/trunk/plugins/history/initng_history.c
==============================================================================
--- initng/trunk/plugins/history/initng_history.c (original)
+++ initng/trunk/plugins/history/initng_history.c Tue Apr 4 04:04:13 2006
@@ -54,7 +54,7 @@
while_history_db_prev(current)
{
active_row *row = payload->p + (i * sizeof(active_row));
-
+
/* if action is not set, it is probably a string logged in this db */
if (!current->action)
continue;
Modified: initng/trunk/plugins/idleprobe/initng_idleprobe.c
==============================================================================
--- initng/trunk/plugins/idleprobe/initng_idleprobe.c (original)
+++ initng/trunk/plugins/idleprobe/initng_idleprobe.c Tue Apr 4 04:04:13 2006
@@ -191,12 +191,12 @@
- if ((value = initng_active_db_get_int(&WAIT_FOR_CPU_COUNT, service)) > 0)
+ if ((value = get_int(&WAIT_FOR_CPU_COUNT, service)) > 0)
{
return (is_cpu_idle(value));
}
- if (initng_active_db_is(&WAIT_FOR_CPU_IDLE, service))
+ if (is(&WAIT_FOR_CPU_IDLE, service))
return (is_cpu_idle(DEFAULT_IDLE));
Modified: initng/trunk/plugins/initctl/initng_initctl.c
==============================================================================
--- initng/trunk/plugins/initctl/initng_initctl.c (original)
+++ initng/trunk/plugins/initctl/initng_initctl.c Tue Apr 4 04:04:13 2006
@@ -61,7 +61,7 @@
static void initng_reload(void);
-f_module_h pipe_fd = { &parse_control_input, FDW_READ, -1 }; /* /dev/initctl */
+f_module_h pipe_fd = { &parse_control_input, FDW_READ, -1 }; /* /dev/initctl */
struct stat st, st2;
Modified: initng/trunk/plugins/iparser/initng_i_parser.c
==============================================================================
--- initng/trunk/plugins/iparser/initng_i_parser.c (original)
+++ initng/trunk/plugins/iparser/initng_i_parser.c Tue Apr 4 04:04:13 2006
@@ -665,8 +665,7 @@
return (FALSE);
}
- initng_service_cache_set_string(&FROM_FILE, new_service,
- i_strdup(filename));
+ set_string(&FROM_FILE, new_service, i_strdup(filename));
if (strcmp(new_service->name, watch_for) == 0)
@@ -934,7 +933,7 @@
if ((*value)[0] == ';')
{
D_("set_parser(%s,s,%s);\n", type->opt_name, from_service->name);
- initng_service_cache_set_var(type, va, from_service);
+ set_var(type, va, from_service);
return (TRUE);
}
@@ -966,7 +965,7 @@
if (strncasecmp(*value, "yes", 3) == 0)
{
D_("set_parser(%s,s,%s);\n", type->opt_name, from_service->name);
- initng_service_cache_set_var(type, va, from_service);
+ set_var(type, va, from_service);
/* skip 3 chars */
(*value) += 3;
@@ -976,7 +975,7 @@
if (strncasecmp(*value, "true", 4) == 0)
{
D_("set_parser(%s,s,%s);\n", type->opt_name, from_service->name);
- initng_service_cache_set_var(type, va, from_service);
+ set_var(type, va, from_service);
/* skip 4 chars */
(*value) += 4;
@@ -984,7 +983,7 @@
}
/* else, remove */
- initng_service_cache_remove_var(type, va, from_service);
+ dfree_var(type, va, from_service);
return (TRUE);
}
@@ -1070,7 +1069,7 @@
- initng_service_cache_set_string_var(type, va, from_service, to);
+ set_string_var(type, va, from_service, to);
return (TRUE);
}
@@ -1150,7 +1149,7 @@
return (FALSE);
}
- initng_service_cache_set_int_var(type, va, from_service, atoi(to));
+ set_int_var(type, va, from_service, atoi(to));
return (TRUE);
}
@@ -1209,13 +1208,11 @@
DL_(*value, "adding");
if (va)
{
- initng_service_cache_set_another_string_var(type, i_strdup(va),
- from_service, to);
+ set_another_string_var(type, i_strdup(va), from_service, to);
}
else
{
- initng_service_cache_set_another_string_var(type, NULL,
- from_service, to);
+ set_another_string_var(type, NULL, from_service, to);
}
/* check if this is end */
if ((*value)[0] == ';')
Modified: initng/trunk/plugins/last/initng_last.c
==============================================================================
--- initng/trunk/plugins/last/initng_last.c (original)
+++ initng/trunk/plugins/last/initng_last.c Tue Apr 4 04:04:13 2006
@@ -49,7 +49,7 @@
assert(service->name);
/* And LAST is set. */
- if (!initng_active_db_is(&LAST, service))
+ if (!is(&LAST, service))
return (TRUE);
/* ok check with all service */
@@ -66,7 +66,7 @@
continue; */
/* if this service also should be started last, continue */
- if (initng_active_db_is(&LAST, current))
+ if (is(&LAST, current))
continue;
/* TODO, use dep_on_deep */
Modified: initng/trunk/plugins/limit/initng_limit.c
==============================================================================
--- initng/trunk/plugins/limit/initng_limit.c (original)
+++ initng/trunk/plugins/limit/initng_limit.c Tue Apr 4 04:04:13 2006
@@ -128,8 +128,8 @@
struct rlimit l;
/* check if the limits are set */
- si = initng_active_db_is(soft, service);
- sh = initng_active_db_is(hard, service);
+ si = is(soft, service);
+ sh = is(hard, service);
/* make sure any is set */
if (si == FALSE && sh == FALSE)
@@ -147,13 +147,13 @@
/* if soft limit is set, get it */
if (si)
{
- l.rlim_cur = (initng_active_db_get_int(soft, service) * times);
+ l.rlim_cur = (get_int(soft, service) * times);
}
/* if hard limit is set, get it */
if (sh)
{
- l.rlim_max = (initng_active_db_get_int(hard, service) * times);
+ l.rlim_max = (get_int(hard, service) * times);
}
/* make sure hard is at least same big, but hopefully bigger. */
Modified: initng/trunk/plugins/lockfile/initng_lockfile.c
==============================================================================
--- initng/trunk/plugins/lockfile/initng_lockfile.c (original)
+++ initng/trunk/plugins/lockfile/initng_lockfile.c Tue Apr 4 04:04:13 2006
@@ -45,7 +45,7 @@
D_("status change [%s]\n", service->name);
// are we under influence of lockfile?
- if (initng_active_db_is(&LOCKFILE, service))
+ if (is(&LOCKFILE, service))
{
char *p = strrchr(service->name, '/') + 1;
char lockfile[sizeof(LOCKDIR) + strlen(p)];
Modified: initng/trunk/plugins/logfile/initng_logfile.c
==============================================================================
--- initng/trunk/plugins/logfile/initng_logfile.c (original)
+++ initng/trunk/plugins/logfile/initng_logfile.c Tue Apr 4 04:04:13 2006
@@ -54,7 +54,7 @@
x->pt->name, x->out_pipe[0], x->out_pipe[1], service->name);
/* get the filename */
- filename = initng_active_db_get_string(&LOGFILE, service);
+ filename = get_string(&LOGFILE, service);
if (!filename)
{
D_("Logfile not set\n");
Modified: initng/trunk/plugins/netprobe/initng_netprobe.c
==============================================================================
--- initng/trunk/plugins/netprobe/initng_netprobe.c (original)
+++ initng/trunk/plugins/netprobe/initng_netprobe.c Tue Apr 4 04:04:13 2006
@@ -116,7 +116,7 @@
active_db_h *current = NULL;
/* The network provider should always be stoppable */
- if (initng_active_db_is(&NETWORK_PROVIDER, service))
+ if (is(&NETWORK_PROVIDER, service))
return (TRUE);
/*
@@ -125,8 +125,7 @@
*/
while_active_db(current)
{
- if (initng_active_db_is(&NETWORK_PROVIDER, service)
- && (!IS_DOWN(service)))
+ if (is(&NETWORK_PROVIDER, service) && (!IS_DOWN(service)))
return (FALSE);
}
return (TRUE);
@@ -135,7 +134,7 @@
static int check_START_DEP_MET(active_db_h * service)
{
/* only apply if service requires network */
- if (!initng_active_db_is(&REQUIRE_NETWORK, service))
+ if (!is(&REQUIRE_NETWORK, service))
return (TRUE);
D_("Doing check because REQURE_NETWORK is set.\n");
@@ -149,7 +148,7 @@
while_active_db(current)
{
- if (initng_active_db_is(&NETWORK_PROVIDER, current) && IS_UP(current))
+ if (is(&NETWORK_PROVIDER, current) && IS_UP(current))
goto ok;
}
/* Don't set sleep 1, because initng will be interrupted when a
Modified: initng/trunk/plugins/ngc4/initng_ngc4.c
==============================================================================
--- initng/trunk/plugins/ngc4/initng_ngc4.c (original)
+++ initng/trunk/plugins/ngc4/initng_ngc4.c Tue Apr 4 04:04:13 2006
@@ -927,9 +927,9 @@
/* the routh state */
row->is = serv->current_state->is;
- /* Copy service type name */
- if(serv->type && serv->type->name)
- strncpy(row->type, serv->type->name, 100);
+ /* Copy service type name */
+ if (serv->type && serv->type->name)
+ strncpy(row->type, serv->type->name, 100);
return;
}
@@ -949,9 +949,9 @@
{
row->is = serv->current_state->is;
strncpy(row->state, serv->current_state->state_name, 100);
- /* Copy service type name */
- if(serv->type && serv->type->name)
- strncpy(row->type, serv->type->name,100);
+ /* Copy service type name */
+ if (serv->type && serv->type->name)
+ strncpy(row->type, serv->type->name, 100);
}
}
@@ -990,12 +990,12 @@
if (serv->current_state && serv->current_state->state_name)
{
row->is = serv->current_state->is;
-
- /* Copy service type name */
- if(serv->type && serv->type->name)
- strncpy(row->type, serv->type->name, 100);
-
- /* Copy state name */
+
+ /* Copy service type name */
+ if (serv->type && serv->type->name)
+ strncpy(row->type, serv->type->name, 100);
+
+ /* Copy state name */
strncpy(row->state, serv->current_state->state_name, 100);
}
else
@@ -1097,9 +1097,9 @@
row->is = current->current_state->is;
strncpy(row->state, current->current_state->state_name, 100);
- /* Copy service type name */
- if(current->type && current->type->name)
- strncpy(row->type, current->type->name, 100);
+ /* Copy service type name */
+ if (current->type && current->type->name)
+ strncpy(row->type, current->type->name, 100);
}
else
@@ -1128,9 +1128,9 @@
{
row->is = current->current_state->is;
strncpy(row->state, current->current_state->state_name, 100);
- /* Copy service type name */
- if(current->type && current->type->name)
- strncpy(row->type, current->type->name, 100);
+ /* Copy service type name */
+ if (current->type && current->type->name)
+ strncpy(row->type, current->type->name, 100);
}
else
{
Modified: initng/trunk/plugins/ngc4/initng_ngc4.h
==============================================================================
--- initng/trunk/plugins/ngc4/initng_ngc4.h (original)
+++ initng/trunk/plugins/ngc4/initng_ngc4.h Tue Apr 4 04:04:13 2006
@@ -48,7 +48,7 @@
char name[101]; /* name of service */
struct timeval time_set; /* time status set */
e_is is; /* is status, status in a number */
- char type[101]; /* Type of service this is */
+ char type[101]; /* Type of service this is */
} active_row;
/* this is a structure for an option_row payload */
Modified: initng/trunk/plugins/ngc4/libngcclient.c
==============================================================================
--- initng/trunk/plugins/ngc4/libngcclient.c (original)
+++ initng/trunk/plugins/ngc4/libngcclient.c Tue Apr 4 04:04:13 2006
@@ -384,18 +384,18 @@
string = strdup("Unable to get reply.");
return (string);
}
-
+
/* Have a look what the result is */
switch (rep->result.t)
{
/* if it returned a string, print it */
case STRING_COMMAND:
- if(!rep->payload || rep->result.payload==0)
- {
- string = strdup("No payload.\n");
- return(string);
- }
+ if (!rep->payload || rep->result.payload == 0)
+ {
+ string = strdup("No payload.\n");
+ return (string);
+ }
string = (char *) rep->payload;
break;
/* if it returned some data, call data handlers */
@@ -403,35 +403,35 @@
string = strdup("Command not supported.");
break;
case DATA_COMMANDS_ROW:
- if(!rep->payload || rep->result.payload==0)
- {
- string = strdup("No payload.\n");
- return(string);
- }
+ if (!rep->payload || rep->result.payload == 0)
+ {
+ string = strdup("No payload.\n");
+ return (string);
+ }
string = ngc_hlp(rep, ansi);
break;
case DATA_ACTIVE_ROW:
- if(!rep->payload || rep->result.payload==0)
- {
- string = strdup("No payload.\n");
- return(string);
- }
+ if (!rep->payload || rep->result.payload == 0)
+ {
+ string = strdup("No payload.\n");
+ return (string);
+ }
string = ngc_active_db(rep, ansi);
break;
case DATA_OPTION_ROW:
- if(!rep->payload || rep->result.payload==0)
- {
- string = strdup("No payload.\n");
- return(string);
- }
+ if (!rep->payload || rep->result.payload == 0)
+ {
+ string = strdup("No payload.\n");
+ return (string);
+ }
string = ngc_option_db(rep, ansi);
break;
case INT_COMMAND:
- if(!rep->payload || rep->result.payload==0)
- {
- string = strdup("No payload.\n");
- return(string);
- }
+ if (!rep->payload || rep->result.payload == 0)
+ {
+ string = strdup("No payload.\n");
+ return (string);
+ }
{
/* simplest create an int pointer */
int *p = rep->payload;
@@ -446,11 +446,11 @@
string = strdup("Command replied a failure.");
break;
case TRUE_OR_FALSE_COMMAND:
- if(!rep->payload || rep->result.payload==0)
- {
- string = strdup("No payload.\n");
- return(string);
- }
+ if (!rep->payload || rep->result.payload == 0)
+ {
+ string = strdup("No payload.\n");
+ return (string);
+ }
{
int *p = rep->payload;
@@ -591,12 +591,14 @@
{
mprintf(&string,
C_FG_LIGHT_RED "%.2i:%.2i:%.2i" C_OFF " %c %-35s : ",
- ts->tm_hour, ts->tm_min, ts->tm_sec, (char)toupper((int)row->type[0]), row->name);
+ ts->tm_hour, ts->tm_min, ts->tm_sec,
+ (char) toupper((int) row->type[0]), row->name);
}
else
{
mprintf(&string, "%.2i:%.2i:%.2i %c %-35s : ",
- ts->tm_hour, ts->tm_min, ts->tm_sec, (char)toupper((int)row->type), row->name);
+ ts->tm_hour, ts->tm_min, ts->tm_sec,
+ (char) toupper((int) row->type), row->name);
}
if (ansi)
Modified: initng/trunk/plugins/ngc4/ngc4.c
==============================================================================
--- initng/trunk/plugins/ngc4/ngc4.c (original)
+++ initng/trunk/plugins/ngc4/ngc4.c Tue Apr 4 04:04:13 2006
@@ -75,7 +75,7 @@
{
if (strcmp(service_starting_stopping->name, service) != 0)
{
- /*printf("Dont wanna lissen on \"%s\"\n", service);*/
+ /*printf("Dont wanna lissen on \"%s\"\n", service); */
return;
}
@@ -97,7 +97,7 @@
ngeclient_close_socket(e);
break;
default:
- printf("\nService \"%s\" is now in state: %s\n", service, state);
+ printf("\nService \"%s\" is now in state: %s\n", service, state);
break;
}
}
@@ -184,7 +184,8 @@
}
#endif
-static int send_and_handle(const char c, const char *l, const char *opt, int instant)
+static int send_and_handle(const char c, const char *l, const char *opt,
+ int instant)
{
char *string = NULL;
reply *rep = NULL;
@@ -219,40 +220,41 @@
/* print header if not printed before. */
/* TODO, put initng version from rep here */
- if(header_printed==FALSE && quiet==FALSE)
+ if (header_printed == FALSE && quiet == FALSE)
{
- /* print banner */
- print_out(C_FG_LIGHT_BLUE
- "\n Next Generation init Control. version ( %s )" C_OFF "\n",
- VERSION);
- print_out(C_FG_NEON_GREEN " http://initng.thinktux.net" C_OFF "\n");
- print_out(" Author: Jimmy Wennlund <jimmy.wennlund at gmail.com>\n\n");
- header_printed=TRUE;
+ /* print banner */
+ print_out(C_FG_LIGHT_BLUE
+ "\n Next Generation init Control. version ( %s )" C_OFF
+ "\n", VERSION);
+ print_out(C_FG_NEON_GREEN " http://initng.thinktux.net" C_OFF "\n");
+ print_out(" Author: Jimmy Wennlund <jimmy.wennlund at gmail.com>\n\n");
+ header_printed = TRUE;
}
#ifdef HAVE_NGE
- if(instant==FALSE && quiet==FALSE)
+ if (instant == FALSE && quiet == FALSE)
{
- /*
- * there are special commands, where we wanna
- * initziate nge, and follow the service.
- */
- if (rep->result.c == 'u' || rep->result.c == 'd')
- {
- return (start_or_stop_command(rep));
- }
+ /*
+ * there are special commands, where we wanna
+ * initziate nge, and follow the service.
+ */
+ if (rep->result.c == 'u' || rep->result.c == 'd')
+ {
+ return (start_or_stop_command(rep));
+ }
}
#endif
-
+
/* only print when not quiet */
- if(quiet == FALSE)
+ if (quiet == FALSE)
{
- string = ngcclient_reply_to_string(rep, TRUE);
- print_out("\n\n%s\n", string);
- if(string) free(string);
+ string = ngcclient_reply_to_string(rep, TRUE);
+ print_out("\n\n%s\n", string);
+ if (string)
+ free(string);
}
-
+
free(rep);
return (TRUE);
}
@@ -326,7 +328,7 @@
if (debug == FALSE && getuid() != 0)
{
print_out(C_ERROR "You need root access to communicate with initng."
- C_OFF "\n");
+ C_OFF "\n");
exit(2);
}
@@ -343,7 +345,8 @@
{
/* check if is a string or char */
if (Argv[4])
- return (send_and_handle('\0', &Argv[3], argv[1], instant));
+ return (send_and_handle
+ ('\0', &Argv[3], argv[1], instant));
else
return (send_and_handle(Argv[3], NULL, argv[1], instant));
}
@@ -351,7 +354,8 @@
{
/* check if its a string or char */
if (Argv[3])
- return (send_and_handle('\0', &Argv[2], argv[1], instant));
+ return (send_and_handle
+ ('\0', &Argv[2], argv[1], instant));
else
return (send_and_handle(Argv[2], NULL, argv[1], instant));
}
@@ -395,23 +399,23 @@
/* if it is an --option */
if (argv[cc][1] == '-')
{
-
- /* handle local --instant */
- if(strcmp(&argv[cc][2], "instant")==0)
- {
- instant=TRUE;
- cc++;
- continue;
- }
-
- /* handle local --quiet */
- if(strcmp(&argv[cc][2], "quiet") == 0)
- {
- quiet = TRUE;
- cc++;
- continue;
- }
-
+
+ /* handle local --instant */
+ if (strcmp(&argv[cc][2], "instant") == 0)
+ {
+ instant = TRUE;
+ cc++;
+ continue;
+ }
+
+ /* handle local --quiet */
+ if (strcmp(&argv[cc][2], "quiet") == 0)
+ {
+ quiet = TRUE;
+ cc++;
+ continue;
+ }
+
if (!send_and_handle('\0', &argv[cc][2], opt, instant))
exit(1);
}
Modified: initng/trunk/plugins/nge/initng_nge.c
==============================================================================
--- initng/trunk/plugins/nge/initng_nge.c (original)
+++ initng/trunk/plugins/nge/initng_nge.c Tue Apr 4 04:04:13 2006
@@ -469,22 +469,25 @@
char *msg;
int len, size;
- size = 256; msg = i_calloc(1,size);
+ size = 256;
+ msg = i_calloc(1, size);
len = vsnprintf(msg, size, format, arg);
- while(len < 0 || len >= size)
+ while (len < 0 || len >= size)
{
/* Some glibc versions apparently return -1 if buffer too small.
Oh, and the argument counts the null char, but the return
value doesn't, apparently. (See man page for gory details.) */
- size = ( len < 0 ? size * 2 : len + 1 );
- free(msg); msg = i_calloc(1, size);
+ size = (len < 0 ? size * 2 : len + 1);
+ free(msg);
+ msg = i_calloc(1, size);
len = vsnprintf(msg, 256, format, arg);
}
-
- buffert=calloc(100 + len + strlen(file) + strlen(func), sizeof(char));
-
- len=sprintf(buffert, "<event type=\"err_msg\" mt=\"%i\" file=\"%s\" func=\"%s\" line=\"%i\">%s</event>\n",
- mt, file, func, line, msg);
+
+ buffert = calloc(100 + len + strlen(file) + strlen(func), sizeof(char));
+
+ len = sprintf(buffert,
+ "<event type=\"err_msg\" mt=\"%i\" file=\"%s\" func=\"%s\" line=\"%i\">%s</event>\n",
+ mt, file, func, line, msg);
len = vsnprintf(msg, 1000, format, arg);
Modified: initng/trunk/plugins/nge/libngeclient.c
==============================================================================
--- initng/trunk/plugins/nge/libngeclient.c (original)
+++ initng/trunk/plugins/nge/libngeclient.c Tue Apr 4 04:04:13 2006
@@ -624,7 +624,7 @@
if (event->read_buffer == NULL || event->read_buffer_len < 1)
return;
- /*printf("read_buffer:\"%s\"\n", event->read_buffer);*/
+ /*printf("read_buffer:\"%s\"\n", event->read_buffer); */
if (event->read_buffer[0] != '<')
{
@@ -647,7 +647,7 @@
/* count the lengt of this tag */
int chars = 0;
- int tagend_found = 0;
+ int tagend_found = 0;
while (event->read_buffer[chars])
{
@@ -656,39 +656,39 @@
&& event->read_buffer[chars + 1] == '>')
{
chars += 2;
- tagend_found = 1;
+ tagend_found = 1;
break;
}
-
+
/* if found "</" This is also tag-out */
if (event->read_buffer[chars] == '<'
- && event->read_buffer[chars + 1] == '/')
+ && event->read_buffer[chars + 1] == '/')
{
- /*printf("tag_stop: %s\n", &event->read_buffer[chars]);*/
+ /*printf("tag_stop: %s\n", &event->read_buffer[chars]); */
chars += 2;
/* skip to the end char of tag */
while (event->read_buffer[chars]
&& event->read_buffer[chars] != '>')
chars++;
- if (event->read_buffer[chars] == '>')
- chars++;
- /*printf("tag_stop_after: %s\n", &event->read_buffer[chars]);*/
-
- tagend_found = 1;
+ if (event->read_buffer[chars] == '>')
+ chars++;
+ /*printf("tag_stop_after: %s\n", &event->read_buffer[chars]); */
+
+ tagend_found = 1;
break;
}
/* increase chars of tags counter */
chars++;
}
-
- /* if tagend not found, return to mainloop and fetch more data */
- if(tagend_found==0)
- {
- /*printf("No tagend [%i]: \"%s\"\n", chars, event->read_buffer);*/
- return;
- }
+
+ /* if tagend not found, return to mainloop and fetch more data */
+ if (tagend_found == 0)
+ {
+ /*printf("No tagend [%i]: \"%s\"\n", chars, event->read_buffer); */
+ return;
+ }
if (chars > 0 && event->read_buffer[0] == '<')
@@ -739,7 +739,7 @@
/* ok, parse tags */
ngeclient_parse_tags(event);
-
- usleep(100);
+
+ usleep(100);
}
}
Modified: initng/trunk/plugins/pause/initng_pause.c
==============================================================================
--- initng/trunk/plugins/pause/initng_pause.c (original)
+++ initng/trunk/plugins/pause/initng_pause.c Tue Apr 4 04:04:13 2006
@@ -49,8 +49,8 @@
D_(" %s\n", s->name);
- s_delay = initng_active_db_get_int_var(&S_DELAY, p->pt->name, s);
- ms_delay = initng_active_db_get_int_var(&MS_DELAY, p->pt->name, s);
+ s_delay = get_int_var(&S_DELAY, p->pt->name, s);
+ ms_delay = get_int_var(&MS_DELAY, p->pt->name, s);
if (s_delay)
Modified: initng/trunk/plugins/reload/initng_reload.c
==============================================================================
--- initng/trunk/plugins/reload/initng_reload.c (original)
+++ initng/trunk/plugins/reload/initng_reload.c Tue Apr 4 04:04:13 2006
@@ -63,20 +63,23 @@
static int fd_used_by_service(int fd)
{
- active_db_h * service = NULL;
+ active_db_h *service = NULL;
+
while_active_db(service)
{
- process_h * process = NULL;
- while_processes(process, service)
- {
- if(process->out_pipe[0]==fd)
- {
- W_("Wont close fd %i, used by service \"%s\"\n", fd, service->name);
- return(TRUE);
- }
- }
+ process_h *process = NULL;
+
+ while_processes(process, service)
+ {
+ if (process->out_pipe[0] == fd)
+ {
+ W_("Wont close fd %i, used by service \"%s\"\n", fd,
+ service->name);
+ return (TRUE);
+ }
+ }
}
- return(FALSE);
+ return (FALSE);
}
static void cmd_fast_reload(char *arg)
@@ -87,12 +90,12 @@
char *new_argv[4];
retval = initng_plugin_callers_dump_active_db();
-
+
/* close all fd, exept stdin, stdout, stderr, and that ones that point to our services */
- for(i=3;i<1024;i++)
+ for (i = 3; i < 1024; i++)
{
- if(fd_used_by_service(i)==FALSE)
- close(i);
+ if (fd_used_by_service(i) == FALSE)
+ close(i);
}
if (retval == TRUE)
@@ -243,7 +246,7 @@
default:
break;
}
- list_add(&d->list, &new_entry->data.list);
+ list_add(&d->list, &new_entry->data.head.list);
i++;
}
}
@@ -340,7 +343,7 @@
}
i = 0;
- list_for_each_entry(c_d, ¤t->data.list, list)
+ list_for_each_entry(c_d, ¤t->data.head.list, list)
{
if (!c_d->type)
continue;
Modified: initng/trunk/plugins/renice/initng_renice.c
==============================================================================
--- initng/trunk/plugins/renice/initng_renice.c (original)
+++ initng/trunk/plugins/renice/initng_renice.c Tue Apr 4 04:04:13 2006
@@ -39,12 +39,11 @@
assert(s->name);
assert(p);
- if (initng_active_db_is(&NICE, s))
+ if (is(&NICE, s))
{
- D_("Will renice %s to %i !\n", s->name,
- initng_active_db_get_int(&NICE, s));
+ D_("Will renice %s to %i !\n", s->name, get_int(&NICE, s));
errno = 0;
- if (nice(initng_active_db_get_int(&NICE, s)) == -1 && errno != 0)
+ if (nice(get_int(&NICE, s)) == -1 && errno != 0)
{
F_("Failed to set the nice value: %s\n", strerror(errno));
return FALSE;
Modified: initng/trunk/plugins/rlparser/initng_rl_parser.c
==============================================================================
--- initng/trunk/plugins/rlparser/initng_rl_parser.c (original)
+++ initng/trunk/plugins/rlparser/initng_rl_parser.c Tue Apr 4 04:04:13 2006
@@ -45,18 +45,20 @@
stype_h *TYPE_RUNLEVEL;
stype_h *TYPE_VIRTUAL;
-static service_cache_h * parse_file(char *filetoparse, const char *runlevel_name, stype_h *type)
+static service_cache_h *parse_file(char *filetoparse,
+ const char *runlevel_name, stype_h * type)
{
service_cache_h *n_service; /* service struct pointer too */
char *w = NULL;
char *a = NULL;
char *w_depends = NULL;
- /* allocate a new service */
- if (!(n_service = initng_service_cache_new(runlevel_name, type)))
- {
- free(filetoparse);
- return (NULL);
- }
+
+ /* allocate a new service */
+ if (!(n_service = initng_service_cache_new(runlevel_name, type)))
+ {
+ free(filetoparse);
+ return (NULL);
+ }
/* copy file filename into allocated file_buf */
if (!open_read_close(filetoparse, &w_depends))
@@ -66,7 +68,7 @@
free(n_service->name);
/* free all data entries */
- initng_service_cache_remove_all(n_service);
+ dfree_all(n_service);
if (n_service)
free(n_service);
@@ -93,7 +95,7 @@
if (a)
{
D_("adding dep: \"%s\"\n", a);
- inting_service_cache_set_another_string(&NEED, n_service, a);
+ set_another_string(&NEED, n_service, a);
}
JUMP_TO_NEXT_ROW(w);
@@ -101,8 +103,7 @@
free(w_depends);
- initng_service_cache_set_string(&FROM_FILE, n_service,
- i_strdup(filetoparse));
+ set_string(&FROM_FILE, n_service, i_strdup(filetoparse));
free(filetoparse);
@@ -120,7 +121,7 @@
{
char *filetoparse = NULL;
struct stat file_stat;
-
+
assert(runlevel_name);
@@ -134,7 +135,7 @@
return (NULL);
}
}
-
+
if (!TYPE_VIRTUAL)
{
TYPE_VIRTUAL = initng_service_types_get("virtual");
@@ -144,7 +145,7 @@
return (NULL);
}
}
-
+
filetoparse = (char *) i_calloc(strlen(INITNG_ROOT) + 1 +
strlen(runlevel_name) + 10, sizeof(char));
@@ -152,23 +153,23 @@
strcpy(filetoparse, INITNG_ROOT "/");
strcat(filetoparse, runlevel_name);
strcat(filetoparse, ".virtual");
-
- if(stat(filetoparse, &file_stat)==0 && S_ISREG(file_stat.st_mode))
+
+ if (stat(filetoparse, &file_stat) == 0 && S_ISREG(file_stat.st_mode))
{
- return(parse_file(filetoparse, runlevel_name, TYPE_VIRTUAL));
+ return (parse_file(filetoparse, runlevel_name, TYPE_VIRTUAL));
}
/* check /etc/initng/name.runlevel */
strcpy(filetoparse, INITNG_ROOT "/");
strcat(filetoparse, runlevel_name);
strcat(filetoparse, ".runlevel");
-
- if(stat(filetoparse, &file_stat)==0 && S_ISREG(file_stat.st_mode))
+
+ if (stat(filetoparse, &file_stat) == 0 && S_ISREG(file_stat.st_mode))
{
- return(parse_file(filetoparse, runlevel_name, TYPE_RUNLEVEL));
+ return (parse_file(filetoparse, runlevel_name, TYPE_RUNLEVEL));
}
- return(NULL);
+ return (NULL);
}
int module_init(int api_version)
Modified: initng/trunk/plugins/runlevel/initng_runlevel.c
==============================================================================
--- initng/trunk/plugins/runlevel/initng_runlevel.c (original)
+++ initng/trunk/plugins/runlevel/initng_runlevel.c Tue Apr 4 04:04:13 2006
@@ -235,72 +235,77 @@
{
/* Start our dependencies */
initng_depend_start_deps(new_runlevel);
-
-
+
+
/* Make sure there will only exist 1 runlevel on the system */
- if(new_runlevel->type == &TYPE_RUNLEVEL)
+ if (new_runlevel->type == &TYPE_RUNLEVEL)
{
- active_db_h *current = NULL;
- active_db_h *old_runlevel = NULL;
-
- /* STEP 1, Go find old runlevel, shud be only one */
- while_active_db(current)
- {
- /* dont look for myself */
- if(current==new_runlevel)
- continue;
-
- if(current->type==&TYPE_RUNLEVEL)
- {
- old_runlevel=current;
- break;
- }
- }
-
- /* if an old runlevel was found */
- if(old_runlevel)
- {
- const char *dep_old=NULL;
-
- /* STEP 2, Stop all old runlevel deps, that are not deps of new runlevel */
-
- /* for every dep the old runlevel have */
- while((dep_old=initng_active_db_get_next_string(&NEED, old_runlevel, dep_old)))
- {
- const char *dep_new=NULL;
- int found=0;
-
- while((dep_new=initng_active_db_get_next_string(&NEED, new_runlevel, dep_new)))
- {
- /* if it matches */
- if(strcmp(dep_new, dep_old)==0)
- {
- found=1;
- break;
- }
- }
-
-
- /* If the service found in old runlevel, does not exsist i new one, stop it */
- if(found==0)
- {
- active_db_h *service_to_stop=initng_active_db_find_by_name(dep_old);
- if(service_to_stop)
- {
- W_("Stopping service %s, not in new service %s\n", service_to_stop->name, new_runlevel->name);
- initng_handler_stop_service(service_to_stop);
- }
- }
- }
- /* check that it also exists in new runlevel */
-
-
- /* STEP 3, Stop old runlevel */
- initng_handler_stop_service(old_runlevel);
- }
- free(g.runlevel);
- g.runlevel=NULL;
- g.runlevel=i_strdup(new_runlevel->name);
+ active_db_h *current = NULL;
+ active_db_h *old_runlevel = NULL;
+
+ /* STEP 1, Go find old runlevel, shud be only one */
+ while_active_db(current)
+ {
+ /* dont look for myself */
+ if (current == new_runlevel)
+ continue;
+
+ if (current->type == &TYPE_RUNLEVEL)
+ {
+ old_runlevel = current;
+ break;
+ }
+ }
+
+ /* if an old runlevel was found */
+ if (old_runlevel)
+ {
+ const char *dep_old = NULL;
+ s_data *itt_old = NULL;
+
+ /* STEP 2, Stop all old runlevel deps, that are not deps of new runlevel */
+
+ /* for every dep the old runlevel have */
+ while ((dep_old = get_next_string(&NEED, old_runlevel, &itt_old)))
+ {
+ const char *dep_new = NULL;
+ s_data *itt_new = NULL;
+ int found = 0;
+
+ while ((dep_new =
+ get_next_string(&NEED, new_runlevel, &itt_new)))
+ {
+ /* if it matches */
+ if (strcmp(dep_new, dep_old) == 0)
+ {
+ found = 1;
+ break;
+ }
+ }
+
+
+ /* If the service found in old runlevel, does not exsist i new one, stop it */
+ if (found == 0)
+ {
+ active_db_h *service_to_stop = initng_active_db_find_by_name(dep_old);
+
+ if (service_to_stop)
+ {
+ W_("Stopping service %s, not in new service %s\n",
+ service_to_stop->name, new_runlevel->name);
+ initng_handler_stop_service(service_to_stop);
+ }
+ }
+ }
+ /* check that it also exists in new runlevel */
+
+
+ /* STEP 3, Stop old runlevel */
+ initng_handler_stop_service(old_runlevel);
+ }
+ free(g.runlevel);
+ g.runlevel = NULL;
+ g.runlevel = i_strdup(new_runlevel->name);
}
initng_common_mark_service(new_runlevel, &RUNLEVEL_WAITING_FOR_START_DEP);
Modified: initng/trunk/plugins/service/initng_service.c
==============================================================================
--- initng/trunk/plugins/service/initng_service.c (original)
+++ initng/trunk/plugins/service/initng_service.c Tue Apr 4 04:04:13 2006
@@ -483,11 +483,11 @@
D_("Service %s, run init_SERVICE_START_RUN\n", service->name);
/* if NEVER_KILL is set, dont bother */
- if (initng_active_db_is(&NEVER_KILL, service))
+ if (is(&NEVER_KILL, service))
return;
/* get the timeout */
- timeout = initng_active_db_get_int(&START_TIMEOUT, service);
+ timeout = get_int(&START_TIMEOUT, service);
/* if not set, use the default one */
if (!timeout)
@@ -509,11 +509,11 @@
D_("Service %s, run init_SERVICE_STOP_RUN\n", service->name);
/* if NEVER_KILL is set, dont bother */
- if (initng_active_db_is(&NEVER_KILL, service))
+ if (is(&NEVER_KILL, service))
return;
/* get the timeout */
- timeout = initng_active_db_get_int(&STOP_TIMEOUT, service);
+ timeout = get_int(&STOP_TIMEOUT, service);
/* if not set, use the default timeout */
if (!timeout)
@@ -644,7 +644,7 @@
*/
/* TODO MAKE UP_ON_FAILURE more universal */
- if (process->r_code && !initng_active_db_is(&START_FAIL_OK, service))
+ if (process->r_code && !is(&START_FAIL_OK, service))
{
initng_common_mark_service(service, &SERVICE_FAIL_STARTING);
@@ -704,7 +704,7 @@
* from the program, is bigger than 0, this commonly signalize
* that something got wrong, print this as an error msg on screen
*/
- if (process->r_code > 0 && !initng_active_db_is(&STOP_FAIL_OK, service))
+ if (process->r_code > 0 && !is(&STOP_FAIL_OK, service))
{
F_(" stop %s, Returned with exit %i.\n", service->name,
process->r_code);
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 Apr 4 04:04:13 2006
@@ -214,9 +214,8 @@
process->pt->name);
/* exec_args should be parsed at the moment, too */
- exec_args_unfixed = initng_active_db_get_string_var(&EXEC_ARGS,
- process->pt->name,
- service);
+ exec_args_unfixed = get_string_var(&EXEC_ARGS,
+ process->pt->name, service);
if (exec_args_unfixed)
{
char *exec_args = NULL;
@@ -262,12 +261,12 @@
{
const char *exec = NULL;
struct stat stat_struct;
+ s_data *itt = NULL;
D_("service: %s, process: %s\n", service->name, process->pt->name);
while ((exec =
- initng_active_db_get_next_string_var(&EXECS, process->pt->name,
- service, exec)))
+ get_next_string_var(&EXECS, process->pt->name, service, &itt)))
{
int res = FALSE;
char *exec_fixed = NULL;
@@ -315,7 +314,7 @@
D_("service: %s process: %s.\n", service->name, process->pt->name);
- exec = initng_active_db_get_string_var(&EXEC, process->pt->name, service);
+ exec = get_string_var(&EXEC, process->pt->name, service);
if (!exec)
return (FALSE);
@@ -386,10 +385,10 @@
D_("service: %s, process: %s\n", service->name, process->pt->name);
- if (initng_active_db_is_var(&EXECS, process->pt->name, service))
+ if (is_var(&EXECS, process->pt->name, service))
return (simple_exec(service, process));
- if (initng_active_db_is_var(&EXEC, process->pt->name, service))
+ if (is_var(&EXEC, process->pt->name, service))
return (simple_run(service, process));
return (FALSE);
Modified: initng/trunk/plugins/stdout/initng_stdout.c
==============================================================================
--- initng/trunk/plugins/stdout/initng_stdout.c (original)
+++ initng/trunk/plugins/stdout/initng_stdout.c Tue Apr 4 04:04:13 2006
@@ -80,10 +80,10 @@
S_;
/* get strings if present */
- s_stdout = initng_active_db_get_string(&STDOUT, s);
- s_stderr = initng_active_db_get_string(&STDERR, s);
- s_stdall = initng_active_db_get_string(&STDALL, s);
- s_stdin = initng_active_db_get_string(&STDIN, s);
+ s_stdout = get_string(&STDOUT, s);
+ s_stderr = get_string(&STDERR, s);
+ s_stdall = get_string(&STDALL, s);
+ s_stdin = get_string(&STDIN, s);
if (!(s_stdout || s_stderr || s_stdall || s_stdin))
{
Modified: initng/trunk/plugins/suid/initng_suid.c
==============================================================================
--- initng/trunk/plugins/suid/initng_suid.c (original)
+++ initng/trunk/plugins/suid/initng_suid.c Tue Apr 4 04:04:13 2006
@@ -38,18 +38,19 @@
s_entry SUID = { "suid", STRING, NULL, "Set this user id on launch." };
s_entry SGID = { "sgid", STRING, NULL, "Set this group id on launch." };
-void adjust_env(active_db_h * service, const char* vn, const char* vv);
-void adjust_env(active_db_h * service, const char* vn, const char* vv)
+void adjust_env(active_db_h * service, const char *vn, const char *vv);
+void adjust_env(active_db_h * service, const char *vn, const char *vv)
{
- /* add to service cache */
- if (initng_service_cache_is_var(&ENV, vn, service->from_service))
- {
- return; /* Assume they were set by .i file, don't override */
- }
- else
- {
- initng_service_cache_set_string_var(&ENV, i_strdup(vn), service->from_service, i_strdup(vv));
- }
+ /* add to service cache */
+ if (is_var(&ENV, vn, service->from_service))
+ {
+ return; /* Assume they were set by .i file, don't override */
+ }
+ else
+ {
+ set_string_var(&ENV, i_strdup(vn), service->from_service,
+ i_strdup(vv));
+ }
}
static int do_suid(active_db_h * service, process_h * process
@@ -69,12 +70,12 @@
assert(service->name);
assert(process);
- if ((tmp = initng_active_db_get_string(&SGID, service)))
+ if ((tmp = get_string(&SGID, service)))
{
groupname = fix_variables(tmp, service);
}
- tmp = initng_active_db_get_string(&SUID, service);
+ tmp = get_string(&SUID, service);
if (tmp)
username = fix_variables(tmp, service);
@@ -129,8 +130,8 @@
/* Set UID-related env variables */
adjust_env(service, "USER", passwd->pw_name);
- adjust_env(service, "HOME", passwd->pw_dir);
- adjust_env(service, "PATH", "/bin:/usr/bin");
+ adjust_env(service, "HOME", passwd->pw_dir);
+ adjust_env(service, "PATH", "/bin:/usr/bin");
}
if (groupname)
Modified: initng/trunk/plugins/syncron/initng_syncron.c
==============================================================================
--- initng/trunk/plugins/syncron/initng_syncron.c (original)
+++ initng/trunk/plugins/syncron/initng_syncron.c Tue Apr 4 04:04:13 2006
@@ -65,8 +65,7 @@
if (!resolv_SSR())
return (TRUE);
- if ((service_syncron =
- initng_active_db_get_string(&SYNCRON, service)) == NULL)
+ if ((service_syncron = get_string(&SYNCRON, service)) == NULL)
return (TRUE);
while_active_db_safe(current, q)
@@ -80,8 +79,7 @@
/* If this service has the start process running */
if (IS_MARK(current, SERVICE_START_RUN))
{
- if ((current_syncron =
- initng_active_db_get_string(&SYNCRON, current)) != NULL)
+ if ((current_syncron = get_string(&SYNCRON, current)) != NULL)
{
if (strcmp(service_syncron, current_syncron) == 0)
{
Modified: initng/trunk/src/initng_active_db.c
==============================================================================
--- initng/trunk/src/initng_active_db.c (original)
+++ initng/trunk/src/initng_active_db.c Tue Apr 4 04:04:13 2006
@@ -250,8 +250,9 @@
return (NULL);
}
+ DATA_HEAD_INIT(&new_active->data);
+
/* initialize the data and process list */
- INIT_LIST_HEAD(&(new_active->data.list));
INIT_LIST_HEAD(&(new_active->processes.list));
/* get the time, and copy that time to all time entries */
@@ -293,7 +294,7 @@
}
/* remove every data entry */
- d_remove_all(&pf->data.list);
+ dfree_all(pf);
/* remove file cache of entry if present, so we got a fresh read from file when this service is restarted */
if (pf->from_service)
@@ -362,7 +363,10 @@
assert(current->name);
/* change this time */
if (current->from_service == from)
+ {
current->from_service = to;
+ current->data.res = ¤t->from_service->data;
+ }
}
}
@@ -508,138 +512,6 @@
}
-/* ######## Data handlers ############## */
-const char *initng_active_db_get_string_var(s_entry * type, const char *vn,
- active_db_h * from_active)
-{
- const char *t = NULL;
-
- assert(from_active);
-
- /* look in active data */
- if ((t = d_get_string_var(type, vn, &from_active->data.list)))
- return (t);
-
- /* load a service file, if not exists */
- if (!from_active->from_service)
- initng_common_get_service(from_active);
-
- /* look in service file data */
- if (from_active->from_service)
- return (initng_service_cache_get_string_var
- (type, vn, from_active->from_service));
-
- return (NULL);
-}
-
-int initng_active_db_get_int_var(s_entry * type, const char *vn,
- active_db_h * from_active)
-{
- assert(from_active);
-
- if (d_is_var(type, vn, &from_active->data.list))
- return (d_get_int_var(type, vn, &from_active->data.list));
-
- if (!from_active->from_service)
- initng_common_get_service(from_active);
- if (from_active->from_service)
- return (initng_service_cache_get_int_var
- (type, vn, (from_active->from_service)));
- return (0);
-}
-
-const char *initng_active_db_get_next_string_var(s_entry * type,
- const char *vn,
- active_db_h * from_active,
- const char *last)
-{
- const char *r = NULL;
-
- assert(from_active);
-
- /* check active overlay data */
- if ((r = d_get_next_string_var(type, vn, &from_active->data.list, last)))
- return (r);
-
- /* load service from disk, if nonexistent */
- if (!from_active->from_service)
- initng_common_get_service(from_active);
-
- /* check service data */
- if (from_active->from_service)
- return (initng_service_cache_get_next_string_var
- (type, vn, from_active->from_service, last));
- return (NULL);
-}
-
-s_data *initng_active_db_get_next(s_entry * type, active_db_h * from_active,
- s_data * current)
-{
- struct list_head *cur = NULL;
-
- /* load service cache from disk, if nonexistent */
- if (!from_active->from_service)
- initng_common_get_service(from_active);
- if (!from_active->from_service)
- return (NULL);
-
- restart:
- /* if current not set, point to a_head */
- if (!current)
- cur = from_active->data.list.prev;
- else
- cur = current->list.prev;
-
- /* if next is end of a_head, point to beginning of c_head */
- if (cur == &from_active->data.list)
- cur = from_active->from_service->data.list.prev;
-
- /* if next is end of c_head, this is the totally last one */
- if (cur == &from_active->from_service->data.list)
- return (NULL);
-
- /* get the sdata pointer */
- current = list_entry(cur, typeof(s_data), list);
-
- /* make sure its the correct type */
- if (current->type != type)
- goto restart;
-
- return (current);
-}
-
-int initng_active_db_is_var(s_entry * type, const char *vn,
- active_db_h * from_active)
-{
- assert(from_active);
-
- /* check active overlay data */
- if (d_is_var(type, vn, &from_active->data.list))
- return (TRUE);
-
- /* load service from disk, if nonexistent */
- if (!from_active->from_service)
- initng_common_get_service(from_active);
-
- /* check service data */
- if (from_active->from_service)
- if (initng_service_cache_is_var(type, vn, from_active->from_service))
- return (TRUE);
-
- return (FALSE);
-}
-
-int initng_active_db_count_type(s_entry * type, active_db_h * from_active)
-{
- assert(from_active);
- if (!from_active->from_service)
- initng_common_get_service(from_active);
-
- if (from_active->from_service)
- return (initng_service_cache_count_type
- (type, from_active->from_service));
- return (0);
-}
/*
* Walk the active db, searching for services that are down, and been so for a minute.
Modified: initng/trunk/src/initng_active_db.h
==============================================================================
--- initng/trunk/src/initng_active_db.h (original)
+++ initng/trunk/src/initng_active_db.h Tue Apr 4 04:04:13 2006
@@ -63,7 +63,7 @@
process_h processes;
/* list container, for data */
- s_data data;
+ data_head data;
/* Alarm, the current state alarm is run when this time passes */
time_t alarm;
@@ -97,54 +97,11 @@
void initng_active_db_free(active_db_h * pf);
void initng_active_db_free_all(void);
-/* dependency check */
-/* returns TRUE if service DEP ON check */
-/*int initng_active_db_dep_on(active_db_h * service, active_db_h * check);
- int initng_active_db_dep_on_deep(active_db_h * service, active_db_h * check); */
-
/* utils */
int initng_active_db_percent_started(void);
int initng_active_db_percent_stopped(void);
-
-/* get/set data handling */
-#define initng_active_db_get_int(t,a) initng_active_db_get_int_var(t, NULL, a)
-#define initng_active_db_get_string(t,a) initng_active_db_get_string_var(t, NULL, a)
-#define initng_active_db_get_next_string(t,a,l) initng_active_db_get_next_string_var(t,NULL, a, l)
-
-
-s_data *initng_active_db_get_next(s_entry * type, active_db_h * from_active,
- s_data * last);
-
-#define initng_active_db_is(t,a) initng_active_db_is_var(t, NULL, a)
-int initng_active_db_get_int_var(s_entry * type, const char *vn,
- active_db_h * from_active);
-const char *initng_active_db_get_string_var(s_entry * type, const char *vn,
- active_db_h * from_active);
-const char *initng_active_db_get_next_string_var(s_entry * type,
- const char *vn,
- active_db_h * from_active,
- const char *last);
-int initng_active_db_is_var(s_entry * type, const char *vn,
- active_db_h * from_active);
-
-/* count the total number of this type */
-int initng_active_db_count_type(s_entry * type, active_db_h * from_active);
void initng_active_db_clean_down(void);
-#define initng_active_db_set_string(type, act, string) d_set_string(type, &act->data.list, string)
-#define initng_active_db_set_another_string(type, act, string) d_set_another_string(type, &act->data.list, string)
-#define initng_active_db_set_int(type, act, value) d_set_int(type, &act->data.list, value)
-#define initng_active_db_set(type, act) d_set(type, &act->data.list)
-#define initng_active_db_set_string_var(type, vn, act, string) d_set_string_var(type, vn, &act->data.list, string)
-#define initng_active_db_set_another_string_var(type, vn, act, string) d_set_another_string_var(type, vn, &act->data.list, string)
-#define initng_active_db_set_int_var(type, vn, act, value) d_set_int_var(type, vn, &act->data.list, value)
-#define initng_active_db_set_var(type, vn, act) d_set_var(type, vn, &act->data.list)
-
-#define initng_active_db_remove(type, act) d_remove(type, &act->data.list)
-#define initng_active_db_remove_var(type, vn, act) d_remove(type, vn, &act->data.list)
-#define initng_active_db_remove_all(act) d_remove_all(&act->data.list)
-#define initng_active_db_unset(type, act) initng_active_db_remove(type, act)
-
#define while_active_db(current) list_for_each_entry_prev(current, &g.active_database.list, list)
#define while_active_db_safe(current, safe) list_for_each_entry_prev_safe(current, safe, &g.active_database.list, list)
Modified: initng/trunk/src/initng_common.c
==============================================================================
--- initng/trunk/src/initng_common.c (original)
+++ initng/trunk/src/initng_common.c Tue Apr 4 04:04:13 2006
@@ -202,6 +202,7 @@
initng_service_cache_find_by_exact_name(service->name)))
{
service->type = service->from_service->type;
+ service->data.res = &service->from_service->data;
D_("get_service(%s): found service in service database!\n",
service->name);
return (TRUE);
@@ -215,6 +216,7 @@
return (FALSE);
}
service->type = service->from_service->type;
+ service->data.res = &service->from_service->data;
D_(" get_service(%s): got service from initng dynamic parsers.\n",
service->name);
@@ -354,7 +356,7 @@
{
if (((*current->c.additional_parse) (service)) != TRUE)
{
- initng_service_cache_free(service);
+ initng_service_cache_free(service);
return (NULL);
}
}
@@ -464,7 +466,7 @@
/* if this service is marked restarting, please restart it if its set to STOPPED */
if (IS_DOWN(service))
{
- if (initng_active_db_is(&RESTARTING, service))
+ if (is(&RESTARTING, service))
{
initng_handler_restart_restarting();
}
Modified: initng/trunk/src/initng_depend.c
==============================================================================
--- initng/trunk/src/initng_depend.c (original)
+++ initng/trunk/src/initng_depend.c Tue Apr 4 04:04:13 2006
@@ -154,25 +154,24 @@
static int dep_on(active_db_h * service, active_db_h * check)
{
const char *string = NULL;
+ s_data *current = NULL;
assert(service);
assert(check);
- while ((string =
- initng_active_db_get_next_string(&REQUIRE, service, string)))
+ while ((string = get_next_string(&REQUIRE, service, ¤t)))
{
if (strcmp(string, check->name) == 0)
return (TRUE);
}
- string = NULL;
- while ((string =
- initng_active_db_get_next_string(&NEED, service, string)))
+ current = NULL;
+ while ((string = get_next_string(&NEED, service, ¤t)))
{
if (strcmp(string, check->name) == 0)
return (TRUE);
}
- string = NULL;
- while ((string = initng_active_db_get_next_string(&USE, service, string)))
+ current = NULL;
+ while ((string = get_next_string(&USE, service, ¤t)))
{
if (strcmp(string, check->name) == 0)
return (TRUE);
@@ -445,11 +444,14 @@
{
const char *tmp = NULL;
active_db_h *dep = NULL;
+ s_data *current = NULL;
assert(service);
assert(service->name);
- while ((tmp = initng_active_db_get_next_string(&REQUIRE, service, tmp)))
+ /* TODO, make this one while loop, using active_db_get_next */
+
+ while ((tmp = get_next_string(&REQUIRE, service, ¤t)))
{
/* look if it exits already */
if ((dep = initng_active_db_find_by_name(tmp)))
@@ -472,7 +474,8 @@
}
}
- while ((tmp = initng_active_db_get_next_string(&NEED, service, tmp)))
+ current = NULL;
+ while ((tmp = get_next_string(&NEED, service, ¤t)))
{
/* look if it exits already */
if ((dep = initng_active_db_find_by_name(tmp)))
Modified: initng/trunk/src/initng_env_variable.c
==============================================================================
--- initng/trunk/src/initng_env_variable.c (original)
+++ initng/trunk/src/initng_env_variable.c Tue Apr 4 04:04:13 2006
@@ -94,7 +94,7 @@
/* count ENVs in service ENV variable */
if (s)
- allocate += initng_active_db_count_type(&ENV, s);
+ allocate += count_type(&ENV, s);
/* finally allocate */
@@ -185,7 +185,7 @@
{
char *fixed = NULL;
- if (!(tmp = initng_active_db_get_next(&ENV, s, tmp)))
+ if (!(tmp = get_next(&ENV, s, tmp)))
break;
fixed = fix_variables(tmp->t.s, s);
@@ -493,7 +493,7 @@
{
s_data *tmp = NULL;
- while ((tmp = initng_active_db_get_next(&ENV, s, tmp)))
+ while ((tmp = get_next(&ENV, s, tmp)))
{
if (strncasecmp(from, tmp->vn, len) == 0 && tmp->vn[len] == 0)
{
@@ -520,7 +520,7 @@
free(tmp);
/* if we got an entry, and if the entry exits in this service */
- if (entry && initng_active_db_is(entry, s))
+ if (entry && is(entry, s))
{
/* Handle differently with different types */
switch (entry->opt_type)
@@ -528,17 +528,16 @@
/* if it is a string, just strcpy in it */
case STRING:
{
- strcpy(set,
- initng_active_db_get_string(entry, s));
+ strcpy(set, get_string(entry, s));
goto go_forward;
}
case STRINGS:
{
const char *tmp2 = NULL;
+ s_data *itterator = NULL;
while ((tmp2 =
- initng_active_db_get_next_string(entry, s,
- tmp2)))
+ get_next_string(entry, s, &itterator)))
{
strcat(set, tmp2);
strcat(set, " ");
@@ -549,8 +548,7 @@
/* if it is an integer, sprintf in it */
case INT:
{
- sprintf(set, "%i",
- initng_active_db_get_int(entry, s));
+ sprintf(set, "%i", get_int(entry, s));
goto go_forward;
}
default:
Modified: initng/trunk/src/initng_fd.c
==============================================================================
--- initng/trunk/src/initng_fd.c (original)
+++ initng/trunk/src/initng_fd.c Tue Apr 4 04:04:13 2006
@@ -283,11 +283,11 @@
continue;
/*D_("adding fd #%i, from an call_db.\n", current->c.fdh->fds); */
- if(currentC->c.fdh->what & FDW_READ)
+ if (currentC->c.fdh->what & FDW_READ)
FD_SET(currentC->c.fdh->fds, &readset);
- if(currentC->c.fdh->what & FDW_WRITE)
+ if (currentC->c.fdh->what & FDW_WRITE)
FD_SET(currentC->c.fdh->fds, &writeset);
- if(currentC->c.fdh->what & FDW_ERROR)
+ if (currentC->c.fdh->what & FDW_ERROR)
FD_SET(currentC->c.fdh->fds, &errset);
added++;
}
@@ -361,19 +361,19 @@
continue;
if (!currentC->c.fdh->call_module)
continue;
-
- if(FD_ISSET(currentC->c.fdh->fds, &readset))
+
+ if (FD_ISSET(currentC->c.fdh->fds, &readset))
what |= FDW_READ;
- if(FD_ISSET(currentC->c.fdh->fds, &writeset))
+ if (FD_ISSET(currentC->c.fdh->fds, &writeset))
what |= FDW_WRITE;
- if(FD_ISSET(currentC->c.fdh->fds, &errset))
+ if (FD_ISSET(currentC->c.fdh->fds, &errset))
what |= FDW_ERROR;
if (what == 0)
continue;
- D_("Calling plugin handler for fd #%i, what=%i\n",
+ D_("Calling plugin handler for fd #%i, what=%i\n",
currentC->c.fdh->fds, what);
(*currentC->c.fdh->call_module) (currentC->c.fdh, what);
D_("Call handler returned.\n");
Modified: initng/trunk/src/initng_global.c
==============================================================================
--- initng/trunk/src/initng_global.c (original)
+++ initng/trunk/src/initng_global.c Tue Apr 4 04:04:13 2006
@@ -78,7 +78,7 @@
/*
* initialize global data storage
*/
- INIT_LIST_HEAD(&g.data.list);
+ DATA_HEAD_INIT(&g.data);
/*
* initialize all databases, next and prev have to point to own struct
@@ -230,7 +230,7 @@
initng_command_free_all(); /* clean command_db */
/* free dynamic global variables */
- global_remove_all();
+ dfree_all(&g);
/* free runlevel name string */
if (g.runlevel)
Modified: initng/trunk/src/initng_global.h
==============================================================================
--- initng/trunk/src/initng_global.h (original)
+++ initng/trunk/src/initng_global.h Tue Apr 4 04:04:13 2006
@@ -56,9 +56,9 @@
s_entry option_db;
s_command command_db;
stype_h stypes;
-
+
/* global options */
- s_data data;
+ data_head data;
/* all hooks to hook at */
s_call ASTATUS_CHANGE; /* Calls as soon as the ASTATUS changes */
@@ -74,8 +74,8 @@
s_call COMPENSATE_TIME; /* Called when initng detects a system time change */
s_call ERR_MSG; /* Called when an error message is sent, so all output plug-ins can show it */
s_call LAUNCH; /* Called when a process are getting launched */
- s_call DUMP_ACTIVE_DB; /* Asks for a plugin willing to dump the acytive_db */
- s_call RELOAD_ACTIVE_DB; /* Asks for a plugin willing to reload the active_db from a dump */
+ s_call DUMP_ACTIVE_DB; /* Asks for a plugin willing to dump the acytive_db */
+ s_call RELOAD_ACTIVE_DB; /* Asks for a plugin willing to reload the active_db from a dump */
s_call DEP_ON; /* Called when a function tries to find out a service dependency */
/* new ones */
Modified: initng/trunk/src/initng_handler.c
==============================================================================
--- initng/trunk/src/initng_handler.c (original)
+++ initng/trunk/src/initng_handler.c Tue Apr 4 04:04:13 2006
@@ -58,7 +58,7 @@
{
if (IS_STOPPING(current))
{
- if (initng_active_db_is(&RESTARTING, current))
+ if (is(&RESTARTING, current))
return;
}
}
@@ -72,10 +72,10 @@
{
if (IS_DOWN(current))
{
- if (initng_active_db_is(&RESTARTING, current))
+ if (is(&RESTARTING, current))
{
/* remove the restarting flag */
- initng_active_db_remove(&RESTARTING, current);
+ dfree(&RESTARTING, current);
/* start the service */
initng_handler_start_service(current);
@@ -183,7 +183,7 @@
}
/* else, mark the service for restarting and stop it */
- if (initng_active_db_is(&RESTARTING, service_to_start))
+ if (is(&RESTARTING, service_to_start))
{
D_("Cant manually start a service that is restarting.\n");
return (FALSE);
@@ -320,7 +320,7 @@
restart_service) (service_to_restart));
/* else, mark the service for restarting and stop it */
- initng_active_db_set(&RESTARTING, service_to_restart);
+ set(&RESTARTING, service_to_restart);
return (initng_handler_stop_service(service_to_restart));
}
Modified: initng/trunk/src/initng_plugin.h
==============================================================================
--- initng/trunk/src/initng_plugin.h (original)
+++ initng/trunk/src/initng_plugin.h Tue Apr 4 04:04:13 2006
@@ -26,9 +26,9 @@
/* flags for f_module_h.what - correspond to the arguments of select() */
typedef enum
{
- FDW_READ = 1, /* Want notification when data is ready to be read */
- FDW_WRITE = 2, /* when data can be written successfully */
- FDW_ERROR = 4, /* when an exceptional condition occurs */
+ FDW_READ = 1, /* Want notification when data is ready to be read */
+ FDW_WRITE = 2, /* when data can be written successfully */
+ FDW_ERROR = 4, /* when an exceptional condition occurs */
} e_fdw;
typedef struct ft_module_h f_module_h;
Modified: initng/trunk/src/initng_plugin_callers.c
==============================================================================
--- initng/trunk/src/initng_plugin_callers.c (original)
+++ initng/trunk/src/initng_plugin_callers.c Tue Apr 4 04:04:13 2006
@@ -136,7 +136,8 @@
{
if (current->c.reload_active_db)
{
- D_("Calling reload_active_db plugin from %s\n", current->from_file);
+ D_("Calling reload_active_db plugin from %s\n",
+ current->from_file);
retval = (*current->c.reload_active_db) ();
if (retval == TRUE)
{
Modified: initng/trunk/src/initng_service_cache.c
==============================================================================
--- initng/trunk/src/initng_service_cache.c (original)
+++ initng/trunk/src/initng_service_cache.c Tue Apr 4 04:04:13 2006
@@ -91,10 +91,10 @@
new_serv->name = name;
/* initialize the data structure */
- INIT_LIST_HEAD(&(new_serv->data.list));
+ DATA_HEAD_INIT(&new_serv->data);
/* copy over all strings */
- d_copy_all(&s->data.list, &new_serv->data.list);
+ d_copy_all(&s->data, &new_serv->data);
/* we must clear pointers, otherwise this service
* will not be added to list
@@ -125,7 +125,7 @@
new_s->type = type;
/* initialize the data list struct */
- INIT_LIST_HEAD(&(new_s->data.list));
+ DATA_HEAD_INIT(&new_s->data);
return (new_s);
}
@@ -270,7 +270,10 @@
while_service_cache(current)
{
if (current->father == s)
+ {
current->father = NULL;
+ current->data.res = NULL;
+ }
}
}
@@ -293,8 +296,8 @@
initng_service_cache_clear_father_pointer_from(to_free);
/* free all data & strings in service */
- d_remove_all(&to_free->data.list);
- INIT_LIST_HEAD(&(to_free->data.list));
+ dfree_all(to_free);
+ DATA_HEAD_INIT(&to_free->data);
/* free father_name */
if (to_free->father_name)
@@ -344,104 +347,12 @@
/* check */
if (service->father)
+ {
+ /* Put service data collection to be resursive to fathers data */
+ service->data.res = &service->father->data;
return (TRUE);
+ }
/* else fail */
return (FALSE);
}
-
-/*
- * DATA WRAPPERS BELOW:
- *
- * These are wrappers, that cant be made macros in initng_service_cache.h
- * wraps to initng_struct_data.c types.
- *
- *
- */
-
-/*
- * service_db_get_string(), look in the service_h->data entry, but also
- * checks fathers->data, that will also apply for this service.
- */
-const char *initng_service_cache_get_string_var(s_entry * type,
- const char *vn,
- service_cache_h * s)
-{
- const char *tmp = NULL;
-
- assert(type);
- assert(s);
-
- /* try to find in local data */
- if ((tmp = d_get_string_var(type, vn, &s->data.list)))
- return (tmp);
-
- /* look for data in my parent */
- if (initng_service_cache_find_father(s) && s->father)
- if ((tmp = initng_service_cache_get_string_var(type, vn, s->father)))
- return (tmp);
-
- return (NULL);
-}
-
-
-/*
- * service_db_get_int(), look in the service_h->data entry, but also
- * checks fathers->data, that will also apply for this service.
- */
-int initng_service_cache_get_int_var(s_entry * type, const char *vn,
- service_cache_h * s)
-{
- assert(type);
- assert(s);
- /* try to find in local data */
- if (d_is_var(type, vn, &s->data.list))
- return (d_get_int_var(type, vn, &s->data.list));
- /* look for data in my parent */
- if (initng_service_cache_find_father(s) && s->father)
- return (initng_service_cache_get_int_var(type, vn, s->father));
- return (0);
-}
-
-/*
- * service_db_get_next_string(), look in the service_h->data entry, but also
- * checks fathers->data, that will also apply for this service.
- */
-const char *initng_service_cache_get_next_string_var(s_entry * type,
- const char *vn,
- service_cache_h * s,
- const char *last)
-{
- const char *tmp = NULL;
-
- assert(type);
- assert(s);
- /* try to find in local data */
- if ((tmp = d_get_next_string_var(type, vn, &s->data.list, last)))
- return (tmp);
- /* look for data in my parent */
- if (initng_service_cache_find_father(s) && s->father)
- if ((tmp =
- initng_service_cache_get_next_string_var(type, vn, s->father,
- last)))
- return (tmp);
- return (NULL);
-}
-
-/*
- * service_db_is(), look in the service_h->data entry, but also
- * checks fathers->data, that will also apply for this service.
- */
-int initng_service_cache_is_var(s_entry * type, const char *vn,
- service_cache_h * s)
-{
- assert(type);
- assert(s);
- if (d_is_var(type, vn, &s->data.list))
- return (TRUE);
- /* look for data in my parent */
- if (initng_service_cache_find_father(s) && s->father)
- if (initng_service_cache_is_var(type, vn, s->father))
- return (TRUE);
- return (FALSE);
-}
Modified: initng/trunk/src/initng_service_cache.h
==============================================================================
--- initng/trunk/src/initng_service_cache.h (original)
+++ initng/trunk/src/initng_service_cache.h Tue Apr 4 04:04:13 2006
@@ -32,7 +32,7 @@
stype_h *type;
/* list container, to store data */
- s_data data;
+ data_head data;
/* father/relative data */
char *father_name;
@@ -65,42 +65,6 @@
/* standard wrappers using service */
#define initng_service_cache_get_next(t,s,l) d_get_next(t, &(s)->data.list, l)
-/* statics */
-#define initng_service_cache_is(t,s) initng_service_cache_is_var(t,NULL,s)
-#define initng_service_cache_get_string(t,s) initng_service_cache_get_string_var(t, NULL, s)
-#define initng_service_cache_get_int(t,s) initng_service_cache_get_int_var(t, NULL, s)
-#define initng_service_cache_get_next_string(t,s,l) initng_service_cache_get_next_string_var(t,NULL,s,l)
-
-#define initng_service_cache_set_string(type, from_service, string) d_set_string(type, &from_service->data.list, string)
-#define inting_service_cache_set_another_string(type, from_service, string) d_set_another_string(type, &from_service->data.list, string)
-#define initng_service_cache_set_int(type, from_service, value) d_set_int(type, &from_service->data.list, value)
-#define initng_service_cache_set(type, from_service) d_set(type, &from_service->data.list)
-#define initng_service_cache_remove(type, from_service) d_remove(type, &from_service->data.list)
-
-/* variable */
-int initng_service_cache_is_var(s_entry * type, const char *vn,
- service_cache_h * s);
-const char *initng_service_cache_get_string_var(s_entry * type,
- const char *vn,
- service_cache_h * s);
-int initng_service_cache_get_int_var(s_entry * type, const char *vn,
- service_cache_h * s);
-const char *initng_service_cache_get_next_string_var(s_entry * type,
- const char *vn,
- service_cache_h * s,
- const char *last);
-
-#define initng_service_cache_set_string_var(type, vn, from_service, string) d_set_string_var(type, vn, &from_service->data.list, string)
-#define initng_service_cache_set_another_string_var(type, vn, from_service, string) d_set_another_string_var(type, vn, &from_service->data.list, string)
-#define initng_service_cache_set_int_var(type, vn, from_service, value) d_set_int_var(type, vn, &from_service->data.list, value)
-#define initng_service_cache_set_var(type, vn, from_service) d_set_var(type, vn, &from_service->data.list)
-#define initng_service_cache_remove_var(type, vn, from_service) d_remove_var(type, vn, &from_service->data.list)
-
-
-/* global */
-#define initng_service_cache_remove_all(from_service) d_remove_all(&from_service->data.list)
-#define initng_service_cache_count_type(type, from_service) d_count_type(type, &from_service->data.list)
-
/* service_list walker */
#define while_service_cache(current) list_for_each_entry_prev(current, &g.service_cache.list, list)
#define while_service_cache_safe(current, safe) list_for_each_entry_prev_safe(current, safe, &g.service_cache.list, list)
Modified: initng/trunk/src/initng_service_data_types.c
==============================================================================
--- initng/trunk/src/initng_service_data_types.c (original)
+++ initng/trunk/src/initng_service_data_types.c Tue Apr 4 04:04:13 2006
@@ -99,13 +99,13 @@
/* clear the active db for this data */
while_active_db(currentA)
{
- d_remove(ent, ¤tA->data.list);
+ dfree(ent, currentA);
}
/* clear the file cache from this data */
while_service_cache(currentS)
{
- d_remove(ent, ¤tS->data.list);
+ dfree(ent, currentS);
}
/* remove it from the list */
Modified: initng/trunk/src/initng_service_data_types.h
==============================================================================
--- initng/trunk/src/initng_service_data_types.h (original)
+++ initng/trunk/src/initng_service_data_types.h Tue Apr 4 04:04:13 2006
@@ -27,14 +27,14 @@
typedef enum
{
- U_D_T = 0, /* UnDefinedType, unknown data type */
- STRING = 1, /* Entry shud contain a string, when set again, the old string is owerwritten */
- STRINGS = 2, /* On every add, a new string with same name is added */
- SET = 3, /* A Bool, Enable or Disable */
- INT = 6, /* An value set in it */
- ALIAS = 7, /* Set this datatype when s_entry->alias is filled */
- TIME_T = 8, /* Contains an time entry */
-
+ U_D_T = 0, /* UnDefinedType, unknown data type */
+ STRING = 1, /* Entry shud contain a string, when set again, the old string is owerwritten */
+ STRINGS = 2, /* On every add, a new string with same name is added */
+ SET = 3, /* A Bool, Enable or Disable */
+ INT = 6, /* An value set in it */
+ ALIAS = 7, /* Set this datatype when s_entry->alias is filled */
+ TIME_T = 8, /* Contains an time entry */
+
/*
* This works works like abow, but you can attach variable names to it,
* like # exec start = /bin/test; and # env TEST = "hello";
@@ -50,11 +50,11 @@
struct ss_entry
{
/* set in statically */
- const char *opt_name; /* The option name in a string */
- e_dt opt_type; /* The variable type, the type of content, see abow */
- stype_h *ot; /* Only used if you want to bound the option, to a special service type */
- const char *opt_desc; /* Short description, shown by ngc -O */
- s_entry *alias; /* You might point this to another s_entry, with another option_name, to get an alias */
+ const char *opt_name; /* The option name in a string */
+ e_dt opt_type; /* The variable type, the type of content, see abow */
+ stype_h *ot; /* Only used if you want to bound the option, to a special service type */
+ const char *opt_desc; /* Short description, shown by ngc -O */
+ s_entry *alias; /* You might point this to another s_entry, with another option_name, to get an alias */
/* this should not be set static */
int opt_name_len;
Modified: initng/trunk/src/initng_struct_data.c
==============================================================================
--- initng/trunk/src/initng_struct_data.c (original)
+++ initng/trunk/src/initng_struct_data.c Tue Apr 4 04:04:13 2006
@@ -32,7 +32,7 @@
#undef D_
#define D_(fmt, ...)
-static void d_free(s_data * current);
+static void d_dfree(s_data * current);
/* gives an error message and return if type is not set */
#define RETURN_TYPE_CHECK(ret) \
@@ -51,172 +51,137 @@
/* check if vn exists, that its correct */
#define VN_MATCH(vnc, vnt) \
- (!vnc || (vnt && strcasecmp(vnc, vnt)==0))
+ (!vnc || !vnt || strcasecmp(vnc, vnt)==0)
#define IT(x) (type->opt_type == x || type->opt_type == (x + 50))
-s_data *d_get_next(s_entry * type, struct list_head *address,
- s_data * current)
-{
- s_data *last = current;
-
- assert(address);
-
- RETURN_TYPE_CHECK(NULL);
-
- ALIAS_WALK;
-
- /* walk through all entries, on address */
- list_for_each_entry_prev(current, address, list)
- {
- /* make sure there is really a new entry */
- if (last == current)
- continue;
- /* if this type is right, return string */
- if (current->type == type)
- return (current);
- }
- return (NULL);
-}
-
-const char *d_get_string_var(s_entry * type, const char *vn,
- struct list_head *address)
+/*
+ * This function will return a s_data pointer, matching type, vn
+ * by the adress struct list.
+ */
+s_data *d_get_next_var(s_entry * type, const char *vn, data_head * head,
+ s_data * last)
{
- s_data *current = NULL;
-
- assert(address);
+ assert(head);
+ struct list_head *place;
+ s_data *current;
RETURN_TYPE_CHECK(NULL);
ALIAS_WALK;
+ /*
+ * There is a problem, functions run get_next_var, and want all variables, not just
+ * the onse with a special vn, so searching for variables with an vn, shud be possible
+ * without setting an vn to search for
+ */
+#ifdef HURT_ME
+ /* Check that vn is sent, when needed */
if (!vn && type->opt_type >= 50)
{
- F_("The vn variable is missing for a type %i %s!\n", type->opt_type,
- type->opt_name);
+ F_("The vn variable is missing for a type %i (%s): %s!\n",
+ type->opt_type, type->opt_name);
return (NULL);
}
- if (!IT(STRING))
+ /* check that vn is not set, when not needed */
+ if (vn && type->opt_type < 50)
{
- F_("Can only fetch a type, that is a STRING\n");
+ F_("The vn %s is set, but not needed for type %i, %s\n", vn,
+ type->opt_type, type->opt_name);
return (NULL);
}
+#endif
- /* walk through all entries, on address */
- list_for_each_entry(current, address, list)
+ /* put place on the initial */
+ place = head->head.list.prev;
+
+ /* as long as we dont stand on the header */
+ while (place != &head->head.list)
{
- /* if this type is right, return string */
- if (current->type == type && current->t.s
- && VN_MATCH(current->vn, vn))
+ /* get the entry */
+ current = list_entry(place, s_data, list);
+
+ /* if last still set, fast forward */
+ if (last && current != last)
{
- D_("got %s\n", current->t.s);
- return (current->t.s);
+ place = place->prev;
+ continue;
}
- }
-
- /* did not get any match */
- D_("String type %s doesn't exist.\n", type->opt_name);
- return (NULL);
-}
-int d_get_int_var(s_entry * type, const char *vn, struct list_head *d)
-{
- s_data *current = NULL;
-
- assert(d);
-
- RETURN_TYPE_CHECK(0);
+ /* if this is the last entry */
+ if (last == current)
+ {
+ last = NULL;
+ place = place->prev;
+ continue;
+ }
- ALIAS_WALK;
+ /* Make sure the string variable name matches if set */
+ if (current->type == type && VN_MATCH(current->vn, vn))
+ {
+ return (current);
+ }
- if (!vn && type->opt_type >= 50)
- {
- F_("The vn variable is missing for a type %i %s!\n", type->opt_type,
- type->opt_name);
- return (0);
+ /* try next */
+ place = place->prev;
}
- if (!IT(INT))
- {
- F_("Can only fetch a type, that is a INT!\n");
- return (0);
- }
- /* walk through all entries on address */
- list_for_each_entry(current, d, list)
+ /* if there is any resursive next to check, do that. */
+ if (head->res)
{
- /* if this type is right, return int */
- if (current->type == type && current->t.i
- && VN_MATCH(current->vn, vn))
- return (current->t.i);
+ return (d_get_next_var(type, vn, head->res, last));
}
- /* did not get any match */
- D_("Int value, type %s doesn't exist in db.\n", type->opt_name);
- return (0);
+ /* no luck */
+ return (NULL);
}
-
-const char *d_get_next_string_var(s_entry * type, const char *vn,
- struct list_head *d, const char *last)
+/* returns a string pointer */
+inline const char *d_get_string_var(s_entry * type, const char *vn,
+ data_head * head)
{
- s_data *current = NULL;
+ s_data *current = d_get_next_var(type, vn, head, NULL);
- assert(d);
+ return (current ? current->t.s : NULL);
+}
- RETURN_TYPE_CHECK(NULL);
- ALIAS_WALK;
+/* returns an int */
+inline int d_get_int_var(s_entry * type, const char *vn, data_head * d)
+{
+ s_data *current = d_get_next_var(type, vn, d, NULL);
- if (!vn && type->opt_type >= 50)
- {
- F_("The vn variable is missing!\n");
- return (NULL);
- }
+ return (current ? current->t.i : 0);
+}
- if (!IT(STRINGS))
- {
- F_("Can only fetch a type, that is a STRINGS!\n");
- return (NULL);
- }
- /* walk through all in d, will be but into current */
- list_for_each_entry_prev(current, d, list)
- {
- /* if the returned type is not that type we are looking for, continue */
- if (current->type != type)
- continue;
+inline const char *d_get_next_string_var(s_entry * type, const char *vn,
+ data_head * d, s_data ** cur)
+{
+ /* Temporary store string pointer here */
+ const char *to_ret;
- /* check that variable name if any matches */
- if (!VN_MATCH(current->vn, vn))
- continue;
+ /* find next var */
+ s_data *current = d_get_next_var(type, vn, d, *cur);
- if (current->t.s == NULL)
- return (NULL);
+ /* Get the string path out of it */
+ to_ret = current ? current->t.s : NULL;
- /* if this is the one, we start looking after, reset last, and continue */
- if (last)
- {
- if (current->t.s == last)
- {
- last = NULL;
- }
- continue;
- }
+ /* update to next */
+ *cur = current;
- /* if this is last, return next string */
- return ((const char *) current->t.s);
- }
- /* no match */
- return (NULL);
+ /* return string */
+ return (to_ret);
}
+
+
/* this has to be only one of */
-void d_set_string_var(s_entry * type, char *vn, struct list_head *d,
- char *string)
+void d_set_string_var(s_entry * type, char *vn, data_head * d, char *string)
{
s_data *current = NULL;
@@ -247,15 +212,12 @@
}
/* check the db, for an current entry to overwrite */
- list_for_each_entry(current, d, list)
+ if ((current = d_get_next_var(type, vn, d, NULL)))
{
- if (current->type == type && VN_MATCH(current->vn, vn))
- {
- if (current->t.s)
- free(current->t.s);
- current->t.s = string;
- return;
- }
+ if (current->t.s)
+ free(current->t.s);
+ current->t.s = string;
+ return;
}
current = (s_data *) i_calloc(1, sizeof(s_data));
@@ -264,13 +226,14 @@
current->vn = vn;
/* add this one */
- list_add(&(current->list), d);
+ list_add(&(current->list), &d->head.list);
}
+
/* this is a function to add a string, that it can exist many of */
-void d_set_another_string_var(s_entry * type, char *vn, struct list_head *d,
+void d_set_another_string_var(s_entry * type, char *vn, data_head * d,
char *string)
{
s_data *current = NULL;
@@ -304,11 +267,11 @@
current->vn = vn;
/* add this one */
- list_add(&(current->list), d);
+ list_add(&(current->list), &d->head.list);
}
/* this has to be only one of */
-void d_set_int_var(s_entry * type, char *vn, struct list_head *d, int value)
+void d_set_int_var(s_entry * type, char *vn, data_head * d, int value)
{
s_data *current = NULL;
@@ -337,75 +300,55 @@
}
/* check the db, for an current entry to overwrite */
- list_for_each_entry(current, d, list)
+ if ((current = d_get_next_var(type, vn, d, NULL)))
{
- if (current->type == type && VN_MATCH(current->vn, vn))
- {
- current->t.i = value;
- return;
- }
+ current->t.i = value;
+ return;
}
+
+ /* else create a new one */
current = (s_data *) i_calloc(1, sizeof(s_data));
current->type = type;
current->t.i = value;
current->vn = vn;
/* add this one */
- list_add(&(current->list), d);
+ list_add(&(current->list), &d->head.list);
}
-/* Walk through and count */
-int d_count_type(s_entry * type, struct list_head *d)
-{
- s_data *current = NULL;
- int count = 0;
-
- /* walk through all entries on address */
- list_for_each_entry(current, d, list)
- {
- if (!type || current->type == type)
- count++;
- }
-
- return (count);
-}
-
/*
* d_is can be used to check any type, if its in the db,
* or just to check unset and set types.
*/
-int d_is_var(s_entry * type, const char *vn, struct list_head *d)
+inline int d_is_var(s_entry * type, const char *vn, data_head * d)
{
- s_data *current = NULL;
+ s_data *current = d_get_next_var(type, vn, d, NULL);
- assert(d);
+ return (current ? TRUE : FALSE);
+}
- RETURN_TYPE_CHECK(FALSE);
- ALIAS_WALK;
- if (!vn && type->opt_type >= 50)
- {
- F_("The vn variable is missing for a type %i %s!\n", type->opt_type,
- type->opt_name);
- return (FALSE);
- }
+/* Walk through and count */
+int d_count_type(s_entry * type, data_head * d)
+{
+ s_data *current = NULL;
+ int count = 0;
/* walk through all entries on address */
- list_for_each_entry(current, d, list)
+ list_for_each_entry(current, &d->head.list, list)
{
- if (current->type == type && VN_MATCH(current->vn, vn))
- {
- return (TRUE);
- }
+ if (!type || current->type == type)
+ count++;
}
- return (FALSE);
+ return (count);
}
-void d_set_var(s_entry * type, char *vn, struct list_head *d)
+
+void d_set_var(s_entry * type, char *vn, data_head * d)
{
s_data *current = NULL;
@@ -433,9 +376,8 @@
}
/* check if its set already */
- if (IT(SET))
- if (d_is_var(type, vn, d))
- return;
+ if (d_is_var(type, vn, d))
+ return;
/* allocate the entry */
current = (s_data *) i_calloc(1, sizeof(s_data));
@@ -443,13 +385,14 @@
current->vn = vn;
/* add this one */
- list_add(&(current->list), d);
+ list_add(&(current->list), &d->head.list);
}
+
/*
* A function to nicely free the s_data content.
*/
-static void d_free(s_data * current)
+static void d_dfree(s_data * current)
{
assert(current);
assert(current->type);
@@ -478,9 +421,11 @@
free(current);
}
-void d_remove_var(s_entry * type, const char *vn, struct list_head *d)
+
+void d_dfree_var(s_entry * type, const char *vn, data_head * d)
{
- s_data *current, *s = NULL;
+ s_data *current;
+ s_data *s = NULL;
assert(d);
assert(type);
@@ -491,64 +436,45 @@
return;
}
- ALIAS_WALK;
-
- /* walk through all entries on address */
- list_for_each_entry_safe(current, s, d, list)
+ while ((current = d_get_next_var(type, vn, d, s)))
{
- /* if this is not the type, continue */
-
- if (current->type != type)
- continue;
-
- /* if a variable name is not specified */
- if (!vn)
- {
- D_("vn not set, freeing all.\n");
- list_del(¤t->list);
- d_free(current);
- current = NULL;
- continue;
- }
-
- /* or if variable name matches */
- if (VN_MATCH(current->vn, vn))
- {
- F_("vn matches, freeing\n");
- list_del(¤t->list);
- d_free(current);
- current = NULL;
- continue;
- }
+ s = current;
+ d_dfree(current);
}
}
-/* walk through and kill all strings */
-void d_remove_all(struct list_head *d)
+
+
+void d_dfree_all(data_head * d)
{
- s_data *current, *s = NULL;
+ s_data *current = NULL;
+ s_data *s = NULL;
assert(d);
/* walk through all entries on address */
- list_for_each_entry_safe(current, s, d, list)
+ list_for_each_entry_safe(current, s, &d->head.list, list)
{
/* walk, and remove all */
list_del(¤t->list);
- d_free(current);
+ d_dfree(current);
current = NULL;
}
+
+ /* make sure its cleared */
+ DATA_HEAD_INIT(d);
}
+
/*
* Walk the db, copy all strings in list from to to.
*/
-void d_copy_all(struct list_head *from, struct list_head *to)
+void d_copy_all(data_head * from, data_head * to)
{
s_data *tmp = NULL;
s_data *current = NULL;
- list_for_each_entry(current, from, list)
+ list_for_each_entry(current, &from->head.list, list)
{
/* make sure type is set
TODO, should this be an assert(current->type) ??? */
@@ -582,6 +508,6 @@
tmp->vn = NULL;
/* add to list */
- list_add(&tmp->list, to);
+ list_add(&tmp->list, &to->head.list);
}
}
Modified: initng/trunk/src/initng_struct_data.h
==============================================================================
--- initng/trunk/src/initng_struct_data.h (original)
+++ initng/trunk/src/initng_struct_data.h Tue Apr 4 04:04:13 2006
@@ -26,17 +26,12 @@
typedef struct ss_data s_data;
+
/*
* This is the data struct == an initng variable, set to an service.
*/
struct ss_data
{
- /* the type of the data */
- s_entry *type;
-
- /* if it is a dynamic variable name, put name here */
- char *vn;
-
/* and the data that it contains */
union
{
@@ -51,49 +46,143 @@
void *p;
} t;
+ /* the type of the data */
+ s_entry *type;
+
+ /* if it is a dynamic variable name, put name here */
+ char *vn;
+
+
struct list_head list;
};
-#define d_is(t,d) d_is_var(t,NULL,d)
-int d_is_var(s_entry * type, const char *vn, struct list_head *d);
+typedef struct s_data_head data_head;
+
+struct s_data_head
+{
+ s_data head; /* This is the header */
+ data_head *res; /* When no data is found, go look in this s_data */
+
+};
+
+#define DATA_HEAD_INIT(point) { INIT_LIST_HEAD(&(point)->head.list); (point)->res=NULL; }
-#define d_get_int(t,d) d_get_int_var(t,NULL,d)
-int d_get_int_var(s_entry * type, const char *vn, struct list_head *d);
+/* data walkers */
+s_data *d_get_next_var(s_entry * type, const char *vn, data_head * head,
+ s_data * last);
+#define d_get_next(type, head, last) d_get_next_var(type, NULL, head, last)
+#define get_next_var(type, vn, head, last) d_get_next_var(type, vn, &(head)->data, last)
+#define get_next(type, head, last) get_next_var(type, NULL, head, last)
+#define while_data(current, d) list_for_each_entry_prev(current, d, list)
+#define while_data_safe(current, safe, d) list_for_each_entry_prev_safe(current, safe, d, list)
-#define d_get_string(t,d) d_get_string_var(t,NULL,d)
-const char *d_get_string_var(s_entry * type, const char *vn,
- struct list_head *d);
+/*
+ * d_is()
+ * Returns true if a data by that type exists.
+ */
+int d_is_var(s_entry * type, const char *vn, data_head * d);
-#define d_get_next_string(t,d,l) d_get_next_string_var(t,NULL,d,l)
-const char *d_get_next_string_var(s_entry * type, const char *vn,
- struct list_head *d, const char *last);
+#define is_var(type, vn, point) d_is_var(type, vn, &(point)->data)
+#define is(type, point) is_var(type, NULL, point)
+
+/*
+ * d_set()
+ * Sets an bool value.
+ */
+void d_set_var(s_entry * type, char *vn, data_head * d);
+
+#define set_var(type, vn, point) d_set_var(type, vn, &(point)->data)
+#define set(type, point) set_var(type, NULL, point)
-#define d_set(t,d) d_set_var(t, NULL, d)
-void d_set_var(s_entry * type, char *vn, struct list_head *d);
-#define d_set_int(t,d,v) d_set_int_var(t,NULL,d,v)
-void d_set_int_var(s_entry * type, char *vn, struct list_head *d, int value);
+/*
+ * d_get_int()
+ * Gets an integear, with matching type, or 0 if not found.
+ */
+int d_get_int_var(s_entry * type, const char *vn, data_head * d);
-#define d_set_string(t,d,s) d_set_string_var(t,NULL,d,s)
-void d_set_string_var(s_entry * type, char *vn, struct list_head *d,
- char *string);
+#define get_int_var(type, vn, point) d_get_int_var(type, vn, &(point)->data)
+#define get_int(type, point) get_int_var(type, NULL, point)
-#define d_set_another_string(t,d,s) d_set_another_string_var(t,NULL,d,s)
-void d_set_another_string_var(s_entry * type, char *vn, struct list_head *d,
+/*
+ * set_int()
+ * Sets an int value, on type.
+ */
+void d_set_int_var(s_entry * type, char *vn, data_head * d, int value);
+
+#define set_int_var(type, vn, point, value) d_set_int_var(type, vn, &(point)->data, value)
+#define set_int(type, point, value) set_int_var(type, NULL, point, value)
+
+/*
+ * d_get_string()
+ * Returns a string, if found.
+ */
+const char *d_get_string_var(s_entry * type, const char *vn, data_head * d);
+
+#define get_string_var(type, vn, point) d_get_string_var(type, vn, &(point)->data)
+#define get_string(type, point) get_string_var(type, NULL, point)
+
+/*
+ * d_get_next_string()
+ * If it is an array with lots of strings, step by this
+ * function.
+ */
+const char *d_get_next_string_var(s_entry * type, const char *vn,
+ data_head * d, s_data ** cur);
+#define get_next_string_var(type, vn, point, cur) d_get_next_string_var(type, vn, &(point)->data, cur)
+#define get_next_string(type, point, cur) get_next_string_var(type, NULL, point, cur)
+
+/*
+ * d_set_string()
+ * Sets a string.
+ */
+void d_set_string_var(s_entry * type, char *vn, data_head * d, char *string);
+
+#define set_string_var(type, vn, point, string) d_set_string_var(type, vn, &(point)->data, string)
+#define set_string(type, point, string) set_string_var(type, NULL, point, string)
+
+/*
+ * set_another_string, for use with get_next_string, with entrys containing lots of strings.
+ */
+void d_set_another_string_var(s_entry * type, char *vn, data_head * d,
char *string);
+#define set_another_string_var(type, vn, point, string) d_set_another_string_var(type, vn, &(point)->data, string)
+#define set_another_string(type, point, string) set_another_string_var(type, NULL, point, string)
-int d_count_type(s_entry * type, struct list_head *d);
-#define d_remove(t,d) d_remove_var(t,NULL,d)
-void d_remove_var(s_entry * type, const char *vn, struct list_head *d);
+/*
+ * Count all variables, of a speical type.
+ */
+int d_count_type(s_entry * type, data_head * data);
-void d_remove_all(struct list_head *d);
+#define d_count_all(point) d_count_type(NULL, point)
+#define count_type(type, point) d_count_type(type, &(point)->data)
+#define count_all(point) d_count_all(&(point)->data)
-void d_copy_all(struct list_head *from, struct list_head *to);
-s_data *d_get_next(s_entry * type, struct list_head *address, s_data * prev);
+/*
+ * free var, frees data of this type.
+ */
+void d_dfree_var(s_entry * type, const char *vn, data_head * d);
+
+#define dfree_var(type, vn, point) d_dfree_var(type, vn, &(point)->data)
+#define dfree(type, point) dfree_var(type, NULL, point)
+
+/*
+ * free_all
+ * Free all data in the data_head.
+ */
+void d_dfree_all(data_head * d);
+
+#define dfree_all(point) d_dfree_all(&(point)->data)
+
+/*
+ * copy_all
+ * Copy a full data_head set.
+ */
+void d_copy_all(data_head * from, data_head * to);
+
+#define copy_all(from, to) d_copy_all(&(from)->data, &(to)->data)
-#define while_data(current, d) list_for_each_entry_prev(current, d, list)
-#define while_data_safe(current, safe, d) list_for_each_entry_prev_safe(current, safe, d, list)
#endif
More information about the Initng-svn
mailing list