AppPkg/Applications/Python/Python-2.7.10: Initial Checkin part 5/5.
These files are candidates for modification during the port to EDK II. The following files were copied, unchanged, from the Python 2.7.2 port. Ia32/pyconfig.h X64/pyconfig.h PyMod-2.7.10/Modules/config.c PyMod-2.7.10/Modules/edk2module.c Py2710ReadMe.txt // Copied from PythonReadMe.txt Python2710.inf // Copied from PythonCore.inf The remaining files were copied, unchanged, from the cPython 2.7.10 distribution. These files are unchanged and set the baseline for subsequent commits. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Daryl McDaniel <edk2-lists@mc2research.org> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18741 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
committed by
darylm503
parent
3257aa9932
commit
3ec97ca490
4034
AppPkg/Applications/Python/Python-2.7.10/PyMod-2.7.10/Modules/_sre.c
Normal file
4034
AppPkg/Applications/Python/Python-2.7.10/PyMod-2.7.10/Modules/_sre.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE 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. Neither the name of the project 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 PROJECT 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 PROJECT 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.
|
||||
*/
|
||||
|
||||
#ifndef HAVE_GETADDRINFO
|
||||
|
||||
/*
|
||||
* Error return codes from getaddrinfo()
|
||||
*/
|
||||
#ifdef EAI_ADDRFAMILY
|
||||
/* If this is defined, there is a conflicting implementation
|
||||
in the C library, which can't be used for some reason.
|
||||
Make sure it won't interfere with this emulation. */
|
||||
|
||||
#undef EAI_ADDRFAMILY
|
||||
#undef EAI_AGAIN
|
||||
#undef EAI_BADFLAGS
|
||||
#undef EAI_FAIL
|
||||
#undef EAI_FAMILY
|
||||
#undef EAI_MEMORY
|
||||
#undef EAI_NODATA
|
||||
#undef EAI_NONAME
|
||||
#undef EAI_SERVICE
|
||||
#undef EAI_SOCKTYPE
|
||||
#undef EAI_SYSTEM
|
||||
#undef EAI_BADHINTS
|
||||
#undef EAI_PROTOCOL
|
||||
#undef EAI_MAX
|
||||
#undef getaddrinfo
|
||||
#define getaddrinfo fake_getaddrinfo
|
||||
#endif /* EAI_ADDRFAMILY */
|
||||
|
||||
#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */
|
||||
#define EAI_AGAIN 2 /* temporary failure in name resolution */
|
||||
#define EAI_BADFLAGS 3 /* invalid value for ai_flags */
|
||||
#define EAI_FAIL 4 /* non-recoverable failure in name resolution */
|
||||
#define EAI_FAMILY 5 /* ai_family not supported */
|
||||
#define EAI_MEMORY 6 /* memory allocation failure */
|
||||
#define EAI_NODATA 7 /* no address associated with hostname */
|
||||
#define EAI_NONAME 8 /* hostname nor servname provided, or not known */
|
||||
#define EAI_SERVICE 9 /* servname not supported for ai_socktype */
|
||||
#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
|
||||
#define EAI_SYSTEM 11 /* system error returned in errno */
|
||||
#define EAI_BADHINTS 12
|
||||
#define EAI_PROTOCOL 13
|
||||
#define EAI_MAX 14
|
||||
|
||||
/*
|
||||
* Flag values for getaddrinfo()
|
||||
*/
|
||||
#ifdef AI_PASSIVE
|
||||
#undef AI_PASSIVE
|
||||
#undef AI_CANONNAME
|
||||
#undef AI_NUMERICHOST
|
||||
#undef AI_MASK
|
||||
#undef AI_ALL
|
||||
#undef AI_V4MAPPED_CFG
|
||||
#undef AI_ADDRCONFIG
|
||||
#undef AI_V4MAPPED
|
||||
#undef AI_DEFAULT
|
||||
#endif /* AI_PASSIVE */
|
||||
|
||||
#define AI_PASSIVE 0x00000001 /* get address to use bind() */
|
||||
#define AI_CANONNAME 0x00000002 /* fill ai_canonname */
|
||||
#define AI_NUMERICHOST 0x00000004 /* prevent name resolution */
|
||||
/* valid flags for addrinfo */
|
||||
#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
|
||||
|
||||
#define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
|
||||
#define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
|
||||
#define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */
|
||||
#define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */
|
||||
/* special recommended flags for getipnodebyname */
|
||||
#define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
|
||||
|
||||
#endif /* !HAVE_GETADDRINFO */
|
||||
|
||||
#ifndef HAVE_GETNAMEINFO
|
||||
|
||||
/*
|
||||
* Constants for getnameinfo()
|
||||
*/
|
||||
#ifndef NI_MAXHOST
|
||||
#define NI_MAXHOST 1025
|
||||
#define NI_MAXSERV 32
|
||||
#endif /* !NI_MAXHOST */
|
||||
|
||||
/*
|
||||
* Flag values for getnameinfo()
|
||||
*/
|
||||
#ifndef NI_NOFQDN
|
||||
#define NI_NOFQDN 0x00000001
|
||||
#define NI_NUMERICHOST 0x00000002
|
||||
#define NI_NAMEREQD 0x00000004
|
||||
#define NI_NUMERICSERV 0x00000008
|
||||
#define NI_DGRAM 0x00000010
|
||||
#endif /* !NI_NOFQDN */
|
||||
|
||||
#endif /* !HAVE_GETNAMEINFO */
|
||||
|
||||
#ifndef HAVE_ADDRINFO
|
||||
struct addrinfo {
|
||||
int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
|
||||
int ai_family; /* PF_xxx */
|
||||
int ai_socktype; /* SOCK_xxx */
|
||||
int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
|
||||
size_t ai_addrlen; /* length of ai_addr */
|
||||
char *ai_canonname; /* canonical name for hostname */
|
||||
struct sockaddr *ai_addr; /* binary address */
|
||||
struct addrinfo *ai_next; /* next structure in linked list */
|
||||
};
|
||||
#endif /* !HAVE_ADDRINFO */
|
||||
|
||||
#ifndef HAVE_SOCKADDR_STORAGE
|
||||
/*
|
||||
* RFC 2553: protocol-independent placeholder for socket addresses
|
||||
*/
|
||||
#define _SS_MAXSIZE 128
|
||||
#ifdef HAVE_LONG_LONG
|
||||
#define _SS_ALIGNSIZE (sizeof(PY_LONG_LONG))
|
||||
#else
|
||||
#define _SS_ALIGNSIZE (sizeof(double))
|
||||
#endif /* HAVE_LONG_LONG */
|
||||
#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(u_char) * 2)
|
||||
#define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(u_char) * 2 - \
|
||||
_SS_PAD1SIZE - _SS_ALIGNSIZE)
|
||||
|
||||
struct sockaddr_storage {
|
||||
#ifdef HAVE_SOCKADDR_SA_LEN
|
||||
unsigned char ss_len; /* address length */
|
||||
unsigned char ss_family; /* address family */
|
||||
#else
|
||||
unsigned short ss_family; /* address family */
|
||||
#endif /* HAVE_SOCKADDR_SA_LEN */
|
||||
char __ss_pad1[_SS_PAD1SIZE];
|
||||
#ifdef HAVE_LONG_LONG
|
||||
PY_LONG_LONG __ss_align; /* force desired structure storage alignment */
|
||||
#else
|
||||
double __ss_align; /* force desired structure storage alignment */
|
||||
#endif /* HAVE_LONG_LONG */
|
||||
char __ss_pad2[_SS_PAD2SIZE];
|
||||
};
|
||||
#endif /* !HAVE_SOCKADDR_STORAGE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
extern void freehostent Py_PROTO((struct hostent *));
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,155 @@
|
||||
/** @file
|
||||
Python Module configuration.
|
||||
|
||||
Copyright (c) 2011-2012, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials are licensed and made available under
|
||||
the terms and conditions of the BSD License that accompanies this distribution.
|
||||
The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
**/
|
||||
|
||||
/* This file contains the table of built-in modules.
|
||||
See init_builtin() in import.c. */
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
extern void initarray(void);
|
||||
extern void init_ast(void);
|
||||
extern void initbinascii(void);
|
||||
extern void init_bisect(void);
|
||||
extern void initcmath(void);
|
||||
extern void init_codecs(void);
|
||||
extern void init_collections(void);
|
||||
extern void initcPickle(void);
|
||||
extern void initcStringIO(void);
|
||||
extern void init_csv(void);
|
||||
extern void init_ctypes(void);
|
||||
extern void initdatetime(void);
|
||||
extern void initedk2(void);
|
||||
extern void initerrno(void);
|
||||
extern void init_functools(void);
|
||||
extern void initfuture_builtins(void);
|
||||
extern void initgc(void);
|
||||
extern void init_heapq(void);
|
||||
extern void init_hotshot(void);
|
||||
extern void initimp(void);
|
||||
extern void init_io(void);
|
||||
extern void inititertools(void);
|
||||
extern void init_json(void);
|
||||
extern void init_lsprof(void);
|
||||
extern void initmath(void);
|
||||
extern void init_md5(void);
|
||||
extern void initmmap(void);
|
||||
extern void initoperator(void);
|
||||
extern void initparser(void);
|
||||
extern void initpyexpat(void);
|
||||
extern void init_random(void);
|
||||
extern void initselect(void);
|
||||
extern void init_sha(void);
|
||||
extern void init_sha256(void);
|
||||
extern void init_sha512(void);
|
||||
extern void initsignal(void);
|
||||
extern void init_socket(void);
|
||||
extern void init_sre(void);
|
||||
extern void initstrop(void);
|
||||
extern void init_struct(void);
|
||||
extern void init_subprocess(void);
|
||||
extern void init_symtable(void);
|
||||
extern void initthread(void);
|
||||
extern void inittime(void);
|
||||
extern void initunicodedata(void);
|
||||
extern void init_weakref(void);
|
||||
extern void init_winreg(void);
|
||||
extern void initxxsubtype(void);
|
||||
extern void initzipimport(void);
|
||||
extern void initzlib(void);
|
||||
|
||||
extern void PyMarshal_Init(void);
|
||||
extern void _PyWarnings_Init(void);
|
||||
|
||||
extern void init_multibytecodec(void);
|
||||
extern void init_codecs_cn(void);
|
||||
extern void init_codecs_hk(void);
|
||||
extern void init_codecs_iso2022(void);
|
||||
extern void init_codecs_jp(void);
|
||||
extern void init_codecs_kr(void);
|
||||
extern void init_codecs_tw(void);
|
||||
|
||||
struct _inittab _PyImport_Inittab[] = {
|
||||
|
||||
//{"_ast", init_ast},
|
||||
//{"_bisect", init_bisect}, /* A fast version of bisect.py */
|
||||
//{"_csv", init_csv},
|
||||
//{"_heapq", init_heapq}, /* A fast version of heapq.py */
|
||||
//{"_io", init_io},
|
||||
//{"_json", init_json},
|
||||
//{"_md5", init_md5},
|
||||
//{"_sha", init_sha},
|
||||
//{"_sha256", init_sha256},
|
||||
//{"_sha512", init_sha512},
|
||||
//{"_socket", init_socket},
|
||||
//{"_symtable", init_symtable},
|
||||
|
||||
//{"array", initarray},
|
||||
//{"cmath", initcmath},
|
||||
//{"cPickle", initcPickle},
|
||||
//{"datetime", initdatetime},
|
||||
//{"future_builtins", initfuture_builtins},
|
||||
//{"parser", initparser},
|
||||
//{"pyexpat", initpyexpat},
|
||||
//{"select", initselect},
|
||||
//{"signal", initsignal},
|
||||
//{"strop", initstrop}, /* redefines some string operations that are 100-1000 times faster */
|
||||
//{"unicodedata", initunicodedata},
|
||||
//{"xxsubtype", initxxsubtype},
|
||||
//{"zipimport", initzipimport},
|
||||
//{"zlib", initzlib},
|
||||
|
||||
/* CJK codecs */
|
||||
//{"_multibytecodec", init_multibytecodec},
|
||||
//{"_codecs_cn", init_codecs_cn},
|
||||
//{"_codecs_hk", init_codecs_hk},
|
||||
//{"_codecs_iso2022", init_codecs_iso2022},
|
||||
//{"_codecs_jp", init_codecs_jp},
|
||||
//{"_codecs_kr", init_codecs_kr},
|
||||
//{"_codecs_tw", init_codecs_tw},
|
||||
|
||||
#ifdef WITH_THREAD
|
||||
{"thread", initthread},
|
||||
#endif
|
||||
|
||||
/* These modules are required for the full built-in help() facility provided by pydoc. */
|
||||
{"_codecs", init_codecs},
|
||||
{"_collections", init_collections},
|
||||
{"_functools", init_functools},
|
||||
{"_random", init_random},
|
||||
{"_sre", init_sre},
|
||||
{"_struct", init_struct}, /* Required by the logging package. */
|
||||
{"_weakref", init_weakref},
|
||||
{"binascii", initbinascii},
|
||||
{"cStringIO", initcStringIO}, /* Required by several modules, such as logging. */
|
||||
{"gc", initgc},
|
||||
{"itertools", inititertools},
|
||||
{"math", initmath},
|
||||
{"operator", initoperator},
|
||||
{"time", inittime},
|
||||
|
||||
/* These four modules should always be built in. */
|
||||
{"edk2", initedk2},
|
||||
{"errno", initerrno},
|
||||
{"imp", initimp}, /* We get this for free from Python/import.c */
|
||||
{"marshal", PyMarshal_Init}, /* We get this for free from Python/marshal.c */
|
||||
|
||||
/* These entries are here for sys.builtin_module_names */
|
||||
{"__main__", NULL},
|
||||
{"__builtin__", NULL},
|
||||
{"sys", NULL},
|
||||
{"exceptions", NULL},
|
||||
{"_warnings", _PyWarnings_Init},
|
||||
|
||||
/* Sentinel */
|
||||
{0, 0}
|
||||
};
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,791 @@
|
||||
|
||||
/* Errno module */
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
/* Windows socket errors (WSA*) */
|
||||
#ifdef MS_WINDOWS
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Pull in the system error definitions
|
||||
*/
|
||||
|
||||
static PyMethodDef errno_methods[] = {
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
/* Helper function doing the dictionary inserting */
|
||||
|
||||
static void
|
||||
_inscode(PyObject *d, PyObject *de, char *name, int code)
|
||||
{
|
||||
PyObject *u = PyString_FromString(name);
|
||||
PyObject *v = PyInt_FromLong((long) code);
|
||||
|
||||
/* Don't bother checking for errors; they'll be caught at the end
|
||||
* of the module initialization function by the caller of
|
||||
* initerrno().
|
||||
*/
|
||||
if (u && v) {
|
||||
/* insert in modules dict */
|
||||
PyDict_SetItem(d, u, v);
|
||||
/* insert in errorcode dict */
|
||||
PyDict_SetItem(de, v, u);
|
||||
}
|
||||
Py_XDECREF(u);
|
||||
Py_XDECREF(v);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(errno__doc__,
|
||||
"This module makes available standard errno system symbols.\n\
|
||||
\n\
|
||||
The value of each symbol is the corresponding integer value,\n\
|
||||
e.g., on most systems, errno.ENOENT equals the integer 2.\n\
|
||||
\n\
|
||||
The dictionary errno.errorcode maps numeric codes to symbol names,\n\
|
||||
e.g., errno.errorcode[2] could be the string 'ENOENT'.\n\
|
||||
\n\
|
||||
Symbols that are not relevant to the underlying system are not defined.\n\
|
||||
\n\
|
||||
To map error codes to error messages, use the function os.strerror(),\n\
|
||||
e.g. os.strerror(2) could return 'No such file or directory'.");
|
||||
|
||||
PyMODINIT_FUNC
|
||||
initerrno(void)
|
||||
{
|
||||
PyObject *m, *d, *de;
|
||||
m = Py_InitModule3("errno", errno_methods, errno__doc__);
|
||||
if (m == NULL)
|
||||
return;
|
||||
d = PyModule_GetDict(m);
|
||||
de = PyDict_New();
|
||||
if (!d || !de || PyDict_SetItemString(d, "errorcode", de) < 0)
|
||||
return;
|
||||
|
||||
/* Macro so I don't have to edit each and every line below... */
|
||||
#define inscode(d, ds, de, name, code, comment) _inscode(d, de, name, code)
|
||||
|
||||
/*
|
||||
* The names and comments are borrowed from linux/include/errno.h,
|
||||
* which should be pretty all-inclusive
|
||||
*/
|
||||
|
||||
#ifdef ENODEV
|
||||
inscode(d, ds, de, "ENODEV", ENODEV, "No such device");
|
||||
#endif
|
||||
#ifdef ENOCSI
|
||||
inscode(d, ds, de, "ENOCSI", ENOCSI, "No CSI structure available");
|
||||
#endif
|
||||
#ifdef EHOSTUNREACH
|
||||
inscode(d, ds, de, "EHOSTUNREACH", EHOSTUNREACH, "No route to host");
|
||||
#else
|
||||
#ifdef WSAEHOSTUNREACH
|
||||
inscode(d, ds, de, "EHOSTUNREACH", WSAEHOSTUNREACH, "No route to host");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ENOMSG
|
||||
inscode(d, ds, de, "ENOMSG", ENOMSG, "No message of desired type");
|
||||
#endif
|
||||
#ifdef EUCLEAN
|
||||
inscode(d, ds, de, "EUCLEAN", EUCLEAN, "Structure needs cleaning");
|
||||
#endif
|
||||
#ifdef EL2NSYNC
|
||||
inscode(d, ds, de, "EL2NSYNC", EL2NSYNC, "Level 2 not synchronized");
|
||||
#endif
|
||||
#ifdef EL2HLT
|
||||
inscode(d, ds, de, "EL2HLT", EL2HLT, "Level 2 halted");
|
||||
#endif
|
||||
#ifdef ENODATA
|
||||
inscode(d, ds, de, "ENODATA", ENODATA, "No data available");
|
||||
#endif
|
||||
#ifdef ENOTBLK
|
||||
inscode(d, ds, de, "ENOTBLK", ENOTBLK, "Block device required");
|
||||
#endif
|
||||
#ifdef ENOSYS
|
||||
inscode(d, ds, de, "ENOSYS", ENOSYS, "Function not implemented");
|
||||
#endif
|
||||
#ifdef EPIPE
|
||||
inscode(d, ds, de, "EPIPE", EPIPE, "Broken pipe");
|
||||
#endif
|
||||
#ifdef EINVAL
|
||||
inscode(d, ds, de, "EINVAL", EINVAL, "Invalid argument");
|
||||
#else
|
||||
#ifdef WSAEINVAL
|
||||
inscode(d, ds, de, "EINVAL", WSAEINVAL, "Invalid argument");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef EOVERFLOW
|
||||
inscode(d, ds, de, "EOVERFLOW", EOVERFLOW, "Value too large for defined data type");
|
||||
#endif
|
||||
#ifdef EADV
|
||||
inscode(d, ds, de, "EADV", EADV, "Advertise error");
|
||||
#endif
|
||||
#ifdef EINTR
|
||||
inscode(d, ds, de, "EINTR", EINTR, "Interrupted system call");
|
||||
#else
|
||||
#ifdef WSAEINTR
|
||||
inscode(d, ds, de, "EINTR", WSAEINTR, "Interrupted system call");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef EUSERS
|
||||
inscode(d, ds, de, "EUSERS", EUSERS, "Too many users");
|
||||
#else
|
||||
#ifdef WSAEUSERS
|
||||
inscode(d, ds, de, "EUSERS", WSAEUSERS, "Too many users");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ENOTEMPTY
|
||||
inscode(d, ds, de, "ENOTEMPTY", ENOTEMPTY, "Directory not empty");
|
||||
#else
|
||||
#ifdef WSAENOTEMPTY
|
||||
inscode(d, ds, de, "ENOTEMPTY", WSAENOTEMPTY, "Directory not empty");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ENOBUFS
|
||||
inscode(d, ds, de, "ENOBUFS", ENOBUFS, "No buffer space available");
|
||||
#else
|
||||
#ifdef WSAENOBUFS
|
||||
inscode(d, ds, de, "ENOBUFS", WSAENOBUFS, "No buffer space available");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef EPROTO
|
||||
inscode(d, ds, de, "EPROTO", EPROTO, "Protocol error");
|
||||
#endif
|
||||
#ifdef EREMOTE
|
||||
inscode(d, ds, de, "EREMOTE", EREMOTE, "Object is remote");
|
||||
#else
|
||||
#ifdef WSAEREMOTE
|
||||
inscode(d, ds, de, "EREMOTE", WSAEREMOTE, "Object is remote");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ENAVAIL
|
||||
inscode(d, ds, de, "ENAVAIL", ENAVAIL, "No XENIX semaphores available");
|
||||
#endif
|
||||
#ifdef ECHILD
|
||||
inscode(d, ds, de, "ECHILD", ECHILD, "No child processes");
|
||||
#endif
|
||||
#ifdef ELOOP
|
||||
inscode(d, ds, de, "ELOOP", ELOOP, "Too many symbolic links encountered");
|
||||
#else
|
||||
#ifdef WSAELOOP
|
||||
inscode(d, ds, de, "ELOOP", WSAELOOP, "Too many symbolic links encountered");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef EXDEV
|
||||
inscode(d, ds, de, "EXDEV", EXDEV, "Cross-device link");
|
||||
#endif
|
||||
#ifdef E2BIG
|
||||
inscode(d, ds, de, "E2BIG", E2BIG, "Arg list too long");
|
||||
#endif
|
||||
#ifdef ESRCH
|
||||
inscode(d, ds, de, "ESRCH", ESRCH, "No such process");
|
||||
#endif
|
||||
#ifdef EMSGSIZE
|
||||
inscode(d, ds, de, "EMSGSIZE", EMSGSIZE, "Message too long");
|
||||
#else
|
||||
#ifdef WSAEMSGSIZE
|
||||
inscode(d, ds, de, "EMSGSIZE", WSAEMSGSIZE, "Message too long");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef EAFNOSUPPORT
|
||||
inscode(d, ds, de, "EAFNOSUPPORT", EAFNOSUPPORT, "Address family not supported by protocol");
|
||||
#else
|
||||
#ifdef WSAEAFNOSUPPORT
|
||||
inscode(d, ds, de, "EAFNOSUPPORT", WSAEAFNOSUPPORT, "Address family not supported by protocol");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef EBADR
|
||||
inscode(d, ds, de, "EBADR", EBADR, "Invalid request descriptor");
|
||||
#endif
|
||||
#ifdef EHOSTDOWN
|
||||
inscode(d, ds, de, "EHOSTDOWN", EHOSTDOWN, "Host is down");
|
||||
#else
|
||||
#ifdef WSAEHOSTDOWN
|
||||
inscode(d, ds, de, "EHOSTDOWN", WSAEHOSTDOWN, "Host is down");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef EPFNOSUPPORT
|
||||
inscode(d, ds, de, "EPFNOSUPPORT", EPFNOSUPPORT, "Protocol family not supported");
|
||||
#else
|
||||
#ifdef WSAEPFNOSUPPORT
|
||||
inscode(d, ds, de, "EPFNOSUPPORT", WSAEPFNOSUPPORT, "Protocol family not supported");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ENOPROTOOPT
|
||||
inscode(d, ds, de, "ENOPROTOOPT", ENOPROTOOPT, "Protocol not available");
|
||||
#else
|
||||
#ifdef WSAENOPROTOOPT
|
||||
inscode(d, ds, de, "ENOPROTOOPT", WSAENOPROTOOPT, "Protocol not available");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef EBUSY
|
||||
inscode(d, ds, de, "EBUSY", EBUSY, "Device or resource busy");
|
||||
#endif
|
||||
#ifdef EWOULDBLOCK
|
||||
inscode(d, ds, de, "EWOULDBLOCK", EWOULDBLOCK, "Operation would block");
|
||||
#else
|
||||
#ifdef WSAEWOULDBLOCK
|
||||
inscode(d, ds, de, "EWOULDBLOCK", WSAEWOULDBLOCK, "Operation would block");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef EBADFD
|
||||
inscode(d, ds, de, "EBADFD", EBADFD, "File descriptor in bad state");
|
||||
#endif
|
||||
#ifdef EDOTDOT
|
||||
inscode(d, ds, de, "EDOTDOT", EDOTDOT, "RFS specific error");
|
||||
#endif
|
||||
#ifdef EISCONN
|
||||
inscode(d, ds, de, "EISCONN", EISCONN, "Transport endpoint is already connected");
|
||||
#else
|
||||
#ifdef WSAEISCONN
|
||||
inscode(d, ds, de, "EISCONN", WSAEISCONN, "Transport endpoint is already connected");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ENOANO
|
||||
inscode(d, ds, de, "ENOANO", ENOANO, "No anode");
|
||||
#endif
|
||||
#ifdef ESHUTDOWN
|
||||
inscode(d, ds, de, "ESHUTDOWN", ESHUTDOWN, "Cannot send after transport endpoint shutdown");
|
||||
#else
|
||||
#ifdef WSAESHUTDOWN
|
||||
inscode(d, ds, de, "ESHUTDOWN", WSAESHUTDOWN, "Cannot send after transport endpoint shutdown");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ECHRNG
|
||||
inscode(d, ds, de, "ECHRNG", ECHRNG, "Channel number out of range");
|
||||
#endif
|
||||
#ifdef ELIBBAD
|
||||
inscode(d, ds, de, "ELIBBAD", ELIBBAD, "Accessing a corrupted shared library");
|
||||
#endif
|
||||
#ifdef ENONET
|
||||
inscode(d, ds, de, "ENONET", ENONET, "Machine is not on the network");
|
||||
#endif
|
||||
#ifdef EBADE
|
||||
inscode(d, ds, de, "EBADE", EBADE, "Invalid exchange");
|
||||
#endif
|
||||
#ifdef EBADF
|
||||
inscode(d, ds, de, "EBADF", EBADF, "Bad file number");
|
||||
#else
|
||||
#ifdef WSAEBADF
|
||||
inscode(d, ds, de, "EBADF", WSAEBADF, "Bad file number");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef EMULTIHOP
|
||||
inscode(d, ds, de, "EMULTIHOP", EMULTIHOP, "Multihop attempted");
|
||||
#endif
|
||||
#ifdef EIO
|
||||
inscode(d, ds, de, "EIO", EIO, "I/O error");
|
||||
#endif
|
||||
#ifdef EUNATCH
|
||||
inscode(d, ds, de, "EUNATCH", EUNATCH, "Protocol driver not attached");
|
||||
#endif
|
||||
#ifdef EPROTOTYPE
|
||||
inscode(d, ds, de, "EPROTOTYPE", EPROTOTYPE, "Protocol wrong type for socket");
|
||||
#else
|
||||
#ifdef WSAEPROTOTYPE
|
||||
inscode(d, ds, de, "EPROTOTYPE", WSAEPROTOTYPE, "Protocol wrong type for socket");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ENOSPC
|
||||
inscode(d, ds, de, "ENOSPC", ENOSPC, "No space left on device");
|
||||
#endif
|
||||
#ifdef ENOEXEC
|
||||
inscode(d, ds, de, "ENOEXEC", ENOEXEC, "Exec format error");
|
||||
#endif
|
||||
#ifdef EALREADY
|
||||
inscode(d, ds, de, "EALREADY", EALREADY, "Operation already in progress");
|
||||
#else
|
||||
#ifdef WSAEALREADY
|
||||
inscode(d, ds, de, "EALREADY", WSAEALREADY, "Operation already in progress");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ENETDOWN
|
||||
inscode(d, ds, de, "ENETDOWN", ENETDOWN, "Network is down");
|
||||
#else
|
||||
#ifdef WSAENETDOWN
|
||||
inscode(d, ds, de, "ENETDOWN", WSAENETDOWN, "Network is down");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ENOTNAM
|
||||
inscode(d, ds, de, "ENOTNAM", ENOTNAM, "Not a XENIX named type file");
|
||||
#endif
|
||||
#ifdef EACCES
|
||||
inscode(d, ds, de, "EACCES", EACCES, "Permission denied");
|
||||
#else
|
||||
#ifdef WSAEACCES
|
||||
inscode(d, ds, de, "EACCES", WSAEACCES, "Permission denied");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ELNRNG
|
||||
inscode(d, ds, de, "ELNRNG", ELNRNG, "Link number out of range");
|
||||
#endif
|
||||
#ifdef EILSEQ
|
||||
inscode(d, ds, de, "EILSEQ", EILSEQ, "Illegal byte sequence");
|
||||
#endif
|
||||
#ifdef ENOTDIR
|
||||
inscode(d, ds, de, "ENOTDIR", ENOTDIR, "Not a directory");
|
||||
#endif
|
||||
#ifdef ENOTUNIQ
|
||||
inscode(d, ds, de, "ENOTUNIQ", ENOTUNIQ, "Name not unique on network");
|
||||
#endif
|
||||
#ifdef EPERM
|
||||
inscode(d, ds, de, "EPERM", EPERM, "Operation not permitted");
|
||||
#endif
|
||||
#ifdef EDOM
|
||||
inscode(d, ds, de, "EDOM", EDOM, "Math argument out of domain of func");
|
||||
#endif
|
||||
#ifdef EXFULL
|
||||
inscode(d, ds, de, "EXFULL", EXFULL, "Exchange full");
|
||||
#endif
|
||||
#ifdef ECONNREFUSED
|
||||
inscode(d, ds, de, "ECONNREFUSED", ECONNREFUSED, "Connection refused");
|
||||
#else
|
||||
#ifdef WSAECONNREFUSED
|
||||
inscode(d, ds, de, "ECONNREFUSED", WSAECONNREFUSED, "Connection refused");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef EISDIR
|
||||
inscode(d, ds, de, "EISDIR", EISDIR, "Is a directory");
|
||||
#endif
|
||||
#ifdef EPROTONOSUPPORT
|
||||
inscode(d, ds, de, "EPROTONOSUPPORT", EPROTONOSUPPORT, "Protocol not supported");
|
||||
#else
|
||||
#ifdef WSAEPROTONOSUPPORT
|
||||
inscode(d, ds, de, "EPROTONOSUPPORT", WSAEPROTONOSUPPORT, "Protocol not supported");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef EROFS
|
||||
inscode(d, ds, de, "EROFS", EROFS, "Read-only file system");
|
||||
#endif
|
||||
#ifdef EADDRNOTAVAIL
|
||||
inscode(d, ds, de, "EADDRNOTAVAIL", EADDRNOTAVAIL, "Cannot assign requested address");
|
||||
#else
|
||||
#ifdef WSAEADDRNOTAVAIL
|
||||
inscode(d, ds, de, "EADDRNOTAVAIL", WSAEADDRNOTAVAIL, "Cannot assign requested address");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef EIDRM
|
||||
inscode(d, ds, de, "EIDRM", EIDRM, "Identifier removed");
|
||||
#endif
|
||||
#ifdef ECOMM
|
||||
inscode(d, ds, de, "ECOMM", ECOMM, "Communication error on send");
|
||||
#endif
|
||||
#ifdef ESRMNT
|
||||
inscode(d, ds, de, "ESRMNT", ESRMNT, "Srmount error");
|
||||
#endif
|
||||
#ifdef EREMOTEIO
|
||||
inscode(d, ds, de, "EREMOTEIO", EREMOTEIO, "Remote I/O error");
|
||||
#endif
|
||||
#ifdef EL3RST
|
||||
inscode(d, ds, de, "EL3RST", EL3RST, "Level 3 reset");
|
||||
#endif
|
||||
#ifdef EBADMSG
|
||||
inscode(d, ds, de, "EBADMSG", EBADMSG, "Not a data message");
|
||||
#endif
|
||||
#ifdef ENFILE
|
||||
inscode(d, ds, de, "ENFILE", ENFILE, "File table overflow");
|
||||
#endif
|
||||
#ifdef ELIBMAX
|
||||
inscode(d, ds, de, "ELIBMAX", ELIBMAX, "Attempting to link in too many shared libraries");
|
||||
#endif
|
||||
#ifdef ESPIPE
|
||||
inscode(d, ds, de, "ESPIPE", ESPIPE, "Illegal seek");
|
||||
#endif
|
||||
#ifdef ENOLINK
|
||||
inscode(d, ds, de, "ENOLINK", ENOLINK, "Link has been severed");
|
||||
#endif
|
||||
#ifdef ENETRESET
|
||||
inscode(d, ds, de, "ENETRESET", ENETRESET, "Network dropped connection because of reset");
|
||||
#else
|
||||
#ifdef WSAENETRESET
|
||||
inscode(d, ds, de, "ENETRESET", WSAENETRESET, "Network dropped connection because of reset");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ETIMEDOUT
|
||||
inscode(d, ds, de, "ETIMEDOUT", ETIMEDOUT, "Connection timed out");
|
||||
#else
|
||||
#ifdef WSAETIMEDOUT
|
||||
inscode(d, ds, de, "ETIMEDOUT", WSAETIMEDOUT, "Connection timed out");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ENOENT
|
||||
inscode(d, ds, de, "ENOENT", ENOENT, "No such file or directory");
|
||||
#endif
|
||||
#ifdef EEXIST
|
||||
inscode(d, ds, de, "EEXIST", EEXIST, "File exists");
|
||||
#endif
|
||||
#ifdef EDQUOT
|
||||
inscode(d, ds, de, "EDQUOT", EDQUOT, "Quota exceeded");
|
||||
#else
|
||||
#ifdef WSAEDQUOT
|
||||
inscode(d, ds, de, "EDQUOT", WSAEDQUOT, "Quota exceeded");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ENOSTR
|
||||
inscode(d, ds, de, "ENOSTR", ENOSTR, "Device not a stream");
|
||||
#endif
|
||||
#ifdef EBADSLT
|
||||
inscode(d, ds, de, "EBADSLT", EBADSLT, "Invalid slot");
|
||||
#endif
|
||||
#ifdef EBADRQC
|
||||
inscode(d, ds, de, "EBADRQC", EBADRQC, "Invalid request code");
|
||||
#endif
|
||||
#ifdef ELIBACC
|
||||
inscode(d, ds, de, "ELIBACC", ELIBACC, "Can not access a needed shared library");
|
||||
#endif
|
||||
#ifdef EFAULT
|
||||
inscode(d, ds, de, "EFAULT", EFAULT, "Bad address");
|
||||
#else
|
||||
#ifdef WSAEFAULT
|
||||
inscode(d, ds, de, "EFAULT", WSAEFAULT, "Bad address");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef EFBIG
|
||||
inscode(d, ds, de, "EFBIG", EFBIG, "File too large");
|
||||
#endif
|
||||
#ifdef EDEADLK
|
||||
inscode(d, ds, de, "EDEADLK", EDEADLK, "Resource deadlock would occur");
|
||||
#endif
|
||||
#ifdef ENOTCONN
|
||||
inscode(d, ds, de, "ENOTCONN", ENOTCONN, "Transport endpoint is not connected");
|
||||
#else
|
||||
#ifdef WSAENOTCONN
|
||||
inscode(d, ds, de, "ENOTCONN", WSAENOTCONN, "Transport endpoint is not connected");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef EDESTADDRREQ
|
||||
inscode(d, ds, de, "EDESTADDRREQ", EDESTADDRREQ, "Destination address required");
|
||||
#else
|
||||
#ifdef WSAEDESTADDRREQ
|
||||
inscode(d, ds, de, "EDESTADDRREQ", WSAEDESTADDRREQ, "Destination address required");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ELIBSCN
|
||||
inscode(d, ds, de, "ELIBSCN", ELIBSCN, ".lib section in a.out corrupted");
|
||||
#endif
|
||||
#ifdef ENOLCK
|
||||
inscode(d, ds, de, "ENOLCK", ENOLCK, "No record locks available");
|
||||
#endif
|
||||
#ifdef EISNAM
|
||||
inscode(d, ds, de, "EISNAM", EISNAM, "Is a named type file");
|
||||
#endif
|
||||
#ifdef ECONNABORTED
|
||||
inscode(d, ds, de, "ECONNABORTED", ECONNABORTED, "Software caused connection abort");
|
||||
#else
|
||||
#ifdef WSAECONNABORTED
|
||||
inscode(d, ds, de, "ECONNABORTED", WSAECONNABORTED, "Software caused connection abort");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ENETUNREACH
|
||||
inscode(d, ds, de, "ENETUNREACH", ENETUNREACH, "Network is unreachable");
|
||||
#else
|
||||
#ifdef WSAENETUNREACH
|
||||
inscode(d, ds, de, "ENETUNREACH", WSAENETUNREACH, "Network is unreachable");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ESTALE
|
||||
inscode(d, ds, de, "ESTALE", ESTALE, "Stale NFS file handle");
|
||||
#else
|
||||
#ifdef WSAESTALE
|
||||
inscode(d, ds, de, "ESTALE", WSAESTALE, "Stale NFS file handle");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ENOSR
|
||||
inscode(d, ds, de, "ENOSR", ENOSR, "Out of streams resources");
|
||||
#endif
|
||||
#ifdef ENOMEM
|
||||
inscode(d, ds, de, "ENOMEM", ENOMEM, "Out of memory");
|
||||
#endif
|
||||
#ifdef ENOTSOCK
|
||||
inscode(d, ds, de, "ENOTSOCK", ENOTSOCK, "Socket operation on non-socket");
|
||||
#else
|
||||
#ifdef WSAENOTSOCK
|
||||
inscode(d, ds, de, "ENOTSOCK", WSAENOTSOCK, "Socket operation on non-socket");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ESTRPIPE
|
||||
inscode(d, ds, de, "ESTRPIPE", ESTRPIPE, "Streams pipe error");
|
||||
#endif
|
||||
#ifdef EMLINK
|
||||
inscode(d, ds, de, "EMLINK", EMLINK, "Too many links");
|
||||
#endif
|
||||
#ifdef ERANGE
|
||||
inscode(d, ds, de, "ERANGE", ERANGE, "Math result not representable");
|
||||
#endif
|
||||
#ifdef ELIBEXEC
|
||||
inscode(d, ds, de, "ELIBEXEC", ELIBEXEC, "Cannot exec a shared library directly");
|
||||
#endif
|
||||
#ifdef EL3HLT
|
||||
inscode(d, ds, de, "EL3HLT", EL3HLT, "Level 3 halted");
|
||||
#endif
|
||||
#ifdef ECONNRESET
|
||||
inscode(d, ds, de, "ECONNRESET", ECONNRESET, "Connection reset by peer");
|
||||
#else
|
||||
#ifdef WSAECONNRESET
|
||||
inscode(d, ds, de, "ECONNRESET", WSAECONNRESET, "Connection reset by peer");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef EADDRINUSE
|
||||
inscode(d, ds, de, "EADDRINUSE", EADDRINUSE, "Address already in use");
|
||||
#else
|
||||
#ifdef WSAEADDRINUSE
|
||||
inscode(d, ds, de, "EADDRINUSE", WSAEADDRINUSE, "Address already in use");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef EOPNOTSUPP
|
||||
inscode(d, ds, de, "EOPNOTSUPP", EOPNOTSUPP, "Operation not supported on transport endpoint");
|
||||
#else
|
||||
#ifdef WSAEOPNOTSUPP
|
||||
inscode(d, ds, de, "EOPNOTSUPP", WSAEOPNOTSUPP, "Operation not supported on transport endpoint");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef EREMCHG
|
||||
inscode(d, ds, de, "EREMCHG", EREMCHG, "Remote address changed");
|
||||
#endif
|
||||
#ifdef EAGAIN
|
||||
inscode(d, ds, de, "EAGAIN", EAGAIN, "Try again");
|
||||
#endif
|
||||
#ifdef ENAMETOOLONG
|
||||
inscode(d, ds, de, "ENAMETOOLONG", ENAMETOOLONG, "File name too long");
|
||||
#else
|
||||
#ifdef WSAENAMETOOLONG
|
||||
inscode(d, ds, de, "ENAMETOOLONG", WSAENAMETOOLONG, "File name too long");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ENOTTY
|
||||
inscode(d, ds, de, "ENOTTY", ENOTTY, "Not a typewriter");
|
||||
#endif
|
||||
#ifdef ERESTART
|
||||
inscode(d, ds, de, "ERESTART", ERESTART, "Interrupted system call should be restarted");
|
||||
#endif
|
||||
#ifdef ESOCKTNOSUPPORT
|
||||
inscode(d, ds, de, "ESOCKTNOSUPPORT", ESOCKTNOSUPPORT, "Socket type not supported");
|
||||
#else
|
||||
#ifdef WSAESOCKTNOSUPPORT
|
||||
inscode(d, ds, de, "ESOCKTNOSUPPORT", WSAESOCKTNOSUPPORT, "Socket type not supported");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ETIME
|
||||
inscode(d, ds, de, "ETIME", ETIME, "Timer expired");
|
||||
#endif
|
||||
#ifdef EBFONT
|
||||
inscode(d, ds, de, "EBFONT", EBFONT, "Bad font file format");
|
||||
#endif
|
||||
#ifdef EDEADLOCK
|
||||
inscode(d, ds, de, "EDEADLOCK", EDEADLOCK, "Error EDEADLOCK");
|
||||
#endif
|
||||
#ifdef ETOOMANYREFS
|
||||
inscode(d, ds, de, "ETOOMANYREFS", ETOOMANYREFS, "Too many references: cannot splice");
|
||||
#else
|
||||
#ifdef WSAETOOMANYREFS
|
||||
inscode(d, ds, de, "ETOOMANYREFS", WSAETOOMANYREFS, "Too many references: cannot splice");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef EMFILE
|
||||
inscode(d, ds, de, "EMFILE", EMFILE, "Too many open files");
|
||||
#else
|
||||
#ifdef WSAEMFILE
|
||||
inscode(d, ds, de, "EMFILE", WSAEMFILE, "Too many open files");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ETXTBSY
|
||||
inscode(d, ds, de, "ETXTBSY", ETXTBSY, "Text file busy");
|
||||
#endif
|
||||
#ifdef EINPROGRESS
|
||||
inscode(d, ds, de, "EINPROGRESS", EINPROGRESS, "Operation now in progress");
|
||||
#else
|
||||
#ifdef WSAEINPROGRESS
|
||||
inscode(d, ds, de, "EINPROGRESS", WSAEINPROGRESS, "Operation now in progress");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ENXIO
|
||||
inscode(d, ds, de, "ENXIO", ENXIO, "No such device or address");
|
||||
#endif
|
||||
#ifdef ENOPKG
|
||||
inscode(d, ds, de, "ENOPKG", ENOPKG, "Package not installed");
|
||||
#endif
|
||||
#ifdef WSASY
|
||||
inscode(d, ds, de, "WSASY", WSASY, "Error WSASY");
|
||||
#endif
|
||||
#ifdef WSAEHOSTDOWN
|
||||
inscode(d, ds, de, "WSAEHOSTDOWN", WSAEHOSTDOWN, "Host is down");
|
||||
#endif
|
||||
#ifdef WSAENETDOWN
|
||||
inscode(d, ds, de, "WSAENETDOWN", WSAENETDOWN, "Network is down");
|
||||
#endif
|
||||
#ifdef WSAENOTSOCK
|
||||
inscode(d, ds, de, "WSAENOTSOCK", WSAENOTSOCK, "Socket operation on non-socket");
|
||||
#endif
|
||||
#ifdef WSAEHOSTUNREACH
|
||||
inscode(d, ds, de, "WSAEHOSTUNREACH", WSAEHOSTUNREACH, "No route to host");
|
||||
#endif
|
||||
#ifdef WSAELOOP
|
||||
inscode(d, ds, de, "WSAELOOP", WSAELOOP, "Too many symbolic links encountered");
|
||||
#endif
|
||||
#ifdef WSAEMFILE
|
||||
inscode(d, ds, de, "WSAEMFILE", WSAEMFILE, "Too many open files");
|
||||
#endif
|
||||
#ifdef WSAESTALE
|
||||
inscode(d, ds, de, "WSAESTALE", WSAESTALE, "Stale NFS file handle");
|
||||
#endif
|
||||
#ifdef WSAVERNOTSUPPORTED
|
||||
inscode(d, ds, de, "WSAVERNOTSUPPORTED", WSAVERNOTSUPPORTED, "Error WSAVERNOTSUPPORTED");
|
||||
#endif
|
||||
#ifdef WSAENETUNREACH
|
||||
inscode(d, ds, de, "WSAENETUNREACH", WSAENETUNREACH, "Network is unreachable");
|
||||
#endif
|
||||
#ifdef WSAEPROCLIM
|
||||
inscode(d, ds, de, "WSAEPROCLIM", WSAEPROCLIM, "Error WSAEPROCLIM");
|
||||
#endif
|
||||
#ifdef WSAEFAULT
|
||||
inscode(d, ds, de, "WSAEFAULT", WSAEFAULT, "Bad address");
|
||||
#endif
|
||||
#ifdef WSANOTINITIALISED
|
||||
inscode(d, ds, de, "WSANOTINITIALISED", WSANOTINITIALISED, "Error WSANOTINITIALISED");
|
||||
#endif
|
||||
#ifdef WSAEUSERS
|
||||
inscode(d, ds, de, "WSAEUSERS", WSAEUSERS, "Too many users");
|
||||
#endif
|
||||
#ifdef WSAMAKEASYNCREPL
|
||||
inscode(d, ds, de, "WSAMAKEASYNCREPL", WSAMAKEASYNCREPL, "Error WSAMAKEASYNCREPL");
|
||||
#endif
|
||||
#ifdef WSAENOPROTOOPT
|
||||
inscode(d, ds, de, "WSAENOPROTOOPT", WSAENOPROTOOPT, "Protocol not available");
|
||||
#endif
|
||||
#ifdef WSAECONNABORTED
|
||||
inscode(d, ds, de, "WSAECONNABORTED", WSAECONNABORTED, "Software caused connection abort");
|
||||
#endif
|
||||
#ifdef WSAENAMETOOLONG
|
||||
inscode(d, ds, de, "WSAENAMETOOLONG", WSAENAMETOOLONG, "File name too long");
|
||||
#endif
|
||||
#ifdef WSAENOTEMPTY
|
||||
inscode(d, ds, de, "WSAENOTEMPTY", WSAENOTEMPTY, "Directory not empty");
|
||||
#endif
|
||||
#ifdef WSAESHUTDOWN
|
||||
inscode(d, ds, de, "WSAESHUTDOWN", WSAESHUTDOWN, "Cannot send after transport endpoint shutdown");
|
||||
#endif
|
||||
#ifdef WSAEAFNOSUPPORT
|
||||
inscode(d, ds, de, "WSAEAFNOSUPPORT", WSAEAFNOSUPPORT, "Address family not supported by protocol");
|
||||
#endif
|
||||
#ifdef WSAETOOMANYREFS
|
||||
inscode(d, ds, de, "WSAETOOMANYREFS", WSAETOOMANYREFS, "Too many references: cannot splice");
|
||||
#endif
|
||||
#ifdef WSAEACCES
|
||||
inscode(d, ds, de, "WSAEACCES", WSAEACCES, "Permission denied");
|
||||
#endif
|
||||
#ifdef WSATR
|
||||
inscode(d, ds, de, "WSATR", WSATR, "Error WSATR");
|
||||
#endif
|
||||
#ifdef WSABASEERR
|
||||
inscode(d, ds, de, "WSABASEERR", WSABASEERR, "Error WSABASEERR");
|
||||
#endif
|
||||
#ifdef WSADESCRIPTIO
|
||||
inscode(d, ds, de, "WSADESCRIPTIO", WSADESCRIPTIO, "Error WSADESCRIPTIO");
|
||||
#endif
|
||||
#ifdef WSAEMSGSIZE
|
||||
inscode(d, ds, de, "WSAEMSGSIZE", WSAEMSGSIZE, "Message too long");
|
||||
#endif
|
||||
#ifdef WSAEBADF
|
||||
inscode(d, ds, de, "WSAEBADF", WSAEBADF, "Bad file number");
|
||||
#endif
|
||||
#ifdef WSAECONNRESET
|
||||
inscode(d, ds, de, "WSAECONNRESET", WSAECONNRESET, "Connection reset by peer");
|
||||
#endif
|
||||
#ifdef WSAGETSELECTERRO
|
||||
inscode(d, ds, de, "WSAGETSELECTERRO", WSAGETSELECTERRO, "Error WSAGETSELECTERRO");
|
||||
#endif
|
||||
#ifdef WSAETIMEDOUT
|
||||
inscode(d, ds, de, "WSAETIMEDOUT", WSAETIMEDOUT, "Connection timed out");
|
||||
#endif
|
||||
#ifdef WSAENOBUFS
|
||||
inscode(d, ds, de, "WSAENOBUFS", WSAENOBUFS, "No buffer space available");
|
||||
#endif
|
||||
#ifdef WSAEDISCON
|
||||
inscode(d, ds, de, "WSAEDISCON", WSAEDISCON, "Error WSAEDISCON");
|
||||
#endif
|
||||
#ifdef WSAEINTR
|
||||
inscode(d, ds, de, "WSAEINTR", WSAEINTR, "Interrupted system call");
|
||||
#endif
|
||||
#ifdef WSAEPROTOTYPE
|
||||
inscode(d, ds, de, "WSAEPROTOTYPE", WSAEPROTOTYPE, "Protocol wrong type for socket");
|
||||
#endif
|
||||
#ifdef WSAHOS
|
||||
inscode(d, ds, de, "WSAHOS", WSAHOS, "Error WSAHOS");
|
||||
#endif
|
||||
#ifdef WSAEADDRINUSE
|
||||
inscode(d, ds, de, "WSAEADDRINUSE", WSAEADDRINUSE, "Address already in use");
|
||||
#endif
|
||||
#ifdef WSAEADDRNOTAVAIL
|
||||
inscode(d, ds, de, "WSAEADDRNOTAVAIL", WSAEADDRNOTAVAIL, "Cannot assign requested address");
|
||||
#endif
|
||||
#ifdef WSAEALREADY
|
||||
inscode(d, ds, de, "WSAEALREADY", WSAEALREADY, "Operation already in progress");
|
||||
#endif
|
||||
#ifdef WSAEPROTONOSUPPORT
|
||||
inscode(d, ds, de, "WSAEPROTONOSUPPORT", WSAEPROTONOSUPPORT, "Protocol not supported");
|
||||
#endif
|
||||
#ifdef WSASYSNOTREADY
|
||||
inscode(d, ds, de, "WSASYSNOTREADY", WSASYSNOTREADY, "Error WSASYSNOTREADY");
|
||||
#endif
|
||||
#ifdef WSAEWOULDBLOCK
|
||||
inscode(d, ds, de, "WSAEWOULDBLOCK", WSAEWOULDBLOCK, "Operation would block");
|
||||
#endif
|
||||
#ifdef WSAEPFNOSUPPORT
|
||||
inscode(d, ds, de, "WSAEPFNOSUPPORT", WSAEPFNOSUPPORT, "Protocol family not supported");
|
||||
#endif
|
||||
#ifdef WSAEOPNOTSUPP
|
||||
inscode(d, ds, de, "WSAEOPNOTSUPP", WSAEOPNOTSUPP, "Operation not supported on transport endpoint");
|
||||
#endif
|
||||
#ifdef WSAEISCONN
|
||||
inscode(d, ds, de, "WSAEISCONN", WSAEISCONN, "Transport endpoint is already connected");
|
||||
#endif
|
||||
#ifdef WSAEDQUOT
|
||||
inscode(d, ds, de, "WSAEDQUOT", WSAEDQUOT, "Quota exceeded");
|
||||
#endif
|
||||
#ifdef WSAENOTCONN
|
||||
inscode(d, ds, de, "WSAENOTCONN", WSAENOTCONN, "Transport endpoint is not connected");
|
||||
#endif
|
||||
#ifdef WSAEREMOTE
|
||||
inscode(d, ds, de, "WSAEREMOTE", WSAEREMOTE, "Object is remote");
|
||||
#endif
|
||||
#ifdef WSAEINVAL
|
||||
inscode(d, ds, de, "WSAEINVAL", WSAEINVAL, "Invalid argument");
|
||||
#endif
|
||||
#ifdef WSAEINPROGRESS
|
||||
inscode(d, ds, de, "WSAEINPROGRESS", WSAEINPROGRESS, "Operation now in progress");
|
||||
#endif
|
||||
#ifdef WSAGETSELECTEVEN
|
||||
inscode(d, ds, de, "WSAGETSELECTEVEN", WSAGETSELECTEVEN, "Error WSAGETSELECTEVEN");
|
||||
#endif
|
||||
#ifdef WSAESOCKTNOSUPPORT
|
||||
inscode(d, ds, de, "WSAESOCKTNOSUPPORT", WSAESOCKTNOSUPPORT, "Socket type not supported");
|
||||
#endif
|
||||
#ifdef WSAGETASYNCERRO
|
||||
inscode(d, ds, de, "WSAGETASYNCERRO", WSAGETASYNCERRO, "Error WSAGETASYNCERRO");
|
||||
#endif
|
||||
#ifdef WSAMAKESELECTREPL
|
||||
inscode(d, ds, de, "WSAMAKESELECTREPL", WSAMAKESELECTREPL, "Error WSAMAKESELECTREPL");
|
||||
#endif
|
||||
#ifdef WSAGETASYNCBUFLE
|
||||
inscode(d, ds, de, "WSAGETASYNCBUFLE", WSAGETASYNCBUFLE, "Error WSAGETASYNCBUFLE");
|
||||
#endif
|
||||
#ifdef WSAEDESTADDRREQ
|
||||
inscode(d, ds, de, "WSAEDESTADDRREQ", WSAEDESTADDRREQ, "Destination address required");
|
||||
#endif
|
||||
#ifdef WSAECONNREFUSED
|
||||
inscode(d, ds, de, "WSAECONNREFUSED", WSAECONNREFUSED, "Connection refused");
|
||||
#endif
|
||||
#ifdef WSAENETRESET
|
||||
inscode(d, ds, de, "WSAENETRESET", WSAENETRESET, "Network dropped connection because of reset");
|
||||
#endif
|
||||
#ifdef WSAN
|
||||
inscode(d, ds, de, "WSAN", WSAN, "Error WSAN");
|
||||
#endif
|
||||
#ifdef ENOTSUP
|
||||
inscode(d, ds, de, "ENOTSUP", ENOTSUP, "Operation not supported");
|
||||
#endif
|
||||
|
||||
Py_DECREF(de);
|
||||
}
|
@@ -0,0 +1,119 @@
|
||||
/* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
#ifndef Expat_External_INCLUDED
|
||||
#define Expat_External_INCLUDED 1
|
||||
|
||||
/* External API definitions */
|
||||
|
||||
/* Namespace external symbols to allow multiple libexpat version to
|
||||
co-exist. */
|
||||
#include "pyexpatns.h"
|
||||
|
||||
#if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__)
|
||||
#define XML_USE_MSC_EXTENSIONS 1
|
||||
#endif
|
||||
|
||||
/* Expat tries very hard to make the API boundary very specifically
|
||||
defined. There are two macros defined to control this boundary;
|
||||
each of these can be defined before including this header to
|
||||
achieve some different behavior, but doing so it not recommended or
|
||||
tested frequently.
|
||||
|
||||
XMLCALL - The calling convention to use for all calls across the
|
||||
"library boundary." This will default to cdecl, and
|
||||
try really hard to tell the compiler that's what we
|
||||
want.
|
||||
|
||||
XMLIMPORT - Whatever magic is needed to note that a function is
|
||||
to be imported from a dynamically loaded library
|
||||
(.dll, .so, or .sl, depending on your platform).
|
||||
|
||||
The XMLCALL macro was added in Expat 1.95.7. The only one which is
|
||||
expected to be directly useful in client code is XMLCALL.
|
||||
|
||||
Note that on at least some Unix versions, the Expat library must be
|
||||
compiled with the cdecl calling convention as the default since
|
||||
system headers may assume the cdecl convention.
|
||||
*/
|
||||
#ifndef XMLCALL
|
||||
#if defined(_MSC_VER)
|
||||
#define XMLCALL __cdecl
|
||||
#elif defined(__GNUC__) && defined(__i386) && !defined(__INTEL_COMPILER)
|
||||
#define XMLCALL __attribute__((cdecl))
|
||||
#else
|
||||
/* For any platform which uses this definition and supports more than
|
||||
one calling convention, we need to extend this definition to
|
||||
declare the convention used on that platform, if it's possible to
|
||||
do so.
|
||||
|
||||
If this is the case for your platform, please file a bug report
|
||||
with information on how to identify your platform via the C
|
||||
pre-processor and how to specify the same calling convention as the
|
||||
platform's malloc() implementation.
|
||||
*/
|
||||
#define XMLCALL
|
||||
#endif
|
||||
#endif /* not defined XMLCALL */
|
||||
|
||||
|
||||
#if !defined(XML_STATIC) && !defined(XMLIMPORT)
|
||||
#ifndef XML_BUILDING_EXPAT
|
||||
/* using Expat from an application */
|
||||
|
||||
#ifdef XML_USE_MSC_EXTENSIONS
|
||||
#define XMLIMPORT __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif /* not defined XML_STATIC */
|
||||
|
||||
|
||||
/* If we didn't define it above, define it away: */
|
||||
#ifndef XMLIMPORT
|
||||
#define XMLIMPORT
|
||||
#endif
|
||||
|
||||
|
||||
#define XMLPARSEAPI(type) XMLIMPORT type XMLCALL
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef XML_UNICODE_WCHAR_T
|
||||
#define XML_UNICODE
|
||||
#endif
|
||||
|
||||
#ifdef XML_UNICODE /* Information is UTF-16 encoded. */
|
||||
#ifdef XML_UNICODE_WCHAR_T
|
||||
typedef wchar_t XML_Char;
|
||||
typedef wchar_t XML_LChar;
|
||||
#else
|
||||
typedef unsigned short XML_Char;
|
||||
typedef char XML_LChar;
|
||||
#endif /* XML_UNICODE_WCHAR_T */
|
||||
#else /* Information is UTF-8 encoded. */
|
||||
typedef char XML_Char;
|
||||
typedef char XML_LChar;
|
||||
#endif /* XML_UNICODE */
|
||||
|
||||
#ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */
|
||||
#if defined(XML_USE_MSC_EXTENSIONS) && _MSC_VER < 1400
|
||||
typedef __int64 XML_Index;
|
||||
typedef unsigned __int64 XML_Size;
|
||||
#else
|
||||
typedef long long XML_Index;
|
||||
typedef unsigned long long XML_Size;
|
||||
#endif
|
||||
#else
|
||||
typedef long XML_Index;
|
||||
typedef unsigned long XML_Size;
|
||||
#endif /* XML_LARGE_SIZE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* not Expat_External_INCLUDED */
|
@@ -0,0 +1,725 @@
|
||||
/** @file
|
||||
Return the initial module search path.
|
||||
|
||||
Search in specified locations for the associated Python libraries.
|
||||
|
||||
Py_GetPath returns module_search_path.
|
||||
Py_GetPrefix returns PREFIX
|
||||
Py_GetExec_Prefix returns PREFIX
|
||||
Py_GetProgramFullPath returns the full path to the python executable.
|
||||
|
||||
These are built dynamically so that the proper volume name can be prefixed
|
||||
to the paths.
|
||||
|
||||
For the EDK II, UEFI, implementation of Python, PREFIX and EXEC_PREFIX
|
||||
are set as follows:
|
||||
PREFIX = /Efi/StdLib
|
||||
EXEC_PREFIX = PREFIX
|
||||
|
||||
The following final paths are assumed:
|
||||
/Efi/Tools/Python.efi The Python executable.
|
||||
/Efi/StdLib/lib/python.VERSION The platform independent Python modules.
|
||||
/Efi/StdLib/lib/python.VERSION/dynalib Dynamically loadable Python extension modules.
|
||||
|
||||
Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials are licensed and made available under
|
||||
the terms and conditions of the BSD License that accompanies this distribution.
|
||||
The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
**/
|
||||
#include <Python.h>
|
||||
#include <osdefs.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* VERSION must be at least two characters long. */
|
||||
#ifndef VERSION
|
||||
#define VERSION "27"
|
||||
#endif
|
||||
|
||||
#ifndef VPATH
|
||||
#define VPATH "."
|
||||
#endif
|
||||
|
||||
/* Search path entry delimiter */
|
||||
#ifdef DELIM
|
||||
#define sDELIM ";"
|
||||
#endif
|
||||
|
||||
#ifndef PREFIX
|
||||
#define PREFIX "/Efi/StdLib"
|
||||
#endif
|
||||
|
||||
#ifndef EXEC_PREFIX
|
||||
#define EXEC_PREFIX PREFIX
|
||||
#endif
|
||||
|
||||
#ifndef LIBPYTHON
|
||||
#define LIBPYTHON "lib/python." VERSION
|
||||
#endif
|
||||
|
||||
#ifndef PYTHONPATH
|
||||
#ifdef HAVE_ENVIRONMENT_OPS
|
||||
#define PYTHONPATH PREFIX LIBPYTHON sDELIM \
|
||||
EXEC_PREFIX LIBPYTHON "/lib-dynload"
|
||||
#else
|
||||
#define PYTHONPATH LIBPYTHON
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef LANDMARK
|
||||
#define LANDMARK "os.py"
|
||||
#endif
|
||||
|
||||
static char prefix[MAXPATHLEN+1];
|
||||
static char exec_prefix[MAXPATHLEN+1];
|
||||
static char progpath[MAXPATHLEN+1];
|
||||
static char *module_search_path = NULL;
|
||||
static char lib_python[] = LIBPYTHON;
|
||||
static char volume_name[32] = { 0 };
|
||||
|
||||
/** Determine if "ch" is a separator character.
|
||||
|
||||
@param[in] ch The character to test.
|
||||
|
||||
@retval TRUE ch is a separator character.
|
||||
@retval FALSE ch is NOT a separator character.
|
||||
**/
|
||||
static int
|
||||
is_sep(char ch)
|
||||
{
|
||||
#ifdef ALTSEP
|
||||
return ch == SEP || ch == ALTSEP;
|
||||
#else
|
||||
return ch == SEP;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Reduce a path by its last element.
|
||||
|
||||
The last element (everything to the right of the last separator character)
|
||||
in the path, dir, is removed from the path. Parameter dir is modified in place.
|
||||
|
||||
@param[in,out] dir Pointer to the path to modify.
|
||||
**/
|
||||
static void
|
||||
reduce(char *dir)
|
||||
{
|
||||
size_t i = strlen(dir);
|
||||
while (i > 0 && !is_sep(dir[i]))
|
||||
--i;
|
||||
dir[i] = '\0';
|
||||
}
|
||||
|
||||
#ifndef UEFI_C_SOURCE
|
||||
/** Does filename point to a file and not directory?
|
||||
|
||||
@param[in] filename The fully qualified path to the object to test.
|
||||
|
||||
@retval 0 Filename was not found, or is a directory.
|
||||
@retval 1 Filename refers to a regular file.
|
||||
**/
|
||||
static int
|
||||
isfile(char *filename)
|
||||
{
|
||||
struct stat buf;
|
||||
if (stat(filename, &buf) != 0) {
|
||||
return 0;
|
||||
}
|
||||
//if (!S_ISREG(buf.st_mode))
|
||||
if (S_ISDIR(buf.st_mode)) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** Determine if filename refers to a Python module.
|
||||
|
||||
A Python module is indicated if the file exists, or if the file with
|
||||
'o' or 'c' appended exists.
|
||||
|
||||
@param[in] filename The fully qualified path to the object to test.
|
||||
|
||||
@retval 0
|
||||
**/
|
||||
static int
|
||||
ismodule(char *filename)
|
||||
{
|
||||
if (isfile(filename)) {
|
||||
//if (Py_VerboseFlag) PySys_WriteStderr("%s[%d]: file = \"%s\"\n", __func__, __LINE__, filename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Check for the compiled version of prefix. */
|
||||
if (strlen(filename) < MAXPATHLEN) {
|
||||
strcat(filename, Py_OptimizeFlag ? "o" : "c");
|
||||
if (isfile(filename)) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Does filename point to a directory?
|
||||
|
||||
@param[in] filename The fully qualified path to the object to test.
|
||||
|
||||
@retval 0 Filename was not found, or is not a regular file.
|
||||
@retval 1 Filename refers to a directory.
|
||||
**/
|
||||
static int
|
||||
isdir(char *filename)
|
||||
{
|
||||
struct stat buf;
|
||||
|
||||
if (stat(filename, &buf) != 0)
|
||||
return 0;
|
||||
|
||||
if (!S_ISDIR(buf.st_mode))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif /* UEFI_C_SOURCE */
|
||||
|
||||
/** Determine if a path is absolute, or not.
|
||||
An absolute path consists of a volume name, "VOL:", followed by a rooted path,
|
||||
"/path/elements". If both of these components are present, the path is absolute.
|
||||
|
||||
Let P be a pointer to the path to test.
|
||||
Let A be a pointer to the first ':' in P.
|
||||
Let B be a pointer to the first '/' or '\\' in P.
|
||||
|
||||
If A and B are not NULL
|
||||
If (A-P+1) == (B-P) then the path is absolute.
|
||||
Otherwise, the path is NOT absolute.
|
||||
|
||||
@param[in] path The path to test.
|
||||
|
||||
@retval -1 Path is absolute but lacking volume name.
|
||||
@retval 0 Path is NOT absolute.
|
||||
@retval 1 Path is absolute.
|
||||
*/
|
||||
static int
|
||||
is_absolute(char *path)
|
||||
{
|
||||
char *A;
|
||||
char *B;
|
||||
|
||||
A = strchr(path, ':');
|
||||
B = strpbrk(path, "/\\");
|
||||
|
||||
if(B != NULL) {
|
||||
if(A == NULL) {
|
||||
if(B == path) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(((A - path) + 1) == (B - path)) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/** Add a path component, by appending stuff to buffer.
|
||||
buffer must have at least MAXPATHLEN + 1 bytes allocated, and contain a
|
||||
NUL-terminated string with no more than MAXPATHLEN characters (not counting
|
||||
the trailing NUL). It's a fatal error if it contains a string longer than
|
||||
that (callers must be careful!). If these requirements are met, it's
|
||||
guaranteed that buffer will still be a NUL-terminated string with no more
|
||||
than MAXPATHLEN characters at exit. If stuff is too long, only as much of
|
||||
stuff as fits will be appended.
|
||||
|
||||
@param[in,out] buffer The path to be extended.
|
||||
@param[in] stuff The stuff to join onto the path.
|
||||
*/
|
||||
static void
|
||||
joinpath(char *buffer, char *stuff)
|
||||
{
|
||||
size_t n, k;
|
||||
|
||||
k = 0;
|
||||
if (is_absolute(stuff) == 1) {
|
||||
n = 0;
|
||||
}
|
||||
else {
|
||||
n = strlen(buffer);
|
||||
if(n == 0) {
|
||||
strncpy(buffer, volume_name, MAXPATHLEN);
|
||||
n = strlen(buffer);
|
||||
}
|
||||
/* We must not use an else clause here because we want to test n again.
|
||||
volume_name may have been empty.
|
||||
*/
|
||||
if (n > 0 && n < MAXPATHLEN) {
|
||||
if(!is_sep(buffer[n-1])) {
|
||||
buffer[n++] = SEP;
|
||||
}
|
||||
if(is_sep(stuff[0])) ++stuff;
|
||||
}
|
||||
}
|
||||
if (n > MAXPATHLEN)
|
||||
Py_FatalError("buffer overflow in getpath.c's joinpath()");
|
||||
k = strlen(stuff);
|
||||
if (n + k > MAXPATHLEN)
|
||||
k = MAXPATHLEN - n;
|
||||
strncpy(buffer+n, stuff, k);
|
||||
buffer[n+k] = '\0';
|
||||
}
|
||||
|
||||
/** Is filename an executable file?
|
||||
|
||||
An executable file:
|
||||
1) exists
|
||||
2) is a file, not a directory
|
||||
3) has a name ending with ".efi"
|
||||
4) Only has a single '.' in the name.
|
||||
|
||||
If basename(filename) does not contain a '.', append ".efi" to filename
|
||||
If filename ends in ".efi", it is executable, else it isn't.
|
||||
|
||||
This routine is used to when searching for the file named by argv[0].
|
||||
As such, there is no need to search for extensions other than ".efi".
|
||||
|
||||
@param[in] filename The name of the file to test. It may, or may not, have an extension.
|
||||
|
||||
@retval 0 filename already has a path other than ".efi", or it doesn't exist, or is a directory.
|
||||
@retval 1 filename refers to an executable file.
|
||||
**/
|
||||
static int
|
||||
isxfile(char *filename)
|
||||
{
|
||||
struct stat buf;
|
||||
char *bn;
|
||||
char *newbn;
|
||||
int bnlen;
|
||||
|
||||
bn = basename(filename); // Separate off the file name component
|
||||
reduce(filename); // and isolate the path component
|
||||
bnlen = strlen(bn);
|
||||
newbn = strrchr(bn, '.'); // Does basename contain a period?
|
||||
if(newbn == NULL) { // Does NOT contain a period.
|
||||
newbn = &bn[bnlen];
|
||||
strncpyX(newbn, ".efi", MAXPATHLEN - bnlen); // append ".efi" to basename
|
||||
bnlen += 4;
|
||||
}
|
||||
else if(strcmp(newbn, ".efi") != 0) {
|
||||
return 0; // File can not be executable.
|
||||
}
|
||||
joinpath(filename, bn); // Stitch path and file name back together
|
||||
|
||||
if (stat(filename, &buf) != 0) { // Now, verify that file exists
|
||||
return 0;
|
||||
}
|
||||
if(S_ISDIR(buf.st_mode)) { // And it is not a directory.
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** Copy p into path, ensuring that the result is an absolute path.
|
||||
|
||||
copy_absolute requires that path be allocated at least
|
||||
MAXPATHLEN + 1 bytes and that p be no more than MAXPATHLEN bytes.
|
||||
|
||||
@param[out] path Destination to receive the absolute path.
|
||||
@param[in] p Path to be tested and possibly converted.
|
||||
**/
|
||||
static void
|
||||
copy_absolute(char *path, char *p)
|
||||
{
|
||||
if (is_absolute(p) == 1)
|
||||
strcpy(path, p);
|
||||
else {
|
||||
if (!getcwd(path, MAXPATHLEN)) {
|
||||
/* unable to get the current directory */
|
||||
if(volume_name[0] != 0) {
|
||||
strcpy(path, volume_name);
|
||||
joinpath(path, p);
|
||||
}
|
||||
else
|
||||
strcpy(path, p);
|
||||
return;
|
||||
}
|
||||
if (p[0] == '.' && is_sep(p[1]))
|
||||
p += 2;
|
||||
joinpath(path, p);
|
||||
}
|
||||
}
|
||||
|
||||
/** Modify path so that the result is an absolute path.
|
||||
absolutize() requires that path be allocated at least MAXPATHLEN+1 bytes.
|
||||
|
||||
@param[in,out] path The path to be made absolute.
|
||||
*/
|
||||
static void
|
||||
absolutize(char *path)
|
||||
{
|
||||
char buffer[MAXPATHLEN + 1];
|
||||
|
||||
if (is_absolute(path) == 1)
|
||||
return;
|
||||
copy_absolute(buffer, path);
|
||||
strcpy(path, buffer);
|
||||
}
|
||||
|
||||
/** Extract the volume name from a path.
|
||||
|
||||
@param[out] Dest Pointer to location in which to store the extracted volume name.
|
||||
@param[in] path Pointer to the path to extract the volume name from.
|
||||
**/
|
||||
static void
|
||||
set_volume(char *Dest, char *path)
|
||||
{
|
||||
size_t VolLen;
|
||||
|
||||
if(is_absolute(path)) {
|
||||
VolLen = strcspn(path, "/\\:");
|
||||
if((VolLen != 0) && (path[VolLen] == ':')) {
|
||||
(void) strncpyX(Dest, path, VolLen + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Determine paths.
|
||||
|
||||
Two directories must be found, the platform independent directory
|
||||
(prefix), containing the common .py and .pyc files, and the platform
|
||||
dependent directory (exec_prefix), containing the shared library
|
||||
modules. Note that prefix and exec_prefix are the same directory
|
||||
for UEFI installations.
|
||||
|
||||
Separate searches are carried out for prefix and exec_prefix.
|
||||
Each search tries a number of different locations until a ``landmark''
|
||||
file or directory is found. If no prefix or exec_prefix is found, a
|
||||
warning message is issued and the preprocessor defined PREFIX and
|
||||
EXEC_PREFIX are used (even though they may not work); python carries on
|
||||
as best as is possible, but some imports may fail.
|
||||
|
||||
Before any searches are done, the location of the executable is
|
||||
determined. If argv[0] has one or more slashes in it, it is used
|
||||
unchanged. Otherwise, it must have been invoked from the shell's path,
|
||||
so we search %PATH% for the named executable and use that. If the
|
||||
executable was not found on %PATH% (or there was no %PATH% environment
|
||||
variable), the original argv[0] string is used.
|
||||
|
||||
Finally, argv0_path is set to the directory containing the executable
|
||||
(i.e. the last component is stripped).
|
||||
|
||||
With argv0_path in hand, we perform a number of steps. The same steps
|
||||
are performed for prefix and for exec_prefix, but with a different
|
||||
landmark.
|
||||
|
||||
The prefix landmark will always be lib/python.VERSION/os.py and the
|
||||
exec_prefix will always be lib/python.VERSION/dynaload, where VERSION
|
||||
is Python's version number as defined at the beginning of this file.
|
||||
|
||||
First. See if the %PYTHONHOME% environment variable points to the
|
||||
installed location of the Python libraries. If %PYTHONHOME% is set, then
|
||||
it points to prefix and exec_prefix. %PYTHONHOME% can be a single
|
||||
directory, which is used for both, or the prefix and exec_prefix
|
||||
directories separated by the DELIM character.
|
||||
|
||||
Next. Search the directories pointed to by the preprocessor variables
|
||||
PREFIX and EXEC_PREFIX. These paths are prefixed with the volume name
|
||||
extracted from argv0_path. The volume names correspond to the UEFI
|
||||
shell "map" names.
|
||||
|
||||
That's it!
|
||||
|
||||
Well, almost. Once we have determined prefix and exec_prefix, the
|
||||
preprocessor variable PYTHONPATH is used to construct a path. Each
|
||||
relative path on PYTHONPATH is prefixed with prefix. Then the directory
|
||||
containing the shared library modules is appended. The environment
|
||||
variable $PYTHONPATH is inserted in front of it all. Finally, the
|
||||
prefix and exec_prefix globals are tweaked so they reflect the values
|
||||
expected by other code, by stripping the "lib/python$VERSION/..." stuff
|
||||
off. This seems to make more sense given that currently the only
|
||||
known use of sys.prefix and sys.exec_prefix is for the ILU installation
|
||||
process to find the installed Python tree.
|
||||
|
||||
The final, fully resolved, paths should look something like:
|
||||
fs0:/Efi/Tools/python.efi
|
||||
fs0:/Efi/StdLib/lib/python27
|
||||
fs0:/Efi/StdLib/lib/python27/dynaload
|
||||
|
||||
**/
|
||||
static void
|
||||
calculate_path(void)
|
||||
{
|
||||
extern char *Py_GetProgramName(void);
|
||||
|
||||
static char delimiter[2] = {DELIM, '\0'};
|
||||
static char separator[2] = {SEP, '\0'};
|
||||
char *pythonpath = PYTHONPATH;
|
||||
char *rtpypath = Py_GETENV("PYTHONPATH");
|
||||
//char *home = Py_GetPythonHome();
|
||||
char *path = getenv("PATH");
|
||||
char *prog = Py_GetProgramName();
|
||||
char argv0_path[MAXPATHLEN+1];
|
||||
char zip_path[MAXPATHLEN+1];
|
||||
char *buf;
|
||||
size_t bufsz;
|
||||
size_t prefixsz;
|
||||
char *defpath;
|
||||
|
||||
|
||||
/* ###########################################################################
|
||||
Determine path to the Python.efi binary.
|
||||
Produces progpath, argv0_path, and volume_name.
|
||||
########################################################################### */
|
||||
|
||||
/* If there is no slash in the argv0 path, then we have to
|
||||
* assume python is on the user's $PATH, since there's no
|
||||
* other way to find a directory to start the search from. If
|
||||
* $PATH isn't exported, you lose.
|
||||
*/
|
||||
if (strchr(prog, SEP))
|
||||
strncpy(progpath, prog, MAXPATHLEN);
|
||||
else if (path) {
|
||||
while (1) {
|
||||
char *delim = strchr(path, DELIM);
|
||||
|
||||
if (delim) {
|
||||
size_t len = delim - path;
|
||||
if (len > MAXPATHLEN)
|
||||
len = MAXPATHLEN;
|
||||
strncpy(progpath, path, len);
|
||||
*(progpath + len) = '\0';
|
||||
}
|
||||
else
|
||||
strncpy(progpath, path, MAXPATHLEN);
|
||||
|
||||
joinpath(progpath, prog);
|
||||
if (isxfile(progpath))
|
||||
break;
|
||||
|
||||
if (!delim) {
|
||||
progpath[0] = '\0';
|
||||
break;
|
||||
}
|
||||
path = delim + 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
progpath[0] = '\0';
|
||||
if ( (!is_absolute(progpath)) && (progpath[0] != '\0') )
|
||||
absolutize(progpath);
|
||||
strncpy(argv0_path, progpath, MAXPATHLEN);
|
||||
argv0_path[MAXPATHLEN] = '\0';
|
||||
set_volume(volume_name, argv0_path);
|
||||
|
||||
reduce(argv0_path);
|
||||
/* At this point, argv0_path is guaranteed to be less than
|
||||
MAXPATHLEN bytes long.
|
||||
*/
|
||||
|
||||
/* ###########################################################################
|
||||
Build the FULL prefix string, including volume name.
|
||||
This is the full path to the platform independent libraries.
|
||||
########################################################################### */
|
||||
|
||||
strncpy(prefix, volume_name, MAXPATHLEN);
|
||||
joinpath(prefix, PREFIX);
|
||||
joinpath(prefix, lib_python);
|
||||
|
||||
/* ###########################################################################
|
||||
Build the FULL path to the zipped-up Python library.
|
||||
########################################################################### */
|
||||
|
||||
strncpy(zip_path, prefix, MAXPATHLEN);
|
||||
zip_path[MAXPATHLEN] = '\0';
|
||||
reduce(zip_path);
|
||||
joinpath(zip_path, "python00.zip");
|
||||
bufsz = strlen(zip_path); /* Replace "00" with version */
|
||||
zip_path[bufsz - 6] = VERSION[0];
|
||||
zip_path[bufsz - 5] = VERSION[1];
|
||||
|
||||
/* ###########################################################################
|
||||
Build the FULL path to dynamically loadable libraries.
|
||||
########################################################################### */
|
||||
|
||||
strncpy(exec_prefix, volume_name, MAXPATHLEN);
|
||||
joinpath(exec_prefix, EXEC_PREFIX);
|
||||
joinpath(exec_prefix, lib_python);
|
||||
joinpath(exec_prefix, "lib-dynload");
|
||||
|
||||
/* ###########################################################################
|
||||
Build the module search path.
|
||||
########################################################################### */
|
||||
|
||||
/* Reduce prefix and exec_prefix to their essence,
|
||||
* e.g. /usr/local/lib/python1.5 is reduced to /usr/local.
|
||||
* If we're loading relative to the build directory,
|
||||
* return the compiled-in defaults instead.
|
||||
*/
|
||||
reduce(prefix);
|
||||
reduce(prefix);
|
||||
/* The prefix is the root directory, but reduce() chopped
|
||||
* off the "/". */
|
||||
if (!prefix[0]) {
|
||||
strcpy(prefix, volume_name);
|
||||
}
|
||||
bufsz = strlen(prefix);
|
||||
if(prefix[bufsz-1] == ':') {
|
||||
prefix[bufsz] = SEP;
|
||||
prefix[bufsz+1] = 0;
|
||||
}
|
||||
|
||||
/* Calculate size of return buffer.
|
||||
*/
|
||||
defpath = pythonpath;
|
||||
bufsz = 0;
|
||||
|
||||
if (rtpypath)
|
||||
bufsz += strlen(rtpypath) + 1;
|
||||
|
||||
prefixsz = strlen(prefix) + 1;
|
||||
|
||||
while (1) {
|
||||
char *delim = strchr(defpath, DELIM);
|
||||
|
||||
if (is_absolute(defpath) == 0)
|
||||
/* Paths are relative to prefix */
|
||||
bufsz += prefixsz;
|
||||
|
||||
if (delim)
|
||||
bufsz += delim - defpath + 1;
|
||||
else {
|
||||
bufsz += strlen(defpath) + 1;
|
||||
break;
|
||||
}
|
||||
defpath = delim + 1;
|
||||
}
|
||||
|
||||
bufsz += strlen(zip_path) + 1;
|
||||
bufsz += strlen(exec_prefix) + 1;
|
||||
|
||||
/* This is the only malloc call in this file */
|
||||
buf = (char *)PyMem_Malloc(bufsz);
|
||||
|
||||
if (buf == NULL) {
|
||||
/* We can't exit, so print a warning and limp along */
|
||||
fprintf(stderr, "Not enough memory for dynamic PYTHONPATH.\n");
|
||||
fprintf(stderr, "Using default static PYTHONPATH.\n");
|
||||
module_search_path = PYTHONPATH;
|
||||
}
|
||||
else {
|
||||
/* Run-time value of $PYTHONPATH goes first */
|
||||
if (rtpypath) {
|
||||
strcpy(buf, rtpypath);
|
||||
strcat(buf, delimiter);
|
||||
}
|
||||
else
|
||||
buf[0] = '\0';
|
||||
|
||||
/* Next is the default zip path */
|
||||
strcat(buf, zip_path);
|
||||
strcat(buf, delimiter);
|
||||
|
||||
/* Next goes merge of compile-time $PYTHONPATH with
|
||||
* dynamically located prefix.
|
||||
*/
|
||||
defpath = pythonpath;
|
||||
while (1) {
|
||||
char *delim = strchr(defpath, DELIM);
|
||||
|
||||
if (is_absolute(defpath) != 1) {
|
||||
strcat(buf, prefix);
|
||||
strcat(buf, separator);
|
||||
}
|
||||
|
||||
if (delim) {
|
||||
size_t len = delim - defpath + 1;
|
||||
size_t end = strlen(buf) + len;
|
||||
strncat(buf, defpath, len);
|
||||
*(buf + end) = '\0';
|
||||
}
|
||||
else {
|
||||
strcat(buf, defpath);
|
||||
break;
|
||||
}
|
||||
defpath = delim + 1;
|
||||
}
|
||||
strcat(buf, delimiter);
|
||||
|
||||
/* Finally, on goes the directory for dynamic-load modules */
|
||||
strcat(buf, exec_prefix);
|
||||
|
||||
/* And publish the results */
|
||||
module_search_path = buf;
|
||||
}
|
||||
/* At this point, exec_prefix is set to VOL:/Efi/StdLib/lib/python.27/dynalib.
|
||||
We want to get back to the root value, so we have to remove the final three
|
||||
segments to get VOL:/Efi/StdLib. Because we don't know what VOL is, and
|
||||
EXEC_PREFIX is also indeterminate, we just remove the three final segments.
|
||||
*/
|
||||
reduce(exec_prefix);
|
||||
reduce(exec_prefix);
|
||||
reduce(exec_prefix);
|
||||
if (!exec_prefix[0]) {
|
||||
strcpy(exec_prefix, volume_name);
|
||||
}
|
||||
bufsz = strlen(exec_prefix);
|
||||
if(exec_prefix[bufsz-1] == ':') {
|
||||
exec_prefix[bufsz] = SEP;
|
||||
exec_prefix[bufsz+1] = 0;
|
||||
}
|
||||
if (Py_VerboseFlag) PySys_WriteStderr("%s[%d]: module_search_path = \"%s\"\n", __func__, __LINE__, module_search_path);
|
||||
if (Py_VerboseFlag) PySys_WriteStderr("%s[%d]: prefix = \"%s\"\n", __func__, __LINE__, prefix);
|
||||
if (Py_VerboseFlag) PySys_WriteStderr("%s[%d]: exec_prefix = \"%s\"\n", __func__, __LINE__, exec_prefix);
|
||||
if (Py_VerboseFlag) PySys_WriteStderr("%s[%d]: progpath = \"%s\"\n", __func__, __LINE__, progpath);
|
||||
}
|
||||
|
||||
|
||||
/* External interface */
|
||||
|
||||
char *
|
||||
Py_GetPath(void)
|
||||
{
|
||||
if (!module_search_path)
|
||||
calculate_path();
|
||||
return module_search_path;
|
||||
}
|
||||
|
||||
char *
|
||||
Py_GetPrefix(void)
|
||||
{
|
||||
if (!module_search_path)
|
||||
calculate_path();
|
||||
return prefix;
|
||||
}
|
||||
|
||||
char *
|
||||
Py_GetExecPrefix(void)
|
||||
{
|
||||
if (!module_search_path)
|
||||
calculate_path();
|
||||
return exec_prefix;
|
||||
}
|
||||
|
||||
char *
|
||||
Py_GetProgramFullPath(void)
|
||||
{
|
||||
if (!module_search_path)
|
||||
calculate_path();
|
||||
return progpath;
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -0,0 +1,704 @@
|
||||
/* Python interpreter main program */
|
||||
|
||||
#include "Python.h"
|
||||
#include "osdefs.h"
|
||||
#include "code.h" /* For CO_FUTURE_DIVISION */
|
||||
#include "import.h"
|
||||
|
||||
#ifdef __VMS
|
||||
#include <unixlib.h>
|
||||
#endif
|
||||
|
||||
#if defined(MS_WINDOWS) || defined(__CYGWIN__)
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (defined(PYOS_OS2) && !defined(PYCC_GCC)) || defined(MS_WINDOWS)
|
||||
#define PYTHONHOMEHELP "<prefix>\\lib"
|
||||
#else
|
||||
#if defined(PYOS_OS2) && defined(PYCC_GCC)
|
||||
#define PYTHONHOMEHELP "<prefix>/Lib"
|
||||
#else
|
||||
#define PYTHONHOMEHELP "<prefix>/pythonX.X"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "pygetopt.h"
|
||||
|
||||
#define COPYRIGHT \
|
||||
"Type \"help\", \"copyright\", \"credits\" or \"license\" " \
|
||||
"for more information."
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* For Py_GetArgcArgv(); set by main() */
|
||||
static char **orig_argv;
|
||||
static int orig_argc;
|
||||
|
||||
/* command line options */
|
||||
#define BASE_OPTS "3bBc:dEhiJm:OQ:RsStuUvVW:xX?"
|
||||
|
||||
#ifndef RISCOS
|
||||
#define PROGRAM_OPTS BASE_OPTS
|
||||
#else /*RISCOS*/
|
||||
/* extra option saying that we are running under a special task window
|
||||
frontend; especially my_readline will behave different */
|
||||
#define PROGRAM_OPTS BASE_OPTS "w"
|
||||
/* corresponding flag */
|
||||
extern int Py_RISCOSWimpFlag;
|
||||
#endif /*RISCOS*/
|
||||
|
||||
/* Short usage message (with %s for argv0) */
|
||||
static char *usage_line =
|
||||
"usage: %s [option] ... [-c cmd | -m mod | file | -] [arg] ...\n";
|
||||
|
||||
/* Long usage message, split into parts < 512 bytes */
|
||||
static char *usage_1 = "\
|
||||
Options and arguments (and corresponding environment variables):\n\
|
||||
-B : don't write .py[co] files on import; also PYTHONDONTWRITEBYTECODE=x\n\
|
||||
-c cmd : program passed in as string (terminates option list)\n\
|
||||
-d : debug output from parser; also PYTHONDEBUG=x\n\
|
||||
-E : ignore PYTHON* environment variables (such as PYTHONPATH)\n\
|
||||
-h : print this help message and exit (also --help)\n\
|
||||
-i : inspect interactively after running script; forces a prompt even\n\
|
||||
";
|
||||
static char *usage_2 = "\
|
||||
if stdin does not appear to be a terminal; also PYTHONINSPECT=x\n\
|
||||
-m mod : run library module as a script (terminates option list)\n\
|
||||
-O : optimize generated bytecode slightly; also PYTHONOPTIMIZE=x\n\
|
||||
-OO : remove doc-strings in addition to the -O optimizations\n\
|
||||
-R : use a pseudo-random salt to make hash() values of various types be\n\
|
||||
unpredictable between separate invocations of the interpreter, as\n\
|
||||
a defense against denial-of-service attacks\n\
|
||||
-Q arg : division options: -Qold (default), -Qwarn, -Qwarnall, -Qnew\n\
|
||||
-s : don't add user site directory to sys.path; also PYTHONNOUSERSITE\n\
|
||||
-S : don't imply 'import site' on initialization\n\
|
||||
-t : issue warnings about inconsistent tab usage (-tt: issue errors)\n\
|
||||
";
|
||||
static char *usage_3 = "\
|
||||
-u : unbuffered binary stdout and stderr; also PYTHONUNBUFFERED=x\n\
|
||||
see man page for details on internal buffering relating to '-u'\n\
|
||||
-v : verbose (trace import statements); also PYTHONVERBOSE=x\n\
|
||||
can be supplied multiple times to increase verbosity\n\
|
||||
-V : print the Python version number and exit (also --version)\n\
|
||||
-W arg : warning control; arg is action:message:category:module:lineno\n\
|
||||
also PYTHONWARNINGS=arg\n\
|
||||
-x : skip first line of source, allowing use of non-Unix forms of #!cmd\n\
|
||||
";
|
||||
static char *usage_4 = "\
|
||||
-3 : warn about Python 3.x incompatibilities that 2to3 cannot trivially fix\n\
|
||||
file : program read from script file\n\
|
||||
- : program read from stdin (default; interactive mode if a tty)\n\
|
||||
arg ...: arguments passed to program in sys.argv[1:]\n\n\
|
||||
Other environment variables:\n\
|
||||
PYTHONSTARTUP: file executed on interactive startup (no default)\n\
|
||||
PYTHONPATH : '%c'-separated list of directories prefixed to the\n\
|
||||
default module search path. The result is sys.path.\n\
|
||||
";
|
||||
static char *usage_5 = "\
|
||||
PYTHONHOME : alternate <prefix> directory (or <prefix>%c<exec_prefix>).\n\
|
||||
The default module search path uses %s.\n\
|
||||
PYTHONCASEOK : ignore case in 'import' statements (Windows).\n\
|
||||
PYTHONIOENCODING: Encoding[:errors] used for stdin/stdout/stderr.\n\
|
||||
";
|
||||
static char *usage_6 = "\
|
||||
PYTHONHASHSEED: if this variable is set to 'random', the effect is the same\n\
|
||||
as specifying the -R option: a random value is used to seed the hashes of\n\
|
||||
str, bytes and datetime objects. It can also be set to an integer\n\
|
||||
in the range [0,4294967295] to get hash values with a predictable seed.\n\
|
||||
";
|
||||
|
||||
|
||||
static int
|
||||
usage(int exitcode, char* program)
|
||||
{
|
||||
FILE *f = exitcode ? stderr : stdout;
|
||||
|
||||
fprintf(f, usage_line, program);
|
||||
if (exitcode)
|
||||
fprintf(f, "Try `python -h' for more information.\n");
|
||||
else {
|
||||
fputs(usage_1, f);
|
||||
fputs(usage_2, f);
|
||||
fputs(usage_3, f);
|
||||
fprintf(f, usage_4, DELIM);
|
||||
fprintf(f, usage_5, DELIM, PYTHONHOMEHELP);
|
||||
fputs(usage_6, f);
|
||||
}
|
||||
#if defined(__VMS)
|
||||
if (exitcode == 0) {
|
||||
/* suppress 'error' message */
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
/* STS$M_INHIB_MSG + SS$_ABORT */
|
||||
return 0x1000002c;
|
||||
}
|
||||
#else
|
||||
return exitcode;
|
||||
#endif
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
static void RunStartupFile(PyCompilerFlags *cf)
|
||||
{
|
||||
char *startup = Py_GETENV("PYTHONSTARTUP");
|
||||
if (startup != NULL && startup[0] != '\0') {
|
||||
FILE *fp = fopen(startup, "r");
|
||||
if (fp != NULL) {
|
||||
(void) PyRun_SimpleFileExFlags(fp, startup, 0, cf);
|
||||
PyErr_Clear();
|
||||
fclose(fp);
|
||||
} else {
|
||||
int save_errno;
|
||||
save_errno = errno;
|
||||
PySys_WriteStderr("Could not open PYTHONSTARTUP\n");
|
||||
errno = save_errno;
|
||||
PyErr_SetFromErrnoWithFilename(PyExc_IOError,
|
||||
startup);
|
||||
PyErr_Print();
|
||||
PyErr_Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int RunModule(char *module, int set_argv0)
|
||||
{
|
||||
PyObject *runpy, *runmodule, *runargs, *result;
|
||||
runpy = PyImport_ImportModule("runpy");
|
||||
if (runpy == NULL) {
|
||||
fprintf(stderr, "Could not import runpy module\n");
|
||||
return -1;
|
||||
}
|
||||
runmodule = PyObject_GetAttrString(runpy, "_run_module_as_main");
|
||||
if (runmodule == NULL) {
|
||||
fprintf(stderr, "Could not access runpy._run_module_as_main\n");
|
||||
Py_DECREF(runpy);
|
||||
return -1;
|
||||
}
|
||||
runargs = Py_BuildValue("(si)", module, set_argv0);
|
||||
if (runargs == NULL) {
|
||||
fprintf(stderr,
|
||||
"Could not create arguments for runpy._run_module_as_main\n");
|
||||
Py_DECREF(runpy);
|
||||
Py_DECREF(runmodule);
|
||||
return -1;
|
||||
}
|
||||
result = PyObject_Call(runmodule, runargs, NULL);
|
||||
if (result == NULL) {
|
||||
PyErr_Print();
|
||||
}
|
||||
Py_DECREF(runpy);
|
||||
Py_DECREF(runmodule);
|
||||
Py_DECREF(runargs);
|
||||
if (result == NULL) {
|
||||
return -1;
|
||||
}
|
||||
Py_DECREF(result);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int RunMainFromImporter(char *filename)
|
||||
{
|
||||
PyObject *argv0 = NULL, *importer = NULL;
|
||||
|
||||
if ((argv0 = PyString_FromString(filename)) &&
|
||||
(importer = PyImport_GetImporter(argv0)) &&
|
||||
(importer->ob_type != &PyNullImporter_Type))
|
||||
{
|
||||
/* argv0 is usable as an import source, so
|
||||
put it in sys.path[0] and import __main__ */
|
||||
PyObject *sys_path = NULL;
|
||||
if ((sys_path = PySys_GetObject("path")) &&
|
||||
!PyList_SetItem(sys_path, 0, argv0))
|
||||
{
|
||||
Py_INCREF(argv0);
|
||||
Py_DECREF(importer);
|
||||
sys_path = NULL;
|
||||
return RunModule("__main__", 0) != 0;
|
||||
}
|
||||
}
|
||||
Py_XDECREF(argv0);
|
||||
Py_XDECREF(importer);
|
||||
if (PyErr_Occurred()) {
|
||||
PyErr_Print();
|
||||
return 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* Main program */
|
||||
|
||||
int
|
||||
Py_Main(int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
int sts;
|
||||
char *command = NULL;
|
||||
char *filename = NULL;
|
||||
char *module = NULL;
|
||||
FILE *fp = stdin;
|
||||
char *p;
|
||||
int unbuffered = 0;
|
||||
int skipfirstline = 0;
|
||||
int stdin_is_interactive = 0;
|
||||
int help = 0;
|
||||
int version = 0;
|
||||
int saw_unbuffered_flag = 0;
|
||||
PyCompilerFlags cf;
|
||||
|
||||
cf.cf_flags = 0;
|
||||
|
||||
orig_argc = argc; /* For Py_GetArgcArgv() */
|
||||
orig_argv = argv;
|
||||
|
||||
#ifdef RISCOS
|
||||
Py_RISCOSWimpFlag = 0;
|
||||
#endif
|
||||
|
||||
/* Hash randomization needed early for all string operations
|
||||
(including -W and -X options). */
|
||||
_PyOS_opterr = 0; /* prevent printing the error in 1st pass */
|
||||
while ((c = _PyOS_GetOpt(argc, argv, PROGRAM_OPTS)) != EOF) {
|
||||
if (c == 'm' || c == 'c') {
|
||||
/* -c / -m is the last option: following arguments are
|
||||
not interpreter options. */
|
||||
break;
|
||||
}
|
||||
switch (c) {
|
||||
case 'E':
|
||||
Py_IgnoreEnvironmentFlag++;
|
||||
break;
|
||||
case 'R':
|
||||
Py_HashRandomizationFlag++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* The variable is only tested for existence here; _PyRandom_Init will
|
||||
check its value further. */
|
||||
if (!Py_HashRandomizationFlag &&
|
||||
(p = Py_GETENV("PYTHONHASHSEED")) && *p != '\0')
|
||||
Py_HashRandomizationFlag = 1;
|
||||
|
||||
_PyRandom_Init();
|
||||
|
||||
PySys_ResetWarnOptions();
|
||||
_PyOS_ResetGetOpt();
|
||||
|
||||
while ((c = _PyOS_GetOpt(argc, argv, PROGRAM_OPTS)) != EOF) {
|
||||
if (c == 'c') {
|
||||
/* -c is the last option; following arguments
|
||||
that look like options are left for the
|
||||
command to interpret. */
|
||||
command = (char *)malloc(strlen(_PyOS_optarg) + 2);
|
||||
if (command == NULL)
|
||||
Py_FatalError(
|
||||
"not enough memory to copy -c argument");
|
||||
strcpy(command, _PyOS_optarg);
|
||||
strcat(command, "\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (c == 'm') {
|
||||
/* -m is the last option; following arguments
|
||||
that look like options are left for the
|
||||
module to interpret. */
|
||||
module = (char *)malloc(strlen(_PyOS_optarg) + 2);
|
||||
if (module == NULL)
|
||||
Py_FatalError(
|
||||
"not enough memory to copy -m argument");
|
||||
strcpy(module, _PyOS_optarg);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (c) {
|
||||
case 'b':
|
||||
Py_BytesWarningFlag++;
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
Py_DebugFlag++;
|
||||
break;
|
||||
|
||||
case '3':
|
||||
Py_Py3kWarningFlag++;
|
||||
if (!Py_DivisionWarningFlag)
|
||||
Py_DivisionWarningFlag = 1;
|
||||
break;
|
||||
|
||||
case 'Q':
|
||||
if (strcmp(_PyOS_optarg, "old") == 0) {
|
||||
Py_DivisionWarningFlag = 0;
|
||||
break;
|
||||
}
|
||||
if (strcmp(_PyOS_optarg, "warn") == 0) {
|
||||
Py_DivisionWarningFlag = 1;
|
||||
break;
|
||||
}
|
||||
if (strcmp(_PyOS_optarg, "warnall") == 0) {
|
||||
Py_DivisionWarningFlag = 2;
|
||||
break;
|
||||
}
|
||||
if (strcmp(_PyOS_optarg, "new") == 0) {
|
||||
/* This only affects __main__ */
|
||||
cf.cf_flags |= CO_FUTURE_DIVISION;
|
||||
/* And this tells the eval loop to treat
|
||||
BINARY_DIVIDE as BINARY_TRUE_DIVIDE */
|
||||
_Py_QnewFlag = 1;
|
||||
break;
|
||||
}
|
||||
fprintf(stderr,
|
||||
"-Q option should be `-Qold', "
|
||||
"`-Qwarn', `-Qwarnall', or `-Qnew' only\n");
|
||||
return usage(2, argv[0]);
|
||||
/* NOTREACHED */
|
||||
|
||||
case 'i':
|
||||
Py_InspectFlag++;
|
||||
Py_InteractiveFlag++;
|
||||
break;
|
||||
|
||||
/* case 'J': reserved for Jython */
|
||||
|
||||
case 'O':
|
||||
Py_OptimizeFlag++;
|
||||
break;
|
||||
|
||||
case 'B':
|
||||
Py_DontWriteBytecodeFlag++;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
Py_NoUserSiteDirectory++;
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
Py_NoSiteFlag++;
|
||||
break;
|
||||
|
||||
case 'E':
|
||||
/* Already handled above */
|
||||
break;
|
||||
|
||||
case 't':
|
||||
Py_TabcheckFlag++;
|
||||
break;
|
||||
|
||||
case 'u':
|
||||
unbuffered++;
|
||||
saw_unbuffered_flag = 1;
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
Py_VerboseFlag++;
|
||||
break;
|
||||
|
||||
#ifdef RISCOS
|
||||
case 'w':
|
||||
Py_RISCOSWimpFlag = 1;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case 'x':
|
||||
skipfirstline = 1;
|
||||
break;
|
||||
|
||||
/* case 'X': reserved for implementation-specific arguments */
|
||||
|
||||
case 'U':
|
||||
Py_UnicodeFlag++;
|
||||
break;
|
||||
case 'h':
|
||||
case '?':
|
||||
help++;
|
||||
break;
|
||||
case 'V':
|
||||
version++;
|
||||
break;
|
||||
|
||||
case 'W':
|
||||
PySys_AddWarnOption(_PyOS_optarg);
|
||||
break;
|
||||
|
||||
case 'R':
|
||||
/* Already handled above */
|
||||
break;
|
||||
|
||||
/* This space reserved for other options */
|
||||
|
||||
default:
|
||||
return usage(2, argv[0]);
|
||||
/*NOTREACHED*/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (help)
|
||||
return usage(0, argv[0]);
|
||||
|
||||
if (version) {
|
||||
fprintf(stderr, "Python %s\n", PY_VERSION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (Py_Py3kWarningFlag && !Py_TabcheckFlag)
|
||||
/* -3 implies -t (but not -tt) */
|
||||
Py_TabcheckFlag = 1;
|
||||
|
||||
if (!Py_InspectFlag &&
|
||||
(p = Py_GETENV("PYTHONINSPECT")) && *p != '\0')
|
||||
Py_InspectFlag = 1;
|
||||
if (!saw_unbuffered_flag &&
|
||||
(p = Py_GETENV("PYTHONUNBUFFERED")) && *p != '\0')
|
||||
unbuffered = 1;
|
||||
|
||||
if (!Py_NoUserSiteDirectory &&
|
||||
(p = Py_GETENV("PYTHONNOUSERSITE")) && *p != '\0')
|
||||
Py_NoUserSiteDirectory = 1;
|
||||
|
||||
if ((p = Py_GETENV("PYTHONWARNINGS")) && *p != '\0') {
|
||||
char *buf, *warning;
|
||||
|
||||
buf = (char *)malloc(strlen(p) + 1);
|
||||
if (buf == NULL)
|
||||
Py_FatalError(
|
||||
"not enough memory to copy PYTHONWARNINGS");
|
||||
strcpy(buf, p);
|
||||
for (warning = strtok(buf, ",");
|
||||
warning != NULL;
|
||||
warning = strtok(NULL, ","))
|
||||
PySys_AddWarnOption(warning);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
if (command == NULL && module == NULL && _PyOS_optind < argc &&
|
||||
strcmp(argv[_PyOS_optind], "-") != 0)
|
||||
{
|
||||
#ifdef __VMS
|
||||
filename = decc$translate_vms(argv[_PyOS_optind]);
|
||||
if (filename == (char *)0 || filename == (char *)-1)
|
||||
filename = argv[_PyOS_optind];
|
||||
|
||||
#else
|
||||
filename = argv[_PyOS_optind];
|
||||
#endif
|
||||
}
|
||||
|
||||
stdin_is_interactive = Py_FdIsInteractive(stdin, (char *)0);
|
||||
|
||||
if (unbuffered) {
|
||||
#if defined(MS_WINDOWS) || defined(__CYGWIN__)
|
||||
_setmode(fileno(stdin), O_BINARY);
|
||||
_setmode(fileno(stdout), O_BINARY);
|
||||
#endif
|
||||
#ifdef HAVE_SETVBUF
|
||||
setvbuf(stdin, (char *)NULL, _IONBF, BUFSIZ);
|
||||
setvbuf(stdout, (char *)NULL, _IONBF, BUFSIZ);
|
||||
setvbuf(stderr, (char *)NULL, _IONBF, BUFSIZ);
|
||||
#else /* !HAVE_SETVBUF */
|
||||
setbuf(stdin, (char *)NULL);
|
||||
setbuf(stdout, (char *)NULL);
|
||||
setbuf(stderr, (char *)NULL);
|
||||
#endif /* !HAVE_SETVBUF */
|
||||
}
|
||||
else if (Py_InteractiveFlag) {
|
||||
#ifdef MS_WINDOWS
|
||||
/* Doesn't have to have line-buffered -- use unbuffered */
|
||||
/* Any set[v]buf(stdin, ...) screws up Tkinter :-( */
|
||||
setvbuf(stdout, (char *)NULL, _IONBF, BUFSIZ);
|
||||
#else /* !MS_WINDOWS */
|
||||
#ifdef HAVE_SETVBUF
|
||||
setvbuf(stdin, (char *)NULL, _IOLBF, BUFSIZ);
|
||||
setvbuf(stdout, (char *)NULL, _IOLBF, BUFSIZ);
|
||||
#endif /* HAVE_SETVBUF */
|
||||
#endif /* !MS_WINDOWS */
|
||||
/* Leave stderr alone - it should be unbuffered anyway. */
|
||||
}
|
||||
#ifdef __VMS
|
||||
else {
|
||||
setvbuf (stdout, (char *)NULL, _IOLBF, BUFSIZ);
|
||||
}
|
||||
#endif /* __VMS */
|
||||
|
||||
#ifdef __APPLE__
|
||||
/* On MacOS X, when the Python interpreter is embedded in an
|
||||
application bundle, it gets executed by a bootstrapping script
|
||||
that does os.execve() with an argv[0] that's different from the
|
||||
actual Python executable. This is needed to keep the Finder happy,
|
||||
or rather, to work around Apple's overly strict requirements of
|
||||
the process name. However, we still need a usable sys.executable,
|
||||
so the actual executable path is passed in an environment variable.
|
||||
See Lib/plat-mac/bundlebuiler.py for details about the bootstrap
|
||||
script. */
|
||||
if ((p = Py_GETENV("PYTHONEXECUTABLE")) && *p != '\0')
|
||||
Py_SetProgramName(p);
|
||||
else
|
||||
Py_SetProgramName(argv[0]);
|
||||
#else
|
||||
Py_SetProgramName(argv[0]);
|
||||
#endif
|
||||
Py_Initialize();
|
||||
|
||||
if (Py_VerboseFlag ||
|
||||
(command == NULL && filename == NULL && module == NULL && stdin_is_interactive)) {
|
||||
fprintf(stderr, "Python %s on %s\n",
|
||||
Py_GetVersion(), Py_GetPlatform());
|
||||
if (!Py_NoSiteFlag)
|
||||
fprintf(stderr, "%s\n", COPYRIGHT);
|
||||
}
|
||||
|
||||
if (command != NULL) {
|
||||
/* Backup _PyOS_optind and force sys.argv[0] = '-c' */
|
||||
_PyOS_optind--;
|
||||
argv[_PyOS_optind] = "-c";
|
||||
}
|
||||
|
||||
if (module != NULL) {
|
||||
/* Backup _PyOS_optind and force sys.argv[0] = '-c'
|
||||
so that PySys_SetArgv correctly sets sys.path[0] to ''
|
||||
rather than looking for a file called "-m". See
|
||||
tracker issue #8202 for details. */
|
||||
_PyOS_optind--;
|
||||
argv[_PyOS_optind] = "-c";
|
||||
}
|
||||
|
||||
PySys_SetArgv(argc-_PyOS_optind, argv+_PyOS_optind);
|
||||
|
||||
if ((Py_InspectFlag || (command == NULL && filename == NULL && module == NULL)) &&
|
||||
isatty(fileno(stdin))) {
|
||||
PyObject *v;
|
||||
v = PyImport_ImportModule("readline");
|
||||
if (v == NULL)
|
||||
PyErr_Clear();
|
||||
else
|
||||
Py_DECREF(v);
|
||||
}
|
||||
|
||||
if (command) {
|
||||
sts = PyRun_SimpleStringFlags(command, &cf) != 0;
|
||||
free(command);
|
||||
} else if (module) {
|
||||
sts = (RunModule(module, 1) != 0);
|
||||
free(module);
|
||||
}
|
||||
else {
|
||||
|
||||
if (filename == NULL && stdin_is_interactive) {
|
||||
Py_InspectFlag = 0; /* do exit on SystemExit */
|
||||
RunStartupFile(&cf);
|
||||
}
|
||||
/* XXX */
|
||||
|
||||
sts = -1; /* keep track of whether we've already run __main__ */
|
||||
|
||||
if (filename != NULL) {
|
||||
sts = RunMainFromImporter(filename);
|
||||
}
|
||||
|
||||
if (sts==-1 && filename!=NULL) {
|
||||
if ((fp = fopen(filename, "r")) == NULL) {
|
||||
fprintf(stderr, "%s: can't open file '%s': [Errno %d] %s\n",
|
||||
argv[0], filename, errno, strerror(errno));
|
||||
|
||||
return 2;
|
||||
}
|
||||
else if (skipfirstline) {
|
||||
int ch;
|
||||
/* Push back first newline so line numbers
|
||||
remain the same */
|
||||
while ((ch = getc(fp)) != EOF) {
|
||||
if (ch == '\n') {
|
||||
(void)ungetc(ch, fp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
/* XXX: does this work on Win/Win64? (see posix_fstat) */
|
||||
struct stat sb;
|
||||
if (fstat(fileno(fp), &sb) == 0 &&
|
||||
S_ISDIR(sb.st_mode)) {
|
||||
fprintf(stderr, "%s: '%s' is a directory, cannot continue\n", argv[0], filename);
|
||||
fclose(fp);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sts==-1) {
|
||||
/* call pending calls like signal handlers (SIGINT) */
|
||||
if (Py_MakePendingCalls() == -1) {
|
||||
PyErr_Print();
|
||||
sts = 1;
|
||||
} else {
|
||||
sts = PyRun_AnyFileExFlags(
|
||||
fp,
|
||||
filename == NULL ? "<stdin>" : filename,
|
||||
filename != NULL, &cf) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Check this environment variable at the end, to give programs the
|
||||
* opportunity to set it from Python.
|
||||
*/
|
||||
if (!Py_InspectFlag &&
|
||||
(p = Py_GETENV("PYTHONINSPECT")) && *p != '\0')
|
||||
{
|
||||
Py_InspectFlag = 1;
|
||||
}
|
||||
|
||||
if (Py_InspectFlag && stdin_is_interactive &&
|
||||
(filename != NULL || command != NULL || module != NULL)) {
|
||||
Py_InspectFlag = 0;
|
||||
/* XXX */
|
||||
sts = PyRun_AnyFileFlags(stdin, "<stdin>", &cf) != 0;
|
||||
}
|
||||
|
||||
Py_Finalize();
|
||||
#ifdef RISCOS
|
||||
if (Py_RISCOSWimpFlag)
|
||||
fprintf(stderr, "\x0cq\x0c"); /* make frontend quit */
|
||||
#endif
|
||||
|
||||
#ifdef __INSURE__
|
||||
/* Insure++ is a memory analysis tool that aids in discovering
|
||||
* memory leaks and other memory problems. On Python exit, the
|
||||
* interned string dictionary is flagged as being in use at exit
|
||||
* (which it is). Under normal circumstances, this is fine because
|
||||
* the memory will be automatically reclaimed by the system. Under
|
||||
* memory debugging, it's a huge source of useless noise, so we
|
||||
* trade off slower shutdown for less distraction in the memory
|
||||
* reports. -baw
|
||||
*/
|
||||
_Py_ReleaseInternedStrings();
|
||||
#endif /* __INSURE__ */
|
||||
|
||||
return sts;
|
||||
}
|
||||
|
||||
/* this is gonna seem *real weird*, but if you put some other code between
|
||||
Py_Main() and Py_GetArgcArgv() you will need to adjust the test in the
|
||||
while statement in Misc/gdbinit:ppystack */
|
||||
|
||||
/* Make the *original* argc/argv available to other modules.
|
||||
This is rare, but it is needed by the secureware extension. */
|
||||
|
||||
void
|
||||
Py_GetArgcArgv(int *argc, char ***argv)
|
||||
{
|
||||
*argc = orig_argc;
|
||||
*argv = orig_argv;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,209 @@
|
||||
/* gzguts.h -- zlib internal header definitions for gz* operations
|
||||
* Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#ifdef _LARGEFILE64_SOURCE
|
||||
# ifndef _LARGEFILE_SOURCE
|
||||
# define _LARGEFILE_SOURCE 1
|
||||
# endif
|
||||
# ifdef _FILE_OFFSET_BITS
|
||||
# undef _FILE_OFFSET_BITS
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_HIDDEN
|
||||
# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
|
||||
#else
|
||||
# define ZLIB_INTERNAL
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "zlib.h"
|
||||
#ifdef STDC
|
||||
# include <string.h>
|
||||
# include <stdlib.h>
|
||||
# include <limits.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <stddef.h>
|
||||
#endif
|
||||
|
||||
#if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32)
|
||||
# include <io.h>
|
||||
#endif
|
||||
|
||||
#ifdef WINAPI_FAMILY
|
||||
# define open _open
|
||||
# define read _read
|
||||
# define write _write
|
||||
# define close _close
|
||||
#endif
|
||||
|
||||
#ifdef NO_DEFLATE /* for compatibility with old definition */
|
||||
# define NO_GZCOMPRESS
|
||||
#endif
|
||||
|
||||
#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
|
||||
# ifndef HAVE_VSNPRINTF
|
||||
# define HAVE_VSNPRINTF
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(__CYGWIN__)
|
||||
# ifndef HAVE_VSNPRINTF
|
||||
# define HAVE_VSNPRINTF
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(MSDOS) && defined(__BORLANDC__) && (BORLANDC > 0x410)
|
||||
# ifndef HAVE_VSNPRINTF
|
||||
# define HAVE_VSNPRINTF
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_VSNPRINTF
|
||||
# ifdef MSDOS
|
||||
/* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
|
||||
but for now we just assume it doesn't. */
|
||||
# define NO_vsnprintf
|
||||
# endif
|
||||
# ifdef __TURBOC__
|
||||
# define NO_vsnprintf
|
||||
# endif
|
||||
# ifdef WIN32
|
||||
/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
|
||||
# if !defined(vsnprintf) && !defined(NO_vsnprintf)
|
||||
# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
|
||||
# define vsnprintf _vsnprintf
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
# ifdef __SASC
|
||||
# define NO_vsnprintf
|
||||
# endif
|
||||
# ifdef VMS
|
||||
# define NO_vsnprintf
|
||||
# endif
|
||||
# ifdef __OS400__
|
||||
# define NO_vsnprintf
|
||||
# endif
|
||||
# ifdef __MVS__
|
||||
# define NO_vsnprintf
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* unlike snprintf (which is required in C99, yet still not supported by
|
||||
Microsoft more than a decade later!), _snprintf does not guarantee null
|
||||
termination of the result -- however this is only used in gzlib.c where
|
||||
the result is assured to fit in the space provided */
|
||||
#ifdef _MSC_VER
|
||||
# define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#ifndef local
|
||||
# define local static
|
||||
#endif
|
||||
/* compile with -Dlocal if your debugger can't find static symbols */
|
||||
|
||||
/* gz* functions always use library allocation functions */
|
||||
#ifndef STDC
|
||||
extern voidp malloc OF((uInt size));
|
||||
extern void free OF((voidpf ptr));
|
||||
#endif
|
||||
|
||||
/* get errno and strerror definition */
|
||||
#if defined UNDER_CE
|
||||
# include <windows.h>
|
||||
# define zstrerror() gz_strwinerror((DWORD)GetLastError())
|
||||
#else
|
||||
# ifndef NO_STRERROR
|
||||
# include <errno.h>
|
||||
# define zstrerror() strerror(errno)
|
||||
# else
|
||||
# define zstrerror() "stdio error (consult errno)"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* provide prototypes for these when building zlib without LFS */
|
||||
#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
|
||||
ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
|
||||
ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
|
||||
ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
|
||||
ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
|
||||
#endif
|
||||
|
||||
/* default memLevel */
|
||||
#if MAX_MEM_LEVEL >= 8
|
||||
# define DEF_MEM_LEVEL 8
|
||||
#else
|
||||
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
|
||||
#endif
|
||||
|
||||
/* default i/o buffer size -- double this for output when reading (this and
|
||||
twice this must be able to fit in an unsigned type) */
|
||||
#define GZBUFSIZE 8192
|
||||
|
||||
/* gzip modes, also provide a little integrity check on the passed structure */
|
||||
#define GZ_NONE 0
|
||||
#define GZ_READ 7247
|
||||
#define GZ_WRITE 31153
|
||||
#define GZ_APPEND 1 /* mode set to GZ_WRITE after the file is opened */
|
||||
|
||||
/* values for gz_state how */
|
||||
#define LOOK 0 /* look for a gzip header */
|
||||
#define COPY 1 /* copy input directly */
|
||||
#define GZIP 2 /* decompress a gzip stream */
|
||||
|
||||
/* internal gzip file state data structure */
|
||||
typedef struct {
|
||||
/* exposed contents for gzgetc() macro */
|
||||
struct gzFile_s x; /* "x" for exposed */
|
||||
/* x.have: number of bytes available at x.next */
|
||||
/* x.next: next output data to deliver or write */
|
||||
/* x.pos: current position in uncompressed data */
|
||||
/* used for both reading and writing */
|
||||
int mode; /* see gzip modes above */
|
||||
int fd; /* file descriptor */
|
||||
char *path; /* path or fd for error messages */
|
||||
unsigned size; /* buffer size, zero if not allocated yet */
|
||||
unsigned want; /* requested buffer size, default is GZBUFSIZE */
|
||||
unsigned char *in; /* input buffer */
|
||||
unsigned char *out; /* output buffer (double-sized when reading) */
|
||||
int direct; /* 0 if processing gzip, 1 if transparent */
|
||||
/* just for reading */
|
||||
int how; /* 0: get header, 1: copy, 2: decompress */
|
||||
z_off64_t start; /* where the gzip data started, for rewinding */
|
||||
int eof; /* true if end of input file reached */
|
||||
int past; /* true if read requested past end */
|
||||
/* just for writing */
|
||||
int level; /* compression level */
|
||||
int strategy; /* compression strategy */
|
||||
/* seek request */
|
||||
z_off64_t skip; /* amount to skip (already rewound if backwards) */
|
||||
int seek; /* true if seek request pending */
|
||||
/* error information */
|
||||
int err; /* error code */
|
||||
char *msg; /* error message */
|
||||
/* zlib inflate or deflate stream */
|
||||
z_stream strm; /* stream structure in-place (not a pointer) */
|
||||
} gz_state;
|
||||
typedef gz_state FAR *gz_statep;
|
||||
|
||||
/* shared functions */
|
||||
void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *));
|
||||
#if defined UNDER_CE
|
||||
char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error));
|
||||
#endif
|
||||
|
||||
/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t
|
||||
value -- needed when comparing unsigned to z_off64_t, which is signed
|
||||
(possible z_off64_t types off_t, off64_t, and long are all signed) */
|
||||
#ifdef INT_MAX
|
||||
# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX)
|
||||
#else
|
||||
unsigned ZLIB_INTERNAL gz_intmax OF((void));
|
||||
# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
|
||||
#endif
|
@@ -0,0 +1,253 @@
|
||||
/* zutil.h -- internal interface and configuration of the compression library
|
||||
* Copyright (C) 1995-2013 Jean-loup Gailly.
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
/* @(#) $Id$ */
|
||||
|
||||
#ifndef ZUTIL_H
|
||||
#define ZUTIL_H
|
||||
|
||||
#ifdef HAVE_HIDDEN
|
||||
# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
|
||||
#else
|
||||
# define ZLIB_INTERNAL
|
||||
#endif
|
||||
|
||||
#include "zlib.h"
|
||||
|
||||
#if defined(STDC) && !defined(Z_SOLO)
|
||||
# if !(defined(_WIN32_WCE) && defined(_MSC_VER))
|
||||
# include <stddef.h>
|
||||
# endif
|
||||
# include <string.h>
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef Z_SOLO
|
||||
typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */
|
||||
#endif
|
||||
|
||||
#ifndef local
|
||||
# define local static
|
||||
#endif
|
||||
/* compile with -Dlocal if your debugger can't find static symbols */
|
||||
|
||||
typedef unsigned char uch;
|
||||
typedef uch FAR uchf;
|
||||
typedef unsigned short ush;
|
||||
typedef ush FAR ushf;
|
||||
typedef unsigned long ulg;
|
||||
|
||||
extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||
/* (size given to avoid silly warnings with Visual C++) */
|
||||
|
||||
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
|
||||
|
||||
#define ERR_RETURN(strm,err) \
|
||||
return (strm->msg = ERR_MSG(err), (err))
|
||||
/* To be used only when the state is known to be valid */
|
||||
|
||||
/* common constants */
|
||||
|
||||
#ifndef DEF_WBITS
|
||||
# define DEF_WBITS MAX_WBITS
|
||||
#endif
|
||||
/* default windowBits for decompression. MAX_WBITS is for compression only */
|
||||
|
||||
#if MAX_MEM_LEVEL >= 8
|
||||
# define DEF_MEM_LEVEL 8
|
||||
#else
|
||||
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
|
||||
#endif
|
||||
/* default memLevel */
|
||||
|
||||
#define STORED_BLOCK 0
|
||||
#define STATIC_TREES 1
|
||||
#define DYN_TREES 2
|
||||
/* The three kinds of block type */
|
||||
|
||||
#define MIN_MATCH 3
|
||||
#define MAX_MATCH 258
|
||||
/* The minimum and maximum match lengths */
|
||||
|
||||
#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
|
||||
|
||||
/* target dependencies */
|
||||
|
||||
#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
|
||||
# define OS_CODE 0x00
|
||||
# ifndef Z_SOLO
|
||||
# if defined(__TURBOC__) || defined(__BORLANDC__)
|
||||
# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
|
||||
/* Allow compilation with ANSI keywords only enabled */
|
||||
void _Cdecl farfree( void *block );
|
||||
void *_Cdecl farmalloc( unsigned long nbytes );
|
||||
# else
|
||||
# include <alloc.h>
|
||||
# endif
|
||||
# else /* MSC or DJGPP */
|
||||
# include <malloc.h>
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef AMIGA
|
||||
# define OS_CODE 0x01
|
||||
#endif
|
||||
|
||||
#if defined(VAXC) || defined(VMS)
|
||||
# define OS_CODE 0x02
|
||||
# define F_OPEN(name, mode) \
|
||||
fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
|
||||
#endif
|
||||
|
||||
#if defined(ATARI) || defined(atarist)
|
||||
# define OS_CODE 0x05
|
||||
#endif
|
||||
|
||||
#ifdef OS2
|
||||
# define OS_CODE 0x06
|
||||
# if defined(M_I86) && !defined(Z_SOLO)
|
||||
# include <malloc.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(MACOS) || defined(TARGET_OS_MAC)
|
||||
# define OS_CODE 0x07
|
||||
# ifndef Z_SOLO
|
||||
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
|
||||
# include <unix.h> /* for fdopen */
|
||||
# else
|
||||
# ifndef fdopen
|
||||
# define fdopen(fd,mode) NULL /* No fdopen() */
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef TOPS20
|
||||
# define OS_CODE 0x0a
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
|
||||
# define OS_CODE 0x0b
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __50SERIES /* Prime/PRIMOS */
|
||||
# define OS_CODE 0x0f
|
||||
#endif
|
||||
|
||||
#if defined(_BEOS_) || defined(RISCOS)
|
||||
# define fdopen(fd,mode) NULL /* No fdopen() */
|
||||
#endif
|
||||
|
||||
#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
|
||||
# if defined(_WIN32_WCE)
|
||||
# define fdopen(fd,mode) NULL /* No fdopen() */
|
||||
# ifndef _PTRDIFF_T_DEFINED
|
||||
typedef int ptrdiff_t;
|
||||
# define _PTRDIFF_T_DEFINED
|
||||
# endif
|
||||
# else
|
||||
# define fdopen(fd,type) _fdopen(fd,type)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(__BORLANDC__) && !defined(MSDOS)
|
||||
#pragma warn -8004
|
||||
#pragma warn -8008
|
||||
#pragma warn -8066
|
||||
#endif
|
||||
|
||||
/* provide prototypes for these when building zlib without LFS */
|
||||
#if !defined(_WIN32) && \
|
||||
(!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
|
||||
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
|
||||
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
|
||||
#endif
|
||||
|
||||
/* common defaults */
|
||||
|
||||
#ifndef OS_CODE
|
||||
# define OS_CODE 0x03 /* assume Unix */
|
||||
#endif
|
||||
|
||||
#ifndef F_OPEN
|
||||
# define F_OPEN(name, mode) fopen((name), (mode))
|
||||
#endif
|
||||
|
||||
/* functions */
|
||||
|
||||
#if defined(pyr) || defined(Z_SOLO)
|
||||
# define NO_MEMCPY
|
||||
#endif
|
||||
#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
|
||||
/* Use our own functions for small and medium model with MSC <= 5.0.
|
||||
* You may have to use the same strategy for Borland C (untested).
|
||||
* The __SC__ check is for Symantec.
|
||||
*/
|
||||
# define NO_MEMCPY
|
||||
#endif
|
||||
#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
|
||||
# define HAVE_MEMCPY
|
||||
#endif
|
||||
#ifdef HAVE_MEMCPY
|
||||
# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
|
||||
# define zmemcpy _fmemcpy
|
||||
# define zmemcmp _fmemcmp
|
||||
# define zmemzero(dest, len) _fmemset(dest, 0, len)
|
||||
# else
|
||||
# define zmemcpy memcpy
|
||||
# define zmemcmp memcmp
|
||||
# define zmemzero(dest, len) memset(dest, 0, len)
|
||||
# endif
|
||||
#else
|
||||
void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
|
||||
int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
|
||||
void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len));
|
||||
#endif
|
||||
|
||||
/* Diagnostic functions */
|
||||
#ifdef DEBUG
|
||||
# include <stdio.h>
|
||||
extern int ZLIB_INTERNAL z_verbose;
|
||||
extern void ZLIB_INTERNAL z_error OF((char *m));
|
||||
# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
|
||||
# define Trace(x) {if (z_verbose>=0) fprintf x ;}
|
||||
# define Tracev(x) {if (z_verbose>0) fprintf x ;}
|
||||
# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
|
||||
# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
|
||||
# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
|
||||
#else
|
||||
# define Assert(cond,msg)
|
||||
# define Trace(x)
|
||||
# define Tracev(x)
|
||||
# define Tracevv(x)
|
||||
# define Tracec(c,x)
|
||||
# define Tracecv(c,x)
|
||||
#endif
|
||||
|
||||
#ifndef Z_SOLO
|
||||
voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
|
||||
unsigned size));
|
||||
void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr));
|
||||
#endif
|
||||
|
||||
#define ZALLOC(strm, items, size) \
|
||||
(*((strm)->zalloc))((strm)->opaque, (items), (size))
|
||||
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
|
||||
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
|
||||
|
||||
/* Reverse the bytes in a 32-bit value */
|
||||
#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
|
||||
(((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
|
||||
|
||||
#endif /* ZUTIL_H */
|
Reference in New Issue
Block a user