4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
38 char options
[] = "s:d:";
45 (void) fprintf(stderr
, "%s: Fatal error: %s. Database not remade.\n",
53 (void) fprintf(stderr
,
54 "usage: %s [-s dict1,...,dictn ] [-d dest-path ]\n", pname
);
59 main(int argc
, char *argv
[])
61 char *default_dbdst
= NULL
;
62 char *default_dbsrc
= NULL
;
71 (void) setlocale(LC_ALL
, "");
73 if ((pname
= strrchr(argv
[0], '/')) == NULL
)
78 if (defopen(PWADMIN
) == 0) {
79 if ((p
= defread("DICTIONLIST=")) != NULL
)
80 default_dbsrc
= strdup(p
);
81 if ((p
= defread("DICTIONDBDIR=")) != NULL
)
82 default_dbdst
= strdup(p
);
86 if (default_dbdst
== NULL
)
87 default_dbdst
= CRACK_DIR
;
89 while ((c
= getopt(argc
, argv
, options
)) != EOF
) {
93 dbsrc_len
+= strlen(optarg
) + 2; /* ',' + \0 */
94 if ((dbsrc
= realloc(dbsrc
, dbsrc_len
)) == NULL
)
95 fatal(strerror(errno
));
96 (void) strlcat(dbsrc
, ",", dbsrc_len
);
97 (void) strlcat(dbsrc
, optarg
, dbsrc_len
);
99 if ((dbsrc
= strdup(optarg
)) == NULL
)
100 fatal(strerror(errno
));
101 dbsrc_len
= strlen(optarg
) + 1;
116 (void) fprintf(stderr
,
117 gettext("%s: using default database location: %s.\n"),
118 pname
, default_dbdst
);
119 dbdst
= default_dbdst
;
123 if ((dbsrc
= default_dbsrc
) == NULL
)
124 fatal(gettext("No source databases defined"));
126 (void) fprintf(stderr
,
127 gettext("%s: using default dictionary list: %s.\n"),
128 pname
, default_dbsrc
);
130 if ((result
= lock_db(dbdst
)) == 0) {
132 result
= build_dict_database(dbsrc
, dbdst
);
136 fatal(strerror(errno
));