Re: CVS repository

From: Robert Collins <robertc@dont-contact.us>
Date: 04 Sep 2002 16:32:11 +1000

The attached patch is against the devel 'nt' branch, and when combined
with:

a link from include/squid-mswin.h to ...port/win32/include/squid-mswin.h
and one from include/readdir.h to ...port/win32/include/READDIR.H

will allow building of most of the squid nt native branch on cygwin with
the configure statement '<srcdir>/configure --enable-win32specific'.

You will need a new mingw msvcrt import library, run the cygwin setup
program, find mingw-runtime and click the src column. Then apply the
mingwfreeosf.patch patch to it, and configure & make it. Copy the result
libmsvcrt.a to /usr/lib/mingw/.

Finally, I ran out of puff on debug.c, which needs further
investigation.

squidclient.exe seemed to run ok.

This is simply meant to address the current issues, not to be done
cleanly. If this provides the basis for someone making a full mingw set
of changes, GREAT.

I'm working on getting the msvcrt patch into mingw at the moment.

Rob

? autom4te.cache
? include/readdir.h
? include/squid-mswin.h
Index: configure.in
===================================================================
RCS file: /cvsroot/squid/squid/configure.in,v
retrieving revision 1.50.2.22
diff -u -p -r1.50.2.22 configure.in
--- configure.in 1 Sep 2002 16:57:00 -0000 1.50.2.22
+++ configure.in 4 Sep 2002 06:25:20 -0000
@@ -1508,6 +1508,18 @@ if test $ac_cv_type_mtyp_t = no; then
 dnl Check for needed libraries
 AC_CHECK_LIB(nsl, main)
 AC_CHECK_LIB(socket, main)
+case "$host_os" in
+ mingw|mingw32|cygwin|cygwin32)
+ echo "Using Win32 sock2 library."
+ LIBS="$LIBS -lwsock32"
+ echo "Using own getopt."
+ AC_LIBOBJ(getopt)
+ ;;
+ *)
+ ;;
+esac
+
+AC_CHECK_LIB(wsock32,WSAGetLastError)
 
 dnl Ripped from the Samba sources
 AC_CACHE_CHECK([for unix domain sockets],squid_cv_unixsocket, [
@@ -2171,12 +2183,19 @@ if test "$INET_NTOA_RESULT" = "1.2.3.4"
         AC_MSG_RESULT("yes")
 else
         AC_MSG_RESULT("no")
- echo "Will use our own inet_ntoa()."
- LIBOBJS="$LIBOBJS inet_ntoa.o"
+ case "$host_os" in
+ mingw|mingw32|cygwin|cygwin32)
+ echo "Using Win32 resolver instead."
+ ;;
+ *)
+ echo "Will use our own inet_ntoa()."
+ AC_LIBOBJ(inet_ntoa)
 # echo "WARNING: This looks bad, and probably prevents Squid from working."
 # echo " If you're on IRIX and using GCC 2.8, you probably need"
 # echo " to use the IRIX C compiler instead."
 # sleep 10
+ ;;
+ esac
 fi
 
 if test "$ac_cv_header_sys_statvfs_h" = "yes" ; then
Index: lib/Makefile.am
===================================================================
RCS file: /cvsroot/squid/squid/lib/Makefile.am,v
retrieving revision 1.5.2.1
diff -u -p -r1.5.2.1 Makefile.am
--- lib/Makefile.am 16 Jul 2002 14:50:37 -0000 1.5.2.1
+++ lib/Makefile.am 4 Sep 2002 06:25:21 -0000
@@ -13,6 +13,11 @@ MD5SOURCE=md5.c
 else
 MD5SOURCE=
 endif
+if ENABLE_WIN32SPECIFIC
+WIN32SRC=win32lib.c
+else
+WIN32SRC=
+endif
 
 EXTRA_LIBRARIES = \
         libdlmalloc.a \
@@ -47,7 +52,8 @@ libmiscutil_a_SOURCES = \
         Stack.c \
         stub_memaccount.c \
         util.c \
