From owner-freebsd-current@FreeBSD.ORG Sun Jan 11 16:04:36 2009 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3C19C106568D for ; Sun, 11 Jan 2009 16:04:36 +0000 (UTC) (envelope-from spikey.it@gmail.com) Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.152]) by mx1.freebsd.org (Postfix) with ESMTP id B3A9C8FC25 for ; Sun, 11 Jan 2009 16:04:35 +0000 (UTC) (envelope-from spikey.it@gmail.com) Received: by fg-out-1718.google.com with SMTP id l26so3496786fgb.35 for ; Sun, 11 Jan 2009 08:04:34 -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 :content-type:mime-version:subject:date:x-mailer; bh=bLIS+Dx/5bGu0UF+W/JsHMFMDlbzSzD+BZSbPWz5+BU=; b=ATEiLsQcEDU3hOHmyS4t5Xk1xXpIJH53P4uIagBW1O8PzN4QtnU8TSWpALC1bPeh4b ccsihshrxebbVwkdco8IuAuMRNYa29SW1pxUk3lANhStDkNCUOLo9TAzAAyThq5cXG6Q KtN3Bu4cbBcqRWy6JnVUMG5+GC+7vvIDoI8fo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:content-type:mime-version:subject:date:x-mailer; b=IAp5Lra9hymOCQ+SBx3NtnvBl2PUNkofUNSHOi0cAKCdFJ6V1Ys+Z7IqOFyzY4iNnf 6UVD+p//fG57k3d2P2X/tYxLSPkuJkFZoRiP0IWzw8XTkSNKjwIe9N8rBuegDfiKKVxU xzDqQ5bEGCN9XP4QyfPk3oFALYSv2DTHLm9u0= Received: by 10.86.80.17 with SMTP id d17mr16141885fgb.14.1231689874354; Sun, 11 Jan 2009 08:04:34 -0800 (PST) Received: from manson.homenet.telecomitalia.it (host185-110-dynamic.53-79-r.retail.telecomitalia.it [79.53.110.185]) by mx.google.com with ESMTPS id 4sm22663899fge.45.2009.01.11.08.04.32 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 11 Jan 2009 08:04:33 -0800 (PST) Message-Id: <354C4317-4471-47A6-9B52-EF53D753D1B8@gmail.com> From: Andrea Di Pasquale To: current@freebsd.org Mime-Version: 1.0 (Apple Message framework v930.3) Date: Sun, 11 Jan 2009 17:04:33 +0100 X-Mailer: Apple Mail (2.930.3) Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Subject: 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: Sun, 11 Jan 2009 16:04:36 -0000 Hi Tim! I written new options parser for argv, string and environment variable. optsscan_argv() /* handle argv */ optsscan_strenv() /* handle string or env var */ They include getopt(), getopt_long() and getopt_long_only() functionalities in two types of functions. So, you can handle only short options, short and long options and only long options, all in two types of functions. Obviously, you can to handle an argument, with this syntax: Short options: -o -o arg -o= arg -o=arg Long options: --option --option argument --option= argument --option=argument Link to tarball: http://jo666.altervista.org/optsscan.tar.gz Here, you can find optsscan code and a main example. Thank you, regards, Andrea