3 * Copyright (C) 2002 Simone Piccardi
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 /****************************************************************
22 * Program to read system parameters
24 * Author: Simone Piccardi
27 * Usage: getparam -h give all info's
29 ****************************************************************/
31 * Include needed headers
34 #include <errno.h> /* error definitions and routines */
35 #include <stdlib.h> /* C standard library */
36 #include <unistd.h> /* unix standard library */
37 #include <string.h> /* C strings library */
38 #include <limits.h> /* system limits constants, types and functions */
39 #include <stdio.h> /* standard I/O library */
40 #include <time.h> /* date and time constants, types and functions */
43 /* Table of constants for sysconf() */
44 char *sc_names[]={"_SC_ARG_MAX",
56 int sc_argument[]={_SC_ARG_MAX,
69 Set the defined[] array to true if the macro is defined else set it
70 to false and define the macro to -1 as a marker
100 #define NGROUPS_MAX -1
106 #define TZNAME_MAX -1
119 /* values of stadard macros */
120 long values[]={ARG_MAX,
132 /* Help printing routine */
135 int main(int argc, char *argv[])
138 * Variables definition
142 * Input section: decode command line parameters
143 * Use getopt function
145 opterr = 0; /* don't want writing to stderr */
146 while ( (i = getopt(argc, argv, "h")) != -1) {
151 case 'h': /* help option */
152 printf("Wrong -h option use\n");
156 case '?': /* unrecognized options */
157 printf("Unrecognized options -%c\n",optopt);
159 default: /* should not reached */
163 /* ***********************************************************
165 * Options processing completed
167 * Main code beginning
169 * ***********************************************************/
170 if ( (argc-optind) != 1 ) {
171 printf("From %d arguments, removed %d options\n", argc, optind);
174 for (i=0; i<=4; i++) {
175 printf("Response for %s is %ld, values is %ld\n", names[i],
176 sysconf(argument[i]), values[i]);
181 * routine to print usage info and exit
184 printf("Program getparam : test fopen for a file \n");
186 printf(" getparam [-h] parameter \n");
187 printf(" -h print this help\n");