From 7c578fa79e8b09b0d4456ca7a5ac9cdb757ddb1a Mon Sep 17 00:00:00 2001 From: losinshi Date: Sun, 17 Sep 2006 20:30:33 +0000 Subject: [PATCH] Default-Dir-Option added git-svn-id: file:///home/jan/tmp/wetterstation/trunk@101 dd492736-c11a-0410-ad51-8c26713eaf7f --- cronjob/chart/chart.conf | 3 ++- cronjob/chart/common.h | 1 + cronjob/chart/config.c | 21 ++++++++++--------- .../{image_file => image_conf}/example.conf | 5 ++++- cronjob/chart/image_file/image_common.h | 1 + cronjob/chart/image_file/image_config.c | 1 + cronjob/chart/image_file/image_file.c | 14 +++++++++++++ cronjob/chart/image_file/testimage.conf | 3 ++- 8 files changed, 36 insertions(+), 13 deletions(-) rename cronjob/chart/{image_file => image_conf}/example.conf (97%) diff --git a/cronjob/chart/chart.conf b/cronjob/chart/chart.conf index a245766..34ce575 100644 --- a/cronjob/chart/chart.conf +++ b/cronjob/chart/chart.conf @@ -1,6 +1,7 @@ #fork yes fork no -image_cfg_location image_file/ +image_cfg_location image_conf/ +dflt_image_location /home/jan/ #image_cfg testimage.conf image_cfg example.conf diff --git a/cronjob/chart/common.h b/cronjob/chart/common.h index dd86ef7..4314898 100644 --- a/cronjob/chart/common.h +++ b/cronjob/chart/common.h @@ -35,6 +35,7 @@ typedef struct config_t { char *pg_user; char *pg_pass; char *image_cfg_location; + char *dflt_image_location; image_cfg_list_ptr image_cfg; int fork; } config; diff --git a/cronjob/chart/config.c b/cronjob/chart/config.c index c5bffa0..2a5877a 100644 --- a/cronjob/chart/config.c +++ b/cronjob/chart/config.c @@ -41,17 +41,18 @@ static int add_image_cfg(const char *, void *); /* Zuordnung zwischen Schlüsselwörtern in der Config, Der Funktion, die diese auswertet * und dem eld in der Options-Struktur */ static const config_keyword dflt_keywords[] = { - /* keyword handler variable address default */ - {"fork", read_yn, &(global_opts.fork), ""}, - {"image_cfg", add_image_cfg, &(global_opts.image_cfg), ""}, - {"image_cfg_location",read_str, &(global_opts.image_cfg_location), DEFAULT_PG_HOST}, + /* keyword handler variable address default */ + {"fork", read_yn, &(global_opts.fork), ""}, + {"image_cfg", add_image_cfg, &(global_opts.image_cfg), ""}, + {"image_cfg_location", read_str, &(global_opts.image_cfg_location), DEFAULT_PG_HOST}, + {"dflt_image_location", read_str, &(global_opts.dflt_image_location), DEFAULT_PG_HOST}, - {"pg_host", read_str, &(global_opts.pg_host), DEFAULT_PG_HOST}, - {"pg_user", read_str, &(global_opts.pg_user), DEFAULT_PG_USER}, - {"pg_pass", read_str, &(global_opts.pg_pass), DEFAULT_PG_PASS}, - {"pg_database", read_str, &(global_opts.pg_database), DEFAULT_PG_DATABASE}, - {"pg_timeout", read_str, &(global_opts.pg_timeout), DEFAULT_PG_TIMEOUT}, - {"", NULL, NULL, ""} + {"pg_host", read_str, &(global_opts.pg_host), DEFAULT_PG_HOST}, + {"pg_user", read_str, &(global_opts.pg_user), DEFAULT_PG_USER}, + {"pg_pass", read_str, &(global_opts.pg_pass), DEFAULT_PG_PASS}, + {"pg_database", read_str, &(global_opts.pg_database), DEFAULT_PG_DATABASE}, + {"pg_timeout", read_str, &(global_opts.pg_timeout), DEFAULT_PG_TIMEOUT}, + {"", NULL, NULL, ""} }; diff --git a/cronjob/chart/image_file/example.conf b/cronjob/chart/image_conf/example.conf similarity index 97% rename from cronjob/chart/image_file/example.conf rename to cronjob/chart/image_conf/example.conf index ba59dbd..303dbcb 100644 --- a/cronjob/chart/image_file/example.conf +++ b/cronjob/chart/image_conf/example.conf @@ -3,7 +3,10 @@ ############################################# # Filename des erzeugten bildes -filename /home/jan/Testbild.png +filename Beispielbild.png + +# Bild im Standart-Verzeichnis speichern +use_dflt_img_dir yes # Ueberschrift des erzeugten bildes headline Mein Wetterbild diff --git a/cronjob/chart/image_file/image_common.h b/cronjob/chart/image_file/image_common.h index 4469c22..ce000d4 100644 --- a/cronjob/chart/image_file/image_common.h +++ b/cronjob/chart/image_file/image_common.h @@ -27,6 +27,7 @@ typedef struct image_cfg { char *x_fmt; int zero_min; int bars; + int dflt_dir; img_color_ptr bg_color; img_color_ptr dia_bg_color; diff --git a/cronjob/chart/image_file/image_config.c b/cronjob/chart/image_file/image_config.c index 46744cd..1fb39ba 100644 --- a/cronjob/chart/image_file/image_config.c +++ b/cronjob/chart/image_file/image_config.c @@ -41,6 +41,7 @@ static int read_fmt_str(const char *, void *); static const config_keyword keywords[] = { /* keyword handler variable address default */ {"filename", read_str, &(img_cfg.file_name), ""}, + {"use_dflt_img_dir", read_yn, &(img_cfg.dflt_dir), DEFAULT_LABEL_SUM}, {"headline", read_str, &(img_cfg.headline), DEFAULT_HEADLINE}, {"table_field", read_str, &(img_cfg.table_field), DEFAULT_TABLE_FIELD}, {"manual_table", read_yn, &(img_cfg.manual_table), DEFAULT_MANUAL_TABLE}, diff --git a/cronjob/chart/image_file/image_file.c b/cronjob/chart/image_file/image_file.c index 6e2a1fc..66d6a85 100644 --- a/cronjob/chart/image_file/image_file.c +++ b/cronjob/chart/image_file/image_file.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include "../definitions.h" @@ -31,6 +32,8 @@ #include "image_config.h" #include "image_draw.h" +#define BUFFSIZE 512 + /* Optionen des Bildes */ image_cfg_t img_cfg; @@ -43,6 +46,8 @@ static int check_file_interval(); /* Handelt ein Bild */ void process_image_cfg(char *image_cfg_file){ + char *buff; + int i; get_image_cfg(image_cfg_file); @@ -60,6 +65,15 @@ void process_image_cfg(char *image_cfg_file){ DEBUGOUT2("ManualTabelle = %d\n", img_cfg.manual_table); DEBUGOUT2("TabellenName = %s\n", img_cfg.table_name); DEBUGOUT1("\n"); + + if(img_cfg.dflt_dir){ + buff = malloc(sizeof(char)*BUFFSIZE); + buff = strncpy(buff, global_opts.dflt_image_location, BUFFSIZE - 1); + i = strlen(buff); + buff = strncat(buff, img_cfg.file_name, BUFFSIZE - i - 1); + img_cfg.file_name = strdup(buff); + free(buff); + } } else { return; } diff --git a/cronjob/chart/image_file/testimage.conf b/cronjob/chart/image_file/testimage.conf index 3c3d15c..1e3e49f 100644 --- a/cronjob/chart/image_file/testimage.conf +++ b/cronjob/chart/image_file/testimage.conf @@ -1,4 +1,5 @@ -filename /home/jan/Testbild.png +filename Testbild.png +use_dflt_img_dir yes headline Temparatur - Innensensor manual_table no manual_table_name auss2_data