-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
563 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include <odr/file.hpp> | ||
#include <odr/http_server.hpp> | ||
|
||
#include <iostream> | ||
#include <string> | ||
|
||
using namespace odr; | ||
|
||
int main(int argc, char **argv) { | ||
std::string input{argv[1]}; | ||
|
||
std::optional<std::string> password; | ||
if (argc >= 3) { | ||
password = argv[2]; | ||
} | ||
|
||
DecodePreference decode_preference; | ||
decode_preference.engine_priority = { | ||
DecoderEngine::poppler, DecoderEngine::wvware, DecoderEngine::odr}; | ||
|
||
DecodedFile decoded_file{input, decode_preference}; | ||
|
||
if (decoded_file.is_document_file()) { | ||
DocumentFile document_file = decoded_file.document_file(); | ||
if (document_file.password_encrypted() && !password) { | ||
std::cerr << "document encrypted but no password given" << std::endl; | ||
return 2; | ||
} | ||
if (document_file.password_encrypted() && | ||
!document_file.decrypt(*password)) { | ||
std::cerr << "wrong password" << std::endl; | ||
return 1; | ||
} | ||
} | ||
|
||
HttpServer::Config config; | ||
HttpServer server(config); | ||
|
||
{ | ||
std::string id = server.host_file(File(input)); | ||
std::cout << "hosted file with id: " << id << std::endl; | ||
std::cout << "http://localhost:8080/" << id << std::endl; | ||
} | ||
|
||
{ | ||
std::string id = server.host_file(decoded_file); | ||
std::cout << "hosted decoded file with id: " << id << std::endl; | ||
std::cout << "http://localhost:8080/" << id << std::endl; | ||
} | ||
|
||
server.listen("localhost", 8080); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#include <odr/exceptions.hpp> | ||
#include <odr/file.hpp> | ||
#include <odr/html.hpp> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.