Switch to unified view

a/upmpd/upmpd.cxx b/upmpd/upmpd.cxx
...
...
89
89
90
/////////////////////////////////////////////////////////////////////
90
/////////////////////////////////////////////////////////////////////
91
// Main program
91
// Main program
92
92
93
#include "conftree.hxx"
93
#include "conftree.hxx"
94
95
static char *thisprog;
96
97
static int op_flags;
98
#define OPT_MOINS 0x1
99
#define OPT_h   0x2
100
#define OPT_p   0x4
101
#define OPT_d   0x8
102
#define OPT_D     0x10
103
#define OPT_c     0x20
104
#define OPT_l     0x40
105
#define OPT_f     0x80
106
#define OPT_q     0x100
107
#define OPT_i     0x200
108
#define OPT_P     0x400
109
110
static const char usage[] = 
111
"-c configfile \t configuration file to use\n"
112
"""""""""""""""""""""""""""""-h host    \t specify host MPD is running on\n"""""""""""""""""""""""""""""
113
"-p port     \t specify MPD port\n"
114
"-d logfilename\t debug messages to\n"
115
"-l loglevel\t  log level (0-6)\n"
116
"-D    \t run as a daemon\n"
117
"-f friendlyname\t define device displayed name\n"
118
"-q 0|1\t if set, we own the mpd queue, else avoid clearing it whenever we feel like it\n"
119
"-i iface    \t specify network interface name to be used for UPnP"
120
"-P upport    \t specify port number to be used for UPnP"
121
"  \n\n"
122
          ;
123
static void
124
Usage(void)
125
{
126
  fprintf(stderr, "%s: usage:\n%s", thisprog, usage);
127
  exit(1);
128
}
129
130
static string myDeviceUUID;
131
132
static string datadir(DATADIR "/");
133
static string configdir(CONFIGDIR "/");
134
135
// Our XML description data. !Keep description.xml first!
136
static vector<const char *> xmlfilenames = 
137
{
138
  /* keep first */ "description.xml", /* keep first */
139
  "RenderingControl.xml", "AVTransport.xml", "ConnectionManager.xml",
140
};
141
static vector<const char *> ohxmlfilenames = 
142
{
143
  "OHProduct.xml", "OHInfo.xml", "OHTime.xml", "OHVolume.xml", 
144
  "OHPlaylist.xml",
145
};
146
147
94
148
static const string ohDesc(
95
static const string ohDesc(
149
    "<service>"
96
    "<service>"
150
    "  <serviceType>urn:av-openhome-org:service:Product:1</serviceType>"
97
    "  <serviceType>urn:av-openhome-org:service:Product:1</serviceType>"
151
    "  <serviceId>urn:av-openhome-org:serviceId:Product</serviceId>"
98
    "  <serviceId>urn:av-openhome-org:serviceId:Product</serviceId>"
...
...
181
    "  <controlURL>/ctl/OHPlaylist</controlURL>"
128
    "  <controlURL>/ctl/OHPlaylist</controlURL>"
182
    "  <eventSubURL>/evt/OHPlaylist</eventSubURL>"
129
    "  <eventSubURL>/evt/OHPlaylist</eventSubURL>"
183
    "</service>"
130
    "</service>"
184
    );
131
    );
185
132
133
static char *thisprog;
134
135
static int op_flags;
136
#define OPT_MOINS 0x1
137
#define OPT_h   0x2
138
#define OPT_p   0x4
139
#define OPT_d   0x8
140
#define OPT_D     0x10
141
#define OPT_c     0x20
142
#define OPT_l     0x40
143
#define OPT_f     0x80
144
#define OPT_q     0x100
145
#define OPT_i     0x200
146
#define OPT_P     0x400
147
#define OPT_O     0x800
148
149
static const char usage[] = 
150
"-c configfile \t configuration file to use\n"
151
"""""""""""""""""""""""""""""-h host    \t specify host MPD is running on\n"""""""""""""""""""""""""""""
152
"-p port     \t specify MPD port\n"
153
"-d logfilename\t debug messages to\n"
154
"-l loglevel\t  log level (0-6)\n"
155
"-D    \t run as a daemon\n"
156
"-f friendlyname\t define device displayed name\n"
157
"-q 0|1\t if set, we own the mpd queue, else avoid clearing it whenever we feel like it\n"
158
"-i iface    \t specify network interface name to be used for UPnP\n"
159
"-P upport    \t specify port number to be used for UPnP\n"
160
"-O 0|1\t decide if we run and export the OpenHome services\n"
161
"\n"
162
          ;