- uudecode.c
+ uudecode.c \
+ $(WIN32SRC)
 libmiscutil_a_LIBADD = \
         @LIBOBJS@
 # $(top_srcdir)/include/version.h should be a dependency
Index: lib/cdefs.h
===================================================================
RCS file: lib/cdefs.h
diff -N lib/cdefs.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lib/cdefs.h 4 Sep 2002 06:25:21 -0000
@@ -0,0 +1,22 @@
+/* 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
+
Index: lib/getopt.c
===================================================================
RCS file: lib/getopt.c
diff -N lib/getopt.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lib/getopt.c 4 Sep 2002 06:25:21 -0000
@@ -0,0 +1,501 @@
+/* $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 <assert.h>
+#include <errno.h>
+/*#include <err.h>*/
+#include <stdlib.h>
+#include <string.h>
+#include "/cygdrive/z/source/squid/squid_nt/port/win32/include/getopt.h"
+#include <stdarg.h>
+#include <stdio.h>
+
+#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: lib/win32lib.c
===================================================================
RCS file: /cvsroot/squid/squid/lib/Attic/win32lib.c,v
retrieving revision 1.1.26.5
diff -u -p -r1.1.26.5 win32lib.c
--- lib/win32lib.c 13 Aug 2002 19:51:03 -0000 1.1.26.5
+++ lib/win32lib.c 4 Sep 2002 06:25:21 -0000
@@ -54,15 +54,15 @@
 #define OPTERRNF (2)
 #define OPTERRARG (3)
 
+#ifndef __MINGW32__
 __declspec(thread) int ws32_result;
 __declspec(thread) int _so_err;
 __declspec(thread) int _so_err_siz;
