Exemple #1
0
int
main (int argc, char **argv)
{
  register int c;
  int errflg;
  int function;
  u_short portnum;
  static const struct option long_options[] = {
    { "help", no_argument, NULL, 'H' },
    { "version", no_argument, NULL, 'V' },
    { NULL, 0, NULL, 0 }
  };

  setlocale (LC_ALL, "");
  textdomain (_libc_intl_domainname);

  function = NONE;
  portnum = 0;
  errflg = 0;
  while ((c = getopt_long (argc, argv, "ptubdn:", long_options, NULL)) != -1)
    {
      switch (c)
	{

	case 'p':
	  if (function != NONE)
	    errflg = 1;
	  else
	    function = PMAPDUMP;
	  break;

	case 't':
	  if (function != NONE)
	    errflg = 1;
	  else
	    function = TCPPING;
	  break;

	case 'u':
	  if (function != NONE)
	    errflg = 1;
	  else
	    function = UDPPING;
	  break;

	case 'b':
	  if (function != NONE)
	    errflg = 1;
	  else
	    function = BRDCST;
	  break;

	case 'n':
	  portnum = (u_short) atoi (optarg);	/* hope we don't get bogus # */
	  break;

	case 'd':
	  if (function != NONE)
	    errflg = 1;
	  else
	    function = DELETES;
	  break;

	case 'H':
	  usage (stdout);
	  return 0;

	case 'V':
	  print_version ();
	  return 0;

	case '?':
	  errflg = 1;
	}
    }

  if (errflg || function == NONE)
    {
      usage (stderr);
      return 1;
    }

  switch (function)
    {

    case PMAPDUMP:
      if (portnum != 0)
	{
	  usage (stderr);
	  return 1;
	}
      pmapdump (argc - optind, argv + optind);
      break;

    case UDPPING:
      udpping (portnum, argc - optind, argv + optind);
      break;

    case TCPPING:
      tcpping (portnum, argc - optind, argv + optind);
      break;

    case BRDCST:
      if (portnum != 0)
	{
	  usage (stderr);
	  return 1;
	}
      brdcst (argc - optind, argv + optind);
      break;

    case DELETES:
      deletereg (argc - optind, argv + optind);
      break;
    }

  return 0;
}
Exemple #2
0
int
main (int argc, char **argv)
{
  register int c;
  int errflg;
  int function;
  u_short portnum;

#ifndef __MINT__
  setlocale (LC_ALL, "");
  textdomain (_libc_intl_domainname);
#endif

  function = NONE;
  portnum = 0;
  errflg = 0;
  while ((c = getopt (argc, argv, "ptubdn:")) != -1)
    {
      switch (c)
	{

	case 'p':
	  if (function != NONE)
	    errflg = 1;
	  else
	    function = PMAPDUMP;
	  break;

	case 't':
	  if (function != NONE)
	    errflg = 1;
	  else
	    function = TCPPING;
	  break;

	case 'u':
	  if (function != NONE)
	    errflg = 1;
	  else
	    function = UDPPING;
	  break;

	case 'b':
	  if (function != NONE)
	    errflg = 1;
	  else
	    function = BRDCST;
	  break;

	case 'n':
	  portnum = (u_short) atoi (optarg);	/* hope we don't get bogus # */
	  break;

	case 'd':
	  if (function != NONE)
	    errflg = 1;
	  else
	    function = DELETES;
	  break;

	case '?':
	  errflg = 1;
	}
    }

  if (errflg || function == NONE)
    {
      usage ();
      return 1;
    }

  switch (function)
    {

    case PMAPDUMP:
      if (portnum != 0)
	{
	  usage ();
	  return 1;
	}
      pmapdump (argc - optind, argv + optind);
      break;

    case UDPPING:
      udpping (portnum, argc - optind, argv + optind);
      break;

    case TCPPING:
      tcpping (portnum, argc - optind, argv + optind);
      break;

    case BRDCST:
      if (portnum != 0)
	{
	  usage ();
	  return 1;
	}
      brdcst (argc - optind, argv + optind);
      break;

    case DELETES:
      deletereg (argc - optind, argv + optind);
      break;
    }

  return 0;
}
Exemple #3
0
int
main(int argc, char **argv)
{
	register int c;
	extern char *optarg;
	extern int optind;
	int errflg;
	int function;
	u_short portnum;

	function = NONE;
	portnum = 0;
	errflg = 0;
	while ((c = getopt(argc, argv, "ptubdn:")) != -1) {
		switch (c) {

		case 'p':
			if (function != NONE)
				errflg = 1;
			else
				function = PMAPDUMP;
			break;

		case 't':
			if (function != NONE)
				errflg = 1;
			else
				function = TCPPING;
			break;

		case 'u':
			if (function != NONE)
				errflg = 1;
			else
				function = UDPPING;
			break;

		case 'b':
			if (function != NONE)
				errflg = 1;
			else
				function = BRDCST;
			break;

		case 'n':
			portnum = (u_short) atoi(optarg);   /* hope we don't get bogus # */
			break;

		case 'd':
			if (function != NONE)
				errflg = 1;
			else
				function = DELETES;
			break;

		case '?':
			errflg = 1;
		}
	}

	if (errflg || function == NONE) {
		usage();
		return (1);
	}

	switch (function) {

	case PMAPDUMP:
		if (portnum != 0) {
			usage();
			return (1);
		}
		pmapdump(argc - optind, argv + optind);
		break;

	case UDPPING:
		udpping(portnum, argc - optind, argv + optind);
		break;

	case TCPPING:
		tcpping(portnum, argc - optind, argv + optind);
		break;

	case BRDCST:
		if (portnum != 0) {
			usage();
			return (1);
		}
		brdcst(argc - optind, argv + optind);
		break;

	case DELETES:
		deletereg(argc - optind, argv + optind);
		break;
	}

	return (0);
}