163
static void
164
Usage(void)
165
{
166
  fprintf(stderr, "%s: usage:\n%s", thisprog, usage);
167
  exit(1);
168
}
169
170
static string myDeviceUUID;
171
172
static string datadir(DATADIR "/");
173
static string configdir(CONFIGDIR "/");
174
175
// Our XML description data. !Keep description.xml first!
176
static vector<const char *> xmlfilenames = 
177
{
178
  /* keep first */ "description.xml", /* keep first */
179
  "RenderingControl.xml", "AVTransport.xml", "ConnectionManager.xml",
180
};
181
static vector<const char *> ohxmlfilenames = 
182
{
183
  "OHProduct.xml", "OHInfo.xml", "OHTime.xml", "OHVolume.xml", 
184
  "OHPlaylist.xml",
185
};
186
187
186
int main(int argc, char *argv[])
188
int main(int argc, char *argv[])
187
{
189
{
188
    string mpdhost("localhost");
190
    string mpdhost("localhost");
189
    int mpdport = 6600;
191
    int mpdport = 6600;
190
    string mpdpassword;
192
    string mpdpassword;
...
...
220
        (*argv)++;
222
        (*argv)++;
221
        if (!(**argv))
223
        if (!(**argv))
222
            Usage();
224
            Usage();
223
        while (**argv)
225
        while (**argv)
224
            switch (*(*argv)++) {
226
            switch (*(*argv)++) {
225
          case 'D':   op_flags |= OPT_D; break;
226
            case 'c':   op_flags |= OPT_c; if (argc < 2)  Usage();
227
            case 'c':   op_flags |= OPT_c; if (argc < 2)  Usage();
227
                configfile = *(++argv); argc--; goto b1;
228
                configfile = *(++argv); argc--; goto b1;
229
          case 'D':   op_flags |= OPT_D; break;
230
          case 'd':   op_flags |= OPT_d; if (argc < 2)  Usage();
231
              logfilename = *(++argv); argc--; goto b1;
228
            case 'f':   op_flags |= OPT_f; if (argc < 2)  Usage();
232
            case 'f':   op_flags |= OPT_f; if (argc < 2)  Usage();
229
                friendlyname = *(++argv); argc--; goto b1;
233
                friendlyname = *(++argv); argc--; goto b1;
230
          case 'd':   op_flags |= OPT_d; if (argc < 2)  Usage();
231
              logfilename = *(++argv); argc--; goto b1;
232
            case 'h':   op_flags |= OPT_h; if (argc < 2)  Usage();
234
            case 'h':   op_flags |= OPT_h; if (argc < 2)  Usage();
233
                mpdhost = *(++argv); argc--; goto b1;
235
                mpdhost = *(++argv); argc--; goto b1;
236
          case 'i':   op_flags |= OPT_i; if (argc < 2)  Usage();
237
              iface = *(++argv); argc--; goto b1;
234
            case 'l':   op_flags |= OPT_l; if (argc < 2)  Usage();
238
            case 'l':   op_flags |= OPT_l; if (argc < 2)  Usage();
235
                loglevel = atoi(*(++argv)); argc--; goto b1;
239
                loglevel = atoi(*(++argv)); argc--; goto b1;
240
          case 'O': {
241
              op_flags |= OPT_O; 
242
              if (argc < 2)  Usage();
243
              const char *cp =  *(++argv);
244
              if (*cp == '1' || *cp == 't' || *cp == 'T' || *cp == 'y' || 
245
                  *cp == 'Y')
246
                  openhome = true;
247
              argc--; goto b1;
248
          }
249
          case 'P':   op_flags |= OPT_P; if (argc < 2)  Usage();
250
              upport = atoi(*(++argv)); argc--; goto b1;
236
            case 'p':   op_flags |= OPT_p; if (argc < 2)  Usage();
251
            case 'p':   op_flags |= OPT_p; if (argc < 2)  Usage();
237
                mpdport = atoi(*(++argv)); argc--; goto b1;
252
                mpdport = atoi(*(++argv)); argc--; goto b1;
238
            case 'q':   op_flags |= OPT_q; if (argc < 2)  Usage();
253
            case 'q':   op_flags |= OPT_q; if (argc < 2)  Usage();
239
                ownqueue = atoi(*(++argv)) != 0; argc--; goto b1;
254
                ownqueue = atoi(*(++argv)) != 0; argc--; goto b1;
240
          case 'i':   op_flags |= OPT_i; if (argc < 2)  Usage();
241
              iface = *(++argv); argc--; goto b1;
242
          case 'P':   op_flags |= OPT_P; if (argc < 2)  Usage();
243
              upport = atoi(*(++argv)); argc--; goto b1;
244
            default: Usage();   break;
255
            default: Usage();   break;
245
            }
256
            }
246
    b1: argc--; argv++;
257
    b1: argc--; argv++;
247
    }
258
    }
248
259