1 /*
2 Copyright (C) Thorsten Kukuk <kukuk@suse.de> 2009
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation in version 2 of the License.
7 */
8
9 #ifdef HAVE_CONFIG_H
10 # include <config.h>
11 #endif
12
13 #include <stdio.h>
14 #include <string.h>
15
16 #include "pam_misc.c"
17
18 /* Simple program to see if _pam_mkargv() would succeed. */
19 int main(void)
20 {
21 static const char argvstring[] = "user = XENDT\\userα user=XENDT\\user1";
22 static const char * const argvresult[] = {"user", "=", "XENDT\\userα",
23 "user=XENDT\\user1"};
24 int myargc;
25 char **myargv;
26 int argvlen;
27 int explen;
28 int i;
29
30 explen = sizeof(argvstring) * ((sizeof(char)) + sizeof(char *));
31 argvlen = _pam_mkargv(argvstring, &myargv, &myargc);
32
33 #if 0
34 printf ("argvlen=%i, argc=%i", argvlen, myargc);
35 for (i = 0; i < myargc; i++) {
36 printf(", argv[%d]=%s", i, myargv[i]);
37 }
38 printf ("\n");
39 #endif
40
41 if (argvlen != explen)
42 return 1;
43
44 if (myargc != 4)
45 return 1;
46
47 for (i = 0; i < 4; i++)
48 {
49 if (strcmp (myargv[i], argvresult[i]) != 0)
50 return 1;
51 }
52
53 return 0;
54 }