2
* Copyright (C) 2007 Tommi Maekitalo
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License as
6
* published by the Free Software Foundation; either version 2 of the
7
* License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful, but
10
* is provided AS IS, WITHOUT ANY WARRANTY; without even the implied
11
* warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and
12
* NON-INFRINGEMENT. See the GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
#include <cxxtools/mime.h>
24
#include <cxxtools/loginit.h>
26
int main(int argc, char* argv[])
34
for (int a = 1; a < argc; ++a)
36
std::string fname = argv[a];
38
std::ifstream ifile(argv[a]);
40
throw std::runtime_error("cannot open file " + fname);
42
if (fname.size() >= 4 && fname.compare(fname.size() - 4, 4, ".jpg") == 0)
43
mime.addBinaryFile("image/jpg", fname, ifile);
44
else if (fname.size() >= 4 && fname.compare(fname.size() - 4, 4, ".gif") == 0)
45
mime.addBinaryFile("image/gif", fname, ifile);
46
else if (fname.size() >= 4 && fname.compare(fname.size() - 4, 4, ".png") == 0)
47
mime.addBinaryFile("image/png", fname, ifile);
54
catch (const std::exception& e)
56
std::cerr << e.what() << std::endl;