Показать сообщение отдельно

  #2  
Старый 27.07.2009, 20:52
fker
Участник форума
Регистрация: 26.11.2008
Сообщений: 158
Провел на форуме:
2816163

Репутация: 158
По умолчанию

getopt

пример из сорцев нетката:
Код:
while ((x = getopt (argc, argv, "ade:g:G:hi:lLno:p:rs:tuvw:z")) != EOF) {
/* Debug (("in go: x now %c, optarg %x optind %d", x, optarg, optind)) */
    switch (x) {
      case 'a':
	bail ("all-A-records NIY");
	o_alla++; break;
#ifdef GAPING_SECURITY_HOLE
      case 'e':				/* prog to exec */
	pr00gie = optarg;
	break;
#endif
	        case 'L':				/* listen then cycle back to start instead of exiting */
	o_listen++; 
  	cycle = 1;
	  break;


        case 'd':				/* detach from console */
  	FreeConsole();;
	  break;


      case 'G':				/* srcrt gateways pointer val */
	x = atoi (optarg);
	if ((x) && (x == (x & 0x1c)))	/* mask off bits of fukt values */
	  gatesptr = x;
	else
	  bail ("invalid hop pointer %d, must be multiple of 4 <= 28", x);
	break;
      case 'g':				/* srcroute hop[s] */
	if (gatesidx > 8)
	  bail ("too many -g hops");

Последний раз редактировалось fker; 27.07.2009 в 21:16.. Причина: поспешил с ответом
 
Ответить с цитированием