-
-char *optarg;
-int optreset = 0;
-int optind = 1;
-int opterr = 1;
-int optopt;
+#else
+int ws32_result;
+int _so_err;
+int _so_err_siz;
+#endif
 
 uid_t geteuid(void)
 {
@@ -222,116 +222,6 @@ int WIN32_truncate (const char *pathname
     }
 
   return res;
-}
-
-
-static int
-optiserr(int argc, char * const *argv, int oint, const char *optstr,
- int optchr, int err)
-{
- if(opterr)
- {
- fprintf(stderr, "Error in argument %d, char %d: ", oint, optchr+1);
- switch(err)
- {
- case OPTERRCOLON:
- fprintf(stderr, ": in flags\n");
- break;
- case OPTERRNF:
- fprintf(stderr, "option not found %c\n", argv[oint][optchr]);
- break;
- case OPTERRARG:
- fprintf(stderr, "no argument for option %c\n", argv[oint][optchr]);
- break;
- default:
- fprintf(stderr, "unknown\n");
- break;
- }
- }
- optopt = argv[oint][optchr];
- return('?');
-}
-
-
-int
-getopt(int argc, char* const *argv, const char *optstr)
-{
- static int optchr = 0;
- static int dash = 0; /* have already seen the - */
-
- char *cp;
-
- if (optreset)
- optreset = optchr = dash = 0;
- if (optind >= argc)
- return(EOF);
- if (!dash && (argv[optind][0] != '-'))
- return(EOF);
- if (!dash && (argv[optind][0] == '-') && !argv[optind][1])
- {
- /*
- * use to specify stdin. Need to let pgm process this and
- * the following args
- */
- return(EOF);
- }
- if ((argv[optind][0] == '-') && (argv[optind][1] == '-'))
- {
- /* -- indicates end of args */
- optind++;
- return(EOF);
- }
- if (!dash)
- {
- assert((argv[optind][0] == '-') && argv[optind][1]);
- dash = 1;
- optchr = 1;
- }
-
- /* Check if the guy tries to do a -: kind of flag */
- assert(dash);
- if(argv[optind][optchr] == ':')
- {
- dash = 0;
- optind++;
- return(optiserr(argc, argv, optind-1, optstr, optchr, OPTERRCOLON));
- }
- if(!(cp = strchr(optstr, argv[optind][optchr])))
- {
- int errind = optind;
- int errchr = optchr;
-
- if(!argv[optind][optchr+1])
- {
- dash = 0;
- optind++;
- }
- else
- optchr++;
- return(optiserr(argc, argv, errind, optstr, errchr, OPTERRNF));
- }
- if(cp[1] == ':')
- {
- dash = 0;
- optind++;
- if(optind == argc)
- return(optiserr(argc, argv, optind-1, optstr, optchr, OPTERRARG));
- optarg = argv[optind++];
- return(*cp);
- }
- else
- {
- if(!argv[optind][optchr+1])
- {
- dash = 0;
- optind++;
- }
- else
- optchr++;
- return(*cp);
- }
- assert(0);
- return(0);
 }
 
 static struct _wsaerrtext {
Index: port/win32/include/READDIR.H
===================================================================
RCS file: /cvsroot/squid/squid/port/win32/include/Attic/READDIR.H,v
retrieving revision 1.1.6.2
diff -u -p -r1.1.6.2 READDIR.H
--- port/win32/include/READDIR.H 14 Jul 2002 21:06:14 -0000 1.1.6.2
+++ port/win32/include/READDIR.H 4 Sep 2002 06:25:21 -0000
@@ -6,6 +6,7 @@
 #include <io.h>
 #include <stdlib.h>
 #include <sys/types.h>
+#ifndef __MINGW32__
 #define off_t _off_t
 
 
@@ -31,3 +32,4 @@ typedef struct {
 DIR * opendir(const char *);
 struct dirent * readdir(DIR *);
 int closedir(DIR *);
+#endif
Index: port/win32/include/getopt.h
===================================================================
RCS file: /cvsroot/squid/squid/port/win32/include/Attic/getopt.h,v
retrieving revision 1.1.6.1
diff -u -p -r1.1.6.1 getopt.h
--- port/win32/include/getopt.h 8 Apr 2002 19:53:38 -0000 1.1.6.1
+++ port/win32/include/getopt.h 4 Sep 2002 06:25:21 -0000
@@ -1,73 +1,84 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000 The Apache Software Foundation. All rights
- * reserved.
+/*
+ * Copyright (c) 1987, 1993, 1994, 1996
+ * 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
  * 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. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``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 APACHE SOFTWARE FOUNDATION 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
+ * 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
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- * Portions of this software are based upon public domain software
- * originally written at the National Center for Supercomputing Applications,
- * University of Illinois, Urbana-Champaign.
  */
 
-#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 */
+
+int getopt (int, char * const *, const char *);
+
+#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;
+};
 
-#ifdef WIN32
+int getopt_long (int, char *const *, const char *, const struct option *, int *);
+#ifndef HAVE_DECL_GETOPT
+#define HAVE_DECL_GETOPT 1
+#endif
 
-extern char *optarg;
-extern int optreset;
-extern int optind;
-extern int opterr;
-extern int optopt;
-int getopt(int argc, char* const *argv, const char *optstr);
+#define no_argument 0
+#define required_argument 1
+#define optional_argument 2
 
-#endif /* WIN32 */
+#ifdef __cplusplus
+}
+#endif
 
-#endif /* GETOPT_H */
\ No newline at end of file
+#endif /* __GETOPT_LONG_H__ */
+#endif /* __UNISTD_GETOPT__ */
Index: port/win32/include/squid-mswin.h
===================================================================
RCS file: /cvsroot/squid/squid/port/win32/include/Attic/squid-mswin.h,v
retrieving revision 1.1.6.9
diff -u -p -r1.1.6.9 squid-mswin.h
--- port/win32/include/squid-mswin.h 12 Aug 2002 19:14:11 -0000 1.1.6.9
+++ port/win32/include/squid-mswin.h 4 Sep 2002 06:25:22 -0000
@@ -31,31 +31,40 @@
  *
  */
 
+#ifndef __MINGW32__
 #include "default_config_file.h"
 
 /* Some tricks for MS Compilers */
 
 #define __STDC__ 1
