mockup for outlining tool

This commit is contained in:
Peter 2011-05-23 10:31:24 +02:00
parent 64f587f2eb
commit 922411b27a
3 changed files with 71 additions and 0 deletions

1
tools/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
osmpbf-outline

17
tools/Makefile Normal file
View File

@ -0,0 +1,17 @@
CXX = g++
CXXFLAGS = -O3
LDFLAGS = -lpthread
LIB_PROTOBUF = -lz -lprotobuf-lite -losmpbf
all: osmpbf-outline
osmpbf-outline: osmpbf-outline.cpp
$(CXX) $(CXXFLAGS) -o $@ $< $(LDFLAGS) $(LIB_PROTOBUF)
install:
install -m 755 -g root -o root -d $(DESTDIR)/usr/bin
install -m 644 -g root -o root osmpbf-outline $(DESTDIR)/usr/bin
clean:
rm -f osmpbf-outline

53
tools/osmpbf-outline.cpp Normal file
View File

@ -0,0 +1,53 @@
#include <stdarg.h>
#include <stdio.h>
#include <zlib.h>
#include <osmpbf/fileformat.pb.h>
#include <osmpbf/osmformat.pb.h>
bool is_a_tty;
void msg(const char* format, int color, va_list args) {
if(is_a_tty) fprintf(stderr, "\x1b[0;%dm", color);
vfprintf(stderr, format, args);
if(is_a_tty) fprintf(stderr, "\x1b[0m\n");
else fprintf(stderr, "\n");
}
void err(const char* format, ...) {
va_list args;
va_start(args, format);
msg(format, 31, args);
va_end(args);
exit(1);
}
void warn(const char* format, ...) {
va_list args;
va_start(args, format);
msg(format, 33, args);
va_end(args);
}
void info(const char* format, ...) {
va_list args;
va_start(args, format);
msg(format, 37, args);
va_end(args);
}
int main(int argc, char *argv[]) {
if(isatty(2)) {
is_a_tty = true;
}
if(argc != 2)
err("usage: %s file.osm.pbf", argv[0]);
FILE *fp = fopen(argv[1], "r");
fclose(fp);
google::protobuf::ShutdownProtobufLibrary();
}