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