From owner-freebsd-questions@FreeBSD.ORG Wed Nov 24 17:48:56 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 37FE61065698 for ; Wed, 24 Nov 2010 17:48:56 +0000 (UTC) (envelope-from demelier.david@gmail.com) Received: from mail-bw0-f54.google.com (mail-bw0-f54.google.com [209.85.214.54]) by mx1.freebsd.org (Postfix) with ESMTP id BA41A8FC27 for ; Wed, 24 Nov 2010 17:48:55 +0000 (UTC) Received: by bwz2 with SMTP id 2so81800bwz.13 for ; Wed, 24 Nov 2010 09:48:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=ZtNk2yk2cjOtU7FyyDaSEPhpzusKA+5/CQ2ebNzLZL0=; b=qh6QaAHO1XIb3ker2FA7WOMTHr3yMISEkK4ugIV5yjvD5fYe5Bn4ATPq4cMgHsthPo rNa4DY2z0tuJqtLBA86uNgy1z1IOEbcTzoJ51MGPGVyCROt98qkR690nEfsIhzPNifod JittFuznm5HcaKQtdD8tLbFGy+n1uTkRXg9JA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=Ds90wXOr1i+V7tdkR5DeHN0+P7D/W/yVwurYa1zpmtHnM77ykjQx8RvaB11+TpkQpy BvlvNch0Y9ObejQC+p92J7nUlv3c40qcOnwOBiFlSXdUfuAMka1fifuH6Ucm5in4JzV/ aali/ajF3kwA/63OE0vGF0sKz4hMQPE6YKUYY= MIME-Version: 1.0 Received: by 10.204.129.210 with SMTP id p18mr9146690bks.85.1290620846997; Wed, 24 Nov 2010 09:47:26 -0800 (PST) Received: by 10.204.127.20 with HTTP; Wed, 24 Nov 2010 09:47:08 -0800 (PST) Date: Wed, 24 Nov 2010 18:47:08 +0100 Message-ID: From: David DEMELIER To: FreeBSD Questions Content-Type: text/plain; charset=UTF-8 Subject: trying to sysctl(3) a char value X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Nov 2010 17:48:56 -0000 Hello, Since I cannot adjust the brightness on my HP Probook because it sucks I'm writing a small script that can be use instead. I need to sysctl the following sysctl variables : hw.acpi.video.lcd0.brightness hw.acpi.video.lcd0.levels the -brightness one is easy since it's an integer, but the levels is possibly a char : markand@Melon ~ $ sysctl hw.acpi.video.lcd0.brightness hw.acpi.video.lcd0.brightness: 90 markand@Melon ~ $ sysctl hw.acpi.video.lcd0.levels hw.acpi.video.lcd0.levels: 100 50 0 5 10 15 20 25 30 33 36 40 43 46 50 55 60 65 70 75 80 83 86 90 93 96 100 How can I store the content of hw.acpi.video.lcd0.levels? This small code doesn't work : #include #include #include #include int main(int argc, char *argv[]) { char buf[128]; size_t len; len = sizeof (buf); if (sysctlbyname("hw.acpi.video.lcd0.levels", &buf, &len, NULL, 0) == -1) { perror("sysctl"); return -1; } printf("levels = %s\n", buf); } markand@Melon ~ $ ./a.out levels = d Kind regards, -- Demelier David