1 /* usage.c */
2 /* ########################### */
3 /* #           rpl           # */
4 /* #     by Joe Laffey       # */
5 /* # joe@laffeycomputer.com  # */
6 /* #                         # */
7 /* ########################### */
8 
9 /*
10  # Last Modified:  $Date: 2008/04/24 13:05:46 $
11  # by:             $Author: joe $
12 */
13 
14 
15 /*  rpl v1.4.1 by Joe Laffey, LAFFEY Computer Imaging. 							*/
16 /*  Visit http://www.laffeycomputer.com for updates 								*/
17 /*  This software is copyright 1998, 1999, 2000, 2001 by Joe Laffey.   				*/
18 
19 /*  Permission is granted to any individual, institution, or company to use, 		*/
20 /*  copy, or redistribute rpl in source code or binary form so long as it is 		*/
21 /*  not modified in any way (beyond modifications required to compile or */
22 /*  "package"), and it is not sold by itself for a profit. 							*/
23 /*  Permission is also granted to bundle rpl in software distributions which 		*/
24 /*  are sold for a profit (e.g. CD-ROMs, etc.), as long as there are at least 		*/
25 /*  ten programs included in the distribution.  									*/
26 /*  In other words, please do NOT release updates or modified verions yourself.     */
27 /*  If you modify the source code and would like to see your changes incorporated 	*/
28 /*  please submit your source code to software@laffeycomputer.com 					*/
29 /*  Please report bugs to that address as well. 									*/
30 
31 /*  rpl IS PROVIDED AS IS AND COMES WITH NO WARRANTY OF ANY KIND, EITHER EXPRESSED 	*/
32 /*  OR IMPLIED. IN NO EVENT WILL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES 	*/
33 /*  RESULTING FROM THE USE OF THIS SOFTWARE. 										*/
34 
35 
36 
37 #include <sysexits.h>
38 #include <stdio.h>
39 #include <stdlib.h>
40 
41 #include "suffix.h"
42 
43 
44 /*****************************/
45 /*  Print out what we can do */
usage(void)46 void usage(void)
47 {
48 	fprintf(stderr, "------------------------------------------------\n");
49 	fprintf(stderr, PACKAGE " " VERSION  " by Joe Laffey, LAFFEY Computer Imaging.\n");
50 	fprintf(stderr, "Visit http://www.laffeycomputer.com/ for updates.\n");
51 	fprintf(stderr, "This software comes with ABSOLUTELY NO WARRANTY. rpl -L for license.\n");
52     fprintf(stderr, "Usage:  rpl [-iwRspfdtxe [-q | -v] ] <old_string> <new_string> <target_file(s)>\n");
53 	fprintf(stderr, "        ( Put strings in single quotes (\') )\n");
54 	fprintf(stderr, "        -i   Ignore case of old_string\n");
55 	fprintf(stderr, "        -w   Whole words (old_string bounded by white space in file)\n");
56 	fprintf(stderr, "        -q   Quiet mode (no output at all)\n");
57 	fprintf(stderr, "        -v   Verbose mode (lots of output)\n");
58 	fprintf(stderr, "        -R   Search directories recursively\n");
59 	fprintf(stderr, "        -x   Specify file suffix to match (e.g. '.html')\n");
60 	fprintf(stderr, "             Only files with this suffix will be searched.\n");
61 	fprintf(stderr, "             You may specify up to %d suffixes. (e.g. -x'.html' -x'.jsp' ...)\n",MAX_SUFFIXES);
62 	fprintf(stderr, "        -p   Prompt to modify each file\n");
63 	fprintf(stderr, "        -s   Simulation mode (lists files that would be changed)\n");
64 	fprintf(stderr, "        -e   Honor string Escapes in old_string and new_string\n");
65 	fprintf(stderr, "             (e.g.'\\n', '\\r', '\\\\', '\\015' (octal), '0x0d' (hex) etc.)\n");
66 	fprintf(stderr, "        -f   Force overwriting files when permissions cannot be matched\n");
67 	fprintf(stderr, "        -d   Don't change modification times of altered files\n");
68 	fprintf(stderr, "        -t   Use value of $TMPDIR for temp files instead of original file dir\n");
69 	fprintf(stderr, "        -L   Display the software license\n");
70 	fprintf(stderr, "        -h   Display this help screen\n");
71 	fprintf(stderr, "Returns: 0 on success, system error code on failure.\n");
72 	fprintf(stderr, "Note: If you are using a \"-\" in either the old_string or then ew_string\n");
73 	fprintf(stderr, "      you must put a \"--\" as your last option before the strings.\n");
74 	exit(EX_USAGE);
75 }
76 
77 
78 
79 /*****************************/
80 /*  Print out the license */
License(void)81 void License(void)
82 {
83 	fprintf(stderr, "------------------------------------------------\n");
84 	fprintf(stderr, PACKAGE " " VERSION " by Joe Laffey, LAFFEY Computer Imaging.\n");
85 	fprintf(stderr, "Visit http:// www.laffeycomputer.com/ for updates.\n");
86 	fprintf(stderr, "This software is copyright 1998, 1999, 2000, 2001 by Joe Laffey.\n\n");
87 
88 	fprintf(stderr, "Permission is granted to any individual, institution, or company to use, copy,\n");
89 	fprintf(stderr, "or redistribute rpl in source code or binary form so long as it is not\n");
90 	fprintf(stderr, "modified in any way (beyond modifications required to compile or \"package\"),\n");
91 	fprintf(stderr, "and it is not sold by itself for profit.\n\n");
92 
93 	fprintf(stderr, "Permission is also granted to bundle rpl in software distributions which\n");
94 	fprintf(stderr, "are sold for a profit (e.g. CD-ROMs, etc.), as long as there are at least \n");
95 	fprintf(stderr, "ten programs included in the distribution.\n\n");
96 
97 	fprintf(stderr, "If you modify the source code and would like to see your changes incorporated\n");
98 	fprintf(stderr, "please submit your source code to software@laffeycomputer.com\n");
99 	fprintf(stderr, "Please report bugs to that address as well.\n\n");
100 
101 	fprintf(stderr, "rpl IS PROVIDED AS IS AND COMES WITH NO WARRANTY OF ANY KIND, EITHER EXPRESSED\n");
102 	fprintf(stderr, "OR IMPLIED;  without even the implied warranty of MERCHANTABILITY or FITNESS\n");
103 	fprintf(stderr, "FOR A PARTICULAR PURPOSE. IN NO EVENT WILL THE COPYRIGHT HOLDERS OR\n");
104 	fprintf(stderr, "CONTRIBUTORS BE LIABLE FOR ANY DAMAGES RESULTING FROM THE USE OF THIS SOFTWARE.\n\n");
105 
106 
107 	exit(EX_USAGE);
108 }
109 
110 
111 
112