File: check.c

package info (click to toggle)
cracklib2 2.9.6-3.4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 3,220 kB
  • sloc: sh: 11,843; ansic: 2,652; xml: 365; python: 288; makefile: 216; sed: 16
file content (50 lines) | stat: -rw-r--r-- 957 bytes parent folder | download | duplicates (7)
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
/*
 * This program is copyright Alec Muffett 1993, portions copyright other authors.
 * The authors disclaim all responsibility or liability with respect to it's usage
 * or its effect upon hardware or computer systems.
 */

#include <stdio.h>
#include <limits.h>
#include <string.h>
#include <locale.h>

#define IN_CRACKLIB
#include "config.h"
#include "crack.h"
#include "packer.h"

int
main(int argc, char **argv)
{
	char buf[LINE_MAX];
	const char *why;
	int i;

	setlocale(LC_ALL, "");

#ifdef ENABLE_NLS
	textdomain(PACKAGE);
#endif

	while (fgets(buf, sizeof(buf), stdin) != NULL) {
		while (((i = strlen(buf)) > 0) && (i > 0)) {
			if (strchr("\r\n", buf[i - 1]) != NULL) {
				buf[i - 1] = '\0';
				i--;
			} else {
				break;
			}
		}
		why = FascistCheck(buf,
				   argc > 1 ?
				   argv[1] :
				   NULL);
		if ((why != NULL) && (strlen(why) > 0)) {
			printf("%s: %s\n", buf, why);
		} else {
			printf("%s: OK\n", buf);
		}
	}
	return 0;
}