mistserver/src/make_html.cpp
Gijs Peskens 529adbfaf6 Add building via meson, remove outdated options
Co-authored-by: Thulinma <jaron@vietors.com>
Change-Id: I2a620c8d98aca7203f6742c66c3f82afe91b5c3c
2022-12-17 03:36:59 +01:00

40 lines
985 B
C++

#include <cstdlib>
#include <ios>
#include <iostream>
#include <fstream>
#include <ostream>
int main(int argc, char* argv[]) {
if (argc < 6) {
std::cerr << "ERROR EXPECTED MORE FILES" << std::endl;
return 1;
}
std::ofstream output(argv[1]);
std::ifstream header(argv[2]);
std::ifstream css(argv[3]);
std::ifstream footer(argv[4]);
if (!header.is_open() || !css.is_open() || !footer.is_open()) {
std::cerr << "ERROR Couldn't open file" << std::endl;
return 1;
}
output << header.rdbuf();
output << "<script>";
for (int i = 5; i < argc; i++) {
std::ifstream script(argv[i]);
if (!script.is_open()) {
std::cerr << "ERROR Couldn't open file" << std::endl;
return 1;
}
output << script.rdbuf();
}
output << "</script>";
output << "<style>" << css.rdbuf() << "</style>";
output << footer.rdbuf();
std::flush(output);
return 0;
}