3 * Copyright (C) 2001 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 rename
24 * Author: Simone Piccardi
27 * Usage: testrem -h give all info's
29 ****************************************************************/
31 * Include needed headers
33 #include <errno.h> /* error definitions and routines */
34 #include <stdlib.h> /* C standard library */
35 #include <unistd.h> /* unix standard library */
36 #include <stdio.h> /* standard I/O library */
37 #include <string.h> /* C strings library */
39 /* Help printing routine */
42 int main(int argc, char *argv[])
45 * Variables definition
50 * Input section: decode command line parameters
55 opterr = 0; /* don't want writing to stderr */
56 while ( (i = getopt(argc, argv, "h")) != -1) {
61 case 'h': /* help option */
62 printf("Wrong -h option use\n");
66 case '?': /* unrecognized options */
67 printf("Unrecognized options -%c\n",optopt);
69 default: /* should not reached */
73 /* ***********************************************************
75 * Options processing completed
79 * ***********************************************************/
80 /* There must be 2 remaing parameters */
81 if ( (argc-optind) != 2 ) {
82 printf("From %d arguments, removed %d options\n", argc, optind);
85 if ( rename(argv[optind], argv[optind+1]) ) {
86 copy = strerror_r(errno, NULL, 0);
87 perror("cannot rename");
93 * routine to print usage info and exit
96 printf("Program testren : test renaming of file/directories \n");
98 printf(" testrem [-h] fileorig filedest \n");
99 printf(" -h print this help\n");