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 test function fopen
24 * Author: Simone Piccardi
27 * Usage: getparam -h give all info's
29 * $Id: getparam.c,v 1.3 2003/05/02 09:55:14 piccardi Exp $
31 ****************************************************************/
33 * Include needed headers
36 #include <errno.h> /* error definitions and routines */
37 #include <stdlib.h> /* C standard library */
38 #include <unistd.h> /* unix standard library */
39 #include <string.h> /* string functions */
44 #include <time.h> /* for CLK_TCK e CLOCKS_PER_SEC */
46 /* Table of constants for sysconf() */
47 char *sc_names[]={"_SC_ARG_MAX",
59 int sc_argument[]={_SC_ARG_MAX,
72 Set the defined[] array to true if the macro is defined else set it
73 to false and define the macro to -1 as a marker
103 #define NGROUPS_MAX -1
109 #define TZNAME_MAX -1
121 /* values of stadard macros */
122 long values[]={ARG_MAX,
134 /* Help printing routine */
137 int main(int argc, char *argv[])
140 * Variables definition
144 * Input section: decode command line parameters
145 * Use getopt function
147 opterr = 0; /* don't want writing to stderr */
148 while ( (i = getopt(argc, argv, "h")) != -1) {
153 case 'h': /* help option */
154 printf("Wrong -h option use\n");
158 case '?': /* unrecognized options */
159 printf("Unrecognized options -%c\n",optopt);
161 default: /* should not reached */
165 /* ***********************************************************
167 * Options processing completed
169 * Main code beginning
171 * ***********************************************************/
172 /* There must be 2 remaing parameters */
173 if ( (argc-optind) != 1 ) {
174 printf("From %d arguments, removed %d options\n", argc, optind);
177 for (i=0; i<=4; i++) {
178 printf("Response for %s is %ld, values is %ld\n", names[i],
179 sysconf(argument[i]), values[i]);
184 * routine to print usage info and exit
187 printf("Program testfopen : test fopen for a file \n");
189 printf(" testfopen [-h] file mode \n");
190 printf(" -h print this help\n");