mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-03-11 13:24:07 +00:00
clean up formatting
This commit is contained in:
@@ -44,7 +44,8 @@ void nominatim_export(int rank_min, int rank_max, const char *conninfo, const ch
|
|||||||
Oid pg_prepare_params[2];
|
Oid pg_prepare_params[2];
|
||||||
|
|
||||||
conn = PQconnectdb(conninfo);
|
conn = PQconnectdb(conninfo);
|
||||||
if (PQstatus(conn) != CONNECTION_OK) {
|
if (PQstatus(conn) != CONNECTION_OK)
|
||||||
|
{
|
||||||
fprintf(stderr, "Connection to database failed: %s\n", PQerrorMessage(conn));
|
fprintf(stderr, "Connection to database failed: %s\n", PQerrorMessage(conn));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@@ -126,7 +127,7 @@ void nominatim_export(int rank_min, int rank_max, const char *conninfo, const ch
|
|||||||
}
|
}
|
||||||
|
|
||||||
tuples = PQntuples(resPlaces);
|
tuples = PQntuples(resPlaces);
|
||||||
for(i = 0; i < tuples; i++)
|
for (i = 0; i < tuples; i++)
|
||||||
{
|
{
|
||||||
nominatim_exportPlace(PGint32(*((uint32_t *)PQgetvalue(resPlaces, i, 0))), conn, writer, NULL);
|
nominatim_exportPlace(PGint32(*((uint32_t *)PQgetvalue(resPlaces, i, 0))), conn, writer, NULL);
|
||||||
rankTotalDone++;
|
rankTotalDone++;
|
||||||
@@ -324,7 +325,7 @@ void nominatim_exportPlace(uint64_t place_id, PGconn * conn, xmlTextWriterPtr wr
|
|||||||
{
|
{
|
||||||
xmlTextWriterStartElement(writer, BAD_CAST "names");
|
xmlTextWriterStartElement(writer, BAD_CAST "names");
|
||||||
|
|
||||||
for(i = 0; i < PQntuples(resNames); i++)
|
for (i = 0; i < PQntuples(resNames); i++)
|
||||||
{
|
{
|
||||||
xmlTextWriterStartElement(writer, BAD_CAST "name");
|
xmlTextWriterStartElement(writer, BAD_CAST "name");
|
||||||
xmlTextWriterWriteAttribute(writer, BAD_CAST "type", BAD_CAST PQgetvalue(resNames, i, 0));
|
xmlTextWriterWriteAttribute(writer, BAD_CAST "type", BAD_CAST PQgetvalue(resNames, i, 0));
|
||||||
@@ -359,7 +360,7 @@ void nominatim_exportPlace(uint64_t place_id, PGconn * conn, xmlTextWriterPtr wr
|
|||||||
if (PQntuples(resAddress) > 0)
|
if (PQntuples(resAddress) > 0)
|
||||||
{
|
{
|
||||||
xmlTextWriterStartElement(writer, BAD_CAST "address");
|
xmlTextWriterStartElement(writer, BAD_CAST "address");
|
||||||
for(i = 0; i < PQntuples(resAddress); i++)
|
for (i = 0; i < PQntuples(resAddress); i++)
|
||||||
{
|
{
|
||||||
xmlTextWriterStartElement(writer, BAD_CAST getRankLabel(atoi(PQgetvalue(resAddress, i, 5))));
|
xmlTextWriterStartElement(writer, BAD_CAST getRankLabel(atoi(PQgetvalue(resAddress, i, 5))));
|
||||||
xmlTextWriterWriteAttribute(writer, BAD_CAST "rank", BAD_CAST PQgetvalue(resAddress, i, 5));
|
xmlTextWriterWriteAttribute(writer, BAD_CAST "rank", BAD_CAST PQgetvalue(resAddress, i, 5));
|
||||||
@@ -378,7 +379,7 @@ void nominatim_exportPlace(uint64_t place_id, PGconn * conn, xmlTextWriterPtr wr
|
|||||||
{
|
{
|
||||||
xmlTextWriterStartElement(writer, BAD_CAST "tags");
|
xmlTextWriterStartElement(writer, BAD_CAST "tags");
|
||||||
|
|
||||||
for(i = 0; i < PQntuples(resExtraTags); i++)
|
for (i = 0; i < PQntuples(resExtraTags); i++)
|
||||||
{
|
{
|
||||||
xmlTextWriterStartElement(writer, BAD_CAST "tag");
|
xmlTextWriterStartElement(writer, BAD_CAST "tag");
|
||||||
xmlTextWriterWriteAttribute(writer, BAD_CAST "type", BAD_CAST PQgetvalue(resExtraTags, i, 0));
|
xmlTextWriterWriteAttribute(writer, BAD_CAST "type", BAD_CAST PQgetvalue(resExtraTags, i, 0));
|
||||||
@@ -405,7 +406,7 @@ void nominatim_exportPlace(uint64_t place_id, PGconn * conn, xmlTextWriterPtr wr
|
|||||||
|
|
||||||
const char * getRankLabel(int rank)
|
const char * getRankLabel(int rank)
|
||||||
{
|
{
|
||||||
switch(rank)
|
switch (rank)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
case 1:
|
case 1:
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ typedef enum { FILEMODE_NONE, FILEMODE_ADD, FILEMODE_UPDATE, FILEMODE_DELETE } f
|
|||||||
#define MAX_FEATURENAMESTRING 100000
|
#define MAX_FEATURENAMESTRING 100000
|
||||||
#define MAX_FEATUREEXTRATAGSTRING 50000
|
#define MAX_FEATUREEXTRATAGSTRING 50000
|
||||||
|
|
||||||
struct feature_address {
|
struct feature_address
|
||||||
|
{
|
||||||
int place_id;
|
int place_id;
|
||||||
int rankAddress;
|
int rankAddress;
|
||||||
char isAddress[2];
|
char isAddress[2];
|
||||||
@@ -33,12 +34,14 @@ struct feature_address {
|
|||||||
xmlChar * distance;
|
xmlChar * distance;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct feature_tag {
|
struct feature_tag
|
||||||
|
{
|
||||||
xmlChar * type;
|
xmlChar * type;
|
||||||
xmlChar * value;
|
xmlChar * value;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct feature {
|
struct feature
|
||||||
|
{
|
||||||
int placeID;
|
int placeID;
|
||||||
xmlChar * type;
|
xmlChar * type;
|
||||||
xmlChar * id;
|
xmlChar * id;
|
||||||
@@ -381,7 +384,7 @@ void EndElement(xmlTextReaderPtr reader, const xmlChar *name)
|
|||||||
namePos = 0;
|
namePos = 0;
|
||||||
lineTypeLen = 0;
|
lineTypeLen = 0;
|
||||||
lineValueLen = 0;
|
lineValueLen = 0;
|
||||||
for(i = 0; i < featureNameLines; i++)
|
for (i = 0; i < featureNameLines; i++)
|
||||||
{
|
{
|
||||||
lineTypeLen = strlen(BAD_CAST featureName[i].type);
|
lineTypeLen = strlen(BAD_CAST featureName[i].type);
|
||||||
lineValueLen = strlen(BAD_CAST featureName[i].value);
|
lineValueLen = strlen(BAD_CAST featureName[i].value);
|
||||||
@@ -409,7 +412,7 @@ void EndElement(xmlTextReaderPtr reader, const xmlChar *name)
|
|||||||
namePos = 0;
|
namePos = 0;
|
||||||
lineTypeLen = 0;
|
lineTypeLen = 0;
|
||||||
lineValueLen = 0;
|
lineValueLen = 0;
|
||||||
for(i = 0; i < featureExtraTagLines; i++)
|
for (i = 0; i < featureExtraTagLines; i++)
|
||||||
{
|
{
|
||||||
lineTypeLen = strlen(BAD_CAST featureExtraTag[i].type);
|
lineTypeLen = strlen(BAD_CAST featureExtraTag[i].type);
|
||||||
lineValueLen = strlen(BAD_CAST featureExtraTag[i].value);
|
lineValueLen = strlen(BAD_CAST featureExtraTag[i].value);
|
||||||
@@ -445,7 +448,7 @@ void EndElement(xmlTextReaderPtr reader, const xmlChar *name)
|
|||||||
}
|
}
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
|
||||||
for(i = 0; i < featureAddressLines; i++)
|
for (i = 0; i < featureAddressLines; i++)
|
||||||
{
|
{
|
||||||
// insert into place_address
|
// insert into place_address
|
||||||
paramValues[0] = (const char *)place_id;
|
paramValues[0] = (const char *)place_id;
|
||||||
@@ -504,7 +507,7 @@ void EndElement(xmlTextReaderPtr reader, const xmlChar *name)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for(i = 0; i < featureAddressLines; i++)
|
for (i = 0; i < featureAddressLines; i++)
|
||||||
{
|
{
|
||||||
xmlFree(featureAddress[i].type);
|
xmlFree(featureAddress[i].type);
|
||||||
xmlFree(featureAddress[i].id);
|
xmlFree(featureAddress[i].id);
|
||||||
@@ -539,7 +542,7 @@ static void processNode(xmlTextReaderPtr reader)
|
|||||||
name = xmlStrdup(BAD_CAST "--");
|
name = xmlStrdup(BAD_CAST "--");
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(xmlTextReaderNodeType(reader))
|
switch (xmlTextReaderNodeType(reader))
|
||||||
{
|
{
|
||||||
case XML_READER_TYPE_ELEMENT:
|
case XML_READER_TYPE_ELEMENT:
|
||||||
StartElement(reader, name);
|
StartElement(reader, name);
|
||||||
@@ -589,13 +592,13 @@ int nominatim_import(const char *conninfo, const char *partionTagsFilename, cons
|
|||||||
|
|
||||||
char buffer[1024], osmkey[256], osmvalue[256];
|
char buffer[1024], osmkey[256], osmvalue[256];
|
||||||
int fields;
|
int fields;
|
||||||
while(fgets(buffer, sizeof(buffer), partionTagsFile) != NULL)
|
while (fgets(buffer, sizeof(buffer), partionTagsFile) != NULL)
|
||||||
{
|
{
|
||||||
fields = sscanf( buffer, "%23s %63s", osmkey, osmvalue );
|
fields = sscanf( buffer, "%23s %63s", osmkey, osmvalue );
|
||||||
|
|
||||||
if( fields <= 0 ) continue;
|
if ( fields <= 0 ) continue;
|
||||||
|
|
||||||
if( fields != 2 )
|
if ( fields != 2 )
|
||||||
{
|
{
|
||||||
fprintf( stderr, "Error partition file\n");
|
fprintf( stderr, "Error partition file\n");
|
||||||
exit_nicely();
|
exit_nicely();
|
||||||
@@ -716,7 +719,8 @@ int nominatim_import(const char *conninfo, const char *partionTagsFilename, cons
|
|||||||
processNode(reader);
|
processNode(reader);
|
||||||
ret = xmlTextReaderRead(reader);
|
ret = xmlTextReaderRead(reader);
|
||||||
}
|
}
|
||||||
if (ret != 0) {
|
if (ret != 0)
|
||||||
|
{
|
||||||
fprintf(stderr, "%s : failed to parse\n", filename);
|
fprintf(stderr, "%s : failed to parse\n", filename);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,8 @@ void nominatim_index(int rank_min, int rank_max, int num_threads, const char *co
|
|||||||
Oid pg_prepare_params[2];
|
Oid pg_prepare_params[2];
|
||||||
|
|
||||||
conn = PQconnectdb(conninfo);
|
conn = PQconnectdb(conninfo);
|
||||||
if (PQstatus(conn) != CONNECTION_OK) {
|
if (PQstatus(conn) != CONNECTION_OK)
|
||||||
|
{
|
||||||
fprintf(stderr, "Connection to database failed: %s\n", PQerrorMessage(conn));
|
fprintf(stderr, "Connection to database failed: %s\n", PQerrorMessage(conn));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@@ -109,7 +110,8 @@ void nominatim_index(int rank_min, int rank_max, int num_threads, const char *co
|
|||||||
for (i = 0; i < num_threads; i++)
|
for (i = 0; i < num_threads; i++)
|
||||||
{
|
{
|
||||||
thread_data[i].conn = PQconnectdb(conninfo);
|
thread_data[i].conn = PQconnectdb(conninfo);
|
||||||
if (PQstatus(thread_data[i].conn) != CONNECTION_OK) {
|
if (PQstatus(thread_data[i].conn) != CONNECTION_OK)
|
||||||
|
{
|
||||||
fprintf(stderr, "Connection to database failed: %s\n", PQerrorMessage(thread_data[i].conn));
|
fprintf(stderr, "Connection to database failed: %s\n", PQerrorMessage(thread_data[i].conn));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@@ -258,7 +260,7 @@ void nominatim_index(int rank_min, int rank_max, int num_threads, const char *co
|
|||||||
|
|
||||||
// Monitor threads to give user feedback
|
// Monitor threads to give user feedback
|
||||||
sleepcount = 0;
|
sleepcount = 0;
|
||||||
while(count < tuples)
|
while (count < tuples)
|
||||||
{
|
{
|
||||||
usleep(1000);
|
usleep(1000);
|
||||||
|
|
||||||
@@ -312,7 +314,7 @@ void *nominatim_indexThread(void * thread_data_in)
|
|||||||
uint32_t place_id;
|
uint32_t place_id;
|
||||||
time_t updateStartTime;
|
time_t updateStartTime;
|
||||||
|
|
||||||
while(1)
|
while (1)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock( thread_data->count_mutex );
|
pthread_mutex_lock( thread_data->count_mutex );
|
||||||
if (*(thread_data->count) >= thread_data->tuples)
|
if (*(thread_data->count) >= thread_data->tuples)
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
#include <libxml/encoding.h>
|
#include <libxml/encoding.h>
|
||||||
#include <libxml/xmlwriter.h>
|
#include <libxml/xmlwriter.h>
|
||||||
|
|
||||||
struct index_thread_data{
|
struct index_thread_data
|
||||||
|
{
|
||||||
pthread_t thread;
|
pthread_t thread;
|
||||||
PGconn * conn;
|
PGconn * conn;
|
||||||
PGresult * res;
|
PGresult * res;
|
||||||
|
|||||||
@@ -19,7 +19,8 @@
|
|||||||
|
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
|
||||||
struct Input {
|
struct Input
|
||||||
|
{
|
||||||
char *name;
|
char *name;
|
||||||
enum { plainFile, gzipFile, bzip2File } type;
|
enum { plainFile, gzipFile, bzip2File } type;
|
||||||
void *fileHandle;
|
void *fileHandle;
|
||||||
@@ -33,7 +34,8 @@ struct Input {
|
|||||||
|
|
||||||
// tries to re-open the bz stream at the next stream start.
|
// tries to re-open the bz stream at the next stream start.
|
||||||
// returns 0 on success, -1 on failure.
|
// returns 0 on success, -1 on failure.
|
||||||
int bzReOpen(struct Input *ctx, int *error) {
|
int bzReOpen(struct Input *ctx, int *error)
|
||||||
|
{
|
||||||
// for copying out the last unused part of the block which
|
// for copying out the last unused part of the block which
|
||||||
// has an EOS token in it. needed for re-initialising the
|
// has an EOS token in it. needed for re-initialising the
|
||||||
// next stream.
|
// next stream.
|
||||||
@@ -68,7 +70,8 @@ int readFile(void *context, char * buffer, int len)
|
|||||||
if (ctx->eof || (len == 0))
|
if (ctx->eof || (len == 0))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
switch(ctx->type) {
|
switch (ctx->type)
|
||||||
|
{
|
||||||
case plainFile:
|
case plainFile:
|
||||||
l = read(*(int *)f, buffer, len);
|
l = read(*(int *)f, buffer, len);
|
||||||
if (l <= 0) ctx->eof = 1;
|
if (l <= 0) ctx->eof = 1;
|
||||||
@@ -82,9 +85,11 @@ int readFile(void *context, char * buffer, int len)
|
|||||||
|
|
||||||
// error codes BZ_OK and BZ_STREAM_END are both "OK", but the stream
|
// error codes BZ_OK and BZ_STREAM_END are both "OK", but the stream
|
||||||
// end means the reader needs to be reset from the original handle.
|
// end means the reader needs to be reset from the original handle.
|
||||||
if (error != BZ_OK) {
|
if (error != BZ_OK)
|
||||||
|
{
|
||||||
// for stream errors, try re-opening the stream before admitting defeat.
|
// for stream errors, try re-opening the stream before admitting defeat.
|
||||||
if (error != BZ_STREAM_END || bzReOpen(ctx, &error) != 0) {
|
if (error != BZ_STREAM_END || bzReOpen(ctx, &error) != 0)
|
||||||
|
{
|
||||||
l = 0;
|
l = 0;
|
||||||
ctx->eof = 1;
|
ctx->eof = 1;
|
||||||
}
|
}
|
||||||
@@ -95,7 +100,8 @@ int readFile(void *context, char * buffer, int len)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (l < 0) {
|
if (l < 0)
|
||||||
|
{
|
||||||
fprintf(stderr, "File reader received error %d (%d)\n", l, error);
|
fprintf(stderr, "File reader received error %d (%d)\n", l, error);
|
||||||
l = 0;
|
l = 0;
|
||||||
}
|
}
|
||||||
@@ -107,12 +113,14 @@ char inputGetChar(void *context)
|
|||||||
{
|
{
|
||||||
struct Input *ctx = context;
|
struct Input *ctx = context;
|
||||||
|
|
||||||
if (ctx->buf_ptr == ctx->buf_fill) {
|
if (ctx->buf_ptr == ctx->buf_fill)
|
||||||
|
{
|
||||||
ctx->buf_fill = readFile(context, &ctx->buf[0], sizeof(ctx->buf));
|
ctx->buf_fill = readFile(context, &ctx->buf[0], sizeof(ctx->buf));
|
||||||
ctx->buf_ptr = 0;
|
ctx->buf_ptr = 0;
|
||||||
if (ctx->buf_fill == 0)
|
if (ctx->buf_fill == 0)
|
||||||
return 0;
|
return 0;
|
||||||
if (ctx->buf_fill < 0) {
|
if (ctx->buf_fill < 0)
|
||||||
|
{
|
||||||
perror("Error while reading file");
|
perror("Error while reading file");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -138,13 +146,17 @@ void *inputOpen(const char *name)
|
|||||||
|
|
||||||
ctx->name = strdup(name);
|
ctx->name = strdup(name);
|
||||||
|
|
||||||
if (ext && !strcmp(ext, ".gz")) {
|
if (ext && !strcmp(ext, ".gz"))
|
||||||
|
{
|
||||||
ctx->fileHandle = (void *)gzopen(name, "rb");
|
ctx->fileHandle = (void *)gzopen(name, "rb");
|
||||||
ctx->type = gzipFile;
|
ctx->type = gzipFile;
|
||||||
} else if (ext && !strcmp(ext, ".bz2")) {
|
}
|
||||||
|
else if (ext && !strcmp(ext, ".bz2"))
|
||||||
|
{
|
||||||
int error = 0;
|
int error = 0;
|
||||||
ctx->systemHandle = fopen(name, "rb");
|
ctx->systemHandle = fopen(name, "rb");
|
||||||
if (!ctx->systemHandle) {
|
if (!ctx->systemHandle)
|
||||||
|
{
|
||||||
fprintf(stderr, "error while opening file %s\n", name);
|
fprintf(stderr, "error while opening file %s\n", name);
|
||||||
exit(10);
|
exit(10);
|
||||||
}
|
}
|
||||||
@@ -152,18 +164,25 @@ void *inputOpen(const char *name)
|
|||||||
ctx->fileHandle = (void *)BZ2_bzReadOpen(&error, ctx->systemHandle, 0, 0, NULL, 0);
|
ctx->fileHandle = (void *)BZ2_bzReadOpen(&error, ctx->systemHandle, 0, 0, NULL, 0);
|
||||||
ctx->type = bzip2File;
|
ctx->type = bzip2File;
|
||||||
|
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
int *pfd = malloc(sizeof(pfd));
|
int *pfd = malloc(sizeof(pfd));
|
||||||
if (pfd) {
|
if (pfd)
|
||||||
if (!strcmp(name, "-")) {
|
{
|
||||||
|
if (!strcmp(name, "-"))
|
||||||
|
{
|
||||||
*pfd = STDIN_FILENO;
|
*pfd = STDIN_FILENO;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
int flags = O_RDONLY;
|
int flags = O_RDONLY;
|
||||||
#ifdef O_LARGEFILE
|
#ifdef O_LARGEFILE
|
||||||
flags |= O_LARGEFILE;
|
flags |= O_LARGEFILE;
|
||||||
#endif
|
#endif
|
||||||
*pfd = open(name, flags);
|
*pfd = open(name, flags);
|
||||||
if (*pfd < 0) {
|
if (*pfd < 0)
|
||||||
|
{
|
||||||
free(pfd);
|
free(pfd);
|
||||||
pfd = NULL;
|
pfd = NULL;
|
||||||
}
|
}
|
||||||
@@ -172,7 +191,8 @@ void *inputOpen(const char *name)
|
|||||||
ctx->fileHandle = (void *)pfd;
|
ctx->fileHandle = (void *)pfd;
|
||||||
ctx->type = plainFile;
|
ctx->type = plainFile;
|
||||||
}
|
}
|
||||||
if (!ctx->fileHandle) {
|
if (!ctx->fileHandle)
|
||||||
|
{
|
||||||
fprintf(stderr, "error while opening file %s\n", name);
|
fprintf(stderr, "error while opening file %s\n", name);
|
||||||
exit(10);
|
exit(10);
|
||||||
}
|
}
|
||||||
@@ -186,7 +206,8 @@ int inputClose(void *context)
|
|||||||
struct Input *ctx = context;
|
struct Input *ctx = context;
|
||||||
void *f = ctx->fileHandle;
|
void *f = ctx->fileHandle;
|
||||||
|
|
||||||
switch(ctx->type) {
|
switch (ctx->type)
|
||||||
|
{
|
||||||
case plainFile:
|
case plainFile:
|
||||||
close(*(int *)f);
|
close(*(int *)f);
|
||||||
free(f);
|
free(f);
|
||||||
@@ -211,7 +232,8 @@ xmlTextReaderPtr inputUTF8(const char *name)
|
|||||||
{
|
{
|
||||||
void *ctx = inputOpen(name);
|
void *ctx = inputOpen(name);
|
||||||
|
|
||||||
if (!ctx) {
|
if (!ctx)
|
||||||
|
{
|
||||||
fprintf(stderr, "Input reader create failed for: %s\n", name);
|
fprintf(stderr, "Input reader create failed for: %s\n", name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,8 @@ static void long_usage(char *arg0)
|
|||||||
fprintf(stderr, " -v|--verbose\t\tVerbose output.\n");
|
fprintf(stderr, " -v|--verbose\t\tVerbose output.\n");
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
|
|
||||||
if (sizeof(int*) == 4) {
|
if (sizeof(int*) == 4)
|
||||||
|
{
|
||||||
fprintf(stderr, "\n\nYou are running this on 32bit system - this will not work\n");
|
fprintf(stderr, "\n\nYou are running this on 32bit system - this will not work\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -112,9 +113,11 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
fprintf(stderr, "nominatim SVN version %s\n\n", VERSION);
|
fprintf(stderr, "nominatim SVN version %s\n\n", VERSION);
|
||||||
|
|
||||||
while (1) {
|
while (1)
|
||||||
|
{
|
||||||
int c, option_index = 0;
|
int c, option_index = 0;
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] =
|
||||||
|
{
|
||||||
{"help", 0, 0, 'h'},
|
{"help", 0, 0, 'h'},
|
||||||
|
|
||||||
{"verbose", 0, 0, 'v'},
|
{"verbose", 0, 0, 'v'},
|
||||||
@@ -140,20 +143,47 @@ int main(int argc, char *argv[])
|
|||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
switch (c) {
|
switch (c)
|
||||||
case 'v': verbose=1; break;
|
{
|
||||||
case 'd': db=optarg; break;
|
case 'v':
|
||||||
case 'U': username=optarg; break;
|
verbose=1;
|
||||||
case 'W': pass_prompt=1; break;
|
break;
|
||||||
case 'H': host=optarg; break;
|
case 'd':
|
||||||
case 'P': port=optarg; break;
|
db=optarg;
|
||||||
case 'h': long_usage_bool=1; break;
|
break;
|
||||||
case 'i': index=1; break;
|
case 'U':
|
||||||
case 'e': export=1; break;
|
username=optarg;
|
||||||
case 'I': import=1; break;
|
break;
|
||||||
case 't': threads=atoi(optarg); break;
|
case 'W':
|
||||||
case 'F': file=optarg; break;
|
pass_prompt=1;
|
||||||
case 'T': tagsfile=optarg; break;
|
break;
|
||||||
|
case 'H':
|
||||||
|
host=optarg;
|
||||||
|
break;
|
||||||
|
case 'P':
|
||||||
|
port=optarg;
|
||||||
|
break;
|
||||||
|
case 'h':
|
||||||
|
long_usage_bool=1;
|
||||||
|
break;
|
||||||
|
case 'i':
|
||||||
|
index=1;
|
||||||
|
break;
|
||||||
|
case 'e':
|
||||||
|
export=1;
|
||||||
|
break;
|
||||||
|
case 'I':
|
||||||
|
import=1;
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
threads=atoi(optarg);
|
||||||
|
break;
|
||||||
|
case 'F':
|
||||||
|
file=optarg;
|
||||||
|
break;
|
||||||
|
case 'T':
|
||||||
|
tagsfile=optarg;
|
||||||
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
default:
|
default:
|
||||||
short_usage(argv[0]);
|
short_usage(argv[0]);
|
||||||
@@ -161,34 +191,38 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (long_usage_bool) {
|
if (long_usage_bool)
|
||||||
|
{
|
||||||
long_usage(argv[0]);
|
long_usage(argv[0]);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (threads < 1) threads = 1;
|
if (threads < 1) threads = 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (argc == optind) { // No non-switch arguments
|
if (argc == optind) { // No non-switch arguments
|
||||||
short_usage(argv[0]);
|
short_usage(argv[0]);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if (index && import) {
|
if (index && import)
|
||||||
|
{
|
||||||
fprintf(stderr, "Error: --index and --import options can not be used on the same database!\n");
|
fprintf(stderr, "Error: --index and --import options can not be used on the same database!\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pass_prompt)
|
if (pass_prompt)
|
||||||
password = simple_prompt("Password:", 100, 0);
|
password = simple_prompt("Password:", 100, 0);
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
password = getenv("PGPASS");
|
password = getenv("PGPASS");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test the database connection
|
// Test the database connection
|
||||||
conninfo = build_conninfo(db, username, password, host, port);
|
conninfo = build_conninfo(db, username, password, host, port);
|
||||||
conn = PQconnectdb(conninfo);
|
conn = PQconnectdb(conninfo);
|
||||||
if (PQstatus(conn) != CONNECTION_OK) {
|
if (PQstatus(conn) != CONNECTION_OK)
|
||||||
|
{
|
||||||
fprintf(stderr, "Connection to database failed: %s\n", PQerrorMessage(conn));
|
fprintf(stderr, "Connection to database failed: %s\n", PQerrorMessage(conn));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
#define MAX(x,y) (x > y?x:y)
|
#define MAX(x,y) (x > y?x:y)
|
||||||
#define MIN(x,y) (x < y?x:y)
|
#define MIN(x,y) (x < y?x:y)
|
||||||
|
|
||||||
struct output_options {
|
struct output_options
|
||||||
|
{
|
||||||
const char *conninfo; /* Connection info string */
|
const char *conninfo; /* Connection info string */
|
||||||
const char *prefix; /* prefix for table names */
|
const char *prefix; /* prefix for table names */
|
||||||
int scale; /* scale for converting coordinates to fixed point */
|
int scale; /* scale for converting coordinates to fixed point */
|
||||||
|
|||||||
@@ -12,22 +12,26 @@ const char *build_conninfo(const char *db, const char *username, const char *pas
|
|||||||
strcat(conninfo, db);
|
strcat(conninfo, db);
|
||||||
strcat(conninfo, "'");
|
strcat(conninfo, "'");
|
||||||
|
|
||||||
if (username) {
|
if (username)
|
||||||
|
{
|
||||||
strcat(conninfo, " user='");
|
strcat(conninfo, " user='");
|
||||||
strcat(conninfo, username);
|
strcat(conninfo, username);
|
||||||
strcat(conninfo, "'");
|
strcat(conninfo, "'");
|
||||||
}
|
}
|
||||||
if (password) {
|
if (password)
|
||||||
|
{
|
||||||
strcat(conninfo, " password='");
|
strcat(conninfo, " password='");
|
||||||
strcat(conninfo, password);
|
strcat(conninfo, password);
|
||||||
strcat(conninfo, "'");
|
strcat(conninfo, "'");
|
||||||
}
|
}
|
||||||
if (host) {
|
if (host)
|
||||||
|
{
|
||||||
strcat(conninfo, " host='");
|
strcat(conninfo, " host='");
|
||||||
strcat(conninfo, host);
|
strcat(conninfo, host);
|
||||||
strcat(conninfo, "'");
|
strcat(conninfo, "'");
|
||||||
}
|
}
|
||||||
if (port) {
|
if (port)
|
||||||
|
{
|
||||||
strcat(conninfo, " port='");
|
strcat(conninfo, " port='");
|
||||||
strcat(conninfo, port);
|
strcat(conninfo, port);
|
||||||
strcat(conninfo, "'");
|
strcat(conninfo, "'");
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ simple_prompt(const char *prompt, int maxlen, int echo)
|
|||||||
|| (getenv("OSTYPE") && strcmp(getenv("OSTYPE"), "msys") == 0)
|
|| (getenv("OSTYPE") && strcmp(getenv("OSTYPE"), "msys") == 0)
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (termin)
|
if (termin)
|
||||||
fclose(termin);
|
fclose(termin);
|
||||||
if (termout)
|
if (termout)
|
||||||
@@ -162,7 +162,8 @@ simple_prompt(const char *prompt, int maxlen, int echo)
|
|||||||
if (fgets(buf, sizeof(buf), termin) == NULL)
|
if (fgets(buf, sizeof(buf), termin) == NULL)
|
||||||
break;
|
break;
|
||||||
buflen = strlen(buf);
|
buflen = strlen(buf);
|
||||||
} while (buflen > 0 && buf[buflen - 1] != '\n');
|
}
|
||||||
|
while (buflen > 0 && buf[buflen - 1] != '\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length > 0 && destination[length - 1] == '\n')
|
if (length > 0 && destination[length - 1] == '\n')
|
||||||
|
|||||||
Reference in New Issue
Block a user