This is an automated email from the git hooks/post-receive script.

rubund-guest pushed a commit to branch master
in repository osm-tile-server.

commit c315736d786df84a27d5fcac3c9a1f7640edaa21
Author: Ruben Undheim <ruben.undh...@gmail.com>
Date:   Thu Sep 3 20:44:46 2015 +0200

    Getting database name from file
---
 src/osm-tile-server-import.c | 38 +++++++++++++++++++++++++++++++++++---
 1 file changed, 35 insertions(+), 3 deletions(-)

diff --git a/src/osm-tile-server-import.c b/src/osm-tile-server-import.c
index 8a51923..5e3dd85 100644
--- a/src/osm-tile-server-import.c
+++ b/src/osm-tile-server-import.c
@@ -1,13 +1,45 @@
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 
 
+
+char dbname[64];
+
+void parse_settings()
+{
+       char *linebuf = NULL;
+       size_t len;
+       ssize_t read;
+       FILE *infile;
+
+       infile = fopen("/etc/osm-tile-server.conf","r");
+       if (infile == NULL) exit(-1);
+       while((read = getline(&linebuf, &len, infile)) != -1 ) {
+               const char *l = linebuf;
+               if(strncmp("DBNAME=\"",l,8) == 0) {
+                       char *substr = strstr(l+8,"\"");
+                       *substr = 0;
+                       //printf("Read line: %s\n",linebuf+8);
+                       strncpy(dbname,linebuf+8,63);
+                       //printf("%s\n",dbname);
+               }
+       }
+       fclose(infile);
+
+       if(linebuf)
+               free(linebuf);
+}
+
 int main(int argc, char **argv)
 {
        char command[256];
 
-       snprintf(command,255,"osm2pgsql --slim -d $DBNAME --cache-strategy 
sparse -C 100 --hstore -S /usr/share/osm2pgsql/default.style 
/usr/share/osm-tile-server-base/samples/liechtenstein-latest.osm.pbf");
-       printf("Importing to database with this command:\n");
-       printf(" %s\n",command);
+       parse_settings();
+
+       snprintf(command,255,"osm2pgsql --slim -d %s --cache-strategy sparse -C 
100 --hstore -S /usr/share/osm2pgsql/default.style 
/usr/share/osm-tile-server-base/samples/liechtenstein-latest.osm.pbf",dbname);
+       printf("Importing to database with this command:\n\n");
+       printf(" %s\n\n",command);
        //system(command);
 
        return 0;

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-grass/osm-tile-server.git

_______________________________________________
Pkg-grass-devel mailing list
Pkg-grass-devel@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel

Reply via email to