gen-win32.h revision 69fe9aaafdd6a141610e86a777d325db75422070
/*
* Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2001 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/*
* 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
* 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
* 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.
*/
/* $Id: gen-win32.h,v 1.18 2005/04/29 00:22:46 marka Exp $ */
/*! \file
* \author Principal Authors: Computer Systems Research Group at UC Berkeley
* \author Principal ISC caretaker: DCL
*/
/*
* \note This file was adapted from the NetBSD project's source tree, RCS ID:
* NetBSD: getopt.c,v 1.15 1999/09/20 04:39:37 lukem Exp
*
* The primary change has been to rename items to the ISC namespace
* and format in the ISC coding style.
*
* This file is responsible for defining two operations that are not
* directly portable between Unix-like systems and Windows NT, option
* parsing and directory scanning. It is here because it was decided
* that the "gen" build utility was not to depend on libisc.a, so
* the functions delcared in isc/commandline.h and isc/dir.h could not
* be used.
*
* The commandline stuff is pretty much a straight copy from the initial
* isc/commandline.c. The dir stuff was shrunk to fit the needs of gen.c.
*/
#ifndef DNS_GEN_WIN32_H
#define DNS_GEN_WIN32_H 1
#include <stdio.h>
#include <string.h>
#include <windows.h>
int isc_commandline_option; /* Character checked for validity. */
char *isc_commandline_argument; /* Argument associated with option. */
char *isc_commandline_progname; /* For printing error messages. */
#define BADOPT '?'
#define BADARG ':'
#define ENDOPT ""
/*
* getopt --
*/
int
char *option; /* Index into *options of option. */
/*
* Update scanning pointer, either because a reset was requested or
* the previous argv was finished.
*/
if (isc_commandline_progname == NULL)
isc_commandline_progname = argv[0];
if (isc_commandline_index >= argc ||
/*
* Index out of range or points to non-option.
*/
return (-1);
}
/*
* Found '--' to signal end of options. Advance
* index to next argv, the first non-option.
*/
return (-1);
}
}
isc_commandline_option = *place++;
/*
* Ensure valid option has been passed as specified by options string.
* '-:' is never a valid command line option because it could not
* distinguish ':' from the argument specifier in the options string.
*/
if (*place == '\0')
return (BADOPT);
}
if (*++option != ':') {
/*
* Option does not take an argument.
*/
/*
* Skip to next argv if at the end of the current argv.
*/
if (*place == '\0')
} else {
/*
* Option needs an argument.
*/
if (*place != '\0')
/*
* Option is in this argv, -D1 style.
*/
else if (argc > ++isc_commandline_index)
/*
* Option is next argv, -D 1 style.
*/
else {
/*
* Argument needed, but no more argv.
*/
/*
* Silent failure with "missing argument" return
* when ':' starts options string, per historical spec.
*/
if (*options == ':')
return (BADARG);
"%s: option requires an argument -- %c\n",
return (BADOPT);
}
/*
* Point to argv that follows argument.
*/
}
return (isc_commandline_option);
}
typedef struct {
char *filename;
} isc_dir_t;
/*
* Need space for slash-splat and final NUL.
*/
return (ISC_FALSE);
/*
* Append slash (if needed) and splat.
*/
*p++ = '\\';
*p++ = '*';
*p++ = '\0';
return (ISC_FALSE);
} else {
return (ISC_TRUE);
}
}
if (dir->first_file)
else
} else
return (ISC_TRUE);
else
return (ISC_FALSE);
}
void
}
#endif /* DNS_GEN_WIN32_H */