%% options copyright owner = Dirk Krause copyright year = 2011-2014 license = bsd %% header #if DK3_HAVE_OPENSSL_RAND_H #include #endif /** Handler function to process one configuration line. @param o Object to modify during processing. @param k Key found in the line. @param v Value found in the line or NULL if no value was found. @return 1 on success, 0 on error (can continue), -1 on error (abort). */ typedef int dkt_conf_fct_t(void *o, dkChar const *k, dkChar const *v); #ifdef __cplusplus extern "C" { #endif /** Print current working directory. @param app Application structure. @param sn Section name for configuration file. @param msg Messages. @param kwnl Keywords, not localized. @return 0 on success or other exit code on errors. */ int dkt_cwd( dk3_app_t *app, dkChar const *sn, dkChar const * const *msg, dkChar const * const *kwnl ); /** Sort texts line by line. @param app Application structure. @param sn Section name for configuration file. @param msg Messages. @param kwnl Keywords, not localized. @return 0 on success or other exit code on errors. */ int dkt_sort( dk3_app_t *app, dkChar const *sn, dkChar const * const *msg, dkChar const * const *kwnl ); /** List specified files. @param app Application structure. @param sn Section name for configuration file. @param msg Message texts. @param kwnl Keywords, not localized. @return Exit status code. */ int dkt_ls( dk3_app_t *app, dkChar const *sn, dkChar const * const *msg, dkChar const * const *kwnl ); /** Read configuration file section. @param app Application structure. @param sn Section name. @param obj Object to store information. @param fct Function to process key/value pair. */ void dkt_tool_read_conf( dk3_app_t *app, dkChar const *sn, void *obj, dkt_conf_fct_t *fct ); /** Find encoding. @param app Application structure. @param enc Pointer to encoding variable. @param val Text containing encoding. @param de Default encoding. @return 1 on success, 0 on error. */ int dkt_tool_set_encoding( dk3_app_t *app, int *enc, dkChar const *val, int de ); /** Perform checksum or checksize command. @param app Application structure. @param sn Section name for configuration file. @param msg Localized messages. @param kwnl Keywords, not localized. @param what Flag: Run for checksum (0) or checksize (1). @return Exit status code. */ int dkt_check( dk3_app_t *app, dkChar const *sn, dkChar const * const *msg, dkChar const * const *kwnl, int what ); /** Run the "uid" sub-command. @param app Application structure for diagnostics. @param sn Section name for configuration file. @param msg Localized messages. @param kwnl Keywords, not localized. @return Exit status code. */ int dkt_uid( dk3_app_t *app, dkChar const *sn, dkChar const * const *msg, dkChar const * const *kwnl ); /** Run the "tape" sub-command. @param app Application structure for diagnostics. @param sn Section name for configuration file. @param msg Localized messages. @param kwnl Keywords, not localized. @return Exit status code. */ int dkt_tape( dk3_app_t *app, dkChar const *sn, dkChar const * const *msg, dkChar const * const *kwnl ); /** Run the "tape-report" sub-command. @param app Application structure for diagnostics. @param sn Section name for configuration file. @param msg Localized messages. @param kwnl Keywords, not localized. @return Exit status code. */ int dkt_tapereport( dk3_app_t *app, dkChar const *sn, dkChar const * const *msg, dkChar const * const *kwnl ); /** Run the "tapeset" sub-command. @param app Application structure for diagnostics. @param sn Section name for configuration file. @param msg Localized messages. @param kwnl Keywords, not localized. @return Exit status code. */ int dkt_tapeset( dk3_app_t *app, dkChar const *sn, dkChar const * const *msg, dkChar const * const *kwnl ); /** Run the "dkt blocksize" sub-command. @param app Application structure for diagnostics. @param sn Section name for configuration file. @param msg Localized messages. @param kwnl Keywords, not localized. @return Exit status code. */ int dkt_blocksize( dk3_app_t *app, dkChar const *sn, dkChar const * const *msg, dkChar const * const *kwnl ); /** Run the "dkt hex" sub-command. @param app Application structure for diagnostics. @param sn Section name for configuration file. @param msg Localized messages. @param kwnoloc Not localized keywords. @param f_oct Flag: Show contents octal. @return Exit status code. */ int dkt_hex( dk3_app_t *app, dkChar const *sn, dkChar const * const *msg, dkChar const * const *kwnoloc, int f_oct ); /** Create password suggestions. @param app Application structure. @param sn Section name for configuration file. @param msg Localized messages. @param kwnoloc Keywords, not localized. @return Exit status code. */ int dkt_create_password( dk3_app_t *app, dkChar const *sn, dkChar const * const *msg, dkChar const * const *kwnoloc ); /** Convert standard input, file or cmd argument to LaTeX. @param app Application structure. @param sn Section name for configuration file. @param msg Localized messages. @param kwnoloc Keywords, not localized. @return Exit status code. */ int dkt_lat( dk3_app_t *app, dkChar const *sn, dkChar const * const *msg, dkChar const * const *kwnoloc ); /** Conversion to HTML (dkt html). @param app Application structure. @param sn Section name for configuration file. @param msg Localized texts. @param kwnl Keywords, not localized. */ int dkt_html( dk3_app_t *app, dkChar const *sn, dkChar const * const *msg, dkChar const * const *kwnl ); /** Cat file(s). @param app Application structure. @param sn Configuration file section name. @param msg Localized texts. @param kwnl Keywords, not localized. */ int dkt_cat( dk3_app_t *app, dkChar const *sn, dkChar const * const *msg, dkChar const * const *kwnl ); /** Create password. @param app Application structure. @param sn Configuration file section name. @param msg Localized texts. @param kwnl Keywords, not localized. */ int dkt_crp( dk3_app_t *app, dkChar const *sn, dkChar const * const *msg, dkChar const * const *kwnl ); /** Show help text file(s). @param app Application structure. @param sn Configuration file section name. @param msg Localized texts. @param kwnl Keywords, not localized. @param htp Help topic index. */ int dkt_help( dk3_app_t *app, dkChar const *sn, dkChar const * const *msg, dkChar const * const *kwnl, int htp ); /** Find message digest type and digest encoding. @param jmdt Pointer to result variable for digest type. @param jmde Pointer to result variable for digest encoding. @param exval Pointer to exit status code variable. @param txt Text to inspect. @param app Application structure for diagnostics. @param msg Message array for diagnostics. @param verb Flag: Verbose. @return 1 on success, 0 on error. */ int dkt_tool_set_md_type( int *jmdt, int *jmde, int *exval, dkChar const *txt, dk3_app_t *app, dkChar const * const *msg, int verb ); /** Set size_t value from string. @param rp Pointer to result variable. @param src String containing the value. @param msg Localized text messages for diagnostics. @param kwnl Non-localized keywords for diagnostics. @param app Application structure for diagnostics. @param exc Pointer to exit code variable. @return 1 on success, 0 on error. */ int dkt_tool_set_size( size_t *rp, dkChar const *src, dkChar const * const *msg, dkChar const * const *kwnl, dk3_app_t *app, int *exc ); /** Run the "dkt erase-disk" sub-command. @param app Application structure for diagnostics. @param sn Section name for configuration file. @param msg Localized messages. @param kwnl Not localized keywords. @return Exit status code. */ int dkt_ed( dk3_app_t *app, dkChar const *sn, dkChar const * const *msg, dkChar const * const *kwnl ); /** Run the "dkt random" sub-command. @param app Application structure for diagnostics. @param sn Section name for configuration file. @param msg Localized messages. @param kwnl Not localized keywords. @return Exit status code. */ int dkt_rnd( dk3_app_t *app, dkChar const *sn, dkChar const * const *msg, dkChar const * const *kwnl ); #ifdef __cplusplus } #endif /** @defgroup dktresult Exit codes for dkt. */ /**@{*/ /** Result: No error occured. */ #define DKT_RESULT_OK 0 /** Error: Unspecific error. */ #define DKT_RESULT_ERR_UNSPECIFIC 1 /** Error: Aborted by signal. */ #define DKT_RESULT_ERR_SIGNAL 2 /** Error: Illegal/unknown option or problem in configuration file. */ #define DKT_RESULT_ERR_OPTION 3 /** Error: getcwd() failed. */ #define DKT_RESULT_ERR_GETCWD 4 /** Error: Memory allocation failed. */ #define DKT_RESULT_ERR_MEMORY 5 /** Error: Failed to open one of the input files. */ #define DKT_RESULT_ERR_FOPEN 6 /** Error: No such file. */ #define DKT_RESULT_ERR_FILENAME 7 /** Error: Checksum or size mismatch. */ #define DKT_RESULT_ERR_MISMATCH 8 /** Error: Failed to create or write output. */ #define DKT_RESULT_ERR_OUTPUT 9 /** Error: The PRNG was unable to deliver enough bytes. */ #define DKT_RESULT_ERR_PRNG 10 /** Error: Invalid input (Input can't be processed). */ #define DKT_RESULT_ERR_INPUT 11 /** Error: Mathematical overflow. */ #define DKT_RESULT_ERR_MATH_OVERFLOW 12 /** Error: Failed to open directory. */ #define DKT_RESULT_ERR_OPENDIR 13 /** Error: Functionality not supported on this system. */ #define DKT_RESULT_ERR_UNSUPPORTED 14 /** Error: Status code from command execution indicates error. */ #define DKT_RESULT_ERR_SYSEXEC 15 /**@}*/ /** @defgroup dktsortcrit Sort criteria for "dkt sort". */ /**@{*/ /** Sort criteria: Normal text search. */ #define DKT_SORT_NORMAL 0 /** Sort criteria: Sort by leading integer. */ #define DKT_SORT_INTEGER 1 /** Sort criteria: Sort by leading unsigned integer. */ #define DKT_SORT_UNSIGNED 2 /** Sort criteria: Sort by leading double. */ #define DKT_SORT_DOUBLE 3 /** Sort criteria mask. */ #define DKT_SORT_CRITERIA_MASK 7 /** Normalize strings before comparison. */ #define DKT_SORT_NORMALIZE 8 /** Ignore leading whitespaces. */ #define DKT_SORT_IGNORE_LWHS 16 /** Do exact comparison. */ #define DKT_SORT_EXACT 32 /** Merge equal strings. */ #define DKT_SORT_MERGE 64 /** Invert search order. */ #define DKT_SORT_INVERT 128 /** Case insensitve comparisons. */ #define DKT_SORT_CASEINS 256 /** Show lines without value before lines with value. */ #define DKT_SORT_NOVALUE_FIRST 512 /**@}*/ /** @defgroup dktsortmerge Merge criteria for "dkt sort". */ /**@{*/ /** No line merging. */ #define DKT_SORT_MERGE_NONE 0 /** Merge lines evaluating equally. */ #define DKT_SORT_MERGE_EQUAL 1 /** Merge lines exactly equally. */ #define DKT_SORT_MERGE_EXACT 2 /**@}*/ /** @defgroup pwclasses Password classes. */ /**@{*/ /** Simple password. */ #define DKT_PWCLASS_SIMPLE 0 /** Hexadecimal characters. */ #define DKT_PWCLASS_HEX 1 /** ASCII-85 set password. */ #define DKT_PWCLASS_A85 2 /**@}*/ /** Default line size for the sort component. */ #define DKT_SORT_LINE_SIZE ((size_t)4096U) /** Size of builtin buffer for dkt blocksize. */ #define DKT_BLOCKSIZE_OUTPUT_SIZE ((size_t)4096) /** Size of builtin buffer for dkt latex. */ #define DKT_LATEX_LINE_SIZE ((size_t)4096U) /** Line size for dkt html. */ #define DKT_HTML_LINE_SIZE ((size_t)4096U) /** Size for long options */ #define DKT_LONGOPT_LINE_SIZE ((size_t)256) /** Maximum length for password. */ #define DKT_PASSWORD_MAXLENGTH 4096 /** Line size for dkt tapeset. */ #define DKT_TS_LINE_SIZE 1024 /** Buffer size for dkt ed. */ #define DKT_ED_BUFFER_SIZE ((size_t)16384U) /** Buffer size for dkt random. */ #define DKT_RND_BUFFER_SIZE ((size_t)16384U) /** For allocation of string pointer arrays. */ typedef dkChar const *DKT_PDKCHAR; %% module #include "dk3all.h" #include "dkt-version.h" #include "dkt.h" #if DK3_HAVE_OPENSSL_MD5_H || DK3_HAVE_OPENSSL_SHA_H || DK3_HAVE_OPENSSL_RIPEMD_H || DK3_HAVE_OPENSSL_RAND_H #ifdef DK3_SHOW_OPENSSL_LICENSE #undef DK3_SHOW_OPENSSL_LICENSE #endif /** Flag: Print OpenSSL license also when asked for license terms. */ #define DK3_SHOW_OPENSSL_LICENSE 1 #endif $!trace-include /** Application group name. */ static dkChar const dkt_group_name[] = { dkT("dkt-3") }; /** Localized texts. */ static dkChar const * const dkt_message_texts[] = { $!string-table file=dkt3.str,macro=dkT # # 0: Error: Options -i and -p are exclusive! # Options -i and -p are exclusive! # # 1: Error: Input contains characters outside ISO-LATIN-1! # Input contains characters outside ISO-LATIN-1! # # 2: Error: Options -n, -u, and -f are exclusive! # Options -n, -u and -f are exclusive! # # 3: Error: Options -w and -b are exclusive! # Options -w and -b are exclusive! # # 4: Error: Options -e and -m are exclusive! # Options -e and -m are exclusive! # # 5/6: Error: Illegal file type specification "..."! # Illegal file type specification: " "! # # 7: Error: Missing message digest type name! # Missing message digest type name! # # 8/9: Error: Message digest type name "..." too long! # Message digest type name too long!: " "! # # 10/11: Error: Illegal symlink depth "..."! # Illegal symlink depth: " "! # # 12: Text: Directories: # Directories: # # 13: Text: Files: # Files: # # 14: Text: Bytes: # Bytes: # # 15/16: Error: Block size too large: "..."! # Block size too large: " "! # # 17: Text: OK # OK # # 18: Text: FAILED! # FAILED! # # 19: Error: Options -v and -q are exclusive! # Options -v and -q are exclusive! # # 20: Error: Missing message digest name! # Missing message digest name! # # 21/22: Error: Unknown control instruction "..."! # Unknown control instruction " "! # # 23/24: Error: Not a regular file: "..."! # Not a regular file: " "! # # 25: Error: No filename specified! # No filename specified! # # 26: Error: There were failed tests! # There were failed tests! # # 27: Error: Syntax - Not a "dkt tape" file! # Syntax error, not a "dkt tape" file! # # 28: Notice: Backup period completed. # Backup period (200 times) completed.\nPlease change media set! # # 29: Error: No set names found! # No set names in line! # # 30: Error: Too many input lines! # Too many input lines! # # FREE 31: Error: Syntax error in input file! # Syntax error in input file! # # 32: Error: Options -e and -x are exclusive! # Options -e and -x are exclusive! # # 33/34: Not LaTeX encoding found for "..."! # No LaTeX encoding found for " "! # # 35/36: Error: Not a hexadecimal number: "..."! # Not a hexadecimal number: " "! # # 37/38: Error: Unknown command "..."! # Unknown command " "! # # 39: Error: No command specified! # No command specified! # # 40: Error: Missing range specification! # Missing range specification! # # 41/42: Error: Unknown password type "..."! # Unknown password type " "! # # 43: Error: Missing class name! # Missing class name! # # 44: Error: Missing configuration text! # Missing configuration text! # # 45: Error: Missing configuration text! # Missing configuration text! # # 46/47: Error: Line too long: "..."! # Line too long: " "! # # 48/49: Error: No such class: "..."! # No such class: " "! # # 50: Error: Inconsistent password class setup! # Inconsistent password class setup! # # 51: Error: Invalid range for upper-case characters! # Invalid range for number of upper-case characters! # # 52: Error: Invalid range for special characters! # Invalid range for number of special characters! # # 53: Error: Invalid range for digits! # Invalid range for number digits! # # 54: Error: Invalid range for length! # Invalid range for length! # # 55: Error: Length too large! # Password length too large! # # 56: Error: Function not supported by system! # Function is not supported on this system! # # 57: Error: Command not available on Windows systems! # This command is not available on Windows systems! # # 58: Error: No maximum UID specified! # Missing maximum UID! # # 59: Error: No minimum UID specified! # Missing minimum UID! # # 60: Error: No UID available in the specified range! # No free user ID available in the specified range! # # 61: Error: Invalid buffer size! # Invalid buffer size! # # 62: Error: Options -i and -d are exclusive! # Options -i and -d are exclusive! # # 63/64: Error: Unknown option "..."! # Illegal option " "! # # 65 # Options -f and -p are exclusive! # # 66 # Option -f requires an argument! # # 67, 68 # Unknown subcommand " "! # # 69 # Too few arguments for command! # # 70 # Error in command line options! # # 71 # Current tape: # # 72 # (previous cycle) # # 73, 74 Problem with backslash escape sequences. # Probably a problem with backslash escape sequences. When using C:\\ in quotes, you probably must use "C:\\\\",\nnot "C:\\". # # 75 # Option -l ignored, can not be used in conjunction with -e! # # 76 # Too many text lines, only 999 allowed! $!end }; /** String table file name. */ static dkChar const dkt_string_table_file_name[] = { dkT("dkt3.str") }; /** Keywords, not localized. */ static dkChar const * const dkt_kw_no_loc[] = { $!string-table macro=dkT # # 0 # %u # # 1 # %lf # # 2 # unlimited # # 3 # mtpn # # 4 # . # # 5 # \# message digest = # # 6 # ------------------- # # 7 # 0 # # 8 # 0000-00-00 # # 9 # 00:00:00 # # 10 # .bck # # 11 # user,type=simple,length=6-8,digits=1-2,specials=1-2,upper-case=1-2 # # 12 # admin,type=ascii-85,length=10-12 # # 13 # wpa,type=hex,length=32 # # 14 # user # # 15 Used in dkt ls for invalid UFI on Windows # -------------------------- # # 16 Used in dkt ls for invalid UFI on *x, 8 byte dk3_um_t # --------------------------------- # # 17 Used in dkt ls for invalid UFI on *x, 4 byte dk3_um_t # ----------------- $!end }; /** Commands. */ static dkChar const * const dkt_commands[] = { /* 0 */ dkT("blocksize"), /* 1 */ dkT("blks"), /* 2 */ dkT("checksum"), /* 3 */ dkT("cs"), /* 4 */ dkT("create-password"), /* 5 */ dkT("crp"), /* 6 */ dkT("pwd"), /* 7 */ dkT("hex"), /* 8 */ dkT("hexadecimal"), /* 9 */ dkT("octal"), /* 10 */ dkT("oct"), /* 11 */ dkT("html"), /* 12 */ dkT("ht"), /* 13 */ dkT("latex"), /* 14 */ dkT("lat"), /* 15 */ dkT("ls"), /* 16 */ dkT("sort"), /* 17 */ dkT("tape-set"), /* 18 */ dkT("ts"), /* 19 */ dkT("tape"), /* 20 */ dkT("uid"), /* 21 */ dkT("help"), /* 22 */ dkT("--help"), /* 23 */ dkT("version"), /* 24 */ dkT("--version"), /* 25 */ dkT("license-terms"), /* 26 */ dkT("--license-terms"), /* 27 */ dkT("cat"), /* 28 */ dkT("checksize"), /* 29 */ dkT("erase-disk"), /* 30 */ dkT("ed"), /* 31 */ dkT("random"), /* 32 */ dkT("rand"), /* 33 */ dkT("rnd"), /* 34 */ dkT("license"), /* 35 */ dkT("--license"), /* 36 */ dkT("-L"), /* 37 */ dkT("-h"), /* 38 */ dkT("-v"), /* 39 */ dkT("tape-report"), /* 40 */ dkT("tr"), NULL }; /** Version number string. */ static dkChar const dkt_version[] = { dkT("dkt ") DKT_VERSION }; /** Licensing overview, list of all sources. */ static dkChar const * const dkt_overview_license[] = { dkT("This software uses code from the following projects either directly"), dkT("or as a library:"), dkT(""), dkT("dktools\t\tDirk Krause's tools and libraries."), dkT("\t\tSee http://dktools.sourceforge.net for more information."), dkT("OpenSSL\t\tCryptographic toolkit implementing the Secure Sockets Layer"), dkT("\t\tprotocols and related cryptography standards required"), dkT("\t\tby them."), dkT("\t\tSee http://www.openssl.org for more information."), dkT(""), dkT(""), NULL }; /** License terms for the dktools project itself. */ static dkChar const * const dkt_license[] = { $!text macro=dkT License for the dktools project =============================== Copyright (c) 2011-2013, Dirk Krause All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder(s) nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. $!end }; /** License terms for teh OpenSSL library. */ static dkChar const * const dkt_openssl_license[] = { $!text macro=dkT OpenSSL library license ======================= The OpenSSL toolkit stays under a dual license, i.e. both the conditions of the OpenSSL License and the original SSLeay license apply to the toolkit. See below for the actual license texts. Actually both licenses are BSD-style Open Source licenses. In case of any license issues related to OpenSSL please contact openssl-core@openssl.org. OpenSSL License --------------- Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. All advertising materials mentioning features or use of this software must display the following acknowledgment: "This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact openssl-core@openssl.org. 5. Products derived from this software may not be called "OpenSSL" nor may "OpenSSL" appear in their names without prior written permission of the OpenSSL Project. 6. Redistributions of any form whatsoever must retain the following acknowledgment: "This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org/)" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ==================================================================== This product includes cryptographic software written by Eric Young (eay@cryptsoft.com). This product includes software written by Tim Hudson (tjh@cryptsoft.com). Original SSLeay License ----------------------- Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) All rights reserved. This package is an SSL implementation written by Eric Young (eay@cryptsoft.com). The implementation was written so as to conform with Netscapes SSL. This library is free for commercial and non-commercial use as long as the following conditions are aheared to. The following conditions apply to all code found in this distribution, be it the RC4, RSA, lhash, DES, etc., code; not just the SSL code. The SSL documentation included with this distribution is covered by the same copyright terms except that the holder is Tim Hudson (tjh@cryptsoft.com). Copyright remains Eric Young's, and as such any Copyright notices in the code are not to be removed. If this package is used in a product, Eric Young should be given attribution as the author of the parts of the library used. This can be in the form of a textual message at program startup or in documentation (online or textual) provided with the package. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: "This product includes cryptographic software written by Eric Young (eay@cryptsoft.com)" The word 'cryptographic' can be left out if the rouines from the library being used are not cryptographic related :-). 4. If you include any Windows specific code (or a derivative thereof) from the apps directory (application code) you must include an acknowledgement: "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The licence and distribution terms for any publically available version or derivative of this code cannot be changed. i.e. this code cannot simply be copied and put under another distribution licence [including the GNU Public Licence.] $!end }; /** The main() function. @param argc Number of command line arguments. @param argv Command line arguments array. @return 0 on success, any other value indicates an error. */ DK3_MAIN { dk3_app_t *app = NULL; dkChar const * const *msg = NULL; /* Localized messages. */ int exval = DKT_RESULT_ERR_UNSPECIFIC; /* Exit code. */ int xargc; /* Cmd arguments number. */ int htp = -1; /* Help topic. */ dkChar const * const *xargv; /* Cmd arguments array. */ $!trace-init dkt.deb $? "+ main" #if DK3_HAVE_TZSET tzset(); #endif app = dk3app_open_command( argc, (dkChar const * const *)argv, dkt_group_name ); if(app) { msg = dk3app_messages( app, dkt_string_table_file_name, (dkChar const **)dkt_message_texts ); xargc = dk3app_get_argc(app); xargv = dk3app_get_argv(app); if(xargc > 1) { switch(dk3str_array_index(dkt_commands, xargv[1], 0)) { case 0: case 1: { $? ". blocksize" exval = dkt_blocksize(app, dkt_commands[0], msg, dkt_kw_no_loc); } break; case 2: case 3: { $? ". checksum" exval = dkt_check(app, dkt_commands[2], msg, dkt_kw_no_loc, 0); } break; case 4: case 5: { $? ". create password" exval = dkt_crp(app, dkt_commands[4], msg, dkt_kw_no_loc); } break; case 6: { $? ". pwd" exval = dkt_cwd(app, dkt_commands[6], msg, dkt_kw_no_loc); } break; case 7: case 8: { $? ". hex" exval = dkt_hex(app, dkt_commands[7], msg, dkt_kw_no_loc, 0); } break; case 9: case 10: { $? ". octal" exval = dkt_hex(app, dkt_commands[7], msg, dkt_kw_no_loc, 1); } break; case 11: case 12: { $? ". html" exval = dkt_html(app, dkt_commands[11], msg, dkt_kw_no_loc); } break; case 13: case 14: { $? ". latex" exval = dkt_lat(app, dkt_commands[13], msg, dkt_kw_no_loc); } break; case 15: { $? ". ls" exval = dkt_ls(app, dkt_commands[15], msg, dkt_kw_no_loc); } break; case 16: { $? ". sort" exval = dkt_sort(app, dkt_commands[16], msg, dkt_kw_no_loc); } break; case 17: case 18: { $? ". tape-set" exval = dkt_tapeset(app, dkt_commands[17], msg, dkt_kw_no_loc); } break; case 19: { $? ". tape" exval = dkt_tape(app, dkt_commands[19], msg, dkt_kw_no_loc); } break; case 39: case 40: { exval = dkt_tapereport(app, dkt_commands[39], msg, dkt_kw_no_loc); } break; case 20: { $? ". uid" dkt_uid(app, dkt_commands[20], msg, dkt_kw_no_loc); } break; case 21: case 22: case 37: { $? ". help" if(xargc > 2) { htp = dk3str_array_index(dkt_commands, xargv[2], 0); } exval = dkt_help(app, dkt_commands[21], msg, dkt_kw_no_loc, htp); } break; case 23: case 24: case 38: { $? ". version" dk3sf_initialize_stdout(); dk3sf_fputs(dkt_version, stdout); dk3sf_fputc(dkT('\n'), stdout); } break; case 25: case 26: case 34: case 35: case 36: { dkChar const * const *sptr; $? ". license" sptr = dkt_overview_license; dk3sf_initialize_stdout(); while(*sptr) { dk3sf_fputs(*(sptr++), stdout); dk3sf_fputc(dkT('\n'), stdout); } sptr = dkt_license; while(*sptr) { dk3sf_fputs(*(sptr++), stdout); dk3sf_fputc(dkT('\n'), stdout); } #if DK3_SHOW_OPENSSL_LICENSE sptr = dkt_openssl_license; while(*sptr) { dk3sf_fputs(*(sptr++), stdout); dk3sf_fputc(dkT('\n'), stdout); } #endif } break; case 27: { exval = dkt_cat(app, dkt_commands[27], msg, dkt_kw_no_loc); } break; case 28: { exval = dkt_check(app, dkt_commands[28], msg, dkt_kw_no_loc, 1); } break; case 29: case 30: { exval = dkt_ed(app, dkt_commands[29], msg, dkt_kw_no_loc); } break; case 31: case 32: case 33: { exval = dkt_rnd(app, dkt_commands[31], msg, dkt_kw_no_loc); } break; default: { dk3app_log_3(app, DK3_LL_ERROR, msg, 37, 38, xargv[1]); exval = dkt_help(app, dkt_commands[21], msg, dkt_kw_no_loc, htp); } break; } } else { dk3app_log_1(app, DK3_LL_ERROR, msg, 39); /* Print help. */ exval = dkt_help(app, dkt_commands[21], msg, dkt_kw_no_loc, htp); } dk3app_close(app); } else { /* ERROR: Memory */ fputs("dkt: ERROR: Not enough memory!\n", stderr); fflush(stderr); } $? "- main %d", exval $!trace-end fflush(stdout); exit(exval); return exval; } /* vim: set ai sw=2 : */