getconf.c (119025) | getconf.c (119312) |
---|---|
1/* 2 * Copyright 2000 Massachusetts Institute of Technology 3 * 4 * Permission to use, copy, modify, and distribute this software and 5 * its documentation for any purpose and without fee is hereby 6 * granted, provided that both the above copyright notice and this 7 * permission notice appear in all copies, that both the above 8 * copyright notice and this permission notice appear in all --- 14 unchanged lines hidden (view full) --- 23 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 26 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> | 1/* 2 * Copyright 2000 Massachusetts Institute of Technology 3 * 4 * Permission to use, copy, modify, and distribute this software and 5 * its documentation for any purpose and without fee is hereby 6 * granted, provided that both the above copyright notice and this 7 * permission notice appear in all copies, that both the above 8 * copyright notice and this permission notice appear in all --- 14 unchanged lines hidden (view full) --- 23 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 26 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: head/usr.bin/getconf/getconf.c 119025 2003-08-17 10:33:54Z tjr $"); | 31__FBSDID("$FreeBSD: head/usr.bin/getconf/getconf.c 119312 2003-08-22 17:32:07Z markm $"); |
32 33#include <sys/types.h> 34 35#include <err.h> 36#include <errno.h> 37#include <stdio.h> 38#include <stdlib.h> 39#include <sysexits.h> --- 93 unchanged lines hidden (view full) --- 133 name); 134 } 135 return 0; 136} 137 138static void 139do_confstr(const char *name, int key) 140{ | 32 33#include <sys/types.h> 34 35#include <err.h> 36#include <errno.h> 37#include <stdio.h> 38#include <stdlib.h> 39#include <sysexits.h> --- 93 unchanged lines hidden (view full) --- 133 name); 134 } 135 return 0; 136} 137 138static void 139do_confstr(const char *name, int key) 140{ |
141 char *buf; | |
142 size_t len; 143 144 len = confstr(key, 0, 0); 145 if (len == (size_t)-1) 146 err(EX_OSERR, "confstr: %s", name); 147 | 141 size_t len; 142 143 len = confstr(key, 0, 0); 144 if (len == (size_t)-1) 145 err(EX_OSERR, "confstr: %s", name); 146 |
148 if (len == 0) { | 147 if (len == 0) |
149 printf("undefined\n"); | 148 printf("undefined\n"); |
150 } else { 151 buf = malloc(len); 152 if (buf != NULL) { 153 confstr(key, buf, len); 154 printf("%s\n", buf); 155 free(buf); 156 } 157 else 158 err(EX_OSERR, "malloc: confstr"); | 149 else { 150 char buf[len + 1]; 151 152 confstr(key, buf, len); 153 printf("%s\n", buf); |
159 } 160} 161 162static void 163do_sysconf(const char *name, int key) 164{ 165 long value; 166 --- 25 unchanged lines hidden --- | 154 } 155} 156 157static void 158do_sysconf(const char *name, int key) 159{ 160 long value; 161 --- 25 unchanged lines hidden --- |