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

Contents of /smsdaemon/smsqueue.cpp

Parent Directory Parent Directory | Revision Log Revision Log


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

astyle -t -b -N

1 #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 #include "Util.h"
11
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 if (!(argc == 3 || argc == 4))
27 {
28 printUsage();
29 return 0;
30 }
31
32 if ( string(argv[1]) == "-m")
33 {
34 if (argc != 4)
35 {
36 printUsage();
37 return 0;
38 }
39 message = string(argv[2]);
40 recipient = string(argv[3]);
41 }
42 else
43 {
44 if (argc != 3)
45 {
46 printUsage();
47 return 0;
48 }
49 try
50 {
51 message = Util::readfile(string(argv[1]));
52 }
53 catch (exception& e)
54 {
55 cout << e.what() << endl;
56 return -1;
57 }
58 recipient = string(argv[2]);
59 }
60
61 srand(time(0));
62
63 Spooler spool;
64
65 try
66 {
67 spool.enqueue(recipient,message);
68 cout << "enqueued as: " << spool.getFilename() << endl;
69 }
70 catch (std::exception& e)
71 {
72 cout << e.what() << endl;
73 return -1;
74 }
75
76 return 0;
77 }

  ViewVC Help
Powered by ViewVC 1.1.20