source: trunk/gsdl/src/getpw/getpw.cpp@ 2832

Last change on this file since 2832 was 2276, checked in by jrm21, 23 years ago

changes to include the right header files, and toplevel config.h

  • Property svn:keywords set to Author Date Id Revision
File size: 2.2 KB
Line 
1/**********************************************************************
2 *
3 * getpw.cpp --
4 * A component of the Greenstone digital library software
5 * from the New Zealand Digital Library Project at the
6 * University of Waikato, New Zealand.
7 *
8 * Copyright (C) 2000 The New Zealand Digital Library Project
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 **********************************************************************/
25
26// include crypt
27#if defined(__WIN32__)
28#include "crypt.h"
29#else
30
31#define _XOPEN_SOURCE 1
32/* following is for solaris */
33#define _XOPEN_SOURCE_EXTENDED 1
34
35#include "config.h"
36#if defined(HAVE_CRYPT_H)
37#include <crypt.h>
38#endif
39
40#if defined(HAVE_UNISTD_H)
41#include <unistd.h>
42#endif
43/* we are probably in trouble if we have neither crypt.h or unistd.h,
44 but for now we'll do nothing about it... */
45
46#endif /* not WIN32 */
47
48#if defined(GSDL_USE_OBJECTSPACE)
49# include <ospace\std\iostream>
50#elif defined(GSDL_USE_IOS_H)
51# include <iostream.h>
52#else
53# include <iostream>
54#endif
55
56#include <string.h>
57#include <pwd.h>
58
59int main (int argc, char *argv[]) {
60
61 char c[10];
62 while (1) {
63 char *a = getpass("Enter password:");
64 int len = strlen (a);
65 if (len < 3 || len > 8) {
66 cerr << "Password must be between 3 and 8 characters long. Try again\n";
67 continue;
68 }
69 strcpy (c, a);
70 char *b = getpass("Re-enter password:");
71 if ((strcmp (c, b)) == 0) break;
72 else cerr << "Passwords didn't match. Try again.\n";
73 }
74
75 char *salt = "Tp";
76 char *pw = crypt (c, salt);
77
78 cout << pw << "\n";
79
80 return 0;
81}
Note: See TracBrowser for help on using the repository browser.