Line data Source code
1 : /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2 : * Copyright (C) 2014 Frediano Ziglio
3 : *
4 : * This library is free software; you can redistribute it and/or
5 : * modify it under the terms of the GNU Library General Public
6 : * License as published by the Free Software Foundation; either
7 : * version 2 of the License, or (at your option) any later version.
8 : *
9 : * This library is distributed in the hope that it will be useful,
10 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 : * Library General Public License for more details.
13 : *
14 : * You should have received a copy of the GNU Library General Public
15 : * License along with this library; if not, write to the
16 : * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 : * Boston, MA 02111-1307, USA.
18 : */
19 : #undef NDEBUG
20 : #include <config.h>
21 :
22 : #include <stdio.h>
23 :
24 : #if HAVE_STDLIB_H
25 : #include <stdlib.h>
26 : #endif /* HAVE_STDLIB_H */
27 :
28 : #ifdef HAVE_UNISTD_H
29 : #include <unistd.h>
30 : #endif
31 :
32 : #if HAVE_STRING_H
33 : #include <string.h>
34 : #endif /* HAVE_STRING_H */
35 :
36 : #include <assert.h>
37 :
38 : #include <freetds/sysdep_private.h>
39 : #include <freetds/utils.h>
40 :
41 8 : int main(void)
42 : {
43 : FILE *f;
44 8 : char *pwd = strdup("password");
45 : char *p;
46 :
47 8 : p = tds_getpassarg(pwd);
48 8 : assert(p);
49 8 : assert(strcmp(pwd, "********") == 0);
50 8 : assert(strcmp(p, "password") == 0);
51 8 : free(p);
52 8 : free(pwd);
53 :
54 8 : f = fopen("passarg.in", "w");
55 8 : assert(f);
56 8 : fputs("line1pwd\nline2pwd\n", f);
57 8 : fclose(f);
58 :
59 8 : f = freopen("passarg.in", "r", stdin);
60 8 : assert(f);
61 :
62 8 : p = tds_getpassarg("-");
63 8 : assert(p);
64 8 : assert(strcmp(p, "line1pwd") == 0);
65 8 : free(p);
66 :
67 8 : unlink("passarg.in");
68 :
69 : return 0;
70 : }
71 :
|