2N/A * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A * Copyright (c) 1998-2003 Carnegie Mellon University. All rights reserved. 2N/A * Redistribution and use in source and binary forms, with or without 2N/A * modification, are permitted provided that the following conditions 2N/A * 1. Redistributions of source code must retain the above copyright 2N/A * notice, this list of conditions and the following disclaimer. 2N/A * 2. Redistributions in binary form must reproduce the above copyright 2N/A * notice, this list of conditions and the following disclaimer in 2N/A * the documentation and/or other materials provided with the 2N/A * 3. The name "Carnegie Mellon University" must not be used to 2N/A * endorse or promote products derived from this software without 2N/A * prior written permission. For permission or any other legal 2N/A * details, please contact 2N/A * Office of Technology Transfer 2N/A * Carnegie Mellon University 2N/A * 5000 Forbes Avenue 2N/A * Pittsburgh, PA 15213-3890 2N/A * (412) 268-4387, fax: (412) 268-7395 2N/A * tech-transfer@andrew.cmu.edu 2N/A * 4. Redistributions of any form whatsoever must retain the following 2N/A * "This product includes software developed by Computing Services 2N/A * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO 2N/A * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 2N/A * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE 2N/A * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 2N/A * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 2N/A * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 2N/A * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 2N/A#
endif /* !_SUN_SDK_ */ 2N/A /* since the init time might be really bad let's make this lazy */ 2N/A "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????";
2N/A -
1,-
1,-
1,-
1, -
1,-
1,-
1,-
1, -
1,-
1,-
1,-
1, -
1,-
1,-
1,-
1,
2N/A -
1,-
1,-
1,-
1, -
1,-
1,-
1,-
1, -
1,-
1,-
1,-
1, -
1,-
1,-
1,-
1,
2N/A -
1,-
1,-
1,-
1, -
1,-
1,-
1,-
1, -
1,-
1,-
1,
62, -
1,-
1,-
1,
63,
2N/A 52,
53,
54,
55,
56,
57,
58,
59,
60,
61,-
1,-
1, -
1,-
1,-
1,-
1,
2N/A -
1, 0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
2N/A 15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,-
1, -
1,-
1,-
1,-
1,
2N/A -
1,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
2N/A 41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,-
1, -
1,-
1,-
1,-
1 2N/A * inlen -- input data length 2N/A * out -- output buffer (will be NUL terminated) 2N/A * outmax -- max size of output buffer 2N/A * outlen -- gets actual length of output buffer (optional) 2N/A * Returns SASL_OK on success, SASL_BUFOVER if result won't fit 2N/A const unsigned char *
in = (
const unsigned char *)
_in;
2N/A#
endif /* !_SUN_SDK_ */ 2N/A#
endif /* _SUN_SDK_ */ 2N/A /* Do the work... */ 2N/A#
endif /* !_SUN_SDK_ */ 2N/A /* user provided max buffer size; make sure we don't go over it */ 2N/A /* user provided max buffer size; make sure we don't go over it */ 2N/A * inlen -- length of input data 2N/A * out -- output data (may be same as in, must have enough space) 2N/A * outmax -- max size of output buffer 2N/A * outlen -- actual output length 2N/A * SASL_BADPROT on bad base64, 2N/A * SASL_BUFOVER if result won't fit, 2N/A * SASL_OK on success 2N/A /* check parameters */ 2N/A#
endif /* _SUN_SDK_ */ 2N/A /* xxx these necessary? */ 2N/A *
out=0;
/* terminate string */ 2N/A/* make a challenge string (NUL terminated) 2N/A * buf -- buffer for result 2N/A * maxlen -- max length of result 2N/A * hostflag -- 0 = don't include hostname, 1 = include hostname 2N/A * returns final length or 0 if not enough space 2N/A#
endif /* !_SUN_SDK_ */ 2N/A#
endif /* !_SUN_SDK_ */ 2N/A#
endif /* _SUN_SDK_ */ 2N/A + (
2 *
20);
/* 2 numbers, 20 => max size of 64bit 2N/A * ulong in base 10 */ 2N/A#
endif /* _SUN_SDK_ */ 2N/A /* borrowed from larry. probably works :) 2N/A * probably is also in acap server somewhere 2N/A#
endif /* _SUN_SDK_ */ 2N/A /* how many octets? */ 2N/A continue;
/* this is a valid US-ASCII char */ 2N/A if (
seqlen == 0)
continue;
/* this is a valid US-ASCII char */ 2N/A#
endif /* _SUN_SDK_ */ 2N/A if ((
str[++i] &
0xC0) !=
0x80)
2N/A#
endif /* _SUN_SDK_ */ 2N/A * To see why this is really bad see RFC 1750 2N/A * unfortunatly there currently is no way to make 2N/A * cryptographically secure pseudo random numbers 2N/A * without specialized hardware etc... 2N/A * thus, this is for nonce use only 2N/A /* xxx autoconf macro */ 2N/A /* longs are guaranteed to be at least 32 bits; we need 2N/A 16 bits in each short */ 2N/A#
endif /* HAVE_GETTIMEOFDAY */ 2N/A /* if all else fails just use time() */ 2N/A#
endif /* _SUN_SDK_ */ 2N/A#
endif /* _SUN_SDK_ */ 2N/A /* is it acceptable to just use the 1st 3 char's given??? */ 2N/A /* xxx varies by platform */ 2N/A#
endif /* HAVE_JRAND48 */ 2N/A /* init if necessary */ 2N/A#
endif /* HAVE_JRAND48 */ 2N/A/* this function is just a bad idea all around, since we're not trying to 2N/A implement a true random number generator */ 2N/A /* init if necessary */ 2N/A/***************************************************************************** 2N/A * MODULE NAME : GETOPT.C 2N/A * This module contains code made available by IBM 2N/A * Corporation on an AS IS basis. Any one receiving the 2N/A * module is considered to be licensed under IBM copyrights 2N/A * to use the IBM-provided source code in any way he or she 2N/A * deems fit, including copying it, compiling it, modifying 2N/A * it, and redistributing it, with or without 2N/A * modifications. No license under any IBM patents or 2N/A * patent applications is to be implied from this copyright 2N/A * A user of the module should understand that IBM cannot 2N/A * provide technical support for the module and will not be 2N/A * responsible for any consequences of use of the program. 2N/A * Any notices, including this one, are not to be removed 2N/A * from the module without the prior written consent of 2N/A * AUTHOR: Original author: 2N/A * G. R. Blair (BOBBLAIR at AUSVM1) 2N/A * Internet: bobblair@bobblair.austin.ibm.com 2N/A * Extensively revised by: 2N/A * John Q. Walker II, Ph.D. (JOHHQ at RALVM6) 2N/A * Internet: johnq@ralvm6.vnet.ibm.com 2N/A *****************************************************************************/ 2N/A/****************************************************************************** 2N/A * The getopt() function is a command line parser. It returns the next 2N/A * option character in argv that matches an option character in opstring. 2N/A * The argv argument points to an array of argc+1 elements containing argc 2N/A * pointers to character strings followed by a null pointer. 2N/A * The opstring argument points to a string of option characters; if an 2N/A * option character is followed by a colon, the option is expected to have 2N/A * an argument that may or may not be separated from it by white space. 2N/A * The external variable optarg is set to point to the start of the option 2N/A * argument on return from getopt(). 2N/A * The getopt() function places in optind the argv index of the next argument 2N/A * to be processed. The system initializes the external variable optind to 2N/A * 1 before the first call to getopt(). 2N/A * When all options have been processed (that is, up to the first nonoption 2N/A * argument), getopt() returns EOF. The special option "--" may be used to 2N/A * delimit the end of the options; EOF will be returned, and "--" will be 2N/A * The getopt() function returns a question mark (?) when it encounters an 2N/A * option character not included in opstring. This error message can be 2N/A * disabled by setting opterr to zero. Otherwise, it returns the option 2N/A * character that was detected. 2N/A * If the special option "--" is detected, or all options have been 2N/A * processed, EOF is returned. 2N/A * Options are marked by either a minus sign (-) or a slash (/). 2N/A * No errors are defined. 2N/A *****************************************************************************/ 2N/A/* static (global) variables that are specified as exported by getopt() */ 2N/A/* handle possible future character set concerns by putting this in a macro */ 2N/A /* we last left off inside an argv string */ 2N/A /* there is more to come in the most recent argv */ 2N/A /* we didn't leave off in the middle of an argv string */ 2N/A /* more command-line arguments than the argument count */ 2N/A return EOF;
/* used up all command-line arguments */ 2N/A /*--------------------------------------------------------------------- 2N/A * If the next argv[] is not an option, there can be no more options. 2N/A *-------------------------------------------------------------------*/ 2N/A if ((
'/' != *
pArgString) &&
/* doesn't start with a slash or a dash? */ 2N/A --
optind;
/* point to current arg once we're done */ 2N/A return EOF;
/* used up all the command-line flags */ 2N/A /* check for special end-of-flags markers */ 2N/A return EOF;
/* encountered the special flag */ 2N/A /*--------------------------------------------------------------------- 2N/A * Rare case: if opterr is non-zero, return a question mark; 2N/A * otherwise, just return the colon we're on. 2N/A *-------------------------------------------------------------------*/ 2N/A /*--------------------------------------------------------------------- 2N/A * The letter on the command-line wasn't any good. 2N/A *-------------------------------------------------------------------*/ 2N/A /*--------------------------------------------------------------------- 2N/A * The letter on the command-line matches one we expect to see 2N/A *-------------------------------------------------------------------*/ 2N/A /* It is a colon. Look for an argument string. */ 2N/A /*------------------------------------------------------------- 2N/A * The argument string must be in the next argv. 2N/A * But, what if there is none (bad input from the user)? 2N/A * In that case, return the letter, and optarg as NULL. 2N/A *-----------------------------------------------------------*/ 2N/A /* it's not a colon, so just return the letter */ 2N/A#
endif /* !_SUN_SDK_ */