| 424 | |
| 425 | |
| 426 | int main(int argc, char **argv) |
| 427 | { |
| 428 | int status = 0, shmid = -1; bool test = false; |
| 429 | char *darg[2] = { NULL, NULL }; |
| 430 | |
| 431 | try |
| 432 | { |
| 433 | if(argc > 1) for(int i = 1; i < argc; i++) |
| 434 | { |
| 435 | if(!stricmp(argv[i], "-display") && i < argc - 1) |
| 436 | { |
| 437 | darg[0] = argv[i++]; darg[1] = argv[i]; |
| 438 | } |
| 439 | else if(!stricmp(argv[i], "-shmid") && i < argc - 1) |
| 440 | { |
| 441 | shmid = atoi(argv[++i]); if(shmid < 0) usage(argv); |
| 442 | } |
| 443 | else if(!stricmp(argv[i], "-test")) test = true; |
| 444 | else if(!stricmp(argv[i], "-ppid") && i < argc - 1) |
| 445 | { |
| 446 | ppid = atoi(argv[++i]); if(ppid <= 0) usage(argv); |
| 447 | } |
| 448 | else usage(argv); |
| 449 | } |
| 450 | if(darg[0] && darg[1]) |
| 451 | { |
| 452 | argv[1] = darg[0]; argv[2] = darg[1]; argc = 3; |
| 453 | } |
| 454 | else argc = 1; |
| 455 | |
| 456 | if(test) |
| 457 | { |
| 458 | if(!(_fconfig = fconfig_getinstance())) |
| 459 | THROW("Could not allocate FakerConfig"); |
| 460 | fl_open_display(); |
| 461 | fconfig_setdefaultsfromdpy(fl_display); |
| 462 | fconfig_print(fconfig); |
| 463 | } |
| 464 | else |
| 465 | { |
| 466 | if(shmid == -1) usage(argv); |
| 467 | if((_fconfig = (FakerConfig *)shmat(shmid, 0, 0)) == (FakerConfig *)-1) |
| 468 | THROW_UNIX(); |
| 469 | if(!_fconfig) |
| 470 | THROW("Could not attach to config structure in shared memory"); |
| 471 | } |
| 472 | |
| 473 | init(argc, argv); |
| 474 | if(ppid > 0) Fl::add_check(checkParentPID); |
| 475 | status = Fl::run(); |
| 476 | } |
| 477 | catch(std::exception &e) |
| 478 | { |
| 479 | vglout.print("Error in vglconfig--\n%s\n", e.what()); |
| 480 | status = -1; |
| 481 | } |
| 482 | if(_fconfig) |
| 483 | { |
nothing calls this directly
no test coverage detected