From owner-freebsd-hackers@FreeBSD.ORG Sat Aug 6 07:04:09 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4EF1316A41F for ; Sat, 6 Aug 2005 07:04:09 +0000 (GMT) (envelope-from tataz@tataz.chchile.org) Received: from postfix3-2.free.fr (postfix3-2.free.fr [213.228.0.169]) by mx1.FreeBSD.org (Postfix) with ESMTP id E772A43D46 for ; Sat, 6 Aug 2005 07:04:08 +0000 (GMT) (envelope-from tataz@tataz.chchile.org) Received: from tatooine.tataz.chchile.org (vol75-8-82-233-239-98.fbx.proxad.net [82.233.239.98]) by postfix3-2.free.fr (Postfix) with ESMTP id D2FAEC0AA; Sat, 6 Aug 2005 09:04:07 +0200 (CEST) Received: by tatooine.tataz.chchile.org (Postfix, from userid 1000) id AD614405B; Sat, 6 Aug 2005 09:04:23 +0200 (CEST) Date: Sat, 6 Aug 2005 09:04:23 +0200 From: Jeremie Le Hen To: "Thordur I. Bjornsson" Message-ID: <20050806070422.GW45385@obiwan.tataz.chchile.org> References: <20050805005543.5bd947f2.thib@mi.is> <20050805145046.GB78669@dan.emsphone.com> <42F386B2.1010108@samsco.org> <20050805160415.44b0b05e.thib@mi.is> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050805160415.44b0b05e.thib@mi.is> User-Agent: Mutt/1.5.9i Cc: freebsd-hackers@freebsd.org Subject: Re: Checking sysctl values from within the kernel. X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Aug 2005 07:04:09 -0000 Hi Thordur, > PS: If you don't mind, what is a "real accessor function" ? This is a function acting as a wrapper for accessing an integer declared as static. This function must of course live in the same file. This may be something like this, there may exist neater interfaces though : static int age; int age_accessor(int *get, int set) { if (get != NULL) *get = age; else if (set < 0 || set > 125) return -1; else age = set; return 0; } If `get' is not NULL, this means the caller wants to retrieve the current age value. Else, this means the caller wants to set the age value to a new one : if the latter is lower than 0 and greater than 125, this is an incredible age and the accessor reports an error. Else it sets the new value. I hope this helped. Regards, -- Jeremie Le Hen < jeremie at le-hen dot org >< ttz at chchile dot org >