Skip to content
Permalink
Browse files

Many fixes and cleanup.

Started coding for generic config files.
  • Loading branch information...
Jorge Daza Garcia-Blanes
Jorge Daza Garcia-Blanes committed Aug 14, 2006
1 parent c65451d commit 06c55ccb967723efaa0f9d1b016775d713a6cf4e
Showing with 546 additions and 139 deletions.
  1. +6 −5 Makefile
  2. +1 −0 SConstruct
  3. +28 −0 cfgreader.c
  4. +2 −4 drqman/main.c
  5. +0 −111 libdrqueue/common.c
  6. +0 −1 libdrqueue/common.h
  7. +285 −0 libdrqueue/config.c
  8. +68 −0 libdrqueue/config.h
  9. +5 −0 libdrqueue/constants.h
  10. +2 −0 libdrqueue/libdrqueue.h
  11. +74 −0 libdrqueue/list.c
  12. +52 −0 libdrqueue/list.h
  13. +5 −5 master.c
  14. +1 −2 master.h
  15. +8 −0 sample.conf
  16. +8 −9 slave.c
  17. +1 −2 slave.h
@@ -30,9 +30,9 @@ ifeq ($(origin systype),undefined)
machinetype=$(shell uname -m)
endif

CFLAGS = -I. -Ilibdrqueue -g -O2 -Wall
CPPFLAGS = -D_GNU_SOURCE -DCOMM_REPORT
CXXFLAGS = $(CFLAGS) -D__CPLUSPLUS
CFLAGS += -g -O2 -Wall
CPPFLAGS += -D_GNU_SOURCE -DCOMM_REPORT -I. -Ilibdrqueue
CXXFLAGS += $(CFLAGS) -D__CPLUSPLUS

ifeq ($(systype),Linux)
CPPFLAGS += -D__LINUX
@@ -220,10 +220,11 @@ endif
endif

