Skip to content

Commit

Permalink
Merge pull request MalcolmRobb#71 from maxried/master
Browse files Browse the repository at this point in the history
--html-dir option
  • Loading branch information
mutability committed Sep 14, 2015
2 parents 909f1ad + 3d44559 commit 3b4c872
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions dump1090.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ void modesInitConfig(void) {
Modes.net_fatsv_port = MODES_NET_OUTPUT_FA_TSV_PORT;
Modes.interactive_rows = getTermRows();
Modes.interactive_display_ttl = MODES_INTERACTIVE_DISPLAY_TTL;
Modes.html_dir = HTMLPATH;
Modes.json_interval = 1000;
Modes.json_location_accuracy = 1;
Modes.maxRange = 1852 * 300; // 300NM default max range
Expand Down Expand Up @@ -713,6 +714,7 @@ void showHelp(void) {
"--quiet Disable output to stdout. Use for daemon applications\n"
"--show-only <addr> Show only messages from the given ICAO on stdout\n"
"--ppm <error> Set receiver error in parts per million (default 0)\n"
"--html-dir <dir> Use <dir> as base directory for the internal HTTP server. Defaults to " HTMLPATH "\n"
"--write-json <dir> Periodically write json output to <dir> (for serving by a separate webserver)\n"
"--write-json-every <t> Write json output every t seconds (default 1)\n"
"--json-location-accuracy <n> Accuracy of receiver location in json metadata: 0=no location, 1=approximate, 2=exact\n"
Expand Down Expand Up @@ -1060,6 +1062,8 @@ int main(int argc, char **argv) {
Modes.interactive_rtl1090 = 1;
} else if (!strcmp(argv[j],"--oversample")) {
Modes.oversample = 1;
} else if (!strcmp(argv[j], "--html-dir") && more) {
Modes.html_dir = strdup(argv[++j]);
#ifndef _WIN32
} else if (!strcmp(argv[j], "--write-json") && more) {
Modes.json_dir = strdup(argv[++j]);
Expand Down
1 change: 1 addition & 0 deletions dump1090.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ struct { // Internal state
int interactive_rtl1090; // flight table in interactive mode is formatted like RTL1090
char *json_dir; // Path to json base directory, or NULL not to write json.
uint64_t json_interval; // Interval between rewriting the json aircraft file, in milliseconds; also the advertised map refresh interval
char *html_dir; // Path to www base directory.
int json_location_accuracy; // Accuracy of location metadata: 0=none, 1=approx, 2=exact
int throttle; // When reading from a file, throttle file playback to realtime?

Expand Down
10 changes: 5 additions & 5 deletions net_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1315,15 +1315,15 @@ static int handleHTTPRequest(struct client *c, char *p) {
char getFile[1024];

if (strlen(url) < 2) {
snprintf(getFile, sizeof getFile, "%s/gmap.html", HTMLPATH); // Default file
snprintf(getFile, sizeof getFile, "%s/gmap.html", Modes.html_dir); // Default file
} else {
snprintf(getFile, sizeof getFile, "%s/%s", HTMLPATH, url);
snprintf(getFile, sizeof getFile, "%s/%s", Modes.html_dir, url);
}

if (!realpath(getFile, rp))
rp[0] = 0;
if (!realpath(HTMLPATH, hrp))
strcpy(hrp, HTMLPATH);
if (!realpath(Modes.html_dir, hrp))
strcpy(hrp, Modes.html_dir);

clen = -1;
content = strdup("Server error occured");
Expand All @@ -1342,7 +1342,7 @@ static int handleHTTPRequest(struct client *c, char *p) {

if (clen < 0) {
content = realloc(content, 128);
clen = snprintf(content, 128,"Error opening HTML file: %s", strerror(errno));
clen = snprintf(content, 128, "Error opening HTML file: %s", strerror(errno));
statuscode = 404;
statusmsg = "Not Found";
}
Expand Down

0 comments on commit 3b4c872

Please sign in to comment.