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

Annotation of /smsdaemon/smsqueue.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 132 - (hide annotations) (download)
Sun Dec 7 00:59:05 2008 UTC (15 years, 5 months ago) by torben
File size: 1015 byte(s)
Added spooling (queing) function, with a standalone application(smsqueue) to put new messages 
into the spool dir.

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

  ViewVC Help
Powered by ViewVC 1.1.20