1 // Copyright 2009 The Archiveopteryx Developers <info@aox.org>
2 
3 #include "anonymise.h"
4 
5 #include "file.h"
6 
7 #include <stdio.h>
8 
9 
10 static AoxFactory<Anonymise>
11 f( "anonymise", "", "Anonymise a named mail message.",
12    "    Synopsis: aox anonymise filename\n\n"
13    "    Reads a mail message from the named file, obscures most or\n"
14    "    all content and prints the result on stdout. The output\n"
15    "    resembles the original closely enough to be used in a bug\n"
16    "    report.\n" );
17 
18 
19 
20 /*! \class Anonymise anonymise.h
21     This class handles the "aox anonymise" command.
22 */
23 
Anonymise(EStringList * args)24 Anonymise::Anonymise( EStringList * args )
25     : AoxCommand( args )
26 {
27     execute();
28 }
29 
30 
execute()31 void Anonymise::execute()
32 {
33     EString s( next() );
34     end();
35 
36     File f( s );
37     if ( f.valid() )
38         fprintf( stdout, "%s\n", f.contents().anonymised().cstr() );
39     else
40         error( "Couldn't open file: " + s );
41 
42     finish();
43 }
44