xref: /illumos-gate/usr/src/lib/pam_modules/authtok_check/stringlib.c (revision 86d949f9497332fe19be6b5d711d265eb957439f)
1 /*
2  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*
7  * This program is copyright Alec Muffett 1993. The author disclaims all
8  * responsibility or liability with respect to it's usage or its effect
9  * upon hardware or computer systems, and maintains copyright as set out
10  * in the "LICENCE" document which accompanies distributions of Crack v4.0
11  * and upwards.
12  */
13 
14 #include "packer.h"
15 
16 
17 char
18 Chop(register char *string)
19 {
20 	register char c;
21 	register char *ptr;
22 
23 	c = '\0';
24 
25 	for (ptr = string; *ptr; ptr++);
26 	if (ptr != string) {
27 		c = *(--ptr);
28 		*ptr = '\0';
29 	}
30 	return (c);
31 }
32 
33 char
34 Chomp(register char *string)
35 {
36 	register char c;
37 	register char *ptr;
38 
39 	c = '\0';
40 
41 	for (ptr = string; *ptr; ptr++)
42 		;
43 	if (ptr != string && isspace(*(--ptr))) {
44 		c = *ptr;
45 		*ptr = '\0';
46 	}
47 	return (c);
48 }
49 
50 
51 char *
52 Trim(register char *string)
53 {
54 	register char *ptr;
55 
56 	for (ptr = string; *ptr; ptr++);
57 
58 	while ((--ptr >= string) && isspace(*ptr));
59 
60 	*(++ptr) = '\0';
61 
62 	return (ptr);
63 }
64