~ubuntu-branches/ubuntu/vivid/zoneminder/vivid-proposed

« back to all changes in this revision

Viewing changes to src/zmu.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Peter Howard
  • Date: 2009-11-14 15:02:10 UTC
  • mfrom: (4.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20091114150210-d8721h9wm90cbaog
Tags: 1.24.2-2
* Remove custom perl parth from zmpkg.pl, fix location of manpages.
(closes: #551746, #553092)
* Fix GCC4.4 bug
(closes: #531717)
* Fix potential bug in postinst script

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//
2
 
// ZoneMinder Control Utility, $Date: 2008-07-25 10:33:23 +0100 (Fri, 25 Jul 2008) $, $Revision: 2611 $
 
2
// ZoneMinder Control Utility, $Date: 2009-04-14 21:18:57 +0100 (Tue, 14 Apr 2009) $, $Revision: 2848 $
3
3
// Copyright (C) 2001-2008 Philip Coombes
4
4
// 
5
5
// This program is free software; you can redistribute it and/or
35
35
        fprintf( stderr, "  -v, --verbose                  : Produce more verbose output\n" );
36
36
        fprintf( stderr, "  -l, --list                     : List the current status of active (or all with -v) monitors\n" );
37
37
        fprintf( stderr, "Options for use with devices:\n" );
38
 
        fprintf( stderr, "  -d, --device <device_path>     : Get the current video device settings for <device_path>\n" );
 
38
        fprintf( stderr, "  -d, --device [device_path]     : Get the current video device settings for [device_path] or all devices\n" );
 
39
        fprintf( stderr, "  -V, --version <V4L version>    : Set the Video 4 Linux API version to use for the query, use 1 or 2\n" );
39
40
        fprintf( stderr, "  -q, --query                    : Query the current settings for the device\n" );
40
41
        fprintf( stderr, "Options for use with monitors:\n" );
41
42
        fprintf( stderr, "  -m, --monitor <monitor_id>     : Specify which monitor to address, default 1 if absent\n" );
137
138
 
138
139
int main( int argc, char *argv[] )
139
140
{
 
141
    srand( getpid() * time( 0 ) );
 
142
 
140
143
        static struct option long_options[] = {
141
 
                {"device", 1, 0, 'd'},
 
144
                {"device", 2, 0, 'd'},
142
145
                {"monitor", 1, 0, 'm'},
143
146
                {"verbose", 0, 0, 'v'},
144
147
                {"image", 2, 0, 'i'},
165
168
                {"query", 0, 0, 'q'},
166
169
                {"username", 1, 0, 'U'},
167
170
                {"password", 1, 0, 'P'},
 
171
                {"auth", 1, 0, 'A'},
 
172
                {"version", 1, 0, 'V'},
168
173
                {"help", 0, 0, 'h'},
169
174
                {"list", 0, 0, 'l'},
170
175
                {0, 0, 0, 0}
171
176
        };
172
177
 
173
 
        const char *device = "";
 
178
        const char *device = 0;
174
179
        int mon_id = 0;
175
180
        bool verbose = false;
176
181
        int function = ZMU_BOGUS;
181
186
        int contrast = -1;
182
187
        int hue = -1;
183
188
        int colour = -1;
184
 
        char *zone_string = 0;
 
189
        char *zoneString = 0;
185
190
        char *username = 0;
186
191
        char *password = 0;
187
192
        char *auth = 0;
 
193
#ifdef ZM_V4L2
 
194
    int v4lVersion = 2;
 
195
#else // ZM_V4L2
 
196
    int v4lVersion = 1;
 
197
#endif // ZM_V4L2
188
198
        while (1)
189
199
        {
190
200
                int option_index = 0;
191
201
 
192
 
                int c = getopt_long (argc, argv, "d:m:vsEDLurwei::S:t::fz::ancqhlB::C::H::O::U:P:A:", long_options, &option_index);
 
202
                int c = getopt_long (argc, argv, "d:m:vsEDLurwei::S:t::fz::ancqhlB::C::H::O::U:P:A:V:", long_options, &option_index);
193
203
                if (c == -1)
194
204
                {
195
205
                        break;
198
208
                switch (c)
199
209
                {
200
210
                        case 'd':
201
 
                                device = optarg;
 
211
                if ( optarg )
 
212
                                    device = optarg;
202
213
                                break;
203
214
                        case 'm':
204
215
                                mon_id = atoi(optarg);
212
223
                        case 'i':
213
224
                                function |= ZMU_IMAGE;
214
225
                                if ( optarg )
215
 
                                {
216
226
                                        image_idx = atoi( optarg );
217
 
                                }
218
227
                                break;
219
228
                        case 'S':
220
229
                                scale = atoi(optarg);
222
231
                        case 't':
223
232
                                function |= ZMU_TIME;
224
233
                                if ( optarg )
225
 
                                {
226
234
                                        image_idx = atoi( optarg );
227
 
                                }
228
235
                                break;
229
236
                        case 'R':
230
237
                                function |= ZMU_READ_IDX;
241
248
                        case 'z':
242
249
                                function |= ZMU_ZONES;
243
250
                                if ( optarg )
244
 
                                {
245
 
                                        zone_string = optarg;
246
 
                                }
 
251
                                        zoneString = optarg;
247
252
                                break;
248
253
                        case 'a':
249
254
                                function |= ZMU_ALARM;
275
280
                        case 'B':
276
281
                                function |= ZMU_BRIGHTNESS;
277
282
                                if ( optarg )
278
 
                                {
279
283
                                        brightness = atoi( optarg );
280
 
                                }
281
284
                                break;
282
285
                        case 'C':
283
286
                                function |= ZMU_CONTRAST;
284
287
                                if ( optarg )
285
 
                                {
286
288
                                        contrast = atoi( optarg );
287
 
                                }
288
289
                                break;
289
290
                        case 'H':
290
291
                                function |= ZMU_HUE;
291
292
                                if ( optarg )
292
 
                                {
293
293
                                        hue = atoi( optarg );
294
 
                                }
295
294
                                break;
296
295
                        case 'O':
297
296
                                function |= ZMU_COLOUR;
298
297
                                if ( optarg )
299
 
                                {
300
298
                                        colour = atoi( optarg );
301
 
                                }
302
299
                                break;
303
300
                        case 'U':
304
301
                                username = optarg;
309
306
                        case 'A':
310
307
                                auth = optarg;
311
308
                                break;
 
309
                        case 'V':
 
310
                                v4lVersion = (atoi(optarg)==1)?1:2;
 
311
                                break;
312
312
                        case 'h':
313
313
                                Usage( 0 );
314
314
                                break;
333
333
                Usage();
334
334
        }
335
335
 
336
 
        if ( device[0] && !(function&ZMU_QUERY) )
 
336
        if ( device && !(function&ZMU_QUERY) )
337
337
        {
338
338
                fprintf( stderr, "Error, -d option cannot be used with this option\n" );
339
339
                Usage();
401
401
        }
402
402
        
403
403
 
404
 
        if ( device[0] )
405
 
        {
406
 
                if ( function & ZMU_QUERY )
407
 
                {
408
 
                        char vid_string[BUFSIZ] = "";
409
 
                        bool ok = LocalCamera::GetCurrentSettings( device, vid_string, verbose );
410
 
                        printf( "%s", vid_string );
411
 
                        exit( ok?0:-1 );
412
 
                }
413
 
        }
414
 
        else if ( mon_id > 0 )
 
404
        if ( mon_id > 0 )
415
405
        {
416
406
                Monitor *monitor = Monitor::Load( mon_id, function&(ZMU_QUERY|ZMU_ZONES), Monitor::QUERY );
417
407
                if ( monitor )
516
506
                        {
517
507
                                if ( verbose )
518
508
                                        printf( "Dumping zone image to %s-Zones.jpg\n", monitor->Name() );
519
 
                                monitor->DumpZoneImage( zone_string );
 
509
                                monitor->DumpZoneImage( zoneString );
520
510
                        }
521
511
                        if ( function & ZMU_ALARM )
522
512
                        {
568
558
                        }
569
559
                        if ( function & ZMU_QUERY )
570
560
                        {
571
 
                                char mon_string[16382] = "";
572
 
                                monitor->DumpSettings( mon_string, verbose );
573
 
                                printf( "%s\n", mon_string );
 
561
                                char monString[16382] = "";
 
562
                                monitor->DumpSettings( monString, verbose );
 
563
                                printf( "%s\n", monString );
574
564
                        }
575
565
                        if ( function & ZMU_BRIGHTNESS )
576
566
                        {
666
656
        }
667
657
        else
668
658
        {
 
659
                if ( function & ZMU_QUERY )
 
660
                {
 
661
                        char vidString[0x10000] = "";
 
662
                        bool ok = LocalCamera::GetCurrentSettings( device, vidString, v4lVersion, verbose );
 
663
                        printf( "%s", vidString );
 
664
                        exit( ok?0:-1 );
 
665
                }
 
666
 
669
667
                if ( function & ZMU_LIST )
670
668
                {
671
669
                        char sql[BUFSIZ];