summaryrefslogtreecommitdiff
path: root/usr/src/lib/pam_modules/authtok_check/stringlib.c
blob: 9027af41a9380ab9858a663fcfa96c78bc8fc781 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#pragma ident	"%Z%%M%	%I%	%E% SMI"

/*
 * This program is copyright Alec Muffett 1993. The author disclaims all
 * responsibility or liability with respect to it's usage or its effect
 * upon hardware or computer systems, and maintains copyright as set out
 * in the "LICENCE" document which accompanies distributions of Crack v4.0
 * and upwards.
 */

#include "packer.h"


char
Chop(register char *string)
{
	register char c;
	register char *ptr;

	c = '\0';

	for (ptr = string; *ptr; ptr++);
	if (ptr != string) {
		c = *(--ptr);
		*ptr = '\0';
	}
	return (c);
}

char
Chomp(register char *string)
{
	register char c;
	register char *ptr;

	c = '\0';

	for (ptr = string; *ptr; ptr++)
		;
	if (ptr != string && isspace(*(--ptr))) {
		c = *ptr;
		*ptr = '\0';
	}
	return (c);
}


char *
Trim(register char *string)
{
	register char *ptr;

	for (ptr = string; *ptr; ptr++);

	while ((--ptr >= string) && isspace(*ptr));

	*(++ptr) = '\0';

	return (ptr);
}