Skip to content

Commit

Permalink
mockup for outlining tool
Browse files Browse the repository at this point in the history
  • Loading branch information
MaZderMind committed May 23, 2011
1 parent 64f587f commit 922411b
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
1 change: 1 addition & 0 deletions tools/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
osmpbf-outline
17 changes: 17 additions & 0 deletions tools/Makefile
Original file line number Diff line number Diff line change
@@ -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 changes: 53 additions & 0 deletions tools/osmpbf-outline.cpp
Original file line number Diff line number Diff line change
@@ -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();
}

0 comments on commit 922411b

Please sign in to comment.