-
 #pragma include_alias(<dirent.h>, <direct.h>)
+#endif
 
+#ifndef __MINGW32__
 #define alloca _alloca
+#endif
 #define bzero(ptr,size) memset(ptr, 0, size)
 #define chdir _chdir
 #define dup _dup
 #define dup2 _dup2
 #define fdopen _fdopen
 #define fileno _fileno
+#ifndef __MINGW32__
 #define fstat _fstati64
+#endif
 #define ftruncate WIN32_ftruncate
 #define getcwd _getcwd
 #define getpid _getpid
 #define getrusage WIN32_getrusage
 #define ioctl ioctlsocket
 #define is_interface_down WIN32_is_interface_down
+#ifndef __MINGW32__
 #define lseek _lseeki64
+#endif
 #define memccpy _memccpy
+#ifndef __MINGW32__
 #define mkdir(p,m) _mkdir(p)
+#endif
 #define mktemp _mktemp
 #define open _open
 #define pclose _pclose
@@ -64,7 +73,9 @@
 #define setmode _setmode
 #define sleep(t) Sleep((t)*1000)
 #define snprintf _snprintf
+#ifndef __MINGW32__
 #define stat _stati64
+#endif
 #define strcasecmp _stricmp
 #define strdup _strdup
 #define strncasecmp _strnicmp
@@ -93,7 +104,9 @@
 #define O_NDELAY 0
 
 #define S_IRWXO 007
+#ifndef __MINGW32__
 #define S_ISDIR(m) (((m) & _S_IFDIR) == _S_IFDIR)
+#endif
 
 #define SIGHUP 1 /* hangup */
 #define SIGKILL 9 /* kill (cannot be caught or ignored) */
@@ -106,7 +119,9 @@
 #define ushort unsigned short int
 #define uid_t int
 #define gid_t int
+#ifndef __MINGW32__
 #define mode_t int
