--------------------- PatchSet 7989 Date: 2008/06/30 12:11:18 Author: serassio Branch: nt Tag: (none) Log: Remove old getopt.c, readdir.c and related files Members: lib/getopt.c:1.2.18.1->1.2.18.2(DEAD) port/win32/Makefile.am:1.2.18.22->1.2.18.23 port/win32/include/Readdir.h:1.1.2.2->1.1.2.3(DEAD) port/win32/include/cdefs.h:1.2.18.1->1.2.18.2(DEAD) port/win32/include/dirent.h:1.1->1.1.2.1 port/win32/include/getopt.h:1.2.18.1->1.2.18.2 port/win32/src/.cvsignore:1.1.2.1->1.1.2.2(DEAD) port/win32/src/encrypt.c:1.2.18.1->1.2.18.2(DEAD) port/win32/src/readdir.c:1.2.18.2->1.2.18.3(DEAD) --- squid3/lib/getopt.c 2008-07-01 00:26:11.695155879 +0000 +++ /dev/null 2008-07-01 00:26:11.000000000 +0000 @@ -1,501 +0,0 @@ -/* $NetBSD: getopt_long.c,v 1.12 2001/04/24 09:07:43 joda Exp $ */ - -/*- - * Copyright (c) 2000 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Dieter Baron and Thomas Klausner. - * - * 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 acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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. - */ - -#include "cdefs.h" - -/*#include "namespace.h"*/ - -#include -#include -/*#include */ -#include -#include -#include "getopt.h" -#include -#include - -#define REPLACE_GETOPT - -#define _DIAGASSERT(x) do {} while (0) - -#ifdef REPLACE_GETOPT -#ifdef __weak_alias -__weak_alias(getopt,_getopt) -#endif -int opterr = 1; /* if error message should be printed */ -int optind = 1; /* index into parent argv vector */ -int optopt = '?'; /* character checked for validity */ -int optreset; /* reset getopt */ -char *optarg; /* argument associated with option */ -#endif - -#ifdef __weak_alias -__weak_alias(getopt_long,_getopt_long) -#endif - -#ifndef __CYGWIN__ -#define __progname __argv[0] -#else -extern char __declspec(dllimport) *__progname; -#endif - -#define IGNORE_FIRST (*options == '-' || *options == '+') -#define PRINT_ERROR ((opterr) && ((*options != ':') \ - || (IGNORE_FIRST && options[1] != ':'))) -#if defined(__CYGWIN__) || defined(__MINGW32__) -# define IS_POSIXLY_CORRECT (1) -#else -# define IS_POSIXLY_CORRECT (getenv("POSIXLY_CORRECT") != NULL) -#endif - -#define PERMUTE (!IS_POSIXLY_CORRECT && !IGNORE_FIRST) -/* XXX: GNU ignores PC if *options == '-' */ -#define IN_ORDER (!IS_POSIXLY_CORRECT && *options == '-') - -/* return values */ -#define BADCH (int)'?' -#define BADARG ((IGNORE_FIRST && options[1] == ':') \ - || (*options == ':') ? (int)':' : (int)'?') -#define INORDER (int)1 - -#define EMSG "" - -static int getopt_internal __P((int, char * const *, const char *)); -static int gcd __P((int, int)); -static void permute_args __P((int, int, int, char * const *)); - -static const char *place = EMSG; /* option letter processing */ - -/* XXX: set optreset to 1 rather than these two */ -static int nonopt_start = -1; /* first non option argument (for permute) */ -static int nonopt_end = -1; /* first option after non options (for permute) */ - -/* Error messages */ -static const char recargchar[] = "option requires an argument -- %c"; -static const char recargstring[] = "option requires an argument -- %s"; -static const char ambig[] = "ambiguous option -- %.*s"; -static const char noarg[] = "option doesn't take an argument -- %.*s"; -static const char illoptchar[] = "unknown option -- %c"; -static const char illoptstring[] = "unknown option -- %s"; - -static void -_vwarnx(const char *fmt, va_list ap) -{ - (void)fprintf(stderr, "%s: ", __progname); - if (fmt != NULL) - (void)vfprintf(stderr, fmt, ap); - (void)fprintf(stderr, "\n"); -} - -static void -warnx(const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - _vwarnx(fmt, ap); - va_end(ap); -} - -/* - * Compute the greatest common divisor of a and b. - */ -static int -gcd(a, b) - int a; - int b; -{ - int c; - - c = a % b; - while (c != 0) { - a = b; - b = c; - c = a % b; - } - - return b; -} - -/* - * Exchange the block from nonopt_start to nonopt_end with the block - * from nonopt_end to opt_end (keeping the same order of arguments - * in each block). - */ -static void -permute_args(nonopt_start, nonopt_end, opt_end, nargv) - int nonopt_start; - int nonopt_end; - int opt_end; - char * const *nargv; -{ - int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos; - char *swap; - - _DIAGASSERT(nargv != NULL); - - /* - * compute lengths of blocks and number and size of cycles - */ - nnonopts = nonopt_end - nonopt_start; - nopts = opt_end - nonopt_end; - ncycle = gcd(nnonopts, nopts); - cyclelen = (opt_end - nonopt_start) / ncycle; - - for (i = 0; i < ncycle; i++) { - cstart = nonopt_end+i; - pos = cstart; - for (j = 0; j < cyclelen; j++) { - if (pos >= nonopt_end) - pos -= nnonopts; - else - pos += nopts; - swap = nargv[pos]; - /* LINTED const cast */ - ((char **) nargv)[pos] = nargv[cstart]; - /* LINTED const cast */ - ((char **)nargv)[cstart] = swap; - } - } -} - -/* - * getopt_internal -- - * Parse argc/argv argument vector. Called by user level routines. - * Returns -2 if -- is found (can be long option or end of options marker). - */ -static int -getopt_internal(int nargc, char *const * nargv, const char *options) -{ - char *oli; /* option letter list index */ - int optchar; - - _DIAGASSERT(nargv != NULL); - _DIAGASSERT(options != NULL); - - optarg = NULL; - - /* - * XXX Some programs (like rsyncd) expect to be able to - * XXX re-initialize optind to 0 and have getopt_long(3) - * XXX properly function again. Work around this braindamage. - */ - if (optind == 0 && optreset == 0) - optind = 1; - - if (optreset) - nonopt_start = nonopt_end = -1; -start: - if (optreset || !*place) { /* update scanning pointer */ - optreset = 0; - if (optind >= nargc) { /* end of argument vector */ - place = EMSG; - if (nonopt_end != -1) { - /* do permutation, if we have to */ - permute_args(nonopt_start, nonopt_end, - optind, nargv); - optind -= nonopt_end - nonopt_start; - } - else if (nonopt_start != -1) { - /* - * If we skipped non-options, set optind - * to the first of them. - */ - optind = nonopt_start; - } - nonopt_start = nonopt_end = -1; - return -1; - } - if ((*(place = nargv[optind]) != '-') - || (place[1] == '\0')) { /* found non-option */ - place = EMSG; - if (IN_ORDER) { - /* - * GNU extension: - * return non-option as argument to option 1 - */ - optarg = nargv[optind++]; - return INORDER; - } - if (!PERMUTE) { - /* - * if no permutation wanted, stop parsing - * at first non-option - */ - return -1; - } - /* do permutation */ - if (nonopt_start == -1) - nonopt_start = optind; - else if (nonopt_end != -1) { - permute_args(nonopt_start, nonopt_end, - optind, nargv); - nonopt_start = optind - - (nonopt_end - nonopt_start); - nonopt_end = -1; - } - optind++; - /* process next argument */ - goto start; - } - if (nonopt_start != -1 && nonopt_end == -1) - nonopt_end = optind; - if (place[1] && *++place == '-') { /* found "--" */ - place++; - return -2; - } - } - if ((optchar = (int)*place++) == (int)':' || - (oli = strchr(options + (IGNORE_FIRST ? 1 : 0), optchar)) == NULL) { - /* option letter unknown or ':' */ - if (!*place) - ++optind; - if (PRINT_ERROR) - warnx(illoptchar, optchar); - optopt = optchar; - return BADCH; - } - if (optchar == 'W' && oli[1] == ';') { /* -W long-option */ - /* XXX: what if no long options provided (called by getopt)? */ - if (*place) - return -2; - - if (++optind >= nargc) { /* no arg */ - place = EMSG; - if (PRINT_ERROR) - warnx(recargchar, optchar); - optopt = optchar; - return BADARG; - } else /* white space */ - place = nargv[optind]; - /* - * Handle -W arg the same as --arg (which causes getopt to - * stop parsing). - */ - return -2; - } - if (*++oli != ':') { /* doesn't take argument */ - if (!*place) - ++optind; - } else { /* takes (optional) argument */ - optarg = NULL; - if (*place) /* no white space */ - optarg = (char *) place; - /* XXX: disable test for :: if PC? (GNU doesn't) */ - else if (oli[1] != ':') { /* arg not optional */ - if (++optind >= nargc) { /* no arg */ - place = EMSG; - if (PRINT_ERROR) - warnx(recargchar, optchar); - optopt = optchar; - return BADARG; - } else - optarg = nargv[optind]; - } - place = EMSG; - ++optind; - } - /* dump back option letter */ - return optchar; -} - -#ifdef REPLACE_GETOPT -/* - * getopt -- - * Parse argc/argv argument vector. - * - * [eventually this will replace the real getopt] - */ -int -getopt(int nargc, char * const *nargv, const char *options) -{ - int retval; - - _DIAGASSERT(nargv != NULL); - _DIAGASSERT(options != NULL); - - if ((retval = getopt_internal(nargc, nargv, options)) == -2) { - ++optind; - /* - * We found an option (--), so if we skipped non-options, - * we have to permute. - */ - if (nonopt_end != -1) { - permute_args(nonopt_start, nonopt_end, optind, - nargv); - optind -= nonopt_end - nonopt_start; - } - nonopt_start = nonopt_end = -1; - retval = -1; - } - return retval; -} -#endif - -/* - * getopt_long -- - * Parse argc/argv argument vector. - */ -int -getopt_long(int nargc, char * const *nargv, const char *options, - const struct option *long_options, int *idx) -{ - int retval; - - _DIAGASSERT(nargv != NULL); - _DIAGASSERT(options != NULL); - _DIAGASSERT(long_options != NULL); - /* idx may be NULL */ - - if ((retval = getopt_internal(nargc, nargv, options)) == -2) { - char *current_argv, *has_equal; - size_t current_argv_len; - int i, match; - - current_argv = (char *) place; - match = -1; - - optind++; - place = EMSG; - - if (*current_argv == '\0') { /* found "--" */ - /* - * We found an option (--), so if we skipped - * non-options, we have to permute. - */ - if (nonopt_end != -1) { - permute_args(nonopt_start, nonopt_end, - optind, nargv); - optind -= nonopt_end - nonopt_start; - } - nonopt_start = nonopt_end = -1; - return -1; - } - if ((has_equal = strchr(current_argv, '=')) != NULL) { - /* argument found (--option=arg) */ - current_argv_len = has_equal - current_argv; - has_equal++; - } else - current_argv_len = strlen(current_argv); - - for (i = 0; long_options[i].name; i++) { - /* find matching long option */ - if (strncmp(current_argv, long_options[i].name, - current_argv_len)) - continue; - - if (strlen(long_options[i].name) == - (unsigned)current_argv_len) { - /* exact match */ - match = i; - break; - } - if (match == -1) /* partial match */ - match = i; - else { - /* ambiguous abbreviation */ - if (PRINT_ERROR) - warnx(ambig, (int)current_argv_len, - current_argv); - optopt = 0; - return BADCH; - } - } - if (match != -1) { /* option found */ - if (long_options[match].has_arg == no_argument - && has_equal) { - if (PRINT_ERROR) - warnx(noarg, (int)current_argv_len, - current_argv); - /* - * XXX: GNU sets optopt to val regardless of - * flag - */ - if (long_options[match].flag == NULL) - optopt = long_options[match].val; - else - optopt = 0; - return BADARG; - } - if (long_options[match].has_arg == required_argument || - long_options[match].has_arg == optional_argument) { - if (has_equal) - optarg = has_equal; - else if (long_options[match].has_arg == - required_argument) { - /* - * optional argument doesn't use - * next nargv - */ - optarg = nargv[optind++]; - } - } - if ((long_options[match].has_arg == required_argument) - && (optarg == NULL)) { - /* - * Missing argument; leading ':' - * indicates no error should be generated - */ - if (PRINT_ERROR) - warnx(recargstring, current_argv); - /* - * XXX: GNU sets optopt to val regardless - * of flag - */ - if (long_options[match].flag == NULL) - optopt = long_options[match].val; - else - optopt = 0; - --optind; - return BADARG; - } - } else { /* unknown option */ - if (PRINT_ERROR) - warnx(illoptstring, current_argv); - optopt = 0; - return BADCH; - } - if (long_options[match].flag) { - *long_options[match].flag = long_options[match].val; - retval = 0; - } else - retval = long_options[match].val; - if (idx) - *idx = match; - } - return retval; -} Index: squid3/port/win32/Makefile.am =================================================================== RCS file: /cvsroot/squid-sf//squid3/port/win32/Attic/Makefile.am,v retrieving revision 1.2.18.22 retrieving revision 1.2.18.23 diff -u -r1.2.18.22 -r1.2.18.23 --- squid3/port/win32/Makefile.am 22 Jan 2008 20:27:30 -0000 1.2.18.22 +++ squid3/port/win32/Makefile.am 30 Jun 2008 12:11:19 -0000 1.2.18.23 @@ -1,6 +1,6 @@ ## Process this file with automake to produce Makefile.in # -# $Id: Makefile.am,v 1.2.18.22 2008/01/22 20:27:30 serassio Exp $ +# $Id: Makefile.am,v 1.2.18.23 2008/06/30 12:11:19 serassio Exp $ # EXTRA_DIST = \ @@ -25,10 +25,9 @@ dnsserver/dnsserver.vcproj \ fake_auth/fake_auth.vcproj \ include/autoconf.h \ - include/cdefs.h \ include/crypt.h \ include/getopt.h \ - include/Readdir.h \ + include/dirent.h \ ip_user_check/ip_user_check.vcproj \ LDAP_auth/LDAP_auth.vcproj \ LDAP_group/LDAP_group.vcproj \ @@ -67,8 +66,6 @@ squid/squid.rc \ squid/squid.rc2 \ squidclient/squidclient.vcproj \ - src/encrypt.c \ - src/readdir.c \ setup/banner.jpg \ setup/Setup.vdproj \ unlinkd/unlinkd.vcproj --- squid3/port/win32/include/Readdir.h 2008-07-01 00:26:11.725476398 +0000 +++ /dev/null 2008-07-01 00:26:11.000000000 +0000 @@ -1,40 +0,0 @@ -/* - * Structures and types used to implement opendir/readdir/closedir - * on Windows 95/NT. -*/ - -#include -#include -#include - -/* To keep API definitions clear */ -#ifdef __cplusplus -#define SQUIDCEXTERN extern "C" -#else -#define SQUIDCEXTERN extern -#endif - -#ifdef _MSC_VER /* Microsoft C Compiler ONLY */ -/* struct dirent - same as Unix */ -struct dirent { - ino_t d_ino; /* inode (always 1 in WIN32) */ - off_t d_off; /* offset to this dirent */ - unsigned short d_reclen; /* length of d_name */ - char d_name[_MAX_FNAME+1]; /* filename (null terminated) */ -}; - -/* typedef DIR - not the same as Unix */ -typedef struct { - long handle; /* _findfirst/_findnext handle */ - short offset; /* offset into directory */ - short finished; /* 1 if there are not more files */ - struct _finddata_t fileinfo; /* from _findfirst/_findnext */ - char *dir; /* the dir we are reading */ - struct dirent dent; /* the dirent to return */ -} DIR; - -/* Function prototypes */ -SQUIDCEXTERN DIR * opendir(const char *); -SQUIDCEXTERN struct dirent * readdir(DIR *); -SQUIDCEXTERN int closedir(DIR *); -#endif --- squid3/port/win32/include/cdefs.h 2008-07-01 00:26:11.734854011 +0000 +++ /dev/null 2008-07-01 00:26:11.000000000 +0000 @@ -1,22 +0,0 @@ -/* sys/cdefs.h - - Copyright 1998, 2000, 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _SYS_CDEFS_H -#define _SYS_CDEFS_H -#ifdef __cplusplus -#define __BEGIN_DECLS extern "C" { -#define __END_DECLS } -#else -#define __BEGIN_DECLS -#define __END_DECLS -#endif -#define __P(protos) protos /* full-blown ANSI C */ -#endif - --- /dev/null 2008-07-01 00:26:11.000000000 +0000 +++ squid3/port/win32/include/dirent.h 2008-07-01 00:26:11.743490197 +0000 @@ -0,0 +1,102 @@ +/* + * $Id: dirent.h,v 1.1.2.1 2008/06/30 12:12:00 serassio Exp $ + * + * Implement dirent-style opendir(), readdir(), closedir(), rewinddir(), + * seekdir() and telldir on Windows - Based on mingw-runtime package sources. + * AUTHOR: Guido Serassio + * + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * incorporates software developed and/or copyrighted by other + * sources; see the CREDITS file for full details. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + * Original file info follow: + * + * DIRENT.H (formerly DIRLIB.H) + * This file has no copyright assigned and is placed in the Public Domain. + * This file is a part of the mingw-runtime package. + * No warranty is given; refer to the file DISCLAIMER within the package. + * + */ +#ifndef _DIRENT_H_ +#define _DIRENT_H_ + +/* All the headers include this file. */ +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + struct dirent { + long d_ino; /* Always zero. */ + unsigned short d_reclen; /* Always zero. */ + unsigned short d_namlen; /* Length of name in d_name. */ + char d_name[FILENAME_MAX]; /* File name. */ + }; + +/* + * This is an internal data structure. Good programmers will not use it + * except as an argument to one of the functions below. + * dd_stat field is now int (was short in older versions). + */ + typedef struct { + /* disk transfer area for this dir */ + struct _finddata_t dd_dta; + + /* dirent struct to return from dir (NOTE: this makes this thread + * safe as long as only one thread uses a particular DIR struct at + * a time) */ + struct dirent dd_dir; + + /* _findnext handle */ + long dd_handle; + + /* + * Status of search: + * 0 = not started yet (next entry to read is first entry) + * -1 = off the end + * positive = 0 based index of next entry + */ + int dd_stat; + + /* given path for dir with search pattern (struct is extended) */ + char dd_name[1]; + } DIR; + + DIR *__cdecl opendir(const char *); + struct dirent *__cdecl readdir(DIR *); + int __cdecl closedir(DIR *); + void __cdecl rewinddir(DIR *); + long __cdecl telldir(DIR *); + void __cdecl seekdir(DIR *, long); + + + +#ifdef __cplusplus +} + +#endif +#endif /* Not _DIRENT_H_ */ Index: squid3/port/win32/include/getopt.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/port/win32/include/Attic/getopt.h,v retrieving revision 1.2.18.1 retrieving revision 1.2.18.2 diff -u -r1.2.18.1 -r1.2.18.2 --- squid3/port/win32/include/getopt.h 25 Feb 2003 02:48:45 -0000 1.2.18.1 +++ squid3/port/win32/include/getopt.h 30 Jun 2008 12:11:20 -0000 1.2.18.2 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1987, 1993, 1994, 1996 - * The Regents of the University of California. All rights reserved. + * Copyright (c) 1987, 1993, 1994 + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -10,11 +10,7 @@ * 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 software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -31,54 +27,23 @@ * SUCH DAMAGE. */ -#ifndef __GETOPT_H__ -#define __GETOPT_H__ +#ifndef __GETOPT_H +#define __GETOPT_H #ifdef __cplusplus extern "C" { #endif -extern int opterr; /* if error message should be printed */ -extern int optind; /* index into parent argv vector */ -extern int optopt; /* character checked for validity */ -extern int optreset; /* reset getopt */ -extern char *optarg; /* argument associated with option */ + extern int opterr; /* if error message should be printed */ + extern int optind; /* index into parent argv vector */ + extern int optopt; /* character checked for validity */ + extern int optreset; /* reset getopt */ + extern char *optarg; /* argument associated with option */ -int getopt (int, char * const *, const char *); + int getopt(int nargc, char *const *nargv, const char *ostr); #ifdef __cplusplus } -#endif - -#endif /* __GETOPT_H__ */ - -#ifndef __UNISTD_GETOPT__ -#ifndef __GETOPT_LONG_H__ -#define __GETOPT_LONG_H__ - -#ifdef __cplusplus -extern "C" { -#endif -struct option { - const char *name; - int has_arg; - int *flag; - int val; -}; - -int getopt_long (int, char *const *, const char *, const struct option *, int *); -#ifndef HAVE_DECL_GETOPT -#define HAVE_DECL_GETOPT 1 #endif - -#define no_argument 0 -#define required_argument 1 -#define optional_argument 2 - -#ifdef __cplusplus -} #endif - -#endif /* __GETOPT_LONG_H__ */ -#endif /* __UNISTD_GETOPT__ */ --- squid3/port/win32/src/.cvsignore 2008-07-01 00:26:11.763531603 +0000 +++ /dev/null 2008-07-01 00:26:11.000000000 +0000 @@ -1 +0,0 @@ -.deps --- squid3/port/win32/src/encrypt.c 2008-07-01 00:26:11.772393794 +0000 +++ /dev/null 2008-07-01 00:26:11.000000000 +0000 @@ -1,323 +0,0 @@ -/* encrypt.c - providing 56 bit DES encryption - Copyright (C) 1991 Jochen Obalek - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include -#include - -#define BS 64 -#define BS2 32 -#define KS 48 -#define KS2 24 -#define IS 56 -#define IS2 28 - -static char schluessel[16][KS]; - - -static char PC1[] = -{ - 56, 48, 40, 32, 24, 16, 8, 0, - 57, 49, 41, 33, 25, 17, 9, 1, - 58, 50, 42, 34, 26, 18, 10, 2, - 59, 51, 43, 35, - 62, 54, 46, 38, 30, 22, 14, 6, - 61, 53, 45, 37, 29, 21, 13, 5, - 60, 52, 44, 36, 28, 20, 12, 4, - 27, 19, 11, 3 -}; - - -static char PC2[] = -{ - 13, 16, 10, 23, 0, 4, 2, 27, - 14, 5, 20, 9, 22, 18, 11, 3, - 25, 7, 15, 6, 26, 19, 12, 1, - 40, 51, 30, 36, 46, 54, 29, 39, - 50, 44, 32, 47, 43, 48, 38, 55, - 33, 52, 45, 41, 49, 35, 28, 31 -}; - - -static char IP[] = -{ - 57, 49, 41, 33, 25, 17, 9, 1, - 59, 51, 43, 35, 27, 19, 11, 3, - 61, 53, 45, 37, 29, 21, 13, 5, - 63, 55, 47, 39, 31, 23, 15, 7, - 56, 48, 40, 32, 24, 16, 8, 0, - 58, 50, 42, 34, 26, 18, 10, 2, - 60, 52, 44, 36, 28, 20, 12, 4, - 62, 54, 46, 38, 30, 22, 14, 6 -}; - - -static char EP[] = -{ - 7, 39, 15, 47, 23, 55, 31, 63, - 6, 38, 14, 46, 22, 54, 30, 62, - 5, 37, 13, 45, 21, 53, 29, 61, - 4, 36, 12, 44, 20, 52, 28, 60, - 3, 35, 11, 43, 19, 51, 27, 59, - 2, 34, 10, 42, 18, 50, 26, 58, - 1, 33, 9, 41, 17, 49, 25, 57, - 0, 32, 8, 40, 16, 48, 24, 56 -}; - - -static char E0[] = -{ - 31, 0, 1, 2, 3, 4, 3, 4, - 5, 6, 7, 8, 7, 8, 9, 10, - 11, 12, 11, 12, 13, 14, 15, 16, - 15, 16, 17, 18, 19, 20, 19, 20, - 21, 22, 23, 24, 23, 24, 25, 26, - 27, 28, 27, 28, 29, 30, 31, 0 -}; - - -static char E[KS]; - - -static char PERM[] = -{ - 15, 6, 19, 20, 28, 11, 27, 16, - 0, 14, 22, 25, 4, 17, 30, 9, - 1, 7, 23, 13, 31, 26, 2, 8, - 18, 12, 29, 5, 21, 10, 3, 24 -}; - - -static char S_BOX[][64] = -{ - { - 14, 0, 4, 15, 13, 7, 1, 4, 2, 14, 15, 2, 11, 13, 8, 1, - 3, 10, 10, 6, 6, 12, 12, 11, 5, 9, 9, 5, 0, 3, 7, 8, - 4, 15, 1, 12, 14, 8, 8, 2, 13, 4, 6, 9, 2, 1, 11, 7, - 15, 5, 12, 11, 9, 3, 7, 14, 3, 10, 10, 0, 5, 6, 0, 13 - }, - { - 15, 3, 1, 13, 8, 4, 14, 7, 6, 15, 11, 2, 3, 8, 4, 14, - 9, 12, 7, 0, 2, 1, 13, 10, 12, 6, 0, 9, 5, 11, 10, 5, - 0, 13, 14, 8, 7, 10, 11, 1, 10, 3, 4, 15, 13, 4, 1, 2, - 5, 11, 8, 6, 12, 7, 6, 12, 9, 0, 3, 5, 2, 14, 15, 9 - }, - { - 10, 13, 0, 7, 9, 0, 14, 9, 6, 3, 3, 4, 15, 6, 5, 10, - 1, 2, 13, 8, 12, 5, 7, 14, 11, 12, 4, 11, 2, 15, 8, 1, - 13, 1, 6, 10, 4, 13, 9, 0, 8, 6, 15, 9, 3, 8, 0, 7, - 11, 4, 1, 15, 2, 14, 12, 3, 5, 11, 10, 5, 14, 2, 7, 12 - }, - { - 7, 13, 13, 8, 14, 11, 3, 5, 0, 6, 6, 15, 9, 0, 10, 3, - 1, 4, 2, 7, 8, 2, 5, 12, 11, 1, 12, 10, 4, 14, 15, 9, - 10, 3, 6, 15, 9, 0, 0, 6, 12, 10, 11, 1, 7, 13, 13, 8, - 15, 9, 1, 4, 3, 5, 14, 11, 5, 12, 2, 7, 8, 2, 4, 14 - }, - { - 2, 14, 12, 11, 4, 2, 1, 12, 7, 4, 10, 7, 11, 13, 6, 1, - 8, 5, 5, 0, 3, 15, 15, 10, 13, 3, 0, 9, 14, 8, 9, 6, - 4, 11, 2, 8, 1, 12, 11, 7, 10, 1, 13, 14, 7, 2, 8, 13, - 15, 6, 9, 15, 12, 0, 5, 9, 6, 10, 3, 4, 0, 5, 14, 3 - }, - { - 12, 10, 1, 15, 10, 4, 15, 2, 9, 7, 2, 12, 6, 9, 8, 5, - 0, 6, 13, 1, 3, 13, 4, 14, 14, 0, 7, 11, 5, 3, 11, 8, - 9, 4, 14, 3, 15, 2, 5, 12, 2, 9, 8, 5, 12, 15, 3, 10, - 7, 11, 0, 14, 4, 1, 10, 7, 1, 6, 13, 0, 11, 8, 6, 13 - }, - { - 4, 13, 11, 0, 2, 11, 14, 7, 15, 4, 0, 9, 8, 1, 13, 10, - 3, 14, 12, 3, 9, 5, 7, 12, 5, 2, 10, 15, 6, 8, 1, 6, - 1, 6, 4, 11, 11, 13, 13, 8, 12, 1, 3, 4, 7, 10, 14, 7, - 10, 9, 15, 5, 6, 0, 8, 15, 0, 14, 5, 2, 9, 3, 2, 12 - }, - { - 13, 1, 2, 15, 8, 13, 4, 8, 6, 10, 15, 3, 11, 7, 1, 4, - 10, 12, 9, 5, 3, 6, 14, 11, 5, 0, 0, 14, 12, 9, 7, 2, - 7, 2, 11, 1, 4, 14, 1, 7, 9, 4, 12, 10, 14, 8, 2, 13, - 0, 15, 6, 12, 10, 9, 13, 0, 15, 3, 3, 5, 5, 6, 8, 11 - } -}; - -static void -perm (a, e, pc, n) - register char *a, *e; - register char *pc; - int n; -{ - for (; n--; pc++, a++) - *a = e[*pc]; -} - -static void -crypt_main (nachr_l, nachr_r, schl) - register char *nachr_l, *nachr_r; - register char *schl; -{ - char tmp[KS]; - register int sbval; - register char *tp = tmp; - register char *e = E; - register int i, j; - - for (i = 0; i < 8; i++) - { - for (j = 0, sbval = 0; j < 6; j++) - sbval = (sbval << 1) | (nachr_r[*e++] ^ *schl++); - sbval = S_BOX[i][sbval]; - for (tp += 4, j = 4; j--; sbval >>= 1) - *--tp = sbval & 1; - tp += 4; - } - - e = PERM; - for (i = 0; i < BS2; i++) - *nachr_l++ ^= tmp[*e++]; -} - -void -encrypt (char *nachr, int decr) -{ - char (*schl)[KS] = decr ? schluessel + 15 : schluessel; - char tmp[BS]; - int i; - - perm (tmp, nachr, IP, BS); - - for (i = 8; i--;) - { - crypt_main (tmp, tmp + BS2, *schl); - if (decr) - schl--; - else - schl++; - crypt_main (tmp + BS2, tmp, *schl); - if (decr) - schl--; - else - schl++; - } - - perm (nachr, tmp, EP, BS); -} - -void -setkey (char *schl) -{ - char tmp1[IS]; - register unsigned int ls = 0x7efc; - register int i, j, k; - register int shval = 0; - register char *akt_schl; - - memcpy (E, E0, KS); - perm (tmp1, schl, PC1, IS); - - for (i = 0; i < 16; i++) - { - shval += 1 + (ls & 1); - akt_schl = schluessel[i]; - for (j = 0; j < KS; j++) - { - if ((k = PC2[j]) >= IS2) - { - if ((k += shval) >= IS) - k = (k - IS2) % IS2 + IS2; - } - else if ((k += shval) >= IS2) - k %= IS2; - *akt_schl++ = tmp1[k]; - } - ls >>= 1; - } -} - -char * -crypt (const char *wort, const char *salt) -{ - static char retkey[14]; - char key[BS + 2]; - char *k; - int tmp, keybyte; - int i, j; - - memset (key, 0, BS + 2); - - for (k = key, i = 0; i < BS; i++) - { - if (!(keybyte = *wort++)) - break; - k += 7; - for (j = 0; j < 7; j++, i++) - { - *--k = keybyte & 1; - keybyte >>= 1; - } - k += 8; - } - - setkey (key); - memset (key, 0, BS + 2); - - for (k = E, i = 0; i < 2; i++) - { - retkey[i] = keybyte = *salt++; - if (keybyte > 'Z') - keybyte -= 'a' - 'Z' - 1; - if (keybyte > '9') - keybyte -= 'A' - '9' - 1; - keybyte -= '.'; - - for (j = 0; j < 6; j++, keybyte >>= 1, k++) - { - if (!(keybyte & 1)) - continue; - tmp = *k; - *k = k[24]; - k[24] = tmp; - } - } - - for (i = 0; i < 25; i++) - encrypt (key, 0); - - for (k = key, i = 0; i < 11; i++) - { - for (j = keybyte = 0; j < 6; j++) - { - keybyte <<= 1; - keybyte |= *k++; - } - - keybyte += '.'; - if (keybyte > '9') - keybyte += 'A' - '9' - 1; - if (keybyte > 'Z') - keybyte += 'a' - 'Z' - 1; - retkey[i + 2] = keybyte; - } - - retkey[i + 2] = 0; - - if (!retkey[1]) - retkey[1] = *retkey; - - return retkey; -} - - --- squid3/port/win32/src/readdir.c 2008-07-01 00:26:11.784066362 +0000 +++ /dev/null 2008-07-01 00:26:11.000000000 +0000 @@ -1,80 +0,0 @@ -#include "config.h" -#include -#include -#include -#define strdup _strdup - -/********************************************************************** - * Implement dirent-style opendir/readdir/closedir on Window 95/NT - * - * Functions defined are opendir(), readdir() and closedir() with the - * same prototypes as the normal dirent.h implementation. - * - * Does not implement telldir(), seekdir(), rewinddir() or scandir(). - * The dirent struct is compatible with Unix, except that d_ino is - * always 1 and d_off is made up as we go along. - * - * The DIR typedef is not compatible with Unix. - **********************************************************************/ - -DIR * opendir(const char *dir) -{ - DIR *dp; - char *filespec; - long handle; - int index; - - filespec = malloc(strlen(dir) + 2 + 1); - strcpy(filespec, dir); - index = strlen(filespec) - 1; - if (index >= 0 && (filespec[index] == '/' || filespec[index] == '\\')) - filespec[index] = '\0'; - strcat(filespec, "/*"); - - dp = (DIR *)malloc(sizeof(DIR)); - dp->offset = 0; - dp->finished = 0; - dp->dir = strdup(dir); - - if ((handle = _findfirst(filespec, &(dp->fileinfo))) < 0) { - if (errno == ENOENT) - dp->finished = 1; - else - return NULL; - } - - dp->handle = handle; - free(filespec); - - return dp; -} - -struct dirent * readdir(DIR *dp) -{ - if (!dp || dp->finished) return NULL; - - if (dp->offset != 0) { - if (_findnext(dp->handle, &(dp->fileinfo)) < 0) { - dp->finished = 1; - return NULL; - } - } - dp->offset++; - - strncpy(dp->dent.d_name, dp->fileinfo.name, _MAX_FNAME); - dp->dent.d_ino = 1; - dp->dent.d_reclen = strlen(dp->dent.d_name); - dp->dent.d_off = dp->offset; - - return &(dp->dent); -} - -int closedir(DIR *dp) -{ - if (!dp) return 0; - _findclose(dp->handle); - if (dp->dir) free(dp->dir); - if (dp) free(dp); - - return 0; -}