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

Last change on this file since 2999 was 2999, checked in by jrm21, 22 years ago

Need to use namespace for gcc3. We now #include gsdlconf as well, so needed
to add gsdlhome/lib to includes.

  • Property svn:keywords set to Author Date Id Revision
File size: 2.4 KB
RevLine 
[1493]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
[2999]26#define _XOPEN_SOURCE 1
27/* following is for solaris */
28#define _XOPEN_SOURCE_EXTENDED 1
29
30#include "gsdlconf.h"
31
32// use the standard namespace
33#if !defined (GSDL_NAMESPACE_BROKEN)
34#if defined(GSDL_USE_OBJECTSPACE)
35using namespace ospace::std;
36#else
37using namespace std;
38#endif
39#endif
40
41
[1493]42// include crypt
43#if defined(__WIN32__)
44#include "crypt.h"
45#else
[2276]46
47#include "config.h"
[1493]48#if defined(HAVE_CRYPT_H)
49#include <crypt.h>
[2276]50#endif
51
52#if defined(HAVE_UNISTD_H)
[1493]53#include <unistd.h>
54#endif
[2276]55/* we are probably in trouble if we have neither crypt.h or unistd.h,
56 but for now we'll do nothing about it... */
[1493]57
[2276]58#endif /* not WIN32 */
59
[1600]60#if defined(GSDL_USE_OBJECTSPACE)
61# include <ospace\std\iostream>
62#elif defined(GSDL_USE_IOS_H)
63# include <iostream.h>
64#else
65# include <iostream>
66#endif
67
[1493]68#include <string.h>
69#include <pwd.h>
70
71int main (int argc, char *argv[]) {
72
73 char c[10];
74 while (1) {
75 char *a = getpass("Enter password:");
76 int len = strlen (a);
77 if (len < 3 || len > 8) {
78 cerr << "Password must be between 3 and 8 characters long. Try again\n";
79 continue;
80 }
81 strcpy (c, a);
82 char *b = getpass("Re-enter password:");
83 if ((strcmp (c, b)) == 0) break;
84 else cerr << "Passwords didn't match. Try again.\n";
85 }
86
87 char *salt = "Tp";
88 char *pw = crypt (c, salt);
89
90 cout << pw << "\n";
91
92 return 0;
93}
Note: See TracBrowser for help on using the repository browser.