/[projects]/smsdaemon/smsqueue.cpp
ViewVC logotype

Annotation of /smsdaemon/smsqueue.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 196 - (hide annotations) (download)
Thu Dec 18 06:53:29 2008 UTC (15 years, 5 months ago) by torben
File size: 1084 byte(s)
Make pretty

astyle -t -b -N

1 torben 132 #include <iostream>
2     #include <fstream>
3     #include <string>
4     #include <stdexcept>
5    
6     #include <stdlib.h>
7    
8     #include "version.h"
9     #include "Spooler.h"
10 torben 158 #include "Util.h"
11 torben 132
12     using namespace std;
13    
14     void printUsage()
15     {
16     cout << "smsqueue / " << SVNVERSION << endl;
17     cout << "Usage: smsqueue <-m message|messagefile> <recipient>" << endl<<endl;
18     }
19    
20    
21     int main(int argc, char* argv[])
22     {
23     string recipient;
24     string message;
25    
26 torben 196 if (!(argc == 3 || argc == 4))
27     {
28 torben 132 printUsage();
29     return 0;
30     }
31    
32     if ( string(argv[1]) == "-m")
33     {
34 torben 196 if (argc != 4)
35     {
36 torben 132 printUsage();
37     return 0;
38     }
39     message = string(argv[2]);
40     recipient = string(argv[3]);
41 torben 196 }
42     else
43 torben 132 {
44 torben 196 if (argc != 3)
45     {
46 torben 132 printUsage();
47     return 0;
48     }
49 torben 196 try
50     {
51 torben 132 message = Util::readfile(string(argv[1]));
52 torben 196 }
53     catch (exception& e)
54     {
55 torben 132 cout << e.what() << endl;
56     return -1;
57     }
58     recipient = string(argv[2]);
59     }
60 torben 196
61 torben 132 srand(time(0));
62    
63     Spooler spool;
64    
65 torben 196 try
66     {
67 torben 132 spool.enqueue(recipient,message);
68 torben 134 cout << "enqueued as: " << spool.getFilename() << endl;
69 torben 196 }
70     catch (std::exception& e)
71     {
72 torben 132 cout << e.what() << endl;
73     return -1;
74     }
75 torben 196
76 torben 132 return 0;
77     }

  ViewVC Help
Powered by ViewVC 1.1.20