Compile fixes for Raspbian 8.

* gcc (Raspbian 4.9.2-10) 4.9.2 complains about -1 in const char[]s.
  gcc (Ubuntu 5.2.1-22ubuntu2) 5.2.1 20151010 was fine with this.
  Use '\xff' instead.

* libjsoncpp-dev 0.6.0~rc2-3.1 doesn't have Json::writeValue.
  Use an older interface instead.

* libre2-dev 20140304+dfsg-2 has a bug in which custom RE2 parsers don't
  compile because the relevant constructor is only declared, not defined as
  trivial. (This is fixed on my Ubuntu's libre2-dev 20150701+dfsg-2.)
  Avoid using this.
This commit is contained in:
Scott Lamb 2016-04-25 04:54:36 -07:00
parent ff08118001
commit 138db4f491
2 changed files with 14 additions and 17 deletions

View File

@ -217,12 +217,12 @@ const char kSubtitleStsdBox[] = {
0x00, 0x00, // right
// TextSampleEntry.StyleRecord
0x00, 0x00, // startChar
0x00, 0x00, // endChar
0x00, 0x01, // font-ID
0x00, // face-style-flags
0x12, // font-size == 18 px
~0, ~0, ~0, ~0, // text-color-rgba == opaque white
0x00, 0x00, // startChar
0x00, 0x00, // endChar
0x00, 0x01, // font-ID
0x00, // face-style-flags
0x12, // font-size == 18 px
'\xff', '\xff', '\xff', '\xff', // text-color-rgba == opaque white
// TextSampleEntry.FontTableBox
0x00, 0x00, 0x00, 0x16, // length

View File

@ -48,18 +48,12 @@ static const char kJsonMimeType[] = "application/json";
void ReplyWithJson(evhttp_request *req, const Json::Value &value) {
EvBuffer buf;
buf.Add(Json::writeString(Json::StreamWriterBuilder(), value));
buf.Add(Json::FastWriter().write(value));
evhttp_add_header(evhttp_request_get_output_headers(req), "Content-Type",
kJsonMimeType);
evhttp_send_reply(req, HTTP_OK, "OK", buf.get());
}
// RE2::Arg::Parser for uuids.
bool ParseUuid(const char *str, int n, void *dest) {
auto *uuid = reinterpret_cast<Uuid *>(dest);
return uuid->ParseText(re2::StringPiece(str, n));
}
} // namespace
void WebInterface::Register(evhttp *http) {
@ -78,25 +72,28 @@ void WebInterface::DispatchHttpRequest(evhttp_request *req, void *arg) {
auto *this_ = reinterpret_cast<WebInterface *>(arg);
const evhttp_uri *uri = evhttp_request_get_evhttp_uri(req);
re2::StringPiece path = evhttp_uri_get_path(uri);
re2::StringPiece camera_uuid_str;
Uuid camera_uuid;
RE2::Arg camera_uuid_arg(&camera_uuid, &ParseUuid);
if (path == "/" || path == "/cameras/") {
if (json) {
this_->HandleJsonCameraList(req);
} else {
this_->HandleHtmlCameraList(req);
}
} else if (RE2::FullMatch(path, kCameraUri, camera_uuid_arg)) {
} else if (RE2::FullMatch(path, kCameraUri, &camera_uuid_str) &&
camera_uuid.ParseText(camera_uuid_str)) {
if (json) {
this_->HandleJsonCameraDetail(req, camera_uuid);
} else {
this_->HandleHtmlCameraDetail(req, camera_uuid);
}
} else if (RE2::FullMatch(path, kCameraRecordingsUri, camera_uuid_arg)) {
} else if (RE2::FullMatch(path, kCameraRecordingsUri, &camera_uuid_str) &&
camera_uuid.ParseText(camera_uuid_str)) {
// The HTML version includes this in the top-level camera view.
// So only support JSON at this URI.
this_->HandleJsonCameraRecordings(req, camera_uuid);
} else if (RE2::FullMatch(path, kCameraViewUri, camera_uuid_arg)) {
} else if (RE2::FullMatch(path, kCameraViewUri, &camera_uuid_str) &&
camera_uuid.ParseText(camera_uuid_str)) {
this_->HandleMp4View(req, camera_uuid);
} else {
evhttp_send_error(req, HTTP_NOTFOUND, "path not understood");