Example #1
0
int main(int argc, String argv[]) {
  /* Handle a plea for help */
  if (argc == 1) {
    printUsage(argv[0]);
    exit(1);
  }

  /* Parse xPL & program command line parms */
  if (!xPL_parseCommonArgs(&argc, argv, FALSE)) exit(1);
  if (!parseCmdLine(&argc, argv)) exit(1);

  /* Ensure we have a class */
  if ((msgSchemaClass == NULL) || (msgSchemaType == NULL)) {
    fprintf(stderr, "The -c schema class.type is REQUIRED\n");
    exit(1);
  }

  /* Start xPL up */
  if (!xPL_initialize(xPL_getParsedConnectionType())) {
    fprintf(stderr, "Unable to start xPL");
    exit(1);
  }

  /* Parse the source */
  if (!parseSourceIdent()) exit(1);

  /* Parse the target */
  if (!parseTargetIdent()) exit(1);

  /* Send the message */
  if (!sendMessage(argc, argv)) exit(1);
  return 0;
}
Example #2
0
void parseCommandLineArgs(int argc, char **argv) {     
  char c;
 if (!xPL_parseCommonArgs(&argc, argv, FALSE)) exit(1);

  while ((c = getopt (argc, argv, "fvh")) != -1)
    switch (c)  {
      case 'f':
        foregroundOption = 1;
        break;        
      case 'v':
        verboseLevel++;
        break;             
      case 'h':
        fprintf (stderr, "usage:\n\t-f start in foreground \n\t-v enable verbose you cannot use more than vvvvv in daemon mode");
        fprintf (stderr, "\n\t-interface lo/eth0/... the network interface where xpl is listening");
        fprintf (stderr, "\n\t-xpldebug anable xpl debugging\n");
  
        exit(0);
      case '?':
        if (isprint (optopt))
          fprintf (stderr, "Unknown option `-%c'.\n", optopt);
        else
          fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt);
        exit(0);        
//      default:
//        return 1;
    }
  }     
Example #3
0
int main(int argc, String argv[]) {

	/* Parse command line parms */
	if (!xPL_parseCommonArgs(&argc, argv, FALSE)) {
		exit(1);
	}

	/* Start xPL up */
	if (!xPL_initialize(xPL_getParsedConnectionType())) {
		fprintf(stderr, "Unable to start xPL");
		exit(1);
	}
	
	/* Parse Hub command arguments */
	if (!parseCmdLine(&argc, argv)) {
		printUsage(argv[0]);
		exit(1);
	}

	if (daemonMode) {
		switch (fork()) {
			case 0: /* child */
				/* No io in child mode */
				close(fileno(stdin));
				close(fileno(stdout));
				close(fileno(stderr));
				setpgrp();

				startServer();
				break;
			case -1: /* error */
				fprintf(stderr, "Unable to spawn daemon, %s (%d)\n", strerror(errno), errno);
				exit(1);
		}
	} else {
		startServer();
	}
	return 0;
}