1 /***************************************************************************
2 copyright : (C) 2002-2005 by Stefano Barbato
3 email : stefano@codesink.org
5 $Id: qp.cxx,v 1.2 2005/02/23 10:26:14 tat Exp $
6 ***************************************************************************/
8 /***************************************************************************
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
15 ***************************************************************************/
17 * Usage: qp [-ed] [in_file [out_file]]
19 * Quoted-Printable encodes or decodes in_file (or standard input) and writes
20 * output to out_file (or standard output)
25 #include <mimetic/mimetic.h>
28 using namespace mimetic;
32 cout << "qp [-ed] [in_file [out_file]]" << endl;
36 void die_if(bool b, const string& s)
46 int main(int argc, char** argv)
48 std::ios_base::sync_with_stdio(false);
65 fin.open(argv[2], ios::in);
66 die_if(!fin.is_open(), string("unable to open file ")+argv[2]);
70 fout.open(argv[3], ios::out);
71 die_if(!fout.is_open(), string("unable to open file ")+argv[3]);
73 istream is( fin.is_open() ? &fin : cin.rdbuf());
74 ostream os( fout.is_open() ? &fout : cout.rdbuf());
75 istreambuf_iterator<char> ibeg(is), iend;
76 ostreambuf_iterator<char> out(os);
80 encode(ibeg, iend, qp, out);
83 decode(ibeg, iend, qp, out);