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

Contents of /smsdaemon/smsqueue.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 158 - (show annotations) (download)
Mon Dec 8 21:49:49 2008 UTC (15 years, 5 months ago) by torben
File size: 1073 byte(s)
rename:
	util.* -> Util.*
	common.* -> Common.*

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 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 cout << "enqueued as: " << spool.getFilename() << endl;
62 } catch (std::exception& e) {
63 cout << e.what() << endl;
64 return -1;
65 }
66
67 return 0;
68 }

  ViewVC Help
Powered by ViewVC 1.1.20