+#endif
 
 struct passwd {
         uid_t pw_uid;
@@ -138,13 +153,17 @@ struct statfs {
 #include <stddef.h>
 #include <process.h>
 /* Hack to suppress compiler warnings on FD_SET() & FD_CLR() */
+#ifndef __MINGW32__
 #pragma warning (push)
 #pragma warning (disable:4142)
 typedef int SOCKET;
 /* prevent inclusion of wingdi.h */
+#endif
 #define NOGDI
 #include <ws2spi.h>
+#ifndef __MINGW32__
 #pragma warning (pop)
+#endif
 #include "readdir.h"
 
 typedef char *caddr_t;
@@ -173,7 +192,11 @@ typedef struct {
         CRITICAL_SECTION lock;
 #endif /* _MT */
     } ioinfo;
+#ifndef __MINGW32__
 extern _CRTIMP ioinfo * __pioinfo[];
+#else
+__MINGW_IMPORT ioinfo * __pioinfo[];
+#endif
 #define IOINFO_L2E 5
 #define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E)
 #define _pioinfo(i) ( __pioinfo[(i) >> IOINFO_L2E] + ((i) & (IOINFO_ARRAY_ELTS - 1)) )
@@ -219,11 +242,12 @@ int __cdecl _free_osfhnd(int);
 
 #undef FD_ISSET
 #define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(_get_osfhandle(fd)), (fd_set FAR *)(set))
-
+#ifndef __MINGW32__
 extern __declspec(thread) int ws32_result;
-
+#else
+extern int ws32_result;
+#endif
 #define strerror(e) xbstrerror(e)
-
 /* internal to CRTLIB */
 /* used also in win32lib.c */
 extern void __cdecl _dosmaperr(unsigned long);
@@ -324,8 +348,14 @@ extern void __cdecl _dosmaperr(unsigned
 #define read _read
 #define write _write
 #else
+/* TODO: replace these declspecs with TLS indexes */
+#ifndef __MINGW32__
 extern __declspec(thread) int _so_err;
 extern __declspec(thread) int _so_err_siz;
+#else
+extern int _so_err;
+extern int _so_err_siz;
+#endif
 #define read(fd,buf,siz) \
         (_so_err_siz = sizeof(_so_err), \
         getsockopt((fd),SOL_SOCKET,SO_ERROR,&_so_err,&_so_err_siz) \
@@ -363,3 +393,4 @@ struct rusage {
         long ru_nvcsw; /* voluntary context switches */
         long ru_nivcsw; /* involuntary context switches */
 };
+
Index: src/Makefile.am
===================================================================
RCS file: /cvsroot/squid/squid/src/Makefile.am,v
retrieving revision 1.17.2.6
diff -u -p -r1.17.2.6 Makefile.am
--- src/Makefile.am 14 Jul 2002 20:56:06 -0000 1.17.2.6
+++ src/Makefile.am 4 Sep 2002 06:25:22 -0000
@@ -58,9 +58,9 @@ else
 WIN32SOURCE =
 endif
 
-SUBDIRS = fs repl auth
+INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include
 
-INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include
+SUBDIRS = fs repl auth
 
 EXTRA_PROGRAMS = \
         unlinkd \
Index: src/client.c
===================================================================
RCS file: /cvsroot/squid/squid/src/client.c,v
retrieving revision 1.8.4.4
diff -u -p -r1.8.4.4 client.c
--- src/client.c 16 Jul 2002 08:55:00 -0000 1.8.4.4
+++ src/client.c 4 Sep 2002 06:25:22 -0000
@@ -34,6 +34,9 @@
  */
 
 #include "squid.h"
+#ifdef __MINGW32__
+#include "/cygdrive/z/source/squid/squid_nt/port/win32/include/getopt.h"
+#endif
 
 #ifndef BUFSIZ
 #define BUFSIZ 8192
Index: src/squid.h
===================================================================
RCS file: /cvsroot/squid/squid/src/squid.h,v
retrieving revision 1.15.2.4
diff -u -p -r1.15.2.4 squid.h
--- src/squid.h 10 Aug 2002 07:09:21 -0000 1.15.2.4
+++ src/squid.h 4 Sep 2002 06:25:22 -0000
@@ -297,7 +297,7 @@
 #endif
 #endif
 
-#if !HAVE_STRUCT_RUSAGE
+#if !defined(HAVE_STRUCT_RUSAGE) && !defined(_SQUID_MSWIN_)
 /*
  * If we don't have getrusage() then we create a fake structure
  * with only the fields Squid cares about. This just makes the
Index: src/fs/ufs/store_dir_ufs.c
===================================================================
RCS file: /cvsroot/squid/squid/src/fs/ufs/store_dir_ufs.c,v
retrieving revision 1.24.2.11
diff -u -p -r1.24.2.11 store_dir_ufs.c
--- src/fs/ufs/store_dir_ufs.c 1 Sep 2002 16:57:02 -0000 1.24.2.11
+++ src/fs/ufs/store_dir_ufs.c 4 Sep 2002 06:25:24 -0000
@@ -214,7 +214,11 @@ storeUfsDirCreateDirectory(const char *p
         } else {
             fatalf("Swap directory %s is not a directory.", path);
         }
+#ifdef __MINGW32__
+ } else if (0 == mkdir(path)) {
+#else
     } else if (0 == mkdir(path, 0755)) {
+#endif
         debug(47, should_exist ? 1 : 3) ("%s created\n", path);
         created = 1;
     } else {
@@ -1168,7 +1172,11 @@ storeUfsDirClean(int swap_index)
     if (dp == NULL) {
         if (errno == ENOENT) {
             debug(36, 0) ("storeDirClean: WARNING: Creating %s\n", p1);
+#ifdef __MINGW32__
+ if (mkdir(p1) == 0)
+#else
             if (mkdir(p1, 0777) == 0)
+#endif
                 return 0;
         }
         debug(50, 0) ("storeDirClean: %s: %s\n", p1, xstrerror());

Received on Wed Sep 04 2002 - 00:32:06 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:16:26 MST