From owner-freebsd-current@FreeBSD.ORG Tue Nov 25 20:03:50 2008 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 69A0C1065673 for ; Tue, 25 Nov 2008 20:03:50 +0000 (UTC) (envelope-from spikey.it@gmail.com) Received: from gv-out-0910.google.com (gv-out-0910.google.com [216.239.58.188]) by mx1.freebsd.org (Postfix) with ESMTP id E300B8FC21 for ; Tue, 25 Nov 2008 20:03:49 +0000 (UTC) (envelope-from spikey.it@gmail.com) Received: by gv-out-0910.google.com with SMTP id n8so70367gve.39 for ; Tue, 25 Nov 2008 12:03:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:mime-version :subject:date:references:x-mailer; bh=rWexJ03Lex56CIJafRCHB2GZu6+62czcHvWPeBunxRc=; b=KeIsQ2tQy3CE/qyaetCL8+1LI6gXDLhESNAgB47NWYCDKeLAI6o/VTQMQzDEPgVxOo +8bSL/ajcdnNtwu+tfcKORDaR7aJkR5DzYX3+q/gK8jsCTU3ArabO0abHxf7L7vHs5Xs AJeigbclc3mBOD7M4Y9YxoTsei472yTIllP4M= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:in-reply-to:content-type :content-transfer-encoding:mime-version:subject:date:references :x-mailer; b=uNlFtJaxuEXLZQzAVqszZQZgcaWcWNK21bEuZ1AAMN8xJuep5hzB/UI9AdXFTLBkb2 fBVXeQZwNWotiocmmoJEry1ohMQY5IwQmTgik3ckicu6YSqToLVcm5hUHT6kiCjQoVNG Zmvai+xa8Yf8QrYEtTuXazMAsub19aSXFV+Is= Received: by 10.103.244.4 with SMTP id w4mr1771855mur.11.1227643428432; Tue, 25 Nov 2008 12:03:48 -0800 (PST) Received: from manson.homenet.telecomitalia.it (host99-3-dynamic.44-79-r.retail.telecomitalia.it [79.44.3.99]) by mx.google.com with ESMTPS id 23sm8330185mum.38.2008.11.25.12.03.46 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 25 Nov 2008 12:03:47 -0800 (PST) Message-Id: From: Andrea Di Pasquale To: freebsd-current@freebsd.org In-Reply-To: <492C360B.8080304@freebsd.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Apple Message framework v929.2) Date: Tue, 25 Nov 2008 21:03:44 +0100 References: <5D9F392B-97B5-4812-B5CB-047193715A94@gmail.com> <492C360B.8080304@freebsd.org> X-Mailer: Apple Mail (2.929.2) Subject: Re: Options handler for userspace programs X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Nov 2008 20:03:50 -0000 Yes but getopt() and getopt() are limited. They can to handle only 2 options type, character and word. My idea is a main type that handle all. For example, Long options: Short options: interface i -interface -i --interface --i Both they can use one or two flag front the option. For example: optarg_t opts[] =3D { {"interface", "--i", OPT_REQARG1}, {"--filter", "f", OPT_REQARG2}, {"-typed", "t", OPT_REQOPT}, {"-status", NULL, OPT_OPTARG1}, {"status", "-s", OPT_OPTARG2}, {NULL, "--v", OPT_NOARG}, {"help", "h", OPT_NOARG}, {NULL, NULL, OPT_NULL} }; and optarg_t is: typedef enum optflag { OPT_NOARG, /* no arguments */ OPT_REQARG1, /* required argument */ OPT_REQARG2, /* required two arguments */ OPT_REQOPT, /* required argument with 2=B0 optional =20= argument */ OPT_OPTARG1, /* optional argument */ OPT_OPTARG2, /* optional two arguments */ OPT_NULL } optflag_t; typedef struct optarg { const char *opt_name; /* option's name */ const char *opt_alias; /* option's alias */ optflag_t opt_flag; } optarg_t; Thank you, regards Andrea Tim Kientzle wrote: > Have you looked at getopt_long, which is in the standard > FreeBSD C libraries? > > man 3 getopt_long > > The use of getopt() in most utilities instead of getopt_long() > is a very deliberate choice. > > Tim Kientzle > > > Andrea Di Pasquale wrote: >> Hi! I seen that all freebsd' s programs use getopt() or sequence =20 >> options with arguments. >> I wanna to propose new options handler that handle name or alias =20 >> for options and >> option's argument, example no argument, required one or two =20 >> arguments, required >> argument with 2=B0 option argument and one or two optional arguments. >> Can it useful for freebsd? >> Regards, >> Andrea_______________________________________________ >> freebsd-current@freebsd.org mailing list >> http://lists.freebsd.org/mailman/listinfo/freebsd-current >> To unsubscribe, send any mail to = "freebsd-current-unsubscribe@freebsd.org=20 >> " >