doc:
cxref *.[ch] drqman/*.[ch] -all-comments -xref-all -index-all -R/home/jorge/prog/drqueue -O/home/jorge/prog/drqueue/doc -html32 -D__LINUX
text -d ./doc || mkdir ./doc
cxref *.[ch] libdrqueue/*.[ch] drqman/*.[ch] $(CPPFLAGS) `pkg-config gtk+-2.0 --cflags` -all-comments -xref-all -index-all -html -O./doc

tags:
etags *.[ch] drqman/*.[ch]
etags *.[ch] libdrqueue/*.[ch] drqman/*.[ch]

clean:
rm -fR *.o *.os *.exe *~ libdrqueue.a $(BASE_C_TOOLS) $(BASE_CXX_TOOLS) TAGS tmp/* logs/* db/* contrib/windows/*.exe bin/*.$(systype).$(machinetype)
@@ -45,6 +45,7 @@ jobfinfo = env.Program ('jobfinfo.c', LIBS=['libdrqueue.a'], LIBPATH=['.'])
jobinfo = env.Program ('jobinfo.c', LIBS=['libdrqueue.a'], LIBPATH=['.'])
compinfo = env.Program ('compinfo.c', LIBS=['libdrqueue.a'], LIBPATH=['.'])
requeue = env.Program ('requeue.c', LIBS=['libdrqueue.a'], LIBPATH=['.'])
cfgreader = env.Program ('cfgreader.c', LIBS=['libdrqueue.a'], LIBPATH=['.'])
cjob = env.Program ('cjob.c', LIBS=['libdrqueue.a'], LIBPATH=['.'])
blockhost = env.Program ('blockhost.c', LIBS=['libdrqueue.a'], LIBPATH=['.'])
sendjob = env.Program ('sendjob.cpp', LIBS=['libdrqueue.a'], LIBPATH=['.'])
@@ -0,0 +1,28 @@
//
// Copyright (C) 2001,2002,2003,2004,2005,2006 Jorge Daza Garcia-Blanes
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA
//
//
// $Id$
//

#include "libdrqueue.h"

int main (int argc, char *argv[])
{
config_read ("./sample.conf","config_reader");
}
@@ -35,7 +35,6 @@ GList *icon_list;
static struct info_drqm info;
char conf[PATH_MAX];

#define DRQMAN_CONF_FILE "/etc/drqueue/drqman.conf"

#ifdef __CYGWIN
FILE *file_null;
@@ -48,9 +47,8 @@ int main (int argc, char *argv[]) {

// fprintf (stderr,"drqman pid: %i\n",getpid());

strncpy (conf,DRQMAN_CONF_FILE,PATH_MAX);
config_parse(conf);
set_default_env(); // Config files overrides environment CHANGE (?)
set_default_env(); // Config files overrides environment
config_parse_tool("drqman");

if (!common_environment_check()) {
fprintf (stderr,"Error checking the environment: %s\n",drerrno_str());
@@ -225,115 +225,4 @@ void set_default_env(void) {
}
}

void config_parse (char *cfg) {
FILE *f_conf;
char buffer[BUFFERLEN];
char *token;
char renv[BUFFERLEN], *penv;

if ((f_conf = fopen (cfg,"r")) == NULL) {
fprintf (stderr,"Could not open config file using defaults\n");
return;
}

while ((fgets (buffer,BUFFERLEN-1,f_conf)) != NULL) {
if (buffer[0] == '#') {
continue;
}
token = strtok(buffer,"=\n\r");
if (strcmp(token,"logs") == 0) {
if ((token = strtok (NULL,"=\n\r")) != NULL) {
fprintf (stderr,"Logs on: '%s'\n",token);
snprintf (renv,BUFFERLEN,"DRQUEUE_LOGS=%s",token);
if ((penv = (char*) malloc (strlen (renv)+1)) == NULL) {
fprintf (stderr,"ERROR allocating memory for DRQUEUE_LOGS.\n");
exit (1);
}
strncpy(penv,renv,strlen(renv)+1);
if (putenv (penv) != 0) {
fprintf (stderr,"ERROR seting the environment: '%s'\n",penv);
}
} else {
fprintf (stderr,"Warning parsing config file. No value for logs. Using default.\n");
}
} else if (strcmp(token,"tmp") == 0) {
if ((token = strtok (NULL,"=\n\r")) != NULL) {
fprintf (stderr,"Tmp on: '%s'\n",token);
snprintf (renv,BUFFERLEN,"DRQUEUE_TMP=%s",token);
if ((penv = (char*) malloc (strlen(renv)+1)) == NULL) {
fprintf (stderr,"ERROR allocating memory for DRQUEUE_TMP.\n");
exit (1);
}
strncpy(penv,renv,strlen(renv)+1);
if (putenv (penv) != 0) {
fprintf (stderr,"ERROR seting the environment: '%s'\n",penv);
}
} else {
fprintf (stderr,"Warning parsing config file. No value for tmp. Using default.\n");
}
} else if (strcmp(token,"bin") == 0) {
if ((token = strtok (NULL,"=\n\r")) != NULL) {
fprintf (stderr,"Bin on: '%s'\n",token);
snprintf (renv,BUFFERLEN,"DRQUEUE_BIN=%s",token);
if ((penv = (char*) malloc (strlen(renv)+1)) == NULL) {
fprintf (stderr,"ERROR allocating memory for DRQUEUE_BIN.\n");
exit (1);
}
strncpy(penv,renv,strlen(renv)+1);
if (putenv (penv) != 0) {
fprintf (stderr,"ERROR seting the environment: '%s'\n",penv);
}
} else {
fprintf (stderr,"Warning parsing config file. No value for bin. Using default.\n");
}
} else if (strcmp(token,"etc") == 0) {
if ((token = strtok (NULL,"=\n\r")) != NULL) {
fprintf (stderr,"Etc on: '%s'\n",token);
snprintf (renv,BUFFERLEN,"DRQUEUE_ETC=%s",token);
if ((penv = (char*) malloc (strlen(renv)+1)) == NULL) {
fprintf (stderr,"ERROR allocating memory for DRQUEUE_ETC.\n");
exit (1);
}
strncpy(penv,renv,strlen(renv)+1);
if (putenv (penv) != 0) {
fprintf (stderr,"ERROR seting the environment: '%s'\n",penv);
}
} else {
fprintf (stderr,"Warning parsing config file. No value for etc. Using default.\n");
}
} else if (strcmp(token,"db") == 0) {
if ((token = strtok (NULL,"=\n\r")) != NULL) {
fprintf (stderr,"Db on: '%s'\n",token);
snprintf (renv,BUFFERLEN,"DRQUEUE_DB=%s",token);
if ((penv = (char*) malloc (strlen(renv)+1)) == NULL) {
fprintf (stderr,"ERROR allocating memory for DRQUEUE_DB.\n");
exit (1);
}
strncpy(penv,renv,strlen(renv)+1);
if (putenv (penv) != 0) {
fprintf (stderr,"ERROR seting the environment: '%s'\n",penv);
}
} else {
fprintf (stderr,"Warning parsing config file. No value for db. Using default.\n");
}
} else if (strcmp(token,"pool") == 0) {
if ((token = strtok (NULL,"=\n\r")) != NULL) {
fprintf (stderr,"Pools are: '%s'\n",token);
snprintf (renv,BUFFERLEN,"DRQUEUE_POOL=%s",token);
if ((penv = (char*) malloc (strlen(renv)+1)) == NULL) {
fprintf (stderr,"ERROR allocating memory for DRQUEUE_POOL.\n");
exit (1);
}
strncpy(penv,renv,strlen(renv)+1);
if (putenv (penv) != 0) {
fprintf (stderr,"ERROR seting the environment: '%s'\n",penv);
}
} else {
fprintf (stderr,"Warning parsing config file. No value for pool. Using default.\n");
}
} else {
fprintf (stderr,"ERROR parsing config file. Unknown token: '%s'\n",token);
exit (1);
}
}
}
@@ -46,7 +46,6 @@ int rmdir_check_str (char *path);
int remove_dir (char *dir);
char *time_str (uint32_t nseconds);
void set_default_env(void);
void config_parse (char *cfg);

int common_date_check (void);

Oops, something went wrong.

0 comments on commit 06c55cc

Please sign in to comment.
You can’t perform that action at this time.