--- /dev/null
+# $Id: Makefile,v 1.6 2002/10/29 04:44:58 rex Exp $
+#
+# ReactOS POSIX+ Personality
+#
+PATH_TO_TOP=../reactos
+
+CFLAGS=-Iinclude
+
+all: lib/crt0w32.o
+ make -C tools
+ make -C lib
+ make -C server
+ make -C lib/psxdll
+ make -C lib/psxx
+ make -C apps/baresh
+ make -C apps/posixw32
+
+lib/crt0w32.o: lib/crt0w32.c
+
+clean:
+ make -C lib clean
+ make -C tools clean
+ make -C server clean
+ make -C lib/psxdll clean
+ make -C lib/psxx clean
+ make -C apps/baresh clean
+ make -C apps/posixw32 clean
+ - $(RM) lib/crt0w32.o
+
+
+include $(PATH_TO_TOP)/rules.mak
+
+# EOF
--- /dev/null
+# $Id: Makefile,v 1.7 2002/10/29 04:44:59 rex Exp $
+#
+# Tu run it in Win32 console mode, undefine __SUBSYSTEM_WINDOWS__
+# and pass "console" in the ld's --subsystem option.
+#
+#
+PATH_TO_TOP=../../../reactos
+
+PATH_TO_PSX_TOP=../..
+
+TARGET_NAME=sh
+
+CFLAGS=-D__SUBSYSTEM_WINDOWS__
+
+OBJECTS=$(TARGET_NAME).o $(TARGET_NAME).coff
+
+LIBRARIES=\
+ $(PATH_TO_PSX_TOP)/lib/crt0w32.o \
+ $(PATH_TO_PSX_TOP)/lib/psxdll/psxdll.a
+
+$(TARGET_NAME): $(OBJECTS) $(LIBRARIES)
+ $(CC) \
+ $(CFLAGS) \
+ $(OBJECTS) \
+ $(LIBRARIES)\
+ -o $@ \
+ -Wl,--subsystem,windows\
+ -nostartfiles \
+ -nostdlib
+
+$(TARGET_NAME).coff: $(TARGET_NAME).rc
+ $(RC) \
+ --include-dir $(PATH_TO_TOP)/include \
+ --output-format coff \
+ $< $@
+
+clean:
+ - $(RM) *.o
+ - $(RM) *.exe
+ - $(RM) *.coff
+ - $(RM) *.sym
+
+
+
+include $(PATH_TO_TOP)/rules.mak
+
+# EOF
--- /dev/null
+/* $Id: sh.c,v 1.3 2002/10/29 04:44:59 rex Exp $
+ *
+ * baresh - Bare Shell for the PSX subsystem.
+ * Copyright (c) 2002 Emanuele Aliberti
+ * License: GNU GPL v2
+ */
+#include <stdio.h>
+#include <sys/types.h>
+#include <dirent.h>
+
+#define INPUT_BUFFER_SIZE 128
+
+int run=1;
+
+void cmd_exit(char*buf)
+{
+ run=0;
+}
+
+void cmd_pwd(char * buf)
+{
+ char pwd[1024];
+
+ getcwd(pwd,sizeof pwd);
+ printf("%s\n",pwd);
+}
+
+void cmd_ls(char*buf)
+{
+ char pwd[1024];
+ DIR * dir;
+ struct dirent * entry;
+
+ getcwd(pwd,sizeof pwd);
+ dir=opendir(pwd);
+ while (NULL!=(entry=readdir(dir)))
+ {
+ printf("%s\n",entry->d_name);
+ }
+ closedir(dir);
+}
+
+int main(int argc,char*argv[])
+{
+ char buf[INPUT_BUFFER_SIZE];
+
+ while (run)
+ {
+ printf("# ");
+ if (gets(buf))
+ {
+ if (!strcmp("exit",buf)) cmd_exit(buf);
+ else if (!strcmp("pwd",buf)) cmd_pwd(buf);
+ else if (!strcmp("ls",buf)) cmd_ls(buf);
+ else printf("%s: unknown command\n",argv[0]);
+ }
+ }
+ return 0;
+}
+/* EOF */
--- /dev/null
+#include <defines.h>
+#include <reactos/resource.h>
+
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION RES_UINT_FV_MAJOR,RES_UINT_FV_MINOR,RES_UINT_FV_REVISION,RES_UINT_FV_BUILD
+ PRODUCTVERSION RES_UINT_PV_MAJOR,RES_UINT_PV_MINOR,RES_UINT_PV_REVISION,RES_UINT_PV_BUILD
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x40004L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "CompanyName", RES_STR_COMPANY_NAME
+ VALUE "FileDescription", "Bare sh for POSIX+\0"
+ VALUE "FileVersion", RES_STR_FILE_VERSION
+ VALUE "InternalName", "sh\0"
+ VALUE "LegalCopyright", RES_STR_LEGAL_COPYRIGHT
+ VALUE "OriginalFilename", "sh\0"
+ VALUE "ProductName", RES_STR_PRODUCT_NAME
+ VALUE "ProductVersion", RES_STR_PRODUCT_VERSION
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
--- /dev/null
+08/08/96 - John L. Miller, johnmil@cs.cmu.edu, johnmil@jprc.com
+
+FILES INCLUDED:
+ 00readme.txt - this file
+ VT100.H - Definitions for VT-100 emulator.
+ VT100.C - Front end parsing code for VT-100 emulator
+ CONSOLE.C - Back-end code to allow VT-100 in WinNt/Win95 console
+
+Many UNIX users take terminals for granted, as something you get for free
+with the operating system. Unfortunately, this isn't the case for many
+non-unix operating systems, especially PC-based ones. After a number of
+projects, I decided it would be nice if there was source publicly available
+for doing VT-100 emulation.
+
+The files included with this distribution are not a complete implementation
+of VT-100 terminal emulation, but do provide complete enough coverage to
+use many vt-100 functions over the network. For instance, its enough to
+use EMACS to edit, or to connect up to your favorite mud with ANSI color
+and graphics characters.
+
+The VT-100 emulator is broken into two parts. The first is the front end,
+vt100.c and vt100.h. These files were written to be fairly device-independant,
+though admittedly if you're running under a 16-bit operating system instead
+of a 32-bit, you might need to change some of the 'int' values to 'long.'
+Otherwise, it should work 'as-is'.
+
+The second part is a back-end. The back-end is responsible for doing the
+workhorse activities. The front-end parses a character stream, and decides
+whether to clear a part of the screen, or move the cursor, or switch fonts.
+Then it calls routines in the back-end to perform these activities.
+
+The back-end functions are, for the most part, very straight forward, and
+quite easy to implement compared to writing a vt-100 emulator from scratch.
+CONSOLE.C is a back-end for use in console (command, dos) windows under
+Windows 95 and Windows NT. This console vt-100 emulator is also being used
+in my TINTIN-III port and kerberized encrypted telnet port.
+
+
+TO USE THIS VT-100 EMULATOR:
+
+First, it's intended to be linked directly into source code. You'll need
+to change printf's and puts' in your source code to call vtprintf() and
+vtputs() instead. You can add additional functions to vt100.c as you see
+fit to handle other output functions like putchar() and write(). Another
+routine you may want to use is vtProcessedTextOut(), which accepts a
+buffer to output, and a count of characters in that buffer.
+
+Second, you need to make sure that your source code calls vtInitVT100()
+before it does ANYTHING else. This initializes the vt-100 emulator.
+
+Third, if you want to use this VT-100 emulator with anything besides
+Windows NT and Windows 95 consoles, you'll need to implement your own
+back end. The list of functions you will need to supply, as well as what
+they need to do is contained in vt100.h. The list (minus descriptions)
+is as follows:
+
+ int beInitVT100Terminal();
+ int beAbsoluteCursor(int row, int col);
+ int beOffsetCursor(int row, int column);
+ int beRestoreCursor(void);
+ int beSaveCursor(void);
+ int beSetTextAttributes(int fore, int back);
+ int beRawTextOut(char *text, int len);
+ int beEraseText(int rowFrom, int colFrom, int rowTo, int colTo);
+ int beDeleteText(int rowFrom, int colFrom, int rowTo, int colTo);
+ int beInsertRow(int row);
+ int beTransmitText(char *text, int len);
+ int beAdvanceToTab(void);
+ int beClearTab(int col);
+ int beSetScrollingRows(int fromRow, int toRow);
+ int beRingBell(void);
+ int beGetTermMode();
+ int beSetTermMode(int newMode);
+
+For details on what each of these does, read the descriptions of each
+function included in vt100.h, and read over CONSOLE.C for examples. I've
+included copious comments in all of these files to try to make them as
+easy to use as possible.
+
+In any case, it should be easier than writing a VT-100 emulator from
+scratch.
+
+KNOWN BUGS -
+
+o Many features of VT-100 emulation aren't implemented. This includes
+ support for graphics character set 0 and many of the
+ answerback functions.
+
+Well, good luck!
+
--- /dev/null
+# $Id: Makefile,v 1.3 2002/10/29 04:44:59 rex Exp $
+#
+# Win32 Terminal Emulator for the POSIX+ subsystem.
+#
+PATH_TO_TOP=../../../reactos
+PATH_TO_TOP_PSX=../..
+
+TARGET_NAME=posixw32
+TARGET_TYPE=program
+TARGET_APPTYPE=console
+TARGET_CFLAGS =-I$(PATH_TO_TOP_PSX)/include
+TARGET_SDKLIBS=ntdll.a kernel32.a
+TARGET_OBJECTS=\
+ $(TARGET_NAME).o \
+ console.o \
+ vt100.o \
+ $(TARGET_NAME).coff
+
+include $(PATH_TO_TOP)/rules.mak
+
+include $(TOOLS_PATH)/helper.mk
+
+# EOF
--- /dev/null
+/* console.c
+ *
+ * AUTHOR: John L. Miller, johnmil@cs.cmu.edu / johnmil@jprc.com
+ * DATE: 8/4/96
+ *
+ * Copyright (c) 1996 John L. Miller
+ *
+ * Full permission is granted to use, modify and distribute
+ * this code, provided:
+ * 1) This comment field is included in its entirity
+ * 2) No money is charged for any work including or based on
+ * portions of this code.
+ *
+ * If you're a nice person and find this useful, I'd appreciate a
+ * note letting me know about it. e-mail is usually what spurs me
+ * on to improve and support software I've written.
+ *
+ * This file contains functions intended to provide the back
+ * end to a console window for my semi-vt100 emulator.
+ */
+
+/* Note - one HUGE difference between console windows and terminal
+ * windows. Console windows displays start at (0,0). Terminal displays
+ * start at (1,1). YUCK!
+ */
+
+#include <windows.h>
+#include "vt100.h"
+
+int topScrollRow=TOP_EDGE;
+int bottomScrollRow=BOTTOM_EDGE;
+
+/* This variable will contain terminal configuration flags, such as
+ * reverse/standard video, whether wrapping is enabled, and so on.
+ */
+int conTermMode;
+
+/* Variable to hold the cursor position for save/restore cursor calls */
+COORD cursorPosSave={1,1};
+
+/* Handles to the current console for input and output */
+HANDLE hConIn, hConOut;
+
+/* Array of all the tabs which are currently set. Ironically, I think the
+ * primary emulator can CLEAR tags, but not set them.
+ */
+int tabSet[132]={0};
+int numTabs = 0;
+
+
+/* This section contains console-specific color information. NT consoles can
+ * have Red, blue, green, and intensity flags set. Hence, 4 con_colors.
+ */
+#define NUM_CON_COLORS 4
+
+/* Foreground and background colors are separated out */
+int conForeColors, conBackColors;
+
+/* mapping between foreground and background console colors: needed
+ * when reverse video is being used
+ */
+int conColorMapping[NUM_CON_COLORS][2] =
+{
+ {FOREGROUND_RED, BACKGROUND_RED},
+ {FOREGROUND_BLUE, BACKGROUND_BLUE},
+ {FOREGROUND_GREEN, BACKGROUND_GREEN},
+ {FOREGROUND_INTENSITY, BACKGROUND_INTENSITY}
+};
+
+
+/* Device-independant foreground and background flags stored here.
+ * probably a bad division of labor, but hey, since we don't use
+ * all of their flags in our console stuff (and hence can't retrieve
+ * them), the information has to live SOMEWHERE.
+ */
+
+int scForeFlags, scBackFlags;
+
+/* Defines for array indexing for translation of flags */
+#define SC_FLAG 0
+#define CONSOLE_FLAG 1
+
+/* Color mapping between SC (the vt-100 emulator device independant
+ * flags) and NT console character specific flags. Flags which have no analog
+ * are set to 0. Note that all global character attributes (character set
+ * underline, bold, reverse) are all stored in foreground only
+ */
+const int scForeMapping[NUM_SC_ATTRIBUTES][2] =
+{
+ {SC_RED,FOREGROUND_RED},
+ {SC_GREEN,FOREGROUND_GREEN},
+ {SC_BLUE,FOREGROUND_BLUE},
+ {SC_BOLD,FOREGROUND_INTENSITY},
+ {SC_UL,0},
+ {SC_BL,0},
+ {SC_RV,0},
+ {SC_ASCII,0},
+ {SC_G0,0},
+ {SC_G1,0},
+ {SC_GRAPHICS,0}
+};
+
+/* Background color mapping between SC and console */
+const int scBackMapping[NUM_SC_ATTRIBUTES][2] =
+{
+ {SC_RED,BACKGROUND_RED},
+ {SC_GREEN,BACKGROUND_GREEN},
+ {SC_BLUE,BACKGROUND_BLUE},
+ {SC_BOLD,BACKGROUND_INTENSITY},
+ {SC_UL,0},
+ {SC_BL,0},
+ {SC_RV,0},
+ {SC_ASCII,0},
+ {SC_G0,0},
+ {SC_G1,0},
+ {SC_GRAPHICS,0}
+};
+
+/* These arrays map character vals 0-255 to new values.
+ * Since the G0 and G1 character sets don't have a direct analog in
+ * NT, I'm settling for replacing the ones I know what to set them
+ * to.
+ */
+char G0Chars[256];
+char G1Chars[256];
+
+/* These four sets of variables are just precomputed combinations of
+ * all the possible flags to save time for masking.
+ */
+int allFore[2], allBack[2];
+int bothFore[2], bothBack[2];
+
+
+/* FORWARD DECLARATIONS */
+int
+RawPrintLine(
+ char *text,
+ int len,
+ int scrollAtEnd
+ );
+
+int
+Scroll(
+ int row
+ );
+/* END FORWARD DECLARATIONS */
+
+
+
+/* beInitVT100Terminal() -
+ *
+ * This function is called by the VT100 emulator as soon as the
+ * front-end terminal is initialized. It's responsible for setting
+ * initial state of the terminal, and initing our many wacky variables.
+ */
+
+int
+beInitVT100Terminal()
+{
+ int i;
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+
+ /* Set tabs to every 8 spaces initially */
+ numTabs = 0;
+ for (numTabs=0; numTabs < 132/8; numTabs++)
+ tabSet[numTabs] = (numTabs+1)*8;
+
+ /* Init the cursor save position to HOME */
+ cursorPosSave.X = 1;
+ cursorPosSave.Y = 1;
+
+ /* Disable scrolling window limits */
+ topScrollRow=TOP_EDGE;
+ bottomScrollRow=BOTTOM_EDGE;
+
+ conTermMode = ANSI_MODE|WRAP_MODE|REPEAT_MODE;
+
+ hConIn = GetStdHandle(STD_INPUT_HANDLE);
+ hConOut = GetStdHandle(STD_OUTPUT_HANDLE);
+
+ /* Init our time-saving mask variables */
+ allFore[SC_FLAG] = allBack[SC_FLAG] = 0;
+ allFore[CONSOLE_FLAG] = allBack[CONSOLE_FLAG] = 0;
+ bothFore[SC_FLAG] = bothBack[SC_FLAG] = 0;
+ bothFore[CONSOLE_FLAG] = bothBack[CONSOLE_FLAG] = 0;
+
+ for (i=0; i<NUM_SC_ATTRIBUTES; i++)
+ {
+ allFore[SC_FLAG] |= scForeMapping[i][SC_FLAG];
+ allFore[CONSOLE_FLAG] |= scForeMapping[i][CONSOLE_FLAG];
+ allBack[SC_FLAG] |= scBackMapping[i][SC_FLAG];
+ allBack[CONSOLE_FLAG] |= scBackMapping[i][CONSOLE_FLAG];
+
+ if (scForeMapping[i][SC_FLAG] && scForeMapping[i][CONSOLE_FLAG])
+ {
+ bothFore[SC_FLAG] |= scForeMapping[i][SC_FLAG];
+ bothFore[CONSOLE_FLAG] |= scForeMapping[i][CONSOLE_FLAG];
+ }
+
+ if (scBackMapping[i][SC_FLAG] && scBackMapping[i][CONSOLE_FLAG])
+ {
+ bothBack[SC_FLAG] |= scBackMapping[i][SC_FLAG];
+ bothBack[CONSOLE_FLAG] |= scBackMapping[i][CONSOLE_FLAG];
+ }
+ }
+
+ conForeColors = conBackColors = 0;
+
+ for (i=0; i<NUM_CON_COLORS; i++)
+ {
+ conForeColors |= conColorMapping[i][0];
+ conBackColors |= conColorMapping[i][1];
+ }
+
+
+ /* Do initial settings for device-independant flags */
+ scForeFlags = SC_ASCII;
+ scBackFlags = 0;
+
+ GetConsoleScreenBufferInfo(hConOut, &csbi);
+
+ for (i=0; i<NUM_SC_ATTRIBUTES; i++)
+ {
+ if (csbi.wAttributes & scForeMapping[i][CONSOLE_FLAG])
+ scForeFlags |= scForeMapping[i][SC_FLAG];
+
+ if (csbi.wAttributes & scBackMapping[i][CONSOLE_FLAG])
+ scBackFlags |= scBackMapping[i][SC_FLAG];
+ }
+
+
+ /* Since the G0/G1 character sets don't really map to
+ * USASCII, So come as close as we can. By default, it'll
+ * just print the ascii character. For the graphics characters
+ * I was able to identify, change that mapping.
+ */
+
+ for (i=0; i<256; i++)
+ {
+ G0Chars[i] = i;
+ G1Chars[i] = i;
+ }
+
+ G1Chars['a']=(char)177;
+ G1Chars['f']=(char)248;
+ G1Chars['g']=(char)241;
+ G1Chars['j']=(char)217;
+ G1Chars['k']=(char)191;
+ G1Chars['l']=(char)218;
+ G1Chars['m']=(char)192;
+ G1Chars['n']=(char)197;
+ G1Chars['o']=(char)196;
+ G1Chars['p']=(char)196;
+ G1Chars['q']=(char)196;
+ G1Chars['r']=(char)196;
+ G1Chars['s']=(char)196;
+ G1Chars['t']=(char)195;
+ G1Chars['u']=(char)180;
+ G1Chars['v']=(char)193;
+ G1Chars['w']=(char)194;
+ G1Chars['x']=(char)179;
+ G1Chars['y']=(char)243;
+ G1Chars['z']=(char)242;
+
+ return(0);
+}
+
+
+
+/* beAbsoluteCursor -
+ *
+ * Given an input row and column, move the cursor to the
+ * absolute screen coordinates requested. Note that if the
+ * display window has scrollbars, the column is adjusted
+ * to take that into account, but the row is not. This allows
+ * for large scrollback in terminal windows.
+ *
+ * ROW must be able to accept CUR_ROW, TOP_EDGE, BOTTOM_EDGE,
+ * or a row number.
+ *
+ * COLUMN must be able to accept CUR_COL, LEFT_EDGE, RIGHT_EDGE,
+ * or a column number.
+ */
+
+int
+beAbsoluteCursor(
+ int row,
+ int col
+ )
+{
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ COORD cursorPos;
+
+ GetConsoleScreenBufferInfo(hConOut, &csbi);
+
+ if (row == CUR_ROW)
+ row = csbi.dwCursorPosition.Y;
+ else if (row == TOP_EDGE)
+ row = csbi.srWindow.Top;
+ else if (row == BOTTOM_EDGE)
+ row = csbi.srWindow.Bottom;
+ else
+ row += csbi.srWindow.Top - 1;
+
+ if (col == CUR_COL)
+ col = csbi.dwCursorPosition.X;
+ else if (col == LEFT_EDGE)
+ col = 0;
+ else if (col == RIGHT_EDGE)
+ col = csbi.dwSize.X-1;
+ else
+ col -= 1;
+
+ cursorPos.X = col;
+ cursorPos.Y = row;
+
+ SetConsoleCursorPosition(hConOut, cursorPos);
+
+ return(0);
+}
+
+
+/* beOffsetCursor -
+ *
+ * Given an input row and column offset, move the cursor by that
+ * many positions. For instance, row=0 and column=-1 would move
+ * the cursor left a single column.
+ *
+ * If the cursor can't move the requested amount, results are
+ * unpredictable.
+ */
+
+int
+beOffsetCursor(
+ int row,
+ int column
+ )
+{
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ COORD cursorPos;
+
+ GetConsoleScreenBufferInfo(hConOut, &csbi);
+
+ cursorPos = csbi.dwCursorPosition;
+ cursorPos.X += column;
+ cursorPos.Y += row;
+
+ if (cursorPos.X < 0)
+ cursorPos.X = 0;
+
+ if (cursorPos.X >= csbi.dwSize.X)
+ {
+ cursorPos.X -= csbi.dwSize.X;
+ cursorPos.Y += 1;
+ }
+
+ if (cursorPos.Y < 0)
+ cursorPos.Y = 0;
+
+ SetConsoleCursorPosition(hConOut, cursorPos);
+
+ return(0);
+}
+
+
+/* beRestoreCursor -
+ *
+ * Saved cursor position should be stored in a static
+ * variable in the back end. This function restores the
+ * cursor to the position stored in that variable.
+ */
+
+int
+beRestoreCursor(void)
+{
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ COORD cursorPos;
+
+ GetConsoleScreenBufferInfo(hConOut, &csbi);
+
+ cursorPos = csbi.dwCursorPosition;
+
+ cursorPos.Y += cursorPosSave.Y;
+
+ SetConsoleCursorPosition(hConOut, cursorPos);
+
+ return(0);
+}
+
+/* beSaveCursor -
+ *
+ * The back-end should maintain a static variable with the
+ * last STORED cursor position in it. This function replaces
+ * the contents of that variable with the current cursor position.
+ * The cursor may be restored to this position by using the
+ * beRestoreCursor function.
+ */
+
+int
+beSaveCursor(void)
+{
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+
+ GetConsoleScreenBufferInfo(hConOut, &csbi);
+ cursorPosSave = csbi.dwCursorPosition;
+
+ cursorPosSave.Y -= csbi.srWindow.Top;
+
+ return(0);
+}
+
+
+/* beGetTextAttributes -
+ *
+ * given a pointer to 'fore'ground and 'back'ground ints,
+ * fill them with a device-independant description of the
+ * current foreground and background colors, as well as any
+ * font information in the foreground variable.
+ */
+
+int
+beGetTextAttributes(
+ int *fore,
+ int *back
+ )
+{
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ int i;
+
+ /* Since it's entirely possible that the text attributes were
+ * changed without our terminal being notified, we might as well
+ * make sure they're accurate.
+ */
+
+ /* First, strip out everything in the screen buffer variables
+ * that we can detect
+ */
+
+ scForeFlags &= ~bothFore[SC_FLAG];
+ scBackFlags &= ~bothBack[SC_FLAG];
+
+ /* Now, find out what the real settings are, and set the
+ * flag values accordingly.
+ */
+
+ GetConsoleScreenBufferInfo(hConOut, &csbi);
+
+
+ /* If reverse video is set, we need to reverse our color mappings
+ * before any calculations get made.
+ */
+
+ if (scForeFlags & SC_RV)
+ {
+ int tmpFore, tmpBack;
+
+ tmpFore = csbi.wAttributes & conForeColors;
+ tmpBack = csbi.wAttributes & conBackColors;
+
+ csbi.wAttributes &= ~(conForeColors | conBackColors);
+
+ for (i=0; i<NUM_CON_COLORS; i++)
+ {
+ if (tmpFore & conColorMapping[i][0])
+ csbi.wAttributes |= conColorMapping[i][1];
+
+ if (tmpBack & conColorMapping[i][1])
+ csbi.wAttributes |= conColorMapping[i][0];
+ }
+ }
+
+ /* Now, do the actual translation between our detectable
+ * console text attributes and the corresponding device-independant
+ * attributes.
+ */
+
+ for (i=0; i<NUM_SC_ATTRIBUTES; i++)
+ {
+ if (csbi.wAttributes & scForeMapping[i][CONSOLE_FLAG])
+ scForeFlags |= scForeMapping[i][SC_FLAG];
+
+ if (csbi.wAttributes & scBackMapping[i][CONSOLE_FLAG])
+ scBackFlags |= scBackMapping[i][SC_FLAG];
+ }
+
+ /* Finally, copy our updated sc flags into the variables
+ * passed in
+ */
+
+ if (fore != NULL)
+ *fore = scForeFlags;
+
+ if (back != NULL)
+ *back = scBackFlags;
+
+ return(0);
+}
+
+
+/* beSetTextAttributes -
+ *
+ * Given a foreground and a background device independant (SC) color and font
+ * specification, apply these to the display, and save the state in the
+ * static screen variables.
+ *
+ * Note that many font-specific constants (bold/underline/reverse, G0/G1/ASCII)
+ * are stored ONLY in the foreground specification.
+ */
+
+int
+beSetTextAttributes(
+ int fore,
+ int back
+ )
+{
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ int i;
+ WORD wAttributes;
+
+ /* First off, let's assign these settings into our
+ * device-independant holder.
+ */
+
+ scForeFlags = fore;
+ scBackFlags = back;
+
+ /* Next, determine the console's actual current settings */
+
+ GetConsoleScreenBufferInfo(hConOut, &csbi);
+
+ /* Mask out any of the attributes which can be set via
+ * our device-independant options. Since the console settings
+ * have additional options, we need to retain those so we don't
+ * do something unpleasant to our I/O abilities, for instance.
+ */
+
+ wAttributes = csbi.wAttributes;
+
+ wAttributes &= ~(bothFore[CONSOLE_FLAG] | bothBack[CONSOLE_FLAG]);
+
+ /* Now, loop through the device-independant possibilities for
+ * flags, and modify our console flags as appropriate.
+ */
+
+ for (i=0; i<NUM_SC_ATTRIBUTES; i++)
+ {
+ if (scForeFlags & scForeMapping[i][SC_FLAG])
+ wAttributes |= scForeMapping[i][CONSOLE_FLAG];
+
+ if (scBackFlags & scBackMapping[i][SC_FLAG])
+ wAttributes |= scBackMapping[i][CONSOLE_FLAG];
+ }
+
+ /* One last unpleasantry: if reverse video is set, then we should
+ * reverse the foreground and background colors
+ */
+
+ if (scForeFlags & SC_RV)
+ {
+ int tmpFore, tmpBack;
+
+ tmpFore = wAttributes & conForeColors;
+ tmpBack = wAttributes & conBackColors;
+
+ wAttributes &= ~(conForeColors | conBackColors);
+
+ for (i=0; i<NUM_CON_COLORS; i++)
+ {
+ if (tmpFore & conColorMapping[i][0])
+ wAttributes |= conColorMapping[i][1];
+
+ if (tmpBack & conColorMapping[i][1])
+ wAttributes |= conColorMapping[i][0];
+ }
+ }
+
+ /* The appropriate colors, etc. should be set in
+ * the wAttributes variable now. Apply them to the
+ * current console.
+ */
+
+ SetConsoleTextAttribute(hConOut, wAttributes);
+
+ return(0);
+}
+
+
+/* beRawTextOut-
+ *
+ * The name of this function is misleading. Given a pointer to
+ * ascii text and a count of bytes to print, print them to the
+ * display device. If wrapping is enabled, wrap text. If there is a
+ * scrolling region set and the cursor is in it,
+ * scroll only within that region. 'beRawTextOut' means that it's guaranteed
+ * not to have control sequences within the text.
+ */
+
+int
+beRawTextOut(
+ char *text,
+ int len
+ )
+{
+ int i,j;
+
+ /* If there's no work to do, return immediately. */
+ if ((text == NULL)||(len == 0))
+ return(0);
+
+ i=0;
+
+ /* Otherwise, loop through the text until all of it has been output */
+ while (i < len)
+ {
+ /* This inner loop serves to divide the raw text to output into
+ * explicit lines. While the 'RawPrintLine' may still have to
+ * break lines to do text wrapping, explicit line breaks are
+ * handled right here.
+ */
+ j=i;
+ while ((text[j] != '\n')&&(j<len))
+ {
+ j++;
+ }
+
+ RawPrintLine(text+i, j-i, (text[j] == '\n'));
+
+ i = j+1;
+ }
+
+ return(0);
+}
+
+
+/* RawPrintLine -
+ *
+ * This routine is a helper for beRawTextOut. It is given a
+ * line of text which is guaranteed not to have any newlines
+ * or control characters (which need to be interpreted) in it.
+ * It prints out the text, wrapping if necessary, and handles
+ * scrolling or truncation.
+ *
+ * If scrollAtEnd is true, an extra carriage return (scroll) is
+ * performed after the text has been printed out.
+ */
+
+int
+RawPrintLine(
+ char *text,
+ int len,
+ int scrollAtEnd
+ )
+{
+ int i, end;
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ DWORD dwWritten;
+
+ if ((scrollAtEnd == FALSE) && ((text == NULL)||(len == 0)))
+ return(0);
+
+ GetConsoleScreenBufferInfo(hConOut, &csbi);
+
+ /* find out how far to the first tab or end of text */
+
+ if (text != NULL)
+ {
+ for (end=0; end<len; end++)
+ {
+ if (text[end] == '\t')
+ break;
+ }
+
+ if (end > (csbi.dwSize.X - csbi.dwCursorPosition.X))
+ end = (csbi.dwSize.X - csbi.dwCursorPosition.X);
+
+ /* If we're in non-ascii mode, we need to do a little
+ * magic to get the right characters out.
+ */
+
+ if (scForeFlags & SC_G1)
+ {
+ for (i=0; i<end; i++)
+ {
+ text[i] = G1Chars[text[i]];
+ }
+ }
+
+ /* actually print out the text. */
+
+ WriteConsole(hConOut,text,(DWORD)end,&dwWritten,NULL);
+
+ if (end == (csbi.dwSize.X - csbi.dwCursorPosition.X))
+ Scroll(CUR_ROW);
+
+ if ( (!(conTermMode & WRAP_MODE))
+ && (end == (csbi.dwSize.X - csbi.dwCursorPosition.X))
+ )
+ end = len;
+
+ if (end != len)
+ {
+ if (text[end] == '\t')
+ {
+ beAdvanceToTab();
+ RawPrintLine(text+end+1,len - (end+1), FALSE);
+ }
+ else
+ {
+ RawPrintLine(text+end, len-end, FALSE);
+ beAbsoluteCursor(CUR_ROW,1);
+ beOffsetCursor(1,0);
+ }
+ }
+ }
+
+ /* Now that we've printed this line, scroll if we need to.
+ * Note that a scroll implies a newline.
+ */
+
+ if (scrollAtEnd)
+ {
+ Scroll(CUR_ROW);
+ beAbsoluteCursor(CUR_ROW,1);
+ beOffsetCursor(1,0);
+ }
+
+ return(0);
+}
+
+
+/* Scroll -
+ *
+ * Given a row specification, calculate a scroll executed in that
+ * row. It could be within a scroll range, or outside of it.
+ *
+ * For some ungodly reason, I made this routine handle the TOP_EDGE,
+ * BOTTOM_EDGE, and CUR_ROW specifiers as well as a real row.
+ */
+
+int
+Scroll(
+ int row
+ )
+{
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ SMALL_RECT scrollRect;
+ COORD dest;
+ CHAR_INFO fillChar;
+
+ GetConsoleScreenBufferInfo(hConOut, &csbi);
+
+ if (row == TOP_EDGE)
+ row = csbi.srWindow.Top;
+ else if (row == BOTTOM_EDGE)
+ row = csbi.srWindow.Bottom;
+ else if (row == CUR_ROW)
+ row = csbi.dwCursorPosition.Y;
+ else
+ row += csbi.srWindow.Top;
+
+ /* Escape out if we don't really need to scroll */
+
+ if ( (row < (csbi.dwSize.Y-1))
+ && ((row-csbi.srWindow.Top + 1) < bottomScrollRow)
+ )
+ return(0);
+
+ /* NT console requires a fill character for scrolling. */
+
+ fillChar.Char.AsciiChar=' ';
+ fillChar.Attributes = csbi.wAttributes;
+
+ /* Determine the rectangle of text to scroll. Under NT this
+ * is actually an overlap-safe block-copy.
+ */
+ scrollRect.Left = 0;
+ scrollRect.Top = 1;
+ scrollRect.Right = csbi.dwSize.X;
+ scrollRect.Bottom = row;
+
+ if (topScrollRow != TOP_EDGE)
+ {
+ scrollRect.Top = csbi.srWindow.Top + topScrollRow + 1;
+ }
+
+ if ( (bottomScrollRow != BOTTOM_EDGE)
+ && ((csbi.srWindow.Top+bottomScrollRow) < scrollRect.Bottom)
+ )
+ {
+ scrollRect.Bottom = csbi.srWindow.Top + bottomScrollRow;
+ }
+
+ dest.X = 0;
+ dest.Y = scrollRect.Top - 1;
+
+ ScrollConsoleScreenBuffer(hConOut,&scrollRect,NULL,
+ dest, &fillChar);
+
+ return(0);
+}
+
+
+/* beEraseText -
+ *
+ * Given a 'from' and a 'to' position in display coordinates,
+ * this function will fill in all characters between the two
+ * (inclusive) with spaces. Note that the coordinates do NOT
+ * specify a rectangle. erasing from (1,1) to (2,2) erases
+ * all of the first row, and the first two characters of the
+ * second.
+ *
+ * Note that this routine must be able to handle TOP_EDGE,
+ * BOTTOM_EDGE, LEFT_EDGE, RIGHT_EDGE, CUR_ROW, and CUR_COL
+ * in the appropriate parameters.
+ */
+
+int
+beEraseText(
+ int rowFrom,
+ int colFrom,
+ int rowTo,
+ int colTo
+ )
+{
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ COORD dest, saveCursor;
+ DWORD nLength, dwWritten;
+
+ GetConsoleScreenBufferInfo(hConOut, &csbi);
+
+ saveCursor = csbi.dwCursorPosition;
+
+ /* Convert the row and column specifications into
+ * buffer coordinates
+ */
+ if (rowFrom == CUR_ROW)
+ rowFrom = csbi.dwCursorPosition.Y;
+ else if (rowFrom == TOP_EDGE)
+ rowFrom = csbi.srWindow.Top;
+ else
+ rowFrom += csbi.srWindow.Top -1;
+
+ if (colFrom == CUR_COL)
+ colFrom = csbi.dwCursorPosition.X;
+ else if (colFrom == LEFT_EDGE)
+ colFrom = 0;
+ else
+ colFrom -= 1;
+
+ if (rowTo == CUR_ROW)
+ rowTo = csbi.dwCursorPosition.Y;
+ else if (rowTo == BOTTOM_EDGE)
+ rowTo = csbi.srWindow.Bottom;
+ else
+ rowTo += csbi.srWindow.Top-1;
+
+ if (colTo == CUR_COL)
+ colTo = csbi.dwCursorPosition.X;
+ else if (colTo == RIGHT_EDGE)
+ colTo = csbi.dwSize.X;
+ else
+ colTo -= 1;
+
+ /* We're going to erase by filling a continuous range of
+ * character cells with spaces. Note that this has displeasing
+ * asthetics under NT, as highlighting appears to be immune.
+ */
+ nLength = (rowTo - rowFrom)*csbi.dwSize.X;
+ nLength += colTo - colFrom;
+
+ dest.X = colFrom;
+ dest.Y = rowFrom;
+
+ FillConsoleOutputCharacter(hConOut, ' ', nLength, dest, &dwWritten);
+ FillConsoleOutputAttribute(hConOut, csbi.wAttributes, nLength, dest, &dwWritten);
+
+ SetConsoleCursorPosition(hConOut, saveCursor);
+
+ return(0);
+}
+
+
+/* beDeleteText -
+ *
+ * Given a screen cursor 'from' and 'to' position, this function
+ * will delete all text between the two. Text will be scrolled
+ * up as appropriate to fill the deleted space. Note that, as in
+ * beEraseText, the two coordinates don't specify a rectangle, but
+ * rather a starting position and ending position. In other words,
+ * deleting from (1,1) to (2,2) should move the text from (2,3) to the
+ * end of the second row to (1,1), move line 3 up to line 2, and so on.
+ *
+ * This function must be able to process TOP_EDGE, BOTTOM_EDGE, LEFT_EDGE,
+ * RIGHT_EDGE, CUR_ROW, and CUR_COL specifications in the appropriate
+ * variables as well as regular row and column specifications.
+ */
+
+int
+beDeleteText(
+ int rowFrom,
+ int colFrom,
+ int rowTo,
+ int colTo
+ )
+{
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ COORD dest, saveCursor;
+ CHAR_INFO fillChar;
+
+ GetConsoleScreenBufferInfo(hConOut, &csbi);
+
+ saveCursor = csbi.dwCursorPosition;
+
+ if (rowFrom == CUR_ROW)
+ rowFrom = csbi.dwCursorPosition.Y;
+ else if (rowFrom == TOP_EDGE)
+ rowFrom = csbi.srWindow.Top;
+ else
+ rowFrom += csbi.srWindow.Top -1;
+
+ if (colFrom == CUR_COL)
+ colFrom = csbi.dwCursorPosition.X;
+ else if (colFrom == LEFT_EDGE)
+ colFrom = 0;
+ else
+ colFrom -= 1;
+
+ if (rowTo == CUR_ROW)
+ rowTo = csbi.dwCursorPosition.Y;
+ else if (rowTo == BOTTOM_EDGE)
+ rowTo = csbi.srWindow.Bottom;
+ else
+ rowTo += csbi.srWindow.Top-1;
+
+ if (colTo == CUR_COL)
+ colTo = csbi.dwCursorPosition.X;
+ else if (colTo == RIGHT_EDGE)
+ colTo = csbi.dwSize.X;
+ else
+ colTo -= 1;
+
+ fillChar.Char.AsciiChar=' ';
+ fillChar.Attributes = csbi.wAttributes;
+
+ /* Now that we've got the from and to positions
+ * set correctly, we need to delete appropriate
+ * rows and columns.
+ */
+
+ dest.X = colFrom;
+ dest.Y = rowFrom;
+
+ /* BUGBUG - need to implement this. What can I say, I'm lazy :) */
+
+ return(0);
+}
+
+
+/* beInsertRow -
+ *
+ * Given a row number or CUR_ROW, TOP_EDGE or BOTTOM_EDGE as an input,
+ * this function will scroll all text from the current row down down by one,
+ * and create a blank row under the cursor.
+ */
+
+int
+beInsertRow(
+ int row
+ )
+{
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ COORD dest;
+ CHAR_INFO fillChar;
+ SMALL_RECT scrollRect;
+
+ GetConsoleScreenBufferInfo(hConOut, &csbi);
+
+ fillChar.Char.AsciiChar=' ';
+ fillChar.Attributes = csbi.wAttributes;
+
+ if (row == CUR_ROW)
+ row = csbi.dwCursorPosition.Y;
+ else if (row == TOP_EDGE)
+ row = csbi.srWindow.Top;
+ else if (row == BOTTOM_EDGE)
+ row = csbi.srWindow.Bottom;
+ else
+ row += csbi.srWindow.Top-1;
+
+ dest.X = 0;
+ dest.Y = row+1;
+
+ scrollRect.Top = row;
+ scrollRect.Left = 0;
+ scrollRect.Right = csbi.dwSize.X;
+ scrollRect.Bottom = csbi.srWindow.Bottom;
+
+ ScrollConsoleScreenBuffer(hConOut, &scrollRect, NULL, dest, &fillChar);
+
+ return(0);
+}
+
+
+/* beTransmitText -
+ *
+ * Given a pointer to text and byte count, this routine should transmit data
+ * to whatever host made the request it's responding to. Typically this routin
+ * should transmit data as though the user had typed it in.
+ */
+
+int
+beTransmitText(
+ char *text,
+ int len
+ )
+{
+ if ((text == NULL) || (len < 1))
+ return(0);
+
+ /* BUGBUG - need to implement this. */
+
+ return(0);
+}
+
+
+/* beAdvanceToTab -
+ *
+ * This routine will destructively advance the cursor to the
+ * next set tab, or to the end of the line if there are no
+ * more tabs to the right of the cursor.
+ */
+
+int
+beAdvanceToTab(void)
+{
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ int i, col, tocol;
+ COORD dest;
+ DWORD dwWritten;
+
+ GetConsoleScreenBufferInfo(hConOut,&csbi);
+
+ col = csbi.dwCursorPosition.X+1;
+
+ dest = csbi.dwCursorPosition;
+
+ for(i=0; i<numTabs; i++)
+ {
+ if (col < tabSet[i])
+ {
+ tocol = tabSet[i];
+ break;
+ }
+ }
+
+ if (i == numTabs)
+ {
+ tocol = csbi.dwSize.X;
+ }
+
+ FillConsoleOutputCharacter(hConOut, ' ', tocol-col,
+ dest, &dwWritten);
+
+ beOffsetCursor(0,tocol-col);
+
+ return(0);
+}
+
+
+/* beClearTab -
+ *
+ * This function accepts a constant, and will try to clear tabs
+ * appropriately. Its argument is either
+ * ALL_TABS, meaning all tabs should be removed
+ * CUR_COL, meaning the tab in the current column should be wiped, or
+ * a column value, meaning if there's a tab there it should be wiped.
+ *
+ */
+
+int
+beClearTab(
+ int col
+ )
+{
+ int i, j;
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+
+ if (col == ALL_TABS)
+ {
+ tabSet[0] = 0;
+ numTabs = 0;
+ return(0);
+ }
+
+ if (col == CUR_COL)
+ {
+ GetConsoleScreenBufferInfo(hConOut,&csbi);
+ col = csbi.dwCursorPosition.X+1;
+ }
+
+ for (i=0; i<numTabs; i++)
+ {
+ if (tabSet[i] == col)
+ {
+ numTabs -= 1;
+
+ for (j=i; j<numTabs; j++)
+ tabSet[j]=tabSet[j+1];
+
+ break;
+ }
+ }
+
+ return(0);
+}
+
+/* beSetScrollingRows -
+ *
+ * Given a pair of row numbers, this routine will set the scrolling
+ * rows to those values. Note that this routine will accept
+ * TOP_ROW and BOTTOM_ROW as values, meaning that scrolling should
+ * be enabled for the entire display, regardless of resizing.
+ */
+
+int
+beSetScrollingRows(
+ int fromRow,
+ int toRow
+ )
+{
+ if (fromRow > toRow)
+ return(-1);
+
+ topScrollRow = fromRow;
+ bottomScrollRow = toRow;
+
+ return(0);
+}
+
+
+/* beRingBell -
+ *
+ * Ring the system bell once.
+ */
+
+int
+beRingBell(void)
+{
+ MessageBeep((UINT)-1);
+ return(0);
+}
+
+
+/* beGetTermMode -
+ *
+ * Return the value of conTermMode, which is the terminal settings which
+ * can be queried/set by <esc>[?#h/l.
+ */
+
+int
+beGetTermMode()
+{
+ return(conTermMode);
+}
+
+
+/* beSetTermMode -
+ *
+ * Set the terminal as requested, assuming we can. Right now we only handle a
+ * couple of the possible flags, but we store many of the others.
+ */
+
+int beSetTermMode(
+ int newMode
+ )
+{
+ int i, changes;
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ COORD newSize;
+ SMALL_RECT newWindowRect;
+ DWORD dwConMode;
+
+ changes = conTermMode ^ newMode;
+
+ /* For each bit set in 'changes', determine the
+ * appropriate course of action.
+ */
+
+ for (i=0; i < NUM_TERM_ATTR_MODES; i++)
+ {
+ if (termAttrMode[i] & changes)
+ {
+ switch(termAttrMode[i])
+ {
+ case COL132_MODE:
+ GetConsoleScreenBufferInfo(hConOut, &csbi);
+ newSize.Y = csbi.dwSize.Y;
+ newSize.X = (newMode & COL132_MODE) ? 132 : 80;
+ if (newSize.X != csbi.dwSize.X)
+ {
+ newWindowRect.Top = csbi.srWindow.Top;
+ newWindowRect.Bottom = csbi.srWindow.Bottom;
+ newWindowRect.Left = 0;
+ newWindowRect.Right = csbi.dwSize.X - 1;
+ SetConsoleScreenBufferSize(hConOut, newSize);
+ SetConsoleWindowInfo(hConOut, TRUE, &newWindowRect);
+ }
+ break;
+
+ case WRAP_MODE:
+ GetConsoleMode(hConOut,&dwConMode);
+ if ( (newMode & WRAP_MODE)
+ && (! (dwConMode & ENABLE_WRAP_AT_EOL_OUTPUT))
+ )
+ {
+ dwConMode |= ENABLE_WRAP_AT_EOL_OUTPUT;
+ SetConsoleMode(hConOut, dwConMode);
+ }
+ if ( (!(newMode & WRAP_MODE))
+ && (dwConMode & ENABLE_WRAP_AT_EOL_OUTPUT)
+ )
+ {
+ dwConMode &= ~ENABLE_WRAP_AT_EOL_OUTPUT;
+ SetConsoleMode(hConOut, dwConMode);
+ }
+ break;
+
+ case CURSORAPPL_MODE:
+ case ANSI_MODE:
+ case SMOOTHSCROLL_MODE:
+ case REVSCREEN_MODE:
+ case ORIGINREL_MODE:
+ case REPEAT_MODE:
+ /* bugbug - we don't handle any of these. */
+ break;
+ }
+ }
+ }
+
+ conTermMode = newMode;
+
+ return(0);
+}
--- /dev/null
+/* $Id: posixw32.c,v 1.3 2002/10/29 04:44:59 rex Exp $
+ *
+ * PROJECT : ReactOS Operating System / POSIX+ Environment Subsystem
+ * DESCRIPTION: POSIXW32 - A DEC VT-100 terminal emulator for the PSX subsystem
+ * DESCRIPTION: that runs in the Win32 subsystem.
+ * COPYRIGHT : Copyright (c) 2001-2002 Emanuele Aliberti
+ * LICENSE : GNU GPL v2
+ * DATE : 2001-05-05
+ * AUTHOR : Emanuele Aliberti <ea@iol.it>
+ * NOTE : This IS a Win32 program, but will fail if the PSX subsystem
+ * NOTE : is not installed. The PSX subsystem consists of two more
+ * NOTE : files: PSXSS.EXE, PSXDLL.DLL.
+ * WARNING : If you use this program under a real NT descendant, be
+ * WARNING : sure to have disabled the PSX subsystem.
+ * --------------------------------------------------------------------
+ *
+ * This software is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; see the file COPYING. If not, write
+ * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
+ * MA 02139, USA.
+ *
+ * --------------------------------------------------------------------
+ * 2002-03-16 EA Today it actually compiled.
+ * 2002-06-08 EA Renamed (old name was CSRTERM)
+ */
+#include <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define NTOS_MODE_USER
+#include <ntos.h>
+#include <psx/lpcproto.h>
+
+#include "vt100.h"
+#include "posixw32.h"
+
+/*** OPTIONS *********************************************************/
+
+#define PRIVATE static
+
+#define INPUT_QUEUE_SIZE 32
+
+#ifdef NDEBUG
+#define TRACE
+#else
+#define TRACE OutputDebugString(__FUNCTION__)
+#endif
+
+/*** GLOBALS *********************************************************/
+
+PRIVATE LPCSTR MyName = "POSIXW32";
+PRIVATE CSRTERM_SESSION Session =
+{
+ 0, //Identifier
+ { //ServerPort
+ {0,0,NULL},
+ L"\\"PSX_NS_SUBSYSTEM_DIRECTORY_NAME"\\"PSX_NS_SESSIONAPI_PORT_NAME,
+ INVALID_HANDLE_VALUE
+ }
+};
+
+/*** PRIVATE FUNCTIONS ***********************************************/
+VOID STDCALL Debug_Print (LPCSTR Format, ...)
+{
+ CHAR Buffer [512];
+ va_list ArgumentPointer;
+
+ va_start(ArgumentPointer, Format);
+ vsprintf(Buffer, Format, ArgumentPointer);
+ va_end(ArgumentPointer);
+ OutputDebugStringA (Buffer);
+}
+/**********************************************************************
+ * OutPort/2 PRIVATE
+ *
+ * DESCRIPTION
+ * Notify to PSXSS that input data is ready by sending a
+ * software interrupt on the \POSIX+\SessionPort port.
+ */
+PRIVATE DWORD STDCALL OutPort (PCHAR Buffer, ULONG Size)
+{
+ NTSTATUS Status;
+ PSX_TERMINAL_READ TerminalRead;
+TRACE;
+ if (Size > 0)
+ {
+ /* LPC */
+ TerminalRead.Header.MessageType = LPC_NEW_MESSAGE;
+ TerminalRead.PsxHeader.Context = PSX_CONNECTION_TYPE_TERMINAL;
+ TerminalRead.PsxHeader.Procedure = PSX_TERMINAL_INTERRUPT;
+ /* Terminal I/O */
+ TerminalRead.Size = Size;
+#if 0
+ RtlCopyMemory (TerminalRead.Buffer, Buffer, Size);
+ Status = NtRequestWaitReplyPort (
+ Session.ServerPort.Handle,
+ & TerminalRead
+ /* FIXME */
+ );
+#endif
+ if (!NT_SUCCESS(Status))
+ {
+ vtprintf ("%s: %s: NtRequestWaitReplyPort failed with %08x\n",
+ MyName, __FUNCTION__, Status);
+ return 0;
+ }
+ }
+ return Size;
+}
+/**********************************************************************
+ * ProcessConnectionRequest/1 PRIVATE
+ *
+ * DESCRIPTION
+ * Initialize our data for managing the control connection
+ * initiated by the PSXSS.EXE process.
+ */
+PRIVATE NTSTATUS STDCALL ProcessConnectionRequest (PLPC_MAX_MESSAGE Request)
+{
+ PPSX_CONNECT_PORT_DATA ConnectData = (PPSX_CONNECT_PORT_DATA) & Request->Data;
+
+TRACE;
+ if (PSX_CONNECTION_TYPE_SERVER != ConnectData->ConnectionType)
+ {
+
+ return STATUS_UNSUCCESSFUL;
+ }
+ if (PSX_LPC_PROTOCOL_VERSION != ConnectData->Version)
+ {
+
+ return STATUS_UNSUCCESSFUL;
+ }
+ Session.SsLinkIsActive = TRUE;
+ return STATUS_SUCCESS;
+}
+/**********************************************************************
+ * ProcessRequest/1 PRIVATE
+ *
+ * DESCRIPTION
+ *
+ */
+PRIVATE NTSTATUS STDCALL ProcessRequest (PPSX_MAX_MESSAGE Request)
+{
+TRACE;
+ /* TODO */
+ vtprintf("TEST VT-100\n");
+
+ return STATUS_SUCCESS;
+}
+/**********************************************************************
+ * PsxSessionPortListener/1 PRIVATE
+ *
+ * DESCRIPTION
+ * Manage messages from the PSXSS, that is LPC messages we get
+ * from the PSXSS process to our \POSIX+\Sessions\P<pid> port.
+ *
+ * NOTE
+ * This function is the thread 's entry point created in
+ * CreateSessionObiects().
+ */
+PRIVATE DWORD STDCALL PsxSessionPortListener (LPVOID Arg)
+{
+ NTSTATUS Status;
+ LPC_TYPE RequestType;
+ PSX_MAX_MESSAGE Request;
+ PPSX_MAX_MESSAGE Reply = NULL;
+ BOOL NullReply = FALSE;
+
+TRACE;
+
+ while (TRUE)
+ {
+ Reply = NULL;
+ NullReply = FALSE;
+ while (!NullReply)
+ {
+ Status = NtReplyWaitReceivePort (
+ Session.Port.Handle,
+ 0,
+ (PLPC_MESSAGE) Reply,
+ (PLPC_MESSAGE) & Request
+ );
+ if (!NT_SUCCESS(Status))
+ {
+ break;
+ }
+ RequestType = PORT_MESSAGE_TYPE(Request);
+ switch (RequestType)
+ {
+ case LPC_CONNECTION_REQUEST:
+ ProcessConnectionRequest ((PLPC_MAX_MESSAGE) & Request);
+ NullReply = TRUE;
+ continue;
+ case LPC_CLIENT_DIED:
+ case LPC_PORT_CLOSED:
+ case LPC_DEBUG_EVENT:
+ case LPC_ERROR_EVENT:
+ case LPC_EXCEPTION:
+ NullReply = TRUE;
+ continue;
+ default:
+ if (RequestType != LPC_REQUEST)
+ {
+ NullReply = TRUE;
+ continue;
+ }
+ }
+ Reply = & Request;
+ Reply->PsxHeader.Status = ProcessRequest (& Request);
+ NullReply = FALSE;
+ }
+ if ((STATUS_INVALID_HANDLE == Status) ||
+ (STATUS_OBJECT_TYPE_MISMATCH == Status))
+ {
+ break;
+ }
+ }
+ Session.SsLinkIsActive = FALSE;
+ TerminateThread (GetCurrentThread(), Status);
+}
+/**********************************************************************
+ * CreateSessionObiects/1 PRIVATE
+ *
+ * DESCRIPTION
+ * Create the session objects which are mananged by our side:
+ *
+ * \POSIX+\Sessions\P<pid>
+ * \POSIX+\Sessions\D<pid>
+ */
+PRIVATE NTSTATUS STDCALL CreateSessionObjects (DWORD Pid)
+{
+ NTSTATUS Status;
+ ULONG Id = 0;
+ OBJECT_ATTRIBUTES Oa;
+ LARGE_INTEGER SectionSize = {PSX_TERMINAL_SECTION_SIZE,0};
+
+TRACE;
+
+
+ /* Critical section */
+ Status = RtlInitializeCriticalSection (& Session.Lock);
+ if (!NT_SUCCESS(Status))
+ {
+ vtprintf (
+ "%s: %s: RtlInitializeCriticalSection failed with %08x\n",
+ MyName, __FUNCTION__, Status);
+ return Status;
+ }
+ /* Port and port management thread */
+ swprintf (
+ Session.Port.NameBuffer,
+ PSX_NS_SESSION_PORT_TEMPLATE,
+ PSX_NS_SUBSYSTEM_DIRECTORY_NAME,
+ PSX_NS_SESSION_DIRECTORY_NAME,
+ Pid
+ );
+ OutputDebugStringW(Session.Port.NameBuffer);
+ RtlInitUnicodeString (& Session.Port.Name, Session.Port.NameBuffer);
+ InitializeObjectAttributes (& Oa, & Session.Port.Name, 0, NULL, NULL);
+ Status = NtCreatePort (& Session.Port.Handle, & Oa, 0, 0, 0x10000);
+ if (!NT_SUCCESS(Status))
+ {
+ RtlDeleteCriticalSection (& Session.Lock);
+ vtprintf ("%s: %s: NtCreatePort failed with %08x\n",
+ MyName, __FUNCTION__, Status);
+ return Status;
+ }
+ Session.Port.Thread.Handle =
+ CreateThread (
+ NULL,
+ 0,
+ PsxSessionPortListener,
+ 0,
+ CREATE_SUSPENDED,
+ & Session.Port.Thread.Id
+ );
+ if ((HANDLE) NULL == Session.Port.Thread.Handle)
+ {
+ Status = (NTSTATUS) GetLastError();
+ NtClose (Session.Port.Handle);
+ RtlDeleteCriticalSection (& Session.Lock);
+ vtprintf ("%s: %s: CreateThread failed with %d\n",
+ MyName, __FUNCTION__, Status);
+ return Status;
+ }
+ /* Section */
+ swprintf (
+ Session.Section.NameBuffer,
+ PSX_NS_SESSION_DATA_TEMPLATE,
+ PSX_NS_SUBSYSTEM_DIRECTORY_NAME,
+ PSX_NS_SESSION_DIRECTORY_NAME,
+ Pid
+ );
+ OutputDebugStringW(Session.Section.NameBuffer);
+ RtlInitUnicodeString (& Session.Section.Name, Session.Section.NameBuffer);
+ InitializeObjectAttributes (& Oa, & Session.Section.Name, 0, 0, 0);
+ Status = NtCreateSection (
+ & Session.Section.Handle,
+ SECTION_ALL_ACCESS, /* DesiredAccess */
+ & Oa,
+ & SectionSize,
+ PAGE_READWRITE, /* Protect 4 */
+ SEC_COMMIT, /* Attributes */
+ 0 /* FileHandle: 0=pagefile.sys */
+ );
+ if (!NT_SUCCESS(Status))
+ {
+ NtClose (Session.Port.Handle);
+ NtTerminateThread (Session.Port.Thread.Handle, Status);
+ RtlDeleteCriticalSection (& Session.Lock);
+ vtprintf ("%s: %s: NtCreateSection failed with %08x\n",
+ MyName, __FUNCTION__, Status);
+ return Status;
+ }
+ Session.Section.BaseAddress = NULL;
+ Session.Section.ViewSize = SectionSize.u.LowPart;
+ Status = NtMapViewOfSection (
+ Session.Section.Handle,
+ NtCurrentProcess(),
+ & Session.Section.BaseAddress,
+ 0, /* ZeroBits */
+ 0, /* Commitsize */
+ 0, /* SectionOffset */
+ & Session.Section.ViewSize,
+ ViewUnmap,
+ 0, /* AllocationType */
+ PAGE_READWRITE /* Protect 4 */
+ );
+ if (!NT_SUCCESS(Status))
+ {
+ NtClose (Session.Port.Handle);
+ NtTerminateThread (Session.Port.Thread.Handle, Status);
+ NtClose (Session.Section.Handle);
+ RtlDeleteCriticalSection (& Session.Lock);
+ vtprintf ("%s: %s: NtMapViewOfSection failed with %08x\n",
+ MyName, __FUNCTION__, Status);
+ return Status;
+ }
+ return Status;
+}
+
+/**********************************************************************
+ * CreateTerminalToPsxChannel/0 PRIVATE
+ *
+ * DESCRIPTION
+ *
+ */
+PRIVATE NTSTATUS STDCALL CreateTerminalToPsxChannel (VOID)
+{
+ PSX_CONNECT_PORT_DATA ConnectData;
+ ULONG ConnectDataLength = sizeof ConnectData;
+ SECURITY_QUALITY_OF_SERVICE Sqos;
+ NTSTATUS Status;
+
+TRACE;
+
+
+ /*
+ * Initialize the connection data object before
+ * calling PSXSS.
+ */
+ ConnectData.ConnectionType = PSX_CONNECTION_TYPE_TERMINAL;
+ ConnectData.Version = PSX_LPC_PROTOCOL_VERSION;
+ /*
+ * Try connecting to \POSIX+\SessionPort.
+ */
+ RtlInitUnicodeString (& Session.ServerPort.Name, Session.ServerPort.NameBuffer);
+ OutputDebugStringW(Session.ServerPort.Name.Buffer);
+ Status = NtConnectPort (
+ & Session.ServerPort.Handle,
+ & Session.ServerPort.Name,
+ & Sqos,
+ NULL,
+ NULL,
+ 0,
+ & ConnectData,
+ & ConnectDataLength
+ );
+ if (STATUS_SUCCESS != Status)
+ {
+ vtprintf ("%s: %s: NtConnectPort failed with %08x\n",
+ MyName, __FUNCTION__, Status);
+ return Status;
+ }
+ Session.Identifier = ConnectData.PortIdentifier;
+ return STATUS_SUCCESS;
+}
+
+/**********************************************************************
+ * InitializeSsIoChannel PRIVATE
+ *
+ * DESCRIPTION
+ * Create our objects in the system name space
+ * (CreateSessionObjects) and then connect to the session port
+ * (CreateControChannel).
+ */
+PRIVATE NTSTATUS STDCALL InitializeSsIoChannel (VOID)
+{
+ NTSTATUS Status = STATUS_SUCCESS;
+ DWORD Pid = GetCurrentProcessId();
+
+TRACE;
+
+
+ Status = CreateSessionObjects (Pid);
+ if (STATUS_SUCCESS != Status)
+ {
+ vtprintf ("%s: %s: CreateSessionObjects failed with %08x\n",
+ MyName, __FUNCTION__, Status);
+ return Status;
+ }
+ Status = CreateTerminalToPsxChannel ();
+ if (STATUS_SUCCESS != Status)
+ {
+ vtprintf ("%s: %s: CreateTerminalToPsxChannel failed with %08x\n",
+ MyName, __FUNCTION__, Status);
+ return Status;
+ }
+ return STATUS_SUCCESS;
+}
+/**********************************************************************
+ * PsxCreateLeaderProcess/1 PRIVATE
+ *
+ * DESCRIPTION
+ * Create a new PSXSS process.
+ */
+PRIVATE NTSTATUS STDCALL PsxCreateLeaderProcess (char * Command)
+{
+ NTSTATUS Status;
+TRACE;
+
+ if (NULL == Command)
+ {
+ Command = "sh";
+ }
+ /* TODO: request PSXSS to init the process slot */
+ vtprintf ("%s: %s: calling CSRSS not implemented!", MyName, __FUNCTION__);
+ return STATUS_SUCCESS;
+}
+/**********************************************************************
+ * PrintInformationProcess/0
+ *
+ * DESCRIPTION
+ */
+PRIVATE VOID STDCALL PrintInformationProcess (VOID)
+{
+
+TRACE;
+
+ vtputs ("Leader:");
+ vtprintf (" UniqueProcess %08x\n", Session.Client.UniqueProcess);
+ vtprintf (" UniqueThread %08x\n", Session.Client.UniqueThread);
+}
+/**********************************************************************
+ * PostMortem/0
+ *
+ * DESCRIPTION
+ */
+PRIVATE INT STDCALL PostMortem (VOID)
+{
+ DWORD ExitCode;
+
+TRACE;
+
+
+ PrintInformationProcess ();
+ if (TRUE == GetExitCodeProcess (Session.Client.UniqueProcess, & ExitCode))
+ {
+ vtprintf (" ExitCode %d\n", ExitCode);
+ }
+ return 0;
+}
+/**********************************************************************
+ * InputTerminalEmulator/0
+ *
+ * DESCRIPTION
+ * Process user terminal input.
+ *
+ * NOTE
+ * This code is run in the main thread.
+ */
+PRIVATE BOOL STDCALL InputTerminalEmulator (VOID)
+{
+ HANDLE StandardInput;
+ INPUT_RECORD InputRecord [INPUT_QUEUE_SIZE];
+ DWORD NumberOfEventsRead = 0;
+ INT CurrentEvent;
+
+
+TRACE;
+
+ StandardInput = GetStdHandle (STD_INPUT_HANDLE);
+ if (INVALID_HANDLE_VALUE == StandardInput)
+ {
+ return FALSE;
+ }
+ while ((TRUE == Session.SsLinkIsActive) &&
+ ReadConsoleInput (
+ StandardInput,
+ InputRecord,
+ (sizeof InputRecord) / sizeof (INPUT_RECORD),
+ & NumberOfEventsRead
+ ))
+ {
+ for ( CurrentEvent = 0;
+ (CurrentEvent < NumberOfEventsRead);
+ CurrentEvent ++
+ )
+ {
+ switch (InputRecord [CurrentEvent].EventType)
+ {
+ case KEY_EVENT:
+ OutPort (& InputRecord [CurrentEvent].Event.KeyEvent.uChar.AsciiChar, 1);
+ break;
+ case MOUSE_EVENT:
+ /* TODO: send a sequence of move cursor codes */
+ /* InputRecord [CurrentEvent].Event.MouseEvent; */
+ break;
+ case WINDOW_BUFFER_SIZE_EVENT:
+ /* TODO: send a SIGWINCH signal to the leader process. */
+ /* InputRecord [CurrentEvent].Event.WindowBufferSizeEvent.dwSize; */
+ break;
+ /* Next events should be ignored. */
+ case MENU_EVENT:
+ vtprintf ("%s: %s: MENU_EVENT received from CSRSS\n", MyName, __FUNCTION__);
+ case FOCUS_EVENT:
+ vtprintf ("%s: %s: FOCUS_EVENT received from CSRSS\n", MyName, __FUNCTION__);
+ break;
+ }
+ }
+ NumberOfEventsRead = 0;
+ }
+ return TRUE;
+}
+/**********************************************************************
+ * Startup/1
+ *
+ * DESCRIPTION
+ * Initialize the program.
+ */
+PRIVATE VOID STDCALL Startup (LPSTR Command)
+{
+ NTSTATUS Status;
+ DWORD ThreadId;
+
+
+TRACE;
+
+ /* PSX process info */
+ Session.Client.UniqueProcess = INVALID_HANDLE_VALUE;
+ Session.Client.UniqueThread = INVALID_HANDLE_VALUE;
+ /* Initialize the VT-100 emulator */
+ vtInitVT100 ();
+ /* Connect to PSXSS */
+ Status = InitializeSsIoChannel ();
+ if (!NT_SUCCESS(Status))
+ {
+ vtprintf ("%s: failed to connect to PSXSS (Status=%08x)!\n",
+ MyName, Status);
+ exit (EXIT_FAILURE);
+ }
+ /* Create the leading process for this session */
+ Status = PsxCreateLeaderProcess (Command);
+ if (!NT_SUCCESS(Status))
+ {
+ vtprintf ("%s: failed to create the PSX process (Status=%08x)!\n",
+ MyName, Status);
+ exit (EXIT_FAILURE);
+ }
+}
+/**********************************************************************
+ * Shutdown/0 PRIVATE
+ *
+ * DESCRIPTION
+ * Shutdown the program.
+ */
+PRIVATE INT STDCALL Shutdown (VOID)
+{
+
+TRACE;
+
+ /* TODO: try exiting cleanly: close any open resource */
+ /* TODO: notify PSXSS the session is terminating */
+ RtlDeleteCriticalSection (& Session.Lock);
+ return PostMortem ();
+}
+/**********************************************************************
+ *
+ * ENTRY POINT PUBLIC
+ *
+ *********************************************************************/
+int main (int argc, char * argv [])
+{
+
+TRACE;
+
+ Startup (argv[1]); /* Initialization */
+ InputTerminalEmulator (); /* Process user input */
+ return Shutdown ();
+}
+/* EOF */
--- /dev/null
+#ifndef _CSRTERM_H
+#define _CSRTERM_H
+
+/* PSX session: CSR terminal emulator side */
+
+#define NAME_BUFFER_SIZE 64
+
+typedef struct _PSXSS_PORT
+{
+ UNICODE_STRING Name;
+ WCHAR NameBuffer [NAME_BUFFER_SIZE];
+ HANDLE Handle;
+
+} PSXSS_PORT, * PPSXSS_PORT;
+
+typedef struct _CSRTERM_SESSION_PORT
+{
+ UNICODE_STRING Name;
+ WCHAR NameBuffer [NAME_BUFFER_SIZE];
+ HANDLE Handle;
+ struct {
+ HANDLE Handle;
+ DWORD Id;
+ } Thread;
+
+} CSRTERM_SESSION_PORT;
+
+typedef struct _CSRTERM_SESSION_SECTION
+{
+ UNICODE_STRING Name;
+ WCHAR NameBuffer [NAME_BUFFER_SIZE];
+ HANDLE Handle;
+ ULONG Size;
+ PVOID BaseAddress;
+ ULONG ViewSize;
+
+} CSRTERM_SESSION_SECTION;
+
+typedef struct _CSRTERM_SESSION
+{
+ ULONG Identifier; /* PortID for ServerPort in PSXSS */
+ PSXSS_PORT ServerPort; /* \POSIX+\SessionPort */
+ CSRTERM_SESSION_PORT Port; /* \POSIX+\Sessions\P<pid> */
+ CSRTERM_SESSION_SECTION Section; /* \POSIX+\Sessions\D<pid> */
+ CLIENT_ID Client;
+ CRITICAL_SECTION Lock;
+ BOOL SsLinkIsActive;
+
+} CSRTERM_SESSION, * PCSRTERM_SESSION;
+
+#define LOCK_SESSION RtlEnterCriticalSection(& Session.Lock)
+#define UNLOCK_SESSION RtlLeaveCriticalSection(& Session.Lock)
+#endif /* ndef _CSRTERM_H */
--- /dev/null
+#include <defines.h>
+#include <reactos/resource.h>
+
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION RES_UINT_FV_MAJOR,RES_UINT_FV_MINOR,RES_UINT_FV_REVISION,RES_UINT_FV_BUILD
+ PRODUCTVERSION RES_UINT_PV_MAJOR,RES_UINT_PV_MINOR,RES_UINT_PV_REVISION,RES_UINT_PV_BUILD
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x40004L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "CompanyName", RES_STR_COMPANY_NAME
+ VALUE "FileDescription", "CSR Terminal Emulator for POSIX+\0"
+ VALUE "FileVersion", RES_STR_FILE_VERSION
+ VALUE "InternalName", "csrterm\0"
+ VALUE "LegalCopyright", RES_STR_LEGAL_COPYRIGHT
+ VALUE "OriginalFilename", "csrterm.exe\0"
+ VALUE "ProductName", RES_STR_PRODUCT_NAME
+ VALUE "ProductVersion", RES_STR_PRODUCT_VERSION
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
--- /dev/null
+$Id: readme.txt,v 1.3 2002/10/29 04:45:05 rex Exp $
+
+posixw32 - a Win32 client terminal emulator for the POSIX+ subsystem
+
+SYNOPSYS
+
+ posixw32 [program]
+
+ program program to be run in the terminal; if none is given,
+ the shell for the current user (W32 session's) is
+ used.
+
+DESCRIPTION
+
+ posixw32 emulates a DEC VT-100 terminal (on top of the CSRSS
+ subsystem, hence the name) which is the controlling terminal
+ for a process [program] running in the context of the PSX
+ subsystem. posixw32 is a Win32 console application, not a PSX
+ application. The process created by the PSX subsystem on behalf
+ of posixw32 is not the child of the posixw32 instance that
+ requested it. posixw32 simply performs terminal I/O in the CSRSS
+ world (the W32 world!) for [program].
+
+NOTES
+
+ The role of posixw32 is creating a session in the PSX subsystem
+ managing any I/O for it. This is how it works:
+
+ 1. posixw32 creates two well known named objects in the system
+ name space that will allow the PSX subsystem server to build
+ the I/O channel for the session. To let the PSX subsystem
+ process recognize the objects, they contain a numeric suffix
+ which is the process identifier (n) the system gives to each
+ instance of posixw32:
+
+ \POSIX+\Session\Pn LPC port (IPC rendez-vous object)
+ \POSIX+\Session\Dn section (shared memory object)
+
+ posixw32 also creates a new thread to manage the calls though
+ the LPC port. Port Pn is used by the subsystem to control the
+ terminal which posixw32 emulates.
+
+ 2. posixw32 connects to the PSX subsystem session port
+
+ \POSIX+\SessionPort
+
+ and asks the subsystem to create a new session.
+
+ 3. The PSX subsystem, if it decides to accept the request, creates
+ a new session for that calling instance of posixw32 (n), and in
+ turn connects back to the terminal control port
+
+ \POSIX+\Session\Pn
+
+ 4. When posixw32 makes the PSX subsystem create the new session, it
+ also tells the subsystem what program should be the session
+ leader process. The PSX subsystem creates that process (the
+ image file to start must be marked IMAGE_SUBSYSTEM_POSIX_GUI or
+ IMAGE_SUBSYSTEM_POSIX_CUI).
+
+ 5. The requested process [program] runs in the context of the
+ PSX subsystem and performs any terminal I/O via the channel
+ posixw32 and the PSX susbstem created.
+
+REVISIONS
+ 2001-05-05 created
+ 2002-03-03 simplified
+ 2002-06-08 renamed to avoid future name clash
+
+AUTHOR
+
+ Emanuele Aliberti <ea@iol.it>
+
+CREDITS
+
+ John L. Miller (johnmil@cs.cmu.edu, johnmil@jprc.com) code for
+ a basic VT-100 emulator for Win32 consoles is used to process
+ tc* calls output.
+
+EOF
--- /dev/null
+/* vt100.c
+ *
+ * AUTHOR: John L. Miller, johnmil@cs.cmu.edu / johnmil@jprc.com
+ * DATE: 8/4/96
+ *
+ * Copyright (c) 1996 John L. Miller
+ *
+ * Full permission is granted to use, modify and distribute
+ * this code, provided:
+ * 1) This comment field is included in its entirity
+ * 2) No money is charged for any work including or based on
+ * portions of this code.
+ *
+ * If you're a nice person and find this useful, I'd appreciate a
+ * note letting me know about it. e-mail is usually what spurs me
+ * on to improve and support software I've written.
+ *
+ */
+
+/* This is the main code body for my generic vt-100 emulator. This code
+ * body provides parsing for most of the vt-100 escape sequences, but it
+ * doesn't actually do anything with some of them. The idea behind this
+ * parser is to provide a generic front-end that you can initialize, then
+ * send all of your output to. The output is parsed by the routines in this
+ * program, then spit out to a back-end.
+ *
+ * What back-end you say? Well, the one you have to supply yourself. There's a
+ * dozen or so routines you have to provide for character-based I/O, cursor
+ * movement, erasing and deleting text, and setting text and terminal attributes.
+ *
+ * For a list of the routines your back end must supply, read vt100.h closely.
+ *
+ * In case it's not obvious, these routines were written for a system running win32.
+ * for vt100.c and vt100.h, most of the code should be easily portable to other
+ * operating systems. Yeah, like they NEED a vt-100 emulator :p
+ */
+
+#include <windows.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include "vt100.h"
+
+
+/* NOTE - many of the functions look like they should
+ * take X-Y pairs. Bear in mind this is a text display,
+ * so for this we're talking ROWS and COLUMNS. So parm
+ * lists go (row, column), which is the opposite of (x, y).
+ */
+
+char cBuffer[MAXVTBUFLEN+1]; /* terminal output buffer for unprocessed characters */
+int BufLen; /* Number of characters in cBuffer waiting for output */
+
+/* List of all device-independant colors. These colors will be transmitted to a
+ * back-end routine responsible for setting the foreground and background text
+ * colors appropriately. Note that the color combinations are ordered to correspond
+ * with combinations of red (0x1), green (0x2) and blue (0x4) bit flags.
+ */
+
+int ScColorTrans[8]= { 0,
+ SC_RED,
+ SC_GREEN,
+ SC_RED|SC_GREEN,
+ SC_BLUE,
+ SC_RED|SC_BLUE,
+ SC_RED|SC_GREEN,
+ SC_RED|SC_GREEN|SC_BLUE
+ };
+
+
+/* List of terminal attributes which we track (used by <esc>[?#h and <esc>[?#l) */
+
+int termAttrMode[NUM_TERM_ATTR_MODES] = { 0,
+ CURSORAPPL_MODE,
+ ANSI_MODE,
+ COL132_MODE,
+ SMOOTHSCROLL_MODE,
+ REVSCREEN_MODE,
+ ORIGINREL_MODE,
+ WRAP_MODE,
+ REPEAT_MODE,
+ };
+
+/* FORWARD FUNCTION DECLARATIONS -
+ * these functions are intended for use only in this module */
+
+static int ProcessBracket(int Start);
+static int ProcessEscape(int Start);
+static int ProcessControl(int Start);
+static int ProcessBuffer(void);
+
+/* END FORWARD FUNCTION DECLARATIONS */
+
+
+
+/* vtputs() -
+ *
+ * front-end 'puts()' substitute. Call this routine instead
+ * of 'puts()', and it'll pass the output through the vt100 emulator.
+ */
+
+vtputs(char *f)
+{
+ char cbuf[1024];
+
+ strcpy(cbuf,f);
+ strcat(cbuf,"\n");
+ vtProcessedTextOut(cbuf, strlen(cbuf));
+
+ return(0);
+}
+
+
+/* vtprintf -
+ *
+ * This routine is a substitute for printf(). Call this routine with the
+ * same parameters you would use for printf, and output will be channelled
+ * through the vt-100 emulator.
+ */
+
+vtprintf(char *format, ...)
+{
+ char cbuf[1024];
+ va_list va;
+
+ va_start(va, format);
+ vsprintf(cbuf,format, va);
+ va_end(va);
+
+ vtProcessedTextOut(cbuf, strlen(cbuf));
+
+ return(0);
+}
+
+/* vtInitVT100 -
+ *
+ * Set the initial state of the VT-100 emulator, and call the initialization
+ * routine for the back end. This routine MUST be invoked before any other, or
+ * the VT-100 emulator will most likely roll over and die.
+ */
+
+vtInitVT100(void)
+{
+ int i=0;
+
+ cBuffer[0]='\0';
+ BufLen=0;
+
+ beInitVT100Terminal(); /* call the back-end initialization. */
+
+ return(0);
+}
+
+
+/* ProcessBracket -
+ *
+ * Helper routine for processing escape sequences. By the time this
+ * routine is invoked, '<esc>[' has already been read in the input
+ * stream. 'Start' is an index in cBuffer to the '<esc>'.
+ *
+ * If an escape sequence is successfully parsed, return the index of the
+ * first character AFTER the escape sequence. Otherwise, return 'Start'.
+ *
+ */
+
+static int ProcessBracket(int Start)
+{
+ int End; /* Current character being examined in cBuffer */
+ int args[10], numargs=0; /* numerical args after <esc>[ */
+ int iMode;
+ int i;
+ int itmp=0;
+ int left;
+ int iForeground, iBackground;
+
+ /* If there's no valid escape sequence, return as we were called. */
+
+ if ((cBuffer[Start+1] != '[')||(Start+2 >= BufLen))
+ return(Start);
+
+ End = Start + 2;
+
+ /* Loop through the buffer, hacking out all numeric
+ * arguments (consecutive string of digits and
+ * semicolons
+ */
+
+ do {
+ itmp = 0; /* itmp will hold the current arguments integer value */
+
+ /* the semicolon is a delimiter */
+ if (cBuffer[End] == ';')
+ {
+ End++;
+
+ if (End >= BufLen)
+ return(Start);
+ }
+
+ /* Parse this argument into a number. */
+
+ while (isdigit(cBuffer[End]))
+ {
+ itmp = itmp*10 + (cBuffer[End]-'0');
+ End++;
+ if (End >= BufLen)
+ return(Start);
+ }
+
+ /* Save the numeric argument if we actually
+ * parsed a number.
+ */
+
+ if (End != Start + 2)
+ args[numargs++] = itmp;
+
+ } while (cBuffer[End] == ';');
+
+ /* At this point, we've come across a character that isn't a number
+ * and isn't a semicolon. This means it is the command specifier.
+ */
+
+ /* Number of characters left in the input stream. I don't use
+ * this as rigorously as I should here.
+ */
+
+ left = BufLen - End;
+
+ /* Return if there's definitely not enough characters for a
+ * full escape sequence.
+ */
+
+ if (left <= 0)
+ return(Start);
+
+ /* Giant switch statement, parsing the command specifier that followed
+ * up <esc>[arg;arg;...arg
+ */
+
+ switch (cBuffer[End])
+ {
+ /* Cursor Up: Esc [ Pn A */
+ case 'A':
+ beOffsetCursor(numargs ? -args[0] : -1, 0);
+ End += 1;
+ break;
+
+ /* Cursor Down: Esc [ Pn B */
+ case 'B':
+ beOffsetCursor(numargs ? args[0] : 1, 0);
+ End += 1;
+ break;
+
+ /* Cursor Right: Esc [ Pn C */
+ case 'C':
+ beOffsetCursor(0, numargs ? args[0] : 1);
+ End += 1;
+ break;
+
+ /* Cursor Left: Esc [ Pn D */
+ case 'D':
+ beOffsetCursor(0, numargs ? -args[0] : -1);
+ End += 1;
+ break;
+
+ /* Direct Addressing : Esc [ Pn(row);Pn(col)H or
+ * Esc [ Pn(row);Pn(col)f
+ */
+ case 'H':
+ case 'f':
+ if (numargs == 0)
+ beAbsoluteCursor(1,1);
+ else if (numargs == 1)
+ beAbsoluteCursor(args[0] > 0 ? args[0] : 1,1);
+ else if (numargs == 2)
+ beAbsoluteCursor(args[0] > 0 ? args[0] : 1, args[1] > 0 ? args[1] : 1);
+
+ End += 1;
+ break;
+
+ /* Erase from Cursor to end of screen Esc [ J
+ * Erase from Beginning of screen to cursor Esc [ 1 J
+ * Erase Entire screen Esc [ 2 J
+ */
+ case 'J':
+ if (numargs == 0)
+ beEraseText(CUR_ROW, CUR_COL, BOTTOM_EDGE, RIGHT_EDGE);
+ else if (args[0] == 1)
+ beEraseText(TOP_EDGE, LEFT_EDGE, CUR_ROW, CUR_COL);
+ else
+ beEraseText(TOP_EDGE, LEFT_EDGE, BOTTOM_EDGE, RIGHT_EDGE);
+
+ End += 1;
+ break;
+
+ /* Erase from Cursor to end of line Esc [ K
+ * Erase from Beginning of line to cursor Esc [ 1 K
+ * Erase Entire line Esc [ 2 K
+ */
+ case 'K':
+ if (numargs == 0)
+ beEraseText(CUR_ROW, CUR_COL, CUR_ROW, RIGHT_EDGE);
+ else if (args[0] == 1)
+ beEraseText(CUR_ROW, LEFT_EDGE, CUR_ROW, CUR_COL);
+ else
+ beEraseText(CUR_ROW, LEFT_EDGE, CUR_ROW, RIGHT_EDGE);
+
+ End += 1;
+ break;
+
+
+ /* Set Graphics Rendition:
+ * ESC[#;#;....;#m
+ * The graphics rendition is basically foreground and background
+ * color and intensity.
+ */
+ case 'm':
+ beGetTextAttributes(&iForeground, &iBackground);
+
+ if (numargs < 1)
+ {
+ /* If we just get ESC[m, treat it as though
+ * we should shut off all extra text
+ * attributes
+ */
+
+ iForeground &= ~(SC_BOLD|SC_UL|SC_BL|SC_RV|SC_GRAPHICS|SC_G0|SC_G1);
+ iForeground |= SC_ASCII;
+
+ beSetTextAttributes(iForeground, iBackground);
+ End += 1;
+ break;
+ }
+
+ /* Loop through all the color specs we got, and combine them
+ * together. Note that things like 'reverse video', 'bold',
+ * and 'blink' are only applied to the foreground. The back end
+ * is responsible for applying these properties to all text.
+ */
+ for (i=0; i < numargs; i++)
+ {
+ switch(args[i])
+ {
+ /* 0 for normal display */
+ case 0:
+ iForeground &= ~SC_BOLD;
+ break;
+
+ /* 1 for bold on */
+ case 1:
+ iForeground |= SC_BOLD;
+ break;
+
+ /* 4 underline (mono only) */
+ case 4:
+ iForeground |= SC_UL;
+ break;
+
+ /* 5 blink on */
+ case 5:
+ iForeground |= SC_BL;
+ break;
+
+ /* 7 reverse video on */
+ case 7:
+ iForeground |= SC_RV;
+ break;
+
+ /* 8 nondisplayed (invisible) BUGBUG - not doing this. */
+
+
+ /* 30-37 is bit combination of 30+ red(1) green(2) blue(4)
+ * 30 black foreground
+ */
+ case 30:
+ case 31:
+ case 32:
+ case 33:
+ case 34:
+ case 35:
+ case 36:
+ case 37:
+ iForeground &= ~(SC_RED|SC_GREEN|SC_BLUE);
+ iForeground |= ScColorTrans[args[i]-30];
+ break;
+
+ /* 40-47 is bit combo similar to 30-37, but for background. */
+ case 40:
+ case 41:
+ case 42:
+ case 43:
+ case 44:
+ case 45:
+ case 46:
+ case 47:
+ iBackground &= ~(SC_RED|SC_GREEN|SC_BLUE);
+ iBackground |= ScColorTrans[args[i]-30];
+ break;
+ }
+ }
+
+ beSetTextAttributes(iForeground, iBackground);
+
+ End += 1;
+ break;
+
+
+ /*
+ * Set with Esc [ Ps h
+ * Reset with Esc [ Ps l
+ * Mode name Ps Set Reset
+ * -------------------------------------------------------------------
+ * Keyboard action 2 Locked Unlocked
+ * Insertion 4 Insert Overwrite
+ * Send - Receive 12 Full Echo
+ * Line feed/New line 20 New line Line feed
+ */
+ case 'h':
+ case 'l':
+ /* BUGBUG - many of the terminal modes are set with '?' as the
+ * first character rather than a number sign. These are dealt with
+ * later in this switch statement because they must be. Most other
+ * settings are just ignored, however.
+ */
+ End += 1;
+ break;
+
+ /* Insert line Esc [ Pn L */
+ case 'L':
+ beInsertRow(CUR_ROW);
+ End += 1;
+ break;
+
+ /* Delete line Esc [ Pn M */
+ case 'M':
+ do {
+ beDeleteText(CUR_ROW,LEFT_EDGE, CUR_ROW, RIGHT_EDGE);
+ } while (--args[0] > 0);
+
+ End += 1;
+ break;
+
+ /* Delete character Esc [ Pn P */
+ case 'P':
+ do {
+ beDeleteText(CUR_ROW, CUR_COL, CUR_ROW, CUR_COL);
+ } while (--args[0] > 0);
+ End += 1;
+ break;
+
+ /* Set the Scrolling region Esc [ Pn(top);Pn(bot) r */
+ case 'r':
+ if (numargs == 0)
+ beSetScrollingRows(TOP_EDGE,BOTTOM_EDGE);
+ else if (numargs == 2)
+ beSetScrollingRows(args[0],args[1]);
+ End += 1;
+ break;
+
+ /* Print screen or region Esc [ i
+ * Print cursor line Esc [ ? 1 i
+ * Enter auto print Esc [ ? 5 i
+ * Exit auto print Esc [ ? 4 i
+ * Enter print controller Esc [ 5 i
+ * Exit print controller Esc [ 4 i
+ */
+ case 'i':
+ /* BUGBUG - print commands are not acted upon. */
+ End += 1;
+ break;
+
+
+ /* Clear tab at current column Esc [ g
+ * Clear all tabs Esc [ 3 g
+ */
+ case 'g':
+ if (numargs == 0)
+ beClearTab(CUR_COL);
+ else
+ if ((numargs == 1) && (args[0] == 3))
+ beClearTab(ALL_TABS);
+
+ End += 1;
+ break;
+
+ /* BUGBUG - queries which require responses are ignored. */
+
+ /* Esc [ c DA:Device Attributes
+ * or
+ *
+ * Esc [ <sol> x DECREQTPARM: Request Terminal Parameters
+ * * <sol> values other than 1 are ignored. Upon
+ * receipt of a <sol> value of 1, the following
+ * response is sent:
+ * Esc[3;<par>;<nbits>;<xspeed>;<rspeed>;1;0x
+ *
+ * * Where <par>, <nbits>, <xspeed>, and <rspeed>
+ * are as for VT100s with the following
+ * exceptions:
+ * <nbits> Values of 5 and 6 bits per
+ * character are sent as 7 bits.
+ * <xspeed>,<rspeed>
+ * These two numbers will always
+ * be the same. 9600 baud is
+ * sent for 7200 baud.
+ *
+ * Esc [ Ps n DSR: Device Status Report
+ * * Parameter values other than 5, 6, are ignored.
+ * If the parameter value is 5, the sequence
+ * Esc [ O n is returned. If the parameter value is
+ * 6, the CPR: Cursor Position Report sequence
+ * Esc [ Pn ; Pn R is returned with the Pn set to
+ * cursor row and column numbers.
+ *
+ * Cursor Controls:
+ * ESC[#;#R Reports current cursor line & column
+ */
+
+ /* spec <esc>[<spec>h <esc>[<spec>l
+ * Cursor key ?1 Application Cursor
+ * ANSI/VT52 ?2 ANSI VT52
+ * Column ?3 132 80
+ * Scrolling ?4 Smooth Jump
+ * Screen ?5 Reverse Normal
+ * Origin ?6 Relative Absolute
+ * Wraparound ?7 Wrap Truncate
+ * Auto key repeat ?8 Repeating No repeat
+ */
+ case '?':
+ /* We didn't catch the numeric argument because the '?' stopped
+ * it before. Parse it now.
+ */
+ args[0]=0;
+ while (isdigit(cBuffer[++End]))
+ {
+ if (End >= BufLen)
+ return(Start);
+ args[0] = 10*args[0] + (cBuffer[End]-'0');
+ }
+
+ /* If we don't handle this particular '?' command (and
+ * there are plenty we don't) then just ignore it.
+ */
+ if ( (args[0] > 8)
+ ||( (cBuffer[End] != 'l') && (cBuffer[End] != 'h'))
+ )
+ {
+ End++;
+ if (End >= BufLen)
+ return(Start);
+ break;
+ }
+
+ /* This command sets terminal status. Get the current status,
+ * determine what needs to be changed, and send it back.
+ */
+
+ iMode = beGetTermMode();
+
+ /* If we need a given mode and it's not already set, set it. */
+
+ if ((cBuffer[End] == 'h') && (!(iMode & termAttrMode[args[0]])))
+ {
+ beSetTermMode(iMode | termAttrMode[args[0]]);
+ }
+
+ /* likewise, clear it as appropriate */
+ if ((cBuffer[End] == 'l') && (iMode & termAttrMode[args[0]]))
+ {
+ beSetTermMode(iMode & ~termAttrMode[args[0]]);
+ }
+
+ End++;
+ break;
+
+ /* If it's an escape sequence we don't treat, pretend as though we never saw
+ * it.
+ */
+ default:
+ End += 1;
+ break;
+ }
+
+ return(End);
+
+}
+
+
+/* ProcessEscape -
+ *
+ * At this point, <esc> has been seen. Start points to the escape
+ * itself, and then this routine is responsible for parsing the
+ * rest of the escape sequence, and either pawning off further parsing,
+ * or acting upon it as appropriate.
+ *
+ * Note that the escape sequences being parsed are still contained in cBuffer.
+ */
+
+static int ProcessEscape(int Start)
+{
+ int End;
+ int left;
+ int fore, back;
+ int i;
+
+ /* if it's definitely not a full escape sequence, return that we haven't
+ * seen it.
+ */
+ if ((cBuffer[Start] != 27)||(Start+1 >= BufLen))
+ return(Start);
+
+ End = Start + 1;
+
+ /* At this point, if the sequence is <esc> x, 'End' points at
+ * x
+ */
+
+ /* left = number of characters left unparsed in the buffer. */
+ left = BufLen - End -1;
+
+ /* Main switch statement - parse the escape sequence according to the
+ * next character we see.
+ */
+
+ switch (cBuffer[End])
+ {
+ /* Hard Reset Esc c BUGBUG - not imp'd. */
+ case 'c':
+ End += 1;
+ break;
+
+ /* Cursor up Esc A */
+ case 'A':
+ beOffsetCursor(-1,0);
+ End += 1;
+ break;
+
+ /* Cursor down Esc B */
+ case 'B':
+ beOffsetCursor(1,0);
+ End += 1;
+ break;
+
+ /* Cursor right Esc C */
+ case 'C':
+ beOffsetCursor(0,1);
+ End += 1;
+ break;
+
+ /* Cursor left Esc D */
+ case 'D':
+ beOffsetCursor(0,-1);
+ End += 1;
+ break;
+
+ /* Newline command: Esc E */
+ case 'E':
+ beRawTextOut("\n",strlen("\n"));
+ End += 1;
+ break;
+
+ /* Invoke the Graphics character set Esc F */
+ case 'F':
+ beGetTextAttributes(&fore, &back);
+ if (! (fore & SC_GRAPHICS))
+ {
+ fore &= ~(SC_ASCII|SC_G0|SC_G1);
+ fore |= SC_GRAPHICS;
+ beSetTextAttributes(fore, back);
+ }
+ End += 1;
+ break;
+
+ /* Invoke the ASCII character set Esc G */
+ case 'G':
+ beGetTextAttributes(&fore, &back);
+ if (! (fore & SC_ASCII))
+ {
+ fore &= ~(SC_G0|SC_G1|SC_GRAPHICS);
+ fore |= SC_ASCII;
+ beSetTextAttributes(fore, back);
+ }
+ End += 1;
+ break;
+
+ /* Move the cursor to (1,1): Home cursor Esc H */
+ case 'H':
+ beAbsoluteCursor(TOP_EDGE,LEFT_EDGE);
+ End += 1;
+ break;
+
+ /* Reverse line feed Esc I */
+ case 'I':
+ beOffsetCursor(-1,0);
+ End += 1;
+ break;
+
+ /* Erase to end of screen Esc J */
+ case 'J':
+ beEraseText(CUR_ROW, CUR_COL, BOTTOM_EDGE, RIGHT_EDGE);
+ End += 1;
+ break;
+
+ /* Erase to end of line Esc K */
+ case 'K':
+ beEraseText(CUR_ROW, CUR_COL, CUR_ROW, RIGHT_EDGE);
+ End += 1;
+ break;
+
+ /* Reverse Line: Esc M */
+ case 'M':
+ beAbsoluteCursor(CUR_ROW, LEFT_EDGE);
+ beOffsetCursor(-1,0);
+ End += 1;
+ break;
+
+ /* Switch to G1 graphics character set. Esc N */
+ case 'N':
+ beGetTextAttributes(&fore, &back);
+ if (! (fore & SC_G1))
+ {
+ fore &= ~(SC_G0|SC_ASCII|SC_GRAPHICS);
+ fore |= SC_G1;
+ beSetTextAttributes(fore, back);
+ }
+ End += 1;
+ break;
+
+ /* Switch to G0 graphics character set Esc O */
+ case 'O':
+ beGetTextAttributes(&fore, &back);
+ if (! (fore & SC_G0))
+ {
+ fore &= ~(SC_G1|SC_ASCII|SC_GRAPHICS);
+ fore |= SC_G0;
+ beSetTextAttributes(fore, back);
+ }
+ End += 1;
+ break;
+
+ /* Print cursor line Esc V BUGBUG - unimp'd */
+ case 'V':
+ End += 1;
+ break;
+
+ /* Enter print controller Esc W BUGBUG - unimp'd */
+ case 'W':
+ End += 1;
+ break;
+
+ /* Exit print controller Esc X BUGBUG - unimp'd */
+ case 'X':
+ End += 1;
+ break;
+
+ /* Cursor address Esc Y row col BUGBUG - unimp'd and needed */
+ case 'Y':
+ End += 1;
+ break;
+
+ /* Identify terminal type Esc Z */
+ case 'Z':
+ beTransmitText(ANSWERBACK_MESSAGE,strlen(ANSWERBACK_MESSAGE));
+ End += 1;
+ break;
+
+ /* One of dozens of escape sequences starting <esc>[. Parse further */
+ case '[':
+ /* pass in the escape as the starting point */
+ End = ProcessBracket(End-1);
+ break;
+
+ /* Print screen Esc ] BUGBUG - unimp'd */
+ case ']':
+ End += 1;
+ break;
+
+ /* Enter auto print Esc ^ BUGBUG - unimpd' */
+ case '^':
+ End += 1;
+ break;
+
+ /* Exit auto print Esc - BUGBUG - unimpd' */
+ case '-':
+ End += 1;
+ break;
+
+ /* Alternate keypad Esc = BUGBUG - unimpd' */
+ case '=':
+ End += 1;
+ break;
+
+ /* Numeric keypad Esc > BUGBUG - unimpd' */
+ case '>':
+ End += 1;
+ break;
+
+ /* Enter ANSI mode Esc < BUGBUG - unimpd' */
+ case '<':
+ End += 1;
+ break;
+
+ /* Save cursor position & Attributes: Esc 7 */
+ case '7':
+ beSaveCursor();
+ End += 1;
+ break;
+
+ /* Restore cursor position & attributes: Esc 8 */
+ case '8':
+ beRestoreCursor();
+ End += 1;
+ break;
+
+ /* Set character size - BUGBUG - unimp'd.
+ * # 1 Double ht, single width top half chars
+ * # 2 Double ht, single width lower half chars
+ * # 3 Double ht, double width top half chars
+ * # 4 Double ht, double width lower half chars
+ * # 5 Single ht, single width chars
+ * # 6 Single ht, double width chars
+ */
+ case '#':
+ End += 1;
+ break;
+
+ /* Select character set
+ * ESC ( A British
+ * ESC ( C Finnish
+ * ESC ( E Danish or Norwegian
+ * ESC ( H Swedish
+ * ESC ( K German
+ * ESC ( Q French Canadian
+ * ESC ( R Flemish or French/Belgian
+ * ESC ( Y Italian
+ * ESC ( Z Spanish
+ * ESC ( 1 Alternative Character
+ * ESC ( 4 Dutch
+ * ESC ( 5 Finnish
+ * ESC ( 6 Danish or Norwegian
+ * ESC ( 7 Swedish
+ * ESC ( = Swiss (French or German)
+ */
+ case '(':
+ case ')':
+ /* BUGBUG - most character sets aren't implemented. */
+ beGetTextAttributes(&fore, &back);
+ switch (cBuffer[++End])
+ {
+ case 'B': /* ESC ( B North American ASCII set */
+ i=SC_ASCII;
+ break;
+
+ case '0': /* ESC ( 0 Line Drawing */
+ i=SC_G1;
+ break;
+
+ case '2': /* ESC ( 2 Alternative Line drawing */
+ i=SC_G0;
+ break;
+
+ default:
+ /* Make sure the screen mode isn't set. */
+ i = 0xFFFFFFFF;
+ break;
+ }
+
+ if (! (fore & i))
+ {
+ fore &= ~(SC_ASCII|SC_G0|SC_G1|SC_GRAPHICS);
+ fore |= i;
+ beSetTextAttributes(fore, back);
+ }
+
+ End += 1;
+ break;
+
+ /* Unknown escape sequence */
+ default:
+ {
+ char cbuf[80];
+ sprintf(cbuf,"<esc>%c", cBuffer[End]);
+ beRawTextOut(cbuf+Start,6);
+ End += 1;
+ }
+ }
+
+ return(End);
+}
+
+
+/* ProcessControl -
+ *
+ * Process a probable escape or control sequence
+ * starting at the supplied index. Return the index
+ * of the first character *after* the escape sequence we
+ * process.
+ * In the case of an incomplete sequence, ie one
+ * that isn't completed by the end of the buffer, return
+ * 'Start'.
+ * In the case of an invalid sequence,
+ * note the invalid escape sequence, and return Start+1
+ */
+
+static int ProcessControl(int Start)
+{
+ int fore, back;
+ int End = Start;
+
+ /* Check to make sure we at least have enough characters
+ * for a control character
+ */
+
+ if (Start >= BufLen)
+ return(Start);
+
+ switch (cBuffer[Start])
+ {
+ /* NUL 0 Fill character; ignored on input.
+ * DEL 127 Fill character; ignored on input.
+ */
+ case 0:
+ case 127:
+ End += 1;
+ break;
+
+ /* ENQ 5 Transmit answerback message. */
+ case 5:
+ beTransmitText(ANSWERBACK_MESSAGE,strlen(ANSWERBACK_MESSAGE));
+ End += 1;
+ break;
+
+ /* BEL 7 Ring the bell. */
+ case 7:
+ beRingBell();
+ End += 1;
+ break;
+
+ /* BS 8 Move cursor left. */
+ case 8:
+ beOffsetCursor(0,-1);
+ End += 1;
+ break;
+
+ /* HT 9 Move cursor to next tab stop. */
+ case 9:
+ beAdvanceToTab();
+ End += 1;
+ break;
+
+ /* LF 10 Line feed; causes print if in autoprint. */
+ case 10:
+ beOffsetCursor(1,0);
+ End += 1;
+ break;
+
+ /* VT 11 Same as LF.
+ * FF 12 Same as LF.
+ */
+ case 11:
+ case 12:
+ beOffsetCursor(1,0);
+ End += 1;
+ break;
+
+ /* CR 13 Move cursor to left margin or newline. */
+ case 13:
+ beOffsetCursor(1,0);
+ beAbsoluteCursor(CUR_ROW,LEFT_EDGE);
+ End += 1;
+ break;
+
+ /* SO 14 Invoke G1 character set. */
+ case 14:
+ beGetTextAttributes(&fore, &back);
+ if (! (fore & SC_G1))
+ {
+ fore &= ~(SC_ASCII|SC_G0|SC_G1|SC_GRAPHICS);
+ fore |= SC_G1;
+ beSetTextAttributes(fore, back);
+ }
+ End += 1;
+ break;
+
+ /* SI 15 Invoke G0 character set. */
+ case 15:
+ beGetTextAttributes(&fore, &back);
+ if (! (fore & SC_G0))
+ {
+ fore &= ~(SC_ASCII|SC_G0|SC_G1|SC_GRAPHICS);
+ fore |= SC_G0;
+ beSetTextAttributes(fore, back);
+ }
+ End += 1;
+ break;
+
+ /* CAN 24 Cancel escape sequence and display checkerboard. BUGBUG - not imp'd.
+ * SUB 26 Same as CAN.
+ */
+ case 24:
+ End += 1;
+ break;
+
+ /* ESC 27 Introduce a control sequence. */
+ case 27:
+ End = ProcessEscape(Start);
+ break;
+
+ /* Print any other control character received. */
+ default:
+ {
+ char buf[4];
+ sprintf(buf,"^%c",'A' + cBuffer[Start] - 1);
+ beRawTextOut(buf, 2);
+ End += 1;
+ }
+ break;
+ }
+
+ return(End);
+}
+
+
+/* ProcessBuffer -
+ *
+ * Process the current contents of the terminal character buffer.
+ */
+static int ProcessBuffer(void)
+{
+ int Start=0,End=0;
+
+ /* Null-terminate the buffer. Why? Heck, why not? */
+
+ cBuffer[BufLen] = '\0';
+
+ /* Loop through the entire buffer. Start will be incremented
+ * to point at the start of unprocessed text in the buffer as
+ * we go.
+ */
+ while (Start < BufLen)
+ {
+ End = Start;
+
+ /* Since we null-terminated, null < 27 and we have a termination condition */
+ while ((cBuffer[End] > 27)||(cBuffer[End] == 10)||(cBuffer[End] == 13))
+ End++;
+
+ /* At this point, if Start < End, we have a string of characters which
+ * doesn't have any control sequences, and should be printed raw.
+ */
+
+ if (End > Start)
+ beRawTextOut(cBuffer+Start, End-Start);
+
+ if (End >= BufLen)
+ {
+ break;
+ }
+
+ /* At this point, 'End' points to the beginning of an escape
+ * sequence. We'll reset 'start' to be AFTER parsing the
+ * escape sequence. Note that if the escape sequence
+ * is incomplete, ProcessControl should return the
+ * same value passed in. Otherwise, it'll return the
+ * index of the first character after the valid
+ * escape sequence.
+ */
+
+ Start = ProcessControl(End);
+
+ if (Start == End)
+ {
+ /* The escape sequence was incomplete.
+ * Move the unprocessed portion of the input buffer
+ * to start at the beginning of the buffer, then
+ * return.
+ */
+
+ while (End < BufLen)
+ {
+ cBuffer[End-Start] = cBuffer[End];
+ End += 1;
+ }
+
+ BufLen = End-Start;
+ return(0);
+ }
+ }
+
+ /* If we made it this far, Start == Buflen, and so we've finished
+ * processing the buffer completely.
+ */
+ BufLen = 0;
+ cBuffer[BufLen] = '\0';
+
+ return(0);
+}
+
+
+/* vtProcessedTextOut -
+ *
+ * Output characters to terminal, passing them through the vt100 emulator.
+ * Return -1 on error
+ */
+int
+vtProcessedTextOut(char *cbuf, int count)
+{
+ /* If we have a buffer overflow, error out if we haven't already crashed. */
+
+ if ((count + BufLen) > MAXVTBUFLEN)
+ {
+ beRawTextOut("ERROR: VT-100 internal buffer overflow!",39);
+ return(-1);
+ }
+
+ /* Otherwise, add our requested information to the
+ * output buffer, and attempt to parse it.
+ */
+
+ memcpy(cBuffer + BufLen, cbuf, count);
+ BufLen += count;
+
+ return(ProcessBuffer());
+}
+
--- /dev/null
+/* vt100.h
+ *
+ * AUTHOR: John L. Miller, johnmil@cs.cmu.edu / johnmil@jprc.com
+ * DATE: 8/4/96
+ *
+ * Copyright (c) 1996 John L. Miller
+ *
+ * Full permission is granted to use, modify and distribute
+ * this code, provided:
+ * 1) This comment field is included in its entirity
+ * 2) No money is charged for any work including or based on
+ * portions of this code.
+ *
+ * If you're a nice person and find this useful, I'd appreciate a
+ * note letting me know about it. e-mail is usually what spurs me
+ * on to improve and support software I've written.
+ *
+ */
+
+
+/* This identifier should be spit back to the computer when a terminal
+ * id is requested.
+ */
+#define ANSWERBACK_MESSAGE "vt100"
+
+/* Various terminal-related modes Entries are as follows:
+ * Identification esc. ID If set, if clear
+ */
+
+ /* Keyboard action 2 Locked Unlocked */
+#define CAPS_MODE 0x00000001
+ /* Insertion 4 Insert Overwrite */
+#define INSERT_MODE 0x00000002
+ /* Send - Receive 12 Full Echo */
+#define FULLDUPLEX_MODE 0x00000004
+ /* Line feed/New line 20 New line Line feed */
+#define NEWLINE_MODE 0x00000008
+
+
+#define NUM_TERM_ATTR_MODES 9 /* We only track eight '?' escape sequences */
+
+ /* Cursor key ?1 Application Cursor */
+#define CURSORAPPL_MODE 0x00000010
+ /* ANSI/VT52 ?2 ANSI VT52 */
+#define ANSI_MODE 0x00000020
+ /* Column ?3 132 80 */
+#define COL132_MODE 0x00000040
+ /* Scrolling ?4 Smooth Jump */
+#define SMOOTHSCROLL_MODE 0x00000080
+ /* Screen ?5 Reverse Normal */
+#define REVSCREEN_MODE 0x00000100
+ /* Origin ?6 Relative Absolute */
+#define ORIGINREL_MODE 0x00000200
+ /* Wraparound ?7 Wrap Truncate */
+#define WRAP_MODE 0x00000400
+ /* Auto key repeat ?8 Repeating No repeat */
+#define REPEAT_MODE 0x00000800
+
+
+ /* Print form feed ?18 Yes No */
+#define PRINTFF_MODE 0x00001000
+ /* Print extent ?19 Full screen Scrolling region */
+#define PRINTFULLSCR_MODE 0x00002000
+ /* Keypad application 'Esc =' numeric 'Esc >' */
+#define KEYPADNUMERIC_MODE 0x00004000
+ /* default mode that we start the emulator with */
+#define DEFAULT_MODE (NEWLINE_MODE|ANSI_MODE|REPEAT_MODE)
+
+ /* This constant is VERY important - the size of the buffer for
+ * unprocessed vt-100 prints!
+ */
+#define MAXVTBUFLEN 4096
+
+ /* Constants used in place of actual row and column numbers
+ * for the cursor movement and text erasing and deleting functions.
+ */
+#define CUR_ROW -999
+#define CUR_COL -999
+#define ALL_TABS -1999
+
+#define LEFT_EDGE 0
+#define RIGHT_EDGE 12000
+#define TOP_EDGE 0
+#define BOTTOM_EDGE 12000
+
+ /* Text attribute definitions; color, font, bold. */
+#define NUM_SC_ATTRIBUTES 11
+
+#define SC_RED 0x0001
+#define SC_GREEN 0x0002
+#define SC_BLUE 0x0004
+#define SC_BOLD 0x0010
+#define SC_UL 0x0020 /* Underlined */
+#define SC_BL 0x0040 /* Blinking */
+#define SC_RV 0x0080 /* Reverse video */
+#define SC_ASCII 0x0100 /* Normal ASCII (USASCII) */
+#define SC_G0 0x0200 /* graphics set G0 */
+#define SC_G1 0x0400 /* Graphics set G1 */
+#define SC_GRAPHICS 0x0800 /* Good question */
+
+
+/* forward variable declarations */
+
+extern int termAttrMode[NUM_TERM_ATTR_MODES];
+extern int alltermAttrModes;
+
+
+/* prototypes from vt100.c */
+
+/* functions meant for use outside of the emulator */
+
+int vtputs(char *f);
+int vtprintf(char *format, ...);
+int vtInitVT100(void);
+int vtProcessedTextOut(char *cbuf, int count);
+
+
+/* Prototype for functions which MUST BE SUPPLIED BY THE BACK END!!! */
+
+/* Back-end specific initialization is performed in this function.
+ * this is gauranteed to be called before any other requests are made
+ * of the back end.
+ */
+
+/* beInitVT100Terminal() -
+ *
+ * This function is called by the VT100 emulator as soon as the
+ * front-end terminal is initialized. It's responsible for setting
+ * initial state of the terminal, and initing our many wacky variables.
+ */
+int beInitVT100Terminal();
+
+
+/* beAbsoluteCursor -
+ *
+ * Given an input row and column, move the cursor to the
+ * absolute screen coordinates requested. Note that if the
+ * display window has scrollbars, the column is adjusted
+ * to take that into account, but the row is not. This allows
+ * for large scrollback in terminal windows.
+ *
+ * ROW must be able to accept CUR_ROW, TOP_EDGE, BOTTOM_EDGE,
+ * or a row number.
+ *
+ * COLUMN must be able to accept CUR_COL, LEFT_EDGE, RIGHT_EDGE,
+ * or a column number.
+ */
+int beAbsoluteCursor(int row, int col);
+
+
+/* beOffsetCursor -
+ *
+ * Given an input row and column offset, move the cursor by that
+ * many positions. For instance, row=0 and column=-1 would move
+ * the cursor left a single column.
+ *
+ * If the cursor can't move the requested amount, results are
+ * unpredictable.
+ */
+int beOffsetCursor(int row, int column);
+
+
+/* beRestoreCursor -
+ *
+ * Saved cursor position should be stored in a static
+ * variable in the back end. This function restores the
+ * cursor to the position stored in that variable.
+ */
+int beRestoreCursor(void);
+
+
+/* beSaveCursor -
+ *
+ * The back-end should maintain a static variable with the
+ * last STORED cursor position in it. This function replaces
+ * the contents of that variable with the current cursor position.
+ * The cursor may be restored to this position by using the
+ * beRestoreCursor function.
+ */
+int beSaveCursor(void);
+
+
+/* beGetTextAttributes -
+ *
+ * given a pointer to 'fore'ground and 'back'ground ints,
+ * fill them with a device-independant description of the
+ * current foreground and background colors, as well as any
+ * font information in the foreground variable.
+ */
+int beGetTextAttributes(int *fore, int *back);
+
+
+/* beSetTextAttributes -
+ *
+ * Given a foreground and a background device independant (SC) color and font
+ * specification, apply these to the display, and save the state in the
+ * static screen variables.
+ *
+ * Note that many font-specific constants (bold/underline/reverse, G0/G1/ASCII)
+ * are stored ONLY in the foreground specification.
+ */
+int beSetTextAttributes(int fore, int back);
+
+
+/* beRawTextOut-
+ *
+ * The name of this function is misleading. Given a pointer to
+ * ascii text and a count of bytes to print, print them to the
+ * display device. If wrapping is enabled, wrap text. If there is a
+ * scrolling region set and the cursor is in it,
+ * scroll only within that region. 'beRawTextOut' means that it's guaranteed
+ * not to have control sequences within the text.
+ */
+int beRawTextOut(char *text, int len);
+
+
+/* beEraseText -
+ *
+ * Given a 'from' and a 'to' position in display coordinates,
+ * this function will fill in all characters between the two
+ * (inclusive) with spaces. Note that the coordinates do NOT
+ * specify a rectangle. erasing from (1,1) to (2,2) erases
+ * all of the first row, and the first two characters of the
+ * second.
+ *
+ * Note that this routine must be able to handle TOP_EDGE,
+ * BOTTOM_EDGE, LEFT_EDGE, RIGHT_EDGE, CUR_ROW, and CUR_COL
+ * in the appropriate parameters.
+ */
+int beEraseText(int rowFrom, int colFrom, int rowTo, int colTo);
+
+
+/* beDeleteText -
+ *
+ * Given a screen cursor 'from' and 'to' position, this function
+ * will delete all text between the two. Text will be scrolled
+ * up as appropriate to fill the deleted space. Note that, as in
+ * beEraseText, the two coordinates don't specify a rectangle, but
+ * rather a starting position and ending position. In other words,
+ * deleting from (1,1) to (2,2) should move the text from (2,3) to the
+ * end of the second row to (1,1), move line 3 up to line 2, and so on.
+ *
+ * This function must be able to process TOP_EDGE, BOTTOM_EDGE, LEFT_EDGE,
+ * RIGHT_EDGE, CUR_ROW, and CUR_COL specifications in the appropriate
+ * variables as well as regular row and column specifications.
+ */
+int beDeleteText(int rowFrom, int colFrom, int rowTo, int colTo);
+
+
+/* beInsertRow -
+ *
+ * Given a row number or CUR_ROW, TOP_EDGE or BOTTOM_EDGE as an input,
+ * this function will scroll all text from the current row down down by one,
+ * and create a blank row under the cursor.
+ */
+int beInsertRow(int row);
+
+
+/* beTransmitText -
+ *
+ * Given a pointer to text and byte count, this routine should transmit data
+ * to whatever host made the request it's responding to. Typically this routin
+ * should transmit data as though the user had typed it in.
+ */
+int beTransmitText(char *text, int len);
+
+
+/* beAdvanceToTab -
+ *
+ * This routine will destructively advance the cursor to the
+ * next set tab, or to the end of the line if there are no
+ * more tabs to the right of the cursor.
+ */
+
+int beAdvanceToTab(void);
+
+
+/* beClearTab -
+ *
+ * This function accepts a constant, and will try to clear tabs
+ * appropriately. Its argument is either
+ * ALL_TABS, meaning all tabs should be removed
+ * CUR_COL, meaning the tab in the current column should be wiped, or
+ * a column value, meaning if there's a tab there it should be wiped.
+ *
+ */
+int beClearTab(int col);
+
+
+/* beSetScrollingRows -
+ *
+ * Given a pair of row numbers, this routine will set the scrolling
+ * rows to those values. Note that this routine will accept
+ * TOP_ROW and BOTTOM_ROW as values, meaning that scrolling should
+ * be enabled for the entire display, regardless of resizing.
+ */
+int beSetScrollingRows(int fromRow, int toRow);
+
+
+/* beRingBell -
+ *
+ * Ring the system bell once.
+ */
+int beRingBell(void);
+
+
+/* beGetTermMode -
+ *
+ * Return the value of conTermMode, which is the terminal settings which
+ * can be queried/set by <esc>[?#h/l.
+ */
+int beGetTermMode();
+
+
+/* beSetTermMode -
+ *
+ * Set the terminal as requested, assuming we can. Right now we only handle a
+ * couple of the possible flags, but we store many of the others.
+ */
+int beSetTermMode(int newMode);
--- /dev/null
+/* $Id: aio.h,v 1.4 2002/10/29 04:45:06 rex Exp $
+ */
+/*
+ * aio.h
+ *
+ * asynchronous input and output (REALTIME). Conforming to the Single UNIX(r)
+ * Specification Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __AIO_H_INCLUDED__
+#define __AIO_H_INCLUDED__
+
+/* INCLUDES */
+#include <fcntl.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <time.h>
+
+/* OBJECTS */
+
+/* TYPES */
+typedef struct _tag_aiocb
+{
+ int aio_fildes; /* file descriptor */
+ off_t aio_offset; /* file offset */
+ volatile void* aio_buf; /* location of buffer */
+ size_t aio_nbytes; /* length of transfer */
+ int aio_reqprio; /* request priority offset */
+ struct sigevent aio_sigevent; /* signal number and value */
+ int aio_lio_opcode; /* operation to be performed */
+} aiocb;
+
+/* CONSTANTS */
+#define AIO_CANCELED 0
+#define AIO_NOTCANCELED 1
+#define AIO_ALLDONE 2
+
+#define LIO_WAIT 0
+#define LIO_NOWAIT 1
+#define LIO_READ 2
+#define LIO_WRITE 3
+#define LIO_NOP 4
+
+/* PROTOTYPES */
+int aio_cancel(int, struct aiocb *);
+int aio_error(const struct aiocb *);
+int aio_fsync(int, struct aiocb *);
+int aio_read(struct aiocb *);
+ssize_t aio_return(struct aiocb *);
+int aio_suspend(const struct aiocb *const[], int, const struct timespec *);
+int aio_write(struct aiocb *);
+int lio_listio(int, struct aiocb *const[], int, struct sigevent *);
+
+/* MACROS */
+
+#endif /* __AIO_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: inet.h,v 1.4 2002/10/29 04:45:06 rex Exp $
+ */
+/*
+ * arpa/inet.h
+ *
+ * definitions for internet operations. Conforming to the Single UNIX(r)
+ * Specification Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __ARPA_INET_H_INCLUDED__
+#define __ARPA_INET_H_INCLUDED__
+
+/* INCLUDES */
+#include <netinet/in.h>
+#include <inttypes.h>
+
+/* OBJECTS */
+
+/* TYPES */
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+uint32_t htonl(uint32_t hostlong);
+uint16_t htons(uint16_t hostshort);
+uint32_t ntohl(uint32_t netlong);
+uint16_t ntohs(uint16_t netshort);
+
+in_addr_t inet_addr(const char *cp);
+in_addr_t inet_lnaof(struct in_addr in);
+struct in_addr inet_makeaddr(in_addr_t net, in_addr_t lna);
+in_addr_t inet_netof(struct in_addr in);
+in_addr_t inet_network(const char *cp);
+char *inet_ntoa(struct in_addr in);
+
+/* MACROS */
+
+#endif /* __ARPA_INET_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: assert.h,v 1.5 2002/10/29 04:45:08 rex Exp $
+ */
+/*
+ * assert.h
+ *
+ * verify program assertion. Conforming to the Single UNIX(r) Specification
+ * Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __ASSERT_H_INCLUDED__
+#define __ASSERT_H_INCLUDED__
+
+/* INCLUDES */
+
+/* OBJECTS */
+
+/* TYPES */
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+
+/* MACROS */
+#ifdef NDEBUG
+#define assert(IGNORE) ((void) 0)
+#else /* !NDEBUG */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define assert(EXPRESSION) \
+ if(!(EXPRESSION)) \
+ { \
+ fputs("__FILE__, line __LINE__: assertion \"EXPRESSION\" failed\n", stderr); \
+ abort(); \
+ }
+
+#endif /* NDEBUG */
+
+#endif /* __ASSERT_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: cpio.h,v 1.4 2002/10/29 04:45:08 rex Exp $
+ */
+/*
+ * cpio.h
+ *
+ * cpio archive values. Conforming to the Single UNIX(r) Specification
+ * Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __CPIO_H_INCLUDED__
+#define __CPIO_H_INCLUDED__
+
+/* INCLUDES */
+
+/* TYPES */
+
+/* CONSTANTS */
+#define C_IRUSR (0000400) /* read by owner */
+#define C_IWUSR (0000200) /* write by owner */
+#define C_IXUSR (0000100) /* execute by owner */
+#define C_IRGRP (0000040) /* read by group */
+#define C_IWGRP (0000020) /* write by group */
+#define C_IXGRP (0000010) /* execute by group */
+#define C_IROTH (0000004) /* read by others */
+#define C_IWOTH (0000002) /* write by others */
+#define C_IXOTH (0000001) /* execute by others */
+#define C_ISUID (0004000) /* set user ID */
+#define C_ISGID (0002000) /* set group ID */
+#define C_ISVTX (0001000) /* on directories, restricted deletion flag */
+#define C_ISDIR (0040000) /* directory */
+#define C_ISFIFO (0010000) /* FIFO */
+#define C_ISREG (0100000) /* regular file */
+#define C_ISBLK (0060000) /* block special */
+#define C_ISCHR (0020000) /* character special */
+#define C_ISCTG (0110000) /* reserved */
+#define C_ISLNK (0120000) /* symbolic link */
+#define C_ISSOCK (0140000) /* socket */
+
+#define MAGIC "070707"
+
+/* PROTOTYPES */
+
+/* MACROS */
+
+#endif /* __CPIO_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: ctype.h,v 1.4 2002/10/29 04:45:08 rex Exp $
+ */
+/*
+ * ctype.h
+ *
+ * character types. Conforming to the Single UNIX(r) Specification
+ * Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __CTYPE_H_INCLUDED__
+#define __CTYPE_H_INCLUDED__
+
+/* INCLUDES */
+
+/* OBJECTS */
+
+/* TYPES */
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+int isalnum(int);
+int isalpha(int);
+int isascii(int);
+int iscntrl(int);
+int isdigit(int);
+int isgraph(int);
+int islower(int);
+int isprint(int);
+int ispunct(int);
+int isspace(int);
+int isupper(int);
+int isxdigit(int);
+int toascii(int);
+int tolower(int);
+int toupper(int);
+
+/* MACROS */
+/* FIXME: the standard isn't clear about these */
+#define _toupper(c) (toupper(c))
+#define _tolower(c) (tolower(c))
+
+#endif /* __CTYPE_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: dirent.h,v 1.6 2002/10/29 04:45:08 rex Exp $
+ */
+/*
+ * dirent.h
+ *
+ * format of directory entries. Conforming to the Single UNIX(r)
+ * Specification Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __DIRENT_H_INCLUDED__
+#define __DIRENT_H_INCLUDED__
+
+/* INCLUDES */
+#include <sys/types.h>
+#include <stddef.h>
+#include <limits.h>
+
+/* TYPES */
+typedef void DIR;
+
+#define NAME_MAX (255)
+
+struct dirent
+{
+ ino_t d_ino; /* file serial number */
+ char * d_name /* [NAME_MAX + 1] */; /* name of entry */
+};
+
+/* for Unicode filenames */
+struct _Wdirent
+{
+ ino_t d_ino; /* file serial number */
+ wchar_t * d_name/* [NAME_MAX + 1] */; /* name of entry */
+};
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+int closedir(DIR *);
+DIR *opendir(const char *);
+struct dirent *readdir(DIR *);
+int readdir_r(DIR *, struct dirent *, struct dirent **);
+void rewinddir(DIR *);
+void seekdir(DIR *, long int);
+long int telldir(DIR *);
+
+/* for Unicode filenames */
+DIR *_Wopendir(const wchar_t *);
+struct _Wdirent *_Wreaddir(DIR *);
+int _Wreaddir_r(DIR *, struct _Wdirent *, struct _Wdirent **);
+
+
+/* MACROS */
+
+#endif /* __DIRENT_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: dlfcn.h,v 1.4 2002/10/29 04:45:08 rex Exp $
+ */
+/*
+ * dlfcn.h
+ *
+ * dynamic linking. Conforming to the Single UNIX(r) Specification
+ * Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __DLFCN_H_INCLUDED__
+#define __DLFCN_H_INCLUDED__
+
+/* INCLUDES */
+
+/* TYPES */
+
+/* CONSTANTS */
+#define RTLD_LAZY (0x00000000) /* Relocations are performed at an \
+ implementation-dependent time. */
+#define RTLD_NOW (0x00000001) /* Relocations are performed when \
+ the object is loaded. */
+
+#define RTLD_GLOBAL (0x00000010) /* All symbols are available for \
+ relocation processing of other \
+ modules. */
+#define RTLD_LOCAL (0x00000020) /* All symbols are not made available \
+ for relocation processing by other \
+ modules. */
+
+#define RTLD_NEXT ((void *)(-1))
+
+/* PROTOTYPES */
+void *dlopen(const char *, int);
+void *dlsym(void *, const char *);
+int dlclose(void *);
+char *dlerror(void);
+
+/* MACROS */
+
+#endif /* __DLFCN_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: errno.h,v 1.5 2002/10/29 04:45:08 rex Exp $
+ */
+/*
+ * errno.h
+ *
+ * system error numbers. Conforming to the Single UNIX(r) Specification
+ * Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __ERRNO_H_INCLUDED__
+#define __ERRNO_H_INCLUDED__
+
+/* INCLUDES */
+
+/* OBJECTS */
+
+/* TYPES */
+
+/* CONSTANTS */
+/* errors from 0 to 42 are the same as in Microsoft POSIX */
+#define EZERO ( 0) /* No error. */
+#define EPERM ( 1) /* Operation not permitted. */
+#define ENOENT ( 2) /* No such file or directory. */
+#define ESRCH ( 3) /* No such process. */
+#define EINTR ( 4) /* Interrupted function. */
+#define EIO ( 5) /* I/O error. */
+#define ENXIO ( 6) /* No such device or address. */
+#define E2BIG ( 7) /* Argument list too long. */
+#define ENOEXEC ( 8) /* Executable file format error. */
+#define EBADF ( 9) /* Bad file descriptor. */
+#define ECHILD ( 10) /* No child processes. */
+#define EAGAIN ( 11) /* Resource unavailable, try again */
+#define ENOMEM ( 12) /* Not enough space. */
+#define EACCES ( 13) /* Permission denied. */
+#define EFAULT ( 14) /* Bad address. */
+#define ENOTBLK ( 15) /* Reserved. */
+#define EBUSY ( 16) /* Device or resource busy. */
+#define EEXIST ( 17) /* File exists. */
+#define EXDEV ( 18) /* Cross-device link. */
+#define ENODEV ( 19) /* No such device. */
+#define ENOTDIR ( 20) /* Not a directory. */
+#define EISDIR ( 21) /* Is a directory. */
+#define EINVAL ( 22) /* Invalid argument. */
+#define ENFILE ( 23) /* Too many files open in system. */
+#define EMFILE ( 24) /* Too many open files. */
+#define ENOTTY ( 25) /* Inappropriate I/O control operation. */
+#define ETXTBSY ( 26) /* Text file busy. */
+#define EFBIG ( 27) /* File too large. */
+#define ENOSPC ( 28) /* No space left on device. */
+#define ESPIPE ( 29) /* Invalid seek. */
+#define EROFS ( 30) /* Read-only file system. */
+#define EMLINK ( 31) /* Too many links. */
+#define EPIPE ( 32) /* Broken pipe. */
+#define EDOM ( 33) /* Mathematics argument out of domain of function. */
+#define ERANGE ( 34) /* Result too large. */
+#define EUCLEAN ( 35) /* Reserved. */
+#define EDEADLK ( 36) /* Resource deadlock would occur. */
+#define UNKNOWN ( 37) /* Reserved. */
+#define ENAMETOOLONG ( 38) /* Filename too long. */
+#define ENOLCK ( 39) /* No locks available. */
+#define ENOSYS ( 40) /* Function not supported. */
+#define ENOTEMPTY ( 41) /* Directory not empty. */
+#define EILSEQ ( 42) /* Illegal byte sequence. */
+/* from this point, constants are in no particular order */
+#define ENODATA ( 44) /* No message is available on the STREAM head read queue. */
+#define ENOSR ( 45) /* No STREAM resources. */
+#define ENOSTR ( 46) /* Not a STREAM. */
+#define ECANCELED ( 47) /* Operation canceled. */
+#define ENOBUFS ( 48) /* No buffer space available. */
+#define EOVERFLOW ( 49) /* Value too large to be stored in data type. */
+#define ENOTSUP ( 50) /* Not supported. */
+#define EADDRINUSE ( 51) /* Address in use. */
+#define EADDRNOTAVAIL ( 52) /* Address not available. */
+#define EAFNOSUPPORT ( 53) /* Address family not supported. */
+#define ECONNABORTED ( 54) /* Connection aborted. */
+#define ECONNREFUSED ( 55) /* Connection refused. */
+#define ECONNRESET ( 56) /* Connection reset. */
+#define EALREADY ( 57) /* Connection already in progress. */
+#define EDESTADDRREQ ( 58) /* Destination address required. */
+#define EHOSTUNREACH ( 59) /* Host is unreachable. */
+#define EISCONN ( 60) /* Socket is connected. */
+#define ENETDOWN ( 61) /* Network is down. */
+#define ENETUNREACH ( 62) /* Network unreachable. */
+#define ENOPROTOOPT ( 63) /* Protocol not available. */
+#define ENOTCONN ( 64) /* The socket is not connected. */
+#define ENOTSOCK ( 65) /* Not a socket. */
+#define EPROTO ( 66) /* Protocol error. */
+#define EPROTONOSUPPORT ( 67) /* Protocol not supported. */
+#define EPROTOTYPE ( 68) /* Socket type not supported. */
+#define EOPNOTSUPP ( 69) /* Operation not supported on socket. */
+#define ETIMEDOUT ( 70) /* Connection timed out. */
+#define EINPROGRESS ( 71) /* Operation in progress. */
+#define EBADMSG ( 72) /* Bad message. */
+#define EMSGSIZE ( 73) /* Message too large. */
+#define ENOMSG ( 74) /* No message of the desired type. */
+#define EDQUOT ( 75) /* Reserved. */
+#define EIDRM ( 76) /* Identifier removed. */
+#define ELOOP ( 77) /* Too many levels of symbolic links. */
+#define EMULTIHOP ( 78) /* Reserved. */
+#define ENOLINK ( 79) /* Reserved. */
+#define ESTALE ( 80) /* Reserved. */
+#define ETIME ( 81) /* Streamioctl() timeout. */
+#define EWOULDBLOCK ( 82) /* Operation would block */
+
+#define EDEADLOCK EDEADLK /* Resource deadlock avoided */
+
+/* PROTOTYPES */
+int * __PdxGetThreadErrNum(void); /* returns a pointer to the current thread's errno */
+
+/* MACROS */
+#define errno (*__PdxGetThreadErrNum())
+
+#endif /* __ERRNO_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: fcntl.h,v 1.6 2002/10/29 04:45:08 rex Exp $
+ */
+/*
+ * fcntl.h
+ *
+ * file control options. Conforming to the Single UNIX(r) Specification
+ * Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __FCNTL_H_INCLUDED__
+#define __FCNTL_H_INCLUDED__
+
+/* INCLUDES */
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+/* OBJECTS */
+
+/* TYPES */
+/*
+ the structure flock describes a file lock
+ */
+struct flock
+{
+ short l_type; /* type of lock; F_RDLCK, F_WRLCK, F_UNLCK */
+ short l_whence; /* flag for starting offset */
+ off_t l_start; /* relative offset in bytes */
+ off_t l_len; /* size; if 0 then until EOF */
+ pid_t l_pid; /* process ID of the process holding the lock;
+ returned with F_GETLK */
+};
+
+/* CONSTANTS */
+/*
+ values for cmd used by fcntl()
+ */
+enum __fcntl_cmd
+{
+ F_DUPFD, /* duplicate file descriptor */
+ F_GETFD, /* get file descriptor flags */
+ F_GETLK, /* get record locking information */
+ F_SETFD, /* set file descriptor flags */
+ F_GETFL, /* get file status flags and file access modes */
+ F_SETFL, /* set file status flags */
+ F_SETLK, /* set record locking information */
+ F_SETLKW, /* set record locking information; wait if blocked */
+/* ReactOS-specific */
+ F_NEWFD, /* create new file descriptor */
+ F_DELFD, /* delete file descriptor */
+ F_GETALL, /* get a copy of the internal descriptor object */
+ F_SETALL, /* initialize internal descriptor object */
+ F_GETXP, /* get file descriptor extra data pointer */
+ F_SETXP, /* set file descriptor extra data pointer */
+ F_GETXS, /* get file descriptor extra data size */
+ F_SETXS, /* set file descriptor extra data size */
+ F_GETFH, /* get file handle */
+ F_SETFH /* set file handle */
+};
+
+/*
+ file descriptor flags used for fcntl()
+ */
+/* Close the file descriptor upon execution of an exec family function. */
+#define FD_CLOEXEC (0x00000001)
+
+/*
+ values for l_type used for record locking with fcntl()
+ */
+/* Shared or read lock. */
+#define F_RDLCK (1)
+/* Unlock. */
+#define F_UNLCK (2)
+/* Exclusive or write lock. */
+#define F_WRLCK (3)
+
+/*
+ file flags used for open()
+ */
+/* Create file if it does not exist. */
+#define O_CREAT (0x00000100)
+/* Truncate flag. */
+#define O_TRUNC (0x00000200)
+/* Exclusive use flag. */
+#define O_EXCL (0x00000400)
+/* Do not assign controlling terminal. */
+#define O_NOCTTY (0x00000800)
+/* ReactOS-specific */
+/* File must be a directory */
+#define _O_DIRFILE (0x00100000)
+
+/*
+ file status flags used for open() and fcntl()
+ */
+/* Set append mode. */
+#define O_APPEND (0x00000008)
+/* Non-blocking mode. */
+#define O_NONBLOCK (0x00001000)
+/* Write according to synchronised I/O data integrity completion. */
+#define O_DSYNC (0x00002000)
+/* Synchronised read I/O operations. */
+#define O_RSYNC (0x00004000)
+/* Write according to synchronised I/O file integrity completion. */
+#define O_SYNC (0x00008000)
+
+/*
+ file access modes used for open() and fcntl()
+ */
+/* Open for reading only. */
+#define O_RDONLY (0x00000000)
+/* Open for writing only. */
+#define O_WRONLY (0x00000001)
+/* Open for reading and writing. */
+#define O_RDWR (0x00000002)
+
+/*
+ mask for use with file access modes
+ */
+#define O_ACCMODE (0x00000007)
+
+/* PROTOTYPES */
+int creat(const char *, mode_t);
+int fcntl(int, int, ...);
+int open(const char *, int, ...);
+
+int _Wcreat(const wchar_t *, mode_t);
+int _Wopen(const wchar_t *, int, ...);
+
+/* MACROS */
+
+#endif /* __FCNTL_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: fmtmsg.h,v 1.4 2002/10/29 04:45:08 rex Exp $
+ */
+/*
+ * fmtmsg.h
+ *
+ * message display structures. Conforming to the Single UNIX(r)
+ * Specification Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __FMTMSG_H_INCLUDED__
+#define __FMTMSG_H_INCLUDED__
+
+/* INCLUDES */
+
+/* OBJECTS */
+
+/* TYPES */
+
+/* CONSTANTS */
+/* Major Classifications */
+/* NOTE: these are unique values, not flags. Their bits can overlap, but
+ cannot overlap with those of other categories */
+#define MM_HARD (0x00000001) /* Source of the condition is hardware. */
+#define MM_SOFT (0x00000002) /* Source of the condition is software. */
+#define MM_FIRM (0x00000003) /* Source of the condition is firmware. */
+
+/* Message Source Subclassifications */
+/* NOTE: these are unique values, not flags. Their bits can overlap, but
+ cannot overlap with those of other categories */
+#define MM_APPL (0x00000010) /* Condition detected by application. */
+#define MM_UTIL (0x00000020) /* Condition detected by utility. */
+#define MM_OPSYS (0x00000030) /* Condition detected by operating system. */
+
+/* Status Subclassifications */
+/* NOTE: these are unique values, not flags. Their bits can overlap, but
+ cannot overlap with those of other categories */
+#define MM_RECOVER (0x00000100) /* Recoverable error. */
+#define MM_NRECOV (0x00000200) /* Non-recoverable error. */
+
+/* Display Subclassifications */
+/* NOTE: these, unlike other classification constants, are flags. Their
+ bits must be distinct */
+#define MM_PRINT (0x00001000) /* Display message on standard error. */
+#define MM_CONSOLE (0x00002000) /* Display message on system console. */
+
+/* Identifiers for the levels of severity */
+#define MM_NOSEV (0) /* No severity level provided for the message. */
+#define MM_INFO (1) /* Informative message. */
+#define MM_WARNING (2) /* Application has detected unusual non-error \
+ condition. */
+#define MM_ERROR (3) /* Application has encountered a non-fatal fault. */
+#define MM_HALT (4) /* Error causing application to halt. */
+
+/* Null values and identifiers */
+#define MM_NULLLBL ((char *)0) /* Null label */
+#define MM_NULLSEV (0) /* Null severity */
+#define MM_NULLMC (0L) /* Null class */
+#define MM_NULLTXT ((char *)0) /* Null text */
+#define MM_NULLACT ((char *)0) /* Null action */
+#define MM_NULLTAG ((char *)0) /* Null tag */
+
+/* Return values */
+#define MM_OK ( 0) /* The function succeeded. */
+#define MM_NOTOK (-1) /* The function failed completely. */
+#define MM_NOMSG (-2) /* The function was unable to generate a message on \
+ standard error, but otherwise succeeded. */
+#define MM_NOCON (-3) /* The function was unable to generate a console \
+ message, but otherwise succeeded. */
+
+/* PROTOTYPES */
+int fmtmsg(long, const char*, int, const char*, const char*, const char*);
+
+/* MACROS */
+
+#endif /* __FMTMSG_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: fnmatch.h,v 1.4 2002/10/29 04:45:08 rex Exp $
+ */
+/*
+ * fnmatch.h
+ *
+ * filename-matching types. Conforming to the Single UNIX(r)
+ * Specification Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __FNMATCH_H_INCLUDED__
+#define __FNMATCH_H_INCLUDED__
+
+/* INCLUDES */
+#ifdef __PSXDLL__
+
+/* headers for internal usage by psxdll.dll and ReactOS */
+
+#else /* ! __PSXDLL__ */
+
+/* standard POSIX headers */
+
+#endif
+
+/* OBJECTS */
+
+/* TYPES */
+
+/* CONSTANTS */
+/* Flags */
+#define FNM_PATHNAME (0x00000001) /* Slash in string only matches slash \
+ in pattern. */
+#define FNM_PERIOD (0x00000002) /* Leading period in string must be \
+ exactly matched by period in \
+ pattern. */
+#define FNM_NOESCAPE (0x00000004) /* Disable backslash escaping. */
+
+/* Return values */
+#define FNM_NOMATCH (1) /* The string does not match the specified \
+ pattern. */
+#define FNM_NOSYS (2) /* The implementation does not support this \
+ function. */
+
+/* PROTOTYPES */
+int fnmatch(const char *, const char *, int);
+
+/* MACROS */
+
+#endif /* __FNMATCH_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: ftw.h,v 1.4 2002/10/29 04:45:08 rex Exp $
+ */
+/*
+ * ftw.h
+ *
+ * file tree traversal. Conforming to the Single UNIX(r) Specification
+ * Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __FTW_H_INCLUDED__
+#define __FTW_H_INCLUDED__
+
+/* INCLUDES */
+
+/* OBJECTS */
+
+/* TYPES */
+struct FTW
+{
+ int base;
+ int level;
+};
+
+/* CONSTANTS */
+/* Values of the third argument to the application-supplied function
+ that is passed as the second argument to ftw() and nftw() */
+#define FTW_F (1) /* File. */
+#define FTW_D (2) /* Directory. */
+#define FTW_DNR (3) /* Directory without read permission. */
+#define FTW_DP (4) /* Directory with subdirectories visited. */
+#define FTW_NS (5) /* Unknown type, stat() failed. */
+#define FTW_SL (6) /* Symbolic link. */
+#define FTW_SLN (7) /* Symbolic link that names a non-existent file. */
+
+/* Values of the fourth argument to nftw() */
+#define FTW_PHYS (0x00000001) /* Physical walk, does not follow symbolic \
+ links. Otherwise, nftw() will follow \
+ links but will not walk down any path \
+ that crosses itself. */
+#define FTW_MOUNT (0x00000002) /* The walk will not cross a mount point. */
+#define FTW_DEPTH (0x00000004) /* All subdirectories will be visited before \
+ the directory itself. */
+#define FTW_CHDIR (0x00000008) /* The walk will change to each directory \
+ before reading it. */
+
+/* PROTOTYPES */
+int ftw(const char *,
+ int (*)(const char *, const struct stat *, int), int);
+int nftw(const char *, int (*)
+ (const char *, const struct stat *, int, struct FTW*),
+ int, int);
+
+/* MACROS */
+
+#endif /* __FTW_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: glob.h,v 1.4 2002/10/29 04:45:10 rex Exp $
+ */
+/*
+ * glob.h
+ *
+ * pathname pattern-matching types. Conforming to the Single UNIX(r)
+ * Specification Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __GLOB_H_INCLUDED__
+#define __GLOB_H_INCLUDED__
+
+/* INCLUDES */
+
+/* OBJECTS */
+
+/* TYPES */
+typedef struct __tagglob_t
+{
+ size_t gl_pathc; /* count of paths matched by pattern */
+ char **gl_pathv; /* pointer to a list of matched pathnames */
+ size_t gl_offs; /* slots to reserve at the beginning of gl_pathv */
+} glob_t;
+
+/* CONSTANTS */
+/* Values for the flags argument */
+#define GLOB_APPEND (0x00000001) /* Append generated pathnames to \
+ those previously obtained. */
+#define GLOB_DOOFFS (0x00000002) /* Specify how many null pointers to \
+ add to the beginning of */
+#define GLOB_ERR (0x00000004) /* Cause glob() to return on error. */
+#define GLOB_MARK (0x00000008) /* Each pathname that is a directory \
+ that matches pattern has a slash \
+ appended. */
+#define GLOB_NOCHECK (0x00000010) /* If pattern does not match any pathname, \
+ then return a list consisting of only \
+ pattern. */
+#define GLOB_NOESCAPE (0x00000020) /* Disable backslash escaping. */
+#define GLOB_NOSORT (0x00000040) /* Do not sort the pathnames returned. */
+
+/* Error return values */
+#define GLOB_ABORTED (-1) /* The scan was stopped because GLOB_ERR was set \
+ or errfunc returned non-zero. */
+#define GLOB_NOMATCH (-2) /* The pattern does not match any existing pathname, \
+ and GLOB_NOCHECK was not set in flags. */
+#define GLOB_NOSPACE (-3) /* An attempt to allocate memory failed. */
+#define GLOB_NOSYS (-4) /* The implementation does not support this function. */
+
+/* PROTOTYPES */
+int glob(const char *, int, int (*)(const char *, int), glob_t *);
+void globfree (glob_t *);
+
+/* MACROS */
+
+#endif /* __GLOB_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: grp.h,v 1.4 2002/10/29 04:45:10 rex Exp $
+ */
+/*
+ * grp.h
+ *
+ * group structure. Conforming to the Single UNIX(r) Specification
+ * Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __GRP_H_INCLUDED__
+#define __GRP_H_INCLUDED__
+
+/* INCLUDES */
+
+/* OBJECTS */
+
+/* TYPES */
+struct group
+{
+ char *gr_name; /* the name of the group */
+ gid_t gr_gid; /* numerical group ID */
+ char **gr_mem; /* pointer to a null-terminated array of character
+ pointers to member names */
+};
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+struct group *getgrgid(gid_t);
+struct group *getgrnam(const char *);
+int getgrgid_r(gid_t, struct group *, char *,
+ size_t, struct group **);
+int getgrnam_r(const char *, struct group *, char *,
+ size_t , struct group **);
+struct group *getgrent(void);
+void endgrent(void);
+void setgrent(void);
+
+/* MACROS */
+
+#endif /* __GRP_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: iconv.h,v 1.4 2002/10/29 04:45:10 rex Exp $
+ */
+/*
+ * iconv.h
+ *
+ * codeset conversion facility. Conforming to the Single UNIX(r)
+ * Specification Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __ICONV_H_INCLUDED__
+#define __ICONV_H_INCLUDED__
+
+/* INCLUDES */
+
+/* OBJECTS */
+
+/* TYPES */
+typedef (void *) iconv_t;
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+iconv_t iconv_open(const char *, const char *);
+size_t iconv(iconv_t, char **, size_t *, char **, size_t *);
+int iconv_close(iconv_t);
+
+/* MACROS */
+
+#endif /* __ICONV_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: inttypes.h,v 1.4 2002/10/29 04:45:10 rex Exp $
+ */
+/*
+ * inttypes.h
+ *
+ * fixed size integral types. Conforming to the Single UNIX(r) Specification
+ * Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __INTTYPES_H_INCLUDED__
+#define __INTTYPES_H_INCLUDED__
+
+/* INCLUDES */
+
+/* OBJECTS */
+
+/* TYPES */
+/* signed */
+typedef signed char int8_t; /* 8-bit signed integral type. */
+typedef signed short int int16_t; /* 16-bit signed integral type. */
+typedef signed long int int32_t; /* 32-bit signed integral type. */
+typedef signed long long int64_t; /* 64-bit signed integral type. */
+
+/* unsigned */
+typedef unsigned char uint8_t; /* 8-bit unsigned integral type. */
+typedef unsigned short int uint16_t; /* 16-bit unsigned integral type. */
+typedef unsigned long int uint32_t; /* 32-bit unsigned integral type. */
+typedef unsigned long long uint64_t; /* 64-bit unsigned integral type. */
+
+/* pointer-sized */
+typedef signed long int intptr_t; /* Signed integral type large enough
+ to hold any pointer. */
+typedef unsigned long int uintptr_t; /* Unsigned integral type large
+ enough to hold any pointer. */
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+
+/* MACROS */
+
+#endif /* __INTTYPES_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: iso646.h,v 1.4 2002/10/29 04:45:10 rex Exp $
+ */
+/*
+ * iso646.h
+ *
+ * alternative spellings. Conforming to the Single UNIX(r) Specification
+ * Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __ISO646_H_INCLUDED__
+#define __ISO646_H_INCLUDED__
+
+/* INCLUDES */
+
+/* OBJECTS */
+
+/* TYPES */
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+
+/* MACROS */
+#define and &&
+#define and_eq &=
+#define bitand &
+#define bitor |
+#define compl ~
+#define not !
+#define not_eq !=
+#define or ||
+#define or_eq |=
+#define xor ^
+#define xor_eq ^=
+
+#endif /* __ISO646_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: libgen.h,v 1.4 2002/10/29 04:45:10 rex Exp $
+ */
+/*
+ * libgen.h
+ *
+ * definitions for pattern matching functions. Conforming to the Single
+ * UNIX(r) Specification Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __LIBGEN_H_INCLUDED__
+#define __LIBGEN_H_INCLUDED__
+
+/* INCLUDES */
+#include <stddef.h>
+
+/* OBJECTS */
+extern char *__loc1; /* LEGACY */
+
+/* TYPES */
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+char *basename(char *);
+char *dirname(char *);
+char *regcmp(const char *, ...); /* LEGACY */
+char *regex(const char *, const char *, ...); /* LEGACY */
+
+wchar_t *_Wbasename(wchar_t *);
+wchar_t *_Wdirname(wchar_t *);
+
+/* MACROS */
+
+#endif /* __LIBGEN_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: limits.h,v 1.5 2002/10/29 04:45:10 rex Exp $
+ */
+/*
+ * limits.h
+ *
+ * implementation-dependent constants. Conforming to the Single UNIX(r)
+ * Specification Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __LIMITS_H_INCLUDED__
+#define __LIMITS_H_INCLUDED__
+
+/* INCLUDES */
+
+/* OBJECTS */
+
+/* TYPES */
+
+/* CONSTANTS */
+/* TODO */
+#define OPEN_MAX (256)
+#define NAME_MAX (255)
+#define ARG_MAX (255)
+#define PATH_MAX (32768)
+
+/* PROTOTYPES */
+
+/* MACROS */
+
+#endif /* __LIMITS_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: math.h,v 1.4 2002/10/29 04:45:10 rex Exp $
+ */
+/*
+ * math.h
+ *
+ * mathematical declarations. Conforming to the Single UNIX(r)
+ * Specification Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __MATH_H_INCLUDED__
+#define __MATH_H_INCLUDED__
+
+/* INCLUDES */
+#ifdef __PSXDLL__
+
+/* headers for internal usage by psxdll.dll and ReactOS */
+
+#else /* ! __PSXDLL__ */
+
+/* standard POSIX headers */
+
+#endif
+
+/* OBJECTS */
+
+/* TYPES */
+
+/* CONSTANTS */
+#define M_E ((double) 2.7182818285) /* Value of e */
+#define M_LOG2E ((double) 1.4426950419) /* Value of log2(e) */
+#define M_LOG10E ((double) 0.4342944819) /* Value of log10(e) */
+#define M_LN2 ((double)-0.6931471806) /* Value of loge2 */
+#define M_LN10 ((double) 2.3025850929) /* Value of loge10 */
+#define M_PI ((double) 3.1415926536) /* Value of Pi */
+#define M_PI_2 ((double) 1.5707963268) /* Value of Pi/2 */
+#define M_PI_4 ((double) 0.7853981634) /* Value of Pi/4 */
+#define M_1_PI ((double) 0.3183098862) /* Value of 1/Pi */
+#define M_2_PI ((double) 0.6366197724) /* Value of 2/Pi */
+#define M_2_SQRTPI ((double) 1.1283791671) /* Value of 2/Sqrt(Pi) */
+#define M_SQRT2 ((double) 1.4142135624) /* Value of Sqrt(2) */
+#define M_SQRT1_2 ((double) 0.7071067812) /* Value of Sqrt(1/2) */
+
+/* PROTOTYPES */
+
+/* MACROS */
+
+#endif /* __MATH_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: in.h,v 1.4 2002/10/29 04:45:10 rex Exp $
+ */
+/*
+ * netinet/in.h
+ *
+ * Internet Protocol family. Conforming to the Single UNIX(r) Specification
+ * Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __NETINET_IN_H_INCLUDED__
+#define __NETINET_IN_H_INCLUDED__
+
+/* INCLUDES */
+
+/* OBJECTS */
+
+/* TYPES */
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+
+/* MACROS */
+
+#endif /* __NETINET_IN_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: debug.h,v 1.4 2002/10/29 04:45:11 rex Exp $
+ */
+/*
+ * psx/debug.h
+ *
+ * debugging utilities
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __PSX_DEBUG_H_INCLUDED__
+#define __PSX_DEBUG_H_INCLUDED__
+
+/* INCLUDES */
+#ifdef __PSX_DEBUG_TO_STDERR__
+#include <stdio.h>
+#else /* !defined(__PSX_DEBUG_TO_STDERR__) */
+#include <ddk/ntddk.h>
+#endif /* defined(__PSX_DEBUG_TO_STDERR__) */
+
+/* OBJECTS */
+
+/* TYPES */
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+
+/* MACROS */
+
+#define __PSX_MODULE__ "psxdll.dll"
+
+#ifndef NDEBUG
+
+#ifdef __PSX_DEBUG_TO_STDERR__
+
+#if 0
+#define DEBUGOUT(MODULE,TYPE,ARGS...) \
+do{ \
+ fprintf(stderr,"%s:%s:%s:%d:%s():\n\t",(MODULE),(TYPE),__FILE__,__LINE__,__FUNCTION__); \
+ fprintf(stderr,ARGS); \
+ fprintf("\n"); \
+} \
+while(0)
+#endif
+
+#define DEBUGOUT(MODULE,TYPE,ARGS...) \
+do{ \
+ printf("%s:%s:%s:%d:%s():\n\t",(MODULE),(TYPE),__FILE__,__LINE__,__FUNCTION__); \
+ printf(ARGS); \
+ printf("\n"); \
+} \
+while(0)
+
+
+#else /* !defined(__PSX_DEBUG_TO_STDERR__) */
+
+#define DEBUGOUT(MODULE,TYPE,ARGS...) \
+do{ \
+ DbgPrint("%s:%s:%s:%d:%s():\n\t",(MODULE),(TYPE),__FILE__,__LINE__,__FUNCTION__); \
+ DbgPrint(ARGS); \
+ DbgPrint("\n"); \
+} \
+while(0)
+
+#endif /* defined(__PSX_DEBUG_TO_STDERR__) */
+
+#define DEBUGOUTIF(CONDITION,MODULE,TYPE,ARGS...) \
+if((CONDITION)) \
+{ \
+ DEBUGOUT((MODULE),(TYPE),ARGS); \
+}
+
+#else /* defined(NDEBUG) */
+
+#define DEBUGOUTIF(c,m,t,args...)
+#define DEBUGOUT(m,t,args...)
+
+#endif /* !defined(NDEBUG) */
+
+#if defined(__PSX_DEBUG_WANT_ALL__) || defined(__PSX_DEBUG_WANT_HINTS__)
+#define HINT(args...) DEBUGOUT(__PSX_MODULE__,"HINT",args)
+#define HINTIF(c,args...) DEBUGOUTIF((c),__PSX_MODULE__,"HINT",args)
+#else
+#define HINT(args...)
+#define HINTIF(c,args...)
+#endif
+
+#if defined(__PSX_DEBUG_WANT_ALL__) || defined(__PSX_DEBUG_WANT_INFOS__)
+#define INFO(args...) DEBUGOUT(__PSX_MODULE__,"INFO",args)
+#define INFOIF(c,args...) DEBUGOUTIF((c),__PSX_MODULE__,"INFO",args)
+#else
+#define INFO(args...)
+#define INFOIF(c,args...)
+#endif
+
+#if defined(__PSX_DEBUG_WANT_ALL__) || defined(__PSX_DEBUG_WANT_WARNS__)
+#define WARN(args...) DEBUGOUT(__PSX_MODULE__,"WARN",args)
+#define WARNIF(c,args...) DEBUGOUTIF((c),__PSX_MODULE__,"WARN",args)
+#else
+#define WARN(args...)
+#define WARNIF(c,args...)
+#endif
+
+#if defined(__PSX_DEBUG_WANT_ALL__) || defined(__PSX_DEBUG_WANT_ERRS__)
+#define ERR(args...) DEBUGOUT(__PSX_MODULE__,"ERR",args)
+#define ERRIF(c,args...) DEBUGOUTIF((c),__PSX_MODULE__,"ERR",args)
+#else
+#define ERR(args...)
+#define ERRIF(c,args...)
+#endif
+
+#if defined(__PSX_DEBUG_WANT_ALL__) || defined(__PSX_DEBUG_WANT_TODOS__)
+#define TODO(args...) DEBUGOUT(__PSX_MODULE__,"TODO",args)
+#define TODOIF(c,args...) DEBUGOUTIF((c),__PSX_MODULE__,"TODO",args)
+#else
+#define TODO(args...)
+#define TODOIF(c,args...)
+#endif
+
+#if defined(__PSX_DEBUG_WANT_ALL__) || defined(__PSX_DEBUG_WANT_FIXMES__)
+#define FIXME(args...) DEBUGOUT(__PSX_MODULE__,"FIXME",args)
+#define FIXMEIF(c,args...) DEBUGOUTIF((c),__PSX_MODULE__,"FIXME",args)
+#else
+#define FIXME(args...)
+#define FIXMEIF(c,args...)
+#endif
+
+
+#endif /* __PSX_DEBUG_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: dirent.h,v 1.4 2002/10/29 04:45:13 rex Exp $
+ */
+/*
+ * psx/dirent.h
+ *
+ * internal dirent.h
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __PSX_DIRENT_H_INCLUDED__
+#define __PSX_DIRENT_H_INCLUDED__
+
+/* INCLUDES */
+#include <ddk/ntddk.h>
+#include <dirent.h>
+#include <psx/safeobj.h>
+
+/* OBJECTS */
+
+/* TYPES */
+struct __internal_DIR
+{
+ __magic_t signature; /* signature to verify object's validity across calls */
+ union __any_dirent{
+ struct dirent de_ansi;
+ struct _Wdirent de_unicode;
+ } ent; /* storage for return buffer of readdir() */
+ int fildes; /* file descriptor of the directory */
+ FILE_DIRECTORY_INFORMATION info; /* directory entry information */
+ WCHAR name[MAX_PATH]; /* filename buffer */
+};
+
+/* CONSTANTS */
+#define __IDIR_MAGIC MAGIC('I', 'D', 'I', 'R')
+
+/* PROTOTYPES */
+
+/* MACROS */
+
+#endif /* __PSX_DIRENT_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: dlfcn.h,v 1.4 2002/10/29 04:45:13 rex Exp $
+ */
+/*
+ * psx/dlfcn.h
+ *
+ * internal dlfcn.h
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __PSX_DLFCN_H_INCLUDED__
+#define __PSX_DLFCN_H_INCLUDED__
+
+/* INCLUDES */
+#include <psx/errno.h>
+
+/* OBJECTS */
+
+/* TYPES */
+/* internal representation for loaded DLLs */
+/* TODO: get rid of this. The handle should be enough, with a proper PE loader */
+struct __dlobj
+{
+ int global; /* if non-zero, all the other fields have no meaning */
+ void *handle; /* pointer to the module mapping */
+};
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+void __dl_set_last_error(int);
+
+/* MACROS */
+#define __dl_get_reloc_flag(m) ((m) & (RTLD_LAZY | RTLD_NOW))
+#define __dl_get_scope_flag(m) ((m) & (RTLD_GLOBAL | RTLD_LOCAL))
+
+#endif /* __PSX_DLFCN_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: errno.h,v 1.4 2002/10/29 04:45:13 rex Exp $
+ */
+/*
+ * psx/errno.h
+ *
+ * internal errno.h
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __PSX_ERRNO_H_INCLUDED__
+#define __PSX_ERRNO_H_INCLUDED__
+
+/* INCLUDES */
+#include <errno.h>
+
+/* OBJECTS */
+
+/* TYPES */
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+
+/* MACROS */
+#define __status_to_errno(s) (s)
+#define __set_errno_from_status(s) (errno = __status_to_errno((s)))
+
+#endif /* __PSX_ERRNO_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: fdtable.h,v 1.5 2002/10/29 04:45:13 rex Exp $
+ */
+/*
+ * psx/fdtable.h
+ *
+ * POSIX+ subsystem file descriptor table data structure
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __PSX_FDTABLE_H_INCLUDED__
+#define __PSX_FDTABLE_H_INCLUDED__
+
+/* INCLUDES */
+#include <limits.h>
+#include <inttypes.h>
+#include <stddef.h>
+#include <psx/safeobj.h>
+
+/* OBJECTS */
+
+/* TYPES */
+typedef struct __tagfildes_t
+{
+ void *FileHandle;
+ int OpenFlags;
+ int FdFlags;
+ size_t ExtraDataSize;
+ void *ExtraData;
+} __fildes_t;
+
+typedef struct __tagfdtable_t
+{
+ __magic_t Signature;
+ int32_t LowestUnusedFileNo;
+ int32_t UsedDescriptors;
+ int32_t AllocatedDescriptors;
+ uint32_t DescriptorsBitmap[OPEN_MAX / 32];
+ __fildes_t *Descriptors;
+} __fdtable_t;
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+int __fdtable_init(__fdtable_t *);
+int __fdtable_free(__fdtable_t *);
+
+int __fdtable_entry_isavail(__fdtable_t *, int);
+int __fdtable_entry_nextavail(__fdtable_t *, int);
+int __fdtable_entry_add(__fdtable_t *, int, __fildes_t *, __fildes_t **);
+int __fdtable_entry_remove(__fdtable_t *, int);
+__fildes_t *__fdtable_entry_get(__fdtable_t *, int);
+
+/* MACROS */
+#define __FDTABLE_MAGIC MAGIC('F', 'D', 'T', 'B')
+
+#endif /* __PSX_FDTABLE_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: interlock.h,v 1.4 2002/10/29 04:45:13 rex Exp $
+ */
+/*
+ * psx/interlock.h
+ *
+ * inter-locked increment/decrement
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __PSX_INTERLOCK_H_INCLUDED__
+#define __PSX_INTERLOCK_H_INCLUDED__
+
+/* INCLUDES */
+
+/* OBJECTS */
+
+/* TYPES */
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+int __interlock_inc(int *);
+int __interlock_dec(int *);
+int __interlock_add(int *, int);
+
+/* MACROS */
+
+#endif /* __PSX_INTERLOCK_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: lpcproto.h,v 1.5 2002/10/29 04:45:13 rex Exp $
+ *
+ * ReactOS POSIX+ Environment Subsystem
+ * LPC protocol spoken by PSXSS.EXE, PSXDLL.DLL, CSRTERM.EXE.
+ */
+#ifndef _PSX_LPCPROTO_H
+#define _PSX_LPCPROTO_H
+
+#include <napi/lpc.h>
+
+#ifndef PRIVATE
+#define PRIVATE static
+#endif
+
+/* Protocol version */
+#define PSX_LPC_PROTOCOL_VERSION 1
+
+/* POSIX+ system name space */
+#define PSX_NS_SUBSYSTEM_DIRECTORY_NAME L"POSIX+"
+#define PSX_NS_SESSION_DIRECTORY_NAME L"Sessions"
+#define PSX_NS_SYSTEM_DIRECTORY_NAME L"System"
+#define PSX_NS_API_PORT_NAME L"ApiPort"
+#define PSX_NS_SBAPI_PORT_NAME L"SbApiPort"
+#define PSX_NS_SESSIONAPI_PORT_NAME L"SessionPort"
+#define PSX_NS_API_PORT_TEMPLATE L"\\%s\\%s"
+#define PSX_NS_SESSION_PORT_TEMPLATE L"\\%s\\%s\\P%d"
+#define PSX_NS_SESSION_DATA_TEMPLATE L"\\%s\\%s\\D%d"
+
+/* ConnectData protocol */
+
+typedef enum {
+ PSX_CONNECTION_TYPE_PROCESS,
+ PSX_CONNECTION_TYPE_TERMINAL,
+ PSX_CONNECTION_TYPE_SERVER
+} PSX_CONNECTION_TYPE;
+
+typedef struct _PSX_CONNECT_PORT_DATA
+{
+ PSX_CONNECTION_TYPE ConnectionType; /* IN OUT */
+ ULONG Version; /* IN OUT */
+ ULONG PortIdentifier; /* OUT */
+} PSX_CONNECT_PORT_DATA, * PPSX_CONNECT_PORT_DATA;
+
+/* LPC message subsystem-specific header */
+
+typedef struct _PSX_MESSAGE_HEADER
+{
+ WORD Context;
+ WORD Procedure;
+ NTSTATUS Status;
+} PSX_MESSAGE_HEADER, * PPSX_MESSAGE_HEADER;
+
+typedef PSX_MESSAGE_HEADER PSX_MESSAGE, * PPSX_MESSAGE;
+
+#define PSX_MAX_LPC_DATA_SIZE 128 /* compute it*/
+
+typedef struct _PSX_MAX_MESSAGE
+{
+ LPC_MESSAGE_HEADER Header;
+ PSX_MESSAGE_HEADER PsxHeader;
+ BYTE Data [PSX_MAX_LPC_DATA_SIZE];
+} PSX_MAX_MESSAGE, * PPSX_MAX_MESSAGE;
+
+/* Terminal I/O */
+
+/* \POSIX+\SessionPort API */
+
+#define PSX_TERMINAL_SECTION_SIZE 65536L
+#define PSX_TERMINAL_SECTION_OFFSET 8192L
+
+typedef enum {
+ PSX_TERMINAL_INTERRUPT,
+ PSX_TERMINAL_SESSION_STATUS_REQUEST
+} PSX_TERMINAL_API;
+
+typedef struct _PSX_TERMINAL_IO
+{
+ LPC_MESSAGE_HEADER Header;
+ PSX_MESSAGE_HEADER PsxHeader;
+ ULONG Size;
+ ULONG Offset;
+} PSX_TERMINAL_READ, * PPSX_TERMINAL_READ;
+
+/* System I/O (system calls) */
+
+#include <psx/syscall.h>
+
+#endif /* ndef _PSX_LPCPROTO_H */
--- /dev/null
+/* $Id: path.h,v 1.4 2002/10/29 04:45:13 rex Exp $
+ */
+/*
+ * psx/path.h
+ *
+ * POSIX+ subsystem path functions
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __PSX_PATH_H_INCLUDED__
+#define __PSX_PATH_H_INCLUDED__
+
+/* INCLUDES */
+#include <ddk/ntddk.h>
+
+/* OBJECTS */
+
+/* TYPES */
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+BOOLEAN
+__PdxPosixPathGetNextComponent_U
+(
+ IN UNICODE_STRING PathName,
+ IN OUT PUNICODE_STRING PathComponent,
+ OUT PBOOLEAN TrailingDelimiter OPTIONAL
+);
+
+BOOLEAN
+__PdxPosixPathResolve_U
+(
+ IN UNICODE_STRING PathName,
+ OUT PUNICODE_STRING ResolvedPathName,
+ IN WCHAR PathDelimiter OPTIONAL
+);
+
+BOOLEAN
+__PdxPosixPathGetNextComponent_A
+(
+ IN ANSI_STRING PathName,
+ IN OUT PANSI_STRING PathComponent,
+ OUT PBOOLEAN TrailingDelimiter OPTIONAL
+);
+
+BOOLEAN
+__PdxPosixPathResolve_A
+(
+ IN ANSI_STRING PathName,
+ OUT PANSI_STRING ResolvedPathName,
+ IN CHAR PathDelimiter OPTIONAL
+);
+
+BOOLEAN
+__PdxPosixPathNameToNtPathName
+(
+ IN PWCHAR PosixPath,
+ OUT PUNICODE_STRING NativePath,
+ IN PUNICODE_STRING CurDir OPTIONAL,
+ IN PUNICODE_STRING RootDir OPTIONAL
+);
+
+/* MACROS */
+/* returns non-zero if the argument is a path delimiter */
+#define IS_CHAR_DELIMITER_U(WCH) (((WCH) == L'/') || ((WCH) == L'\\'))
+#define IS_CHAR_DELIMITER_A(CH) (((CH) == '/') || ((CH) == '\\'))
+
+/* returns non-zero if the argument is an empty path component */
+#define IS_COMPONENT_EMPTY_U(WCOMPONENT) (WCOMPONENT.Length == 0)
+#define IS_COMPONENT_EMPTY_A(COMPONENT) (COMPONENT.Length == 0)
+
+/* returns non-zero if the argument is "." */
+#define IS_COMPONENT_DOT_U(WCOMPONENT) \
+((WCOMPONENT.Length == sizeof(WCHAR)) && (WCOMPONENT.Buffer[0] == L'.'))
+
+#define IS_COMPONENT_DOT_A(COMPONENT) \
+((COMPONENT.Length == 1) && (COMPONENT.Buffer[0] == '.'))
+
+/* returns non-zero if the argument is ".." */
+#define IS_COMPONENT_DOTDOT_U(WCOMPONENT) \
+( \
+ (WCOMPONENT.Length == (sizeof(WCHAR) * 2)) && \
+ (WCOMPONENT.Buffer[0] == L'.') && \
+ (WCOMPONENT.Buffer[1] == L'.') \
+)
+
+#define IS_COMPONENT_DOTDOT_A(COMPONENT) \
+( \
+ (COMPONENT.Length == 2) && \
+ (COMPONENT.Buffer[0] == '.') && \
+ (COMPONENT.Buffer[1] == '.') \
+)
+
+#endif /* __PSX_PATH_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: pdata.h,v 1.8 2002/10/29 04:45:13 rex Exp $
+ */
+/*
+ * psx/pdata.h
+ *
+ * POSIX+ subsystem process environment data structure
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __PSX_PDATA_H_INCLUDED__
+#define __PSX_PDATA_H_INCLUDED__
+
+/* INCLUDES */
+#include <ddk/ntddk.h>
+#include <ntdll/rtl.h>
+#include <limits.h>
+#include <psx/fdtable.h>
+
+/* OBJECTS */
+
+/* TYPES */
+typedef struct __tagPDX_PDATA
+{
+ BOOL Spawned; /* TRUE if process has been created through __PdxSpawnPosixProcess() */
+ int ArgCount; /* count of arguments passed to exec() */
+ char **ArgVect; /* array of arguments passed to exec() */
+ char ***Environment; /* pointer to user-provided environ variable */
+ UNICODE_STRING NativePathBuffer; /* static buffer used by low-level calls for pathname conversions */
+ UNICODE_STRING CurDir; /* current working directory */
+ UNICODE_STRING RootPath; /* NT path to the process's root directory */
+ HANDLE RootHandle; /* handle to the process's root directory */
+ __fdtable_t FdTable; /* file descriptors table */
+ /* WARNING: PRELIMINARY CODE FOR DEBUGGING PURPOSES ONLY - DO NOT CHANGE */
+ CRITICAL_SECTION Lock;
+ LONG TlsIndex;
+} __PDX_PDATA, * __PPDX_PDATA;
+
+/* serialized process data block, used by __PdxSpawnPosixProcess() and __PdxExecThunk().
+ The layout of buffers inside the Buffer byte array is as following:
+
+ ArgVect[0] + null byte
+ ArgVect[1] + null byte
+ ...
+ ArgVect[ArgCount - 1] + null byte
+ Environment[0] + null byte
+ Environment[1] + null byte
+ ...
+ Environment[n - 1] + null byte (NOTE: the value of n is stored in ProcessData.Environment)
+ CurDir.Buffer
+ RootPath.Buffer
+ FdTable.Descriptors[0]
+ FdTable.Descriptors[1]
+ ...
+ FdTable.Descriptors[FdTable.AllocatedDescriptors - 1]
+ FdTable.Descriptors[x].ExtraData
+ FdTable.Descriptors[y].ExtraData
+ ...
+ padding for page boundary alignment
+ */
+typedef struct __tagPDX_SERIALIZED_PDATA
+{
+ __PDX_PDATA ProcessData;
+ ULONG AllocSize;
+ BYTE Buffer[1];
+} __PDX_SERIALIZED_PDATA, *__PPDX_SERIALIZED_PDATA;
+
+typedef struct __tagPDX_TDATA
+{
+ __PPDX_PDATA ProcessData;
+ int ErrNum;
+} __PDX_TDATA, * __PPDX_TDATA;
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+NTSTATUS STDCALL __PdxSerializeProcessData(IN __PPDX_PDATA, OUT __PPDX_SERIALIZED_PDATA *);
+NTSTATUS STDCALL __PdxUnserializeProcessData(IN OUT __PPDX_SERIALIZED_PDATA *, OUT __PPDX_PDATA * OPTIONAL);
+
+NTSTATUS
+STDCALL
+__PdxProcessDataToProcessParameters
+(
+ OUT PRTL_USER_PROCESS_PARAMETERS *ProcessParameters,
+ IN __PPDX_PDATA ProcessData,
+ IN PUNICODE_STRING ImageFile
+);
+
+/* MACROS */
+/* WARNING: PRELIMINARY CODE FOR DEBUGGING PURPOSES ONLY - DO NOT CHANGE */
+VOID __PdxSetProcessData(__PPDX_PDATA);
+__PPDX_PDATA __PdxGetProcessData(VOID);
+
+#include <ddk/ntddk.h>
+
+#define __PdxAcquirePdataLock() (RtlEnterCriticalSection(&__PdxGetProcessData()->Lock))
+#define __PdxReleasePdataLock() (RtlLeaveCriticalSection(&__PdxGetProcessData()->Lock))
+
+#if 0
+#define __PdxAcquirePdataLock() (RtlAcquirePebLock())
+#define __PdxReleasePdataLock() (RtlReleasePebLock())
+
+#define __PdxSetProcessData(PPDATA) ((void)((NtCurrentPeb()->SubSystemData) = (PPDATA)))
+#define __PdxGetProcessData() ((__PPDX_PDATA)(&(NtCurrentPeb()->SubSystemData)))
+#endif
+
+#define __PdxGetNativePathBuffer() ((PUNICODE_STRING)(&(__PdxGetProcessData()->NativePathBuffer)))
+#define __PdxGetCurDir() ((PUNICODE_STRING)(&(__PdxGetProcessData()->CurDir)))
+#define __PdxGetRootPath() ((PUNICODE_STRING)(&(__PdxGetProcessData()->RootPath)))
+#define __PdxGetRootHandle() ((HANDLE)(__PdxGetProcessData()->RootHandle))
+#define __PdxGetFdTable() ((__fdtable_t *)(__PdxGetProcessData()->FdTable))
+
+#define __PdxSetNativePathBuffer(BUF) ((void)((__PdxGetProcessData()->NativePathBuffer) = (BUF)))
+#define __PdxSetCurDir(CURDIR) ((void)((__PdxGetProcessData()->CurDir) = (CURDIR)))
+#define __PdxSetRootPath(ROOTPATH) ((void)((__PdxGetProcessData()->RootPath) = (ROOTPATH)))
+#define __PdxSetRootHandle(ROOTHANDLE) ((void)((__PdxGetProcessData()->RootHandle) = (ROOTHANDLE)))
+#define __PdxSetFdTable(FDTABLE) ((void)((__PdxGetProcessData()->FdTable) = (FDTABLE)))
+
+#endif /* __PSX_PDATA_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: pthread.h,v 1.4 2002/10/29 04:45:15 rex Exp $
+ */
+/*
+ * psx/pthread.h
+ *
+ * internal pthread.h
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __PSX_PTHREAD_H_INCLUDED__
+#define __PSX_PTHREAD_H_INCLUDED__
+
+/* INCLUDES */
+#include <psx/safeobj.h>
+
+/* OBJECTS */
+
+/* TYPES */
+
+struct __mutexattr
+{
+ __magic_t signature;
+ int pshared;
+ int protocol;
+ int type;
+};
+
+struct __mutex
+{
+ __magic_t signature;
+ void * handle;
+ int protocol;
+ int type;
+};
+
+/* CONSTANTS */
+#define __PTHREAD_MUTEX_MAGIC (MAGIC('P', 'T', 'M', 'X'))
+#define __PTHREAD_MUTEX_ATTR_MAGIC (MAGIC('P', 'T', 'M', 'A'))
+
+/* PROTOTYPES */
+
+/* MACROS */
+
+#endif /* __PSX_PTHREAD_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: safeobj.h,v 1.4 2002/10/29 04:45:15 rex Exp $
+ */
+/*
+ * psx/safeobj.h
+ *
+ * types and definitions for safe checking of user-provided objects
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __PSX_SAFEOBJ_H_INCLUDED__
+#define __PSX_SAFEOBJ_H_INCLUDED__
+
+/* INCLUDES */
+#include <inttypes.h>
+
+/* OBJECTS */
+
+/* TYPES */
+typedef uint32_t __magic_t;
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+int __safeobj_validate(void *, __magic_t);
+
+/* MACROS */
+/* builds a magic number from 4 characters */
+#define MAGIC(a,b,c,d) ( \
+ (((uint32_t)(uint8_t)(a)) << 24) | \
+ (((uint32_t)(uint8_t)(b)) << 16) | \
+ (((uint32_t)(uint8_t)(c)) << 8) | \
+ (((uint32_t)(uint8_t)(d)) << 0) \
+)
+
+/* retrieves a comma-separated list of the 4 characters in a magic number */
+#define MAGIC_DECOMPOSE(m) \
+ ((uint8_t)(m >> 24)), \
+ ((uint8_t)(m >> 16)), \
+ ((uint8_t)(m >> 8)), \
+ ((uint8_t)(m >> 0))
+
+#endif /* __PSX_SAFEOBJ_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: spawn.h,v 1.3 2002/10/29 04:45:15 rex Exp $
+ */
+/*
+ * psx/spawn.h
+ *
+ * spawn POSIX+ processes
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+
+#ifndef __PSX_SPAWN_H_INCLUDED__
+#define __PSX_SPAWN_H_INCLUDED__
+
+/* INCLUDES */
+#include <ddk/ntddk.h>
+#include <psx/pdata.h>
+
+/* OBJECTS */
+
+/* TYPES */
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+NTSTATUS STDCALL __PdxSpawnPosixProcess
+(
+ OUT PHANDLE ProcessHandle,
+ OUT PHANDLE ThreadHandle,
+ IN POBJECT_ATTRIBUTES FileObjectAttributes,
+ IN POBJECT_ATTRIBUTES ProcessObjectAttributes,
+ IN HANDLE InheritFromProcessHandle,
+ IN __PPDX_PDATA ProcessData
+);
+
+/* MACROS */
+
+#endif /* __PSX_SPAWN_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: stdlib.h,v 1.4 2002/10/29 04:45:15 rex Exp $
+ */
+/*
+ * psx/stdlib.h
+ *
+ * internal stdlib.h
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __PSX_STDLIB_H_INCLUDED__
+#define __PSX_STDLIB_H_INCLUDED__
+
+/* INCLUDES */
+#include <ddk/ntddk.h>
+#include <ntos/heap.h>
+#include <stdlib.h>
+
+/* OBJECTS */
+
+/* TYPES */
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+
+/* MACROS */
+/* FIXME? Windows NT's ntdll doesn't export RtlGetProcessHeap() */
+#define RtlGetProcessHeap() ((HANDLE)NtCurrentPeb()->ProcessHeap)
+
+#define __malloc(SIZE) (RtlAllocateHeap(RtlGetProcessHeap(), 0, (SIZE)))
+#define __realloc(PTR,SIZE) (RtlReAllocateHeap(RtlGetProcessHeap(), 0, (PTR), (SIZE)))
+#define __free(PTR) (RtlFreeHeap(RtlGetProcessHeap(), 0, (PTR)))
+
+#endif /* __PSX_STDLIB_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: template.h,v 1.6 2002/10/29 04:45:15 rex Exp $
+ How to create a new header file from this template:
+ - copy the template in the new file (never edit this file directly, unless
+ that's what you want)
+ - search for the string "EDITME" in the file, and follow the instructions
+ - remove this comment block, all blocks containing REMOVEME, and all EDITME
+ instructions
+ - save your file, and Have Fun! (TM)
+ */
+/* $*Id*$ (EDITME: remove asterisks from "$*Id*$")
+ */
+/*
+ * psx/template.h (EDITME: replace with the real name of the header)
+ *
+ * template for POSIX headers (EDITME: replace this line with the real file
+ * description)
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by John Doe <john.doe@mail.com> (EDITME: your name and e-mail go
+ * here)
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+
+/*
+ Tags are used to prevent double inclusion of C header files. This
+ technique should be documented in all good C manuals
+
+ How to generate an unique tag for your header:
+ - uppercase the name of the header, where "name" is the filename and
+ the optional relative path (e.g. "stdio.h", "sys/types.h")
+ - replace all non-alphanumeric characters in the obtained name with an
+ underscore character ("_")
+ - prepend a double underscore ("__"), and append the string "_INCLUDED__"
+ - replace all occurrences of "__PSX_TEMPLATE_H_INCLUDED__" in this file
+ with your tag
+
+ Example tags:
+ sys/types.h -> SYS/TYPES.H -> SYS_TYPES_H -> __SYS_TYPES_H_INCLUDED__
+ iso646.h -> ISO646.H -> ISO646_H -> __ISO646_H_INCLUDED__
+
+ (REMOVEME)
+ */
+#ifndef __PSX_TEMPLATE_H_INCLUDED__ /* EDITME: replace macro with unique tag */
+#define __PSX_TEMPLATE_H_INCLUDED__ /* EDITME: replace macro with unique tag */
+/*
+ Explanation of the sections:
+ INCLUDES #include directives should be grouped here
+ OBJECTS declare global variables here
+ TYPES types, structures and unions here
+ CONSTANTS symbolic constants (simple #define's), enums, constants
+ PROTOTYPES ANSI C function prototypes
+ MACROS parametrized macros
+
+ (REMOVEME)
+ */
+/* INCLUDES */
+
+/* OBJECTS */
+
+/* TYPES */
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+
+/* MACROS */
+
+#endif /* __PSX_TEMPLATE_H_INCLUDED__ */ /* EDITME: replace macro with unique tag */
+
+/* EOF */
+
--- /dev/null
+/* $Id: tls.h,v 1.3 2002/10/29 04:45:15 rex Exp $
+ */
+/*
+ * psx/tls.h
+ *
+ * types and calls for TLS management
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+
+#ifndef __PSX_TLS_H_INCLUDED__
+#define __PSX_TLS_H_INCLUDED__
+
+/* INCLUDES */
+
+/* OBJECTS */
+
+/* TYPES */
+typedef unsigned int __tls_index_t;
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+__tls_index_t __tls_alloc();
+int __tls_free(__tls_index_t index);
+void * __tls_get_val(__tls_index_t index);
+int __tls_put_val(__tls_index_t index, void * data);
+
+/* MACROS */
+
+#endif /* __PSX_TLS_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: pthread.h,v 1.4 2002/10/29 04:45:16 rex Exp $
+ */
+/*
+ * pthread.h
+ *
+ * threads. Conforming to the Single UNIX(r) Specification Version 2,
+ * System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __PTHREAD_H_INCLUDED__
+#define __PTHREAD_H_INCLUDED__
+
+/* INCLUDES */
+#include <sched.h>
+#include <time.h>
+
+/* OBJECTS */
+
+/* TYPES */
+
+/* CONSTANTS */
+#define PTHREAD_MUTEX_NORMAL (1)
+#define PTHREAD_MUTEX_ERRORCHECK (2)
+#define PTHREAD_MUTEX_RECURSIVE (3)
+
+#define PTHREAD_MUTEX_DEFAULT (PTHREAD_MUTEX_NORMAL)
+
+#define PTHREAD_PROCESS_PRIVATE (1)
+#define PTHREAD_PROCESS_SHARED (2)
+
+#define PTHREAD_PRIO_NONE (1)
+
+/* PROTOTYPES */
+int pthread_attr_destroy(pthread_attr_t *);
+int pthread_attr_getdetachstate(const pthread_attr_t *, int *);
+int pthread_attr_getguardsize(const pthread_attr_t *, size_t *);
+int pthread_attr_getinheritsched(const pthread_attr_t *, int *);
+int pthread_attr_getschedparam(const pthread_attr_t *,
+ struct sched_param *);
+int pthread_attr_getschedpolicy(const pthread_attr_t *, int *);
+int pthread_attr_getscope(const pthread_attr_t *, int *);
+int pthread_attr_getstackaddr(const pthread_attr_t *, void **);
+int pthread_attr_getstacksize(const pthread_attr_t *, size_t *);
+int pthread_attr_init(pthread_attr_t *);
+int pthread_attr_setdetachstate(pthread_attr_t *, int);
+int pthread_attr_setguardsize(pthread_attr_t *, size_t);
+int pthread_attr_setinheritsched(pthread_attr_t *, int);
+int pthread_attr_setschedparam(pthread_attr_t *,
+ const struct sched_param *);
+int pthread_attr_setschedpolicy(pthread_attr_t *, int);
+int pthread_attr_setscope(pthread_attr_t *, int);
+int pthread_attr_setstackaddr(pthread_attr_t *, void *);
+int pthread_attr_setstacksize(pthread_attr_t *, size_t);
+int pthread_cancel(pthread_t);
+void pthread_cleanup_push(void (*)(void *), void *);
+void pthread_cleanup_pop(int);
+int pthread_cond_broadcast(pthread_cond_t *);
+int pthread_cond_destroy(pthread_cond_t *);
+int pthread_cond_init(pthread_cond_t *, const pthread_condattr_t *);
+int pthread_cond_signal(pthread_cond_t *);
+int pthread_cond_timedwait(pthread_cond_t *,
+ pthread_mutex_t *, const struct timespec *);
+int pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *);
+int pthread_condattr_destroy(pthread_condattr_t *);
+int pthread_condattr_getpshared(const pthread_condattr_t *, int *);
+int pthread_condattr_init(pthread_condattr_t *);
+int pthread_condattr_setpshared(pthread_condattr_t *, int);
+int pthread_create(pthread_t *, const pthread_attr_t *,
+ void *(*)(void *), void *);
+int pthread_detach(pthread_t);
+int pthread_equal(pthread_t, pthread_t);
+void pthread_exit(void *);
+int pthread_getconcurrency(void);
+int pthread_getschedparam(pthread_t, int *, struct sched_param *);
+void *pthread_getspecific(pthread_key_t);
+int pthread_join(pthread_t, void **);
+int pthread_key_create(pthread_key_t *, void (*)(void *));
+int pthread_key_delete(pthread_key_t);
+int pthread_mutex_destroy(pthread_mutex_t *);
+int pthread_mutex_getprioceiling(const pthread_mutex_t *, int *);
+int pthread_mutex_init(pthread_mutex_t *, const pthread_mutexattr_t *);
+int pthread_mutex_lock(pthread_mutex_t *);
+int pthread_mutex_setprioceiling(pthread_mutex_t *, int, int *);
+int pthread_mutex_trylock(pthread_mutex_t *);
+int pthread_mutex_unlock(pthread_mutex_t *);
+int pthread_mutexattr_destroy(pthread_mutexattr_t *);
+int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *,
+ int *);
+int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *, int *);
+int pthread_mutexattr_getpshared(const pthread_mutexattr_t *, int *);
+int pthread_mutexattr_gettype(const pthread_mutexattr_t *, int *);
+int pthread_mutexattr_init(pthread_mutexattr_t *);
+int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *, int);
+int pthread_mutexattr_setprotocol(pthread_mutexattr_t *, int);
+int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int);
+int pthread_mutexattr_settype(pthread_mutexattr_t *, int);
+int pthread_once(pthread_once_t *, void (*)(void));
+int pthread_rwlock_destroy(pthread_rwlock_t *);
+int pthread_rwlock_init(pthread_rwlock_t *,
+ const pthread_rwlockattr_t *);
+int pthread_rwlock_rdlock(pthread_rwlock_t *);
+int pthread_rwlock_tryrdlock(pthread_rwlock_t *);
+int pthread_rwlock_trywrlock(pthread_rwlock_t *);
+int pthread_rwlock_unlock(pthread_rwlock_t *);
+int pthread_rwlock_wrlock(pthread_rwlock_t *);
+int pthread_rwlockattr_destroy(pthread_rwlockattr_t *);
+int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *,
+ int *);
+int pthread_rwlockattr_init(pthread_rwlockattr_t *);
+int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *, int);
+pthread_t
+ pthread_self(void);
+int pthread_setcancelstate(int, int *);
+int pthread_setcanceltype(int, int *);
+int pthread_setconcurrency(int);
+int pthread_setschedparam(pthread_t, int ,
+ const struct sched_param *);
+int pthread_setspecific(pthread_key_t, const void *);
+void pthread_testcancel(void);
+
+/* MACROS */
+
+#endif /* __PTHREAD_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: pwd.h,v 1.4 2002/10/29 04:45:16 rex Exp $
+ */
+/*
+ * pwd.h
+ *
+ * password structure. Conforming to the Single UNIX(r) Specification
+ * Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __PWD_H_INCLUDED__
+#define __PWD_H_INCLUDED__
+
+/* INCLUDES */
+
+/* OBJECTS */
+
+/* TYPES */
+struct passwd
+{
+ char *pw_name; /* user's login name */
+ uid_t pw_uid; /* numerical user ID */
+ gid_t pw_gid; /* numerical group ID */
+ char *pw_dir; /* initial working directory */
+ char *pw_shell; /* program to use as shell */
+};
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+struct passwd *getpwnam(const char *);
+struct passwd *getpwuid(uid_t);
+int getpwnam_r(const char *, struct passwd *, char *,
+ size_t, struct passwd **);
+int getpwuid_r(uid_t, struct passwd *, char *,
+ size_t, struct passwd **);
+void endpwent(void);
+struct passwd *getpwent(void);
+void setpwent(void);
+
+/* MACROS */
+
+#endif /* __PWD_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: sched.h,v 1.4 2002/10/29 04:45:18 rex Exp $
+ */
+/*
+ * sched.h
+ *
+ * execution scheduling (REALTIME). Conforming to the Single UNIX(r)
+ * Specification Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __SCHED_H_INCLUDED__
+#define __SCHED_H_INCLUDED__
+
+/* INCLUDES */
+#include <time.h>
+
+/* OBJECTS */
+
+/* TYPES */
+struct sched_param
+{
+ int sched_priority; /* process execution scheduling priority */
+};
+
+/* CONSTANTS */
+/* First in-first out (FIFO) scheduling policy */
+#define SCHED_FIFO (1)
+/* Round robin scheduling policy */
+#define SCHED_RR (2)
+/* Another scheduling policy */
+#define SCHED_OTHER (3)
+
+/* PROTOTYPES */
+int sched_get_priority_max(int);
+int sched_get_priority_min(int);
+int sched_getparam(pid_t, struct sched_param *);
+int sched_getscheduler(pid_t);
+int sched_rr_get_interval(pid_t, struct timespec *);
+int sched_setparam(pid_t, const struct sched_param *);
+int sched_setscheduler(pid_t, int, const struct sched_param *);
+int sched_yield(void);
+
+/* MACROS */
+
+#endif /* __SCHED_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: signal.h,v 1.5 2002/10/29 04:45:18 rex Exp $
+ */
+/*
+ * signal.h
+ *
+ * signals. Conforming to the Single UNIX(r) Specification Version 2,
+ * System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __SIGNAL_H_INCLUDED__
+#define __SIGNAL_H_INCLUDED__
+
+/* INCLUDES */
+#include <time.h>
+#include <sys/types.h>
+
+/* OBJECTS */
+
+/* TYPES */
+/* pre-declaration of time.h types to suppress warnings caused by circular
+ dependencies */
+struct timespec;
+
+typedef int sig_atomic_t; /* Integral type of an object that can be
+ accessed as an atomic entity, even in the
+ presence of asynchronous interrupts */
+
+typedef unsigned long int sigset_t; /* Integral or structure type of an object
+ used to represent sets of signals. */
+
+union sigval
+{
+ int sival_int; /* integer signal value */
+ void* sival_ptr; /* pointer signal value */
+};
+
+struct sigevent
+{
+ int sigev_notify; /* notification type */
+ int sigev_signo; /* signal number */
+ union sigval sigev_value; /* signal value */
+ void (* sigev_notify_function)(union sigval); /* notification function */
+ pthread_attr_t * sigev_notify_attributes; /* notification attributes */
+};
+
+
+typedef struct __tagsiginfo_t
+{
+ int si_signo; /* signal number */
+ int si_errno; /* if non-zero, an errno value associated with
+ this signal, as defined in <errno.h> */
+ int si_code; /* signal code */
+ pid_t si_pid; /* sending process ID */
+ uid_t si_uid; /* real user ID of sending process */
+ void *si_addr; /* address of faulting instruction */
+ int si_status; /* exit value or signal */
+ long si_band; /* band event for SIGPOLL */
+ union sigval si_value; /* signal value */
+} siginfo_t;
+
+struct sigaction
+{
+ void (* sa_handler)(int); /* what to do on receipt of signal */
+ sigset_t sa_mask; /* set of signals to be blocked during
+ execution of the signal handling function */
+ int sa_flags; /* special flags */
+ void (* sa_sigaction)(int, siginfo_t *, void *);
+ /* pointer to signal handler function
+ or one of the macros SIG_IGN or SIG_DFL */
+};
+
+typedef struct __tagstack_t
+{
+ void *ss_sp; /* stack base or pointer */
+ size_t ss_size; /* stack size */
+ int ss_flags; /* flags */
+} stack_t;
+
+struct sigstack
+{
+ int ss_onstack; /* non-zero when signal stack is in use */
+ void *ss_sp; /* signal stack pointer */
+};
+
+/* CONSTANTS */
+#define SIG_DFL ((void (*)(int))(0xFFFFFFFF)) /* Request for default signal handling. */
+#define SIG_ERR ((void (*)(int))(0x00000000)) /* Return value from signal() in case of error. */
+#define SIG_IGN ((void (*)(int))(0x00000001)) /* Request that signal be ignored. */
+#define SIG_HOLD ((void (*)(int))(0x00000002)) /* Request that signal be held. */
+
+#define SIGEV_NONE (0) /* No asynchronous notification will be delivered \
+ when the event of interest occurs. */
+#define SIGEV_SIGNAL (1) /* A queued signal, with an application-defined \
+ value, will be generated when the event of \
+ interest occurs. */
+#define SIGEV_THREAD (2) /* A notification function will be called to perform \
+ notification. */
+
+/* TODO: realtime features not supported yet */
+#define SIGRTMIN (-1)
+#define SIGRTMAX (-1)
+
+#define SIGABRT ( 1) /* Process abort signal. */
+#define SIGALRM ( 2) /* Alarm clock. */
+#define SIGFPE ( 3) /* Erroneous arithmetic operation. */
+#define SIGHUP ( 4) /* Hangup. */
+#define SIGILL ( 5) /* Illegal instruction. */
+#define SIGINT ( 6) /* Terminal interrupt signal. */
+#define SIGKILL ( 7) /* Kill (cannot be caught or ignored). */
+#define SIGPIPE ( 8) /* Write on a pipe with no one to read it. */
+#define SIGQUIT ( 9) /* Terminal quit signal. */
+#define SIGSEGV (10) /* Invalid memory reference. */
+#define SIGTERM (11) /* Termination signal. */
+#define SIGUSR1 (12) /* User-defined signal 1. */
+#define SIGUSR2 (13) /* User-defined signal 2. */
+#define SIGCHLD (14) /* Child process terminated or stopped. */
+#define SIGCONT (15) /* Continue executing, if stopped. */
+#define SIGSTOP (16) /* Stop executing (cannot be caught or ignored). */
+#define SIGTSTP (17) /* Terminal stop signal. */
+#define SIGTTIN (18) /* Background process attempting read. */
+#define SIGTTOU (19) /* Background process attempting write. */
+#define SIGBUS (20) /* Access to an undefined portion of a memory object. */
+#define SIGPOLL (21) /* Pollable event. */
+#define SIGPROF (22) /* Profiling timer expired. */
+#define SIGSYS (23) /* Bad system call. */
+#define SIGTRAP (24) /* Trace/breakpoint trap. */
+#define SIGURG (25) /* High bandwidth data is available at a socket. */
+#define SIGVTALRM (26) /* Virtual timer expired. */
+#define SIGXCPU (27) /* CPU time limit exceeded. */
+#define SIGXFSZ (28) /* File size limit exceeded. */
+
+/* FIXME: the following constants need to be reviewed */
+/* Do not generate SIGCHLD when children stop. */
+#define SA_NOCLDSTOP (0x00000001)
+/* The resulting set is the union of the current set and the signal set
+ pointed to by the argument set. */
+#define SA_ONSTACK (0x00000002)
+/* Causes signal dispositions to be set to SIG_DFL on entry to signal
+ handlers. */
+#define SA_RESETHAND (0x00000004)
+/* Causes certain functions to become restartable. */
+#define SA_RESTART (0x00000008)
+/* Causes extra information to be passed to signal handlers at the time
+ of receipt of a signal. */
+#define SA_SIGINFO (0x00000010)
+/* Causes implementations not to create zombie processes on child death. */
+#define SA_NOCLDWAIT (0x00000020)
+/* Causes signal not to be automatically blocked on entry to signal
+ handler. */
+#define SA_NODEFER (0x00000040)
+
+/* FIXME: the following constants need to be reviewed */
+/* The resulting set is the intersection of the current set and the
+ complement of the signal set pointed to by the argument set. */
+#define SIG_BLOCK (1)
+/* The resulting set is the signal set pointed to by the argument
+ set. */
+#define SIG_UNBLOCK (2)
+/* Causes signal delivery to occur on an alternate stack. */
+#define SIG_SETMASK (3)
+
+/* FIXME: the following constants need to be reviewed */
+/* Process is executing on an alternate signal stack. */
+#define SS_ONSTACK (1)
+/* Alternate signal stack is disabled. */
+#define SS_DISABLE (2)
+
+/* Minimum stack size for a signal handler. */ /* FIXME */
+#define MINSIGSTKSZ (0)
+/* Default size in bytes for the alternate signal stack. */ /* FIXME */
+#define SIGSTKSZ (0)
+
+/*
+ signal-specific reasons why the signal was generated
+ */
+/* SIGILL */
+/* illegal opcode */
+#define ILL_ILLOPC (1)
+/* illegal operand */
+#define ILL_ILLOPN (2)
+/* illegal addressing mode */
+#define ILL_ILLADR (3)
+/* illegal trap */
+#define ILL_ILLTRP (4)
+/* privileged opcode */
+#define ILL_PRVOPC (5)
+/* privileged register */
+#define ILL_PRVREG (6)
+/* coprocessor error */
+#define ILL_COPROC (7)
+/* internal stack error */
+#define ILL_BADSTK (8)
+
+/* SIGFPE */
+/* integer divide by zero */
+#define FPE_INTDIV
+/* integer overflow */
+#define FPE_INTOVF
+/* floating point divide by zero */
+#define FPE_FLTDIV
+/* floating point overflow */
+#define FPE_FLTOVF
+/* floating point underflow */
+#define FPE_FLTUND
+/* floating point inexact result */
+#define FPE_FLTRES
+/* invalid floating point operation */
+#define FPE_FLTINV
+/* subscript out of range */
+#define FPE_FLTSUB
+
+/* SIGSEGV */
+/* address not mapped to object */
+#define SEGV_MAPERR
+/* invalid permissions for mapped object */
+#define SEGV_ACCERR
+
+/* SIGBUS */
+/* invalid address alignment */
+#define BUS_ADRALN
+/* non-existent physical address */
+#define BUS_ADRERR
+/* object specific hardware error */
+#define BUS_OBJERR
+
+/* SIGTRAP */
+/* process breakpoint */
+#define TRAP_BRKPT
+/* process trace trap */
+#define TRAP_TRACE
+
+/* SIGCHLD */
+/* child has exited */
+#define CLD_EXITED
+/* child has terminated abnormally and did not create a core file */
+#define CLD_KILLED
+/* child has terminated abnormally and created a core file */
+#define CLD_DUMPED
+/* traced child has trapped */
+#define CLD_TRAPPED
+/* child has stopped */
+#define CLD_STOPPED
+/* stopped child has continued */
+#define CLD_CONTINUED
+
+/* SIGPOLL */
+/* data input available */
+#define POLL_IN
+/* output buffers available */
+#define POLL_OUT
+/* input message available */
+#define POLL_MSG
+/* I/O error */
+#define POLL_ERR
+/* high priority input available */
+#define POLL_PRI
+/* device disconnected */
+#define POLL_HUP
+/* signal sent by kill() */
+#define SI_USER
+/* signal sent by the sigqueue() */
+#define SI_QUEUE
+/* signal generated by expiration of a timer set by timer_settime() */
+#define SI_TIMER
+/* signal generated by completion of an asynchronous I/O request */
+#define SI_ASYNCIO
+/* signal generated by arrival of a message on an empty message queue */
+#define SI_MESGQ
+
+/* PROTOTYPES */
+void (*bsd_signal(int, void (*)(int)))(int);
+int kill(pid_t, int);
+int killpg(pid_t, int);
+int pthread_kill(pthread_t, int);
+int pthread_sigmask(int, const sigset_t *, sigset_t *);
+int raise(int);
+int sigaction(int, const struct sigaction *, struct sigaction *);
+int sigaddset(sigset_t *, int);
+int sigaltstack(const stack_t *, stack_t *);
+int sigdelset(sigset_t *, int);
+int sigemptyset(sigset_t *);
+int sigfillset(sigset_t *);
+int sighold(int);
+int sigignore(int);
+int siginterrupt(int, int);
+int sigismember(const sigset_t *, int);
+void (*signal(int, void (*)(int)))(int);
+int sigpause(int);
+int sigpending(sigset_t *);
+int sigprocmask(int, const sigset_t *, sigset_t *);
+int sigqueue(pid_t, int, const union sigval);
+int sigrelse(int);
+void (*sigset(int, void (*)(int)))(int);
+int sigstack(struct sigstack *ss,
+ struct sigstack *oss); /* LEGACY */
+int sigsuspend(const sigset_t *);
+int sigtimedwait(const sigset_t *, siginfo_t *,
+ const struct timespec *);
+int sigwait(const sigset_t *set, int *sig);
+int sigwaitinfo(const sigset_t *, siginfo_t *);
+
+/* MACROS */
+
+#endif /* __SIGNAL_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: stdarg.h,v 1.4 2002/10/29 04:45:18 rex Exp $
+ */
+/*
+ * stdarg.h
+ *
+ * handle variable argument list. Conforming to the Single UNIX(r)
+ * Specification Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __STDARG_H_INCLUDED__
+#define __STDARG_H_INCLUDED__
+
+/* OBJECTS */
+
+/* TYPES */
+typedef char* va_list;
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+
+/* MACROS */
+/* taken from mingw's stdarg.h */
+
+/* Amount of space required in an argument list (ie. the stack) for an
+ argument of type t. */
+#define __va_argsiz(t) \
+ (((sizeof(t) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
+
+#define va_start(ap, pN) \
+ ((ap) = ((va_list) (&pN) + __va_argsiz(pN)))
+
+#define va_end(ap) ((void)0)
+
+#define va_arg(ap, t) \
+ (((ap) = (ap) + __va_argsiz(t)), \
+ *((t*) (void*) ((ap) - __va_argsiz(t))))
+
+#endif /* __STDARG_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: stddef.h,v 1.4 2002/10/29 04:45:19 rex Exp $
+ */
+/*
+ * stddef.h
+ *
+ * standard type definitions. Conforming to the Single UNIX(r) Specification
+ * Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __STDDEF_H_INCLUDED__
+#define __STDDEF_H_INCLUDED__
+
+/* INCLUDES */
+#include <sys/types.h>
+
+/* OBJECTS */
+
+/* TYPES */
+typedef signed long int ptrdiff_t;
+typedef unsigned short int wchar_t;
+
+/* CONSTANTS */
+#ifndef NULL
+#define NULL ((void *)(0)) /* Null pointer constant. */
+#endif
+
+/* PROTOTYPES */
+
+/* MACROS */
+#define offsetof(t,m) ((size_t) &((t *)0)->m)
+
+#endif /* __STDDEF_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: stdio.h,v 1.4 2002/10/29 04:45:19 rex Exp $
+ */
+/*
+ * stdio.h
+ *
+ * standard buffered input/output. Conforming to the Single UNIX(r)
+ * Specification Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __STDIO_H_INCLUDED__
+#define __STDIO_H_INCLUDED__
+
+/* INCLUDES */
+#include <stddef.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+/* OBJECTS */
+extern char *optarg;
+extern int opterr;
+extern int optind; /* LEGACY */
+extern int optopt;
+
+/* TYPES */
+typedef struct __tagFILE
+{
+ int _dummy;
+} FILE;
+
+typedef struct __tagfpos_t
+{
+ int _dummy;
+} fpos_t;
+
+
+/* CONSTANTS */
+/* Size of <stdio.h> buffers. */
+#define BUFSIZ (0x10000)
+
+/* Maximum size in bytes of the longest filename string that the implementation
+ guarantees can be opened. */
+#define FILENAME_MAX (255)
+
+/* Number of streams which the implementation guarantees can be open
+ simultaneously. The value will be at least eight. */
+#define FOPEN_MAX (8)
+
+/* Input/output fully buffered. */
+#define _IOFBF (1)
+/* Input/output line buffered. */
+#define _IOLBF (2)
+/* Input/output unbuffered. */
+#define _IONBF (3)
+
+/* Maximum size of character array to hold ctermid() output. */
+#define L_ctermid (255)
+/* Maximum size of character array to hold cuserid() output. (LEGACY) */
+#define L_cuserid (255)
+/* Maximum size of character array to hold tmpnam() output. */
+#define L_tmpnam (255)
+
+/* Minimum number of unique filenames generated by tmpnam(). Maximum number
+ of times an application can call tmpnam() reliably. The value of TMP_MAX
+ will be at least 10,000. */
+#define TMP_MAX (0xFFFF)
+
+/* End-of-file return value. */
+#define EOF (-1)
+
+/* default directory prefix for tempnam() */
+#define P_tmpdir "/tmp/"
+
+/* Standard error output stream. */
+#define stderr ((FILE *)STDERR_FILENO)
+/* Standard input stream. */
+#define stdin ((FILE *)STDIN_FILENO)
+/* Standard output stream. */
+#define stdout ((FILE *)STDOUT_FILENO)
+
+/* PROTOTYPES */
+void clearerr(FILE *);
+char *ctermid(char *);
+char *cuserid(char *); /* LEGACY */
+int fclose(FILE *);
+FILE *fdopen(int, const char *);
+int feof(FILE *);
+int ferror(FILE *);
+int fflush(FILE *);
+int fgetc(FILE *);
+int fgetpos(FILE *, fpos_t *);
+char *fgets(char *, int, FILE *);
+int fileno(FILE *);
+void flockfile(FILE *);
+FILE *fopen(const char *, const char *);
+int fprintf(FILE *, const char *, ...);
+int fputc(int, FILE *);
+int fputs(const char *, FILE *);
+size_t fread(void *, size_t, size_t, FILE *);
+FILE *freopen(const char *, const char *, FILE *);
+int fscanf(FILE *, const char *, ...);
+int fseek(FILE *, long int, int);
+int fseeko(FILE *, off_t, int);
+int fsetpos(FILE *, const fpos_t *);
+long int ftell(FILE *);
+off_t ftello(FILE *);
+int ftrylockfile(FILE *);
+void funlockfile(FILE *);
+size_t fwrite(const void *, size_t, size_t, FILE *);
+int getc(FILE *);
+int getchar(void);
+int getc_unlocked(FILE *);
+int getchar_unlocked(void);
+int getopt(int, char * const[], const char *); /* LEGACY */
+char *gets(char *);
+int getw(FILE *);
+int pclose(FILE *);
+void perror(const char *);
+FILE *popen(const char *, const char *);
+int printf(const char *, ...);
+int putc(int, FILE *);
+int putchar(int);
+int putc_unlocked(int, FILE *);
+int putchar_unlocked(int);
+int puts(const char *);
+int putw(int, FILE *);
+int remove(const char *);
+int rename(const char *, const char *);
+void rewind(FILE *);
+int scanf(const char *, ...);
+void setbuf(FILE *, char *);
+int setvbuf(FILE *, char *, int, size_t);
+int snprintf(char *, size_t, const char *, ...);
+int sprintf(char *, const char *, ...);
+int sscanf(const char *, const char *, int, ...);
+char *tempnam(const char *, const char *);
+FILE *tmpfile(void);
+char *tmpnam(char *);
+int ungetc(int, FILE *);
+int vfprintf(FILE *, const char *, va_list);
+int vprintf(const char *, va_list);
+int vsnprintf(char *, size_t, const char *, va_list);
+int vsprintf(char *, const char *, va_list);
+
+/* MACROS */
+
+#endif /* __STDIO_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: stdlib.h,v 1.4 2002/10/29 04:45:19 rex Exp $
+ */
+/*
+ * stdlib.h
+ *
+ * standard library definitions. Conforming to the Single UNIX(r)
+ * Specification Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __STDLIB_H_INCLUDED__
+#define __STDLIB_H_INCLUDED__
+
+/* INCLUDES */
+#include <stddef.h>
+#include <limits.h>
+#include <math.h>
+#include <sys/wait.h>
+
+/* OBJECTS */
+
+/* TYPES */
+typedef struct __tagdiv_t
+{
+ int quot; /* quotient */
+ int rem; /* remainder */
+} div_t;
+
+typedef struct __tagldiv_t
+{
+ long int quot; /* quotient */
+ long int rem; /* remainder */
+} ldiv_t;
+
+/* CONSTANTS */
+#define EXIT_FAILURE (-1) /* Unsuccessful termination for exit(), evaluates \
+ to a non-zero value. */
+#define EXIT_SUCCESS (0) /* Successful termination for exit(), evaluates to 0. */
+
+/* FIXME */
+#define RAND_MAX (32767) /* Maximum value returned by rand(), at least 32,767. */
+
+/* FIXME */
+#define MB_CUR_MAX (1) /* Integer expression whose value is the maximum number \
+ of bytes in a character specified by the current \
+ locale. */
+
+/* PROTOTYPES */
+long a64l(const char *);
+void abort(void);
+int abs(int);
+int atexit(void (*)(void));
+double atof(const char *);
+int atoi(const char *);
+long int atol(const char *);
+void *bsearch(const void *, const void *, size_t, size_t,
+ int (*)(const void *, const void *));
+void *calloc(size_t, size_t);
+div_t div(int, int);
+double drand48(void);
+char *ecvt(double, int, int *, int *);
+double erand48(unsigned short int[3]);
+void exit(int);
+char *fcvt (double, int, int *, int *);
+void free(void *);
+char *gcvt(double, int, char *);
+char *getenv(const char *);
+int getsubopt(char **, char *const *, char **);
+int grantpt(int);
+char *initstate(unsigned int, char *, size_t);
+long int jrand48(unsigned short int[3]);
+char *l64a(long);
+long int labs(long int);
+void lcong48(unsigned short int[7]);
+ldiv_t ldiv(long int, long int);
+long int lrand48(void);
+void *malloc(size_t);
+int mblen(const char *, size_t);
+size_t mbstowcs(wchar_t *, const char *, size_t);
+int mbtowc(wchar_t *, const char *, size_t);
+char *mktemp(char *);
+int mkstemp(char *);
+long int mrand48(void);
+long int nrand48(unsigned short int [3]);
+char *ptsname(int);
+int putenv(char *);
+void qsort(void *, size_t, size_t, int (*)(const void *,
+ const void *));
+int rand(void);
+int rand_r(unsigned int *);
+long random(void);
+void *realloc(void *, size_t);
+char *realpath(const char *, char *);
+unsigned short int seed48(unsigned short int[3]);
+void setkey(const char *);
+char *setstate(const char *);
+void srand(unsigned int);
+void srand48(long int);
+void srandom(unsigned);
+double strtod(const char *, char **);
+long int strtol(const char *, char **, int);
+unsigned long int
+ strtoul(const char *, char **, int);
+int system(const char *);
+int ttyslot(void); /* LEGACY */
+int unlockpt(int);
+void *valloc(size_t); /* LEGACY */
+size_t wcstombs(char *, const wchar_t *, size_t);
+int wctomb(char *, wchar_t);
+
+/* MACROS */
+
+#endif /* __STDLIB_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: string.h,v 1.4 2002/10/29 04:45:19 rex Exp $
+ */
+/*
+ * string.h
+ *
+ * string operations. Conforming to the Single UNIX(r) Specification
+ * Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __STRING_H_INCLUDED__ /* replace with the appropriate tag */
+#define __STRING_H_INCLUDED__ /* replace with the appropriate tag */
+
+/* INCLUDES */
+#include <stddef.h>
+
+/* OBJECTS */
+
+/* TYPES */
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+void *memccpy(void *, const void *, int, size_t);
+void *memchr(const void *, int, size_t);
+int memcmp(const void *, const void *, size_t);
+void *memcpy(void *, const void *, size_t);
+void *memmove(void *, const void *, size_t);
+void *memset(void *, int, size_t);
+char *strcat(char *, const char *);
+char *strchr(const char *, int);
+int strcmp(const char *, const char *);
+int strcoll(const char *, const char *);
+char *strcpy(char *, const char *);
+size_t strcspn(const char *, const char *);
+char *strdup(const char *);
+char *strerror(int);
+size_t strlen(const char *);
+char *strncat(char *, const char *, size_t);
+int strncmp(const char *, const char *, size_t);
+char *strncpy(char *, const char *, size_t);
+char *strpbrk(const char *, const char *);
+char *strrchr(const char *, int);
+size_t strspn(const char *, const char *);
+char *strstr(const char *, const char *);
+char *strtok(char *, const char *);
+char *strtok_r(char *, const char *, char **);
+size_t strxfrm(char *, const char *, size_t);
+
+/* MACROS */
+
+#endif /* __STRING_H_INCLUDED__ */ /* replace with the appropriate tag */
+
+/* EOF */
+
--- /dev/null
+/* $Id: errno.h,v 1.3 2002/10/29 04:45:19 rex Exp $
+ */
+/*
+ * sys/errno.h
+ *
+ * dummy include file for Microsoft POSIX and Interix compatibility
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+
+#ifndef __SYS_ERRNO_H_INCLUDED__
+#define __SYS_ERRNO_H_INCLUDED__
+
+/* INCLUDES */
+#include <errno.h>
+
+/* OBJECTS */
+
+/* TYPES */
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+
+/* MACROS */
+
+#endif /* __SYS_ERRNO_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: ipc.h,v 1.5 2002/10/29 04:45:19 rex Exp $
+ */
+/*
+ * sys/ipc.h
+ *
+ * interprocess communication access structure. Conforming to the Single
+ * UNIX(r) Specification Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __SYS_IPC_H_INCLUDED__
+#define __SYS_IPC_H_INCLUDED__
+
+/* INCLUDES */
+
+/* OBJECTS */
+
+/* TYPES */
+struct ipc_perm
+{
+ uid_t uid; /* owner's user ID */
+ gid_t gid; /* owner's group ID */
+ uid_t cuid; /* creator's user ID */
+ gid_t cgid; /* creator's group ID */
+ mode_t mode; /* read/write permission */
+};
+
+/* CONSTANTS */
+/* Mode bits */
+#define IPC_CREAT (0x00000200) /* Create entry if key does not exist */
+#define IPC_EXCL (0x00000400) /* Fail if key exists */
+#define IPC_NOWAIT (0x00000800) /* Error if request must wait */
+
+/* Keys */
+#define IPC_PRIVATE (0xFFFFFFFF) /* Private key */
+
+/* Control commands */
+#define IPC_RMID (1) /* Remove identifier */
+#define IPC_SET (2) /* Set options */
+#define IPC_STAT (3) /* Get options */
+
+/* PROTOTYPES */
+key_t ftok(const char *, int);
+
+/* MACROS */
+
+#endif /* __SYS_IPC_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: mman.h,v 1.4 2002/10/29 04:45:20 rex Exp $
+ */
+/*
+ * sys/mman.h
+ *
+ * memory management declarations. Conforming to the Single UNIX(r)
+ * Specification Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __SYS_SOCKET_H_INCLUDED__
+#define __SYS_SOCKET_H_INCLUDED__
+
+/* INCLUDES */
+
+/* OBJECTS */
+
+/* TYPES */
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+
+/* MACROS */
+
+#endif /* __SYS_SOCKET_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: msg.h,v 1.5 2002/10/29 04:45:21 rex Exp $
+ */
+/*
+ * sys/msg.h
+ *
+ * message queue structures. Conforming to the Single UNIX(r) Specification
+ * Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __SYS_SOCKET_H_INCLUDED__
+#define __SYS_SOCKET_H_INCLUDED__
+
+/* INCLUDES */
+#include <sys/ipc.h>
+
+/* OBJECTS */
+
+/* TYPES */
+typedef unsigned int msgqnum_t; /* Used for the number of messages in the message queue */
+typedef unsigned int msglen_t; /* Used for the number of bytes allowed in a message queue */
+
+struct msqid_ds
+{
+ struct ipc_perm msg_perm; /* operation permission structure */
+ msgqnum_t msg_qnum; /* number of messages currently on queue */
+ msglen_t msg_qbytes; /* maximum number of bytes allowed on queue */
+ pid_t msg_lspid; /* process ID of last msgsnd() */
+ pid_t msg_lrpid; /* process ID of last msgrcv() */
+ time_t msg_stime; /* time of last msgsnd() */
+ time_t msg_rtime; /* time of last msgrcv() */
+ time_t msg_ctime; /* time of last change */
+};
+
+/* CONSTANTS */
+/* Message operation flag */
+#define MSG_NOERROR (0x00001000) /* No error if big message */
+
+/* PROTOTYPES */
+int msgctl(int, int, struct msqid_ds *);
+int msgget(key_t, int);
+ssize_t msgrcv(int, void *, size_t, long int, int);
+int msgsnd(int, const void *, size_t, int);
+
+/* MACROS */
+
+#endif /* __SYS_SOCKET_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: resource.h,v 1.5 2002/10/29 04:45:21 rex Exp $
+ */
+/*
+ * sys/resource.h
+ *
+ * definitions for XSI resource operations. Conforming to the Single UNIX(r)
+ * Specification Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __SYS_RESOURCE_H_INCLUDED__
+#define __SYS_RESOURCE_H_INCLUDED__
+
+/* INCLUDES */
+#include <sys/time.h>
+
+/* OBJECTS */
+
+/* TYPES */
+struct rusage
+{
+ struct timeval ru_utime; /* user time used */
+ struct timeval ru_stime; /* system time used */
+};
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+
+/* MACROS */
+
+#endif /* __SYS_RESOURCE_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: sem.h,v 1.5 2002/10/29 04:45:21 rex Exp $
+ */
+/*
+ * sys/sem.h
+ *
+ * semaphore facility. Conforming to the Single UNIX(r) Specification
+ * Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __SYS_SEM_H_INCLUDED__
+#define __SYS_SEM_H_INCLUDED__
+
+/* INCLUDES */
+#include <sys/ipc.h>
+
+/* OBJECTS */
+
+/* TYPES */
+struct semid_ds
+{
+ struct ipc_perm sem_perm; /* operation permission structure */
+ unsigned short int sem_nsems; /* number of semaphores in set */
+ time_t sem_otime; /* last semop time */
+ time_t sem_ctime; /* last time changed by semctl() */
+};
+
+struct sembuf
+{
+ unsigned short int sem_num; /* semaphore number */
+ short int sem_op; /* semaphore operation */
+ short int sem_flg; /* operation flags */
+};
+
+/* CONSTANTS */
+/* Semaphore operation flags */
+#define SEM_UNDO (0x00001000) /* Set up adjust on exit entry */
+
+/* Command definitions for the function semctl() */
+#define GETNCNT (1) /* Get semncnt */
+#define GETPID (2) /* Get sempid */
+#define GETVAL (3) /* Get semval */
+#define GETALL (4) /* Get all cases of semval */
+#define GETZCNT (5) /* Get semzcnt */
+#define SETVAL (6) /* Set semval */
+#define SETALL (7) /* Set all cases of semval */
+
+/* PROTOTYPES */
+int semctl(int, int, int, ...);
+int semget(key_t, int, int);
+int semop(int, struct sembuf *, size_t);
+
+/* MACROS */
+
+#endif /* __SYS_SEM_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: shm.h,v 1.5 2002/10/29 04:45:21 rex Exp $
+ */
+/*
+ * sys/shm.h
+ *
+ * shared memory facility. Conforming to the Single UNIX(r) Specification
+ * Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __SYS_SHM_H_INCLUDED__
+#define __SYS_SHM_H_INCLUDED__
+
+/* INCLUDES */
+
+/* OBJECTS */
+
+/* TYPES */
+typedef unsigned short shmatt_t;
+
+struct shmid_ds
+{
+ struct ipc_perm shm_perm; /* operation permission structure */
+ size_t shm_segsz; /* size of segment in bytes */
+ pid_t shm_lpid; /* process ID of last shared memory operation */
+ pid_t shm_cpid; /* process ID of creator */
+ shmatt_t shm_nattch; /* number of current attaches */
+ time_t shm_atime; /* time of last shmat() */
+ time_t shm_dtime; /* time of last shmdt() */
+ time_t shm_ctime; /* time of last change by shmctl() */
+};
+
+/* CONSTANTS */
+#define SHM_RDONLY (0x00000200) /* Attach read-only (else read-write). */
+#define SHM_RND (0x00000400) /* Round attach address to SHMLBA. */
+
+#define SHMLBA (4096) /* Segment low boundary address multiple. */
+
+/* PROTOTYPES */
+void *shmat(int, const void *, int);
+int shmctl(int, int, struct shmid_ds *);
+int shmdt(const void *);
+int shmget(key_t, size_t, int);
+
+/* MACROS */
+
+#endif /* __SYS_SHM_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: socket.h,v 1.4 2002/10/29 04:45:21 rex Exp $
+ */
+/*
+ * sys/socket.h
+ *
+ * Internet Protocol family. Conforming to the Single UNIX(r) Specification
+ * Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __SYS_SOCKET_H_INCLUDED__
+#define __SYS_SOCKET_H_INCLUDED__
+
+/* INCLUDES */
+
+/* OBJECTS */
+
+/* TYPES */
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+
+/* MACROS */
+
+#endif /* __SYS_SOCKET_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: stat.h,v 1.5 2002/10/29 04:45:21 rex Exp $
+ */
+/*
+ * sys/stat.h
+ *
+ * data returned by the stat() function. Conforming to the Single
+ * UNIX(r) Specification Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __SYS_STAT_H_INCLUDED__
+#define __SYS_STAT_H_INCLUDED__
+
+/* INCLUDES */
+#include <sys/types.h>
+
+/* OBJECTS */
+
+/* TYPES */
+struct stat
+{
+ mode_t st_mode; /* mode of file (see below) */
+ ino_t st_ino; /* file serial number */
+ dev_t st_dev; /* ID of device containing file */
+ nlink_t st_nlink; /* number of links to the file */
+ uid_t st_uid; /* user ID of file */
+ gid_t st_gid; /* group ID of file */
+ off_t st_size; /* file size in bytes (if file is a regular file) */
+ time_t st_atime; /* time of last access */
+ time_t st_mtime; /* time of last data modification */
+ time_t st_ctime; /* time of last status change */
+ dev_t st_rdev; /* device ID (if file is character or block special) */
+ blksize_t st_blksize; /* a filesystem-specific preferred I/O block size for
+ this object. In some filesystem types, this may
+ vary from file to file */
+ blkcnt_t st_blocks; /* number of blocks allocated for this object */
+};
+
+/* CONSTANTS */
+/*
+ file type
+ */
+#define S_IFIFO (000010000) /* FIFO special */
+#define S_IFCHR (000020000) /* character special */
+#define S_IFDIR (000040000) /* directory */
+#define S_IFBLK (000060000) /* block special */
+#define S_IFREG (000100000) /* regular */
+#define S_IFLNK (000200000) /* symbolic link */
+#define S_IFSOCK (000400000) /* socket */
+
+/* type of file */
+#define S_IFMT (000770000)
+
+/*
+ file mode bits
+ */
+#define S_IRUSR (000000400) /* read permission, owner */
+#define S_IWUSR (000000200) /* write permission, owner */
+#define S_IXUSR (000000100) /* execute/search permission, owner */
+#define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) /* read, write, execute/search by owner */
+
+#define S_IRGRP (000000040) /* read permission, group */
+#define S_IWGRP (000000020) /* write permission, group */
+#define S_IXGRP (000000010) /* execute/search permission, group */
+#define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) /* read, write, execute/search by group */
+
+#define S_IROTH (000000004) /* read permission, others */
+#define S_IWOTH (000000002) /* write permission, others */
+#define S_IXOTH (000000001) /* execute/search permission, others */
+#define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) /* read, write, execute/search by others */
+
+#define S_ISUID (000004000) /* set-user-ID on execution */
+#define S_ISGID (000002000) /* set-group-ID on execution */
+
+#define S_ISVTX (000010000) /* on directories, restricted deletion flag */
+
+/*
+ the following macros will test whether a file is of the specified type
+ */
+#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
+#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
+#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
+#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
+#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
+#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
+
+/* shared memory, semaphores and message queues are unlikely to be ever
+ implemented as files */
+#define S_TYPEISMQ(buf) (0) /* Test for a message queue */
+#define S_TYPEISSEM(buf) (0) /* Test for a semaphore */
+#define S_TYPEISSHM(buf) (0) /* Test for a shared memory object */
+
+/* PROTOTYPES */
+int chmod(const char *, mode_t);
+int fchmod(int, mode_t);
+int fstat(int, struct stat *);
+int lstat(const char *, struct stat *);
+int mkdir(const char *, mode_t);
+int mkfifo(const char *, mode_t);
+int mknod(const char *, mode_t, dev_t);
+int stat(const char *, struct stat *);
+mode_t umask(mode_t);
+
+/* MACROS */
+
+#endif /* __SYS_STAT_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: statvfs.h,v 1.4 2002/10/29 04:45:21 rex Exp $
+ */
+/*
+ * sys/statvfs.h
+ *
+ * VFS Filesystem information structure. Conforming to the Single UNIX(r)
+ * Specification Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __SYS_STATVFS_H_INCLUDED__
+#define __SYS_STATVFS_H_INCLUDED__
+
+/* INCLUDES */
+
+/* OBJECTS */
+
+/* TYPES */
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+
+/* MACROS */
+
+#endif /* __SYS_STATVFS_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: time.h,v 1.5 2002/10/29 04:45:22 rex Exp $
+ */
+/*
+ * sys/time.h
+ *
+ * time types. Conforming to the Single UNIX(r) Specification Version 2,
+ * System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __SYS_TIME_H_INCLUDED__
+#define __SYS_TIME_H_INCLUDED__
+
+/* INCLUDES */
+
+/* OBJECTS */
+
+/* TYPES */
+struct timeval
+{
+ time_t tv_sec; /* seconds */
+ suseconds_t tv_usec; /* microseconds */
+};
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+
+/* MACROS */
+
+#endif /* __SYS_TIME_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: timeb.h,v 1.4 2002/10/29 04:45:22 rex Exp $
+ */
+/*
+ * sys/timeb.h
+ *
+ * additional definitions for date and time. Conforming to the Single UNIX(r)
+ * Specification Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __SYS_TIMEB_H_INCLUDED__
+#define __SYS_TIMEB_H_INCLUDED__
+
+/* INCLUDES */
+
+/* OBJECTS */
+
+/* TYPES */
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+
+/* MACROS */
+
+#endif /* __SYS_TIMEB_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: times.h,v 1.4 2002/10/29 04:45:22 rex Exp $
+ */
+/*
+ * sys/times.h
+ *
+ * file access and modification times structure. Conforming to the Single
+ * UNIX(r) Specification Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __SYS_TIMES_H_INCLUDED__
+#define __SYS_TIMES_H_INCLUDED__
+
+/* INCLUDES */
+
+/* OBJECTS */
+
+/* TYPES */
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+
+/* MACROS */
+
+#endif /* __SYS_TIMES_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: types.h,v 1.6 2002/10/29 04:45:22 rex Exp $
+ */
+/*
+ * sys/types.h
+ *
+ * data types. Conforming to the Single UNIX(r) Specification Version 2,
+ * System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __SYS_TYPES_H_INCLUDED__
+#define __SYS_TYPES_H_INCLUDED__
+
+/* INCLUDES */
+
+/* OBJECTS */
+
+/* TYPES */
+/* FIXME: all these types need to be checked */
+typedef unsigned long int blkcnt_t; /* Used for file block counts */
+typedef unsigned long int blksize_t; /* Used for block sizes */
+typedef long long clock_t; /* Used for system times in clock ticks or CLOCKS_PER_SEC */
+typedef int clockid_t; /* Used for clock ID type in the clock and timer functions. */
+typedef unsigned long int dev_t; /* Used for device IDs. */
+typedef unsigned long int fsblkcnt_t; /* Used for file system block counts */
+typedef unsigned long int fsfilcnt_t; /* Used for file system file counts */
+typedef unsigned long int gid_t; /* Used for group IDs. */
+typedef int id_t; /* Used as a general identifier; can be used to contain at least a
+ pid_t, uid_t or a gid_t. */
+typedef unsigned long int ino_t; /* Used for file serial numbers. */
+typedef int key_t; /* Used for interprocess communication. */
+typedef unsigned long int mode_t; /* Used for some file attributes. */
+typedef unsigned long int nlink_t; /* Used for link counts. */
+typedef long off_t; /* Used for file sizes. */
+typedef long int pid_t; /* Used for process IDs and process group IDs. */
+
+/* pthread types */
+typedef void * pthread_cond_t; /* Used for condition variables. */
+typedef void * pthread_condattr_t; /* Used to identify a condition attribute object. */
+typedef void * pthread_key_t; /* Used for thread-specific data keys. */
+typedef void * pthread_attr_t; /* Used to identify a thread attribute object. */
+
+typedef void * pthread_mutex_t;
+typedef void * pthread_mutexattr_t;
+
+typedef void * pthread_once_t; /* Used for dynamic package initialisation. */
+typedef void * pthread_rwlock_t; /* Used for read-write locks. */
+typedef void * pthread_rwlockattr_t; /* Used for read-write lock attributes. */
+typedef unsigned long int pthread_t; /* Used to identify a thread. */
+
+typedef unsigned int size_t; /* Used for sizes of objects. */
+typedef signed int ssize_t; /* Used for a count of bytes or an error indication. */
+typedef long long suseconds_t; /* Used for time in microseconds */
+typedef long int time_t; /* Used for time in seconds. */
+typedef void * timer_t; /* Used for timer ID returned by timer_create(). */
+typedef int uid_t; /* Used for user IDs. */
+typedef unsigned long long useconds_t; /* Used for time in microseconds. */
+
+/*
+ additional types for sockets and streams - for compatibility with Microsoft POSIX
+ */
+typedef unsigned char u_char;
+typedef unsigned short int u_short;
+typedef unsigned short int ushort;
+typedef unsigned int u_int;
+typedef unsigned long int u_long;
+
+typedef unsigned int uint;
+typedef unsigned long ulong;
+typedef unsigned char unchar;
+
+typedef char *caddr_t;
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+
+/* MACROS */
+/* for compatibility with Microsoft POSIX */
+#define _CRTAPI1 __cdecl
+#define _CRTAPI2 __cdecl
+
+#endif /* __SYS_TYPES_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: uio.h,v 1.4 2002/10/29 04:45:23 rex Exp $
+ */
+/*
+ * sys/uio.h
+ *
+ * definitions for vector I/O operations. Conforming to the Single UNIX(r)
+ * Specification Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __SYS_UIO_H_INCLUDED__
+#define __SYS_UIO_H_INCLUDED__
+
+/* INCLUDES */
+
+/* OBJECTS */
+
+/* TYPES */
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+
+/* MACROS */
+
+#endif /* __SYS_UIO_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: un.h,v 1.4 2002/10/29 04:45:23 rex Exp $
+ */
+/*
+ * sys/un.h
+ *
+ * declarations for definitions for UNIX-domain sockets. Conforming to the
+ * Single UNIX(r) Specification Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __SYS_UN_H_INCLUDED__
+#define __SYS_UN_H_INCLUDED__
+
+/* INCLUDES */
+
+/* OBJECTS */
+
+/* TYPES */
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+
+/* MACROS */
+
+#endif /* __SYS_UN_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: utsname.h,v 1.4 2002/10/29 04:45:23 rex Exp $
+ */
+/*
+ * sys/utsname.h
+ *
+ * system name structure. Conforming to the Single UNIX(r) Specification
+ * Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __SYS_UTSNAME_H_INCLUDED__
+#define __SYS_UTSNAME_H_INCLUDED__
+
+/* INCLUDES */
+
+/* OBJECTS */
+
+/* TYPES */
+struct utsname
+{
+ char sysname[255]; /* name of this implementation of the operating system */
+ char nodename[255]; /* name of this node within an implementation-dependent
+ communications network */
+ char release[255]; /* current release level of this implementation */
+ char version[255]; /* current version level of this release */
+ char machine[255]; /* name of the hardware type on which the system is
+ running */
+};
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+int uname(struct utsname *);
+
+/* MACROS */
+
+#endif /* __SYS_UTSNAME_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: wait.h,v 1.5 2002/10/29 04:45:23 rex Exp $
+ */
+/*
+ * sys/wait.h
+ *
+ * declarations for waiting. Conforming to the Single UNIX(r) Specification
+ * Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __SYS_WAIT_H_INCLUDED__
+#define __SYS_WAIT_H_INCLUDED__
+
+/* INCLUDES */
+#include <signal.h>
+#include <sys/resource.h>
+
+/* OBJECTS */
+
+/* TYPES */
+typedef enum __tagidtype_t
+{
+ P_ALL,
+ P_PID,
+ P_PGID
+} idtype_t;
+
+/* CONSTANTS */
+/* Possible values for the options argument to waitid() */
+#define WEXITED (0x00000001) /* Wait for processes that have exited */
+#define WSTOPPED (0x00000002) /* Status will be returned for any child that has stopped upon receipt of a signal */
+#define WNOWAIT (0x00000004) /* Keep the process whose status is returned in infop in a waitable state */
+
+#define WCONTINUED (0x00000008) /* Status will be returned for any child that was stopped and has been continued */
+#define WNOHANG (0x00000010) /* Return immediately if there are no children to wait for */
+#define WUNTRACED (0x00000020) /* Report status of stopped child process */
+
+/* PROTOTYPES */
+pid_t wait(int *);
+pid_t wait3(int *, int, struct rusage *);
+int waitid(idtype_t, id_t, siginfo_t *, int);
+pid_t waitpid(pid_t, int *, int);
+
+/* MACROS */
+/* Macros for analysis of process status values */
+#define WEXITSTATUS(__STATUS__) (1) /* Return exit status */
+#define WIFCONTINUED(__STATUS__) (1) /* True if child has been continued */
+#define WIFEXITED(__STATUS__) (1) /* True if child exited normally */
+#define WIFSIGNALED(__STATUS__) (1) /* True if child exited due to uncaught signal */
+#define WIFSTOPPED(__STATUS__) (1) /* True if child is currently stopped */
+#define WSTOPSIG(__STATUS__) (1) /* Return signal number that caused process to stop */
+#define WTERMSIG(__STATUS__) (1) /* Return signal number that caused process to terminate */
+
+#endif /* __SYS_WAIT_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: time.h,v 1.5 2002/10/29 04:45:25 rex Exp $
+ */
+/*
+ * time.h
+ *
+ * time types. Conforming to the Single UNIX(r) Specification Version 2,
+ * System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __TIME_H_INCLUDED__
+#define __TIME_H_INCLUDED__
+
+/* INCLUDES */
+#include <signal.h>
+#include <sys/types.h>
+
+/* OBJECTS */
+/* extern static int getdate_err; */ /* FIXME */
+extern int daylight;
+extern long int timezone;
+extern char *tzname[];
+
+/* TYPES */
+/* pre-declaration of signal.h types to suppress warnings caused by circular
+ dependencies */
+struct sigevent;
+
+struct tm
+{
+ int tm_sec; /* seconds [0,61] */
+ int tm_min; /* minutes [0,59] */
+ int tm_hour; /* hour [0,23] */
+ int tm_mday; /* day of month [1,31] */
+ int tm_mon; /* month of year [0,11] */
+ int tm_year; /* years since 1900 */
+ int tm_wday; /* day of week [0,6] (Sunday = 0) */
+ int tm_yday; /* day of year [0,365] */
+ int tm_isdst; /* daylight savings flag */
+};
+
+struct timespec
+{
+ time_t tv_sec; /* seconds */
+ long tv_nsec; /* nanoseconds */
+};
+
+struct itimerspec
+{
+ struct timespec it_interval; /* timer period */
+ struct timespec it_value; /* timer expiration */
+};
+
+/* CONSTANTS */
+/* FIXME: all the constants are wrong */
+/* Number of clock ticks per second returned by the times() function (LEGACY). */
+#define CLK_TCK (1)
+/* A number used to convert the value returned by the clock() function into
+ seconds. */
+#define CLOCKS_PER_SEC (1)
+/* The identifier of the systemwide realtime clock. */
+#define CLOCK_REALTIME (0)
+/* Flag indicating time is absolute with respect to the clock associated with a
+ timer. */
+#define TIMER_ABSTIME (1)
+
+/* PROTOTYPES */
+char *asctime(const struct tm *);
+char *asctime_r(const struct tm *, char *);
+clock_t clock(void);
+int clock_getres(clockid_t, struct timespec *);
+int clock_gettime(clockid_t, struct timespec *);
+int clock_settime(clockid_t, const struct timespec *);
+char *ctime(const time_t *);
+char *ctime_r(const time_t *, char *);
+double difftime(time_t, time_t);
+struct tm *getdate(const char *);
+struct tm *gmtime(const time_t *);
+struct tm *gmtime_r(const time_t *, struct tm *);
+struct tm *localtime(const time_t *);
+struct tm *localtime_r(const time_t *, struct tm *);
+time_t mktime(struct tm *);
+int nanosleep(const struct timespec *, struct timespec *);
+size_t strftime(char *, size_t, const char *, const struct tm *);
+char *strptime(const char *, const char *, struct tm *);
+time_t time(time_t *);
+int timer_create(clockid_t, struct sigevent *, timer_t *);
+int timer_delete(timer_t);
+int timer_gettime(timer_t, struct itimerspec *);
+int timer_getoverrun(timer_t);
+int timer_settime(timer_t, int, const struct itimerspec *,
+ struct itimerspec *);
+void tzset(void);
+
+/* MACROS */
+
+#endif /* __TIME_H_INCLUDED__ */ /* replace with the appropriate tag */
+
+/* EOF */
+
--- /dev/null
+/* $Id: types.h,v 1.3 2002/10/29 04:45:25 rex Exp $
+ */
+/*
+ * types.h
+ *
+ * dummy include file for Microsoft POSIX and Interix compatibility
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+
+#ifndef __TYPES_H_INCLUDED__
+#define __TYPES_H_INCLUDED__
+
+/* INCLUDES */
+#include <sys/types.h>
+
+/* OBJECTS */
+
+/* TYPES */
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+
+/* MACROS */
+
+#endif /* __TYPES_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: ucontext.h,v 1.4 2002/10/29 04:45:25 rex Exp $
+ */
+/*
+ * ucontext.h
+ *
+ * user context. Conforming to the Single UNIX(r) Specification Version 2,
+ * System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __UCONTEXT_H_INCLUDED__
+#define __UCONTEXT_H_INCLUDED__
+
+/* INCLUDES */
+#include <signal.h>
+
+/* OBJECTS */
+
+/* TYPES */
+typedef void * mcontext_t;
+
+typedef struct __tagucontext_t ucontext_t;
+
+struct __tagucontext_t
+{
+ ucontext_t *uc_link; /* pointer to the context that will be resumed
+ when this context returns */
+ sigset_t uc_sigmask; /* the set of signals that are blocked when this
+ context is active */
+ stack_t uc_stack; /* the stack used by this context */
+ mcontext_t uc_mcontext; /* a machine-specific representation of the saved
+ context */
+};
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+int getcontext(ucontext_t *);
+int setcontext(const ucontext_t *);
+void makecontext(ucontext_t *, (void *)(), int, ...);
+int swapcontext(ucontext_t *, const ucontext_t *);
+
+/* MACROS */
+
+#endif /* __UCONTEXT_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: unistd.h,v 1.5 2002/10/29 04:45:25 rex Exp $
+ */
+/*
+ * unistd.h
+ *
+ * standard symbolic constants and types. Conforming to the Single UNIX(r)
+ * Specification Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __UNISTD_H_INCLUDED__
+#define __UNISTD_H_INCLUDED__
+
+/* INCLUDES */
+#include <sys/types.h>
+#include <stdio.h>
+#include <inttypes.h>
+
+/* OBJECTS */
+extern char *optarg;
+extern int optind, opterr, optopt;
+
+/* TYPES */
+
+/* CONSTANTS */
+/* FIXME: set these constants appropriately */
+/* Integer value indicating version of the ISOÂ POSIX-1 standard (C
+ language binding). */
+#define _POSIX_VERSION (0)
+
+/* Integer value indicating version of the ISO POSIX-2 standard
+ (Commands). */
+#define _POSIX2_VERSION (0)
+
+/* Integer value indicating version of the ISO POSIX-2 standard (C
+ language binding). */
+#define _POSIX2_C_VERSION (0)
+
+/* Integer value indicating version of the X/Open Portability Guide to
+ which the implementation conforms. */
+#define _XOPEN_VERSION (500)
+
+/* The version of the XCU specification to which the implementation
+ conforms */
+/* TODO: set to an appropriate value when commands and utilities will
+ be available */
+#define _XOPEN_XCU_VERSION (-1)
+
+#if _XOPEN_XCU_VERSION != -1
+#error TODO: define these constants
+#define _POSIX2_C_BIND
+#define _POSIX2_C_VERSION
+#define _POSIX2_CHAR_TERM
+#define _POSIX2_LOCALEDEF
+#define _POSIX2_UPE
+#define _POSIX2_VERSION
+#endif
+
+#if 0
+/* TODO: check for conformance to the following specs */
+#define _XOPEN_XPG2
+#define _XOPEN_XPG3
+#define _XOPEN_XPG4
+#define _XOPEN_UNIX
+#endif
+
+#if 0
+/* TODO: don't forget these features */
+/* The use of chown() is restricted to a process with appropriate
+ privileges, and to changing the group ID of a file only to the
+ effective group ID of the process or to one of its supplementary
+ group IDs. */
+#define _POSIX_CHOWN_RESTRICTED
+
+/* Terminal special characters defined in <termios.h> can be disabled
+ using this character value. */
+#define _POSIX_VDISABLE
+
+/* Each process has a saved set-user-ID and a saved set-group-ID. */
+#define _POSIX_SAVED_IDS
+
+/* Implementation supports job control. */
+#define _POSIX_JOB_CONTROL
+
+#endif
+
+/* Pathname components longer than {NAME_MAX} generate an error. */
+#define _POSIX_NO_TRUNC (1)
+
+/* The implementation supports the threads option. */
+#define _POSIX_THREADS (1)
+
+/* FIXME: none of the following is strictly true yet */
+/* The implementation supports the thread stack address attribute
+ option. */ /* FIXME: not currently implemented. Should be trivial */
+#define _POSIX_THREAD_ATTR_STACKADDR (1)
+
+/* The implementation supports the thread stack size attribute
+ option. */ /* FIXME: not currently implemented. Should be trivial */
+#define _POSIX_THREAD_ATTR_STACKSIZE (1)
+
+/* The implementation supports the process-shared synchronisation
+ option. */ /* FIXME? not sure */
+#define _POSIX_THREAD_PROCESS_SHARED (1)
+
+/* The implementation supports the thread-safe functions option. */
+/* FIXME: fix errno (currently not thread-safe) */
+#define _POSIX_THREAD_SAFE_FUNCTIONS (1)
+
+/*
+ Â Constants for Options and Feature Groups
+ */
+
+/* Implementation supports the C Language Binding option. This will
+ always have a value other than -1. */
+#define _POSIX2_C_BIND (1)
+
+/* Implementation supports the C Language Development Utilities
+ option. */ /* FIXME: please change this when C compiler and
+ utilities are ported */
+#define _POSIX2_C_DEV (-1)
+
+/* Implementation supports at least one terminal type. */ /* FIXME:
+ please change this when terminal emulation is complete */
+#define _POSIX2_CHAR_TERM (-1)
+
+/* Implementation supports the FORTRAN Development Utilities option. */
+/* FIXME: please change this when Fortran compiler and utilities are
+ ported */
+#define _POSIX2_FORT_DEV (-1)
+
+/* Implementation supports the FORTRAN Run-time Utilities option. */
+/* FIXME: please change this when Fortran runtimes are ported */
+#define _POSIX2_FORT_RUN (-1)
+
+/* Implementation supports the creation of locales by the localedef
+ utility. */ /* FIXME: please change this when locales are ready */
+#define _POSIX2_LOCALEDEF (-1)
+
+/* Implementation supports the Software Development Utilities option. */
+/* FIXME? */
+#define _POSIX2_SW_DEV (-1)
+
+/* The implementation supports the User Portability Utilities option. */
+/* FIXME? */
+#define _POSIX2_UPE (-1)
+
+/* The implementation supports the X/Open Encryption Feature Group. */
+/* FIXME: please change this when encryption is ready */
+#define _XOPEN_CRYPT (-1)
+
+/* The implementation supports the Issue 4, Version 2 Enhanced
+ Internationalisation Feature Group. This is always set to a value
+ other than -1. */ /* TODO: high priority. Support for this feature is
+ needed for a conforming implementation */
+#define _XOPEN_ENH_I18N (-1)
+
+/* The implementation supports the Legacy Feature Group. */
+#define _XOPEN_LEGACY (1)
+
+/* The implementation supports the X/Open Realtime Feature Group. */
+/* FIXME? unlikely to be ever supported */
+#define _XOPEN_REALTIME (-1)
+
+/* The implementation supports the X/Open Realtime Threads Feature
+ Group. */ /* FIXME? really unlikely to be ever supported */
+#define _XOPEN_REALTIME_THREADS (-1)
+
+/* The implementation supports the Issue 4, Version 2 Shared Memory
+ Feature Group. This is always set to a value other than -1. */ /* TODO:
+ high priority. Support for this feature is needed for a conforming
+ implementation */
+#define _XOPEN_SHM (-1)
+
+/* Implementation provides a C-language compilation environment with
+ 32-bit int, long, pointer and off_t types. */
+#define _XBS5_ILP32_OFF32 (1)
+
+/* Implementation provides a C-language compilation environment with
+ 32-bit int, long and pointer types and an off_t type using at
+ least 64 bits. */ /* FIXME? check the off_t type */
+#define _XBS5_ILP32_OFFBIG (1)
+
+/* Implementation provides a C-language compilation environment with
+ 32-bit int and 64-bit long, pointer and off_t types. */ /* FIXME: on
+ some architectures this may be true */
+#define _XBS5_LP64_OFF64 (-1)
+
+/* Implementation provides a C-language compilation environment with
+ an int type using at least 32 bits and long, pointer and off_t
+ types using at least 64 bits. */ /* FIXME: on some architectures
+ this may be true */
+#define _XBS5_LPBIG_OFFBIG (-1)
+
+/* Implementation supports the File Synchronisation option. */
+/* TODO: high priority. Implement this */
+#define _POSIX_FSYNC
+
+/* Implementation supports the Memory Mapped Files option. */
+/* TODO: high priority. Implement this */
+#define _POSIX_MAPPED_FILES
+
+/* Implementation supports the Memory Protection option. */
+/* TODO: high priority. Implement this */
+#define _POSIX_MEMORY_PROTECTION
+
+#if 0
+/* Implementation supports the Prioritized Input and Output option. */
+/* FIXME? unlikely to be ever supported */
+#define _POSIX_PRIORITIZED_IO
+#endif
+
+/* FIXME: these should be implemented */
+/* Asynchronous input or output operations may be performed for the
+ associated file. */
+#define _POSIX_ASYNC_IO (-1)
+
+/* Prioritized input or output operations may be performed for the
+ associated file. */
+#define _POSIX_PRIO_IO (-1)
+
+/* Synchronised input or output operations may be performed for the
+ associated file. */
+#define _POSIX_SYNC_IO (-1)
+
+/*
+ null pointer
+ */
+#ifndef NULL
+/* NULL seems to be defined pretty much everywhere - we prevent
+ redefinition */
+#define NULL ((void *)(0))
+#endif
+
+/*
+ constants for the access() function
+ */
+
+#define R_OK (0x00000004) /* Test for read permission. */
+#define W_OK (0x00000002) /* Test for write permission. */
+#define X_OK (0x00000001) /* Test for execute (search) permission. */
+#define F_OK (0) /* Test for existence of file. */
+
+/*
+ constants for the confstr() function
+ */
+#define _CS_PATH (1)
+#define _CS_XBS5_ILP32_OFF32_CFLAGS (2)
+#define _CS_XBS5_ILP32_OFF32_LDFLAGS (3)
+#define _CS_XBS5_ILP32_OFF32_LIBS (4)
+#define _CS_XBS5_ILP32_OFF32_LINTFLAGS (5)
+#define _CS_XBS5_ILP32_OFFBIG_CFLAGS (6)
+#define _CS_XBS5_ILP32_OFFBIG_LDFLAGS (7)
+#define _CS_XBS5_ILP32_OFFBIG_LIBS (8)
+#define _CS_XBS5_ILP32_OFFBIG_LINTFLAGS (9)
+#define _CS_XBS5_LP64_OFF64_CFLAGS (10)
+#define _CS_XBS5_LP64_OFF64_LDFLAGS (11)
+#define _CS_XBS5_LP64_OFF64_LIBS (12)
+#define _CS_XBS5_LP64_OFF64_LINTFLAGS (13)
+#define _CS_XBS5_LPBIG_OFFBIG_CFLAGS (14)
+#define _CS_XBS5_LPBIG_OFFBIG_LDFLAGS (15)
+#define _CS_XBS5_LPBIG_OFFBIG_LIBS (16)
+#define _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS (17)
+
+/*
+ constants for the lseek() and fcntl() functions
+ */
+
+#define SEEK_SET (0) /* Set file offset to offset. */
+#define SEEK_CUR (1) /* Set file offset to current plus offset. */
+#define SEEK_END (2) /* Set file offset to EOF plus offset. */
+
+/*
+ constants for pathconf()
+ */
+/* constants 1 to 9 are the same as in Microsoft POSIX */
+#define _PC_LINK_MAX ( 1)
+#define _PC_MAX_CANON ( 2)
+#define _PC_MAX_INPUT ( 3)
+#define _PC_NAME_MAX ( 4)
+#define _PC_PATH_MAX ( 5)
+#define _PC_PIPE_BUF ( 6)
+#define _PC_CHOWN_RESTRICTED ( 7)
+#define _PC_NO_TRUNC ( 8)
+#define _PC_VDISABLE ( 9)
+/* from this point, constants are in no particular order */
+#define _PC_ALLOC_SIZE_MIN ( 10)
+#define _PC_ASYNC_IO ( 11)
+#define _PC_FILESIZEBITS ( 12)
+#define _PC_PRIO_IO ( 13)
+#define _PC_REC_INCR_XFER_SIZE ( 14)
+#define _PC_REC_MAX_XFER_SIZE ( 15)
+#define _PC_REC_MIN_XFER_SIZE ( 16)
+#define _PC_REC_XFER_ALIGN ( 17)
+#define _PC_SYNC_IO ( 18)
+
+/*
+ constants for sysconf()
+ */
+/* constants 1 to 10 are the same as in Microsoft POSIX */
+#define _SC_ARG_MAX ( 1)
+#define _SC_CHILD_MAX ( 2)
+#define _SC_CLK_TCK ( 3)
+#define _SC_NGROUPS_MAX ( 4)
+#define _SC_OPEN_MAX ( 5)
+#define _SC_JOB_CONTROL ( 6)
+#define _SC_SAVED_IDS ( 7)
+#define _SC_STREAM_MAX ( 8)
+#define _SC_TZNAME_MAX ( 9)
+#define _SC_VERSION ( 10)
+/* from this point, constants are in no particular order */
+#define _SC_2_C_BIND ( 11)
+#define _SC_2_C_DEV ( 12)
+#define _SC_2_C_VERSION ( 13)
+#define _SC_2_FORT_DEV ( 14)
+#define _SC_2_FORT_RUN ( 15)
+#define _SC_2_LOCALEDEF ( 16)
+#define _SC_2_SW_DEV ( 17)
+#define _SC_2_UPE ( 18)
+#define _SC_2_VERSION ( 19)
+#define _SC_AIO_LISTIO_MAX ( 20)
+#define _SC_AIO_MAX ( 21)
+#define _SC_AIO_PRIO_DELTA_MAX ( 22)
+#define _SC_ASYNCHRONOUS_IO ( 23)
+#define _SC_ATEXIT_MAX ( 24)
+#define _SC_BC_BASE_MAX ( 25)
+#define _SC_BC_DIM_MAX ( 26)
+#define _SC_BC_SCALE_MAX ( 27)
+#define _SC_BC_STRING_MAX ( 28)
+#define _SC_COLL_WEIGHTS_MAX ( 29)
+#define _SC_DELAYTIMER_MAX ( 30)
+#define _SC_EXPR_NEST_MAX ( 31)
+#define _SC_FSYNC ( 32)
+#define _SC_GETGR_R_SIZE_MAX ( 33)
+#define _SC_GETPW_R_SIZE_MAX ( 34)
+#define _SC_IOV_MAX ( 35)
+#define _SC_LINE_MAX ( 36)
+#define _SC_LOGIN_NAME_MAX ( 37)
+#define _SC_MAPPED_FILES ( 38)
+#define _SC_MEMLOCK ( 39)
+#define _SC_MEMLOCK_RANGE ( 40)
+#define _SC_MEMORY_PROTECTION ( 41)
+#define _SC_MESSAGE_PASSING ( 42)
+#define _SC_MQ_OPEN_MAX ( 43)
+#define _SC_MQ_PRIO_MAX ( 44)
+#define _SC_PAGE_SIZE ( 45)
+#define _SC_PASS_MAX ( 46) /* LEGACY */
+#define _SC_PRIORITIZED_IO ( 47)
+#define _SC_PRIORITY_SCHEDULING ( 48)
+#define _SC_RE_DUP_MAX ( 49)
+#define _SC_REALTIME_SIGNALS ( 50)
+#define _SC_RTSIG_MAX ( 51)
+#define _SC_SEMAPHORES ( 52)
+#define _SC_SEM_NSEMS_MAX ( 53)
+#define _SC_SEM_VALUE_MAX ( 54)
+#define _SC_SHARED_MEMORY_OBJECTS ( 55)
+#define _SC_SIGQUEUE_MAX ( 56)
+#define _SC_SYNCHRONIZED_IO ( 57)
+#define _SC_THREADS ( 58)
+#define _SC_THREAD_ATTR_STACKADDR ( 59)
+#define _SC_THREAD_ATTR_STACKSIZE ( 60)
+#define _SC_THREAD_DESTRUCTOR_ITERATIONS ( 61)
+#define _SC_THREAD_KEYS_MAX ( 62)
+#define _SC_THREAD_PRIORITY_SCHEDULING ( 63)
+#define _SC_THREAD_PRIO_INHERIT ( 64)
+#define _SC_THREAD_PRIO_PROTECT ( 65)
+#define _SC_THREAD_PROCESS_SHARED ( 66)
+#define _SC_THREAD_SAFE_FUNCTIONS ( 67)
+#define _SC_THREAD_STACK_MIN ( 68)
+#define _SC_THREAD_THREADS_MAX ( 69)
+#define _SC_TIMERS ( 70)
+#define _SC_TIMER_MAX ( 71)
+#define _SC_TTY_NAME_MAX ( 72)
+#define _SC_XOPEN_VERSION ( 73)
+#define _SC_XOPEN_CRYPT ( 74)
+#define _SC_XOPEN_ENH_I18N ( 75)
+#define _SC_XOPEN_SHM ( 76)
+#define _SC_XOPEN_UNIX ( 77)
+#define _SC_XOPEN_XCU_VERSION ( 78)
+#define _SC_XOPEN_LEGACY ( 79)
+#define _SC_XOPEN_REALTIME ( 80)
+#define _SC_XOPEN_REALTIME_THREADS ( 81)
+#define _SC_XBS5_ILP32_OFF32 ( 82)
+#define _SC_XBS5_ILP32_OFFBIG ( 83)
+#define _SC_XBS5_LP64_OFF64 ( 84)
+#define _SC_XBS5_LPBIG_OFFBIG ( 85)
+
+
+#define _SC_PAGESIZE _SC_PAGE_SIZE
+
+/* possible values for the function argument to the lockf() function */
+#define F_LOCK (1) /* Lock a section for exclusive use. */
+#define F_ULOCK (2) /* Unlock locked sections. */
+#define F_TEST (3) /* Test section for locks by other processes. */
+#define F_TLOCK (4) /* Test and lock a section for exclusive use. */
+
+#define STDIN_FILENO (0) /* File number of stdin. */
+#define STDOUT_FILENO (1) /* File number of stdout. */
+#define STDERR_FILENO (2) /* File number of stderr. */
+
+/* PROTOTYPES */
+int access(const char *, int);
+unsigned int alarm(unsigned int);
+int brk(void *);
+int chdir(const char *);
+int chroot(const char *); /* LEGACY */
+int chown(const char *, uid_t, gid_t);
+int close(int);
+size_t confstr(int, char *, size_t);
+char *crypt(const char *, const char *);
+char *ctermid(char *);
+char *cuserid(char *s); /* LEGACY */
+int dup(int);
+int dup2(int, int);
+void encrypt(char[64], int);
+int execl(const char *, const char *, ...);
+int execle(const char *, const char *, ...);
+int execlp(const char *, const char *, ...);
+int execv(const char *, char *const []);
+int execve(const char *, char *const [], char *const []);
+int execvp(const char *, char *const []);
+void _exit(int);
+int fchown(int, uid_t, gid_t);
+int fchdir(int);
+int fdatasync(int);
+pid_t fork(void);
+long int fpathconf(int, int);
+int fsync(int);
+int ftruncate(int, off_t);
+char *getcwd(char *, size_t);
+int getdtablesize(void); /* LEGACY */
+gid_t getegid(void);
+uid_t geteuid(void);
+gid_t getgid(void);
+int getgroups(int, gid_t []);
+long gethostid(void);
+char *getlogin(void);
+int getlogin_r(char *, size_t);
+int getopt(int, char * const [], const char *);
+int getpagesize(void); /* LEGACY */
+char *getpass(const char *); /* LEGACY */
+pid_t getpgid(pid_t);
+pid_t getpgrp(void);
+pid_t getpid(void);
+pid_t getppid(void);
+pid_t getsid(pid_t);
+uid_t getuid(void);
+char *getwd(char *);
+int isatty(int);
+int lchown(const char *, uid_t, gid_t);
+int link(const char *, const char *);
+int lockf(int, int, off_t);
+off_t lseek(int, off_t, int);
+int nice(int);
+long int pathconf(const char *, int);
+int pause(void);
+int pipe(int [2]);
+ssize_t pread(int, void *, size_t, off_t);
+int pthread_atfork(void (*)(void), void (*)(void),
+ void(*)(void));
+ssize_t pwrite(int, const void *, size_t, off_t);
+ssize_t read(int, void *, size_t);
+int readlink(const char *, char *, size_t);
+int rmdir(const char *);
+void *sbrk(intptr_t);
+int setgid(gid_t);
+int setpgid(pid_t, pid_t);
+pid_t setpgrp(void);
+int setregid(gid_t, gid_t);
+int setreuid(uid_t, uid_t);
+pid_t setsid(void);
+int setuid(uid_t);
+unsigned int sleep(unsigned int);
+void swab(const void *, void *, ssize_t);
+int symlink(const char *, const char *);
+void sync(void);
+long int sysconf(int);
+pid_t tcgetpgrp(int);
+int tcsetpgrp(int, pid_t);
+int truncate(const char *, off_t);
+char *ttyname(int);
+int ttyname_r(int, char *, size_t);
+useconds_t ualarm(useconds_t, useconds_t);
+int unlink(const char *);
+int usleep(useconds_t);
+pid_t vfork(void);
+ssize_t write(int, const void *, size_t);
+
+/* MACROS */
+
+#endif /* __UNISTD_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: utime.h,v 1.4 2002/10/29 04:45:26 rex Exp $
+ */
+/*
+ * utime.h
+ *
+ * access and modification times structure. Conforming to the Single
+ * UNIX(r) Specification Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __UTIME_H_INCLUDED__
+#define __UTIME_H_INCLUDED__
+
+/* INCLUDES */
+#include <sys/types.h>
+
+/* OBJECTS */
+
+/* TYPES */
+struct utimbuf
+{
+ time_t actime; /* access time */
+ time_t modtime; /* modification time */
+};
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+int utime(const char *, const struct utimbuf *);
+
+/* MACROS */
+
+#endif /* __UTIME_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+/* $Id: wchar.h,v 1.4 2002/10/29 04:45:26 rex Exp $
+ */
+/*
+ * wchar.h
+ *
+ * wide-character types. Conforming to the Single UNIX(r) Specification
+ * Version 2, System Interface & Headers Issue 5
+ *
+ * This file is part of the ReactOS Operating System.
+ *
+ * Contributors:
+ * Created by KJK::Hyperion <noog@libero.it>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef __WCHAR_H_INCLUDED__
+#define __WCHAR_H_INCLUDED__
+
+/* INCLUDES */
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stddef.h>
+#include <time.h>
+
+/* OBJECTS */
+
+/* TYPES */
+typedef wchar_t wint_t; /* An integral type capable of storing any valid
+ value of wchar_t, or WEOF */
+typedef long int wctype_t; /* A scalar type of a data object that can hold
+ values which represent locale-specific
+ character classification. */
+typedef void * mbstate_t; /* An object type other than an array type that
+ can hold the conversion state information
+ necessary to convert between sequences of
+ (possibly multibyte) characters and
+ wide-characters */
+
+/* CONSTANTS */
+
+/* PROTOTYPES */
+wint_t btowc(int);
+int fwprintf(FILE *, const wchar_t *, ...);
+int fwscanf(FILE *, const wchar_t *, ...);
+int iswalnum(wint_t);
+int iswalpha(wint_t);
+int iswcntrl(wint_t);
+int iswdigit(wint_t);
+int iswgraph(wint_t);
+int iswlower(wint_t);
+int iswprint(wint_t);
+int iswpunct(wint_t);
+int iswspace(wint_t);
+int iswupper(wint_t);
+int iswxdigit(wint_t);
+int iswctype(wint_t, wctype_t);
+wint_t fgetwc(FILE *);
+wchar_t *fgetws(wchar_t *, int, FILE *);
+wint_t fputwc(wchar_t, FILE *);
+int fputws(const wchar_t *, FILE *);
+int fwide(FILE *, int);
+wint_t getwc(FILE *);
+wint_t getwchar(void);
+int mbsinit(const mbstate_t *);
+size_t mbrlen(const char *, size_t, mbstate_t *);
+size_t mbrtowc(wchar_t *, const char *, size_t,
+ mbstate_t *);
+size_t mbsrtowcs(wchar_t *, const char **, size_t,
+ mbstate_t *);
+wint_t putwc(wchar_t, FILE *);
+wint_t putwchar(wchar_t);
+int swprintf(wchar_t *, size_t, const wchar_t *, ...);
+int swscanf(const wchar_t *, const wchar_t *, ...);
+wint_t towlower(wint_t);
+wint_t towupper(wint_t);
+wint_t ungetwc(wint_t, FILE *);
+int vfwprintf(FILE *, const wchar_t *, va_list);
+int vwprintf(const wchar_t *, va_list);
+int vswprintf(wchar_t *, size_t, const wchar_t *,
+ va_list);
+size_t wcrtomb(char *, wchar_t, mbstate_t *);
+wchar_t *wcscat(wchar_t *, const wchar_t *);
+wchar_t *wcschr(const wchar_t *, wchar_t);
+int wcscmp(const wchar_t *, const wchar_t *);
+int wcscoll(const wchar_t *, const wchar_t *);
+wchar_t *wcscpy(wchar_t *, const wchar_t *);
+size_t wcscspn(const wchar_t *, const wchar_t *);
+size_t wcsftime(wchar_t *, size_t, const wchar_t *,
+ const struct tm *);
+size_t wcslen(const wchar_t *);
+wchar_t *wcsncat(wchar_t *, const wchar_t *, size_t);
+int wcsncmp(const wchar_t *, const wchar_t *, size_t);
+wchar_t *wcsncpy(wchar_t *, const wchar_t *, size_t);
+wchar_t *wcspbrk(const wchar_t *, const wchar_t *);
+wchar_t *wcsrchr(const wchar_t *, wchar_t);
+size_t wcsrtombs(char *, const wchar_t **, size_t,
+ mbstate_t *);
+size_t wcsspn(const wchar_t *, const wchar_t *);
+wchar_t *wcsstr(const wchar_t *, const wchar_t *);
+double wcstod(const wchar_t *, wchar_t **);
+wchar_t *wcstok(wchar_t *, const wchar_t *, wchar_t **);
+long int wcstol(const wchar_t *, wchar_t **, int);
+unsigned long int wcstoul(const wchar_t *, wchar_t **, int);
+wchar_t *wcswcs(const wchar_t *, const wchar_t *);
+int wcswidth(const wchar_t *, size_t);
+size_t wcsxfrm(wchar_t *, const wchar_t *, size_t);
+int wctob(wint_t);
+wctype_t wctype(const char *);
+int wcwidth(wchar_t);
+wchar_t *wmemchr(const wchar_t *, wchar_t, size_t);
+int wmemcmp(const wchar_t *, const wchar_t *, size_t);
+wchar_t *wmemcpy(wchar_t *, const wchar_t *, size_t);
+wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t);
+wchar_t *wmemset(wchar_t *, wchar_t, size_t);
+int wprintf(const wchar_t *, ...);
+int wscanf(const wchar_t *, ...);
+
+/* MACROS */
+#define WCHAR_MAX (0xFFFF)
+#define WCHAR_MIN (0x0000)
+
+/* FIXME? */
+#define WEOF (0xFFFF)
+
+#endif /* __WCHAR_H_INCLUDED__ */
+
+/* EOF */
+
--- /dev/null
+# $Id: Makefile,v 1.3 2002/10/29 04:45:26 rex Exp $
+# posix/lib/Makefile
+#
+PATH_TO_TOP=../../reactos
+
+PATH_TO_PSX_TOP = ../..
+
+all:
+ make -C psxdll psxdll.a
+ make -C psxx psxx.a
+
+clean:
+ - $(RM) *.a
+
+include $(PATH_TO_TOP)/rules.mak
+
+# EOF
--- /dev/null
+/* $Id: crt0w32.c,v 1.4 2002/10/29 04:45:26 rex Exp $
+ *
+ * PROJECT : ReactOS / POSIX+ personality
+ * FILE : subsys/psx/lib/crt0w32.c
+ * DESCRIPTION: startup code for POSIX+ applications.
+ * DATE : 2002-01-18
+ * AUTHOR : Emanuele Aliberti <eal@users.sf.net>
+ */
+
+extern void __stdcall __PdxInitializeData(int*,char***);
+extern int main (int,char**,char**);
+extern void exit(int);
+
+/* ANSI ENVIRONMENT */
+
+char **_environ = (char**) 0;
+
+int errno = 0;
+
+#ifdef __SUBSYSTEM_WINDOWS__
+void WinMainCRTStartup (void)
+#else
+void mainCRTStartup (void)
+#endif
+{
+ char * argv[2] = {"none", 0};
+
+ /* TODO: parse the command line */
+ exit(main(1,argv,0));
+}
+
+void __main ()
+{
+ /*
+ * Store in PSXDLL.DLL two well known global symbols
+ * references.
+ */
+ __PdxInitializeData (& errno, & _environ); /* PSXDLL.__PdxInitializeData */
+ /* CRT initialization. */
+#ifdef __SUBSYSTEM_WINDOWS__
+ WinMainCRTStartup ();
+#else
+ mainCRTStartup ();
+#endif
+}
+/* EOF */
--- /dev/null
+# $Id: Makefile,v 1.13 2002/10/29 04:45:26 rex Exp $
+
+PATH_TO_TOP = ../../../reactos
+
+PATH_TO_PSX_TOP = ../..
+
+TARGET_TYPE = dynlink
+
+TARGET_NAME = psxdll
+
+TARGET_LIBPATH = $(PATH_TO_TOP)/dk/psx/lib
+
+TARGET_LFLAGS = -nostartfiles
+
+TARGET_SDKLIBS = ntdll.a
+
+TARGET_BASE = 0x68EB0000
+
+TARGET_ENTRY = _DllMain@12
+
+TARGET_CFLAGS =\
+ -Wall \
+ -nostdinc \
+ -nostdlib \
+ -fno-builtin \
+ -I$(PATH_TO_PSX_TOP)/include \
+ -I$(PATH_TO_TOP)/include \
+ -D__PSXDLL__ \
+ -D__PSX_DEBUG_WANT_ALL__
+
+TARGET_OBJECTS = $(TARGET_NAME).o
+
+TARGET_CLEAN = $(OBJECTS) csrapi.a
+
+include $(PATH_TO_TOP)/rules.mak
+include $(TOOLS_PATH)/helper.mk
+
+OBJECTS_MISC = \
+ misc/main.o \
+ misc/init.o \
+ misc/heap.o \
+ misc/interlock.o \
+ misc/safeobj.o \
+ misc/spawn.o \
+ misc/path.o \
+ misc/pdata.o \
+ misc/fdtable.o \
+ misc/tls.o
+
+OBJECTS_DIRENT = \
+ dirent/opendir.o \
+ dirent/readdir.o \
+ dirent/closedir.o
+
+OBJECTS_DLFCN = \
+ dlfcn/dlopen.o \
+ dlfcn/dlclose.o \
+ dlfcn/dlsym.o \
+ dlfcn/dlerror.o
+
+OBJECTS_ERRNO = \
+ errno/errno.o
+
+OBJECTS_FCNTL = \
+ fcntl/open.o \
+ fcntl/fcntl.o
+
+OBJECTS_LIBGEN = \
+ libgen/basename.o
+
+OBJECTS_SCHED = \
+ sched/yield.o
+
+OBJECTS_SIGNAL = \
+ pthread/kill.o \
+ signal/raise.o
+
+OBJECTS_STDLIB = \
+ stdlib/abort.o \
+ stdlib/malloc.o \
+ stdlib/exit.o
+
+OBJECTS_STRING = \
+ string/strdup.o \
+ string/strerror.o
+
+OBJECTS_PTHREAD = \
+ pthread/create.o \
+ pthread/exit.o \
+ pthread/join.o \
+ pthread/mutex.o \
+ pthread/self.o
+
+OBJECTS_SYS_STAT = \
+ sys/stat/chmod.o \
+ sys/stat/mkdir.o \
+ sys/stat/mkfifo.o \
+ sys/stat/mknod.o \
+ sys/stat/stat.o \
+ sys/stat/umask.o
+
+OBJECTS_SYS_UTSNAME = \
+ sys/utsname/uname.o
+
+OBJECTS_UNISTD = \
+ unistd/access.o \
+ unistd/close.o \
+ unistd/dup.o \
+ unistd/fork.o \
+ unistd/getcwd.o \
+ unistd/getpid.o \
+ unistd/getppid.o \
+ unistd/read.o \
+ unistd/sleep.o \
+ unistd/write.o
+
+OBJECTS = \
+ $(OBJECTS_MISC) \
+ $(OBJECTS_DIRENT) \
+ $(OBJECTS_DLFCN) \
+ $(OBJECTS_ERRNO) \
+ $(OBJECTS_FCNTL) \
+ $(OBJECTS_LIBGEN) \
+ $(OBJECTS_SCHED) \
+ $(OBJECTS_SIGNAL) \
+ $(OBJECTS_STDLIB) \
+ $(OBJECTS_STRING) \
+ $(OBJECTS_PTHREAD) \
+ $(OBJECTS_SYS_STAT) \
+ $(OBJECTS_SYS_UTSNAME) \
+ $(OBJECTS_UNISTD)
+
+DEP_OBJECTS = $(OBJECTS)
+
+include $(TOOLS_PATH)/depend.mk
+
+DTFLAGS = -k -l $@
+
+$(TARGET_NAME).a: $(TARGET_NAME).def
+ $(DLLTOOL) \
+ $(DTFLAGS) \
+ -D $(TARGET_NAME).dll \
+ -d $(TARGET_NAME).def
+
+csrapi.a: csrapi.def
+ $(DLLTOOL) \
+ $(DTFLAGS) \
+ -D ntdll.dll \
+ -d csrapi.def
+
+$(TARGET_NAME).o: csrapi.a $(OBJECTS)
+ $(LD) -r $(OBJECTS) -o $(TARGET_NAME).o
+
+
+# EOF
--- /dev/null
+; $Id: csrapi.def,v 1.3 2002/10/29 04:45:26 rex Exp $
+
+LIBRARY NTDLL.DLL
+EXPORTS
+
+CsrClientCallServer@16
\ No newline at end of file
--- /dev/null
+/* $Id: closedir.c,v 1.4 2002/10/29 04:45:28 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/dirent/closedir.c
+ * PURPOSE: Close a directory stream
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 01/02/2002: Created
+ * 13/02/2002: KJK::Hyperion: modified to use file descriptors
+ */
+
+#include <dirent.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <psx/dirent.h>
+#include <psx/safeobj.h>
+
+int closedir(DIR *dirp)
+{
+ /* check the "magic" signature */
+ if(!__safeobj_validate(dirp, __IDIR_MAGIC))
+ {
+ errno = EBADF;
+ return (-1);
+ }
+
+ /* this will close the handle, deallocate the internal object and
+ invalidate the descriptor */
+ return (close(((struct __internal_DIR *)dirp)->fildes));
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: opendir.c,v 1.4 2002/10/29 04:45:28 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/dirent/opendir.c
+ * PURPOSE: Open a directory
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 27/01/2002: Created
+ * 13/02/2002: KJK::Hyperion: modified to use file descriptors
+ */
+
+#include <sys/types.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <wchar.h>
+#include <errno.h>
+#include <psx/debug.h>
+#include <psx/stdlib.h>
+#include <psx/dirent.h>
+#include <psx/safeobj.h>
+
+DIR *opendir(const char *dirname)
+{
+ ANSI_STRING strDirName;
+ UNICODE_STRING wstrDirName;
+ DIR *pdData;
+
+ RtlInitAnsiString(&strDirName, (PCSZ)dirname);
+ RtlAnsiStringToUnicodeString(&wstrDirName, &strDirName, TRUE);
+
+ pdData = (DIR *)_Wopendir(wstrDirName.Buffer);
+
+ RtlFreeUnicodeString(&wstrDirName);
+
+ return (pdData);
+
+}
+
+DIR *_Wopendir(const wchar_t *dirname)
+{
+ struct __internal_DIR *pidData;
+ int nFileNo;
+
+ /* allocate internal object */
+ pidData = __malloc(sizeof(*pidData));
+
+ /* allocation failed */
+ if(pidData == 0)
+ {
+ errno = ENOMEM;
+ return (0);
+ }
+
+ /* open the directory */
+ nFileNo = _Wopen(dirname, O_RDONLY | _O_DIRFILE);
+
+ /* failure */
+ if(nFileNo < 0)
+ {
+ __free(pidData);
+ return (0);
+ }
+
+ /* directory file descriptors must be closed on exec() */
+ if(fcntl(nFileNo, F_SETFD, FD_CLOEXEC) == -1)
+ WARN
+ (
+ "couldn't set FD_CLOEXEC flag on file number %u, errno %u",
+ nFileNo,
+ errno
+ );
+
+ /* associate the internal data to the file descriptor */
+ if(fcntl(nFileNo, F_SETXP, pidData) == -1)
+ WARN
+ (
+ "couldn't associate the object at 0x%X to the file number %u, errno %u",
+ pidData,
+ nFileNo,
+ errno
+ );
+
+ if(fcntl(nFileNo, F_SETXS, sizeof(*pidData)) == -1)
+ WARN
+ (
+ "couldn't set the extra data size of the file number %u, errno %u",
+ nFileNo,
+ errno
+ );
+
+ pidData->signature = __IDIR_MAGIC;
+
+ /* success */
+ return ((DIR *)pidData);
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: readdir.c,v 1.7 2002/10/29 04:45:28 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/dirent/readdir.c
+ * PURPOSE: Read directory
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 27/01/2002: Created
+ * 13/02/2002: KJK::Hyperion: modified to use file descriptors
+ */
+
+#include <sys/types.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <dirent.h>
+#include <psx/dirent.h>
+#include <psx/debug.h>
+#include <psx/errno.h>
+#include <psx/safeobj.h>
+#include <ddk/ntddk.h>
+
+struct dirent *readdir(DIR *dirp)
+{
+ struct _Wdirent *lpwdReturn;
+ struct __internal_DIR *pidData;
+ ANSI_STRING strFileName;
+ UNICODE_STRING wstrFileName;
+ NTSTATUS nErrCode;
+
+ /* call Unicode function */
+ lpwdReturn = _Wreaddir(dirp);
+
+ /* failure */
+ if(lpwdReturn == 0)
+ return (0);
+
+ /* get the internal data object */
+ pidData = ((struct __internal_DIR *)dirp);
+
+ /* create NT Unicode string from the Unicode dirent's buffer */
+ RtlInitUnicodeString(&wstrFileName, pidData->ent.de_unicode.d_name);
+
+ /* HACK: make the ANSI string point to the same buffer where the Unicode string is stored */
+ strFileName.Buffer = (PCSZ)&pidData->info.FileName[0];
+ strFileName.Length = 0;
+ strFileName.MaximumLength = MAX_PATH;
+
+ /* convert the filename to ANSI */
+ nErrCode = RtlUnicodeStringToAnsiString(&strFileName, &wstrFileName, FALSE);
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ errno = __status_to_errno(nErrCode);
+ return (0);
+ }
+
+ /* make the ANSI dirent filename point to the ANSI buffer */
+ pidData->ent.de_ansi.d_name = strFileName.Buffer;
+
+ /* null-terminate the ANSI name */
+ pidData->ent.de_ansi.d_name[strFileName.Length] = 0;
+
+ /* success */
+ return (&(pidData->ent.de_ansi));
+}
+
+int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
+{
+ errno = ENOSYS;
+ return (0);
+}
+
+struct _Wdirent *_Wreaddir(DIR *dirp)
+{
+ HANDLE hFile;
+ HANDLE hDir;
+ OBJECT_ATTRIBUTES oaFileAttribs;
+ UNICODE_STRING wstrFileName;
+ FILE_INTERNAL_INFORMATION fiiInfo;
+ IO_STATUS_BLOCK isbStatus;
+ NTSTATUS nErrCode;
+ struct __internal_DIR *pidData;
+
+ /* check the "magic" signature */
+ if(!__safeobj_validate(dirp, __IDIR_MAGIC))
+ {
+ errno = EINVAL;
+ return (0);
+ }
+
+ /* get internal data */
+ pidData = (struct __internal_DIR *)dirp;
+
+ /* get handle */
+ hDir = (HANDLE)fcntl(pidData->fildes, F_GETFH);
+
+ /* failure */
+ if(((int)hDir) == -1)
+ return (0);
+
+ /* read next directory entry */
+ nErrCode = NtQueryDirectoryFile
+ (
+ hDir,
+ NULL,
+ NULL,
+ NULL,
+ &isbStatus,
+ (PVOID)&pidData->info,
+ sizeof(pidData->info) + sizeof(WCHAR) * (MAX_PATH - 1),
+ FileDirectoryInformation,
+ TRUE,
+ NULL,
+ FALSE
+ );
+
+ /* failure or EOF */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ if(nErrCode == (NTSTATUS)STATUS_NO_MORE_FILES)
+ return (0);
+ else
+ {
+ ERR("NtQueryDirectoryFile() failed with status 0x%08X", nErrCode);
+ errno = __status_to_errno(nErrCode);
+ return (0);
+ }
+ }
+
+ /* null-terminate the filename, just in case */
+ pidData->info.FileName[pidData->info.FileNameLength / sizeof(WCHAR)] = 0;
+
+ INFO("this entry: %ls", pidData->info.FileName);
+
+ /* file inodes are not returned by NtQueryDirectoryFile, we have to open every file */
+ /* set file's object attributes */
+ wstrFileName.Length = pidData->info.FileNameLength;
+ wstrFileName.MaximumLength = sizeof(WCHAR) * MAX_PATH;
+ wstrFileName.Buffer = &pidData->info.FileName[0];
+
+ oaFileAttribs.Length = sizeof(OBJECT_ATTRIBUTES);
+ oaFileAttribs.RootDirectory = hDir;
+ oaFileAttribs.ObjectName = &wstrFileName;
+ oaFileAttribs.Attributes = 0;
+ oaFileAttribs.SecurityDescriptor = NULL;
+ oaFileAttribs.SecurityQualityOfService = NULL;
+
+ /* open the file */
+ nErrCode = NtOpenFile
+ (
+ &hFile,
+ FILE_READ_ATTRIBUTES | SYNCHRONIZE,
+ &oaFileAttribs,
+ &isbStatus,
+ 0,
+ FILE_SYNCHRONOUS_IO_NONALERT
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtOpenFile() failed with status %#X", nErrCode);
+ errno = __status_to_errno(nErrCode);
+ return (0);
+ }
+
+ /* get the internal information for the file */
+ nErrCode = NtQueryInformationFile
+ (
+ hFile,
+ &isbStatus,
+ &fiiInfo,
+ sizeof(FILE_INTERNAL_INFORMATION),
+ FileInternalInformation
+ );
+
+ /* close the handle (not needed anymore) */
+ NtClose(hFile);
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtQueryInformationFile() failed with status %#X", nErrCode);
+ errno = __status_to_errno(nErrCode);
+ return (0);
+ }
+
+ /* return file inode */
+ pidData->ent.de_unicode.d_ino = (ino_t)fiiInfo.IndexNumber.QuadPart;
+
+ /* return file name */
+ pidData->ent.de_unicode.d_name = &pidData->info.FileName[0];
+
+ /* success */
+ return &(pidData->ent.de_unicode);
+}
+
+int _Wreaddir_r(DIR *dirp, struct _Wdirent *entry, struct _Wdirent **result)
+{
+ errno = ENOSYS;
+ return (0);
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: dlclose.c,v 1.4 2002/10/29 04:45:28 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/dlfcn/dlclose.c
+ * PURPOSE: Close a dlopen() object
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 19/12/2001: Created
+ */
+
+#include <ddk/ntddk.h>
+#include <ntdll/rtl.h>
+#include <ntdll/ldr.h>
+#include <dlfcn.h>
+#include <stdlib.h>
+#include <psx/debug.h>
+#include <psx/dlfcn.h>
+#include <psx/errno.h>
+
+int dlclose(void *handle)
+{
+ if(handle == 0)
+ {
+ ERR("invalid handle passed to dlclose");
+
+ __dl_set_last_error(EFAULT); /* FIXME? maybe EINVAL? */
+ return (-1);
+ }
+
+ if(((struct __dlobj *)handle)->global)
+ {
+ TODO("global symbol matching not implemented");
+
+ __dl_set_last_error(EINVAL);
+ return (-1);
+ }
+ else
+ {
+ NTSTATUS nErrCode = LdrUnloadDll(((struct __dlobj *)handle)->handle);
+
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("LdrUnloadDll(%#x) failed with status %d", ((struct __dlobj *)handle)->handle, nErrCode);
+
+ free(handle);
+ __dl_set_last_error(__status_to_errno(nErrCode));
+ return (-1);
+ }
+ }
+
+ free(handle);
+
+ return (0);
+
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: dlerror.c,v 1.4 2002/10/29 04:45:28 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/dlfcn/dlerror.c
+ * PURPOSE: Gain access to an executable object file
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 19/12/2001: Created
+ */
+
+#include <ddk/ntddk.h>
+#include <ntdll/rtl.h>
+#include <ntdll/ldr.h>
+#include <dlfcn.h>
+#include <string.h>
+#include <psx/debug.h>
+#include <psx/dlfcn.h>
+#include <psx/errno.h>
+
+static int __dl_last_error = 0;
+
+void __dl_set_last_error(int err)
+{
+ FIXME("dlfcn error handling not thread safe");
+ __dl_last_error = err;
+}
+
+char *dlerror(void)
+{
+ return strerror(__dl_last_error);
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: dlopen.c,v 1.4 2002/10/29 04:45:28 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/dlfcn/dlopen.c
+ * PURPOSE: Gain access to an executable object file
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 19/12/2001: Created
+ */
+
+#include <ddk/ntddk.h>
+#include <ntdll/rtl.h>
+#include <ntdll/ldr.h>
+#include <wchar.h>
+#include <dlfcn.h>
+#include <stdlib.h>
+#include <psx/dlfcn.h>
+#include <psx/errno.h>
+#include <psx/debug.h>
+
+void *__wdlopen(const wchar_t *, int);
+
+void *dlopen(const char *file, int mode)
+{
+ /* TODO: ANSI-to-Unicode stubs like this need to be standardized in some way */
+ void * pRetVal;
+ ANSI_STRING strFile;
+ UNICODE_STRING wstrFile;
+
+ RtlInitAnsiString(&strFile, (LPSTR)file);
+ RtlAnsiStringToUnicodeString (&wstrFile, &strFile, TRUE);
+
+ pRetVal = __wdlopen((wchar_t *)wstrFile.Buffer, mode);
+
+ free(wstrFile.Buffer);
+
+ return pRetVal;
+
+}
+
+void *__wdlopen(const wchar_t *file, int mode)
+{
+ NTSTATUS nErrCode;
+ UNICODE_STRING wstrNativePath;
+ struct __dlobj * pdloObject;
+
+ if(file == 0)
+ {
+ /* POSIX dynamic linking allows for global symbol matching */
+ pdloObject = (struct __dlobj *)malloc(sizeof(struct __dlobj));
+
+ TODO("\
+move the global symbol matching semantics into the PE Loader \
+(NTDLL Ldr family of calls), and just return a pointer to the module \
+image\
+");
+
+ pdloObject->global = 1;
+ return (pdloObject);
+ }
+
+ FIXME("\
+LdrLoadDll() only accepts DOS paths - probably because the POSIX \
+standard didn't specify dynamic linking interfaces at the time Windows NT \
+was born \
+");
+
+#if 0
+ /* TODO: LdrLoadNtDll() or LdrLoadDllEx() (the former is preferrable, since
+ the latter is more likely to be implemented with different purposes from
+ Microsoft), accepting native NT paths */
+
+ if(wcschr(file, '/'L) != NULL)
+ {
+ /* TODO: RtlPosixPathNameToNtPathName_U */
+ if(!RtlPosixPathNameToNtPathName_U((LPWSTR)file, &wstrNativePath, NULL, NULL))
+ {
+ __dl_set_last_error(ENOENT);
+ return (NULL);
+ }
+ }
+ else
+ {
+ RtlInitUnicodeString(&wstrNativePath, (LPWSTR)file);
+ }
+#endif
+
+ RtlInitUnicodeString(&wstrNativePath, (LPWSTR)file);
+
+ pdloObject = (struct __dlobj *)malloc(sizeof(struct __dlobj));
+ pdloObject->global = 0;
+
+ WARN("\
+mode flags are not fully supported by Windows NT, due to the \
+completely different semantics of dynamical linking (for \
+example the global symbol matching is unsupported). This \
+implementation will then behave as if mode was set to \
+(RTLD_NOW | RTLD_GLOBAL), and fail if other flags are set.\
+");
+
+ if(__dl_get_scope_flag(mode) == RTLD_LOCAL)
+ {
+ __dl_set_last_error(EINVAL);
+ return (NULL);
+ }
+
+ /* load the DLL */
+ nErrCode = LdrLoadDll
+ (
+ NULL,
+ 0,
+ &wstrNativePath,
+ (PVOID*)&pdloObject->handle
+ );
+
+ if(!NT_SUCCESS(nErrCode))
+ {
+ __dl_set_last_error(__status_to_errno(nErrCode));
+ return (NULL);
+ }
+
+ return (pdloObject);
+
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: dlsym.c,v 1.4 2002/10/29 04:45:30 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/dlfcn/dlsym.c
+ * PURPOSE: Obtain the address of a symbol from a dlopen() object
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 19/12/2001: Created
+ */
+
+#include <ddk/ntddk.h>
+#include <ntdll/rtl.h>
+#include <ntdll/ldr.h>
+#include <dlfcn.h>
+#include <psx/dlfcn.h>
+#include <psx/errno.h>
+#include <psx/debug.h>
+
+void *__dlsymn(void *, unsigned long int);
+void *__dlsym(void *, int, const char *, unsigned long int);
+
+void *dlsym(void *handle, const char *name)
+{
+ return (__dlsym(handle, 1, name, 0));
+}
+
+void *__dlsymn(void *handle, unsigned long int ordinal)
+{
+ return (__dlsym(handle, 0, 0, ordinal));
+}
+
+void *__dlsym(void *handle, int by_name, const char *name, unsigned long int ordinal)
+{
+ struct __dlobj * pdloObject;
+
+ void * pProcAddr;
+ NTSTATUS nErrCode;
+
+ if(handle == RTLD_NEXT)
+ {
+ FIXME("implement RTLD_NEXT semantics");
+ return (NULL);
+ }
+
+ pdloObject = (struct __dlobj *) handle;
+
+ if(pdloObject->global)
+ {
+ FIXME("implement global symbol matching");
+ return (NULL);
+ }
+
+ if(by_name)
+ {
+ ANSI_STRING strName;
+
+ RtlInitAnsiString(&strName, (LPSTR)name);
+
+ nErrCode = LdrGetProcedureAddress
+ (
+ pdloObject->handle,
+ &strName,
+ 0,
+ (PVOID *)&pProcAddr
+ );
+
+ }
+ else
+ {
+ nErrCode = LdrGetProcedureAddress
+ (
+ pdloObject->handle,
+ NULL,
+ ordinal,
+ (PVOID *)&pProcAddr
+ );
+ }
+
+ if(!NT_SUCCESS(nErrCode))
+ {
+ __dl_set_last_error(__status_to_errno(nErrCode));
+ return (NULL);
+ }
+
+ return pProcAddr;
+
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: errno.c,v 1.5 2002/10/29 04:45:31 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/errno/errno.c
+ * PURPOSE: Internal errno implementation
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 27/12/2001: Created
+ */
+
+#include <ddk/ntddk.h>
+#include <psx/pdata.h>
+#include <psx/errno.h>
+#include <psx/debug.h>
+
+int * __PdxGetThreadErrNum(void)
+{
+ return &(((__PPDX_TDATA) (NtCurrentTeb()->TlsSlots[__PdxGetProcessData()->TlsIndex]) )->ErrNum);
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: fcntl.c,v 1.7 2002/10/29 04:45:31 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/fcntl/fcntl.c
+ * PURPOSE: File control
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 13/02/2002: Created
+ * 15/02/2002: Implemented fcntl() (KJK::Hyperion)
+ */
+
+#include <ddk/ntddk.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <stdarg.h>
+#include <psx/errno.h>
+#include <psx/stdlib.h>
+#include <psx/fdtable.h>
+#include <psx/pdata.h>
+#include <psx/debug.h>
+
+int fcntl(int fildes, int cmd, ...)
+{
+ __fdtable_t *pftFdTable;
+ __fildes_t *pfdDescriptor;
+ NTSTATUS nErrCode;
+ int nRetVal;
+ int nThirdArg;
+ void *pThirdArg;
+ va_list vlArgs;
+
+ /* lock the environment */
+ __PdxAcquirePdataLock();
+ INFO("environment locked");
+
+ /* get the file descriptors table */
+ pftFdTable = &__PdxGetProcessData()->FdTable;
+ INFO("file descriptors table at 0x%08X", pftFdTable);
+
+ /* fildes is an invalid descriptor, or it's a closed or uninitialized
+ descriptor and the requested operation is not the creation of a new
+ descriptor */
+ if
+ (
+ fildes < 0 ||
+ fildes >= OPEN_MAX ||
+ (
+ (cmd != F_NEWFD) &&
+ (
+ __fdtable_entry_isavail(pftFdTable, fildes) == 0 ||
+ __fdtable_entry_get(pftFdTable, fildes) == 0
+ )
+ )
+ )
+ {
+ INFO("invalid file descriptor");
+ errno = EBADF;
+ __PdxReleasePdataLock();
+ return (-1);
+ }
+
+ /* get the file descriptor referenced by fildes */
+ pfdDescriptor = __fdtable_entry_get(pftFdTable, fildes);
+ INFO("file descriptor %d at 0x%08X", fildes, pftFdTable);
+
+ /* get third argument as integer */
+ va_start(vlArgs, cmd);
+ nThirdArg = va_arg(vlArgs, int);
+ va_end(vlArgs);
+
+ /* get third argument as pointer */
+ va_start(vlArgs, cmd);
+ pThirdArg = va_arg(vlArgs, void *);
+ va_end(vlArgs);
+
+ /* initialize return value */
+ nRetVal = -1;
+
+ switch(cmd)
+ {
+ case F_DUPFD:
+ {
+ int nDupFileNo;
+ __fildes_t *pfdDupDescriptor;
+
+ INFO("requested operation: F_DUPFD");
+
+ /* allocate the duplicated descriptor */
+ nDupFileNo = __fdtable_entry_add(pftFdTable, nThirdArg, 0, &pfdDupDescriptor);
+
+ if(nDupFileNo)
+ {
+ ERR("__fdtable_entry_add() failed, errno %d", errno);
+ break;
+ }
+
+ /* copy the open flags */
+ pfdDupDescriptor->OpenFlags = pfdDescriptor->OpenFlags;
+
+ /* clear the FD_CLOEXEC flag */
+ pfdDupDescriptor->FdFlags = pfdDescriptor->FdFlags & ~FD_CLOEXEC;
+
+ /* duplicate the extra data */
+ if(pfdDescriptor->ExtraDataSize != 0 && pfdDescriptor->ExtraData != 0)
+ {
+ /* allocate space for the duplicated extra data */
+ pfdDupDescriptor->ExtraDataSize = pfdDescriptor->ExtraDataSize;
+ pfdDupDescriptor->ExtraData = __malloc(pfdDupDescriptor->ExtraDataSize);
+
+ /* failure */
+ if(pfdDupDescriptor->ExtraData == 0)
+ {
+ errno = ENOMEM;
+ break;
+ }
+
+ /* copy the extra data */
+ memcpy(pfdDupDescriptor->ExtraData, pfdDescriptor->ExtraData, pfdDupDescriptor->ExtraDataSize);
+ INFO
+ (
+ "copied %u bytes from 0x%08X into 0x%08X",
+ pfdDupDescriptor->ExtraDataSize,
+ pfdDescriptor->ExtraData,
+ pfdDupDescriptor->ExtraData
+ );
+ }
+
+ /* duplicate the handle */
+ nErrCode = NtDuplicateObject
+ (
+ NtCurrentProcess(),
+ pfdDescriptor->FileHandle,
+ NtCurrentProcess(),
+ &pfdDupDescriptor->FileHandle,
+ 0,
+ 0,
+ DUPLICATE_SAME_ACCESS /* | DUPLICATE_SAME_ATTRIBUTES */
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ __free(pfdDupDescriptor->ExtraData);
+ errno = __status_to_errno(nErrCode);
+ break;
+ }
+
+ INFO
+ (
+ "duplicated handle 0x%08X into handle 0x%08X",
+ pfdDescriptor->FileHandle,
+ pfdDupDescriptor->FileHandle
+ );
+
+ /* return the duplicated file number */
+ nRetVal = nDupFileNo;
+ break;
+ }
+
+ case F_GETFD:
+ {
+ INFO("requested operation: F_GETFD");
+ nRetVal = pfdDescriptor->FdFlags;
+ break;
+ }
+
+ case F_SETFD:
+ {
+ INFO("requested operation: F_SETFD");
+ pfdDescriptor->FdFlags = nThirdArg;
+ nRetVal = 0;
+ break;
+ }
+
+ case F_GETFL:
+ {
+ INFO("requested operation: F_GETFL");
+ nRetVal = pfdDescriptor->OpenFlags;
+ break;
+ }
+
+ case F_SETFL:
+ {
+ INFO("requested operation: F_SETFL");
+ pfdDescriptor->OpenFlags = nThirdArg;
+ nRetVal = 0;
+ break;
+ }
+
+ case F_GETLK:
+ {
+ INFO("requested operation: F_GETLK");
+ errno = EINVAL;
+ break;
+ }
+
+ case F_SETLK:
+ {
+ INFO("requested operation: F_SETLK");
+ errno = EINVAL;
+ break;
+ }
+
+ case F_SETLKW:
+ {
+ INFO("requested operation: F_SETLKW");
+ errno = EINVAL;
+ break;
+ }
+
+ case F_NEWFD:
+ {
+ INFO("requested operation: F_NEWFD");
+ /* allocate a new descriptor */
+ nRetVal = __fdtable_entry_add(pftFdTable, fildes, (__fildes_t *)pThirdArg, 0);
+ break;
+ }
+
+ case F_DELFD:
+ {
+ INFO("requested operation: F_DELFD");
+ /* invalid return pointer */
+ if(pThirdArg == 0)
+ {
+ errno = EINVAL;
+ break;
+ }
+
+ memcpy((__fildes_t *)pThirdArg, pfdDescriptor, sizeof(*pfdDescriptor));
+
+ /* remove file descriptor */
+ nRetVal = __fdtable_entry_remove(pftFdTable, fildes);
+
+ }
+
+ case F_GETALL:
+ {
+ INFO("requested operation: F_GETALL");
+ /* invalid return pointer */
+ if(pThirdArg == 0)
+ {
+ errno = EINVAL;
+ break;
+ }
+
+ /* return a copy of the file descriptor */
+ memcpy((__fildes_t *)pThirdArg, pfdDescriptor, sizeof(*pfdDescriptor));
+ nRetVal = 0;
+
+ break;
+ }
+
+ case F_SETALL:
+ {
+ INFO("requested operation: F_SETALL");
+ /* invalid file descriptor to copy attributes from */
+ if(pThirdArg == 0)
+ {
+ errno = EINVAL;
+ break;
+ }
+
+ /* copy the attributes of file descriptor from the provided descriptor */
+ memcpy(pfdDescriptor, pThirdArg, sizeof(*pfdDescriptor));
+ nRetVal = 0;
+
+ break;
+ }
+
+ case F_GETXP:
+ {
+ INFO("requested operation: F_GETXP");
+ /* invalid return pointer */
+ if(pThirdArg == 0)
+ {
+ errno = EINVAL;
+ break;
+ }
+
+ /* return a pointer to the extra data associated to the descriptor */
+ *((void **)pThirdArg) = pfdDescriptor->ExtraData;
+ nRetVal = 0;
+
+ break;
+ }
+
+ case F_SETXP:
+ {
+ INFO("requested operation: F_SETXP");
+ /* set the pointer to the extra data associated */
+ pfdDescriptor->ExtraData = pThirdArg;
+ nRetVal = 0;
+ break;
+ }
+
+ case F_GETXS:
+ {
+ INFO("requested operation: F_GETXS");
+ nRetVal = pfdDescriptor->ExtraDataSize;
+ break;
+ }
+
+ case F_SETXS:
+ {
+ INFO("requested operation: F_SETXS");
+ pfdDescriptor->ExtraDataSize = nThirdArg;
+ nRetVal = 0;
+ break;
+ }
+
+ case F_GETFH:
+ {
+ INFO("requested operation: F_GETFH");
+ /* invalid return pointer */
+ if(pThirdArg == 0)
+ {
+ errno = EINVAL;
+ break;
+ }
+
+ /* return the handle associated to the descriptor */
+ *((void **)pThirdArg) = pfdDescriptor->FileHandle;
+ nRetVal = 0;
+ break;
+ }
+
+ case F_SETFH:
+ {
+ INFO("requested operation: F_SETFH");
+ pfdDescriptor->FileHandle = pThirdArg;
+ nRetVal = 0;
+ break;
+ }
+
+ default:
+ INFO("invalid operation requested");
+ errno = EINVAL;
+ }
+
+ /* unlock the environment */
+ __PdxReleasePdataLock();
+ INFO("environment unlocked");
+
+ return (nRetVal);
+}
+
+/* EOF */
\ No newline at end of file
--- /dev/null
+/* $Id: open.c,v 1.5 2002/10/29 04:45:31 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/fcntl/open.c
+ * PURPOSE: Open a file
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 04/02/2002: Created
+ */
+
+#include <ddk/ntddk.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <psx/path.h>
+#include <psx/debug.h>
+#include <psx/errno.h>
+#include <psx/pdata.h>
+
+int open(const char *path, int oflag, ...)
+{
+ ANSI_STRING strPath;
+ UNICODE_STRING wstrPath;
+ int nRetVal;
+
+ RtlInitAnsiString(&strPath, (PCSZ)path);
+ RtlAnsiStringToUnicodeString(&wstrPath, &strPath, TRUE);
+
+ nRetVal = _Wopen(wstrPath.Buffer, oflag);
+
+ RtlFreeUnicodeString(&wstrPath);
+
+ return (nRetVal);
+}
+
+int _Wopen(const wchar_t *path, int oflag, ...)
+{
+ OBJECT_ATTRIBUTES oaFileAttribs;
+ IO_STATUS_BLOCK isbStatus;
+ UNICODE_STRING wstrNativePath;
+ NTSTATUS nErrCode;
+ ULONG nDesiredAccess;
+ ULONG nCreateDisposition;
+ ULONG nCreateOptions;
+ HANDLE hFile;
+#if 0
+ mode_t mFileMode;
+#endif
+ int nFileNo;
+ __fildes_t fdDescriptor;
+
+ /* translate file access flag */
+ switch(oflag & O_ACCMODE)
+ {
+ case O_RDONLY:
+ {
+ nDesiredAccess = FILE_READ_ACCESS;
+ nCreateOptions = 0;
+ break;
+ }
+
+ case O_WRONLY:
+ {
+ nDesiredAccess = FILE_WRITE_ACCESS;
+ nCreateOptions = FILE_NON_DIRECTORY_FILE; /* required by the specification */
+ break;
+ }
+
+ case O_RDWR:
+ {
+ nDesiredAccess = FILE_READ_ACCESS | FILE_WRITE_ACCESS;
+ nCreateOptions = FILE_NON_DIRECTORY_FILE; /* required by the specification */
+ break;
+ }
+
+ default:
+ {
+ errno = EINVAL;
+ return (-1);
+ }
+
+ }
+
+ /* miscellaneous flags */
+ if((oflag & _O_DIRFILE) == _O_DIRFILE)
+ nCreateOptions |= FILE_DIRECTORY_FILE;
+
+ /* creation disposition */
+ if((oflag & O_CREAT) == O_CREAT)
+ if((oflag & O_EXCL) == O_EXCL)
+ nCreateDisposition = FILE_CREATE; /* O_CREAT + O_EXCL: create file, fail if file exists */
+ else
+ nCreateDisposition = FILE_OPEN_IF; /* O_CREAT: open file, create if file doesn't exist */
+ else if((oflag & O_TRUNC) == O_TRUNC)
+ nCreateDisposition = FILE_OVERWRITE; /* O_TRUNC: truncate existing file */
+ else
+ nCreateDisposition = FILE_OPEN; /* normal: open file, fail if file doesn't exist */
+
+ /* lock the environment */
+ __PdxAcquirePdataLock();
+
+ /* convert the path into a native path */
+ if(!__PdxPosixPathNameToNtPathName((LPWSTR)path, __PdxGetNativePathBuffer(), __PdxGetCurDir(), NULL))
+ {
+ __PdxReleasePdataLock();
+ return (-1);
+ }
+
+ /* set file generic object attributes */
+ oaFileAttribs.Length = sizeof(oaFileAttribs);
+ oaFileAttribs.RootDirectory = __PdxGetRootHandle();
+ oaFileAttribs.ObjectName = &wstrNativePath;
+ oaFileAttribs.Attributes = OBJ_INHERIT; /* child processes inherit all file descriptors */
+ oaFileAttribs.SecurityDescriptor = NULL;
+ oaFileAttribs.SecurityQualityOfService = NULL;
+
+ /* open or create the file */
+ nErrCode = NtCreateFile
+ (
+ &hFile,
+ nDesiredAccess | SYNCHRONIZE,
+ &oaFileAttribs,
+ &isbStatus,
+ NULL,
+ 0,
+ FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ nCreateDisposition,
+ nCreateOptions | FILE_SYNCHRONOUS_IO_NONALERT,
+ NULL,
+ 0
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtCreateFile() failed with status 0x%08X", nErrCode);
+ __PdxReleasePdataLock();
+ errno = __status_to_errno(nErrCode);
+ return (-1);
+ }
+
+ /* initialize descriptor constructor */
+ memset(&fdDescriptor, 0, sizeof(fdDescriptor));
+ fdDescriptor.FileHandle = hFile;
+ fdDescriptor.OpenFlags = oflag;
+
+ /* allocate a new file descriptor */
+ nFileNo = fcntl(0, F_NEWFD, &fdDescriptor);
+
+ /* unlock the environment */
+ __PdxReleasePdataLock();
+
+ /* could not allocate the file descriptor */
+ if(nFileNo < 0)
+ {
+ NtClose(hFile);
+ return (-1);
+ }
+
+ /* return the file number */
+ return (nFileNo);
+}
+
+int creat(const char *path, mode_t mode)
+{
+ return (open(path, O_WRONLY | O_CREAT | O_TRUNC, mode));
+}
+
+int _Wcreat(const wchar_t *path, mode_t mode)
+{
+ return (_Wopen(path, O_WRONLY | O_CREAT | O_TRUNC, mode));
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: basename.c,v 1.4 2002/10/29 04:45:31 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/libgen/basename.c
+ * PURPOSE: Return the last component of a pathname
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 15/02/2002: Created
+ */
+
+#include <sys/types.h>
+#include <libgen.h>
+#include <wchar.h>
+#include <psx/path.h>
+
+static const char *__basename_dot = ".";
+static const wchar_t *__Wbasename_dot = L".";
+
+char *basename(char *path)
+{
+ char *pcTail;
+ size_t nStrLen;
+
+ /* null or empty string */
+ if(path == 0 && ((nStrLen = strlen(path)) == 0))
+ return ((char *)__basename_dot);
+
+ if(nStrLen == 1)
+ {
+ /* path is "/", return "/" */
+ if(IS_CHAR_DELIMITER_A(path[0]))
+ {
+ path[0] = '/';
+ path[1] = 0;
+ return (path);
+ }
+ /* path is a single character, return it */
+ else
+ {
+ return (path);
+ }
+ }
+
+ /* tail of the string (null terminator excluded) */
+ pcTail = &path[nStrLen - 1];
+
+ /* skip trailing slashes */
+ while(pcTail > path && IS_CHAR_DELIMITER_A(*pcTail))
+ pcTail --;
+
+ pcTail[1] = 0;
+
+ /* go backwards until a delimiter char or the beginning of the string */
+ while(pcTail >= path)
+ /* delimiter found, return the basename */
+ if(IS_CHAR_DELIMITER_A(*pcTail))
+ return (&pcTail[1]);
+ else
+ pcTail --;
+
+ /* return all the path */
+ return (path);
+}
+
+wchar_t *_Wbasename(wchar_t *path)
+{
+ wchar_t *pwcTail;
+ size_t nStrLen;
+
+ /* null or empty string */
+ if(path == 0 && ((nStrLen = wcslen(path)) == 0))
+ return ((wchar_t *)__Wbasename_dot);
+
+ if(nStrLen == 1)
+ {
+ /* path is "/", return "/" */
+ if(IS_CHAR_DELIMITER_U(path[0]))
+ {
+ path[0] = L'/';
+ path[1] = 0;
+ return (path);
+ }
+ /* path is a single character, return it */
+ else
+ {
+ return (path);
+ }
+ }
+
+ /* tail of the string (null terminator excluded) */
+ pwcTail = &path[nStrLen - 1];
+
+ /* skip trailing slashes */
+ while(pwcTail > path && IS_CHAR_DELIMITER_U(*pwcTail))
+ pwcTail --;
+
+ pwcTail[1] = 0;
+
+ /* go backwards until a delimiter char or the beginning of the string */
+ while(pwcTail >= path)
+ /* delimiter found, return the basename */
+ if(IS_CHAR_DELIMITER_U(*pwcTail))
+ return (&pwcTail[1]);
+ else
+ pwcTail --;
+
+ /* return all the path */
+ return (path);
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: fdtable.c,v 1.6 2002/10/29 04:45:31 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/misc/fdtable.c
+ * PURPOSE: File descriptors table functions
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 12/02/2002: Created
+ */
+
+#include <string.h>
+#include <errno.h>
+#include <psx/fdtable.h>
+#include <psx/stdlib.h>
+#include <psx/debug.h>
+#include <psx/safeobj.h>
+
+int __fdtable_init(__fdtable_t * fdtable)
+{
+ if(fdtable == 0)
+ {
+ errno = EINVAL;
+ return (-1);
+ }
+
+ memset(fdtable, 0, sizeof(*fdtable));
+
+ fdtable->Signature = __FDTABLE_MAGIC;
+
+ return (0);
+}
+
+int __fdtable_free(__fdtable_t * fdtable)
+{
+ if(fdtable == 0)
+ {
+ errno = EINVAL;
+ return (-1);
+ }
+
+ __free(&fdtable->Descriptors);
+
+ memset(fdtable, 0, sizeof(*fdtable));
+
+ fdtable->Signature = MAGIC('B', 'A', 'A', 'D');
+
+ return (0);
+}
+
+int __fdtable_entry_isavail(__fdtable_t * fdtable, int fileno)
+{
+ return ((fdtable->DescriptorsBitmap[fileno / 32] >> (fileno % 32)) % 2);
+}
+
+int __fdtable_entry_nextavail(__fdtable_t * fdtable, int fileno)
+{
+ int nCurMapIndex;
+ int nUnusedIndex;
+ uint32_t nCurMapCell;
+
+ nUnusedIndex = fileno;
+
+ /* The file descriptors bitmap is an array of 32 bit unsigned integers (32 bit
+ integers were chosen for proper data alignment without padding). The array is
+ big enough to hold at least OPEN_MAX bits, that is it has OPEN_MAX / 32 cells
+ (see also the __fdtable_t definition in psx/fdtable.h). Bits correspond to
+ file numbers: if a bit is 1, the corresponding file number is in use, else
+ it's unused. Bit numbering is right-to-left wise, that is the rightmost (least
+ significative) bit of cell 0 corresponds to file number 0, the leftmost (most
+ significative) bit of cell 0 to file number 7, the leftmost bit of cell 1 to
+ file number 8, and so on
+ */
+ /* NOTE: I'm sure the algorytm can be greatly optimized, but I prefer to privilege
+ readability - it allows for more maintenable code. Please don't pretend to
+ outsmart the compiler: such optimizations as performing divisions as bit shifts
+ are useless */
+
+ /* index of the bitmap cell containing nUnusedIndex */
+ nCurMapIndex = nUnusedIndex / 32;
+
+ /* get a copy of the bitmap cell containg nUnusedIndex, and shift it to the right
+ so that the rightmost (least significative) bit is the one referencing nUnusedIndex */
+ nCurMapCell = fdtable->DescriptorsBitmap[nCurMapIndex] >> (nUnusedIndex % 32);
+
+ while(1)
+ {
+ /* if the least significative bit of the current cell is 0, we've found an unused
+ fileno, and we return it */
+ if((nCurMapCell % 2) == 0)
+ return (nUnusedIndex);
+
+ /* on to next fileno */
+ nUnusedIndex ++;
+
+ /* this is NOT a failure. -1 with undefined errno means that no unused file
+ number exists */
+ if(nUnusedIndex >= OPEN_MAX)
+ return (-1);
+
+ /* this fileno is referenced in the next cell */
+ if((nUnusedIndex % 32) == 0)
+ {
+ nCurMapIndex ++;
+ nCurMapCell = fdtable->DescriptorsBitmap[nCurMapIndex];
+ }
+ /* on to next fileno (bit) in the current cell */
+ else
+ nCurMapCell >>= 1;
+ }
+
+ return (-1);
+}
+
+int __fdtable_entry_add(__fdtable_t * fdtable, int fileno, __fildes_t * fildes, __fildes_t ** newfd)
+{
+ int nFileNo;
+
+ /* descriptors count reached OPEN_MAX */
+ if(fdtable->UsedDescriptors >= OPEN_MAX)
+ {
+ ERR("file descriptor table full");
+ errno = EMFILE;
+ return (-1);
+ }
+
+ /* base fileno less than zero: use the lowest unused fileno */
+ if(fileno < 0)
+ nFileNo = fdtable->LowestUnusedFileNo;
+ /* base fileno greater than or equal to zero: use the next available fileno */
+ else
+ nFileNo = __fdtable_entry_nextavail(fdtable, fileno);
+
+ INFO("lowest unused file number is %d", nFileNo);
+
+ /* descriptors count reached OPEN_MAX */
+ if(nFileNo < 0)
+ {
+ ERR("nFileNo is less than zero");
+ errno = EMFILE;
+ return (-1);
+ }
+
+ /* if the table doesn't have enough space for the next entry ... */
+ if(nFileNo >= fdtable->AllocatedDescriptors)
+ {
+ void * pTemp;
+
+ INFO
+ (
+ "growing the array from %lu to %lu bytes",
+ fdtable->AllocatedDescriptors * sizeof(*fdtable->Descriptors),
+ (nFileNo + 1) * sizeof(*fdtable->Descriptors)
+ );
+
+ /* ... try to increase the size of the table */
+ if(fdtable->AllocatedDescriptors * sizeof(*fdtable->Descriptors) == 0)
+ pTemp = __malloc((nFileNo + 1) * sizeof(*fdtable->Descriptors));
+ else
+ pTemp = __realloc
+ (
+ fdtable->Descriptors,
+ (nFileNo + 1) * sizeof(*fdtable->Descriptors)
+ );
+
+ /* reallocation failed */
+ if(pTemp == 0)
+ {
+ ERR("__realloc() failed");
+ errno = ENOMEM;
+ return (-1);
+ }
+
+ /* update the table */
+ fdtable->AllocatedDescriptors = nFileNo + 1;
+ fdtable->Descriptors = pTemp;
+ }
+
+ /* initialize descriptor */
+ if(fildes == 0)
+ memset(&fdtable->Descriptors[nFileNo], 0, sizeof(__fildes_t));
+ else
+ memcpy(&fdtable->Descriptors[nFileNo], fildes, sizeof(__fildes_t));
+
+ if(newfd != 0)
+ *newfd = &fdtable->Descriptors[nFileNo];
+
+ INFO
+ (
+ "file number %d: handle 0x%08X, open flags 0x%08X, flags 0x%08X, extra data size %u, extra data at 0x%08X",
+ nFileNo,
+ fdtable->Descriptors[nFileNo].FileHandle,
+ fdtable->Descriptors[nFileNo].OpenFlags,
+ fdtable->Descriptors[nFileNo].FdFlags,
+ fdtable->Descriptors[nFileNo].ExtraDataSize,
+ fdtable->Descriptors[nFileNo].ExtraData
+ );
+
+ INFO
+ (
+ "incrementing used descriptors count from %u to %u",
+ fdtable->UsedDescriptors,
+ fdtable->UsedDescriptors + 1
+ );
+ fdtable->UsedDescriptors ++;
+
+ INFO
+ (
+ "setting bit %u of cell %u of the bitmap to 1",
+ nFileNo % 32,
+ nFileNo / 32
+ );
+ fdtable->DescriptorsBitmap[nFileNo / 32] |= (1 << (nFileNo % 32));
+
+ fdtable->LowestUnusedFileNo = __fdtable_entry_nextavail(fdtable, nFileNo);
+ INFO("setting the lowest unused file number to %d", fdtable->LowestUnusedFileNo);
+
+ return (nFileNo);
+}
+
+int __fdtable_entry_remove(__fdtable_t * fdtable, int fileno)
+{
+ return (-1);
+}
+
+__fildes_t *__fdtable_entry_get(__fdtable_t * fdtable, int fileno)
+{
+ /* this fileno hasn't been allocated */
+ if(fileno >= fdtable->AllocatedDescriptors)
+ return (0);
+
+ /* TODO: check the fileno against the bitmap */
+ return (&fdtable->Descriptors[fileno]);
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: heap.c,v 1.3 2002/10/29 04:45:33 rex Exp $
+ *
+ * FILE: reactos/subsys/psx/lib/psxdll/misc/heap.c
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * PURPOSE: Support routines for crt0.c
+ * UPDATE HISTORY:
+ * 2001-05-06
+ */
+#define NTOS_MODE_USER
+#include <ntos.h>
+#include <napi/teb.h>
+HANDLE STDCALL GetProcessHeap (VOID)
+{
+ return (HANDLE)NtCurrentPeb()->ProcessHeap;
+}
+/* EOF */
--- /dev/null
+/* $Id: init.c,v 1.5 2002/10/29 04:45:33 rex Exp $
+ *
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: reactos/subsys/psx/lib/psxdll/misc/init.c
+ * PURPOSE: Client initialization
+ * PROGRAMMER: Emanuele Aliberti
+ * UPDATE HISTORY:
+ * 2001-05-06
+ */
+#define NTOS_MODE_USER
+#include <ntos.h>
+#include <psx/lpcproto.h>
+
+/* DLL GLOBALS */
+int * errno = NULL;
+char *** _environ = NULL;
+HANDLE ApiPort = INVALID_HANDLE_VALUE;
+/*
+ * Called by startup code in crt0.o, where real
+ * errno and _environ are actually defined.
+ */
+VOID STDCALL __PdxInitializeData (int * errno_arg, char *** environ_arg)
+{
+ errno = errno_arg;
+ _environ = environ_arg;
+}
+/*
+ * Called by DLL's entry point when reason==PROCESS_ATTACH.
+ */
+NTSTATUS STDCALL PsxConnectApiPort (VOID)
+{
+ UNICODE_STRING usApiPortName;
+ LPWSTR wsApiPortName = L"\\"PSX_NS_SUBSYSTEM_DIRECTORY_NAME"\\"PSX_NS_API_PORT_NAME;
+ SECURITY_QUALITY_OF_SERVICE Sqos;
+ ULONG MaxMessageSize = 0;
+ NTSTATUS Status;
+ PSX_CONNECT_PORT_DATA ConnectData;
+ ULONG ConnectDataLength = sizeof ConnectData;
+
+ RtlInitUnicodeString (& usApiPortName, wsApiPortName);
+ RtlZeroMemory (& Sqos, sizeof Sqos);
+ ConnectData.ConnectionType = PSX_CONNECTION_TYPE_PROCESS;
+ ConnectData.Version = PSX_LPC_PROTOCOL_VERSION;
+ ConnectData.PortIdentifier = 0;
+ Status = NtConnectPort (
+ & ApiPort,
+ & usApiPortName,
+ & Sqos,
+ NULL,
+ NULL,
+ & MaxMessageSize,
+ & ConnectData,
+ & ConnectDataLength
+ );
+ if (!NT_SUCCESS(Status))
+ {
+ /* TODO: emit a diagnostic message */
+ return Status;
+ }
+ /* TODO: save returned data */
+ return STATUS_SUCCESS;
+}
+/* EOF */
+
--- /dev/null
+/* $Id: interlock.c,v 1.4 2002/10/29 04:45:33 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/misc/interlock.c
+ * PURPOSE: inter-locked increments/decrements
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 20/01/2002: Adapted from lib/kernel32/synch/intrlck.c
+ */
+
+/*
+ * NOTE by KJK::Hyperion: I do not understand what's behind these functions.
+ * Don't ask me how they work, or to fix errors in them.
+ * Please refer to the authors referenced in the original
+ * file, lib/kernel32/synch/intrlck.c
+ */
+
+/* TODO? move these in some shared library */
+
+#include <psx/interlock.h>
+
+int __interlock_inc(int * addend)
+{
+ int ret = 0;
+
+ __asm__
+ (
+ " lock\n" /* for SMP systems */
+ " incl (%1)\n"
+ " je 2f\n"
+ " jl 1f\n"
+ " incl %0\n"
+ " jmp 2f\n"
+ "1: dec %0\n"
+ "2:\n"
+ :"=r" (ret):"r" (addend), "0" (0): "memory"
+ );
+
+ return (ret);
+}
+
+int __interlock_dec(int * addend)
+{
+ int ret = 0;
+
+ __asm__
+ (
+ " lock\n" /* for SMP systems */
+ " decl (%1)\n"
+ " je 2f\n"
+ " jl 1f\n"
+ " incl %0\n"
+ " jmp 2f\n"
+ "1: dec %0\n"
+ "2:\n"
+ :"=r" (ret):"r" (addend), "0" (0): "memory"
+ );
+
+ return (ret);
+
+}
+
+int __interlock_add(int * addend, int increment)
+{
+ int ret = 0;
+
+ __asm__
+ (
+ " lock\n" /* for SMP systems */
+ " xaddl %0,(%1)"
+ :"=r" (ret)
+ :"r" (addend), "0" (increment)
+ :"memory"
+ );
+
+ return (ret);
+
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: main.c,v 1.6 2002/10/29 04:45:33 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/misc/main.c
+ * PURPOSE: psxdll.dll entry point
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 27/12/2001: Created
+ */
+
+#include <ddk/ntddk.h>
+#include <string.h>
+#include <psx/debug.h>
+#include <psx/fdtable.h>
+#include <psx/pdata.h>
+#include <psx/stdlib.h>
+#include <psx/tls.h>
+
+#define DLL_PROCESS_ATTACH 1
+#define DLL_THREAD_ATTACH 2
+#define DLL_THREAD_DETACH 3
+#define DLL_PROCESS_DETACH 0
+
+/* WARNING: PRELIMINARY CODE FOR DEBUGGING PURPOSES ONLY - DO NOT CHANGE */
+static __PDX_PDATA __PdxPdata;
+static WCHAR __tempPathBuf[32768];
+static char * __tempSelf = "-sh";
+static char * __tempArgv[2] = {0, 0};
+
+VOID __PdxSetProcessData(__PPDX_PDATA NewPdata)
+{
+ memcpy(&__PdxPdata, NewPdata, sizeof(__PdxPdata));
+}
+
+__PPDX_PDATA __PdxGetProcessData(VOID)
+{
+ return &__PdxPdata;
+}
+
+BOOL STDCALL DllMain(PVOID pDllInstance, DWORD nReason, PVOID pUnknown)
+{
+ ULONG nJunk;
+
+ switch(nReason)
+ {
+ /* process created, first thread created */
+ case DLL_PROCESS_ATTACH:
+ {
+ __PPDX_TDATA ThreadData;
+ int i;
+
+ INFO("new process and new thread created");
+
+ __PdxPdata.Spawned = 1;
+
+ __PdxPdata.ArgCount = 1;
+ __tempArgv[0] = __tempSelf;
+ __PdxPdata.ArgVect = __tempArgv;
+
+ __PdxPdata.NativePathBuffer.Length = 0;
+ __PdxPdata.NativePathBuffer.MaximumLength = sizeof(__tempPathBuf);
+ __PdxPdata.NativePathBuffer.Buffer = __tempPathBuf;
+
+ INFO("about to initialize process data lock");
+ RtlInitializeCriticalSection(&__PdxPdata.Lock);
+
+ INFO("about to allocate TLS slot");
+ __PdxPdata.TlsIndex = RtlFindClearBitsAndSet(NtCurrentPeb()->TlsBitmap, 1, 0);
+
+ if(__PdxPdata.TlsIndex == -1)
+ {
+ DbgBreakPoint();
+ NtRaiseHardError(STATUS_NO_MEMORY, 0, 0, 0, 1, (ULONG)&nJunk);
+ return (FALSE);
+ }
+
+ INFO("allocated TLS slot %d", __PdxPdata.TlsIndex);
+
+ INFO("about to allocate thread data");
+ ThreadData = __malloc(sizeof(*ThreadData));
+
+ if(ThreadData == 0)
+ {
+ DbgBreakPoint();
+ NtRaiseHardError(STATUS_NO_MEMORY, 0, 0, 0, 1, (ULONG)&nJunk);
+ return (FALSE);
+ }
+
+ NtCurrentTeb()->TlsSlots[__PdxPdata.TlsIndex] = ThreadData;
+
+ INFO("about to initialize file descriptors table");
+ __fdtable_init(&__PdxPdata.FdTable);
+
+ INFO("end of initialization");
+ return (TRUE);
+ }
+
+ /* process about to exit */
+ case DLL_PROCESS_DETACH:
+ {
+ INFO("process about to exit");
+
+ INFO("about to deallocate thread data");
+ __free(NtCurrentTeb()->TlsSlots[__PdxPdata.TlsIndex]);
+
+ return (TRUE);
+ }
+
+ /* thread created */
+ case DLL_THREAD_ATTACH:
+ {
+ __PPDX_TDATA ThreadData;
+
+ INFO("new thread created");
+
+ INFO("about to allocate thread data");
+ ThreadData = __malloc(sizeof(*ThreadData));
+
+ if(ThreadData == 0)
+ {
+ DbgBreakPoint();
+ NtRaiseHardError(STATUS_NO_MEMORY, 0, 0, 0, 1, (ULONG)&nJunk);
+ return (FALSE);
+ }
+
+ NtCurrentTeb()->TlsSlots[__PdxPdata.TlsIndex] = ThreadData;
+
+ return (TRUE);
+ }
+
+ /* thread exited */
+ case DLL_THREAD_DETACH:
+ {
+ INFO("thread about to exit");
+
+ INFO("about to deallocate thread data");
+ __free(NtCurrentTeb()->TlsSlots[__PdxPdata.TlsIndex]);
+
+ return (TRUE);
+ }
+ }
+
+ return (FALSE);
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: path.c,v 1.4 2002/10/29 04:45:33 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/misc/path.c
+ * PURPOSE: POSIX subsystem path utilities
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 31/01/2002: Created
+ */
+
+#include <ddk/ntddk.h>
+#include <errno.h>
+#include <string.h>
+#include <psx/stdlib.h>
+#include <psx/pdata.h>
+#include <psx/path.h>
+
+BOOLEAN
+__PdxPosixPathGetNextComponent_U
+(
+ IN UNICODE_STRING PathName,
+ IN OUT PUNICODE_STRING PathComponent,
+ OUT PBOOLEAN TrailingDelimiter OPTIONAL
+)
+{
+ int i, j;
+ USHORT l = PathName.Length / sizeof(WCHAR);
+
+ if(PathComponent->Buffer == 0)
+ i = 0;
+ else
+ i = ((ULONG)PathComponent->Buffer - (ULONG)PathName.Buffer + PathComponent->Length) / sizeof(WCHAR);
+
+ /* skip leading empty components */
+ while(1)
+ if(i >= l)
+ {
+ PathComponent->Length = PathComponent->MaximumLength = 0;
+ return (FALSE);
+ }
+ else if(IS_CHAR_DELIMITER_U(PathName.Buffer[i]))
+ i ++;
+ else
+ break;
+
+ if(i > l)
+ {
+ PathComponent->Length = PathComponent->MaximumLength = 0;
+ return (FALSE);
+ }
+
+ PathComponent->Buffer = &PathName.Buffer[i];
+
+ j = i + 1;
+
+ /* advance until the end of the string, or the next delimiter */
+ while(1)
+ {
+ if(j >= l)
+ {
+
+ if(TrailingDelimiter != 0)
+ *TrailingDelimiter = FALSE;
+
+ break;
+ }
+ else if (IS_CHAR_DELIMITER_U(PathName.Buffer[j]))
+ {
+
+ if(TrailingDelimiter != 0)
+ *TrailingDelimiter = TRUE;
+
+ break;
+ }
+ else
+ j ++;
+ }
+
+ PathComponent->Length = PathComponent->MaximumLength = (j - i) * sizeof(WCHAR);
+
+ return (TRUE);
+
+}
+
+BOOLEAN
+__PdxPosixPathResolve_U
+(
+ IN UNICODE_STRING PathName,
+ OUT PUNICODE_STRING ResolvedPathName,
+ IN WCHAR PathDelimiter OPTIONAL
+)
+{
+ UNICODE_STRING wstrThisComponent = {0, 0, NULL};
+ PWCHAR pwcCurPos;
+ PWCHAR pwcStartPos;
+ BOOLEAN bIsDirectory;
+
+ if(PathDelimiter == 0)
+ PathDelimiter = L'/';
+
+ /* start from the beginning of the return buffer */
+ pwcCurPos = ResolvedPathName->Buffer;
+
+ /* path begins with a delimiter (absolute path) */
+ if(IS_CHAR_DELIMITER_U(PathName.Buffer[0]))
+ {
+ /* put a delimiter in front of the return buffer */
+ *pwcCurPos = PathDelimiter;
+ /* move to next character */
+ pwcCurPos ++;
+ }
+
+ pwcStartPos = pwcCurPos;
+
+ /* repeat until the end of the path string */
+ while(__PdxPosixPathGetNextComponent_U(PathName, &wstrThisComponent, &bIsDirectory))
+ {
+ /* ".": skip */
+ if(IS_COMPONENT_DOT_U(wstrThisComponent))
+ continue;
+ /* "..": go back to the last component */
+ else if(IS_COMPONENT_DOTDOT_U(wstrThisComponent))
+ {
+ if(pwcCurPos == pwcStartPos)
+ continue;
+
+ /* skip the last (undefined) character */
+ pwcCurPos --;
+ /* down to the previous path delimiter */
+ do{ pwcCurPos --; }while(!IS_CHAR_DELIMITER_U(*pwcCurPos));
+ /* include the delimiter */
+ pwcCurPos ++;
+ }
+ else
+ {
+ /* copy this component into the return string */
+ memcpy
+ (
+ pwcCurPos,
+ wstrThisComponent.Buffer,
+ wstrThisComponent.Length
+ );
+
+ /* move the current position to the end of the string */
+ pwcCurPos = (PWCHAR)((PBYTE)pwcCurPos + wstrThisComponent.Length);
+
+ /* component had a trailing delimiter */
+ if(bIsDirectory)
+ {
+ /* append a delimiter */
+ *pwcCurPos = PathDelimiter;
+ /* on to next character */
+ pwcCurPos ++;
+ }
+ }
+ }
+
+ /* set the return string's length as the byte offset between the initial buffer
+ position and the current position */
+ ResolvedPathName->Length = ((ULONG)pwcCurPos - (ULONG)ResolvedPathName->Buffer);
+
+ return (TRUE);
+
+}
+
+BOOLEAN
+__PdxPosixPathGetNextComponent_A
+(
+ IN ANSI_STRING PathName,
+ IN OUT PANSI_STRING PathComponent,
+ OUT PBOOLEAN TrailingDelimiter OPTIONAL
+)
+{
+ int i, j;
+
+ if(PathComponent->Buffer == 0)
+ i = 0;
+ else
+ i = ((ULONG)PathComponent->Buffer - (ULONG)PathName.Buffer + PathComponent->Length);
+
+ /* skip leading empty components */
+ while(1)
+ if(i >= PathName.Length)
+ {
+ PathComponent->Length = PathComponent->MaximumLength = 0;
+ return (FALSE);
+ }
+ else if(IS_CHAR_DELIMITER_A(PathName.Buffer[i]))
+ i ++;
+ else
+ break;
+
+ if(i > PathName.Length)
+ {
+ PathComponent->Length = PathComponent->MaximumLength = 0;
+ return (FALSE);
+ }
+
+ PathComponent->Buffer = &PathName.Buffer[i];
+
+ j = i + 1;
+
+ /* advance until the end of the string, or the next delimiter */
+ while(1)
+ {
+ if(j >= PathName.Length)
+ {
+
+ if(TrailingDelimiter != 0)
+ *TrailingDelimiter = FALSE;
+
+ break;
+ }
+ else if (IS_CHAR_DELIMITER_A(PathName.Buffer[j]))
+ {
+
+ if(TrailingDelimiter != 0)
+ *TrailingDelimiter = TRUE;
+
+ break;
+ }
+ else
+ j ++;
+ }
+
+ PathComponent->Length = PathComponent->MaximumLength = j - i;
+
+ return (TRUE);
+
+}
+
+BOOLEAN
+__PdxPosixPathResolve_A
+(
+ IN ANSI_STRING PathName,
+ OUT PANSI_STRING ResolvedPathName,
+ IN CHAR PathDelimiter OPTIONAL
+)
+{
+ ANSI_STRING strThisComponent = {0, 0, NULL};
+ PCHAR pcCurPos;
+ PCHAR pcStartPos;
+ BOOLEAN bIsDirectory;
+
+ if(PathDelimiter == 0)
+ PathDelimiter = '/';
+
+ /* start from the beginning of the return buffer */
+ pcCurPos = ResolvedPathName->Buffer;
+
+ /* path begins with a delimiter (absolute path) */
+ if(IS_CHAR_DELIMITER_A(PathName.Buffer[0]))
+ {
+ /* put a delimiter in front of the return buffer */
+ *pcCurPos = PathDelimiter;
+ /* move to next character */
+ pcCurPos ++;
+ }
+
+ pcStartPos = pcCurPos;
+
+ /* repeat until the end of the path string */
+ while(__PdxPosixPathGetNextComponent_A(PathName, &strThisComponent, &bIsDirectory))
+ {
+ /* ".": skip */
+ if(IS_COMPONENT_DOT_A(strThisComponent))
+ continue;
+ /* "..": go back to the last component */
+ else if(IS_COMPONENT_DOTDOT_A(strThisComponent))
+ {
+ if(pcCurPos == pcStartPos)
+ continue;
+
+ /* skip the last (undefined) character */
+ pcCurPos --;
+ /* down to the previous path delimiter */
+ do{ pcCurPos --; }while(!IS_CHAR_DELIMITER_A(*pcCurPos));
+ /* include the delimiter */
+ pcCurPos ++;
+ }
+ else
+ {
+ /* copy this component into the return string */
+ strncpy
+ (
+ pcCurPos,
+ strThisComponent.Buffer,
+ strThisComponent.Length
+ );
+
+ /* move the current position to the end of the string */
+ pcCurPos = (PCHAR)((PBYTE)pcCurPos + strThisComponent.Length);
+
+ /* component had a trailing delimiter */
+ if(bIsDirectory)
+ {
+ /* append a delimiter */
+ *pcCurPos = PathDelimiter;
+ /* on to next character */
+ pcCurPos ++;
+ }
+ }
+ }
+
+ /* set the return string's length as the byte offset between the initial buffer
+ position and the current position */
+ ResolvedPathName->Length = ((ULONG)pcCurPos - (ULONG)ResolvedPathName->Buffer);
+
+ return (TRUE);
+
+}
+
+BOOLEAN
+__PdxPosixPathNameToNtPathName
+(
+ IN PWCHAR PosixPath,
+ OUT PUNICODE_STRING NativePath,
+ IN PUNICODE_STRING CurDir OPTIONAL,
+ IN PUNICODE_STRING RootDir OPTIONAL
+)
+{
+ UNICODE_STRING wstrPosixPath;
+ UNICODE_STRING wstrTempString;
+
+ /* parameter validation */
+ if
+ (
+ PosixPath == 0 ||
+ NativePath == 0 ||
+ NativePath->Buffer == 0 ||
+ NativePath->MaximumLength == 0 ||
+ (RootDir != 0 && RootDir->Buffer == 0)
+ )
+ {
+ errno = EINVAL;
+ return (FALSE);
+ }
+
+ RtlInitUnicodeString(&wstrPosixPath, PosixPath);
+
+ /* path is null */
+ if(0 == wstrPosixPath.Length)
+ {
+ errno = EINVAL;
+ return (FALSE);
+ }
+
+ /* first, copy the root path into the return buffer */
+ /* if no root dir passed by the caller... */
+ if(RootDir == 0)
+ /* return buffer too small */
+ if(NativePath->MaximumLength < sizeof(WCHAR))
+ {
+ errno = ENOBUFS;
+ return (FALSE);
+ }
+ /* set the first character to a backslash, and set length accordingly */
+ else
+ {
+ NativePath->Buffer[0] = L'\\';
+ NativePath->Length = sizeof(WCHAR);
+ }
+ /* ... else copy the root dir into the return buffer */
+ else
+ /* return buffer too small */
+ if(NativePath->MaximumLength < RootDir->Length)
+ {
+ errno = ENOBUFS;
+ return (FALSE);
+ }
+ /* copy the root directory into the return buffer, and set length */
+ else
+ {
+ memcpy(NativePath->Buffer, RootDir->Buffer, RootDir->Length);
+ NativePath->Length = RootDir->Length;
+ }
+
+ /* path is "/" - our work is done */
+ if(sizeof(WCHAR) == wstrPosixPath.Length && IS_CHAR_DELIMITER_U(wstrPosixPath.Buffer[0]))
+ return (TRUE);
+
+ /* temp string pointing to the tail of the return buffer */
+ wstrTempString.Length = 0;
+ wstrTempString.MaximumLength = NativePath->MaximumLength - NativePath->Length;
+ wstrTempString.Buffer = (PWCHAR)(((PBYTE)(NativePath->Buffer)) + NativePath->Length);
+
+ /* path begins with '/': absolute path. Append the resolved path to the return buffer */
+ if(IS_CHAR_DELIMITER_U(wstrPosixPath.Buffer[0]))
+ {
+ /* copy the resolved path in the return buffer */
+ __PdxPosixPathResolve_U(wstrPosixPath, &wstrTempString, L'\\');
+
+ return (TRUE);
+ }
+ else
+ {
+ UNICODE_STRING wstrAbsolutePath;
+
+ if(CurDir == 0)
+ CurDir = __PdxGetCurDir();
+
+ /* initialize the buffer for the absolute path */
+ wstrAbsolutePath.Length = 0;
+ wstrAbsolutePath.MaximumLength = 0xFFFF;
+ wstrAbsolutePath.Buffer = __malloc(0xFFFF);
+
+ /* if the current directory is not null... */
+ if(!(CurDir->Buffer == 0 || CurDir->Length == 0))
+ {
+ /* copy it into the absolute path buffer */
+ memcpy(wstrAbsolutePath.Buffer, CurDir->Buffer, CurDir->Length);
+ wstrAbsolutePath.Length += CurDir->Length;
+ }
+
+ /* not enough space to append an extra slash */
+ if((wstrAbsolutePath.MaximumLength - wstrAbsolutePath.Length) < (USHORT)sizeof(WCHAR))
+ {
+ __free(wstrAbsolutePath.Buffer);
+ NativePath->Length = 0;
+ errno = ENOBUFS;
+ return (FALSE);
+ }
+
+ /* append an extra slash */
+ wstrAbsolutePath.Buffer[wstrAbsolutePath.Length / sizeof(WCHAR)] = L'/';
+ wstrAbsolutePath.Length += sizeof(WCHAR);
+
+ /* not enough space to copy the relative path */
+ if((wstrAbsolutePath.MaximumLength - wstrAbsolutePath.Length) < wstrPosixPath.Length)
+ {
+ __free(wstrAbsolutePath.Buffer);
+ NativePath->Length = 0;
+ errno = ENOBUFS;
+ return (FALSE);
+ }
+
+ /* append the relative path to the absolute path */
+ memcpy(
+ (PWCHAR)(((PBYTE)wstrAbsolutePath.Buffer) + wstrAbsolutePath.Length),
+ wstrPosixPath.Buffer,
+ wstrPosixPath.Length
+ );
+ wstrAbsolutePath.Length += wstrPosixPath.Length;
+
+ /* resolve the path */
+ __PdxPosixPathResolve_U(wstrAbsolutePath, &wstrTempString, L'\\');
+
+ __free(wstrAbsolutePath.Buffer);
+
+ return (TRUE);
+ }
+
+ return (FALSE);
+
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: pdata.c,v 1.5 2002/10/29 04:45:33 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/misc/pdata.c
+ * PURPOSE: Process data management
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 06/03/2002: Created
+ * 07/03/2002: Added __PdxUnserializeProcessData() (KJK::Hyperion
+ * <noog@libero.it>)
+ * 11/03/2002: Added __PdxProcessDataToProcessParameters()
+ * (KJK::Hyperion <noog@libero.it>)
+ */
+
+#include <ddk/ntddk.h>
+#include <string.h>
+#include <unistd.h>
+#include <psx/fdtable.h>
+#include <psx/pdata.h>
+#include <psx/stdlib.h>
+#include <psx/debug.h>
+
+NTSTATUS
+STDCALL
+__PdxProcessDataToProcessParameters
+(
+ OUT PRTL_USER_PROCESS_PARAMETERS *ProcessParameters,
+ IN __PPDX_PDATA ProcessData,
+ IN PUNICODE_STRING ImageFile
+)
+{
+ NTSTATUS nErrCode;
+ UNICODE_STRING wstrEmpty = {0, 0, NULL};
+ UNICODE_STRING wstrCommandLine = {0, 0, NULL};
+ __fildes_t * fdDescriptor;
+ int i;
+
+ /* RtlInitUnicodeString(&wstrEmpty, L""); */
+ /* TODO: error checking */
+
+ /* build the command line string from argument count and argument vector */
+ if(ProcessData->ArgVect)
+ {
+ BOOL bQuoteArg;
+ BOOL bFirstArg;
+ ANSI_STRING strArgument;
+ PWCHAR pwcBufferTail;
+
+ for(i = 0; i < ProcessData->ArgCount; i ++)
+ {
+ RtlInitAnsiString(&strArgument, ProcessData->ArgVect[i]);
+
+ bFirstArg = (i == 0);
+ bQuoteArg = (strchr(strArgument.Buffer, ' ') != 0);
+
+ /* allocate buffer space for the argument, a blank space if the argument is
+ not the first, and two quotes if the argument contains a space */
+ /* TODO: check this operation for overflow */
+ wstrCommandLine.MaximumLength +=
+ (strArgument.Length + (bFirstArg ? 0 : 1) + (bQuoteArg ? 2 : 0)) *
+ sizeof(WCHAR);
+
+ if(bFirstArg)
+ {
+ wstrCommandLine.Buffer = __malloc(wstrCommandLine.MaximumLength);
+ }
+ else
+ {
+ wstrCommandLine.Buffer =
+ __realloc(wstrCommandLine.Buffer, wstrCommandLine.MaximumLength);
+ }
+
+ /* buffer tail */
+ pwcBufferTail =
+ (PWCHAR)((ULONG)wstrCommandLine.Buffer + wstrCommandLine.Length);
+
+ /* append the separator if the argument isn't the first */
+ if(!bFirstArg)
+ {
+ *pwcBufferTail = L' ';
+ pwcBufferTail ++;
+ }
+
+ /* append the opening quote if the argument contains spaces */
+ if(bQuoteArg)
+ {
+ *pwcBufferTail = L'"';
+ pwcBufferTail ++;
+ }
+
+ mbstowcs(pwcBufferTail, strArgument.Buffer, strArgument.Length);
+
+ /* append closing quote */
+ if(bQuoteArg)
+ {
+ pwcBufferTail = (PWCHAR)((ULONG)pwcBufferTail + strArgument.Length * sizeof(WCHAR));
+ *pwcBufferTail = L'"';
+ }
+
+ wstrCommandLine.Length = wstrCommandLine.MaximumLength;
+ }
+ }
+
+ nErrCode = RtlCreateProcessParameters
+ (
+ ProcessParameters,
+ ImageFile,
+ NULL,
+ &wstrEmpty,
+ &wstrCommandLine,
+ 0,
+ &wstrEmpty,
+ &wstrEmpty,
+ &wstrEmpty,
+ &wstrEmpty
+ );
+
+ /* standard input handle */
+ fdDescriptor = __fdtable_entry_get(&ProcessData->FdTable, STDIN_FILENO);
+
+ if(fdDescriptor != NULL)
+ (*ProcessParameters)->InputHandle = fdDescriptor->FileHandle;
+
+ /* standard output handle */
+ fdDescriptor = __fdtable_entry_get(&ProcessData->FdTable, STDOUT_FILENO);
+
+ if(fdDescriptor != NULL)
+ (*ProcessParameters)->OutputHandle = fdDescriptor->FileHandle;
+
+ /* standard error handle */
+ fdDescriptor = __fdtable_entry_get(&ProcessData->FdTable, STDERR_FILENO);
+
+ if(fdDescriptor != NULL)
+ (*ProcessParameters)->ErrorHandle = fdDescriptor->FileHandle;
+
+ /* POSIX+ and NT environments are incompatible, we set the environment to
+ nothing */
+ (*ProcessParameters)->Environment = NULL;
+
+ (*ProcessParameters)->ConsoleHandle = (PVOID)-1;
+ (*ProcessParameters)->ConsoleFlags = 0;
+
+ return (STATUS_SUCCESS);
+}
+
+/* serialize a process data block in a contiguous, page-aligned block, suitable
+ for transfer across processes */
+NTSTATUS
+STDCALL
+__PdxSerializeProcessData
+(
+ IN __PPDX_PDATA ProcessData,
+ OUT __PPDX_SERIALIZED_PDATA *SerializedProcessData
+)
+{
+ __PPDX_SERIALIZED_PDATA pspdProcessData = 0;
+ NTSTATUS nErrCode;
+ PBYTE pBufferTail;
+ ULONG ulAllocSize = sizeof(__PDX_SERIALIZED_PDATA) - 1;
+ size_t *pnArgLengths;
+ size_t *pnEnvVarsLengths;
+ int nEnvVarsCount;
+ int i;
+
+ /* calculate buffer length */
+ /* FIXME please! this is the most inefficient way to do it */
+
+ /* argv */
+ INFO("serializing arguments\n");
+
+ if(ProcessData->ArgVect != 0)
+ {
+ pnArgLengths = __malloc(ProcessData->ArgCount * sizeof(size_t));
+
+ for(i = 0; i < ProcessData->ArgCount; i ++)
+ {
+ int nStrLen;
+
+ if(ProcessData->ArgVect[i] == 0)
+ {
+ INFO("argument %d is NULL\n", i);
+ pnArgLengths[i] = 0;
+ continue;
+ }
+
+ nStrLen = strlen(ProcessData->ArgVect[i]) + 1;
+ ulAllocSize += nStrLen;
+ pnArgLengths[i] = nStrLen;
+
+ INFO
+ (
+ "argument %d: \"%s\", length %d\n",
+ i,
+ ProcessData->ArgVect[i],
+ nStrLen
+ );
+ }
+
+ }
+ else
+ INFO("arguments vector is NULL\n");
+
+ /* environ */
+ pnEnvVarsLengths = NULL;
+ nEnvVarsCount = 0;
+
+ if(ProcessData->Environment == 0)
+ INFO("pointer to environ is NULL\n");
+ else if((ProcessData->Environment) == 0)
+ INFO("environ is NULL\n");
+ else
+ {
+ for(i = 0; *(ProcessData->Environment)[i] != 0; i++)
+ {
+ int nStrLen = strlen(*(ProcessData->Environment)[i]) + 1;
+ ulAllocSize += nStrLen;
+
+ nEnvVarsCount ++;
+ __realloc(pnEnvVarsLengths, nEnvVarsCount * sizeof(size_t));
+ pnEnvVarsLengths[i] = nStrLen;
+
+ INFO
+ (
+ "environment variable %d: \"%s\", length %d\n",
+ i,
+ *(ProcessData->Environment)[i],
+ nStrLen
+ );
+ }
+
+ INFO("(%d environment variables were found)\n", nEnvVarsCount);
+ }
+
+ /* current directory */
+ ulAllocSize += ProcessData->CurDir.Length;
+
+ INFO
+ (
+ "current directory: \"%.*ls\"\n",
+ ProcessData->CurDir.Length / sizeof(WCHAR),
+ ProcessData->CurDir.Buffer
+ );
+
+ /* root directory */
+ ulAllocSize += ProcessData->RootPath.Length;
+
+ INFO
+ (
+ "root directory: \"%.*ls\"\n",
+ ProcessData->RootPath.Length / sizeof(WCHAR),
+ ProcessData->RootPath.Buffer
+ );
+
+ /* file descriptors table */
+ ulAllocSize += sizeof(__fildes_t) * ProcessData->FdTable.AllocatedDescriptors;
+ INFO
+ (
+ "descriptors table contains %d allocated descriptors, combined length %d\n",
+ ProcessData->FdTable.AllocatedDescriptors,
+ sizeof(__fildes_t) * ProcessData->FdTable.AllocatedDescriptors
+ );
+
+ /* extra descriptors data */
+ for(i = 0; ProcessData->FdTable.AllocatedDescriptors; i ++)
+ if(ProcessData->FdTable.Descriptors[i].ExtraData != NULL)
+ {
+ ulAllocSize += ProcessData->FdTable.Descriptors[i].ExtraDataSize;
+
+ INFO
+ (
+ "descriptor %d has %d bytes of associated data\n",
+ i,
+ ProcessData->FdTable.Descriptors[i].ExtraDataSize
+ );
+
+ }
+
+ /* allocate return block */
+ INFO("about to allocate %d bytes\n", ulAllocSize);
+
+ nErrCode = NtAllocateVirtualMemory
+ (
+ NtCurrentProcess(),
+ (PVOID *)&pspdProcessData,
+ 0,
+ &ulAllocSize,
+ MEM_COMMIT,
+ PAGE_READWRITE
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtAllocateVirtualMemory() failed with status 0x%08X\n", nErrCode);
+ __free(pnArgLengths);
+ __free(pnEnvVarsLengths);
+ *SerializedProcessData = 0;
+ return nErrCode;
+ }
+
+ INFO("%d bytes actually allocated\n", ulAllocSize);
+ pspdProcessData->AllocSize = ulAllocSize;
+
+ /* copy data */
+ /* static data */
+ memcpy(&pspdProcessData->ProcessData, ProcessData, sizeof(__PDX_PDATA));
+
+ /* buffers */
+ pBufferTail = &pspdProcessData->Buffer[0];
+ INFO("buffer tail begins at 0x%08X\n", pBufferTail);
+
+ /* argv */
+ pspdProcessData->ProcessData.ArgVect = 0;
+
+ for(i = 0; i < ProcessData->ArgCount; i ++)
+ {
+ INFO
+ (
+ "copying %d bytes of argument %d (\"%s\") to 0x%08X\n",
+ pnArgLengths[i],
+ i,
+ ProcessData->ArgVect[i],
+ pBufferTail
+ );
+
+ strncpy(pBufferTail, ProcessData->ArgVect[i], pnArgLengths[i]);
+ pBufferTail += pnArgLengths[i];
+
+ INFO
+ (
+ "buffer tail increased by %d bytes, new tail at 0x%08X\n",
+ pnArgLengths[i],
+ pBufferTail
+ );
+
+ }
+
+ __free(pnArgLengths);
+
+ /* environ */
+ pspdProcessData->ProcessData.Environment = (char ***)nEnvVarsCount;
+
+ for(i = 0; i < nEnvVarsCount; i ++)
+ {
+ INFO
+ (
+ "copying %d bytes of environment variable %d (\"%s\") to 0x%08X\n",
+ pnEnvVarsLengths[i],
+ i,
+ ProcessData->Environment[i],
+ pBufferTail
+ );
+
+ strncpy(pBufferTail, *ProcessData->Environment[i], pnEnvVarsLengths[i]);
+ pBufferTail += pnEnvVarsLengths[i];
+
+ INFO
+ (
+ "buffer tail increased by %d bytes, new tail at 0x%08X\n",
+ pnEnvVarsLengths[i],
+ pBufferTail
+ );
+ }
+
+ __free(pnEnvVarsLengths);
+
+ /* current directory */
+ INFO
+ (
+ "copying %d bytes of current directory (\"%.*ls\") to 0x%08X\n",
+ ProcessData->CurDir.Length,
+ ProcessData->CurDir.Length / sizeof(WCHAR),
+ ProcessData->CurDir.Buffer,
+ pBufferTail
+ );
+
+ memcpy(pBufferTail, ProcessData->CurDir.Buffer, ProcessData->CurDir.Length);
+ pBufferTail += ProcessData->CurDir.Length;
+
+ INFO
+ (
+ "buffer tail increased by %d bytes, new tail at 0x%08X\n",
+ ProcessData->CurDir.Length,
+ pBufferTail
+ );
+
+ /* root directory */
+ INFO
+ (
+ "copying %d bytes of root directory (\"%.*ls\") to 0x%08X\n",
+ ProcessData->RootPath.Length,
+ ProcessData->RootPath.Length / sizeof(WCHAR),
+ ProcessData->RootPath.Buffer,
+ pBufferTail
+ );
+
+ memcpy
+ (
+ pBufferTail,
+ ProcessData->RootPath.Buffer,
+ ProcessData->RootPath.Length
+ );
+
+ pBufferTail += ProcessData->RootPath.Length;
+
+ INFO
+ (
+ "buffer tail increased by %d bytes, new tail at 0x%08X\n",
+ ProcessData->RootPath.Length,
+ pBufferTail
+ );
+
+ /* file descriptors table */
+ /* save the offset to the descriptors array */
+ pspdProcessData->ProcessData.FdTable.Descriptors =
+ (PVOID)((ULONG)pBufferTail - (ULONG)pspdProcessData);
+
+ INFO
+ (
+ "descriptors table contains %d allocated descriptors, combined length %d\n",
+ ProcessData->FdTable.AllocatedDescriptors,
+ sizeof(__fildes_t) * ProcessData->FdTable.AllocatedDescriptors
+ );
+
+ memcpy
+ (
+ pBufferTail,
+ ProcessData->FdTable.Descriptors,
+ sizeof(__fildes_t) * ProcessData->FdTable.AllocatedDescriptors
+ );
+
+ pBufferTail +=
+ sizeof(__fildes_t) * ProcessData->FdTable.AllocatedDescriptors;
+
+ INFO
+ (
+ "buffer tail increased by %d bytes, new tail at 0x%08X\n",
+ sizeof(__fildes_t) * ProcessData->FdTable.AllocatedDescriptors,
+ pBufferTail
+ );
+
+ /* extra descriptors data */
+ for(i = 0; ProcessData->FdTable.AllocatedDescriptors; i ++)
+ if(ProcessData->FdTable.Descriptors[i].ExtraData != 0)
+ {
+ INFO
+ (
+ "descriptor %d has %d bytes of associated data\n",
+ i,
+ ProcessData->FdTable.Descriptors[i].ExtraDataSize
+ );
+
+ memcpy
+ (
+ pBufferTail,
+ ProcessData->FdTable.Descriptors[i].ExtraData,
+ ProcessData->FdTable.Descriptors[i].ExtraDataSize
+ );
+
+ pBufferTail += ProcessData->FdTable.Descriptors[i].ExtraDataSize;
+
+ INFO
+ (
+ "buffer tail increased by %d bytes, new tail at 0x%08X\n",
+ ProcessData->FdTable.Descriptors[i].ExtraDataSize,
+ pBufferTail
+ );
+ }
+
+ /* success */
+ *SerializedProcessData = pspdProcessData;
+
+ return (STATUS_SUCCESS);
+}
+
+/* unserialize a process data block. Dynamic data will be moved into the default
+ heap */
+NTSTATUS
+STDCALL
+__PdxUnserializeProcessData
+(
+ IN OUT __PPDX_SERIALIZED_PDATA *SerializedProcessData,
+ OUT __PPDX_PDATA *ProcessData OPTIONAL
+)
+{
+ int i;
+ int nEnvVarsCount;
+ __PPDX_PDATA ppdReturnBlock;
+ BOOLEAN bInPlace;
+ PBYTE pBufferTail;
+
+ /* no return buffer */
+ if(NULL == ProcessData)
+ {
+ /* perform an in-place conversion */
+ ppdReturnBlock = &((*SerializedProcessData)->ProcessData);
+ bInPlace = TRUE;
+ }
+ else
+ {
+ /* use the provided return buffer */
+ ppdReturnBlock = *ProcessData;
+ bInPlace = FALSE;
+ }
+
+ /* non in-place conversion: copy static data */
+ if(!bInPlace)
+ {
+ memcpy(ppdReturnBlock, *SerializedProcessData, sizeof(*ppdReturnBlock));
+ }
+
+ pBufferTail = &((*SerializedProcessData)->Buffer[0]);
+
+ /* allocate arguments array */
+ ppdReturnBlock->ArgVect = __malloc(ppdReturnBlock->ArgCount * sizeof(char *));
+
+ /* duplicate arguments */
+ for(i = 0; i < ppdReturnBlock->ArgCount; i ++)
+ {
+ int nStrLen = strlen(pBufferTail) + 1;
+ ppdReturnBlock->ArgVect[i] = __malloc(nStrLen);
+ strncpy(ppdReturnBlock->ArgVect[i], pBufferTail, nStrLen);
+ pBufferTail += nStrLen;
+ }
+
+ /* allocate environment array */
+ nEnvVarsCount = ppdReturnBlock->Environment;
+ ppdReturnBlock->Environment = __malloc(nEnvVarsCount * sizeof(char *));
+
+ /* duplicate environment */
+ for(i = 0; i < nEnvVarsCount; i ++)
+ {
+ int nStrLen = strlen(pBufferTail) + 1;
+ ppdReturnBlock->Environment[i] = __malloc(nStrLen);
+ strncpy(ppdReturnBlock->Environment[i], pBufferTail, nStrLen);
+ pBufferTail += nStrLen;
+ }
+
+ /* static buffer for path conversions */
+ ppdReturnBlock->NativePathBuffer.Buffer = __malloc(0xFFFF);
+ ppdReturnBlock->NativePathBuffer.Length = 0;
+ ppdReturnBlock->NativePathBuffer.MaximumLength = 0xFFFF;
+
+ /* current directory */
+ ppdReturnBlock->CurDir.Buffer = __malloc(ppdReturnBlock->CurDir.Length);
+ ppdReturnBlock->CurDir.MaximumLength = ppdReturnBlock->CurDir.Length;
+ memcpy(ppdReturnBlock->CurDir.Buffer, pBufferTail, ppdReturnBlock->CurDir.Length);
+ pBufferTail += ppdReturnBlock->CurDir.Length;
+
+ /* root directory */
+ ppdReturnBlock->RootPath.Buffer = __malloc(ppdReturnBlock->RootPath.Length);
+ ppdReturnBlock->RootPath.MaximumLength = ppdReturnBlock->RootPath.Length;
+ memcpy(ppdReturnBlock->RootPath.Buffer, pBufferTail, ppdReturnBlock->RootPath.Length);
+ pBufferTail += ppdReturnBlock->RootPath.Length;
+
+ /* file descriptors table */
+ ppdReturnBlock->FdTable.Descriptors = __malloc(ppdReturnBlock->FdTable.AllocatedDescriptors * sizeof(__fildes_t));
+ memcpy(ppdReturnBlock->FdTable.Descriptors, pBufferTail, ppdReturnBlock->FdTable.AllocatedDescriptors * sizeof(__fildes_t));
+ pBufferTail += ppdReturnBlock->FdTable.AllocatedDescriptors * sizeof(__fildes_t);
+
+ for(i = 0; i < ppdReturnBlock->FdTable.AllocatedDescriptors; i ++)
+ {
+ if(ppdReturnBlock->FdTable.Descriptors[i].ExtraData != 0)
+ {
+ ppdReturnBlock->FdTable.Descriptors[i].ExtraData = __malloc(ppdReturnBlock->FdTable.Descriptors[i].ExtraDataSize);
+ memcpy(ppdReturnBlock->FdTable.Descriptors[i].ExtraData, pBufferTail, ppdReturnBlock->FdTable.Descriptors[i].ExtraDataSize);
+ pBufferTail += ppdReturnBlock->FdTable.Descriptors[i].ExtraDataSize;
+ }
+ }
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: safeobj.c,v 1.4 2002/10/29 04:45:33 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/misc/safeobj.c
+ * PURPOSE: safe checking of user-provided objects
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 09/01/2002: Created
+ */
+
+#include <psx/safeobj.h>
+#include <psx/debug.h>
+
+int __safeobj_validate(void *obj, __magic_t refsignature)
+{
+ if(obj == 0)
+ return (0);
+ else
+ {
+ /* cast the object to a magic number */
+ __magic_t mSignature = *((__magic_t *)obj);
+
+ ERRIF
+ (
+ mSignature != refsignature,
+ "invalid object at %X: signature is \"%c%c%c%c\", should be \"%c%c%c%c\"",
+ obj,
+ MAGIC_DECOMPOSE(refsignature),
+ MAGIC_DECOMPOSE(mSignature)
+ );
+
+ if(mSignature == refsignature)
+ /* signatures match: ok */
+ return (-1);
+ else
+ /* signatures mismatch: fail */
+ return (0);
+
+ }
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: spawn.c,v 1.8 2002/10/29 04:45:35 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/misc/spawn.c
+ * PURPOSE: Create the first POSIX+ process
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 25/02/2002: Created
+ */
+
+/*
+ * NOTE by KJK::Hyperion:
+ * The __PdxSpawnPosixProcess() call solves the chicken-egg dilemma of
+ * creating the first POSIX+ process in a group without the ability to
+ * fork+exec (for example from inside a Win32 process). Processes created by
+ * __PdxSpawnPosixProcess() will *not* inherit anything from the parent, not
+ * even handles: all creation parameters have to be specified explicitely
+ */
+
+#include <ddk/ntddk.h>
+#include <ntdll/base.h>
+#include <napi/i386/segment.h>
+#include <ntdll/rtl.h>
+#include <ntdll/ldr.h>
+#include <stddef.h>
+#include <string.h>
+#include <inttypes.h>
+#include <unistd.h>
+#include <psx/debug.h>
+#include <psx/pdata.h>
+#include <psx/spawn.h>
+#include <psx/stdlib.h>
+
+#include <windows.h>
+
+typedef struct _PORT_MESSAGE {
+ USHORT DataSize;
+ USHORT MessageSize;
+ USHORT MessageType;
+ USHORT VirtualRangesOffset;
+ CLIENT_ID ClientId;
+ ULONG MessageId;
+ ULONG SectionSize;
+ // UCHAR Data[];
+} PORT_MESSAGE, *PPORT_MESSAGE;
+
+NTSTATUS STDCALL CsrClientCallServer(
+ IN PVOID Message,
+ IN PVOID Unknown,
+ IN ULONG Opcode,
+ IN ULONG Size
+);
+
+NTSTATUS STDCALL __PdxSpawnPosixProcess
+(
+ OUT PHANDLE ProcessHandle,
+ OUT PHANDLE ThreadHandle,
+ IN POBJECT_ATTRIBUTES FileObjectAttributes,
+ IN POBJECT_ATTRIBUTES ProcessObjectAttributes,
+ IN HANDLE InheritFromProcessHandle,
+ IN __PPDX_PDATA ProcessData
+)
+{
+ struct CSRSS_MESSAGE {
+ ULONG Unknown1;
+ ULONG Opcode;
+ ULONG Status;
+ ULONG Unknown2;
+ };
+
+ struct __tagcsrmsg{
+ PORT_MESSAGE PortMessage;
+ struct CSRSS_MESSAGE CsrssMessage;
+ PROCESS_INFORMATION ProcessInformation;
+ CLIENT_ID Debugger;
+ ULONG CreationFlags;
+ ULONG VdmInfo[2];
+ } csrmsg;
+
+ __PPDX_SERIALIZED_PDATA pspdProcessData;
+ IO_STATUS_BLOCK isbStatus;
+ PROCESS_BASIC_INFORMATION pbiProcessInfo;
+ INITIAL_TEB itInitialTeb;
+ PRTL_USER_PROCESS_PARAMETERS pppProcessParameters;
+ SECTION_IMAGE_INFORMATION siiInfo;
+ CONTEXT ctxThreadContext;
+ CLIENT_ID ciClientId;
+ NTSTATUS nErrCode;
+ HANDLE hExeFile;
+ HANDLE hExeImage;
+ HANDLE hProcess;
+ PVOID pPdataBuffer = 0;
+ PVOID pParamsBuffer = 0;
+ ULONG nDestBufferSize;
+ ULONG nCurFilDesOffset;
+ ULONG nVirtualSize;
+ ULONG nCommitSize;
+ PVOID pCommitBottom;
+ ULONG nOldProtect;
+ int i;
+
+ /* STEP 1: map executable image in memory */
+ /* 1.1: open the file for execution */
+ nErrCode = NtOpenFile
+ (
+ &hExeFile,
+ SYNCHRONIZE | FILE_EXECUTE,
+ FileObjectAttributes,
+ &isbStatus,
+ FILE_SHARE_READ | FILE_SHARE_DELETE,
+ FILE_SYNCHRONOUS_IO_NONALERT | FILE_NON_DIRECTORY_FILE
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtOpenFile() failed with status 0x%08X\n", nErrCode);
+ return (nErrCode);
+ }
+
+ /* 1.2: create an image section for the file */
+ nErrCode = NtCreateSection
+ (
+ &hExeImage,
+ SECTION_ALL_ACCESS,
+ NULL,
+ 0,
+ PAGE_EXECUTE,
+ SEC_IMAGE,
+ hExeFile
+ );
+
+ /* close file handle (not needed anymore) */
+ NtClose(hExeFile);
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtCreateSection() failed with status 0x%08X\n", nErrCode);
+ return (nErrCode);
+ }
+
+ /* 1.3: get section image information */
+ nErrCode = NtQuerySection
+ (
+ hExeImage,
+ SectionImageInformation,
+ &siiInfo,
+ sizeof(siiInfo),
+ NULL
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtCreateSection() failed with status 0x%08X\n", nErrCode);
+ NtClose(hExeImage);
+ return (nErrCode);
+ }
+
+ /* STEP 2: create process */
+ nErrCode = NtCreateProcess
+ (
+ &hProcess,
+ PROCESS_ALL_ACCESS,
+ ProcessObjectAttributes,
+ InheritFromProcessHandle,
+ FALSE,
+ hExeImage,
+ NULL,
+ NULL
+ );
+
+ /* close image handle (not needed anymore) */
+ NtClose(hExeImage);
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtCreateProcess() failed with status 0x%08X\n", nErrCode);
+ return (nErrCode);
+ }
+
+ /* STEP 3: write process environment and process parameters */
+ /* 3.1: convert process data into process parameters */
+ __PdxProcessDataToProcessParameters
+ (
+ &pppProcessParameters,
+ ProcessData,
+ FileObjectAttributes->ObjectName
+ );
+
+ /* 3.2: serialize the process data for transfer */
+ /* FIXME: the serialized data can be allocated and written directly in the
+ destination process */
+ __PdxSerializeProcessData(ProcessData, &pspdProcessData);
+
+ /* 3.2.1: adjust some fields */
+ pspdProcessData->ProcessData.Spawned = TRUE;
+
+ /* 3.3: allocate memory in the destination process */
+ /* 3.3.1: process data */
+ nDestBufferSize = pspdProcessData->AllocSize;
+
+ nErrCode = NtAllocateVirtualMemory
+ (
+ hProcess,
+ &pPdataBuffer,
+ 0,
+ &nDestBufferSize,
+ MEM_COMMIT,
+ PAGE_READWRITE
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtAllocateVirtualMemory() failed with status 0x%08X\n", nErrCode);
+ goto undoPData;
+ }
+
+ /* 3.3.2: process parameters */
+ nDestBufferSize = pppProcessParameters->Length;
+
+ nErrCode = NtAllocateVirtualMemory
+ (
+ hProcess,
+ &pParamsBuffer,
+ 0,
+ &nDestBufferSize,
+ MEM_COMMIT,
+ PAGE_READWRITE
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtAllocateVirtualMemory() failed with status 0x%08X\n", nErrCode);
+ goto undoPData;
+ }
+
+ /* 3.4: get pointer to the PEB */
+ nErrCode = NtQueryInformationProcess
+ (
+ hProcess,
+ ProcessBasicInformation,
+ &pbiProcessInfo,
+ sizeof(pbiProcessInfo),
+ NULL
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtQueryInformationProcess() failed with status 0x%08X\n", nErrCode);
+ goto undoPData;
+ }
+
+ /* 3.5: write pointers in the PEB */
+ /* 3.5.1: process data */
+ nErrCode = NtWriteVirtualMemory
+ (
+ hProcess,
+ (PVOID)((ULONG)pbiProcessInfo.PebBaseAddress + offsetof(PEB, SubSystemData)),
+ &pPdataBuffer,
+ sizeof(PVOID),
+ NULL
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtWriteVirtualMemory() failed with status 0x%08X\n", nErrCode);
+ goto undoPData;
+ }
+
+ /* 3.5.2: process parameters */
+ nErrCode = NtWriteVirtualMemory
+ (
+ hProcess,
+ (PVOID)((ULONG)pbiProcessInfo.PebBaseAddress + offsetof(PEB, ProcessParameters)),
+ &pParamsBuffer,
+ sizeof(PVOID),
+ NULL
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtWriteVirtualMemory() failed with status 0x%08X\n", nErrCode);
+ goto undoPData;
+ }
+
+ /* 3.6: write data */
+ /* 3.6.1: process data */
+ nErrCode = NtWriteVirtualMemory
+ (
+ hProcess,
+ pPdataBuffer,
+ pspdProcessData,
+ pspdProcessData->AllocSize,
+ NULL
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtWriteVirtualMemory() failed with status 0x%08X\n", nErrCode);
+ goto undoPData;
+ }
+
+ /* 3.6.2 process parameters */
+ nErrCode = NtWriteVirtualMemory
+ (
+ hProcess,
+ pParamsBuffer,
+ pppProcessParameters,
+ pppProcessParameters->Length,
+ NULL
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtWriteVirtualMemory() failed with status 0x%08X\n", nErrCode);
+ goto undoPData;
+ }
+
+undoPData:
+ /* deallocate the temporary data block in the current process */
+ NtFreeVirtualMemory
+ (
+ NtCurrentProcess(),
+ (PVOID *)&pspdProcessData,
+ 0,
+ MEM_RELEASE
+ );
+
+ /* destroy process parameters */
+ RtlDestroyProcessParameters(pppProcessParameters);
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ goto failProcess;
+
+ /* STEP 4: duplicate handles */
+ /* 4.1: handles in the structure itself */
+ /* 4.1.1: root directory */
+ nErrCode = NtDuplicateObject
+ (
+ NtCurrentProcess(),
+ ProcessData->RootHandle,
+ hProcess,
+ (PHANDLE)((ULONG)pPdataBuffer + offsetof(__PDX_PDATA, RootHandle)),
+ 0,
+ 0,
+ DUPLICATE_SAME_ACCESS | 4 /* | DUPLICATE_SAME_ATTRIBUTES */ /* FIXME */
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtDuplicateObject() failed with status 0x%08X\n", nErrCode);
+ goto failProcess;
+ }
+
+ /* 4.2: file descriptors table */
+ for
+ (
+ /* pspdProcessData->ProcessData.FdTable.Descriptors contains the offset to
+ the descriptors array inside pspdProcessData->Buffer[], that is to the
+ first element of the array */
+ i = 0,
+ nCurFilDesOffset = (ULONG)pspdProcessData->ProcessData.FdTable.Descriptors;
+ /* iterate through all allocated descriptors */
+ i < ProcessData->FdTable.AllocatedDescriptors;
+ /* at every step, go on to next input descriptor, and increase the offset to
+ the next output descriptor */
+ i ++, nCurFilDesOffset += sizeof(__fildes_t)
+ )
+ /* FIXME? check the table's bitmap instead? */
+ if(ProcessData->FdTable.Descriptors[i].FileHandle != NULL)
+ {
+ /* duplicate the source handle, ProcessData->FdTable.Descriptors[i], from
+ the current process into the process identified by hProcess, at an
+ address calculated by adding to the serialized data block base address:
+ - the offset to the current descriptor
+ - the offset to the handle field of the descriptor */
+ nErrCode = NtDuplicateObject
+ (
+ NtCurrentProcess(),
+ ProcessData->FdTable.Descriptors[i].FileHandle,
+ hProcess,
+ (PHANDLE)(
+ (ULONG)pPdataBuffer + nCurFilDesOffset + offsetof(__fildes_t, FileHandle)
+ ),
+ 0,
+ 0,
+ DUPLICATE_SAME_ACCESS | 4 /* | DUPLICATE_SAME_ATTRIBUTES */ /* FIXME */
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtDuplicateObject() failed with status 0x%08X\n", nErrCode);
+ goto failProcess;
+ }
+
+ /* duplicate standard handles */
+ /* standard input */
+ if(i == STDIN_FILENO)
+ {
+ nErrCode = NtDuplicateObject
+ (
+ NtCurrentProcess(),
+ ProcessData->FdTable.Descriptors[i].FileHandle,
+ hProcess,
+ (PHANDLE)((ULONG)pParamsBuffer + offsetof(RTL_USER_PROCESS_PARAMETERS, InputHandle)),
+ 0,
+ 0,
+ DUPLICATE_SAME_ACCESS | 4 /* | DUPLICATE_SAME_ATTRIBUTES */ /* FIXME */
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtDuplicateObject() failed with status 0x%08X\n", nErrCode);
+ goto failProcess;
+ }
+ }
+ /* standard output */
+ else if(i == STDOUT_FILENO)
+ {
+ nErrCode = NtDuplicateObject
+ (
+ NtCurrentProcess(),
+ ProcessData->FdTable.Descriptors[i].FileHandle,
+ hProcess,
+ (PHANDLE)((ULONG)pParamsBuffer + offsetof(RTL_USER_PROCESS_PARAMETERS, OutputHandle)),
+ 0,
+ 0,
+ DUPLICATE_SAME_ACCESS | 4 /* | DUPLICATE_SAME_ATTRIBUTES */ /* FIXME */
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtDuplicateObject() failed with status 0x%08X\n", nErrCode);
+ goto failProcess;
+ }
+ }
+ /* standard error */
+ else if(i == STDERR_FILENO)
+ {
+ nErrCode = NtDuplicateObject
+ (
+ NtCurrentProcess(),
+ ProcessData->FdTable.Descriptors[i].FileHandle,
+ hProcess,
+ (PHANDLE)((ULONG)pParamsBuffer + offsetof(RTL_USER_PROCESS_PARAMETERS, ErrorHandle)),
+ 0,
+ 0,
+ DUPLICATE_SAME_ACCESS | 4 /* | DUPLICATE_SAME_ATTRIBUTES */ /* FIXME */
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtDuplicateObject() failed with status 0x%08X\n", nErrCode);
+ goto failProcess;
+ }
+ }
+ }
+
+ /* STEP 5: create first thread */
+ /* 5.1: set up the stack */
+ itInitialTeb.StackAllocate = NULL;
+ nVirtualSize = 0x100000;
+ nCommitSize = 0x100000 - PAGE_SIZE;
+
+ /* 5.1.1: reserve the stack */
+ nErrCode = NtAllocateVirtualMemory
+ (
+ hProcess,
+ &itInitialTeb.StackAllocate,
+ 0,
+ &nVirtualSize,
+ MEM_RESERVE,
+ PAGE_READWRITE
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtAllocateVirtualMemory() failed with status 0x%08X\n", nErrCode);
+ goto failProcess;
+ }
+
+ itInitialTeb.StackBase =
+ (PVOID)((ULONG)itInitialTeb.StackAllocate + nVirtualSize);
+
+ itInitialTeb.StackLimit =
+ (PVOID)((ULONG)itInitialTeb.StackBase - nCommitSize);
+
+ /* 5.1.2: commit the stack */
+ nVirtualSize = nCommitSize + PAGE_SIZE;
+ pCommitBottom =
+ (PVOID)((ULONG)itInitialTeb.StackBase - nVirtualSize);
+
+ nErrCode = NtAllocateVirtualMemory
+ (
+ hProcess,
+ &pCommitBottom,
+ 0,
+ &nVirtualSize,
+ MEM_COMMIT,
+ PAGE_READWRITE
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtAllocateVirtualMemory() failed with status 0x%08X\n", nErrCode);
+ goto failProcess;
+ }
+
+ /* 5.1.3: set up the guard page */
+ nVirtualSize = PAGE_SIZE;
+
+ nErrCode = NtProtectVirtualMemory
+ (
+ hProcess,
+ &pCommitBottom,
+ &nVirtualSize,
+ PAGE_GUARD | PAGE_READWRITE,
+ &nOldProtect
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtProtectVirtualMemory() failed with status 0x%08X\n", nErrCode);
+ goto failProcess;
+ }
+
+ /* 5.2: initialize the thread context */
+ memset(&ctxThreadContext, 0, sizeof(ctxThreadContext));
+
+ ctxThreadContext.Eip = (ULONG)siiInfo.EntryPoint;
+ ctxThreadContext.SegGs = USER_DS;
+ ctxThreadContext.SegFs = USER_DS;
+ ctxThreadContext.SegEs = USER_DS;
+ ctxThreadContext.SegDs = USER_DS;
+ ctxThreadContext.SegCs = USER_CS;
+ ctxThreadContext.SegSs = USER_DS;
+ ctxThreadContext.Esp = (ULONG)itInitialTeb.StackBase - 4;
+ ctxThreadContext.EFlags = (1 << 1) + (1 << 9);
+
+ /* 5.3: create the thread object */
+ nErrCode = NtCreateThread
+ (
+ ThreadHandle,
+ THREAD_ALL_ACCESS,
+ NULL,
+ hProcess,
+ &ciClientId,
+ &ctxThreadContext,
+ &itInitialTeb,
+ TRUE /* FIXME: the thread is only created in suspended state for easier
+ debugging. This behavior is subject to future changes */
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtCreateThread() failed with status 0x%08X\n", nErrCode);
+ goto failProcess;
+ }
+
+ /* 6: register the process with the Win32 subsystem (temporary code for
+ debugging purposes) */
+
+ memset(&csrmsg, 0, sizeof(csrmsg));
+
+ //csrmsg.PortMessage = {0};
+ //csrmsg.CsrssMessage = {0};
+ csrmsg.ProcessInformation.hProcess = hProcess;
+ csrmsg.ProcessInformation.hThread = *ThreadHandle;
+ csrmsg.ProcessInformation.dwProcessId = (DWORD)ciClientId.UniqueProcess;
+ csrmsg.ProcessInformation.dwThreadId = (DWORD)ciClientId.UniqueThread;
+ //csrmsg.Debugger = {0};
+ //csrmsg.CreationFlags = 0;
+ //csrmsg.VdmInfo = {0};
+
+ nErrCode = CsrClientCallServer(&csrmsg, 0, 0x10000, 0x24);
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("CsrClientCallServer() failed with status 0x%08X\n", nErrCode);
+ goto failProcess;
+ }
+
+ nErrCode = NtResumeThread(*ThreadHandle, NULL);
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtResumeThread() failed with status 0x%08X\n", nErrCode);
+ goto failProcess;
+ }
+
+ /* success */
+ return (STATUS_SUCCESS);
+
+ /* failure */
+failProcess:
+ NtTerminateProcess
+ (
+ hProcess,
+ nErrCode
+ );
+
+ return (nErrCode);
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: template.c,v 1.5 2002/10/29 04:45:35 rex Exp $
+ How to create a new source file from this template:
+ - copy the template in the new file (never edit this file directly, unless
+ that's what you want)
+ - search for the string "EDITME" in the file, and follow the instructions
+ - remove this comment block, all blocks containing DELETEME, and all EDITME
+ instructions
+ - save your file, and Have Fun! (TM)
+ */
+/* $*Id*$ (EDITME: remove asterisks from "$*Id*$")
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: (EDITME: put real path of the file here)
+ * PURPOSE: (EDITME: put a very syntetic description of the file here)
+ * PROGRAMMER: John Doe <john.doe@mail.com> (EDITME: your name and e-mail go here)
+ * UPDATE HISTORY:
+ * (EDITME: put here the creation date): Created
+ */
+
+/* EDITME: your code here */
+
+/* EOF */
+
--- /dev/null
+/* $Id: tls.c,v 1.3 2002/10/29 04:45:35 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/misc/tls.c
+ * PURPOSE: Thread local storage
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 30/04/2002: Created
+ */
+
+#include <ddk/ntddk.h>
+#include <ntdll/rtl.h>
+#include <psx/tls.h>
+#include <psx/errno.h>
+
+__tls_index_t __tls_alloc()
+{
+ ULONG nIndex;
+
+ RtlAcquirePebLock();
+
+ nIndex = RtlFindClearBitsAndSet(NtCurrentPeb()->TlsBitmap, 1, 0);
+
+ if (nIndex == (ULONG)-1)
+ errno = ENOMEM;
+ else
+ NtCurrentTeb()->TlsSlots[nIndex] = 0;
+
+ RtlReleasePebLock();
+
+ return(nIndex);
+
+}
+
+int __tls_free(__tls_index_t index)
+{
+ if (index >= TLS_MINIMUM_AVAILABLE)
+ {
+ errno = ERANGE;
+ return (-1);
+ }
+
+ RtlAcquirePebLock();
+
+ if(RtlAreBitsSet(NtCurrentPeb()->TlsBitmap, index, 1))
+ {
+ NtSetInformationThread
+ (
+ NtCurrentThread(),
+ ThreadZeroTlsCell,
+ &index,
+ sizeof(DWORD)
+ );
+
+ RtlClearBits(NtCurrentPeb()->TlsBitmap, index, 1);
+ }
+
+ RtlReleasePebLock();
+
+ return (0);
+}
+
+void * __tls_get_val(__tls_index_t index)
+{
+ if(index >= TLS_MINIMUM_AVAILABLE)
+ {
+ errno = ERANGE;
+ return (0);
+ }
+
+ return (NtCurrentTeb()->TlsSlots[index]);
+}
+
+int __tls_put_val(__tls_index_t index, void * data)
+{
+ if(index >= TLS_MINIMUM_AVAILABLE)
+ {
+ errno = ERANGE;
+ return (-1);
+ }
+
+ NtCurrentTeb()->TlsSlots[index] = data;
+ return (0);
+}
+
+/* EOF */
+
--- /dev/null
+; $Id: psxdll.def,v 1.10 2002/10/29 04:45:35 rex Exp $
+;
+; ReactOS POSIX+ Client Library
+;
+
+LIBRARY PSXDLL.DLL
+EXPORTS
+
+;ctype
+isalnum
+isalpha
+iscntrl
+isdigit
+isgraph
+islower
+isprint
+ispunct
+isspace
+isupper
+iswalpha
+iswctype
+iswdigit
+iswlower
+iswspace
+iswxdigit
+isxdigit
+tolower
+toupper
+towlower
+towupper
+
+;dirent
+opendir
+readdir
+closedir
+
+;dlfcn
+dlopen
+dlclose
+dlsym
+dlerror
+
+;errno
+__PdxGetThreadErrNum
+
+;fcntl
+open
+creat
+fcntl
+
+;libgen
+basename
+
+;math
+atan
+ceil
+cos
+fabs
+floor
+log
+pow
+sin
+sqrt
+tan
+
+;misc
+;misc/fdtable
+__fdtable_init
+__fdtable_free
+__fdtable_entry_nextavail
+__fdtable_entry_add
+__fdtable_entry_remove
+__fdtable_entry_get
+;misc/heap
+;for Microsoft POSIX and Interix compatibility
+GetProcessHeap@0
+HeapAlloc
+HeapFree
+HeapReAlloc
+HeapSize
+;misc/init
+__PdxInitializeData@8
+;misc/path
+__PdxPosixPathGetNextComponent_A
+__PdxPosixPathGetNextComponent_U
+__PdxPosixPathResolve_A
+__PdxPosixPathResolve_U
+__PdxPosixPathNameToNtPathName
+;misc/safeobj
+__safeobj_validate
+;misc/spawn
+__PdxSpawnPosixProcess@24
+
+;pthread
+pthread_create
+pthread_exit
+pthread_join
+pthread_mutex_destroy
+pthread_mutex_init
+pthread_mutex_lock
+pthread_mutex_trylock
+pthread_mutex_unlock
+pthread_mutex_getprioceiling
+pthread_mutex_setprioceiling
+pthread_mutexattr_destroy
+pthread_mutexattr_getpshared
+pthread_mutexattr_init
+pthread_mutexattr_setpshared
+pthread_mutexattr_gettype
+pthread_mutexattr_settype
+pthread_mutexattr_getprioceiling
+pthread_mutexattr_getprotocol
+pthread_mutexattr_setprioceiling
+pthread_mutexattr_setprotocol
+
+;sched
+sched_yield
+
+;signal
+pthread_kill
+raise
+
+;stdio
+;temporary forward exports, soon to be changed
+printf
+gets
+
+;stdlib
+abs
+abort
+atoi
+atol
+malloc
+mbstowcs
+realloc
+free
+calloc
+exit
+;FIXME: should the two calls be distinct?
+_exit
+
+;string
+;forward-exports to NTDLL
+memchr
+memcmp
+memcpy
+memmove
+memset
+strcat
+strchr
+strcmp
+strcpy
+strcspn
+strlen
+strncat
+strncmp
+strncpy
+strpbrk
+strrchr
+strspn
+strstr
+;implemented internally
+strdup
+
+;sys/stat
+chmod
+fchmod
+fstat
+lstat
+mkdir
+mkfifo
+mknod
+stat
+umask
+
+;sys/utsname
+uname
+
+;unistd
+access
+close
+dup
+dup2
+fork
+getcwd
+getpid
+getppid
+pread
+read
+sleep
+write
+
+;wchar
+;forward-exports to NTDLL
+wcscat
+wcschr
+wcscmp
+wcscpy
+wcscspn
+wcslen
+wcsncat
+wcsncmp
+wcsncpy
+wcspbrk
+wcsrchr
+wcsspn
+wcsstr
+wcstol
+wcstombs
+wcstoul
+;implemented internally
+
+;others (FIXME: cathegorize these calls)
+RtlAnsiCharToUnicodeChar
+RtlFillMemory
+RtlMoveMemory
+RtlMultiByteToUnicodeN
+RtlUnicodeToMultiByteN
+RtlUnicodeToMultiByteSize
+RtlUnwind
+RtlUpcaseUnicodeChar
+RtlUpcaseUnicodeToMultiByteN
+RtlZeroMemory
+
+;WARNING: PRELIMINARY CODE FOR DEBUGGING PURPOSES ONLY - DO NOT CHANGE
+__PdxGetProcessData
+
+;EOF
--- /dev/null
+; $Id: psxdll.edf,v 1.9 2002/10/29 04:45:35 rex Exp $
+;
+; ReactOS POSIX+ Client Library
+;
+
+LIBRARY PSXDLL.DLL
+EXPORTS
+
+;ctype
+isalnum=NTDLL.isalnum
+isalpha=NTDLL.isalpha
+iscntrl=NTDLL.iscntrl
+isdigit=NTDLL.isdigit
+isgraph=NTDLL.isgraph
+islower=NTDLL.islower
+isprint=NTDLL.isprint
+ispunct=NTDLL.ispunct
+isspace=NTDLL.isspace
+isupper=NTDLL.isupper
+iswalpha=NTDLL.iswalpha
+iswctype=NTDLL.iswctype
+iswdigit=NTDLL.iswdigit
+iswlower=NTDLL.iswlower
+iswspace=NTDLL.iswspace
+iswxdigit=NTDLL.iswxdigit
+isxdigit=NTDLL.isxdigit
+tolower=NTDLL.tolower
+toupper=NTDLL.toupper
+towlower=NTDLL.towlower
+towupper=NTDLL.towupper
+
+;dirent
+opendir=opendir
+readdir=readdir
+closedir=closedir
+
+;dlfcn
+dlopen=dlopen
+dlclose=dlclose
+dlsym=dlsym
+dlerror=dlerror
+
+;errno
+__PdxGetThreadErrNum=__PdxGetThreadErrNum
+
+;fcntl
+open=open
+creat=creat
+fcntl=fcntl
+
+;libgen
+basename=basename
+
+;math
+atan=NTDLL.atan
+ceil=NTDLL.ceil
+cos=NTDLL.cos
+fabs=NTDLL.fabs
+floor=NTDLL.floor
+log=NTDLL.log
+pow=NTDLL.pow
+sin=NTDLL.sin
+sqrt=NTDLL.sqrt
+tan=NTDLL.tan
+
+;misc
+;misc/fdtable
+__fdtable_init=__fdtable_init
+__fdtable_free=__fdtable_free
+__fdtable_entry_nextavail=__fdtable_entry_nextavail
+__fdtable_entry_add=__fdtable_entry_add
+__fdtable_entry_remove=__fdtable_entry_remove
+__fdtable_entry_get=__fdtable_entry_get
+;misc/heap
+;for Microsoft POSIX and Interix compatibility
+GetProcessHeap=GetProcessHeap@0
+HeapAlloc=NTDLL.RtlAllocateHeap
+HeapFree=NTDLL.RtlFreeHeap
+HeapReAlloc=NTDLL.ReAllocateHeap
+HeapSize=NTDLL.RtlSizeHeap
+;misc/init
+__PdxInitializeData=__PdxInitializeData@8
+;misc/path
+__PdxPosixPathGetNextComponent_A=__PdxPosixPathGetNextComponent_A
+__PdxPosixPathGetNextComponent_U=__PdxPosixPathGetNextComponent_U
+__PdxPosixPathResolve_A=__PdxPosixPathResolve_A
+__PdxPosixPathResolve_U=__PdxPosixPathResolve_U
+__PdxPosixPathNameToNtPathName=__PdxPosixPathNameToNtPathName
+;misc/safeobj
+__safeobj_validate=__safeobj_validate
+;misc/spawn
+__PdxSpawnPosixProcess=__PdxSpawnPosixProcess@24
+
+;pthread
+pthread_create=pthread_create
+pthread_exit=pthread_exit
+pthread_join=pthread_join
+pthread_mutex_destroy=pthread_mutex_destroy
+pthread_mutex_init=pthread_mutex_init
+pthread_mutex_lock=pthread_mutex_lock
+pthread_mutex_trylock=pthread_mutex_trylock
+pthread_mutex_unlock=pthread_mutex_unlock
+pthread_mutex_getprioceiling=pthread_mutex_getprioceiling
+pthread_mutex_setprioceiling=pthread_mutex_setprioceiling
+pthread_mutexattr_destroy=pthread_mutexattr_destroy
+pthread_mutexattr_getpshared=pthread_mutexattr_getpshared
+pthread_mutexattr_init=pthread_mutexattr_init
+pthread_mutexattr_setpshared=pthread_mutexattr_setpshared
+pthread_mutexattr_gettype=pthread_mutexattr_gettype
+pthread_mutexattr_settype=pthread_mutexattr_settype
+pthread_mutexattr_getprioceiling=pthread_mutexattr_getprioceiling
+pthread_mutexattr_getprotocol=pthread_mutexattr_getprotocol
+pthread_mutexattr_setprioceiling=pthread_mutexattr_setprioceiling
+pthread_mutexattr_setprotocol=pthread_mutexattr_setprotocol
+
+;sched
+sched_yield=sched_yield
+
+;signal
+pthread_kill=pthread_kill
+raise=raise
+
+;stdio
+;temporary forward exports, soon to be changed
+printf=MSVCRT.printf
+gets=MSVCRT.gets
+
+;stdlib
+abs=NTDLL.abs
+abort=abort
+atoi=NTDLL.atoi
+atol=NTDLL.atol
+malloc=malloc
+mbstowcs=NTDLL.mbstowcs
+realloc=realloc
+free=free
+calloc=calloc
+exit=exit
+;FIXME: should the two calls be distinct?
+_exit=exit
+
+;string
+;forward-exports to NTDLL
+memchr=NTDLL.memchr
+memcmp=NTDLL.memcmp
+memcpy=NTDLL.memcpy
+memmove=NTDLL.memmove
+memset=NTDLL.memset
+strcat=NTDLL.strcat
+strchr=NTDLL.strchr
+strcmp=NTDLL.strcmp
+strcpy=NTDLL.strcpy
+strcspn=NTDLL.strcspn
+strlen=NTDLL.strlen
+strncat=NTDLL.strncat
+strncmp=NTDLL.strncmp
+strncpy=NTDLL.strncpy
+strpbrk=NTDLL.strpbrk
+strrchr=NTDLL.strrchr
+strspn=NTDLL.strspn
+strstr=NTDLL.strstr
+;implemented internally
+strdup
+
+;sys/stat
+chmod=chmod
+fchmod=fchmod
+fstat=fstat
+lstat=lstat
+mkdir=mkdir
+mkfifo=mkfifo
+mknod=mknod
+stat=stat
+umask=umask
+
+;sys/utsname
+uname=uname
+
+;unistd
+access=access
+close=close
+dup=dup
+dup2=dup2
+fork=fork
+getcwd=getcwd
+getpid=getpid
+getppid=getppid
+pread=pread
+read=read
+sleep=sleep
+write=write
+
+;wchar
+;forward-exports to NTDLL
+wcscat=NTDLL.wcscat
+wcschr=NTDLL.wcschr
+wcscmp=NTDLL.wcscmp
+wcscpy=NTDLL.wcscpy
+wcscspn=NTDLL.wcscspn
+wcslen=NTDLL.wcslen
+wcsncat=NTDLL.wcsncat
+wcsncmp=NTDLL.wcsncmp
+wcsncpy=NTDLL.wcsncpy
+wcspbrk=NTDLL.wcspbrk
+wcsrchr=NTDLL.wcsrchr
+wcsspn=NTDLL.wcsspn
+wcsstr=NTDLL.wcsstr
+wcstol=NTDLL.wcstol
+wcstombs=NTDLL.wcstombs
+wcstoul=NTDLL.wcstoul
+;implemented internally
+
+;others (FIXME: cathegorize these calls)
+RtlAnsiCharToUnicodeChar=NTDLL.RtlAnsiCharToUnicodeChar
+RtlFillMemory=NTDLL.RtlFillMemory
+RtlMoveMemory=NTDLL.RtlMoveMemory
+RtlMultiByteToUnicodeN=NTDLL.RtlMultiByteToUnicodeN
+RtlUnicodeToMultiByteN=NTDLL.RtlUnicodeToMultiByteN
+RtlUnicodeToMultiByteSize=NTDLL.RtlUnicodeToMultiByteSize
+RtlUnwind=NTDLL.RtlUnwind
+RtlUpcaseUnicodeChar=NTDLL.RtlUpcaseUnicodeChar
+RtlUpcaseUnicodeToMultiByteN=NTDLL.RtlUpcaseUnicodeToMultiByteN
+RtlZeroMemory=NTDLL.RtlZeroMemory
+
+;WARNING: PRELIMINARY CODE FOR DEBUGGING PURPOSES ONLY - DO NOT CHANGE
+__PdxGetProcessData=__PdxGetProcessData
+
+;EOF
--- /dev/null
+/* $Id: psxdll.rc,v 1.4 2002/10/29 04:45:35 rex Exp $
+*/
+#include <defines.h>
+#include <reactos/resource.h>
+
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION RES_UINT_FV_MAJOR,RES_UINT_FV_MINOR,RES_UINT_FV_REVISION,RES_UINT_FV_BUILD
+ PRODUCTVERSION RES_UINT_PV_MAJOR,RES_UINT_PV_MINOR,RES_UINT_PV_REVISION,RES_UINT_PV_BUILD
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x40004L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "CompanyName", RES_STR_COMPANY_NAME
+ VALUE "FileDescription", "POSIX+ Client DLL\0"
+ VALUE "FileVersion", RES_STR_FILE_VERSION
+ VALUE "InternalName", "psxdll\0"
+ VALUE "LegalCopyright", RES_STR_LEGAL_COPYRIGHT
+ VALUE "OriginalFilename", "psxdll.dll\0"
+ VALUE "ProductName", RES_STR_PRODUCT_NAME
+ VALUE "ProductVersion", RES_STR_PRODUCT_VERSION
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
--- /dev/null
+/* $Id: create.c,v 1.5 2002/10/29 04:45:36 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/pthread/create.c
+ * PURPOSE: Thread creation
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 19/12/2001: Created
+ */
+
+#include <ddk/ntddk.h>
+#include <string.h>
+#include <sys/types.h>
+#include <pthread.h>
+#include <psx/debug.h>
+#include <psx/errno.h>
+#include <napi/i386/segment.h>
+
+/* thread creation code adapted from kernel32's CreateRemoteThread() function */
+
+static void __threadentry (void *(*start_routine)(void*), void *arg)
+{
+ INFO("hello world! thread successfully created");
+
+ TODO("initialize thread data");
+ TODO("notify DLLs");
+ TODO("notify psxss");
+
+ INFO("about to call start routine at %#x with argument %#x", start_routine, arg);
+
+ pthread_exit(start_routine(arg));
+}
+
+int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
+ void *(*start_routine)(void*), void *arg)
+{
+ HANDLE hThread;
+ OBJECT_ATTRIBUTES oaThreadAttrs;
+ CLIENT_ID ciId;
+ CONTEXT cxThreadContext;
+ INITIAL_TEB itInitialTeb;
+ BOOLEAN fSuspended;
+ ULONG nOldPageProtection;
+ NTSTATUS nErrCode;
+
+ /* initialize generic object attributes */
+ oaThreadAttrs.Length = sizeof(OBJECT_ATTRIBUTES);
+ oaThreadAttrs.RootDirectory = NULL;
+ oaThreadAttrs.ObjectName = NULL;
+ oaThreadAttrs.Attributes = 0;
+ oaThreadAttrs.SecurityDescriptor = NULL;
+ oaThreadAttrs.SecurityQualityOfService = NULL;
+
+ /* initialize thread attributes */
+ fSuspended = FALSE; /* FIXME? really needed? can we hardcode this to FALSE? */
+
+ /* stack attributes */
+ FIXME("stack size defaulted to 0x100000 - thread attributes ignored");
+
+ /* stack reserve size */
+ itInitialTeb.StackReserve = 0x100000;
+
+ /* stack commit size */
+ itInitialTeb.StackCommit = itInitialTeb.StackReserve - PAGE_SIZE;
+
+ /* guard page */
+ itInitialTeb.StackCommit += PAGE_SIZE;
+
+ /* reserve stack */
+ itInitialTeb.StackAllocate = NULL;
+
+ nErrCode = NtAllocateVirtualMemory
+ (
+ NtCurrentProcess(),
+ &itInitialTeb.StackAllocate,
+ 0,
+ &itInitialTeb.StackReserve,
+ MEM_RESERVE,
+ PAGE_READWRITE
+ );
+
+ if(!NT_SUCCESS(nErrCode))
+ {
+ return (__status_to_errno(nErrCode)); /* FIXME? TODO? pthread specific error codes? */
+ }
+
+ itInitialTeb.StackBase = (PVOID)((ULONG)itInitialTeb.StackAllocate + itInitialTeb.StackReserve);
+ itInitialTeb.StackLimit = (PVOID)((ULONG)itInitialTeb.StackBase - itInitialTeb.StackCommit);
+
+ /* commit stack */
+ nErrCode = NtAllocateVirtualMemory
+ (
+ NtCurrentProcess(),
+ &itInitialTeb.StackLimit,
+ 0,
+ &itInitialTeb.StackCommit,
+ MEM_COMMIT,
+ PAGE_READWRITE
+ );
+
+ if(!NT_SUCCESS(nErrCode))
+ {
+ NtFreeVirtualMemory
+ (
+ NtCurrentProcess(),
+ itInitialTeb.StackAllocate,
+ &itInitialTeb.StackReserve,
+ MEM_RELEASE
+ );
+
+ return (__status_to_errno(nErrCode));
+ }
+
+ /* protect guard page */
+ nErrCode = NtProtectVirtualMemory
+ (
+ NtCurrentProcess(),
+ itInitialTeb.StackLimit,
+ PAGE_SIZE,
+ PAGE_GUARD | PAGE_READWRITE,
+ &nOldPageProtection
+ );
+
+ if(!NT_SUCCESS(nErrCode))
+ {
+ NtFreeVirtualMemory
+ (
+ NtCurrentProcess(),
+ itInitialTeb.StackAllocate,
+ &itInitialTeb.StackReserve,
+ MEM_RELEASE
+ );
+
+ return (__status_to_errno(nErrCode));
+ }
+
+ /* initialize thread registers */
+
+//#ifdef __i386__
+ memset(&cxThreadContext, 0, sizeof(CONTEXT));
+ cxThreadContext.Eip = (LONG)__threadentry;
+ cxThreadContext.SegGs = USER_DS;
+ cxThreadContext.SegFs = TEB_SELECTOR;
+ cxThreadContext.SegEs = USER_DS;
+ cxThreadContext.SegDs = USER_DS;
+ cxThreadContext.SegCs = USER_CS;
+ cxThreadContext.SegSs = USER_DS;
+ cxThreadContext.Esp = (ULONG)itInitialTeb.StackBase - 12;
+ cxThreadContext.EFlags = (1<<1) + (1<<9);
+
+ /* initialize call stack */
+ *((PULONG)((ULONG)itInitialTeb.StackBase - 4)) = (ULONG)arg; /* thread argument */
+ *((PULONG)((ULONG)itInitialTeb.StackBase - 8)) = (ULONG)start_routine; /* thread start routine */
+ *((PULONG)((ULONG)itInitialTeb.StackBase - 12)) = 0xDEADBEEF; /* "shouldn't see me" */
+//#else
+//#error Unsupported architecture
+//#endif
+
+ INFO("about to create new thread - start routine at %#x, argument %#x", start_routine, arg);
+
+ /* create thread */
+ nErrCode = NtCreateThread
+ (
+ &hThread,
+ THREAD_ALL_ACCESS,
+ &oaThreadAttrs,
+ NtCurrentProcess(),
+ &ciId,
+ &cxThreadContext,
+ &itInitialTeb,
+ fSuspended
+ );
+
+ if(!NT_SUCCESS(nErrCode))
+ {
+ NtFreeVirtualMemory
+ (
+ NtCurrentProcess(),
+ itInitialTeb.StackAllocate,
+ &itInitialTeb.StackReserve,
+ MEM_RELEASE
+ );
+
+ return (__status_to_errno(nErrCode));
+ }
+
+ /* FIXME? should we return the thread handle or the thread id? */
+ if(thread != 0)
+ *thread = (pthread_t)&ciId.UniqueThread; /* for the moment, we return the id */
+
+ return (0);
+
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: exit.c,v 1.4 2002/10/29 04:45:38 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/pthread/exit.c
+ * PURPOSE: Thread termination
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 19/12/2001: Created
+ */
+
+#include <ddk/ntddk.h>
+#include <ntdll/ldr.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <psx/debug.h>
+
+void pthread_exit(void *value_ptr)
+{
+ NTSTATUS nErrCode;
+ BOOLEAN fLastThread;
+
+ /* terminate process if this is the last thread of the current process */
+ nErrCode = NtQueryInformationThread
+ (
+ NtCurrentThread(),
+ ThreadAmILastThread,
+ &fLastThread,
+ sizeof(BOOLEAN),
+ NULL
+ );
+
+ if(NT_SUCCESS(nErrCode))
+ {
+ if(fLastThread)
+ {
+ INFO("this thread is the last in the current process - about to call exit(0)");
+ exit(0);
+ }
+ }
+ else
+ {
+ WARN
+ (
+ "NtQueryInformationThread(ThreadAmILastThread) failed with status %#x. \
+Can't determine if the current thread is the last in the process. The process \
+could hang",
+ nErrCode
+ );
+
+ }
+
+ TODO("Notify psxss of thread termination");
+
+ LdrShutdownThread(); /* detach DLLs */
+
+ /* kill this thread */
+
+ WARNIF(
+ sizeof(ULONG) < sizeof(typeof(value_ptr)),
+ "\
+the value returned from the current thread will be truncated (pointers shorter \
+than long integers on this architecture?) - expect trouble"
+ );
+
+ INFO("bye bye. Current thread about to die");
+
+ NtTerminateThread(NtCurrentThread(), (ULONG)value_ptr);
+
+ /* "The pthread_exit() function cannot return to its caller." */
+ NtDelayExecution(FALSE, NULL);
+
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: join.c,v 1.4 2002/10/29 04:45:38 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/pthread/join.c
+ * PURPOSE: Wait for thread termination
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 19/12/2001: Created
+ */
+
+#include <ddk/ntddk.h>
+#include <ntdll/ldr.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <pthread.h>
+#include <psx/debug.h>
+#include <psx/errno.h>
+
+int pthread_join(pthread_t thread, void **value_ptr)
+{
+ HANDLE hThread;
+ NTSTATUS nErrCode;
+ OBJECT_ATTRIBUTES oaThreadAttrs;
+ CLIENT_ID ciId;
+ THREAD_BASIC_INFORMATION tbiThreadInfo;
+
+ /* "[EDEADLK] A deadlock was detected or the value of thread specifies
+ the calling thread" */
+ if(thread == pthread_self())
+ return (EDEADLK);
+
+ /* initialize id */
+ ciId.UniqueProcess = (HANDLE)-1;
+ ciId.UniqueThread = (HANDLE)thread;
+
+ /* initialize object attributes */
+ oaThreadAttrs.Length = sizeof(OBJECT_ATTRIBUTES);
+ oaThreadAttrs.RootDirectory = NULL;
+ oaThreadAttrs.ObjectName = NULL;
+ oaThreadAttrs.Attributes = 0;
+ oaThreadAttrs.SecurityDescriptor = NULL;
+ oaThreadAttrs.SecurityQualityOfService = NULL;
+
+ /* open the thread */
+ nErrCode = NtOpenThread
+ (
+ &hThread,
+ SYNCHRONIZE | THREAD_QUERY_INFORMATION,
+ &oaThreadAttrs,
+ &ciId
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ return (__status_to_errno(nErrCode));
+ }
+
+ /* wait for thread termination */
+ nErrCode = NtWaitForSingleObject
+ (
+ hThread,
+ FALSE,
+ NULL
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ NtClose(hThread);
+ return (__status_to_errno(nErrCode));
+ }
+
+ /* get thread basic information (includes return code) */
+ nErrCode = NtQueryInformationThread
+ (
+ hThread,
+ ThreadBasicInformation,
+ &tbiThreadInfo,
+ sizeof(THREAD_BASIC_INFORMATION),
+ NULL
+ );
+
+ NtClose(hThread);
+
+ if(!value_ptr)
+ return (EFAULT);
+
+ *value_ptr = (void *)tbiThreadInfo.ExitStatus;
+
+ return (0);
+
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: kill.c,v 1.4 2002/10/29 04:45:38 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/pthread/kill.c
+ * PURPOSE: Send a signal to a thread
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 15/02/2002: Created
+ */
+
+#include <signal.h>
+#include <errno.h>
+
+int pthread_kill(pthread_t thread, int sig)
+{
+ return (ENOSYS);
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: mutex.c,v 1.4 2002/10/29 04:45:38 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/pthread/mutex.c
+ * PURPOSE: Mutex functions
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 19/12/2001: Created
+ */
+
+#include <ntos.h>
+#include <ddk/ntddk.h>
+#include <sys/types.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <string.h>
+#include <psx/debug.h>
+#include <psx/pthread.h>
+#include <psx/errno.h>
+#include <psx/safeobj.h>
+
+int pthread_mutex_init(pthread_mutex_t *mutex,
+ const pthread_mutexattr_t *attr)
+{
+ struct __mutex *pmMutex;
+ struct __mutexattr *pmaMutexAttrs;
+ BOOL bShared;
+ OBJECT_ATTRIBUTES oaMutexAttrs;
+ NTSTATUS nErrCode;
+
+ /* invalid return buffer */
+ if(mutex == NULL)
+ return (EINVAL);
+
+ /* object still open */
+ if(__safeobj_validate(*mutex, __PTHREAD_MUTEX_MAGIC))
+ return (EBUSY);
+
+ if(attr == NULL)
+ {
+ /* use default attributes */
+ /* create new mutex object */
+ pmMutex = (struct __mutex *)malloc(sizeof(struct __mutex));
+
+ /* malloc() failure */
+ if(!pmMutex)
+ return (ENOMEM);
+
+ /* set the attributes */
+ bShared = FALSE;
+ pmMutex->type = PTHREAD_MUTEX_RECURSIVE;
+ }
+ else if(__safeobj_validate(*attr, __PTHREAD_MUTEX_ATTR_MAGIC))
+ {
+ /* use provided attributes */
+ /* create new mutex object */
+ pmMutex = (struct __mutex *)malloc(sizeof(struct __mutex));
+
+ /* malloc() failure */
+ if(!pmMutex)
+ return (ENOMEM);
+
+ /* get the attributes object */
+ pmaMutexAttrs = (struct __mutexattr *) *attr;
+
+ /* set the attributes */
+ bShared = (pmaMutexAttrs->pshared != PTHREAD_PROCESS_PRIVATE);
+ pmMutex->type = pmaMutexAttrs->type;
+ }
+ else
+ return (EINVAL);
+
+ /* necessary for the mutex to be considered valid later */
+ pmMutex->signature = __PTHREAD_MUTEX_MAGIC;
+
+ /* creation of the native mutex object */
+ pmMutex->handle = 0;
+
+ /* initialize generic object attributes */
+ oaMutexAttrs.Length = sizeof(OBJECT_ATTRIBUTES);
+ oaMutexAttrs.RootDirectory = NULL;
+ oaMutexAttrs.ObjectName = NULL;
+ oaMutexAttrs.Attributes = 0;
+ oaMutexAttrs.SecurityDescriptor = NULL;
+ oaMutexAttrs.SecurityQualityOfService = NULL;
+
+ /* process-exclusive mutex */
+ if(bShared)
+ oaMutexAttrs.Attributes |= OBJ_EXCLUSIVE;
+
+ /* try to create the object */
+ nErrCode = NtCreateMutant
+ (
+ &pmMutex->handle,
+ MUTANT_ALL_ACCESS,
+ &oaMutexAttrs,
+ FALSE
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ /* free the internal mutex object */
+ free(pmMutex);
+ /* return errno */
+ return (__status_to_errno(nErrCode));
+ }
+
+ /* return the pointer to the mutex */
+ *mutex = (pthread_mutex_t)pmMutex;
+
+ /* success */
+ return (0);
+
+}
+
+int pthread_mutex_destroy(pthread_mutex_t *mutex)
+{
+ struct __mutex *pmMutex;
+ NTSTATUS nErrCode;
+ MUTANT_BASIC_INFORMATION mbiMutexInfo;
+
+ /* invalid pointer or pointer to invalid object */
+ if(mutex == NULL || !__safeobj_validate(*mutex, __PTHREAD_MUTEX_MAGIC))
+ {
+ return (EINVAL);
+ }
+
+ pmMutex = (struct __mutex *)*mutex;
+
+ /* query the mutex's status */
+ nErrCode = NtQueryMutant
+ (
+ pmMutex->handle,
+ MutantBasicInformation,
+ &mbiMutexInfo,
+ sizeof(MUTANT_BASIC_INFORMATION),
+ NULL
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ return (__status_to_errno(nErrCode));
+ }
+
+ /* the thread is owned - cannot destroy it */
+ if(mbiMutexInfo.Count <= 0)
+ {
+ return (EBUSY);
+ }
+
+ /* try to close the handle */
+ nErrCode = NtClose(pmMutex->handle);
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ return (__status_to_errno(nErrCode));
+ }
+
+ /* free the object, nil the pointer */
+ free(*mutex);
+ *mutex = NULL;
+
+ /* success */
+ return (0);
+
+}
+
+int pthread_mutex_lock(pthread_mutex_t *mutex)
+{
+ struct __mutex * pmMutex;
+ NTSTATUS nErrCode;
+
+ /* invalid pointer or pointer to invalid object */
+ if(mutex == NULL || !__safeobj_validate(*mutex, __PTHREAD_MUTEX_MAGIC))
+ return (EINVAL);
+
+ pmMutex = (struct __mutex *)*mutex;
+
+ /* decide the behavior from the mutex type */
+ switch(pmMutex->type)
+ {
+ case PTHREAD_MUTEX_NORMAL:
+ {
+ /* unconditionally try to lock the mutex */
+ /* FIXME? should we "artificially" hang the thread if it's the mutex owner, since
+ NT mutexes always behave recursively? */
+
+#if 0
+ if(0 /* mutex owner */ == pthread_self() */)
+ NtDelayExecution(FALSE, NULL);
+#endif
+
+ nErrCode = NtWaitForSingleObject(pmMutex->handle, FALSE, NULL);
+ break;
+ }
+
+ case PTHREAD_MUTEX_ERRORCHECK:
+ {
+ /* prevent a thread from recursively locking the same mutex */
+ if(0 /* mutex owner */ == pthread_self()) /* FIXME: implement the correct logic */
+ return (EDEADLK);
+ else
+ nErrCode = NtWaitForSingleObject(pmMutex->handle, FALSE, NULL);
+
+ break;
+ }
+
+ case PTHREAD_MUTEX_RECURSIVE:
+ {
+ /* allow recursive locking */
+ /* ASSERT: this is the default behavior for NT */
+ nErrCode = NtWaitForSingleObject(pmMutex->handle, FALSE, NULL);
+ break;
+ }
+
+ default:
+ /* we should never reach this point */
+ INFO("you should never read this");
+
+ }
+
+ if(nErrCode == STATUS_ABANDONED)
+ {
+ FIXME("mutex abandoned, not sure on what to do: should we try to lock the mutex again?");
+ }
+ else if(!NT_SUCCESS(nErrCode))
+ {
+ return (__status_to_errno(nErrCode));
+ }
+
+ /* success */
+ return (0);
+
+}
+
+int pthread_mutex_trylock(pthread_mutex_t *mutex)
+{
+ struct __mutex * pmMutex;
+ NTSTATUS nErrCode;
+ MUTANT_BASIC_INFORMATION mbiMutexInfo;
+
+ /* invalid pointer or pointer to invalid object */
+ if(mutex == NULL || !__safeobj_validate(*mutex, __PTHREAD_MUTEX_MAGIC))
+ return (EINVAL);
+
+ pmMutex = (struct __mutex *)*mutex;
+
+ /* query the mutex's status */
+ nErrCode = NtQueryMutant
+ (
+ pmMutex->handle,
+ MutantBasicInformation,
+ &mbiMutexInfo,
+ sizeof(MUTANT_BASIC_INFORMATION),
+ NULL
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ return (__status_to_errno(nErrCode));
+ }
+
+ /* mutex already locked */
+ if(mbiMutexInfo.Count <= 0)
+ return (EBUSY);
+
+ /* mutex not locked - mutex type attribute doesn't matter */
+ nErrCode = NtWaitForSingleObject(pmMutex->handle, FALSE, NULL);
+
+ if(!NT_SUCCESS(nErrCode))
+ {
+ return (__status_to_errno(nErrCode));
+ }
+
+ /* success */
+ return (0);
+
+}
+
+int pthread_mutex_unlock(pthread_mutex_t *mutex)
+{
+ struct __mutex * pmMutex;
+ NTSTATUS nErrCode;
+
+ /* invalid pointer or pointer to invalid object */
+ if(mutex == NULL || !__safeobj_validate(*mutex, __PTHREAD_MUTEX_MAGIC))
+ return (EINVAL);
+
+ pmMutex = (struct __mutex *)*mutex;
+
+ /* try to release the mutex */
+ nErrCode = NtReleaseMutant(pmMutex->handle, NULL);
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ return (__status_to_errno(nErrCode));
+ }
+
+ /* success */
+ return (0);
+
+}
+
+/* mutex attributes routines */
+
+int pthread_mutexattr_init(pthread_mutexattr_t *attr)
+{
+ struct __mutexattr * pmaMutexAttrs;
+
+ /* invalid return pointer */
+ if(!attr)
+ return (EINVAL);
+
+ /* allocate internal structure for mutex attributes */
+ pmaMutexAttrs = (struct __mutexattr *)malloc(sizeof(struct __mutexattr));
+
+ /* failure */
+ if(pmaMutexAttrs == 0)
+ return (ENOMEM);
+
+ /* attribute defaults */
+ pmaMutexAttrs->pshared = PTHREAD_PROCESS_PRIVATE;
+ pmaMutexAttrs->type = PTHREAD_MUTEX_DEFAULT;
+
+ /* return the pointer to the attributes object */
+ *attr = (pthread_mutexattr_t)pmaMutexAttrs;
+
+ /* success */
+ return (0);
+
+}
+
+int pthread_mutexattr_destroy(pthread_mutexattr_t *attr)
+{
+ /* invalid pointer or pointer to invalid object */
+ if(attr == NULL || !__safeobj_validate(*attr, __PTHREAD_MUTEX_ATTR_MAGIC))
+ return (EINVAL);
+
+ /* deallocate internal structure */
+ free(*attr);
+
+ /* success */
+ return (0);
+
+}
+
+#define PTHREAD_MUTEXATTR_GET(PATTR,PVAR,FIELD) \
+ if( \
+ (PATTR) == NULL || \
+ (PVAR) == NULL || \
+ !__safeobj_validate(*(PATTR), __PTHREAD_MUTEX_ATTR_MAGIC) \
+ ) \
+ return (EINVAL); \
+ else \
+ { \
+ (*(PVAR)) = ((struct __mutexattr *)*(PATTR))->FIELD; \
+ return (0); \
+ }
+
+int pthread_mutexattr_getpshared(const pthread_mutexattr_t *attr,
+ int *pshared)
+{
+ PTHREAD_MUTEXATTR_GET(attr, pshared, pshared)
+}
+
+int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *type)
+{
+ PTHREAD_MUTEXATTR_GET(attr, type, type)
+}
+
+int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr,
+ int pshared)
+{
+ /* invalid pointer or pointer to invalid object */
+ if(attr == NULL || !__safeobj_validate(*attr, __PTHREAD_MUTEX_ATTR_MAGIC))
+ return (EINVAL);
+
+ /* validate value */
+ switch(pshared)
+ {
+ case PTHREAD_PROCESS_SHARED: break;
+ case PTHREAD_PROCESS_PRIVATE: break;
+ default: return (EINVAL);
+ }
+
+ ((struct __mutexattr *)*attr)->pshared = pshared;
+
+ return (0);
+
+}
+
+int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type)
+{
+ /* invalid pointer or pointer to invalid object */
+ if(attr == NULL || !__safeobj_validate(*attr, __PTHREAD_MUTEX_ATTR_MAGIC))
+ return (EINVAL);
+
+ /* validate value */
+ switch(type)
+ {
+ case PTHREAD_MUTEX_NORMAL: break;
+ case PTHREAD_MUTEX_ERRORCHECK: break;
+ case PTHREAD_MUTEX_RECURSIVE: break;
+ default: return (EINVAL);
+ }
+
+ ((struct __mutexattr *)*attr)->type = type;
+
+ return (0);
+
+}
+
+/* STUBS */
+
+int pthread_mutex_setprioceiling(pthread_mutex_t *mutex,
+ int prioceiling, int *old_ceiling)
+{
+ TODO("realtime threads not currently implemented");
+ return (ENOSYS);
+}
+
+int pthread_mutex_getprioceiling(const pthread_mutex_t *mutex,
+ int *prioceiling)
+{
+ TODO("realtime threads not currently implemented");
+ return (ENOSYS);
+}
+
+int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *attr,
+ int *protocol)
+{
+ TODO("realtime threads not currently implemented");
+ return (ENOSYS);
+}
+
+int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr,
+ int protocol)
+{
+ TODO("realtime threads not currently implemented");
+ return (ENOSYS);
+}
+
+int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *attr,
+ int prioceiling)
+{
+ TODO("realtime threads not currently implemented");
+ return (ENOSYS);
+}
+
+int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *attr,
+ int *prioceiling)
+{
+ TODO("realtime threads not currently implemented");
+ return (ENOSYS);
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: self.c,v 1.4 2002/10/29 04:45:38 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/pthread/self.c
+ * PURPOSE: get calling thread's ID
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 27/12/2001: Created
+ */
+
+#include <ddk/ntddk.h>
+#include <sys/types.h>
+#include <pthread.h>
+
+pthread_t pthread_self(void)
+{
+ return ((pthread_t)(NtCurrentTeb()->Cid).UniqueThread);
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: yield.c,v 1.4 2002/10/29 04:45:39 rex Exp $
+*/
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/sched/yield.c
+ * PURPOSE: Yield processor
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 15/02/2002: Created
+ */
+
+#include <ddk/ntddk.h>
+#include <sched.h>
+#include <psx/errno.h>
+
+int sched_yield(void)
+{
+ NTSTATUS nErrCode;
+
+ nErrCode = NtYieldExecution();
+
+ if(!NT_SUCCESS(nErrCode))
+ {
+ errno = __status_to_errno(nErrCode);
+ return (-1);
+ }
+
+ return (0);
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: raise.c,v 1.4 2002/10/29 04:45:41 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/signal/raise.c
+ * PURPOSE: Send a signal to the executing process
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 15/02/2002: Created
+ */
+
+#include <signal.h>
+#include <pthread.h>
+#include <errno.h>
+
+int raise(int sig)
+{
+ /* returns zero if pthread_kill() returned zero, non-zero otherwise */
+ /* pthread_kill() returns the error number and doesn't set errno */
+ return (((errno = pthread_kill(pthread_self(), sig))) == 0 ? (0) : (1));
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: abort.c,v 1.4 2002/10/29 04:45:41 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/stdlib/abort.c
+ * PURPOSE: Generate an abnormal process abort
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 15/02/2002: Created
+ */
+
+#include <stdlib.h>
+#include <signal.h>
+
+void abort(void)
+{
+ raise(SIGABRT);
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: exit.c,v 1.4 2002/10/29 04:45:41 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/stdlib/exit.c
+ * PURPOSE: Terminate a process
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 27/12/2001: Created
+ */
+
+#include <ddk/ntddk.h>
+#include <stdlib.h>
+#include <psx/debug.h>
+
+void exit(int status)
+{
+ TODO("call all functions registered with atexit()");
+
+ TODO("flush all output streams, close all open streams");
+ TODO("remove all files created by tmpfile()");
+
+ TODO("close all of the file descriptors, directory streams, conversion \
+descriptors and message catalogue descriptors");
+ TODO("send SIGCHILD to the parent process");
+ TODO("set parent pid of children to pid of psxss");
+ TODO("detach each attached shared-memory segment");
+ TODO("for each semaphore for which the calling process has set a semadj \
+value(), add the value to the semval of the semaphore.");
+ TODO("if the process is a controlling process, send SIGHUP to each process \
+in the foreground process group...");
+ TODO("... and disassociate the terminal from the session");
+ TODO("if the exit causes a process group to become orphaned, and if any \
+member of the newly-orphaned process group is stopped, send SIGHUP and \
+SIGCONT to each process in the newly-orphaned process group");
+ TODO("all open named semaphores in the calling process are closed");
+ TODO("remove any memory locks");
+ TODO("destroy memory mappings");
+ TODO("close all open message queue descriptors");
+
+#if 0
+ ExitProcess(status);
+#endif
+
+ NtTerminateProcess(NtCurrentProcess(), status);
+
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: malloc.c,v 1.4 2002/10/29 04:45:41 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/stdlib/malloc.c
+ * PURPOSE: Memory allocator
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 27/12/2001: Created
+ */
+
+#include <errno.h>
+#include <psx/stdlib.h>
+
+void * malloc(size_t size)
+{
+ void * pTemp = __malloc(size);
+
+ if(!pTemp)
+ errno = ENOMEM;
+
+ return (pTemp);
+}
+
+void free(void * ptr)
+{
+ __free(ptr);
+}
+
+void * calloc(size_t nelem, size_t elsize)
+{
+ return (__malloc(nelem * elsize));
+}
+
+void * realloc(void * ptr, size_t size)
+{
+ void * pTemp;
+
+ if(size == 0)
+ __free(ptr);
+
+ if(ptr == 0)
+ return __malloc(size);
+
+ pTemp = __realloc(ptr, size);
+
+ if(pTemp == 0)
+ errno = ENOMEM;
+
+ return (pTemp);
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: strcoll.c,v 1.4 2002/10/29 04:45:42 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/string/strcoll.c
+ * PURPOSE: string comparison using collating information
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 20/01/2002: Created
+ */
+
+#include <string.h>
+#include <psx/debug.h>
+
+int strcoll(const char *s1, const char *s2)
+{
+ TODO("locale semantics currently unimplemented");
+ return (strcmp(s1, s2));
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: strdup.c,v 1.4 2002/10/29 04:45:42 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/string/strdup.c
+ * PURPOSE: Duplicate a string
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 21/01/2002: Created
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <psx/debug.h>
+
+char *strdup(const char *s1)
+{
+ char *pchRetBuf;
+ int nStrLen;
+
+ HINT("strdup() is inefficient - consider dropping zero-terminated strings");
+
+ if (s1 == 0)
+ return 0;
+
+ nStrLen = strlen(s1);
+
+ /* allocate enough buffer space for s1 and the null terminator */
+ pchRetBuf = (char *) malloc(nStrLen + 1);
+
+ if (pchRetBuf == 0)
+ /* memory allocation failed */
+ return 0;
+
+ /* copy the string */
+ strcpy(pchRetBuf, s1);
+
+ return pchRetBuf;
+
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: strerror.c,v 1.4 2002/10/29 04:45:43 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/string/strerror.c
+ * PURPOSE: Get error message string
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 20/01/2002: Created
+ */
+
+#include <errno.h>
+#include <string.h>
+#include <psx/debug.h>
+
+static char *__errstr = "<strerror() unsupported>";
+char *strerror(int errnum)
+{
+ INFO("errnum %#x", errnum);
+ TODO("getting error string not currently implemented");
+ errno = EINVAL;
+ return (__errstr);
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: chmod.c,v 1.3 2002/10/29 04:45:44 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/sys/stat/chmod.c
+ * PURPOSE: Change mode of a file
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 15/05/2002: Created
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+int chmod(const char *path, mode_t mode)
+{
+ errno = ENOSYS;
+ return (-1);
+}
+
+int fchmod(int fildes, mode_t mode)
+{
+ errno = ENOSYS;
+ return (-1);
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: mkdir.c,v 1.3 2002/10/29 04:45:44 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/sys/stat/mkdir.c
+ * PURPOSE: Make a directory
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 15/05/2002: Created
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+int mkdir(const char *path, mode_t mode)
+{
+ int nFileNo;
+
+ switch((nFileNo = open(path, O_CREAT | O_EXCL | _O_DIRFILE, mode)))
+ {
+ case -1:
+ return (-1);
+
+ default:
+ close(nFileNo);
+ return (0);
+ }
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: mkfifo.c,v 1.3 2002/10/29 04:45:44 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/sys/stat/mkfifo.c
+ * PURPOSE: Make a FIFO special file
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 15/05/2002: Created
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+int mkfifo(const char *path, mode_t mode)
+{
+ errno = ENOSYS;
+ return (-1);
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: mknod.c,v 1.3 2002/10/29 04:45:44 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/sys/stat/mknod.c
+ * PURPOSE: Make a directory, a special or regular file
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 15/05/2002: Created
+ */
+
+#include <sys/stat.h>
+#include <errno.h>
+
+int mknod(const char *path, mode_t mode, dev_t dev)
+{
+ errno = ENOSYS;
+ return (-1);
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: stat.c,v 1.3 2002/10/29 04:45:44 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/sys/stat/stat.c
+ * PURPOSE: Get file status
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 15/05/2002: Created
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+int fstat(int fildes, struct stat *buf)
+{
+ errno = ENOSYS;
+ return (-1);
+}
+
+int lstat(const char *path, struct stat *buf)
+{
+ errno = ENOSYS;
+ return (-1);
+}
+
+int stat(const char *path, struct stat *buf)
+{
+ errno = ENOSYS;
+ return (-1);
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: umask.c,v 1.3 2002/10/29 04:45:46 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/sys/stat/umask.c
+ * PURPOSE:
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 15/05/2002: Created
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+mode_t umask(mode_t cmask)
+{
+ errno = ENOSYS;
+ return (-1);
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: uname.c,v 1.4 2002/10/29 04:45:46 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: lib/psxdll/sys/utsname/uname.c
+ * PURPOSE: Get name of current system
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 19/12/2001: Created
+ */
+
+#include <ddk/ntddk.h>
+#include <ntdll/rtl.h>
+#include <string.h>
+#include <sys/utsname.h>
+#include <psx/stdlib.h>
+#include <psx/debug.h>
+#include <psx/errno.h>
+
+int uname(struct utsname *name)
+{
+ NTSTATUS nErrCode;
+ OBJECT_ATTRIBUTES oaKeyAttribs;
+ UNICODE_STRING wstrKeyPath;
+ UNICODE_STRING wstrValueName;
+ UNICODE_STRING wstrValueData;
+ ANSI_STRING strValueData;
+ PKEY_VALUE_PARTIAL_INFORMATION pkvpiKeyValue;
+ ULONG nKeyValueSize;
+ HANDLE hKey;
+
+ /* system name and version info are fixed strings, at the moment */ /* FIXME? */
+ strncpy(name->sysname, "ReactOS" , 255);
+ strncpy(name->release, "0.0" , 255);
+ strncpy(name->version, "pre-alpha", 255);
+
+ /* hardware identifier */
+ /* FIXME: this should definitely be determined programmatically */
+ strncpy(name->machine, "i386" , 255);
+
+ /* we use the active computer's name as the node name */
+ /* TODO: POSIX-style registry functions */
+
+ /* initialize the registry key path */
+ RtlInitUnicodeString(
+ &wstrKeyPath,
+ L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Control\\ComputerName\\ActiveComputerName"
+ );
+
+ /* initialize object attributes */
+ oaKeyAttribs.Length = sizeof(OBJECT_ATTRIBUTES);
+ oaKeyAttribs.RootDirectory = NULL;
+ oaKeyAttribs.ObjectName = &wstrKeyPath;
+ oaKeyAttribs.Attributes = OBJ_CASE_INSENSITIVE /* | OBJ_OPENLINK | OBJ_OPENIF */ /* FIXME? */;
+ oaKeyAttribs.SecurityDescriptor = NULL;
+ oaKeyAttribs.SecurityQualityOfService = NULL;
+
+ /* open the key object */
+ nErrCode = NtOpenKey
+ (
+ &hKey,
+ KEY_QUERY_VALUE,
+ &oaKeyAttribs
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+
+ ERR("NtOpenKey() failed with status 0x%08X", nErrCode);
+ errno = __status_to_errno(nErrCode);
+ return (-1);
+ }
+
+ /* initialize the registry value name */
+ RtlInitUnicodeString(&wstrValueName, L"ComputerName");
+
+ /* fake query - null buffer and zero length to pre-fetch the appropriate buffer size */
+ nErrCode = NtQueryValueKey
+ (
+ hKey,
+ &wstrValueName,
+ KeyValuePartialInformation,
+ NULL,
+ 0,
+ &nKeyValueSize
+ );
+
+ /* success */
+ if(nErrCode == (NTSTATUS)STATUS_BUFFER_TOO_SMALL)
+ {
+
+ /* allocate the appropriate buffer size */
+ if(nKeyValueSize < sizeof(KEY_VALUE_PARTIAL_INFORMATION)) /* just to be sure */
+ nKeyValueSize = sizeof(KEY_VALUE_PARTIAL_INFORMATION);
+
+ pkvpiKeyValue = __malloc(nKeyValueSize);
+
+ }
+ /* failure */
+ else
+ {
+
+ ERR("NtQueryValueKey() failed with status 0x%08X", nErrCode);
+ NtClose(hKey);
+ errno = __status_to_errno(nErrCode);
+ return (-1);
+ }
+
+ /* query the value */
+ nErrCode = NtQueryValueKey
+ (
+ hKey,
+ &wstrValueName,
+ KeyValuePartialInformation,
+ pkvpiKeyValue,
+ nKeyValueSize,
+ &nKeyValueSize
+ );
+
+ /* close the key handle (not needed anymore) */
+ NtClose(hKey);
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtQueryValueKey() failed with status 0x%08X", nErrCode);
+ __free(pkvpiKeyValue);
+ errno = __status_to_errno(nErrCode);
+ return (-1);
+ }
+
+ /* make wstrValueData refer to the Data field of the key value information */
+ wstrValueData.Length = pkvpiKeyValue->DataLength;
+ wstrValueData.MaximumLength = wstrValueData.Length;
+ wstrValueData.Buffer = (PWCHAR)&(pkvpiKeyValue->Data[0]);
+
+ /* make strValueData refer to the nodename buffer */
+ strValueData.Length = 0;
+ strValueData.MaximumLength = 254;
+ strValueData.Buffer = name->nodename;
+
+ RtlUnicodeStringToAnsiString
+ (
+ &strValueData,
+ &wstrValueData,
+ FALSE
+ );
+
+ /* free the key value buffer */
+ __free(pkvpiKeyValue);
+
+ /* null-terminate the returned string */
+ name->nodename[strValueData.Length] = '0';
+
+ INFO
+ (
+ " \
+name->sysname = \"%s\"\n\
+tname->nodename = \"%s\"\n\
+tname->release = \"%s\"\n\
+tname->version = \"%s\"\n\
+tname->machine = \"%s\"",
+ name->sysname,
+ name->nodename,
+ name->release,
+ name->version,
+ name->machine
+ );
+
+ /* success */
+ return (0);
+
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: access.c,v 1.3 2002/10/29 04:45:46 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/unistd/access.c
+ * PURPOSE: Determine accessibility of a file
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 13/02/2002: Created
+ */
+
+#include <ddk/ntddk.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <psx/errno.h>
+
+int access(const char *path, int amode)
+{
+ OBJECT_ATTRIBUTES oaFileAttribs;
+ IO_STATUS_BLOCK isbStatus;
+ ACCESS_MASK amDesiredAccess = 0;
+ NTSTATUS nErrCode;
+ HANDLE hFile;
+
+ if(amode != F_OK)
+ {
+ if(amode && R_OK) amDesiredAccess |= GENERIC_READ;
+ if(amode && W_OK) amDesiredAccess |= GENERIC_WRITE;
+ if(amode && X_OK) amDesiredAccess |= GENERIC_EXECUTE;
+ }
+
+ nErrCode = NtCreateFile
+ (
+ &hFile,
+ amDesiredAccess,
+ &oaFileAttribs,
+ &isbStatus,
+ 0,
+ 0,
+ FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ FILE_OPEN,
+ 0,
+ 0,
+ 0
+ );
+
+ if(NT_SUCCESS(nErrCode))
+ {
+ NtClose(hFile);
+ return (0);
+ }
+
+ errno = __status_to_errno(nErrCode);
+ return (-1);
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: close.c,v 1.4 2002/10/29 04:45:46 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/unistd/close.c
+ * PURPOSE: Close a file descriptor
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 13/02/2002: Created
+ */
+
+#include <ddk/ntddk.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <psx/errno.h>
+#include <psx/stdlib.h>
+#include <psx/fdtable.h>
+
+int close(int fildes)
+{
+ __fildes_t fdDescriptor;
+ NTSTATUS nErrCode;
+
+ if(fcntl(fildes, F_DELFD, &fdDescriptor) == -1)
+ return (-1);
+
+ __free(fdDescriptor.ExtraData);
+
+ nErrCode = NtClose(fdDescriptor.FileHandle);
+
+ if(!NT_SUCCESS(nErrCode))
+ {
+ errno = __status_to_errno(nErrCode);
+ return (-1);
+ }
+
+ return (0);
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: dup.c,v 1.4 2002/10/29 04:45:46 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/unistd/dup.c
+ * PURPOSE: Duplicate an open file descriptor
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 13/02/2002: Created
+ */
+
+#include <unistd.h>
+#include <limits.h>
+#include <errno.h>
+#include <fcntl.h>
+
+int dup(int fildes)
+{
+ return (fcntl(fildes, F_DUPFD, 0));
+}
+
+int dup2(int fildes, int fildes2)
+{
+ if(fildes < 0 || fildes >= OPEN_MAX)
+ {
+ errno = EBADF;
+ return (-1);
+ }
+
+ /* TODO: check if fildes is valid */
+
+ if(fildes == fildes2)
+ return fildes2;
+
+ close(fildes2);
+ return (fcntl(fildes, F_DUPFD, fildes2));
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: fork.c,v 1.3 2002/10/29 04:45:46 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/unistd/fork.c
+ * PURPOSE: create a new process
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 14/05/2002: Created
+ */
+
+#include <ddk/ntddk.h>
+#include <napi/teb.h>
+#include <sys/types.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <errno.h>
+#include <psx/debug.h>
+#include <psx/errno.h>
+
+#include <windows.h>
+
+typedef struct _PORT_MESSAGE {
+ USHORT DataSize;
+ USHORT MessageSize;
+ USHORT MessageType;
+ USHORT VirtualRangesOffset;
+ CLIENT_ID ClientId;
+ ULONG MessageId;
+ ULONG SectionSize;
+ /* UCHAR Data[]; */
+} PORT_MESSAGE, *PPORT_MESSAGE;
+
+struct CSRSS_MESSAGE {
+ ULONG Unknown1;
+ ULONG Opcode;
+ ULONG Status;
+ ULONG Unknown2;
+};
+
+NTSTATUS STDCALL CsrClientCallServer(
+ IN PVOID Message,
+ IN PVOID Unknown,
+ IN ULONG Opcode,
+ IN ULONG Size
+);
+
+pid_t fork(void)
+{
+ NTSTATUS nErrCode;
+ CONTEXT ctxThreadContext;
+ HANDLE hProcess;
+ HANDLE hThread;
+ INITIAL_TEB itInitialTeb;
+ CLIENT_ID ciClientId;
+ MEMORY_BASIC_INFORMATION mbiStackInfo;
+ THREAD_BASIC_INFORMATION tbiThreadInfo;
+
+ struct __tagcsrmsg{
+ PORT_MESSAGE PortMessage;
+ struct CSRSS_MESSAGE CsrssMessage;
+ PROCESS_INFORMATION ProcessInformation;
+ CLIENT_ID Debugger;
+ ULONG CreationFlags;
+ ULONG VdmInfo[2];
+ } csrmsg;
+
+ /* STEP 1: Duplicate current process */
+ nErrCode = NtCreateProcess
+ (
+ &hProcess,
+ PROCESS_ALL_ACCESS,
+ NULL,
+ NtCurrentProcess(),
+ TRUE,
+ 0,
+ 0,
+ 0
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtCreateProcess() failed with status 0x%08X\n", nErrCode);
+ goto fail;
+ }
+
+ /* STEP 2: Duplicate current thread */
+ /* 2.1: duplicate registers */
+ ctxThreadContext.ContextFlags =
+ CONTEXT_FULL | CONTEXT_DEBUG_REGISTERS | CONTEXT_FLOATING_POINT;
+
+ /* get the current thread's registers */
+ nErrCode = NtGetContextThread(NtCurrentThread(), &ctxThreadContext);
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtGetContextThread() failed with status 0x%08X\n", nErrCode);
+ goto cleanup_and_fail;
+ }
+
+ /* redirect the child process to the child_branch label (see 4.3 below) */
+ ctxThreadContext.Eip = (ULONG)&&child_branch;
+
+ /* 2.2: duplicate stack */
+ /* get stack base and size */
+ nErrCode = NtQueryVirtualMemory
+ (
+ NtCurrentProcess(),
+ (PVOID)ctxThreadContext.Esp,
+ MemoryBasicInformation,
+ &mbiStackInfo,
+ sizeof(mbiStackInfo),
+ 0
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtQueryVirtualMemory() failed with status 0x%08X\n", nErrCode);
+ goto cleanup_and_fail;
+ }
+
+ itInitialTeb.StackCommit = 0;
+ itInitialTeb.StackReserve = 0;
+ itInitialTeb.StackBase = (PVOID)((ULONG)(mbiStackInfo.BaseAddress) + mbiStackInfo.RegionSize);
+ itInitialTeb.StackLimit = mbiStackInfo.BaseAddress;
+ itInitialTeb.StackAllocate = mbiStackInfo.AllocationBase;
+
+ /* 2.3: create duplicate thread */
+ nErrCode = NtCreateThread
+ (
+ &hThread,
+ THREAD_ALL_ACCESS,
+ NULL,
+ hProcess,
+ (CLIENT_ID *)&ciClientId,
+ &ctxThreadContext,
+ &itInitialTeb,
+ TRUE
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtCreateThread() failed with status 0x%08X\n", nErrCode);
+ goto cleanup_and_fail;
+ }
+
+ /* 2.4: duplicate the TEB */
+ /* store the client id in the child thread's stack (see 4.3b) */
+ nErrCode = NtWriteVirtualMemory
+ (
+ hProcess,
+ &ciClientId,
+ &ciClientId,
+ sizeof(ciClientId),
+ 0
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtWriteVirtualMemory() failed with status 0x%08X\n", nErrCode);
+ goto cleanup_and_fail;
+ }
+
+ /* get the child thread's TEB base */
+ nErrCode = NtQueryInformationThread
+ (
+ hThread,
+ ThreadBasicInformation,
+ &tbiThreadInfo,
+ sizeof(tbiThreadInfo),
+ 0
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtQueryInformationThread() failed with status 0x%08X\n", nErrCode);
+ goto cleanup_and_fail;
+ }
+
+ /* copy the TEB */
+ nErrCode = NtWriteVirtualMemory
+ (
+ hProcess,
+ tbiThreadInfo.TebBaseAddress,
+ NtCurrentTeb(),
+ sizeof(TEB),
+ 0
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtWriteVirtualMemory() failed with status 0x%08X\n", nErrCode);
+ goto cleanup_and_fail;
+ }
+
+ /* STEP 3: Call Win32 subsystem */
+ memset(&csrmsg, 0, sizeof(csrmsg));
+
+ csrmsg.ProcessInformation.hProcess = hProcess;
+ csrmsg.ProcessInformation.hThread = hThread;
+ csrmsg.ProcessInformation.dwProcessId = (DWORD)ciClientId.UniqueProcess;
+ csrmsg.ProcessInformation.dwThreadId = (DWORD)ciClientId.UniqueThread;
+
+ nErrCode = CsrClientCallServer(&csrmsg, 0, 0x10000, 0x24);
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("CsrClientCallServer() failed with status 0x%08X\n", nErrCode);
+ goto cleanup_and_fail;
+ }
+
+ /* STEP 4: Finalization */
+ /* 4.1: resume thread */
+ nErrCode = NtResumeThread(hThread, 0);
+
+ /* 4.2: close superfluous handles */
+ NtClose(hProcess);
+ NtClose(hThread);
+
+ /* 4.3: (parent) return the child process id */
+ return ((pid_t)(ciClientId.UniqueProcess));
+
+ /* 4.3b: (child) cleanup and return 0 */
+child_branch:
+ /* restore the thread and process id in the TEB */
+ memcpy(&NtCurrentTeb()->Cid, &ciClientId, sizeof(ciClientId));
+
+ /* return 0 */
+ return (0);
+
+cleanup_and_fail:
+ NtTerminateProcess(hProcess, nErrCode);
+
+fail:
+ errno = __status_to_errno(nErrCode);
+ return (-1);
+
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: getcwd.c,v 1.4 2002/10/29 04:45:48 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/unistd/getcwd.c
+ * PURPOSE: Get the pathname of the current working directory
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 01/02/2002: Created
+ */
+
+#include <ddk/ntddk.h>
+#include <ntdll/rtl.h>
+#include <unistd.h>
+#include <stddef.h>
+#include <wchar.h>
+#include <psx/errno.h>
+#include <psx/stdlib.h>
+#include <psx/pdata.h>
+
+wchar_t *_Wgetcwd(wchar_t *buf, size_t size)
+{
+ PUNICODE_STRING pwstrCurDir;
+
+ __PdxAcquirePdataLock();
+
+ pwstrCurDir = __PdxGetCurDir();
+
+ if(size < (pwstrCurDir->Length / sizeof(WCHAR)))
+ {
+ __PdxReleasePdataLock();
+ errno = ERANGE;
+ return (0);
+ }
+ else
+ {
+ wcsncpy(buf, pwstrCurDir->Buffer, pwstrCurDir->Length);
+ __PdxReleasePdataLock();
+ return (buf);
+ }
+}
+
+char *getcwd(char *buf, size_t size)
+{
+ PUNICODE_STRING pwstrCurDir;
+
+ __PdxAcquirePdataLock();
+
+ pwstrCurDir = __PdxGetCurDir();
+
+ if(size < (pwstrCurDir->Length / sizeof(WCHAR)))
+ {
+ __PdxReleasePdataLock();
+ errno = ERANGE;
+ return (0);
+ }
+ else
+ {
+ ANSI_STRING strBuffer;
+ NTSTATUS nErrCode;
+
+ strBuffer.Length = 0;
+ strBuffer.MaximumLength = size;
+ strBuffer.Buffer = buf;
+
+ nErrCode = RtlUnicodeStringToAnsiString
+ (
+ &strBuffer,
+ pwstrCurDir,
+ FALSE
+ );
+
+ __PdxReleasePdataLock();
+
+ if(!NT_SUCCESS(nErrCode))
+ {
+ errno = __status_to_errno(nErrCode);
+ return (0);
+ }
+
+ return (buf);
+ }
+
+ __PdxReleasePdataLock();
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: getpid.c,v 1.5 2002/10/29 04:45:48 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/unistd/getpid.c
+ * PURPOSE: Get the process ID
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 15/02/2002: Created
+ */
+
+#include <ddk/ntddk.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <psx/errno.h>
+
+pid_t getpid(void)
+{
+ PROCESS_BASIC_INFORMATION pbiInfo;
+ NTSTATUS nErrCode;
+
+ nErrCode = NtQueryInformationProcess
+ (
+ NtCurrentProcess(),
+ ProcessBasicInformation,
+ &pbiInfo,
+ sizeof(pbiInfo),
+ NULL
+ );
+
+ if(!NT_SUCCESS(nErrCode))
+ {
+ errno = __status_to_errno(nErrCode);
+ return (0);
+ }
+
+ return (pbiInfo.UniqueProcessId);
+#if 0
+ return ((pid_t)NtCurrentTeb()->Cid.UniqueProcess);
+#endif
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: getppid.c,v 1.4 2002/10/29 04:45:48 rex Exp $
+*/
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/unistd/getppid.c
+ * PURPOSE: Get the parent process ID
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 15/02/2002: Created
+ */
+
+#include <ddk/ntddk.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <psx/errno.h>
+
+pid_t getppid(void)
+{
+ PROCESS_BASIC_INFORMATION pbiInfo;
+ NTSTATUS nErrCode;
+
+ nErrCode = NtQueryInformationProcess
+ (
+ NtCurrentProcess(),
+ ProcessBasicInformation,
+ &pbiInfo,
+ sizeof(pbiInfo),
+ NULL
+ );
+
+ if(!NT_SUCCESS(nErrCode))
+ {
+ errno = __status_to_errno(nErrCode);
+ return (0);
+ }
+
+ return (pbiInfo.InheritedFromUniqueProcessId);
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: read.c,v 1.4 2002/10/29 04:45:48 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/unistd/read.c
+ * PURPOSE: Read from a file
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 15/02/2002: Created
+ */
+
+#include <ddk/ntddk.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <psx/debug.h>
+#include <psx/errno.h>
+
+ssize_t __read(int fildes, void *buf, size_t nbyte, off_t *offset)
+{
+ HANDLE hFile;
+ NTSTATUS nErrCode;
+ IO_STATUS_BLOCK isbStatus;
+
+ /* get the file handle for the specified file descriptor */
+ if(fcntl(fildes, F_GETFH, &hFile) == -1)
+ return (-1);
+
+ if(offset != NULL)
+ {
+ /* NT always moves the file pointer, while Unix pread() must not: we have to
+ duplicate the handle and work on the duplicate */ /* FIXME? better save
+ the file position and restore it later? */
+ HANDLE hDupFile;
+
+ /* duplicate the handle */
+ nErrCode = NtDuplicateObject
+ (
+ NtCurrentProcess(),
+ hFile,
+ NtCurrentProcess(),
+ &hDupFile,
+ 0,
+ 0,
+ DUPLICATE_SAME_ACCESS
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ errno = __status_to_errno(nErrCode);
+ return (0);
+ }
+
+ /* read data from file at the specified offset */
+ nErrCode = NtReadFile
+ (
+ hDupFile,
+ NULL,
+ NULL,
+ NULL,
+ &isbStatus,
+ buf,
+ nbyte,
+ (PLARGE_INTEGER)offset,
+ NULL
+ );
+
+ NtClose(hDupFile);
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ errno = __status_to_errno(nErrCode);
+ return (0);
+ }
+ }
+ else
+ {
+ /* read data from file at the current offset */
+ nErrCode = NtReadFile
+ (
+ hFile,
+ NULL,
+ NULL,
+ NULL,
+ &isbStatus,
+ buf,
+ nbyte,
+ NULL,
+ NULL
+ );
+
+ /* failure */
+ if(!NT_SUCCESS(nErrCode))
+ {
+ errno = __status_to_errno(nErrCode);
+ return (0);
+ }
+ }
+
+ return ((ssize_t)isbStatus.Information);
+}
+
+ssize_t read(int fildes, void *buf, size_t nbyte)
+{
+ return (__read(fildes, buf, nbyte, NULL));
+}
+
+ssize_t pread(int fildes, void *buf, size_t nbyte, off_t offset)
+{
+ return (__read(fildes, buf, nbyte, &offset));
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: sleep.c,v 1.3 2002/10/29 04:45:48 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/unistd/sleep.c
+ * PURPOSE: Suspend execution for an interval of time
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 14/05/2002: Created
+ */
+
+#include <ddk/ntddk.h>
+#include <unistd.h>
+
+unsigned int sleep(unsigned int seconds)
+{
+ LARGE_INTEGER lnDelay = RtlEnlargedIntegerMultiply(seconds, 10000000);
+
+ if(!NT_SUCCESS(NtDelayExecution(FALSE, &lnDelay)))
+ return seconds;
+
+ return 0;
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: write.c,v 1.6 2002/10/29 04:45:48 rex Exp $
+ */
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS POSIX+ Subsystem
+ * FILE: subsys/psx/lib/psxdll/unistd/write.c
+ * PURPOSE: Write on a file
+ * PROGRAMMER: KJK::Hyperion <noog@libero.it>
+ * UPDATE HISTORY:
+ * 15/02/2002: Created
+ * 21/03/2002: Implemented write() (KJK::Hyperion <noog@libero.it>)
+ */
+
+#include <ddk/ntddk.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <psx/debug.h>
+#include <psx/errno.h>
+#include <psx/fdtable.h>
+
+ssize_t write(int fildes, const void *buf, size_t nbyte)
+{
+ __fildes_t fdDescriptor;
+ NTSTATUS nErrCode;
+ IO_STATUS_BLOCK isbStatus;
+
+ if(nbyte == 0)
+ return (0);
+
+ if(fcntl(fildes, F_GETALL, &fdDescriptor) == -1)
+ {
+ ERR("fcntl() failed, errno %d", errno);
+ return (0);
+ }
+
+ if((fdDescriptor.OpenFlags && O_APPEND) == O_APPEND)
+ {
+ TODO("move file pointer to the end");
+ }
+
+ INFO("handle for descriptor %d is %d", fildes, fdDescriptor.FileHandle);
+
+ nErrCode = NtWriteFile
+ (
+ fdDescriptor.FileHandle,
+ NULL,
+ NULL,
+ NULL,
+ &isbStatus,
+ (PVOID)buf,
+ nbyte,
+ NULL,
+ NULL
+ );
+
+ if(!NT_SUCCESS(nErrCode))
+ {
+ ERR("NtWriteFile() failed with status 0x%08X", nErrCode);
+ errno = __status_to_errno(nErrCode);
+ return (0);
+ }
+
+ return (isbStatus.Information);
+}
+
+/* EOF */
+
--- /dev/null
+/* $Id: main.c,v 1.3 2002/10/29 04:45:50 rex Exp $
+ */
+#define NTOS_MODE_USER
+#include <ntos.h>
+
+BOOL STDCALL DllMain (HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
+{
+ return TRUE;
+}
+/* EOF */
--- /dev/null
+; $Id: psxx.def,v 1.3 2002/10/29 04:45:50 rex Exp $
+;
+; ReactOS - POSIX+ - X/11 over W32k
+;
+LIBRARY psxx.dll
+;
+EXPORTS
+XActivateScreenSaver
+XAddConnectionWatch
+XAddExtension
+XAddHost
+XAddHosts
+XAddPixel
+XAddToExtensionList
+XAddToSaveSet
+XAllPlanes
+XAllocClassHint
+XAllocColor
+XAllocColorCells
+XAllocColorPlanes
+XAllocIconSize
+XAllocNamedColor
+XAllocSizeHints
+XAllocStandardColormap
+XAllocWMHints
+XAllowEvents
+XAutoRepeatOff
+XAutoRepeatOn
+XBaseFontNameListOfFontSet
+XBell
+XBitmapBitOrder
+XBitmapPad
+XBitmapUnit
+XBlackPixel
+XBlackPixelOfScreen
+XCellsOfScreen
+XChangeActivePointerGrab
+XChangeGC
+XChangeKeyboardControl
+XChangeKeyboardMapping
+XChangePointerControl
+XChangeProperty
+XChangeSaveSet
+XChangeWindowAttributes
+XCheckIfEvent
+XCheckMaskEvent
+XCheckTypedEvent
+XCheckTypedWindowEvent
+XCheckWindowEvent
+XCirculateSubwindows
+XCirculateSubwindowsDown
+XCirculateSubwindowsUp
+XClearArea
+XClearWindow
+XClipBox
+XCloseDisplay
+XCloseIM
+XCloseOM
+XConfigureWindow
+XConnectionNumber
+XContextDependentDrawing
+XContextualDrawing
+XConvertCase
+XConvertSelection
+XCopyArea
+XCopyColormapAndFree
+XCopyGC
+XCopyPlane
+XCreateBitmapFromData
+XCreateColormap
+XCreateFontCursor
+XCreateFontSet
+XCreateGC
+XCreateGlyphCursor
+XCreateIC
+XCreateImage
+XCreateOC
+XCreatePixmap
+XCreatePixmapCursor
+XCreatePixmapFromBitmapData
+XCreateRegion
+XCreateSimpleWindow
+XCreateWindow
+XDefaultColormap
+XDefaultColormapOfScreen
+XDefaultDepth
+XDefaultDepthOfScreen
+XDefaultGC
+XDefaultGCOfScreen
+XDefaultRootWindow
+XDefaultScreen
+XDefaultScreenOfDisplay
+XDefaultString
+XDefaultVisual
+XDefaultVisualOfScreen
+XDefineCursor
+XDeleteContext
+XDeleteModifiermapEntry
+XDeleteProperty
+XDestroyIC
+XDestroyImage
+XDestroyOC
+XDestroyRegion
+XDestroySubwindows
+XDestroyWindow
+XDirectionalDependentDrawing
+XDisableAccessControl
+XDisplayCells
+XDisplayHeight
+XDisplayHeightMM
+XDisplayKeycodes
+XDisplayMotionBufferSize
+XDisplayName
+XDisplayOfIM
+XDisplayOfOM
+XDisplayOfScreen
+XDisplayPlanes
+XDisplayString
+XDisplayWidth
+XDisplayWidthMM
+XDoesBackingStore
+XDoesSaveUnders
+XDrawArc
+XDrawArcs
+XDrawImageString
+XDrawImageString16
+XDrawLine
+XDrawLines
+XDrawPoint
+XDrawPoints
+XDrawRectangle
+XDrawRectangles
+XDrawSegments
+XDrawString
+XDrawString16
+XDrawText
+XDrawText16
+XEHeadOfExtensionList
+XESetBeforeFlush
+XESetCloseDisplay
+XESetCopyGC
+XESetCreateFont
+XESetCreateGC
+XESetError
+XESetErrorString
+XESetEventToWire
+XESetFlushGC
+XESetFreeFont
+XESetFreeGC
+XESetPrintErrorValues
+XESetWireToError
+XESetWireToEvent
+XEmptyRegion
+XEnableAccessControl
+XEqualRegion
+XEventMaskOfScreen
+XEventsQueued
+XExtendedMaxRequestSize
+XExtentsOfFontSet
+XFetchBuffer
+XFetchBytes
+XFetchName
+XFillArc
+XFillArcs
+XFillPolygon
+XFillRectangle
+XFillRectangles
+XFilterEvent
+XFindContext
+XFindOnExtensionList
+XFlush
+XFlushGC
+XFontsOfFontSet
+XForceScreenSaver
+XFree
+XFreeColormap
+XFreeColors
+XFreeCursor
+XFreeExtensionList
+XFreeFont
+XFreeFontInfo
+XFreeFontNames
+XFreeFontPath
+XFreeFontSet
+XFreeGC
+XFreeModifiermap
+XFreePixmap
+XFreeStringList
+XGContextFromGC
+XGeometry
+XGetAtomName
+XGetAtomNames
+XGetClassHint
+XGetCommand
+XGetDefault
+XGetErrorDatabaseText
+XGetErrorText
+XGetFontPath
+XGetFontProperty
+XGetGCValues
+XGetGeometry
+XGetICValues
+XGetIMValues
+XGetIconName
+XGetIconSizes
+XGetImage
+XGetInputFocus
+XGetKeyboardControl
+XGetKeyboardMapping
+XGetModifierMapping
+XGetMotionEvents
+XGetNormalHints
+XGetOCValues
+XGetOMValues
+XGetPixel
+XGetPointerControl
+XGetPointerMapping
+XGetRGBColormaps
+XGetScreenSaver
+XGetSelectionOwner
+XGetSizeHints
+XGetStandardColormap
+XGetSubImage
+XGetTextProperty
+XGetTransientForHint
+XGetVisualInfo
+XGetWMClientMachine
+XGetWMColormapWindows
+XGetWMHints
+XGetWMIconName
+XGetWMName
+XGetWMNormalHints
+XGetWMProtocols
+XGetWMSizeHints
+XGetWindowAttributes
+XGetWindowProperty
+XGetZoomHints
+XGrabButton
+XGrabKey
+XGrabKeyboard
+XGrabPointer
+XGrabServer
+XHeightMMOfScreen
+XHeightOfScreen
+XIMOfIC
+XIconifyWindow
+XIfEvent
+XImageByteOrder
+XInitExtension
+XInitImage
+XInitThreads
+XInsertModifiermapEntry
+XInstallColormap
+XInternAtom
+XInternAtoms
+XInternalConnectionNumbers
+XIntersectRegion
+XKeycodeToKeysym
+XKeysymToKeycode
+XKeysymToString
+XKillClient
+XLastKnownRequestProcessed
+XListDepths
+XListExtensions
+XListFonts
+XListFontsWithInfo
+XListHosts
+XListInstalledColormaps
+XListPixmapFormats
+XListProperties
+XLoadFont
+XLoadQueryFont
+XLocaleOfFontSet
+XLocaleOfIM
+XLocaleOfOM
+XLockDisplay
+XLookupColor
+XLookupKeysym
+XLookupString
+XLowerWindow
+XMapRaised
+XMapSubwindows
+XMapWindow
+XMaskEvent
+XMatchVisualInfo
+XMaxCmapsOfScreen
+XMaxRequestSize
+XMinCmapsOfScreen
+XMoveResizeWindow
+XMoveWindow
+XNewModifiermap
+XNextEvent
+XNextRequest
+XNoOp
+XOMOfOC
+XOffsetRegion
+XOpenDisplay
+XOpenIM
+XOpenOM
+XParseColor
+XParseGeometry
+XPeekEvent
+XPeekIfEvent
+XPending
+XPlanesOfScreen
+XPointInRegion
+XPolygonRegion
+XProcessInternalConnection
+XProtocolRevision
+XProtocolVersion
+XPutBackEvent
+XPutImage
+XPutPixel
+XQLength
+XQueryBestCursor
+XQueryBestSize
+XQueryBestStipple
+XQueryBestTile
+XQueryColor
+XQueryColors
+XQueryExtension
+XQueryFont
+XQueryKeymap
+XQueryPointer
+XQueryTextExtents
+XQueryTextExtents16
+XQueryTree
+XRaiseWindow
+XReadBitmapFile
+XReadBitmapFileData
+XRebindKeysym
+XRecolorCursor
+XReconfigureWMWindow
+XRectInRegion
+XRefreshKeyboardMapping
+XRegisterIMInstantiateCallback
+XRemoveConnectionWatch
+XRemoveFromSaveSet
+XRemoveHost
+XRemoveHosts
+XReparentWindow
+XResetScreenSaver
+XResizeWindow
+XResourceManagerString
+XRestackWindows
+XRootWindow
+XRootWindowOfScreen
+XRotateBuffers
+XRotateWindowProperties
+XSaveContext
+XScreenCount
+XScreenNumberOfScreen
+XScreenOfDisplay
+XScreenResourceString
+XSelectInput
+XSendEvent
+XServerVendor
+XSetAccessControl
+XSetAfterFunction
+XSetArcMode
+XSetAuthorization
+XSetBackground
+XSetClassHint
+XSetClipMask
+XSetClipOrigin
+XSetClipRectangles
+XSetCloseDownMode
+XSetCommand
+XSetDashes
+XSetErrorHandler
+XSetFillRule
+XSetFillStyle
+XSetFont
+XSetFontPath
+XSetForeground
+XSetFunction
+XSetGraphicsExposures
+XSetICFocus
+XSetICValues
+XSetIMValues
+XSetIOErrorHandler
+XSetIconName
+XSetIconSizes
+XSetInputFocus
+XSetLineAttributes
+XSetLocaleModifiers
+XSetModifierMapping
+XSetNormalHints
+XSetOCValues
+XSetOMValues
+XSetPlaneMask
+XSetPointerMapping
+XSetRGBColormaps
+XSetRegion
+XSetScreenSaver
+XSetSelectionOwner
+XSetSizeHints
+XSetStandardColormap
+XSetStandardProperties
+XSetState
+XSetStipple
+XSetSubwindowMode
+XSetTSOrigin
+XSetTextProperty
+XSetTile
+XSetTransientForHint
+XSetWMClientMachine
+XSetWMColormapWindows
+XSetWMHints
+XSetWMIconName
+XSetWMName
+XSetWMNormalHints
+XSetWMProperties
+XSetWMProtocols
+XSetWMSizeHints
+XSetWindowBackground
+XSetWindowBackgroundPixmap
+XSetWindowBorder
+XSetWindowBorderPixmap
+XSetWindowBorderWidth
+XSetWindowColormap
+XSetZoomHints
+XShrinkRegion
+XStoreBuffer
+XStoreBytes
+XStoreColor
+XStoreColors
+XStoreName
+XStoreNamedColor
+XStringListToTextProperty
+XStringToKeysym
+XSubImage
+XSubtractRegion
+XSupportsLocale
+XSync
+XSynchronize
+XTextExtents
+XTextExtents16
+XTextPropertyToStringList
+XTextWidth
+XTextWidth16
+XTranslateCoordinates
+XUndefineCursor
+XUngrabButton
+XUngrabKey
+XUngrabKeyboard
+XUngrabPointer
+XUngrabServer
+XUninstallColormap
+XUnionRectWithRegion
+XUnionRegion
+XUnloadFont
+XUnlockDisplay
+XUnmapSubwindows
+XUnmapWindow
+XUnregisterIMInstantiateCallback
+XUnsetICFocus
+XVaCreateNestedList
+XVendorRelease
+XVisualIDFromVisual
+XWMGeometry
+XWarpPointer
+XWhitePixel
+XWhitePixelOfScreen
+XWidthMMOfScreen
+XWidthOfScreen
+XWindowEvent
+XWithdrawWindow
+XWriteBitmapFile
+XXorRegion
+XcmsAddColorSpace
+XcmsAddFunctionSet
+XcmsAllocColor
+XcmsAllocNamedColor
+XcmsCCCOfColormap
+XcmsCIELabClipL
+XcmsCIELabClipLab
+XcmsCIELabClipab
+XcmsCIELabQueryMaxC
+XcmsCIELabQueryMaxL
+XcmsCIELabQueryMaxLC
+XcmsCIELabQueryMinL
+XcmsCIELabToCIEXYZ
+XcmsCIELabWhiteShiftColors
+XcmsCIELuvClipL
+XcmsCIELuvClipLuv
+XcmsCIELuvClipuv
+XcmsCIELuvQueryMaxC
+XcmsCIELuvQueryMaxL
+XcmsCIELuvQueryMaxLC
+XcmsCIELuvQueryMinL
+XcmsCIELuvToCIEuvY
+XcmsCIELuvWhiteShiftColors
+XcmsCIEXYZToCIELab
+XcmsCIEXYZToCIEuvY
+XcmsCIEXYZToCIExyY
+XcmsCIEXYZToRGBi
+XcmsCIEuvYToCIELuv
+XcmsCIEuvYToCIEXYZ
+XcmsCIEuvYToTekHVC
+XcmsCIExyYToCIEXYZ
+XcmsClientWhitePointOfCCC
+XcmsConvertColors
+XcmsCreateCCC
+XcmsDefaultCCC
+XcmsDisplayOfCCC
+XcmsFormatOfPrefix
+XcmsFreeCCC
+XcmsLookupColor
+XcmsPrefixOfFormat
+XcmsQueryBlack
+XcmsQueryBlue
+XcmsQueryColor
+XcmsQueryColors
+XcmsQueryGreen
+XcmsQueryRed
+XcmsQueryWhite
+XcmsRGBToRGBi
+XcmsRGBiToCIEXYZ
+XcmsRGBiToRGB
+XcmsScreenNumberOfCCC
+XcmsScreenWhitePointOfCCC
+XcmsSetCCCOfColormap
+XcmsSetCompressionProc
+XcmsSetWhiteAdjustProc
+XcmsSetWhitePoint
+XcmsStoreColor
+XcmsStoreColors
+XcmsTekHVCClipC
+XcmsTekHVCClipV
+XcmsTekHVCClipVC
+XcmsTekHVCQueryMaxC
+XcmsTekHVCQueryMaxV
+XcmsTekHVCQueryMaxVC
+XcmsTekHVCQueryMaxVSamples
+XcmsTekHVCQueryMinV
+XcmsTekHVCToCIEuvY
+XcmsTekHVCWhiteShiftColors
+XcmsVisualOfCCC
+XmbDrawImageString
+XmbDrawString
+XmbDrawText
+XmbLookupString
+XmbResetIC
+XmbSetWMProperties
+XmbTextEscapement
+XmbTextExtents
+XmbTextListToTextProperty
+XmbTextPerCharExtents
+XmbTextPropertyToTextList
+Xpermalloc
+XrmCombineDatabase
+XrmCombineFileDatabase
+XrmDestroyDatabase
+XrmEnumerateDatabase
+XrmGetDatabase
+XrmGetFileDatabase
+XrmGetResource
+XrmGetStringDatabase
+XrmInitialize
+XrmLocaleOfDatabase
+XrmMergeDatabases
+XrmParseCommand
+XrmPermStringToQuark
+XrmPutFileDatabase
+XrmPutLineResource
+XrmPutResource
+XrmPutStringResource
+XrmQGetResource
+XrmQGetSearchList
+XrmQGetSearchResource
+XrmQPutResource
+XrmQPutStringResource
+XrmQuarkToString
+XrmSetDatabase
+XrmStringToBindingQuarkList
+XrmStringToQuark
+XrmStringToQuarkList
+XrmUniqueQuark
+XwcDrawImageString
+XwcDrawString
+XwcDrawText
+XwcFreeStringList
+XwcLookupString
+XwcResetIC
+XwcTextEscapement
+XwcTextExtents
+XwcTextListToTextProperty
+XwcTextPerCharExtents
+XwcTextPropertyToTextList
+_XAllocID
+_XAllocIDs
+_XAllocScratch
+_XAllocTemp
+_XAsyncErrorHandler
+_XConnectDisplay
+_XCreateMutex_fn_p
+_XDeqAsyncHandler
+_XEatData
+_XError
+_XFlushGCCache
+_XFlushIt
+_XFreeMutex_fn_p
+_XFreeTemp
+_XGetAsyncData
+_XGetAsyncReply
+_XIOError
+_XInitImageFuncPtrs
+_XKillTimer
+_XLockMutex_fn_p
+_XRead
+_XReadEvents
+_XReadPad
+_XRegisterFilterByMask
+_XRegisterFilterByType
+_XRegisterInternalConnection
+_XReply
+_XSend
+_XSetLastRequestRead
+_XSetTimer
+_XUnknownNativeEvent
+_XUnlockMutex_fn_p
+_XUnregisterFilter
+_XUnregisterInternalConnection
+_XVIDtoVisual
+_XWinSelectWindow
+_Xdebug_p
+_Xglobal_lock_p
+_Xthread_init
+_Xthread_waiter
+; EOF
--- /dev/null
+; $Id: psxx.edf,v 1.3 2002/10/29 04:45:50 rex Exp $
+;
+; ReactOS - POSIX+ - X/11 over W32k
+;
+LIBRARY psxx.dll
+;
+EXPORTS
+XActivateScreenSaver
+XAddConnectionWatch
+XAddExtension
+XAddHost
+XAddHosts
+XAddPixel
+XAddToExtensionList
+XAddToSaveSet
+XAllPlanes
+XAllocClassHint
+XAllocColor
+XAllocColorCells
+XAllocColorPlanes
+XAllocIconSize
+XAllocNamedColor
+XAllocSizeHints
+XAllocStandardColormap
+XAllocWMHints
+XAllowEvents
+XAutoRepeatOff
+XAutoRepeatOn
+XBaseFontNameListOfFontSet
+XBell
+XBitmapBitOrder
+XBitmapPad
+XBitmapUnit
+XBlackPixel
+XBlackPixelOfScreen
+XCellsOfScreen
+XChangeActivePointerGrab
+XChangeGC
+XChangeKeyboardControl
+XChangeKeyboardMapping
+XChangePointerControl
+XChangeProperty
+XChangeSaveSet
+XChangeWindowAttributes
+XCheckIfEvent
+XCheckMaskEvent
+XCheckTypedEvent
+XCheckTypedWindowEvent
+XCheckWindowEvent
+XCirculateSubwindows
+XCirculateSubwindowsDown
+XCirculateSubwindowsUp
+XClearArea
+XClearWindow
+XClipBox
+XCloseDisplay
+XCloseIM
+XCloseOM
+XConfigureWindow
+XConnectionNumber
+XContextDependentDrawing
+XContextualDrawing
+XConvertCase
+XConvertSelection
+XCopyArea
+XCopyColormapAndFree
+XCopyGC
+XCopyPlane
+XCreateBitmapFromData
+XCreateColormap
+XCreateFontCursor
+XCreateFontSet
+XCreateGC
+XCreateGlyphCursor
+XCreateIC
+XCreateImage
+XCreateOC
+XCreatePixmap
+XCreatePixmapCursor
+XCreatePixmapFromBitmapData
+XCreateRegion
+XCreateSimpleWindow
+XCreateWindow
+XDefaultColormap
+XDefaultColormapOfScreen
+XDefaultDepth
+XDefaultDepthOfScreen
+XDefaultGC
+XDefaultGCOfScreen
+XDefaultRootWindow
+XDefaultScreen
+XDefaultScreenOfDisplay
+XDefaultString
+XDefaultVisual
+XDefaultVisualOfScreen
+XDefineCursor
+XDeleteContext
+XDeleteModifiermapEntry
+XDeleteProperty
+XDestroyIC
+XDestroyImage
+XDestroyOC
+XDestroyRegion
+XDestroySubwindows
+XDestroyWindow
+XDirectionalDependentDrawing
+XDisableAccessControl
+XDisplayCells
+XDisplayHeight
+XDisplayHeightMM
+XDisplayKeycodes
+XDisplayMotionBufferSize
+XDisplayName
+XDisplayOfIM
+XDisplayOfOM
+XDisplayOfScreen
+XDisplayPlanes
+XDisplayString
+XDisplayWidth
+XDisplayWidthMM
+XDoesBackingStore
+XDoesSaveUnders
+XDrawArc
+XDrawArcs
+XDrawImageString
+XDrawImageString16
+XDrawLine
+XDrawLines
+XDrawPoint
+XDrawPoints
+XDrawRectangle
+XDrawRectangles
+XDrawSegments
+XDrawString
+XDrawString16
+XDrawText
+XDrawText16
+XEHeadOfExtensionList
+XESetBeforeFlush
+XESetCloseDisplay
+XESetCopyGC
+XESetCreateFont
+XESetCreateGC
+XESetError
+XESetErrorString
+XESetEventToWire
+XESetFlushGC
+XESetFreeFont
+XESetFreeGC
+XESetPrintErrorValues
+XESetWireToError
+XESetWireToEvent
+XEmptyRegion
+XEnableAccessControl
+XEqualRegion
+XEventMaskOfScreen
+XEventsQueued
+XExtendedMaxRequestSize
+XExtentsOfFontSet
+XFetchBuffer
+XFetchBytes
+XFetchName
+XFillArc
+XFillArcs
+XFillPolygon
+XFillRectangle
+XFillRectangles
+XFilterEvent
+XFindContext
+XFindOnExtensionList
+XFlush
+XFlushGC
+XFontsOfFontSet
+XForceScreenSaver
+XFree
+XFreeColormap
+XFreeColors
+XFreeCursor
+XFreeExtensionList
+XFreeFont
+XFreeFontInfo
+XFreeFontNames
+XFreeFontPath
+XFreeFontSet
+XFreeGC
+XFreeModifiermap
+XFreePixmap
+XFreeStringList
+XGContextFromGC
+XGeometry
+XGetAtomName
+XGetAtomNames
+XGetClassHint
+XGetCommand
+XGetDefault
+XGetErrorDatabaseText
+XGetErrorText
+XGetFontPath
+XGetFontProperty
+XGetGCValues
+XGetGeometry
+XGetICValues
+XGetIMValues
+XGetIconName
+XGetIconSizes
+XGetImage
+XGetInputFocus
+XGetKeyboardControl
+XGetKeyboardMapping
+XGetModifierMapping
+XGetMotionEvents
+XGetNormalHints
+XGetOCValues
+XGetOMValues
+XGetPixel
+XGetPointerControl
+XGetPointerMapping
+XGetRGBColormaps
+XGetScreenSaver
+XGetSelectionOwner
+XGetSizeHints
+XGetStandardColormap
+XGetSubImage
+XGetTextProperty
+XGetTransientForHint
+XGetVisualInfo
+XGetWMClientMachine
+XGetWMColormapWindows
+XGetWMHints
+XGetWMIconName
+XGetWMName
+XGetWMNormalHints
+XGetWMProtocols
+XGetWMSizeHints
+XGetWindowAttributes
+XGetWindowProperty
+XGetZoomHints
+XGrabButton
+XGrabKey
+XGrabKeyboard
+XGrabPointer
+XGrabServer
+XHeightMMOfScreen
+XHeightOfScreen
+XIMOfIC
+XIconifyWindow
+XIfEvent
+XImageByteOrder
+XInitExtension
+XInitImage
+XInitThreads
+XInsertModifiermapEntry
+XInstallColormap
+XInternAtom
+XInternAtoms
+XInternalConnectionNumbers
+XIntersectRegion
+XKeycodeToKeysym
+XKeysymToKeycode
+XKeysymToString
+XKillClient
+XLastKnownRequestProcessed
+XListDepths
+XListExtensions
+XListFonts
+XListFontsWithInfo
+XListHosts
+XListInstalledColormaps
+XListPixmapFormats
+XListProperties
+XLoadFont
+XLoadQueryFont
+XLocaleOfFontSet
+XLocaleOfIM
+XLocaleOfOM
+XLockDisplay
+XLookupColor
+XLookupKeysym
+XLookupString
+XLowerWindow
+XMapRaised
+XMapSubwindows
+XMapWindow
+XMaskEvent
+XMatchVisualInfo
+XMaxCmapsOfScreen
+XMaxRequestSize
+XMinCmapsOfScreen
+XMoveResizeWindow
+XMoveWindow
+XNewModifiermap
+XNextEvent
+XNextRequest
+XNoOp
+XOMOfOC
+XOffsetRegion
+XOpenDisplay
+XOpenIM
+XOpenOM
+XParseColor
+XParseGeometry
+XPeekEvent
+XPeekIfEvent
+XPending
+XPlanesOfScreen
+XPointInRegion
+XPolygonRegion
+XProcessInternalConnection
+XProtocolRevision
+XProtocolVersion
+XPutBackEvent
+XPutImage
+XPutPixel
+XQLength
+XQueryBestCursor
+XQueryBestSize
+XQueryBestStipple
+XQueryBestTile
+XQueryColor
+XQueryColors
+XQueryExtension
+XQueryFont
+XQueryKeymap
+XQueryPointer
+XQueryTextExtents
+XQueryTextExtents16
+XQueryTree
+XRaiseWindow
+XReadBitmapFile
+XReadBitmapFileData
+XRebindKeysym
+XRecolorCursor
+XReconfigureWMWindow
+XRectInRegion
+XRefreshKeyboardMapping
+XRegisterIMInstantiateCallback
+XRemoveConnectionWatch
+XRemoveFromSaveSet
+XRemoveHost
+XRemoveHosts
+XReparentWindow
+XResetScreenSaver
+XResizeWindow
+XResourceManagerString
+XRestackWindows
+XRootWindow
+XRootWindowOfScreen
+XRotateBuffers
+XRotateWindowProperties
+XSaveContext
+XScreenCount
+XScreenNumberOfScreen
+XScreenOfDisplay
+XScreenResourceString
+XSelectInput
+XSendEvent
+XServerVendor
+XSetAccessControl
+XSetAfterFunction
+XSetArcMode
+XSetAuthorization
+XSetBackground
+XSetClassHint
+XSetClipMask
+XSetClipOrigin
+XSetClipRectangles
+XSetCloseDownMode
+XSetCommand
+XSetDashes
+XSetErrorHandler
+XSetFillRule
+XSetFillStyle
+XSetFont
+XSetFontPath
+XSetForeground
+XSetFunction
+XSetGraphicsExposures
+XSetICFocus
+XSetICValues
+XSetIMValues
+XSetIOErrorHandler
+XSetIconName
+XSetIconSizes
+XSetInputFocus
+XSetLineAttributes
+XSetLocaleModifiers
+XSetModifierMapping
+XSetNormalHints
+XSetOCValues
+XSetOMValues
+XSetPlaneMask
+XSetPointerMapping
+XSetRGBColormaps
+XSetRegion
+XSetScreenSaver
+XSetSelectionOwner
+XSetSizeHints
+XSetStandardColormap
+XSetStandardProperties
+XSetState
+XSetStipple
+XSetSubwindowMode
+XSetTSOrigin
+XSetTextProperty
+XSetTile
+XSetTransientForHint
+XSetWMClientMachine
+XSetWMColormapWindows
+XSetWMHints
+XSetWMIconName
+XSetWMName
+XSetWMNormalHints
+XSetWMProperties
+XSetWMProtocols
+XSetWMSizeHints
+XSetWindowBackground
+XSetWindowBackgroundPixmap
+XSetWindowBorder
+XSetWindowBorderPixmap
+XSetWindowBorderWidth
+XSetWindowColormap
+XSetZoomHints
+XShrinkRegion
+XStoreBuffer
+XStoreBytes
+XStoreColor
+XStoreColors
+XStoreName
+XStoreNamedColor
+XStringListToTextProperty
+XStringToKeysym
+XSubImage
+XSubtractRegion
+XSupportsLocale
+XSync
+XSynchronize
+XTextExtents
+XTextExtents16
+XTextPropertyToStringList
+XTextWidth
+XTextWidth16
+XTranslateCoordinates
+XUndefineCursor
+XUngrabButton
+XUngrabKey
+XUngrabKeyboard
+XUngrabPointer
+XUngrabServer
+XUninstallColormap
+XUnionRectWithRegion
+XUnionRegion
+XUnloadFont
+XUnlockDisplay
+XUnmapSubwindows
+XUnmapWindow
+XUnregisterIMInstantiateCallback
+XUnsetICFocus
+XVaCreateNestedList
+XVendorRelease
+XVisualIDFromVisual
+XWMGeometry
+XWarpPointer
+XWhitePixel
+XWhitePixelOfScreen
+XWidthMMOfScreen
+XWidthOfScreen
+XWindowEvent
+XWithdrawWindow
+XWriteBitmapFile
+XXorRegion
+XcmsAddColorSpace
+XcmsAddFunctionSet
+XcmsAllocColor
+XcmsAllocNamedColor
+XcmsCCCOfColormap
+XcmsCIELabClipL
+XcmsCIELabClipLab
+XcmsCIELabClipab
+XcmsCIELabQueryMaxC
+XcmsCIELabQueryMaxL
+XcmsCIELabQueryMaxLC
+XcmsCIELabQueryMinL
+XcmsCIELabToCIEXYZ
+XcmsCIELabWhiteShiftColors
+XcmsCIELuvClipL
+XcmsCIELuvClipLuv
+XcmsCIELuvClipuv
+XcmsCIELuvQueryMaxC
+XcmsCIELuvQueryMaxL
+XcmsCIELuvQueryMaxLC
+XcmsCIELuvQueryMinL
+XcmsCIELuvToCIEuvY
+XcmsCIELuvWhiteShiftColors
+XcmsCIEXYZToCIELab
+XcmsCIEXYZToCIEuvY
+XcmsCIEXYZToCIExyY
+XcmsCIEXYZToRGBi
+XcmsCIEuvYToCIELuv
+XcmsCIEuvYToCIEXYZ
+XcmsCIEuvYToTekHVC
+XcmsCIExyYToCIEXYZ
+XcmsClientWhitePointOfCCC
+XcmsConvertColors
+XcmsCreateCCC
+XcmsDefaultCCC
+XcmsDisplayOfCCC
+XcmsFormatOfPrefix
+XcmsFreeCCC
+XcmsLookupColor
+XcmsPrefixOfFormat
+XcmsQueryBlack
+XcmsQueryBlue
+XcmsQueryColor
+XcmsQueryColors
+XcmsQueryGreen
+XcmsQueryRed
+XcmsQueryWhite
+XcmsRGBToRGBi
+XcmsRGBiToCIEXYZ
+XcmsRGBiToRGB
+XcmsScreenNumberOfCCC
+XcmsScreenWhitePointOfCCC
+XcmsSetCCCOfColormap
+XcmsSetCompressionProc
+XcmsSetWhiteAdjustProc
+XcmsSetWhitePoint
+XcmsStoreColor
+XcmsStoreColors
+XcmsTekHVCClipC
+XcmsTekHVCClipV
+XcmsTekHVCClipVC
+XcmsTekHVCQueryMaxC
+XcmsTekHVCQueryMaxV
+XcmsTekHVCQueryMaxVC
+XcmsTekHVCQueryMaxVSamples
+XcmsTekHVCQueryMinV
+XcmsTekHVCToCIEuvY
+XcmsTekHVCWhiteShiftColors
+XcmsVisualOfCCC
+XmbDrawImageString
+XmbDrawString
+XmbDrawText
+XmbLookupString
+XmbResetIC
+XmbSetWMProperties
+XmbTextEscapement
+XmbTextExtents
+XmbTextListToTextProperty
+XmbTextPerCharExtents
+XmbTextPropertyToTextList
+Xpermalloc
+XrmCombineDatabase
+XrmCombineFileDatabase
+XrmDestroyDatabase
+XrmEnumerateDatabase
+XrmGetDatabase
+XrmGetFileDatabase
+XrmGetResource
+XrmGetStringDatabase
+XrmInitialize
+XrmLocaleOfDatabase
+XrmMergeDatabases
+XrmParseCommand
+XrmPermStringToQuark
+XrmPutFileDatabase
+XrmPutLineResource
+XrmPutResource
+XrmPutStringResource
+XrmQGetResource
+XrmQGetSearchList
+XrmQGetSearchResource
+XrmQPutResource
+XrmQPutStringResource
+XrmQuarkToString
+XrmSetDatabase
+XrmStringToBindingQuarkList
+XrmStringToQuark
+XrmStringToQuarkList
+XrmUniqueQuark
+XwcDrawImageString
+XwcDrawString
+XwcDrawText
+XwcFreeStringList
+XwcLookupString
+XwcResetIC
+XwcTextEscapement
+XwcTextExtents
+XwcTextListToTextProperty
+XwcTextPerCharExtents
+XwcTextPropertyToTextList
+_XAllocID
+_XAllocIDs
+_XAllocScratch
+_XAllocTemp
+_XAsyncErrorHandler
+_XConnectDisplay
+_XCreateMutex_fn_p
+_XDeqAsyncHandler
+_XEatData
+_XError
+_XFlushGCCache
+_XFlushIt
+_XFreeMutex_fn_p
+_XFreeTemp
+_XGetAsyncData
+_XGetAsyncReply
+_XIOError
+_XInitImageFuncPtrs
+_XKillTimer
+_XLockMutex_fn_p
+_XRead
+_XReadEvents
+_XReadPad
+_XRegisterFilterByMask
+_XRegisterFilterByType
+_XRegisterInternalConnection
+_XReply
+_XSend
+_XSetLastRequestRead
+_XSetTimer
+_XUnknownNativeEvent
+_XUnlockMutex_fn_p
+_XUnregisterFilter
+_XUnregisterInternalConnection
+_XVIDtoVisual
+_XWinSelectWindow
+_Xdebug_p
+_Xglobal_lock_p
+_Xthread_init
+_Xthread_waiter
+; EOF
--- /dev/null
+#include <defines.h>
+#include <reactos/resource.h>
+
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION RES_UINT_FV_MAJOR,RES_UINT_FV_MINOR,RES_UINT_FV_REVISION,RES_UINT_FV_BUILD
+ PRODUCTVERSION RES_UINT_PV_MAJOR,RES_UINT_PV_MINOR,RES_UINT_PV_REVISION,RES_UINT_PV_BUILD
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x40004L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "CompanyName", RES_STR_COMPANY_NAME
+ VALUE "FileDescription", "X11R6 client library for the POSIX+ Subsystem\0"
+ VALUE "FileVersion", RES_STR_FILE_VERSION
+ VALUE "InternalName", "psxx\0"
+ VALUE "LegalCopyright", RES_STR_LEGAL_COPYRIGHT
+ VALUE "OriginalFilename", "psxx.dll\0"
+ VALUE "ProductName", RES_STR_PRODUCT_NAME
+ VALUE "ProductVersion", RES_STR_PRODUCT_VERSION
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
--- /dev/null
+/* $Id: stubs.c,v 1.3 2002/10/29 04:45:50 rex Exp $
+ *
+ * ReactOS - POSIX+ - X/11 over W32k
+ */
+#define X_NOT_IMPLEMENTED(n) void n(void) {}
+X_NOT_IMPLEMENTED(XActivateScreenSaver)
+X_NOT_IMPLEMENTED(XAddConnectionWatch)
+X_NOT_IMPLEMENTED(XAddExtension)
+X_NOT_IMPLEMENTED(XAddHost)
+X_NOT_IMPLEMENTED(XAddHosts)
+X_NOT_IMPLEMENTED(XAddPixel)
+X_NOT_IMPLEMENTED(XAddToExtensionList)
+X_NOT_IMPLEMENTED(XAddToSaveSet)
+X_NOT_IMPLEMENTED(XAllPlanes)
+X_NOT_IMPLEMENTED(XAllocClassHint)
+X_NOT_IMPLEMENTED(XAllocColor)
+X_NOT_IMPLEMENTED(XAllocColorCells)
+X_NOT_IMPLEMENTED(XAllocColorPlanes)
+X_NOT_IMPLEMENTED(XAllocIconSize)
+X_NOT_IMPLEMENTED(XAllocNamedColor)
+X_NOT_IMPLEMENTED(XAllocSizeHints)
+X_NOT_IMPLEMENTED(XAllocStandardColormap)
+X_NOT_IMPLEMENTED(XAllocWMHints)
+X_NOT_IMPLEMENTED(XAllowEvents)
+X_NOT_IMPLEMENTED(XAutoRepeatOff)
+X_NOT_IMPLEMENTED(XAutoRepeatOn)
+X_NOT_IMPLEMENTED(XBaseFontNameListOfFontSet)
+X_NOT_IMPLEMENTED(XBell)
+X_NOT_IMPLEMENTED(XBitmapBitOrder)
+X_NOT_IMPLEMENTED(XBitmapPad)
+X_NOT_IMPLEMENTED(XBitmapUnit)
+X_NOT_IMPLEMENTED(XBlackPixel)
+X_NOT_IMPLEMENTED(XBlackPixelOfScreen)
+X_NOT_IMPLEMENTED(XCellsOfScreen)
+X_NOT_IMPLEMENTED(XChangeActivePointerGrab)
+X_NOT_IMPLEMENTED(XChangeGC)
+X_NOT_IMPLEMENTED(XChangeKeyboardControl)
+X_NOT_IMPLEMENTED(XChangeKeyboardMapping)
+X_NOT_IMPLEMENTED(XChangePointerControl)
+X_NOT_IMPLEMENTED(XChangeProperty)
+X_NOT_IMPLEMENTED(XChangeSaveSet)
+X_NOT_IMPLEMENTED(XChangeWindowAttributes)
+X_NOT_IMPLEMENTED(XCheckIfEvent)
+X_NOT_IMPLEMENTED(XCheckMaskEvent)
+X_NOT_IMPLEMENTED(XCheckTypedEvent)
+X_NOT_IMPLEMENTED(XCheckTypedWindowEvent)
+X_NOT_IMPLEMENTED(XCheckWindowEvent)
+X_NOT_IMPLEMENTED(XCirculateSubwindows)
+X_NOT_IMPLEMENTED(XCirculateSubwindowsDown)
+X_NOT_IMPLEMENTED(XCirculateSubwindowsUp)
+X_NOT_IMPLEMENTED(XClearArea)
+X_NOT_IMPLEMENTED(XClearWindow)
+X_NOT_IMPLEMENTED(XClipBox)
+X_NOT_IMPLEMENTED(XCloseDisplay)
+X_NOT_IMPLEMENTED(XCloseIM)
+X_NOT_IMPLEMENTED(XCloseOM)
+X_NOT_IMPLEMENTED(XConfigureWindow)
+X_NOT_IMPLEMENTED(XConnectionNumber)
+X_NOT_IMPLEMENTED(XContextDependentDrawing)
+X_NOT_IMPLEMENTED(XContextualDrawing)
+X_NOT_IMPLEMENTED(XConvertCase)
+X_NOT_IMPLEMENTED(XConvertSelection)
+X_NOT_IMPLEMENTED(XCopyArea)
+X_NOT_IMPLEMENTED(XCopyColormapAndFree)
+X_NOT_IMPLEMENTED(XCopyGC)
+X_NOT_IMPLEMENTED(XCopyPlane)
+X_NOT_IMPLEMENTED(XCreateBitmapFromData)
+X_NOT_IMPLEMENTED(XCreateColormap)
+X_NOT_IMPLEMENTED(XCreateFontCursor)
+X_NOT_IMPLEMENTED(XCreateFontSet)
+X_NOT_IMPLEMENTED(XCreateGC)
+X_NOT_IMPLEMENTED(XCreateGlyphCursor)
+X_NOT_IMPLEMENTED(XCreateIC)
+X_NOT_IMPLEMENTED(XCreateImage)
+X_NOT_IMPLEMENTED(XCreateOC)
+X_NOT_IMPLEMENTED(XCreatePixmap)
+X_NOT_IMPLEMENTED(XCreatePixmapCursor)
+X_NOT_IMPLEMENTED(XCreatePixmapFromBitmapData)
+X_NOT_IMPLEMENTED(XCreateRegion)
+X_NOT_IMPLEMENTED(XCreateSimpleWindow)
+X_NOT_IMPLEMENTED(XCreateWindow)
+X_NOT_IMPLEMENTED(XDefaultColormap)
+X_NOT_IMPLEMENTED(XDefaultColormapOfScreen)
+X_NOT_IMPLEMENTED(XDefaultDepth)
+X_NOT_IMPLEMENTED(XDefaultDepthOfScreen)
+X_NOT_IMPLEMENTED(XDefaultGC)
+X_NOT_IMPLEMENTED(XDefaultGCOfScreen)
+X_NOT_IMPLEMENTED(XDefaultRootWindow)
+X_NOT_IMPLEMENTED(XDefaultScreen)
+X_NOT_IMPLEMENTED(XDefaultScreenOfDisplay)
+X_NOT_IMPLEMENTED(XDefaultString)
+X_NOT_IMPLEMENTED(XDefaultVisual)
+X_NOT_IMPLEMENTED(XDefaultVisualOfScreen)
+X_NOT_IMPLEMENTED(XDefineCursor)
+X_NOT_IMPLEMENTED(XDeleteContext)
+X_NOT_IMPLEMENTED(XDeleteModifiermapEntry)
+X_NOT_IMPLEMENTED(XDeleteProperty)
+X_NOT_IMPLEMENTED(XDestroyIC)
+X_NOT_IMPLEMENTED(XDestroyImage)
+X_NOT_IMPLEMENTED(XDestroyOC)
+X_NOT_IMPLEMENTED(XDestroyRegion)
+X_NOT_IMPLEMENTED(XDestroySubwindows)
+X_NOT_IMPLEMENTED(XDestroyWindow)
+X_NOT_IMPLEMENTED(XDirectionalDependentDrawing)
+X_NOT_IMPLEMENTED(XDisableAccessControl)
+X_NOT_IMPLEMENTED(XDisplayCells)
+X_NOT_IMPLEMENTED(XDisplayHeight)
+X_NOT_IMPLEMENTED(XDisplayHeightMM)
+X_NOT_IMPLEMENTED(XDisplayKeycodes)
+X_NOT_IMPLEMENTED(XDisplayMotionBufferSize)
+X_NOT_IMPLEMENTED(XDisplayName)
+X_NOT_IMPLEMENTED(XDisplayOfIM)
+X_NOT_IMPLEMENTED(XDisplayOfOM)
+X_NOT_IMPLEMENTED(XDisplayOfScreen)
+X_NOT_IMPLEMENTED(XDisplayPlanes)
+X_NOT_IMPLEMENTED(XDisplayString)
+X_NOT_IMPLEMENTED(XDisplayWidth)
+X_NOT_IMPLEMENTED(XDisplayWidthMM)
+X_NOT_IMPLEMENTED(XDoesBackingStore)
+X_NOT_IMPLEMENTED(XDoesSaveUnders)
+X_NOT_IMPLEMENTED(XDrawArc)
+X_NOT_IMPLEMENTED(XDrawArcs)
+X_NOT_IMPLEMENTED(XDrawImageString)
+X_NOT_IMPLEMENTED(XDrawImageString16)
+X_NOT_IMPLEMENTED(XDrawLine)
+X_NOT_IMPLEMENTED(XDrawLines)
+X_NOT_IMPLEMENTED(XDrawPoint)
+X_NOT_IMPLEMENTED(XDrawPoints)
+X_NOT_IMPLEMENTED(XDrawRectangle)
+X_NOT_IMPLEMENTED(XDrawRectangles)
+X_NOT_IMPLEMENTED(XDrawSegments)
+X_NOT_IMPLEMENTED(XDrawString)
+X_NOT_IMPLEMENTED(XDrawString16)
+X_NOT_IMPLEMENTED(XDrawText)
+X_NOT_IMPLEMENTED(XDrawText16)
+X_NOT_IMPLEMENTED(XEHeadOfExtensionList)
+X_NOT_IMPLEMENTED(XESetBeforeFlush)
+X_NOT_IMPLEMENTED(XESetCloseDisplay)
+X_NOT_IMPLEMENTED(XESetCopyGC)
+X_NOT_IMPLEMENTED(XESetCreateFont)
+X_NOT_IMPLEMENTED(XESetCreateGC)
+X_NOT_IMPLEMENTED(XESetError)
+X_NOT_IMPLEMENTED(XESetErrorString)
+X_NOT_IMPLEMENTED(XESetEventToWire)
+X_NOT_IMPLEMENTED(XESetFlushGC)
+X_NOT_IMPLEMENTED(XESetFreeFont)
+X_NOT_IMPLEMENTED(XESetFreeGC)
+X_NOT_IMPLEMENTED(XESetPrintErrorValues)
+X_NOT_IMPLEMENTED(XESetWireToError)
+X_NOT_IMPLEMENTED(XESetWireToEvent)
+X_NOT_IMPLEMENTED(XEmptyRegion)
+X_NOT_IMPLEMENTED(XEnableAccessControl)
+X_NOT_IMPLEMENTED(XEqualRegion)
+X_NOT_IMPLEMENTED(XEventMaskOfScreen)
+X_NOT_IMPLEMENTED(XEventsQueued)
+X_NOT_IMPLEMENTED(XExtendedMaxRequestSize)
+X_NOT_IMPLEMENTED(XExtentsOfFontSet)
+X_NOT_IMPLEMENTED(XFetchBuffer)
+X_NOT_IMPLEMENTED(XFetchBytes)
+X_NOT_IMPLEMENTED(XFetchName)
+X_NOT_IMPLEMENTED(XFillArc)
+X_NOT_IMPLEMENTED(XFillArcs)
+X_NOT_IMPLEMENTED(XFillPolygon)
+X_NOT_IMPLEMENTED(XFillRectangle)
+X_NOT_IMPLEMENTED(XFillRectangles)
+X_NOT_IMPLEMENTED(XFilterEvent)
+X_NOT_IMPLEMENTED(XFindContext)
+X_NOT_IMPLEMENTED(XFindOnExtensionList)
+X_NOT_IMPLEMENTED(XFlush)
+X_NOT_IMPLEMENTED(XFlushGC)
+X_NOT_IMPLEMENTED(XFontsOfFontSet)
+X_NOT_IMPLEMENTED(XForceScreenSaver)
+X_NOT_IMPLEMENTED(XFree)
+X_NOT_IMPLEMENTED(XFreeColormap)
+X_NOT_IMPLEMENTED(XFreeColors)
+X_NOT_IMPLEMENTED(XFreeCursor)
+X_NOT_IMPLEMENTED(XFreeExtensionList)
+X_NOT_IMPLEMENTED(XFreeFont)
+X_NOT_IMPLEMENTED(XFreeFontInfo)
+X_NOT_IMPLEMENTED(XFreeFontNames)
+X_NOT_IMPLEMENTED(XFreeFontPath)
+X_NOT_IMPLEMENTED(XFreeFontSet)
+X_NOT_IMPLEMENTED(XFreeGC)
+X_NOT_IMPLEMENTED(XFreeModifiermap)
+X_NOT_IMPLEMENTED(XFreePixmap)
+X_NOT_IMPLEMENTED(XFreeStringList)
+X_NOT_IMPLEMENTED(XGContextFromGC)
+X_NOT_IMPLEMENTED(XGeometry)
+X_NOT_IMPLEMENTED(XGetAtomName)
+X_NOT_IMPLEMENTED(XGetAtomNames)
+X_NOT_IMPLEMENTED(XGetClassHint)
+X_NOT_IMPLEMENTED(XGetCommand)
+X_NOT_IMPLEMENTED(XGetDefault)
+X_NOT_IMPLEMENTED(XGetErrorDatabaseText)
+X_NOT_IMPLEMENTED(XGetErrorText)
+X_NOT_IMPLEMENTED(XGetFontPath)
+X_NOT_IMPLEMENTED(XGetFontProperty)
+X_NOT_IMPLEMENTED(XGetGCValues)
+X_NOT_IMPLEMENTED(XGetGeometry)
+X_NOT_IMPLEMENTED(XGetICValues)
+X_NOT_IMPLEMENTED(XGetIMValues)
+X_NOT_IMPLEMENTED(XGetIconName)
+X_NOT_IMPLEMENTED(XGetIconSizes)
+X_NOT_IMPLEMENTED(XGetImage)
+X_NOT_IMPLEMENTED(XGetInputFocus)
+X_NOT_IMPLEMENTED(XGetKeyboardControl)
+X_NOT_IMPLEMENTED(XGetKeyboardMapping)
+X_NOT_IMPLEMENTED(XGetModifierMapping)
+X_NOT_IMPLEMENTED(XGetMotionEvents)
+X_NOT_IMPLEMENTED(XGetNormalHints)
+X_NOT_IMPLEMENTED(XGetOCValues)
+X_NOT_IMPLEMENTED(XGetOMValues)
+X_NOT_IMPLEMENTED(XGetPixel)
+X_NOT_IMPLEMENTED(XGetPointerControl)
+X_NOT_IMPLEMENTED(XGetPointerMapping)
+X_NOT_IMPLEMENTED(XGetRGBColormaps)
+X_NOT_IMPLEMENTED(XGetScreenSaver)
+X_NOT_IMPLEMENTED(XGetSelectionOwner)
+X_NOT_IMPLEMENTED(XGetSizeHints)
+X_NOT_IMPLEMENTED(XGetStandardColormap)
+X_NOT_IMPLEMENTED(XGetSubImage)
+X_NOT_IMPLEMENTED(XGetTextProperty)
+X_NOT_IMPLEMENTED(XGetTransientForHint)
+X_NOT_IMPLEMENTED(XGetVisualInfo)
+X_NOT_IMPLEMENTED(XGetWMClientMachine)
+X_NOT_IMPLEMENTED(XGetWMColormapWindows)
+X_NOT_IMPLEMENTED(XGetWMHints)
+X_NOT_IMPLEMENTED(XGetWMIconName)
+X_NOT_IMPLEMENTED(XGetWMName)
+X_NOT_IMPLEMENTED(XGetWMNormalHints)
+X_NOT_IMPLEMENTED(XGetWMProtocols)
+X_NOT_IMPLEMENTED(XGetWMSizeHints)
+X_NOT_IMPLEMENTED(XGetWindowAttributes)
+X_NOT_IMPLEMENTED(XGetWindowProperty)
+X_NOT_IMPLEMENTED(XGetZoomHints)
+X_NOT_IMPLEMENTED(XGrabButton)
+X_NOT_IMPLEMENTED(XGrabKey)
+X_NOT_IMPLEMENTED(XGrabKeyboard)
+X_NOT_IMPLEMENTED(XGrabPointer)
+X_NOT_IMPLEMENTED(XGrabServer)
+X_NOT_IMPLEMENTED(XHeightMMOfScreen)
+X_NOT_IMPLEMENTED(XHeightOfScreen)
+X_NOT_IMPLEMENTED(XIMOfIC)
+X_NOT_IMPLEMENTED(XIconifyWindow)
+X_NOT_IMPLEMENTED(XIfEvent)
+X_NOT_IMPLEMENTED(XImageByteOrder)
+X_NOT_IMPLEMENTED(XInitExtension)
+X_NOT_IMPLEMENTED(XInitImage)
+X_NOT_IMPLEMENTED(XInitThreads)
+X_NOT_IMPLEMENTED(XInsertModifiermapEntry)
+X_NOT_IMPLEMENTED(XInstallColormap)
+X_NOT_IMPLEMENTED(XInternAtom)
+X_NOT_IMPLEMENTED(XInternAtoms)
+X_NOT_IMPLEMENTED(XInternalConnectionNumbers)
+X_NOT_IMPLEMENTED(XIntersectRegion)
+X_NOT_IMPLEMENTED(XKeycodeToKeysym)
+X_NOT_IMPLEMENTED(XKeysymToKeycode)
+X_NOT_IMPLEMENTED(XKeysymToString)
+X_NOT_IMPLEMENTED(XKillClient)
+X_NOT_IMPLEMENTED(XLastKnownRequestProcessed)
+X_NOT_IMPLEMENTED(XListDepths)
+X_NOT_IMPLEMENTED(XListExtensions)
+X_NOT_IMPLEMENTED(XListFonts)
+X_NOT_IMPLEMENTED(XListFontsWithInfo)
+X_NOT_IMPLEMENTED(XListHosts)
+X_NOT_IMPLEMENTED(XListInstalledColormaps)
+X_NOT_IMPLEMENTED(XListPixmapFormats)
+X_NOT_IMPLEMENTED(XListProperties)
+X_NOT_IMPLEMENTED(XLoadFont)
+X_NOT_IMPLEMENTED(XLoadQueryFont)
+X_NOT_IMPLEMENTED(XLocaleOfFontSet)
+X_NOT_IMPLEMENTED(XLocaleOfIM)
+X_NOT_IMPLEMENTED(XLocaleOfOM)
+X_NOT_IMPLEMENTED(XLockDisplay)
+X_NOT_IMPLEMENTED(XLookupColor)
+X_NOT_IMPLEMENTED(XLookupKeysym)
+X_NOT_IMPLEMENTED(XLookupString)
+X_NOT_IMPLEMENTED(XLowerWindow)
+X_NOT_IMPLEMENTED(XMapRaised)
+X_NOT_IMPLEMENTED(XMapSubwindows)
+X_NOT_IMPLEMENTED(XMapWindow)
+X_NOT_IMPLEMENTED(XMaskEvent)
+X_NOT_IMPLEMENTED(XMatchVisualInfo)
+X_NOT_IMPLEMENTED(XMaxCmapsOfScreen)
+X_NOT_IMPLEMENTED(XMaxRequestSize)
+X_NOT_IMPLEMENTED(XMinCmapsOfScreen)
+X_NOT_IMPLEMENTED(XMoveResizeWindow)
+X_NOT_IMPLEMENTED(XMoveWindow)
+X_NOT_IMPLEMENTED(XNewModifiermap)
+X_NOT_IMPLEMENTED(XNextEvent)
+X_NOT_IMPLEMENTED(XNextRequest)
+X_NOT_IMPLEMENTED(XNoOp)
+X_NOT_IMPLEMENTED(XOMOfOC)
+X_NOT_IMPLEMENTED(XOffsetRegion)
+X_NOT_IMPLEMENTED(XOpenDisplay)
+X_NOT_IMPLEMENTED(XOpenIM)
+X_NOT_IMPLEMENTED(XOpenOM)
+X_NOT_IMPLEMENTED(XParseColor)
+X_NOT_IMPLEMENTED(XParseGeometry)
+X_NOT_IMPLEMENTED(XPeekEvent)
+X_NOT_IMPLEMENTED(XPeekIfEvent)
+X_NOT_IMPLEMENTED(XPending)
+X_NOT_IMPLEMENTED(XPlanesOfScreen)
+X_NOT_IMPLEMENTED(XPointInRegion)
+X_NOT_IMPLEMENTED(XPolygonRegion)
+X_NOT_IMPLEMENTED(XProcessInternalConnection)
+X_NOT_IMPLEMENTED(XProtocolRevision)
+X_NOT_IMPLEMENTED(XProtocolVersion)
+X_NOT_IMPLEMENTED(XPutBackEvent)
+X_NOT_IMPLEMENTED(XPutImage)
+X_NOT_IMPLEMENTED(XPutPixel)
+X_NOT_IMPLEMENTED(XQLength)
+X_NOT_IMPLEMENTED(XQueryBestCursor)
+X_NOT_IMPLEMENTED(XQueryBestSize)
+X_NOT_IMPLEMENTED(XQueryBestStipple)
+X_NOT_IMPLEMENTED(XQueryBestTile)
+X_NOT_IMPLEMENTED(XQueryColor)
+X_NOT_IMPLEMENTED(XQueryColors)
+X_NOT_IMPLEMENTED(XQueryExtension)
+X_NOT_IMPLEMENTED(XQueryFont)
+X_NOT_IMPLEMENTED(XQueryKeymap)
+X_NOT_IMPLEMENTED(XQueryPointer)
+X_NOT_IMPLEMENTED(XQueryTextExtents)
+X_NOT_IMPLEMENTED(XQueryTextExtents16)
+X_NOT_IMPLEMENTED(XQueryTree)
+X_NOT_IMPLEMENTED(XRaiseWindow)
+X_NOT_IMPLEMENTED(XReadBitmapFile)
+X_NOT_IMPLEMENTED(XReadBitmapFileData)
+X_NOT_IMPLEMENTED(XRebindKeysym)
+X_NOT_IMPLEMENTED(XRecolorCursor)
+X_NOT_IMPLEMENTED(XReconfigureWMWindow)
+X_NOT_IMPLEMENTED(XRectInRegion)
+X_NOT_IMPLEMENTED(XRefreshKeyboardMapping)
+X_NOT_IMPLEMENTED(XRegisterIMInstantiateCallback)
+X_NOT_IMPLEMENTED(XRemoveConnectionWatch)
+X_NOT_IMPLEMENTED(XRemoveFromSaveSet)
+X_NOT_IMPLEMENTED(XRemoveHost)
+X_NOT_IMPLEMENTED(XRemoveHosts)
+X_NOT_IMPLEMENTED(XReparentWindow)
+X_NOT_IMPLEMENTED(XResetScreenSaver)
+X_NOT_IMPLEMENTED(XResizeWindow)
+X_NOT_IMPLEMENTED(XResourceManagerString)
+X_NOT_IMPLEMENTED(XRestackWindows)
+X_NOT_IMPLEMENTED(XRootWindow)
+X_NOT_IMPLEMENTED(XRootWindowOfScreen)
+X_NOT_IMPLEMENTED(XRotateBuffers)
+X_NOT_IMPLEMENTED(XRotateWindowProperties)
+X_NOT_IMPLEMENTED(XSaveContext)
+X_NOT_IMPLEMENTED(XScreenCount)
+X_NOT_IMPLEMENTED(XScreenNumberOfScreen)
+X_NOT_IMPLEMENTED(XScreenOfDisplay)
+X_NOT_IMPLEMENTED(XScreenResourceString)
+X_NOT_IMPLEMENTED(XSelectInput)
+X_NOT_IMPLEMENTED(XSendEvent)
+X_NOT_IMPLEMENTED(XServerVendor)
+X_NOT_IMPLEMENTED(XSetAccessControl)
+X_NOT_IMPLEMENTED(XSetAfterFunction)
+X_NOT_IMPLEMENTED(XSetArcMode)
+X_NOT_IMPLEMENTED(XSetAuthorization)
+X_NOT_IMPLEMENTED(XSetBackground)
+X_NOT_IMPLEMENTED(XSetClassHint)
+X_NOT_IMPLEMENTED(XSetClipMask)
+X_NOT_IMPLEMENTED(XSetClipOrigin)
+X_NOT_IMPLEMENTED(XSetClipRectangles)
+X_NOT_IMPLEMENTED(XSetCloseDownMode)
+X_NOT_IMPLEMENTED(XSetCommand)
+X_NOT_IMPLEMENTED(XSetDashes)
+X_NOT_IMPLEMENTED(XSetErrorHandler)
+X_NOT_IMPLEMENTED(XSetFillRule)
+X_NOT_IMPLEMENTED(XSetFillStyle)
+X_NOT_IMPLEMENTED(XSetFont)
+X_NOT_IMPLEMENTED(XSetFontPath)
+X_NOT_IMPLEMENTED(XSetForeground)
+X_NOT_IMPLEMENTED(XSetFunction)
+X_NOT_IMPLEMENTED(XSetGraphicsExposures)
+X_NOT_IMPLEMENTED(XSetICFocus)
+X_NOT_IMPLEMENTED(XSetICValues)
+X_NOT_IMPLEMENTED(XSetIMValues)
+X_NOT_IMPLEMENTED(XSetIOErrorHandler)
+X_NOT_IMPLEMENTED(XSetIconName)
+X_NOT_IMPLEMENTED(XSetIconSizes)
+X_NOT_IMPLEMENTED(XSetInputFocus)
+X_NOT_IMPLEMENTED(XSetLineAttributes)
+X_NOT_IMPLEMENTED(XSetLocaleModifiers)
+X_NOT_IMPLEMENTED(XSetModifierMapping)
+X_NOT_IMPLEMENTED(XSetNormalHints)
+X_NOT_IMPLEMENTED(XSetOCValues)
+X_NOT_IMPLEMENTED(XSetOMValues)
+X_NOT_IMPLEMENTED(XSetPlaneMask)
+X_NOT_IMPLEMENTED(XSetPointerMapping)
+X_NOT_IMPLEMENTED(XSetRGBColormaps)
+X_NOT_IMPLEMENTED(XSetRegion)
+X_NOT_IMPLEMENTED(XSetScreenSaver)
+X_NOT_IMPLEMENTED(XSetSelectionOwner)
+X_NOT_IMPLEMENTED(XSetSizeHints)
+X_NOT_IMPLEMENTED(XSetStandardColormap)
+X_NOT_IMPLEMENTED(XSetStandardProperties)
+X_NOT_IMPLEMENTED(XSetState)
+X_NOT_IMPLEMENTED(XSetStipple)
+X_NOT_IMPLEMENTED(XSetSubwindowMode)
+X_NOT_IMPLEMENTED(XSetTSOrigin)
+X_NOT_IMPLEMENTED(XSetTextProperty)
+X_NOT_IMPLEMENTED(XSetTile)
+X_NOT_IMPLEMENTED(XSetTransientForHint)
+X_NOT_IMPLEMENTED(XSetWMClientMachine)
+X_NOT_IMPLEMENTED(XSetWMColormapWindows)
+X_NOT_IMPLEMENTED(XSetWMHints)
+X_NOT_IMPLEMENTED(XSetWMIconName)
+X_NOT_IMPLEMENTED(XSetWMName)
+X_NOT_IMPLEMENTED(XSetWMNormalHints)
+X_NOT_IMPLEMENTED(XSetWMProperties)
+X_NOT_IMPLEMENTED(XSetWMProtocols)
+X_NOT_IMPLEMENTED(XSetWMSizeHints)
+X_NOT_IMPLEMENTED(XSetWindowBackground)
+X_NOT_IMPLEMENTED(XSetWindowBackgroundPixmap)
+X_NOT_IMPLEMENTED(XSetWindowBorder)
+X_NOT_IMPLEMENTED(XSetWindowBorderPixmap)
+X_NOT_IMPLEMENTED(XSetWindowBorderWidth)
+X_NOT_IMPLEMENTED(XSetWindowColormap)
+X_NOT_IMPLEMENTED(XSetZoomHints)
+X_NOT_IMPLEMENTED(XShrinkRegion)
+X_NOT_IMPLEMENTED(XStoreBuffer)
+X_NOT_IMPLEMENTED(XStoreBytes)
+X_NOT_IMPLEMENTED(XStoreColor)
+X_NOT_IMPLEMENTED(XStoreColors)
+X_NOT_IMPLEMENTED(XStoreName)
+X_NOT_IMPLEMENTED(XStoreNamedColor)
+X_NOT_IMPLEMENTED(XStringListToTextProperty)
+X_NOT_IMPLEMENTED(XStringToKeysym)
+X_NOT_IMPLEMENTED(XSubImage)
+X_NOT_IMPLEMENTED(XSubtractRegion)
+X_NOT_IMPLEMENTED(XSupportsLocale)
+X_NOT_IMPLEMENTED(XSync)
+X_NOT_IMPLEMENTED(XSynchronize)
+X_NOT_IMPLEMENTED(XTextExtents)
+X_NOT_IMPLEMENTED(XTextExtents16)
+X_NOT_IMPLEMENTED(XTextPropertyToStringList)
+X_NOT_IMPLEMENTED(XTextWidth)
+X_NOT_IMPLEMENTED(XTextWidth16)
+X_NOT_IMPLEMENTED(XTranslateCoordinates)
+X_NOT_IMPLEMENTED(XUndefineCursor)
+X_NOT_IMPLEMENTED(XUngrabButton)
+X_NOT_IMPLEMENTED(XUngrabKey)
+X_NOT_IMPLEMENTED(XUngrabKeyboard)
+X_NOT_IMPLEMENTED(XUngrabPointer)
+X_NOT_IMPLEMENTED(XUngrabServer)
+X_NOT_IMPLEMENTED(XUninstallColormap)
+X_NOT_IMPLEMENTED(XUnionRectWithRegion)
+X_NOT_IMPLEMENTED(XUnionRegion)
+X_NOT_IMPLEMENTED(XUnloadFont)
+X_NOT_IMPLEMENTED(XUnlockDisplay)
+X_NOT_IMPLEMENTED(XUnmapSubwindows)
+X_NOT_IMPLEMENTED(XUnmapWindow)
+X_NOT_IMPLEMENTED(XUnregisterIMInstantiateCallback)
+X_NOT_IMPLEMENTED(XUnsetICFocus)
+X_NOT_IMPLEMENTED(XVaCreateNestedList)
+X_NOT_IMPLEMENTED(XVendorRelease)
+X_NOT_IMPLEMENTED(XVisualIDFromVisual)
+X_NOT_IMPLEMENTED(XWMGeometry)
+X_NOT_IMPLEMENTED(XWarpPointer)
+X_NOT_IMPLEMENTED(XWhitePixel)
+X_NOT_IMPLEMENTED(XWhitePixelOfScreen)
+X_NOT_IMPLEMENTED(XWidthMMOfScreen)
+X_NOT_IMPLEMENTED(XWidthOfScreen)
+X_NOT_IMPLEMENTED(XWindowEvent)
+X_NOT_IMPLEMENTED(XWithdrawWindow)
+X_NOT_IMPLEMENTED(XWriteBitmapFile)
+X_NOT_IMPLEMENTED(XXorRegion)
+X_NOT_IMPLEMENTED(XcmsAddColorSpace)
+X_NOT_IMPLEMENTED(XcmsAddFunctionSet)
+X_NOT_IMPLEMENTED(XcmsAllocColor)
+X_NOT_IMPLEMENTED(XcmsAllocNamedColor)
+X_NOT_IMPLEMENTED(XcmsCCCOfColormap)
+X_NOT_IMPLEMENTED(XcmsCIELabClipL)
+X_NOT_IMPLEMENTED(XcmsCIELabClipLab)
+X_NOT_IMPLEMENTED(XcmsCIELabClipab)
+X_NOT_IMPLEMENTED(XcmsCIELabQueryMaxC)
+X_NOT_IMPLEMENTED(XcmsCIELabQueryMaxL)
+X_NOT_IMPLEMENTED(XcmsCIELabQueryMaxLC)
+X_NOT_IMPLEMENTED(XcmsCIELabQueryMinL)
+X_NOT_IMPLEMENTED(XcmsCIELabToCIEXYZ)
+X_NOT_IMPLEMENTED(XcmsCIELabWhiteShiftColors)
+X_NOT_IMPLEMENTED(XcmsCIELuvClipL)
+X_NOT_IMPLEMENTED(XcmsCIELuvClipLuv)
+X_NOT_IMPLEMENTED(XcmsCIELuvClipuv)
+X_NOT_IMPLEMENTED(XcmsCIELuvQueryMaxC)
+X_NOT_IMPLEMENTED(XcmsCIELuvQueryMaxL)
+X_NOT_IMPLEMENTED(XcmsCIELuvQueryMaxLC)
+X_NOT_IMPLEMENTED(XcmsCIELuvQueryMinL)
+X_NOT_IMPLEMENTED(XcmsCIELuvToCIEuvY)
+X_NOT_IMPLEMENTED(XcmsCIELuvWhiteShiftColors)
+X_NOT_IMPLEMENTED(XcmsCIEXYZToCIELab)
+X_NOT_IMPLEMENTED(XcmsCIEXYZToCIEuvY)
+X_NOT_IMPLEMENTED(XcmsCIEXYZToCIExyY)
+X_NOT_IMPLEMENTED(XcmsCIEXYZToRGBi)
+X_NOT_IMPLEMENTED(XcmsCIEuvYToCIELuv)
+X_NOT_IMPLEMENTED(XcmsCIEuvYToCIEXYZ)
+X_NOT_IMPLEMENTED(XcmsCIEuvYToTekHVC)
+X_NOT_IMPLEMENTED(XcmsCIExyYToCIEXYZ)
+X_NOT_IMPLEMENTED(XcmsClientWhitePointOfCCC)
+X_NOT_IMPLEMENTED(XcmsConvertColors)
+X_NOT_IMPLEMENTED(XcmsCreateCCC)
+X_NOT_IMPLEMENTED(XcmsDefaultCCC)
+X_NOT_IMPLEMENTED(XcmsDisplayOfCCC)
+X_NOT_IMPLEMENTED(XcmsFormatOfPrefix)
+X_NOT_IMPLEMENTED(XcmsFreeCCC)
+X_NOT_IMPLEMENTED(XcmsLookupColor)
+X_NOT_IMPLEMENTED(XcmsPrefixOfFormat)
+X_NOT_IMPLEMENTED(XcmsQueryBlack)
+X_NOT_IMPLEMENTED(XcmsQueryBlue)
+X_NOT_IMPLEMENTED(XcmsQueryColor)
+X_NOT_IMPLEMENTED(XcmsQueryColors)
+X_NOT_IMPLEMENTED(XcmsQueryGreen)
+X_NOT_IMPLEMENTED(XcmsQueryRed)
+X_NOT_IMPLEMENTED(XcmsQueryWhite)
+X_NOT_IMPLEMENTED(XcmsRGBToRGBi)
+X_NOT_IMPLEMENTED(XcmsRGBiToCIEXYZ)
+X_NOT_IMPLEMENTED(XcmsRGBiToRGB)
+X_NOT_IMPLEMENTED(XcmsScreenNumberOfCCC)
+X_NOT_IMPLEMENTED(XcmsScreenWhitePointOfCCC)
+X_NOT_IMPLEMENTED(XcmsSetCCCOfColormap)
+X_NOT_IMPLEMENTED(XcmsSetCompressionProc)
+X_NOT_IMPLEMENTED(XcmsSetWhiteAdjustProc)
+X_NOT_IMPLEMENTED(XcmsSetWhitePoint)
+X_NOT_IMPLEMENTED(XcmsStoreColor)
+X_NOT_IMPLEMENTED(XcmsStoreColors)
+X_NOT_IMPLEMENTED(XcmsTekHVCClipC)
+X_NOT_IMPLEMENTED(XcmsTekHVCClipV)
+X_NOT_IMPLEMENTED(XcmsTekHVCClipVC)
+X_NOT_IMPLEMENTED(XcmsTekHVCQueryMaxC)
+X_NOT_IMPLEMENTED(XcmsTekHVCQueryMaxV)
+X_NOT_IMPLEMENTED(XcmsTekHVCQueryMaxVC)
+X_NOT_IMPLEMENTED(XcmsTekHVCQueryMaxVSamples)
+X_NOT_IMPLEMENTED(XcmsTekHVCQueryMinV)
+X_NOT_IMPLEMENTED(XcmsTekHVCToCIEuvY)
+X_NOT_IMPLEMENTED(XcmsTekHVCWhiteShiftColors)
+X_NOT_IMPLEMENTED(XcmsVisualOfCCC)
+X_NOT_IMPLEMENTED(XmbDrawImageString)
+X_NOT_IMPLEMENTED(XmbDrawString)
+X_NOT_IMPLEMENTED(XmbDrawText)
+X_NOT_IMPLEMENTED(XmbLookupString)
+X_NOT_IMPLEMENTED(XmbResetIC)
+X_NOT_IMPLEMENTED(XmbSetWMProperties)
+X_NOT_IMPLEMENTED(XmbTextEscapement)
+X_NOT_IMPLEMENTED(XmbTextExtents)
+X_NOT_IMPLEMENTED(XmbTextListToTextProperty)
+X_NOT_IMPLEMENTED(XmbTextPerCharExtents)
+X_NOT_IMPLEMENTED(XmbTextPropertyToTextList)
+X_NOT_IMPLEMENTED(Xpermalloc)
+X_NOT_IMPLEMENTED(XrmCombineDatabase)
+X_NOT_IMPLEMENTED(XrmCombineFileDatabase)
+X_NOT_IMPLEMENTED(XrmDestroyDatabase)
+X_NOT_IMPLEMENTED(XrmEnumerateDatabase)
+X_NOT_IMPLEMENTED(XrmGetDatabase)
+X_NOT_IMPLEMENTED(XrmGetFileDatabase)
+X_NOT_IMPLEMENTED(XrmGetResource)
+X_NOT_IMPLEMENTED(XrmGetStringDatabase)
+X_NOT_IMPLEMENTED(XrmInitialize)
+X_NOT_IMPLEMENTED(XrmLocaleOfDatabase)
+X_NOT_IMPLEMENTED(XrmMergeDatabases)
+X_NOT_IMPLEMENTED(XrmParseCommand)
+X_NOT_IMPLEMENTED(XrmPermStringToQuark)
+X_NOT_IMPLEMENTED(XrmPutFileDatabase)
+X_NOT_IMPLEMENTED(XrmPutLineResource)
+X_NOT_IMPLEMENTED(XrmPutResource)
+X_NOT_IMPLEMENTED(XrmPutStringResource)
+X_NOT_IMPLEMENTED(XrmQGetResource)
+X_NOT_IMPLEMENTED(XrmQGetSearchList)
+X_NOT_IMPLEMENTED(XrmQGetSearchResource)
+X_NOT_IMPLEMENTED(XrmQPutResource)
+X_NOT_IMPLEMENTED(XrmQPutStringResource)
+X_NOT_IMPLEMENTED(XrmQuarkToString)
+X_NOT_IMPLEMENTED(XrmSetDatabase)
+X_NOT_IMPLEMENTED(XrmStringToBindingQuarkList)
+X_NOT_IMPLEMENTED(XrmStringToQuark)
+X_NOT_IMPLEMENTED(XrmStringToQuarkList)
+X_NOT_IMPLEMENTED(XrmUniqueQuark)
+X_NOT_IMPLEMENTED(XwcDrawImageString)
+X_NOT_IMPLEMENTED(XwcDrawString)
+X_NOT_IMPLEMENTED(XwcDrawText)
+X_NOT_IMPLEMENTED(XwcFreeStringList)
+X_NOT_IMPLEMENTED(XwcLookupString)
+X_NOT_IMPLEMENTED(XwcResetIC)
+X_NOT_IMPLEMENTED(XwcTextEscapement)
+X_NOT_IMPLEMENTED(XwcTextExtents)
+X_NOT_IMPLEMENTED(XwcTextListToTextProperty)
+X_NOT_IMPLEMENTED(XwcTextPerCharExtents)
+X_NOT_IMPLEMENTED(XwcTextPropertyToTextList)
+X_NOT_IMPLEMENTED(_XAllocID)
+X_NOT_IMPLEMENTED(_XAllocIDs)
+X_NOT_IMPLEMENTED(_XAllocScratch)
+X_NOT_IMPLEMENTED(_XAllocTemp)
+X_NOT_IMPLEMENTED(_XAsyncErrorHandler)
+X_NOT_IMPLEMENTED(_XConnectDisplay)
+X_NOT_IMPLEMENTED(_XCreateMutex_fn_p)
+X_NOT_IMPLEMENTED(_XDeqAsyncHandler)
+X_NOT_IMPLEMENTED(_XEatData)
+X_NOT_IMPLEMENTED(_XError)
+X_NOT_IMPLEMENTED(_XFlushGCCache)
+X_NOT_IMPLEMENTED(_XFlushIt)
+X_NOT_IMPLEMENTED(_XFreeMutex_fn_p)
+X_NOT_IMPLEMENTED(_XFreeTemp)
+X_NOT_IMPLEMENTED(_XGetAsyncData)
+X_NOT_IMPLEMENTED(_XGetAsyncReply)
+X_NOT_IMPLEMENTED(_XIOError)
+X_NOT_IMPLEMENTED(_XInitImageFuncPtrs)
+X_NOT_IMPLEMENTED(_XKillTimer)
+X_NOT_IMPLEMENTED(_XLockMutex_fn_p)
+X_NOT_IMPLEMENTED(_XRead)
+X_NOT_IMPLEMENTED(_XReadEvents)
+X_NOT_IMPLEMENTED(_XReadPad)
+X_NOT_IMPLEMENTED(_XRegisterFilterByMask)
+X_NOT_IMPLEMENTED(_XRegisterFilterByType)
+X_NOT_IMPLEMENTED(_XRegisterInternalConnection)
+X_NOT_IMPLEMENTED(_XReply)
+X_NOT_IMPLEMENTED(_XSend)
+X_NOT_IMPLEMENTED(_XSetLastRequestRead)
+X_NOT_IMPLEMENTED(_XSetTimer)
+X_NOT_IMPLEMENTED(_XUnknownNativeEvent)
+X_NOT_IMPLEMENTED(_XUnlockMutex_fn_p)
+X_NOT_IMPLEMENTED(_XUnregisterFilter)
+X_NOT_IMPLEMENTED(_XUnregisterInternalConnection)
+X_NOT_IMPLEMENTED(_XVIDtoVisual)
+X_NOT_IMPLEMENTED(_XWinSelectWindow)
+X_NOT_IMPLEMENTED(_Xdebug_p)
+X_NOT_IMPLEMENTED(_Xglobal_lock_p)
+X_NOT_IMPLEMENTED(_Xthread_init)
+X_NOT_IMPLEMENTED(_Xthread_waiter)
+/* EOF */
--- /dev/null
+# $Id: Makefile,v 1.4 2002/10/29 04:45:50 rex Exp $
+#
+# ReactOS POSIX+ Environment Subsystem
+#
+PATH_TO_TOP=../../reactos
+
+TARGET_TYPE = program
+
+TARGET_PATH = misc
+
+TARGET_NAME = psxss
+
+TARGET_APPTYPE = console
+
+TARGET_SDKLIBS = ntdll.a kernel32.a
+
+TARGET_CFLAGS=-Iinclude -I../include -D__PSXSS_ON_W32__
+
+PSXSS_MISC_OBJECTS = \
+ misc/main.o \
+ misc/init.o \
+ misc/print.o
+
+PSXSS_OB_OBJECTS = \
+ ob/process.o \
+ ob/session.o \
+ ob/terminal.o
+
+PSXSS_PORT_OBJECTS = \
+ port/api.o \
+ port/sbapi.o \
+ port/session.o \
+ port/utils.o
+
+PSXSS_CALL_OBJECTS = \
+ call/null.o \
+ call/_exit.o \
+ call/stubs.o \
+ call/syscall.o
+
+TARGET_OBJECTS=\
+ $(PSXSS_MISC_OBJECTS) \
+ $(PSXSS_OB_OBJECTS) \
+ $(PSXSS_PORT_OBJECTS) \
+ $(PSXSS_CALL_OBJECTS)
+
+include $(PATH_TO_TOP)/rules.mak
+
+include $(TOOLS_PATH)/helper.mk
+
+# EOF
--- /dev/null
+/* $Id: _exit.c,v 1.3 2002/10/29 04:45:51 rex Exp $
+ *
+ * PROJECT : ReactOS / POSIX+ Environment Subsystem Server
+ * FILE : reactos/subsys/psx/server/call/_exit.c
+ * DESCRIPTION: System call _exit().
+ * DATE : 2002-04-05
+ * AUTHOR : Emanuele Aliberti <eal@users.sf.net>
+ *
+ * --------------------------------------------------------------------
+ *
+ * This software is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; see the file COPYING. If not, write
+ * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
+ * MA 02139, USA.
+ *
+ * --------------------------------------------------------------------
+ */
+#define NTOS_MODE_USER
+#include <ntos.h>
+#include <ntdll/rtl.h>
+#include <napi/lpc.h>
+#include <psxss.h>
+
+NTSTATUS STDCALL syscall__exit (PPSX_MAX_MESSAGE Msg)
+{
+ Msg->PsxHeader.Status = STATUS_SUCCESS;
+ /* TODO */
+ return STATUS_SUCCESS;
+}
+/* EOF */
--- /dev/null
+/* $Id: null.c,v 1.3 2002/10/29 04:45:54 rex Exp $
+ *
+ * PROJECT : ReactOS / POSIX+ Environment Subsystem Server
+ * FILE : reactos/subsys/psx/server/call/null.c
+ * DESCRIPTION: Void system call.
+ * DATE : 2002-04-05
+ * AUTHOR : Emanuele Aliberti <eal@users.sf.net>
+ *
+ * --------------------------------------------------------------------
+ *
+ * This software is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; see the file COPYING. If not, write
+ * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
+ * MA 02139, USA.
+ *
+ * --------------------------------------------------------------------
+ */
+#define NTOS_MODE_USER
+#include <ntos.h>
+#include <ntdll/rtl.h>
+#include <napi/lpc.h>
+#include <psxss.h>
+
+NTSTATUS STDCALL syscall_null (PPSX_MAX_MESSAGE Msg)
+{
+ Msg->PsxHeader.Status = STATUS_SUCCESS;
+ return STATUS_SUCCESS;
+}
+/* EOF */
--- /dev/null
+/* $Id: psxss.h,v 1.3 2002/10/29 04:45:54 rex Exp $ */
+#ifndef _PSX_PSXSS_H
+#define _PSX_PSXSS_H
+
+#define NTOS_MODE_USER
+#include <ntos.h>
+#include <ntdll/rtl.h>
+#include <psx/lpcproto.h>
+
+#ifdef __PSXSS_ON_W32__
+#include <windows.h>
+#endif
+
+#define NAME_BUFFER_SIZE 64
+
+/* PSXSS GLOBAL DATA */
+
+typedef struct _SERVER_DIRECTORY
+{
+ HANDLE hObject;
+ LPWSTR wsName;
+ UNICODE_STRING usName;
+
+} SERVER_DIRECTORY;
+
+#define PSXSS_THREADS_PER_PORT 2
+
+typedef struct _SERVER_PORT
+{
+ HANDLE hObject;
+ LPWSTR wsName;
+ UNICODE_STRING usName;
+ PTHREAD_START_ROUTINE EntryPoint;
+ struct {
+ HANDLE hObject;
+ DWORD Id;
+ } ThreadInfo [PSXSS_THREADS_PER_PORT];
+
+} SERVER_PORT, * PSERVER_PORT;
+
+#define SERVER_DIRECTORY_COUNT 3
+#define SERVER_PORT_COUNT 3
+
+typedef struct _SERVER
+{
+ HANDLE Heap;
+ SERVER_DIRECTORY Directory [SERVER_DIRECTORY_COUNT];
+ SERVER_PORT Port [SERVER_PORT_COUNT];
+
+} SERVER;
+
+#define PSX_PORT_API 0
+#define PSX_PORT_SBAPI 1
+#define PSX_PORT_SESSION 2
+
+#define PSX_DIRECTORY_POSIX 0
+#define PSX_DIRECTORY_SESSIONS 1
+#define PSX_DIRECTORY_SYSTEM 2
+
+extern SERVER Server; /* server/misc/init.c */
+
+/* System call type */
+typedef NTSTATUS (STDCALL *PSX_SYSTEM_CALL)(PPSX_MAX_MESSAGE);
+
+/* System calls table */
+
+extern PSX_SYSTEM_CALL SystemCall []; /* server/call/syscall.c */
+
+/* Listener's Threads */
+VOID STDCALL ApiPortListener (PVOID);
+VOID STDCALL SbApiPortListener (PVOID);
+VOID STDCALL SessionPortListener (PVOID);
+
+/* TERMINAL OBJECT */
+
+typedef struct _PSX_TERMINAL
+{
+ DWORD Id;
+ /* TODO */
+} PSX_TERMINAL, * PPSX_TERMINAL;
+
+/* PROCESS OBJECT */
+
+typedef enum
+{
+ PROCESS_STATUS_INITIALIZATION,
+ PROCESS_STATUS_READY,
+ PROCESS_STATUS_WAITING,
+ PROCESS_STATUS_DEAD,
+ PROCESS_STATUS_ZOMBIE
+
+} PROCESS_STATUS;
+
+typedef DWORD PSX_SECURITY; /* TODO */
+
+struct _PSX_SESSION;
+
+typedef struct _PSX_PROCESS
+{
+ INT Id; /* pid */
+ HANDLE hProcess; /* hProcess */
+ PROCESS_STATUS Status;
+ struct _PSX_PROCESS * Parent;
+ struct _PSX_SESSION * Session;
+ PPSX_TERMINAL ControlTty;
+ PSX_SECURITY Security;
+
+} PSX_PROCESS, * PPSX_PROCESS;
+
+/* SESSION OBJECT */
+
+typedef enum
+{
+ SESSION_STATUS_INITIALIZATION,
+ SESSION_STATUS_READY,
+ SESSION_STATUS_SHUTDOWN,
+ SESSION_STATUS_ERROR
+
+} SESSION_STATUS;
+
+typedef struct _PSX_SESSION
+{
+ DWORD Id;
+ ULONG ReferenceCount;
+ SESSION_STATUS Status;
+ HANDLE Heap;
+ struct {
+ HANDLE hPort;
+ ULONG ulPortIdentifier;
+ } SessionChannel;
+ struct {
+ ULONG Id; /* csrterm pid */
+ HANDLE hPort; /* LPC port owned by csrterm: \POSIX+\Sessions\P{Id} */
+ struct {
+ HANDLE Handle; /* Section owned by csrterm: \POSIX+\Sessions\D{Id} */
+ PVOID BaseAddress;
+ ULONG ViewSize;
+ } Section;
+ } TerminalChannel;
+ PPSX_PROCESS Leader;
+ CRITICAL_SECTION Lock;
+ struct _PSX_SESSION * Previous;
+ struct _PSX_SESSION * Next;
+
+} PSX_SESSION, * PPSX_SESSION;
+
+/* prototypes */
+
+VOID STDCALL debug_print (LPWSTR Template, ...);
+NTSTATUS STDCALL PsxInitializeSessions (VOID); /* ob/session.c */
+NTSTATUS STDCALL PsxCreateSession (PLPC_MAX_MESSAGE,HANDLE,ULONG);
+NTSTATUS STDCALL PsxInitializeProcesses (VOID); /* ob/process.c */
+NTSTATUS STDCALL PsxCreateProcess (PLPC_MAX_MESSAGE,HANDLE,ULONG);
+
+#endif /* ndef _PSX_PSXSS_H */
--- /dev/null
+/* $Id: init.c,v 1.3 2002/10/29 04:45:54 rex Exp $
+ *
+ * PROJECT : ReactOS / POSIX+ Environment Subsystem Server
+ * FILE : reactos/subsys/psx/server/srv/init.c
+ * DESCRIPTION: POSIX+ server initialization.
+ * DATE : 2001-05-05
+ * AUTHOR : Emanuele Aliberti <eal@users.sf.net>
+ *
+ * --------------------------------------------------------------------
+ *
+ * This software is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; see the file COPYING. If not, write
+ * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
+ * MA 02139, USA.
+ *
+ * --------------------------------------------------------------------
+ */
+#include <psxss.h>
+#include <napi/teb.h>
+
+#ifdef __PSXSS_ON_W32__
+#include <windows.h>
+#endif
+
+/*** GLOBALS *********************************************************/
+
+SERVER Server =
+{
+ /* .Heap */
+ INVALID_HANDLE_VALUE,
+ /* .Directory */
+ {
+ { INVALID_HANDLE_VALUE,
+ L"\\"PSX_NS_SUBSYSTEM_DIRECTORY_NAME,
+ {0,0,NULL}
+ },
+ { INVALID_HANDLE_VALUE,
+ L"\\"PSX_NS_SUBSYSTEM_DIRECTORY_NAME"\\"PSX_NS_SESSION_DIRECTORY_NAME,
+ {0,0,NULL}
+ },
+ { INVALID_HANDLE_VALUE,
+ L"\\"PSX_NS_SUBSYSTEM_DIRECTORY_NAME"\\"PSX_NS_SYSTEM_DIRECTORY_NAME,
+ {0,0,NULL}
+ },
+ },
+ /* .Port */
+ {
+ { INVALID_HANDLE_VALUE,
+ L"\\"PSX_NS_SUBSYSTEM_DIRECTORY_NAME"\\"PSX_NS_API_PORT_NAME,
+ {0,0,NULL},
+ ApiPortListener
+ },
+ { INVALID_HANDLE_VALUE,
+ L"\\"PSX_NS_SUBSYSTEM_DIRECTORY_NAME"\\"PSX_NS_SBAPI_PORT_NAME,
+ {0,0,NULL},
+ SbApiPortListener
+ },
+ { INVALID_HANDLE_VALUE,
+ L"\\"PSX_NS_SUBSYSTEM_DIRECTORY_NAME"\\"PSX_NS_SESSIONAPI_PORT_NAME,
+ {0,0,NULL},
+ SessionPortListener
+ }
+ }
+};
+
+/*** FUNCTIONS *******************************************************/
+
+/**********************************************************************
+ * PdxInitializeHeap/0 PRIVATE
+ *
+ * DESCRIPTION
+ * Initialize the PSX server process' heap.
+ */
+PRIVATE HANDLE STDCALL
+PdxInitializeHeap (VOID)
+{
+ return Server.Heap = (HANDLE)NtCurrentPeb()->ProcessHeap;
+}
+/**********************************************************************
+ * PdxCreateDirectory/1 PRIVATE
+ *
+ * DESCRIPTION
+ * Create a directory in the system name space.
+ */
+PRIVATE NTSTATUS STDCALL
+PdxCreateDirectory (
+ IN ULONG ulIndex
+ )
+{
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ NTSTATUS Status;
+
+ RtlCreateUnicodeString (
+ & Server.Directory[ulIndex].usName,
+ Server.Directory[ulIndex].wsName
+ );
+ InitializeObjectAttributes (
+ & ObjectAttributes,
+ & Server.Directory[ulIndex].usName,
+ 0,
+ NULL,
+ NULL
+ );
+ Status = NtCreateDirectoryObject(
+ & Server.Directory[ulIndex].hObject,
+ DIRECTORY_ALL_ACCESS,
+ & ObjectAttributes
+ );
+ if (!NT_SUCCESS(Status))
+ {
+ debug_print(
+ L"PSXSS: %s directory creation failed (Status = %08x)",
+ Server.Directory[ulIndex].wsName,
+ Status
+ );
+
+ }
+ return Status;
+}
+/**********************************************************************
+ * PdxInitializeDirectories/0 PRIVATE
+ *
+ * DESCRIPTION
+ * Create the directories used by the POSIX+ subsystem
+ * components in the system name space.
+ */
+PRIVATE NTSTATUS STDCALL
+PdxInitializeDirectories (VOID)
+{
+ NTSTATUS Status;
+ ULONG ulIndex;
+
+ for ( ulIndex = 0;
+ (ulIndex < (sizeof Server.Directory / sizeof Server.Directory[0]));
+ ulIndex ++)
+ {
+ Status = PdxCreateDirectory (ulIndex);
+ if (!NT_SUCCESS(Status)) return Status;
+ }
+ return STATUS_SUCCESS;
+}
+/**********************************************************************
+ * PdxInitializeListener/1 PRIVATE
+ *
+ * DESCRIPTION
+ * Initialize a thread to make an LPC port listen.
+ */
+PRIVATE NTSTATUS STDCALL
+PdxInitializeListener (ULONG ulIndex)
+{
+ NTSTATUS Status;
+ OBJECT_ATTRIBUTES Oa;
+ ULONG ulThreadIndex;
+
+ RtlInitUnicodeString (
+ & Server.Port[ulIndex].usName,
+ Server.Port[ulIndex].wsName
+ );
+ InitializeObjectAttributes(
+ & Oa,
+ & Server.Port[ulIndex].usName,
+ 0,
+ NULL,
+ NULL
+ );
+ /* Create the listening LPC port */
+ Status = NtCreatePort (
+ & Server.Port[ulIndex].hObject,
+ & Oa,
+ 260,
+ 328,
+ 0
+ );
+ if (!NT_SUCCESS(Status))
+ {
+ debug_print(
+ L"PSXSS: Unable to create port \"%s\": Status %08x\n",
+ Server.Port[ulIndex].wsName,
+ Status);
+ return Status;
+ }
+ /*
+ * Create the server thread that will process
+ * messages sent to this port.
+ */
+ for ( ulThreadIndex = 0;
+ (ulThreadIndex < PSXSS_THREADS_PER_PORT);
+ ulThreadIndex ++
+ )
+ {
+#ifdef __PSXSS_ON_W32__
+ Server.Port[ulIndex].ThreadInfo[ulThreadIndex].hObject =
+ CreateThread (
+ NULL,
+ 0,
+ (PTHREAD_START_ROUTINE) Server.Port[ulIndex].EntryPoint,
+ (PVOID) ulIndex,
+ CREATE_SUSPENDED,
+ & Server.Port[ulIndex].ThreadInfo[ulThreadIndex].Id
+ );
+ if (NULL == Server.Port[ulIndex].ThreadInfo[ulThreadIndex].hObject)
+#else
+ if (!NT_SUCCESS(Status))
+#endif
+ {
+ debug_print(
+ L"PSXSS: Unable to create a server thread for port \"%s\": Status %08x\n",
+ Server.Port[ulIndex].wsName,
+ Status
+ );
+ NtClose (Server.Port[ulIndex].hObject);
+ return Status;
+ }
+ }
+ return STATUS_SUCCESS;
+}
+/**********************************************************************
+ * PsxInitializeListeners/0 PRIVATE
+ *
+ * DESCRIPTION
+ * Initialize the LPC ports and associate threads.
+ */
+PRIVATE NTSTATUS STDCALL
+PdxInitializeListeners (VOID)
+{
+ NTSTATUS Status;
+ ULONG ulIndex;
+
+ for ( ulIndex = 0;
+ (ulIndex < (sizeof Server.Port / sizeof Server.Port[0]));
+ ulIndex ++)
+ {
+ Status = PdxInitializeListener (ulIndex);
+ if (!NT_SUCCESS(Status)) return Status;
+ }
+ return STATUS_SUCCESS;
+}
+/**********************************************************************
+ * PdxRunServer/0 PRIVATE
+ *
+ * DESCRIPTION
+ * Wake up all suspended threads.
+ */
+PRIVATE NTSTATUS STDCALL
+PdxRunServer (VOID)
+{
+ NTSTATUS Status;
+ ULONG ulIndex;
+ ULONG ulThreadIndex;
+
+ for ( ulIndex = 0;
+ (ulIndex < (sizeof Server.Port / sizeof Server.Port[0]));
+ ulIndex ++)
+ {
+ for (ulThreadIndex = 0;
+ (ulThreadIndex < PSXSS_THREADS_PER_PORT);
+ ulThreadIndex ++
+ )
+ {
+#ifdef __PSXSS_ON_W32__
+ if (0xFFFFFFFF == ResumeThread (Server.Port[ulIndex].ThreadInfo[ulThreadIndex].hObject))
+#else
+ Status = NtResumeThread (Server.Port[ulIndex].ThreadInfo[ulThreadIndex].hObject, NULL);
+ if (!NT_SUCCESS(Status))
+#endif
+ {
+ debug_print(
+ L"PSXSS: "__FUNCTION__": NtResumeThread failed with Status = %08x",
+ Status
+ );
+ return Status;
+ }
+ }
+ }
+ return STATUS_SUCCESS;
+}
+/**********************************************************************
+ * PsxServerInitialization/2
+ *
+ * DESCRIPTION
+ * Initialize the PSX server process.
+ */
+NTSTATUS STDCALL
+PsxServerInitialization (
+ IN ULONG ArgumentCount,
+ IN PWSTR *ArgumentArray
+ )
+{
+ NTSTATUS Status;
+
+ /* Get our heap */
+ PdxInitializeHeap ();
+ /* Initialize POSIX+ and Sessions */
+ Status = PdxInitializeDirectories ();
+ if (!NT_SUCCESS(Status)) return Status;
+ /* LPCs dispatchers */
+ Status = PdxInitializeListeners ();
+ if (!NT_SUCCESS(Status)) return Status;
+ /* Terminal manager */
+ Status = PsxInitializeSessions ();
+ if (!NT_SUCCESS(Status)) return Status;
+ /* Process manager */
+ Status = PsxInitializeProcesses ();
+ if (!NT_SUCCESS(Status)) return Status;
+ /* OK. Run! */
+ Status = PdxRunServer ();
+ /* Done */
+ return Status;
+}
+/* EOF */
--- /dev/null
+/* $Id: main.c,v 1.3 2002/10/29 04:45:54 rex Exp $
+ *
+ * PROJECT : ReactOS / POSIX+ Environment Subsystem Server
+ * FILE : reactos/subsys/psx/server/misc/main.c
+ * DESCRIPTION: POSIX+ server main.
+ * DATE : 2001-05-05
+ * AUTHOR : Emanuele Aliberti <eal@users.sf.net>
+ *
+ * --------------------------------------------------------------------
+ *
+ * This software is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; see the file COPYING. If not, write
+ * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
+ * MA 02139, USA.
+ *
+ * --------------------------------------------------------------------
+ *
+ * 19990605 (Emanuele Aliberti)
+ * Compiled successfully with egcs 1.1.2
+ * 20020323 (Emanuele Aliberti)
+ * Converted to Win32 for testing it using NT LPC.
+ */
+#include <windows.h>
+#include <reactos/buildno.h>
+#include <psxss.h>
+
+/*** EXTERNAL ********************************************************/
+
+NTSTATUS STDCALL
+PsxServerInitialization (
+ IN ULONG ArgumentCount,
+ IN PWSTR *ArgumentArray
+ );
+
+/*** ENTRY POINT *****************************************************/
+
+#ifdef __PSXSS_ON_W32__ // W32 PSXSS.EXE
+int main (int argc, char * argv[])
+{
+ INT c;
+
+ debug_print(L"POSIX+ Subsystem for ReactOS "KERNEL_RELEASE_STR);
+
+ if (STATUS_SUCCESS == PsxServerInitialization(0,NULL))
+ {
+ debug_print(L"PSXSS: server active");
+ while (TRUE)
+ {
+ c = getch();
+ if (c == 1) break;
+ }
+ }
+ else
+ {
+ debug_print(L"PSXSS: Subsystem initialization failed.\n");
+ }
+ return 0;
+}
+#else /* Native PSXSS.EXE */
+VOID NtProcessStartup (PPEB Peb)
+{
+ UNICODE_STRING Banner;
+
+ RtlInitUnicodeString (& Banner, L"POSIX+ Subsystem for ReactOS "KERNEL_RELEASE_STR);
+ NtDisplayString(& Banner);
+
+ if (STATUS_SUCCESS == PsxServerInitialization(0,NULL))
+ {
+ DbgPrint("PSXSS: server active\n");
+ /* TODO */
+ }
+ else
+ {
+ DbgPrint("PSXSS: Subsystem initialization failed.\n");
+ }
+ NtTerminateProcess (NtCurrentProcess(), 0);
+}
+#endif
+/* EOF */
--- /dev/null
+/* $Id: print.c,v 1.3 2002/10/29 04:45:54 rex Exp $ */
+#define UNICODE
+#include <windows.h>
+VOID STDCALL debug_print (LPWSTR Template, ...)
+{
+ WCHAR Buffer [1024];
+ va_list ArgumentPointer;
+
+ va_start(ArgumentPointer, Template);
+ vswprintf(Buffer, Template, ArgumentPointer);
+ va_end(ArgumentPointer);
+#ifdef __PSXSS_ON_W32__
+ _putws (Buffer);
+#else
+#error TODO
+#endif
+}
+/* EOF */
--- /dev/null
+#include <defines.h>
+#include <reactos/resource.h>
+
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION RES_UINT_FV_MAJOR,RES_UINT_FV_MINOR,RES_UINT_FV_REVISION,RES_UINT_FV_BUILD
+ PRODUCTVERSION RES_UINT_PV_MAJOR,RES_UINT_PV_MINOR,RES_UINT_PV_REVISION,RES_UINT_PV_BUILD
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x40004L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "CompanyName", RES_STR_COMPANY_NAME
+ VALUE "FileDescription", "POSIX+ Environment Subsystem Server\0"
+ VALUE "FileVersion", RES_STR_FILE_VERSION
+ VALUE "InternalName", "psxss\0"
+ VALUE "LegalCopyright", RES_STR_LEGAL_COPYRIGHT
+ VALUE "OriginalFilename", "psxss.exe\0"
+ VALUE "ProductName", RES_STR_PRODUCT_NAME
+ VALUE "ProductVersion", RES_STR_PRODUCT_VERSION
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+/* EOF */
--- /dev/null
+/* $Id: process.c,v 1.3 2002/10/29 04:45:54 rex Exp $
+ *
+ * PROJECT : ReactOS / POSIX+ Environment Subsystem Server
+ * FILE : reactos/subsys/psx/server/ob/session.c
+ * DESCRIPTION: terminal
+ * DATE : 2002-04-04
+ * AUTHOR : Emanuele Aliberti <eal@users.sf.net>
+ *
+ * --------------------------------------------------------------------
+ *
+ * This software is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; see the file COPYING. If not, write
+ * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
+ * MA 02139, USA.
+ *
+ * --------------------------------------------------------------------
+ */
+#include <psxss.h>
+
+/**********************************************************************
+ * PsxInitializeProcesses/0
+ */
+NTSTATUS STDCALL
+PsxInitializeProcesses (VOID)
+{
+ debug_print (L"PSXSS: ->"__FUNCTION__);
+ /* TODO */
+ debug_print (L"PSXSS: <-"__FUNCTION__);
+ return STATUS_SUCCESS;
+}
+/**********************************************************************
+ * PsxCreateProcess/3
+ */
+NTSTATUS STDCALL
+PsxCreateProcess (
+ PLPC_MAX_MESSAGE pRequest,
+ HANDLE hConnectedPort,
+ ULONG ulPortIdentifier
+ )
+{
+ debug_print (L"PSXSS: ->"__FUNCTION__);
+ /* TODO */
+ debug_print (L"PSXSS: <-"__FUNCTION__);
+ return STATUS_SUCCESS;
+}
+/* EOF */
--- /dev/null
+/* $Id: session.c,v 1.3 2002/10/29 04:45:54 rex Exp $
+ *
+ * PROJECT : ReactOS / POSIX+ Environment Subsystem Server
+ * FILE : reactos/subsys/psx/server/ob/session.c
+ * DESCRIPTION: terminal
+ * DATE : 2002-04-04
+ * AUTHOR : Emanuele Aliberti <eal@users.sf.net>
+ *
+ * --------------------------------------------------------------------
+ *
+ * This software is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; see the file COPYING. If not, write
+ * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
+ * MA 02139, USA.
+ *
+ * --------------------------------------------------------------------
+ */
+#include <psxss.h>
+
+#define LOCK_ALL_SESSIONS RtlEnterCriticalSection(& Sessions.Lock)
+#define UNLOCK_ALL_SESSIONS RtlLeaveCriticalSection(& Sessions.Lock)
+#define LOCK_THIS_SESSION RtlEnterCriticalSection(& Session->Lock)
+#define UNLOCK_THIS_SESSION RtlLeaveCriticalSection(& Session->Lock)
+
+
+/* A double-linked list for the PSX_SESSION instances */
+
+static struct
+{
+ ULONG NextFreeId;
+ LONG Count;
+ PPSX_SESSION List;
+ CRITICAL_SECTION Lock;
+
+} Sessions;
+
+/**** FUNCTIONS ******************************************************/
+
+/**********************************************************************
+ * PsxInitializeSessions/0
+ *
+ * DESCRIPTION
+ * Initialize the PSX session manager.
+ * ARGUMENTS
+ * None.
+ * RETURN VALUE
+ * None.
+ */
+NTSTATUS STDCALL
+PsxInitializeSessions (VOID)
+{
+ debug_print (L"PSXSS: ->"__FUNCTION__);
+ /* Initalize the attributes */
+ Sessions.NextFreeId = 0;
+ Sessions.Count = 0;
+ Sessions.List = NULL;
+ RtlInitializeCriticalSection (& Sessions.Lock);
+ return STATUS_SUCCESS;
+}
+/**********************************************************************
+ * PsxCreateSessionObjects/1 PRIVATE
+ *
+ */
+PRIVATE NTSTATUS STDCALL
+PsxCreateSessionObjects (
+ IN PLPC_MAX_MESSAGE pRequest,
+ IN OUT PPSX_SESSION pSession
+ )
+{
+ NTSTATUS Status;
+ OBJECT_ATTRIBUTES Oa;
+ WCHAR NameBuffer [NAME_BUFFER_SIZE];
+ UNICODE_STRING Name;
+ SECURITY_QUALITY_OF_SERVICE Sqos;
+ PSX_CONNECT_PORT_DATA ConnectData;
+ ULONG ConnectDataSize = sizeof ConnectData;
+
+ /* Port */
+ swprintf (
+ NameBuffer,
+ PSX_NS_SESSION_PORT_TEMPLATE,
+ PSX_NS_SUBSYSTEM_DIRECTORY_NAME,
+ PSX_NS_SESSION_DIRECTORY_NAME,
+ pRequest->Header.Cid.UniqueProcess
+ );
+ debug_print (L"PSXSS: "__FUNCTION__": %s", NameBuffer);
+ RtlInitUnicodeString (& Name, NameBuffer);
+ InitializeObjectAttributes (& Oa, & Name, 0, NULL, NULL);
+ RtlZeroMemory (& Sqos, sizeof Sqos);
+ ConnectData.ConnectionType = PSX_CONNECTION_TYPE_SERVER;
+ ConnectData.Version = PSX_LPC_PROTOCOL_VERSION;
+ ConnectData.PortIdentifier = 0;
+ Status = NtConnectPort (
+ & pSession->TerminalChannel.hPort,
+ & Name,
+ & Sqos,
+ NULL,
+ NULL,
+ NULL,
+ (PVOID) & ConnectData,
+ & ConnectDataSize
+ );
+ if (!NT_SUCCESS(Status))
+ {
+ debug_print (L"PSXSS: "__FUNCTION__": NtConnectPort failed with %08x\n", Status);
+ return Status;
+ }
+ /* TODO: */
+ /* Section */
+ swprintf (
+ NameBuffer,
+ PSX_NS_SESSION_DATA_TEMPLATE,
+ PSX_NS_SUBSYSTEM_DIRECTORY_NAME,
+ PSX_NS_SESSION_DIRECTORY_NAME,
+ pRequest->Header.Cid.UniqueProcess
+ );
+ debug_print (L"PSXSS: "__FUNCTION__": %s", NameBuffer);
+ RtlInitUnicodeString (& Name, NameBuffer);
+ InitializeObjectAttributes (& Oa, & Name, 0, 0, 0);
+ Status = NtOpenSection (
+ & pSession->TerminalChannel.Section.Handle,
+ SECTION_ALL_ACCESS, /* DesiredAccess */
+ & Oa
+ );
+ if (!NT_SUCCESS(Status))
+ {
+ NtClose (pSession->TerminalChannel.hPort);
+ debug_print (L"PSXSS: "__FUNCTION__": NtOpenSection failed with %08x\n", Status);
+ return Status;
+ }
+ pSession->TerminalChannel.Section.BaseAddress = NULL;
+ pSession->TerminalChannel.Section.ViewSize = PSX_TERMINAL_SECTION_SIZE;
+ Status = NtMapViewOfSection (
+ pSession->TerminalChannel.Section.Handle,
+ NtCurrentProcess(),
+ & pSession->TerminalChannel.Section.BaseAddress,
+ 0, /* ZeroBits */
+ 0, /* Commitsize */
+ 0, /* SectionOffset */
+ & pSession->TerminalChannel.Section.ViewSize,
+ ViewUnmap,
+ 0, /* AllocationType */
+ PAGE_READWRITE /* Protect 4 */
+ );
+ if (!NT_SUCCESS(Status))
+ {
+ NtClose (pSession->TerminalChannel.hPort);
+ NtClose (pSession->TerminalChannel.Section.Handle);
+ debug_print (L"PSXSS: "__FUNCTION__": NtMapViewOfSection failed with %08x\n", Status);
+ return Status;
+ }
+ return Status;
+}
+/**********************************************************************
+ * PsxCreateSession/3
+ *
+ * DESCRIPTION
+ * Create a new PSX_SESSION object and insert it in the
+ * PSX sessions table.
+ * ARGUMENTS
+ * MessageHeader
+ * Id
+ * RETURN VALUE
+ * A status value on error; otherwise STATUS_SUCCESS.
+ */
+NTSTATUS STDCALL
+PsxCreateSession (
+ IN PLPC_MAX_MESSAGE pRequest,
+ IN HANDLE hConnectedPort,
+ IN ULONG ulPortIdentifier
+ )
+{
+ PPSX_SESSION Session = NULL;
+
+ debug_print (L"PSXSS: ->"__FUNCTION__);
+ /* Create the PSX_SESSION object */
+ Session = RtlAllocateHeap (Server.Heap, 0, sizeof (PSX_SESSION));
+ if (NULL == Session)
+ {
+ debug_print (L"PSXSS: "__FUNCTION__": failed to create a new session object");
+ return STATUS_MEMORY_NOT_ALLOCATED;
+ }
+ RtlZeroMemory (Session, sizeof (PSX_SESSION));
+ /* Initialiaze the new PSX_SESSION object */
+ Session->SessionChannel.hPort = hConnectedPort;
+ Session->SessionChannel.ulPortIdentifier = ulPortIdentifier;
+ LOCK_ALL_SESSIONS;
+ Session->Id = Sessions.NextFreeId ++;
+ UNLOCK_ALL_SESSIONS;
+ Session->Status = SESSION_STATUS_INITIALIZATION;
+ Session->Heap =
+ RtlCreateHeap (
+ HEAP_GROWABLE,
+ NULL,
+ 65536,
+ 65536,
+ NULL,
+ NULL
+ );
+ if (INVALID_HANDLE_VALUE == Session->Heap)
+ {
+ RtlFreeHeap (Server.Heap, 0, Session);
+ debug_print (L"PSX: "__FUNCTION__": failed to create a new heap for session # %d", Session->Id);
+ return STATUS_MEMORY_NOT_ALLOCATED;
+ }
+ RtlInitializeCriticalSection (& Session->Lock);
+ /* TODO: open the terminal's shared section */
+ /* TODO: connect to the terminal's port */
+ /* Inset the new PSX_SESSION object in the sessions table */
+ LOCK_ALL_SESSIONS;
+ if (NULL == Sessions.List)
+ {
+ Sessions.List = Session;
+ Session->Previous = Session;
+ }
+ Session->Next = Sessions.List; /* Last one points to the top one */
+ Session->Previous = Sessions.List->Previous;
+ Sessions.List->Previous = Session; /* Top one now points to the new one (tail) */
+ ++ Sessions.Count;
+ UNLOCK_ALL_SESSIONS;
+ /* DONE */
+ debug_print (L""__FUNCTION__": session # %d created", Session->Id);
+ Session->Status = SESSION_STATUS_READY;
+ return STATUS_SUCCESS;
+}
+/**********************************************************************
+ * PsxTerminateSession/1
+ *
+ * DESCRIPTION
+ * Remove a PSX_SESSION object from the PSX sessions table and
+ * destroy it.
+ *
+ * ARGUMENTS
+ *
+ * RETURN VALUE
+ * A status value on error; otherwise STATUS_SUCCESS.
+ */
+NTSTATUS STDCALL
+PsxTerminateSession (
+ IN PPSX_SESSION Session
+ )
+{
+ LONG Id;
+ PPSX_SESSION Previous = NULL;
+ PPSX_SESSION Next = NULL;
+
+ /* Release any resource managed by the session */
+ RtlDestroyHeap (Session->Heap);
+ /* Remove the session object from the sessions table */
+ LOCK_ALL_SESSIONS;
+ Id = Session->Id;
+ Previous = Session->Previous;
+ Next = Session->Next;
+ /* TODO: handle the case of no session left */
+ Next->Previous = Previous;
+ Previous->Next = Next;
+ -- Sessions.Count;
+ UNLOCK_ALL_SESSIONS;
+ /* Delete the old PSX_SESSION object */
+ RtlFreeHeap (Server.Heap, 0, Session);
+ /* DONE */
+ debug_print(L"PSX: session # %d deleted", Id);
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS STDCALL
+PsxWriteTerminalSession (
+ IN PPSX_SESSION Session,
+ IN PVOID Buffer,
+ IN ULONG Size,
+ IN OUT PULONG Written
+ )
+{
+ LOCK_THIS_SESSION;
+ /* TODO: lock this session's section for writing */
+ /* TODO: copy the data in this session's section */
+ /* TODO: request a WRITE operation to the session terminal */
+ /* TODO: unlock this session's section */
+ UNLOCK_THIS_SESSION;
+}
+
+NTSTATUS STDCALL
+PsxReadTerminalSession (
+ IN PPSX_SESSION Session,
+ OUT PVOID Buffer,
+ IN ULONG Size,
+ IN OUT PULONG Read
+ )
+{
+ LOCK_THIS_SESSION;
+ /* TODO: lock this session's section for reading */
+ /* TODO: request a READ operation to the session terminal */
+ /* TODO: copy the data from this session's section */
+ /* TODO: unlock this session's section */
+ UNLOCK_THIS_SESSION;
+}
+/* EOF */
--- /dev/null
+/* $Id: terminal.c,v 1.3 2002/10/29 04:45:57 rex Exp $
+ *
+ * PROJECT : ReactOS / POSIX+ Environment Subsystem Server
+ * FILE : reactos/subsys/psx/server/ob/terminal.c
+ * DESCRIPTION: terminal
+ * DATE : 2002-04-04
+ * AUTHOR : Emanuele Aliberti <eal@users.sf.net>
+ *
+ * --------------------------------------------------------------------
+ *
+ * This software is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; see the file COPYING. If not, write
+ * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
+ * MA 02139, USA.
+ *
+ * --------------------------------------------------------------------
+ */
+#include <psxss.h>
+
+/**********************************************************************
+ * WriteTerminal/4
+ */
+NTSTATUS STDCALL
+WriteTerminal (
+ IN PPSX_TERMINAL Terminal,
+ IN PVOID Buffer,
+ IN ULONG Size,
+ IN OUT PULONG WrittenSize
+ )
+{
+ return STATUS_NOT_IMPLEMENTED;
+}
+/**********************************************************************
+ * ReadTerminal/4
+ */
+NTSTATUS STDCALL
+ReadTerminal (
+ IN PPSX_TERMINAL Terminal,
+ IN OUT PVOID Buffer,
+ IN ULONG Size,
+ IN OUT PULONG ReadSize
+ )
+{
+ return STATUS_NOT_IMPLEMENTED;
+}
+/* EOF */
--- /dev/null
+/* $Id: api.c,v 1.3 2002/10/29 04:45:58 rex Exp $
+ *
+ * PROJECT : ReactOS / POSIX+ Environment Subsystem Server
+ * FILE : reactos/subsys/psx/server/port/api.c
+ * DESCRIPTION: \POSIX+\ApiPort LPC port logic.
+ * DATE : 2001-04-04
+ * AUTHOR : Emanuele Aliberti <eal@users.sf.net>
+ *
+ * --------------------------------------------------------------------
+ *
+ * This software is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; see the file COPYING. If not, write
+ * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
+ * MA 02139, USA.
+ *
+ * --------------------------------------------------------------------
+ */
+#include <psxss.h>
+#include <psx/lpcproto.h>
+#include "utils.h"
+
+/**********************************************************************
+ * ProcessConnectionRequest/ PRIVATE
+ *
+ * DESCRIPTION
+ * This is called when a PSX process attaches to PSXDLL.DLL.
+ */
+PRIVATE NTSTATUS STDCALL
+ProcessConnectionRequest (PLPC_MAX_MESSAGE pRequest)
+{
+ PPSX_CONNECT_PORT_DATA pConnectData = (PPSX_CONNECT_PORT_DATA) & pRequest->Data;
+ NTSTATUS Status;
+ HANDLE hConnectedPort;
+ ULONG ulPortIdentifier;
+
+ debug_print (L"PSXSS: ->"__FUNCTION__);
+ /* Check if the caller is a process */
+ Status = PsxCheckConnectionRequest (
+ pConnectData,
+ PSX_CONNECTION_TYPE_PROCESS
+ );
+ if (!NT_SUCCESS(Status))
+ {
+ Status = NtAcceptConnectPort (
+ & hConnectedPort,
+ NULL,
+ & pRequest->Header,
+ FALSE, /* reject connection request */
+ NULL,
+ NULL
+ );
+ if (!NT_SUCCESS(Status))
+ {
+ debug_print(
+ L"PSXSS: "__FUNCTION__": NtAcceptConnectPort failed with status=%08x",
+ Status
+ );
+ }
+ return STATUS_UNSUCCESSFUL;
+ }
+ /* OK, accept the connection */
+ Status = NtAcceptConnectPort (
+ & hConnectedPort,
+ & ulPortIdentifier,
+ & pRequest->Header,
+ TRUE, /* accept connection request */
+ NULL,
+ NULL
+ );
+ if (!NT_SUCCESS(Status))
+ {
+ debug_print(L"PSXSS: "__FUNCTION__": NtAcceptConnectPort failed with status=%08x", Status);
+ return Status;
+ }
+ Status = PsxCreateProcess (pRequest,hConnectedPort,ulPortIdentifier);
+ if (!NT_SUCCESS(Status))
+ {
+ debug_print(L"PSXSS: "__FUNCTION__": PsxCreateProcess failed with status=%08x", Status);
+ return Status;
+ }
+ Status = NtCompleteConnectPort (hConnectedPort);
+ if (!NT_SUCCESS(Status))
+ {
+ debug_print(L"PSXSS: "__FUNCTION__": NtCompleteConnectPort failed with status=%08x", Status);
+ return Status;
+ }
+ debug_print (L"PSXSS: <-"__FUNCTION__);
+ return STATUS_SUCCESS;
+}
+/**********************************************************************
+ * ProcessRequest/ PRIVATE
+ *
+ * DESCRIPTION
+ * This is the actual POSIX system calls dispatcher.
+ */
+PRIVATE NTSTATUS STDCALL
+ProcessRequest (PPSX_MAX_MESSAGE pRequest)
+{
+ debug_print (L"PSXSS: ->"__FUNCTION__);
+
+ if (pRequest->PsxHeader.Procedure < PSX_SYSCALL_APIPORT_COUNT)
+ {
+ pRequest->PsxHeader.Status =
+ SystemCall [pRequest->PsxHeader.Procedure] (pRequest);
+ }
+ else
+ {
+ pRequest->PsxHeader.Status = STATUS_INVALID_SYSTEM_SERVICE;
+ }
+ return STATUS_SUCCESS;
+}
+/**********************************************************************
+ * ApiPortListener/1
+ *
+ * DESCRIPTION
+ * The thread to process messages from the \POSIX+\ApiPort
+ * LPC port. Mostly used by PSXDLL.DLL.
+ */
+VOID STDCALL
+ApiPortListener (PVOID pArg)
+{
+ ULONG ulIndex = (ULONG) pArg;
+ NTSTATUS Status;
+ LPC_TYPE RequestType;
+ ULONG PortIdentifier;
+ PSX_MAX_MESSAGE Request;
+ PPSX_MAX_MESSAGE Reply = NULL;
+ BOOL NullReply = FALSE;
+
+ debug_print (L"PSXSS: ->"__FUNCTION__" pArg=%d", ulIndex);
+
+ while (TRUE)
+ {
+ Reply = NULL;
+ NullReply = FALSE;
+ while (!NullReply)
+ {
+ Status = NtReplyWaitReceivePort (
+ Server.Port[ulIndex].hObject,
+ 0,
+ (PLPC_MESSAGE) Reply,
+ (PLPC_MESSAGE) & Request
+ );
+ if (!NT_SUCCESS(Status))
+ {
+ break;
+ }
+ RequestType = PORT_MESSAGE_TYPE(Request);
+ switch (RequestType)
+ {
+ case LPC_CONNECTION_REQUEST:
+ ProcessConnectionRequest ((PLPC_MAX_MESSAGE) & Request);
+ NullReply = TRUE;
+ continue;
+ case LPC_CLIENT_DIED:
+ case LPC_PORT_CLOSED:
+ case LPC_DEBUG_EVENT:
+ case LPC_ERROR_EVENT:
+ case LPC_EXCEPTION:
+ NullReply = TRUE;
+ continue;
+ default:
+ if (RequestType != LPC_REQUEST)
+ {
+ NullReply = TRUE;
+ continue;
+ }
+ }
+ Reply = & Request;
+ Reply->PsxHeader.Status = ProcessRequest (& Request);
+ NullReply = FALSE;
+ }
+ if ((STATUS_INVALID_HANDLE == Status) ||
+ (STATUS_OBJECT_TYPE_MISMATCH == Status))
+ {
+ break;
+ }
+ }
+#ifdef __PSXSS_ON_W32__
+ TerminateThread(GetCurrentThread(),Status);
+#else
+ NtTerminateThread(NtCurrentThread(),Status);
+#endif
+}
+/* EOF */
--- /dev/null
+/* $Id: sbapi.c,v 1.3 2002/10/29 04:45:58 rex Exp $
+ *
+ * PROJECT : ReactOS / POSIX+ Environment Subsystem Server
+ * FILE : reactos/subsys/psx/server/port/sbapi.c
+ * DESCRIPTION: \POSIX+\SbApiPort LPC logic.
+ * DATE : 2001-03-23
+ * AUTHOR : Emanuele Aliberti <eal@users.sf.net>
+ *
+ * --------------------------------------------------------------------
+ *
+ * This software is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; see the file COPYING. If not, write
+ * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
+ * MA 02139, USA.
+ *
+ * --------------------------------------------------------------------
+ */
+#include <psxss.h>
+#include "utils.h"
+
+
+/**********************************************************************
+ * ProcessConnectionRequest/ PRIVATE
+ */
+PRIVATE NTSTATUS STDCALL
+ProcessConnectionRequest (PPSX_MESSAGE pRequest)
+{
+ return STATUS_NOT_IMPLEMENTED;
+}
+/**********************************************************************
+ * ProcessRequest/ PRIVATE
+ */
+PRIVATE NTSTATUS STDCALL
+ProcessRequest (PPSX_MESSAGE pRequest)
+{
+ return STATUS_NOT_IMPLEMENTED;
+}
+/**********************************************************************
+ * SbApiPortListener/1
+ *
+ * DESCRIPTION
+ * The \POSIX+\SbApiPort LPC port message dispatcher.
+ *
+ * NOTE
+ * what is this port for? Is "Sb" for "shared block"?
+ */
+VOID STDCALL
+SbApiPortListener (PVOID pArg)
+{
+ NTSTATUS Status;
+ ULONG PortIdentifier;
+ PSX_MAX_MESSAGE Request;
+ PPSX_MAX_MESSAGE Reply = NULL;
+
+ debug_print (L"PSXSS: ->"__FUNCTION__" pArg=%d", (ULONG) pArg);
+
+ RtlZeroMemory (& Request, sizeof Request);
+ /* TODO */
+#ifdef __PSXSS_ON_W32__
+ Sleep(30000);
+ TerminateThread(GetCurrentThread(),Status);
+#else
+ NtTerminateThread(NtCurrentThread(),Status);
+#endif
+}
+/* EOF */
--- /dev/null
+/* $Id: session.c,v 1.3 2002/10/29 04:45:58 rex Exp $
+ *
+ * PROJECT : ReactOS / POSIX+ Environment Subsystem Server
+ * FILE : reactos/subsys/psx/server/port/session.c
+ * DESCRIPTION: \POSIX+\SessionPort LPC port logic.
+ * DATE : 2002-04-04
+ * AUTHOR : Emanuele Aliberti <eal@users.sf.net>
+ *
+ * --------------------------------------------------------------------
+ *
+ * This software is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; see the file COPYING. If not, write
+ * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
+ * MA 02139, USA.
+ *
+ * --------------------------------------------------------------------
+ */
+#include <psxss.h>
+#include <psx/lpcproto.h>
+#include "utils.h"
+
+/**********************************************************************
+ * ProcessConnectionRequest/ PRIVATE
+ */
+PRIVATE NTSTATUS STDCALL
+ProcessConnectionRequest (PLPC_MAX_MESSAGE pRequest)
+{
+ PPSX_CONNECT_PORT_DATA pConnectData = (PPSX_CONNECT_PORT_DATA) & pRequest->Data;
+ NTSTATUS Status;
+ HANDLE hConnectedPort;
+ ULONG ulPortIdentifier;
+
+ debug_print (L"PSXSS: ->"__FUNCTION__);
+
+ /* Check if the caller is a terminal */
+ Status = PsxCheckConnectionRequest (
+ pConnectData,
+ PSX_CONNECTION_TYPE_TERMINAL
+ );
+ if (!NT_SUCCESS(Status))
+ {
+ Status = NtAcceptConnectPort (
+ & hConnectedPort,
+ NULL,
+ & pRequest->Header,
+ FALSE, /* reject connection request */
+ NULL,
+ NULL
+ );
+ if (!NT_SUCCESS(Status))
+ {
+ debug_print(
+ L"PSXSS: "__FUNCTION__": NtAcceptConnectPort failed with status=%08x",
+ Status
+ );
+ }
+ return STATUS_UNSUCCESSFUL;
+ }
+ /* OK, accept the connection */
+ Status = NtAcceptConnectPort (
+ & hConnectedPort,
+ & ulPortIdentifier,
+ & pRequest->Header,
+ TRUE, /* accept connection request */
+ NULL,
+ NULL
+ );
+ if (!NT_SUCCESS(Status))
+ {
+ debug_print(L"PSXSS: "__FUNCTION__": NtAcceptConnectPort failed with status=%08x", Status);
+ return Status;
+ }
+ /* OK, now create a new PSX_SESSION object */
+ Status = PsxCreateSession (
+ pRequest,
+ hConnectedPort,
+ ulPortIdentifier
+ );
+ if (!NT_SUCCESS(Status))
+ {
+ debug_print(L"PSXSS: "__FUNCTION__": PsxCreateSession failed with status=%08x", Status);
+ return Status;
+ }
+ Status = NtCompleteConnectPort (hConnectedPort);
+ if (!NT_SUCCESS(Status))
+ {
+ debug_print(L"PSXSS: "__FUNCTION__": NtCompleteConnectPort failed with status=%08x", Status);
+ return Status;
+ }
+ debug_print (L"PSXSS: <-"__FUNCTION__);
+ return STATUS_SUCCESS;
+}
+/**********************************************************************
+ * ProcessRequest/ PRIVATE
+ */
+PRIVATE NTSTATUS STDCALL
+ProcessRequest (PPSX_MAX_MESSAGE pRequest)
+{
+ debug_print (L"PSXSS: ->"__FUNCTION__);
+ /* TODO: Read data from the section */
+ /* TODO: send data to the process */
+ debug_print (L"PSXSS: <-"__FUNCTION__);
+ return STATUS_NOT_IMPLEMENTED;
+}
+/**********************************************************************
+ * SessionPortListener/1
+ *
+ * DESCRIPTION
+ * Listen on port \POSIX+\SessionPort and create new sessions
+ * when a new terminal emulator calls.
+ *
+ * ARGUMENTS
+ * \POSIX+\SessionPort handle.
+ *
+ * RETURN VALUE
+ * None.
+ */
+VOID STDCALL
+SessionPortListener (PVOID pArg)
+{
+ ULONG ulIndex = (ULONG) pArg;
+ NTSTATUS Status;
+ LPC_TYPE RequestType;
+ ULONG PortIdentifier;
+ PSX_MAX_MESSAGE Request;
+ PPSX_MAX_MESSAGE Reply = NULL;
+ BOOL NullReply = FALSE;
+
+ debug_print (L"PSXSS: ->"__FUNCTION__" pArg=%d", ulIndex);
+
+ while (TRUE)
+ {
+ Reply = NULL;
+ NullReply = FALSE;
+ while (!NullReply)
+ {
+ Status = NtReplyWaitReceivePort (
+ Server.Port[ulIndex].hObject,
+ 0,
+ (PLPC_MESSAGE) Reply,
+ (PLPC_MESSAGE) & Request
+ );
+ if (!NT_SUCCESS(Status))
+ {
+ break;
+ }
+ RequestType = PORT_MESSAGE_TYPE(Request);
+ switch (RequestType)
+ {
+ case LPC_CONNECTION_REQUEST:
+ ProcessConnectionRequest ((PLPC_MAX_MESSAGE) & Request);
+ NullReply = TRUE;
+ continue;
+ case LPC_CLIENT_DIED:
+ case LPC_PORT_CLOSED:
+ case LPC_DEBUG_EVENT:
+ case LPC_ERROR_EVENT:
+ case LPC_EXCEPTION:
+ NullReply = TRUE;
+ continue;
+ default:
+ if (RequestType != LPC_REQUEST)
+ {
+ NullReply = TRUE;
+ continue;
+ }
+ }
+ Reply = & Request;
+ Reply->PsxHeader.Status = ProcessRequest (& Request);
+ NullReply = FALSE;
+ }
+ if ((STATUS_INVALID_HANDLE == Status) ||
+ (STATUS_OBJECT_TYPE_MISMATCH == Status))
+ {
+ break;
+ }
+ }
+#ifdef __PSXSS_ON_W32__
+ TerminateThread(GetCurrentThread(),Status);
+#else
+ NtTerminateThread(NtCurrentThread(),Status);
+#endif
+}
+/* EOF */
--- /dev/null
+/* $Id: utils.c,v 1.3 2002/10/29 04:45:58 rex Exp $
+ *
+ * PROJECT : ReactOS / POSIX+ Environment Subsystem Server
+ * FILE : reactos/subsys/psx/server/port/utils.c
+ * DESCRIPTION: LPC port utilities.
+ * DATE : 2002-04-07
+ * AUTHOR : Emanuele Aliberti <eal@users.sf.net>
+ *
+ * --------------------------------------------------------------------
+ *
+ * This software is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; see the file COPYING. If not, write
+ * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
+ * MA 02139, USA.
+ *
+ * --------------------------------------------------------------------
+ */
+#include <psxss.h>
+#include "utils.h"
+
+/**********************************************************************
+ * PsxCheckConnectionRequest/2
+ *
+ * DESCRIPTION
+ * Check if we can accept the connection request sent to
+ * an LPC port. Protocol version and ConnectionType MUST match.
+ */
+NTSTATUS STDCALL
+PsxCheckConnectionRequest (
+ IN OUT PPSX_CONNECT_PORT_DATA pConnectData,
+ IN PSX_CONNECTION_TYPE ConnectionType
+ )
+{
+ /* Check if the caller is ConnectionType */
+ if (ConnectionType != pConnectData->ConnectionType)
+ {
+ debug_print(
+ L"PSXSS: "__FUNCTION__": ConnectionType=%d, expected %d",
+ pConnectData->ConnectionType,
+ ConnectionType
+ );
+ return STATUS_UNSUCCESSFUL;
+ }
+ /* Check if the LPC protocol version matches */
+ if (PSX_LPC_PROTOCOL_VERSION != pConnectData->Version)
+ {
+ debug_print(
+ L"PSXSS: "__FUNCTION__": Version=%d, expected %d",
+ pConnectData->Version,
+ PSX_LPC_PROTOCOL_VERSION
+ );
+ pConnectData->Version = PSX_LPC_PROTOCOL_VERSION;
+ return STATUS_UNSUCCESSFUL;
+ }
+ return STATUS_SUCCESS;
+}
+/* EOF */
--- /dev/null
+#ifndef _UTILS_H
+#define _UTILS_H
+NTSTATUS STDCALL PsxCheckConnectionRequest (PPSX_CONNECT_PORT_DATA,PSX_CONNECTION_TYPE);
+#endif
--- /dev/null
+# $Id: Makefile,v 1.4 2002/10/29 04:45:58 rex Exp $
+#
+# Tool to generate the POSIX+ server system calls table
+# and other auxiliary C files.
+#
+PATH_TO_TOP=../../reactos
+PATH_TO_PSX_TOP=..
+
+TARGET_NAME=mksystab
+SYSCALL_DB=syscall.db
+SYSTAB_C=$(PATH_TO_PSX_TOP)/server/call/syscall.c
+SYSTAB_H=$(PATH_TO_PSX_TOP)/server/include/syscall.h
+SYSCALL_H=$(PATH_TO_PSX_TOP)/include/psx/syscall.h
+STUBS_C=$(PATH_TO_PSX_TOP)/server/call/stubs.c
+
+all: systab
+
+$(TARGET_NAME)$(EXE_POSTFIX): $(TARGET_NAME).c
+ $(CC) $(CFLAGS) -o $(TARGET_NAME)$(EXE_POSTFIX) $(TARGET_NAME).c
+
+systab: $(TARGET_NAME)$(EXE_POSTFIX)
+ $(TARGET_NAME)$(EXE_POSTFIX) \
+ $(SYSCALL_DB) \
+ $(SYSTAB_C) \
+ $(SYSTAB_H) \
+ $(SYSCALL_H) \
+ $(STUBS_C)
+
+clean:
+ - $(RM) $(TARGET_NAME)$(EXE_POSTFIX)
+ - $(RM) *.o
+ - $(RM) $(SYSTAB_C)
+ - $(RM) $(SYSTAB_H)
+ - $(RM) $(SYSCALL_H)
+ - $(RM) $(STUBS_C)
+
+include $(PATH_TO_TOP)/rules.mak
+
+# EOF
--- /dev/null
+/* $Id: mksystab.c,v 1.4 2002/10/29 04:45:58 rex Exp $
+ *
+ * PROJECT : ReactOS / POSIX+ Subsystem
+ * DESCRIPTION: Build the system calls table for
+ * DESCRIPTION: the POSIX+ LPC server process.
+ * NOTE : this code is supposed to be portable.
+ * AUTHOR : Emanuele Aliberti
+ * DATE : 2001-05-26
+ * REVISIONS
+ * 2002-03-19 EA added stub file generation
+ * 2002-04-06 EA added to the CVS repository
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#define PARSER_CONTEXT_LINE_SIZE 1024
+#define PARSER_CONTEXT_INTERFACE_SIZE 64
+
+const char * myname = "mksystab";
+
+const char * syscall_name_prefix = "syscall_";
+const char * proxy_name_prefix = "psxss_";
+
+typedef enum {
+ METHOD_SUCCESS,
+ METHOD_EOF,
+ METHOD_FAILURE
+} METHOD_TYPE;
+
+typedef struct _PARSER_CONTEXT
+{
+ int line_number;
+ int id;
+ char line [PARSER_CONTEXT_LINE_SIZE];
+ char status;
+ char interface [PARSER_CONTEXT_INTERFACE_SIZE];
+ int argc;
+
+} PARSER_CONTEXT, * PPARSER_CONTEXT;
+
+typedef struct _MFILE
+{
+ char * name;
+ FILE * fp;
+ char * fopen_mode;
+ METHOD_TYPE (*prologue)(int,PPARSER_CONTEXT);
+ METHOD_TYPE (*iter)(int,PPARSER_CONTEXT);
+ METHOD_TYPE (*epilog)(int,PPARSER_CONTEXT);
+
+} MFILE, * PMFILE;
+
+/* MFILE file table */
+
+METHOD_TYPE db_prologue (int self, PPARSER_CONTEXT context);
+METHOD_TYPE db_iter (int self, PPARSER_CONTEXT context);
+METHOD_TYPE db_epilog (int self, PPARSER_CONTEXT context);
+
+METHOD_TYPE systab_prologue (int self, PPARSER_CONTEXT context);
+METHOD_TYPE systab_iter (int self, PPARSER_CONTEXT context);
+METHOD_TYPE systab_epilog (int self, PPARSER_CONTEXT context);
+
+METHOD_TYPE psx_include_prologue (int self, PPARSER_CONTEXT context);
+METHOD_TYPE psx_include_iter (int self, PPARSER_CONTEXT context);
+METHOD_TYPE psx_include_epilog (int self, PPARSER_CONTEXT context);
+
+METHOD_TYPE server_include_prologue (int self, PPARSER_CONTEXT context);
+METHOD_TYPE server_include_iter (int self, PPARSER_CONTEXT context);
+METHOD_TYPE server_include_epilog (int self, PPARSER_CONTEXT context);
+
+METHOD_TYPE stubs_prologue (int self, PPARSER_CONTEXT context);
+METHOD_TYPE stubs_iter (int self, PPARSER_CONTEXT context);
+METHOD_TYPE stubs_epilog (int self, PPARSER_CONTEXT context);
+
+
+MFILE mf [] =
+{
+ { NULL, NULL, "r", db_prologue, db_iter, db_epilog }, /* it must be 1st */
+ { NULL, NULL, "w", systab_prologue, systab_iter, systab_epilog },
+ { NULL, NULL, "w", server_include_prologue, server_include_iter, server_include_epilog },
+ { NULL, NULL, "w", psx_include_prologue, psx_include_iter, psx_include_epilog },
+ { NULL, NULL, "w", stubs_prologue, stubs_iter, stubs_epilog }
+};
+
+
+/* mf objects methods */
+
+int mf_open (int index)
+{
+ mf [index].fp = fopen (mf [index].name, mf [index].fopen_mode);
+ if (NULL == mf [index].fp)
+ {
+ fprintf (stderr, "%s: error %d while opening \"%s\".", myname, errno, mf [index].name);
+ return METHOD_FAILURE;
+ }
+ return METHOD_SUCCESS;
+}
+
+void mf_close (int index)
+{
+ fclose (mf[index].fp);
+}
+
+/* db file methods */
+
+METHOD_TYPE db_prologue (int self, PPARSER_CONTEXT context)
+{
+ if (METHOD_FAILURE == mf_open (self))
+ {
+ return METHOD_FAILURE;
+ }
+ fprintf (stderr, "Processing \"%s\"...\n", mf [self].name);
+ return METHOD_SUCCESS;
+}
+
+METHOD_TYPE db_iter (int self, PPARSER_CONTEXT context)
+{
+ char * eol;
+
+ do
+ {
+ if (feof(mf [self].fp))
+ {
+ return METHOD_EOF;
+ }
+ if (NULL == fgets (context->line, PARSER_CONTEXT_LINE_SIZE, mf [self].fp))
+ {
+ return METHOD_EOF;
+ }
+ ++ context->line_number;
+ eol = strchr(context->line, '\n');
+ if (eol)
+ {
+ *eol = '\0';
+ }
+ /* Is line empty or a comment? */
+ } while (0 == strlen (context->line) || context->line[0] == '#');
+ /* Line is not a comment nor an empty line */
+ if (3 != sscanf (context->line, "%c%s%d", & context->status, context->interface, & context->argc))
+ {
+ fprintf (stderr, "Syntax error at line %d.\n", context->line_number);
+ return METHOD_FAILURE;
+ }
+ return METHOD_SUCCESS;
+}
+
+METHOD_TYPE db_epilog (int self, PPARSER_CONTEXT context)
+{
+ mf_close (self);
+ return METHOD_SUCCESS;
+}
+
+/* systab file methods */
+
+METHOD_TYPE systab_prologue (int self, PPARSER_CONTEXT context)
+{
+ if (METHOD_FAILURE == mf_open (self))
+ {
+ return METHOD_FAILURE;
+ }
+ fprintf (mf[self].fp, "/* POSIX+ system calls (machine generated: do not edit!) */\n");
+ fprintf (mf[self].fp, "#include <psxss.h>\n");
+ fprintf (mf[self].fp, "#include <syscall.h>\n");
+ fprintf (mf[self].fp, "PSX_SYSTEM_CALL SystemCall [] =\n");
+ fprintf (mf[self].fp, "{\n");
+ return METHOD_SUCCESS;
+}
+
+METHOD_TYPE systab_iter (int self, PPARSER_CONTEXT context)
+{
+ switch (context->status)
+ {
+ case '+':
+ case '-': /* unimplemented interface */
+ fprintf (mf[self].fp, "(void*)%s%s,\n", syscall_name_prefix, context->interface);
+ break;
+ default:
+ fprintf (stderr, "%s: unknown interface status \"%c\" at line %d.\n",
+ myname, context->status, context->line_number);
+ return METHOD_FAILURE;
+ }
+ return METHOD_SUCCESS;
+}
+
+METHOD_TYPE systab_epilog (int self, PPARSER_CONTEXT context)
+{
+ fprintf (mf[self].fp, "0\n};\n");
+ fputs ("/* EOF */", mf[self].fp);
+ return METHOD_SUCCESS;
+}
+
+
+/* server/include file methods */
+
+METHOD_TYPE server_include_prologue (int self, PPARSER_CONTEXT context)
+{
+ if (METHOD_FAILURE == mf_open (self))
+ {
+ return METHOD_FAILURE;
+ }
+ fprintf (mf[self].fp, "/* POSIX+ system calls (machine generated: do not edit!) */\n");
+ fprintf (mf[self].fp, "#ifndef _SERVER_SYSCALL_H\n");
+ fprintf (mf[self].fp, "#define _SERVER_SYSCALL_H\n");
+ return METHOD_SUCCESS;
+}
+
+METHOD_TYPE server_include_iter (int self, PPARSER_CONTEXT context)
+{
+ char interface [PARSER_CONTEXT_INTERFACE_SIZE*2];
+
+ sprintf (interface, "%s%s", syscall_name_prefix, context->interface);
+ fprintf (mf[self].fp, "NTSTATUS STDCALL %s (PPSX_MAX_MESSAGE);\n", interface);
+
+ return METHOD_SUCCESS;
+}
+
+METHOD_TYPE server_include_epilog (int self, PPARSER_CONTEXT context)
+{
+ fprintf (mf[self].fp, "#endif /* ndef _SERVER_SYSCALL_H */\n");
+ fputs ("/* EOF */", mf[self].fp);
+ return METHOD_SUCCESS;
+}
+
+
+/* psx/include file methods */
+
+METHOD_TYPE psx_include_prologue (int self, PPARSER_CONTEXT context)
+{
+ if (METHOD_FAILURE == mf_open (self))
+ {
+ return METHOD_FAILURE;
+ }
+ fprintf (mf[self].fp, "/* POSIX+ system calls (machine generated: do not edit!) */\n");
+ fprintf (mf[self].fp, "#ifndef _PSX_SYSCALL_H\n");
+ fprintf (mf[self].fp, "#define _PSX_SYSCALL_H\n");
+ return METHOD_SUCCESS;
+}
+
+METHOD_TYPE psx_include_iter (int self, PPARSER_CONTEXT context)
+{
+ char interface [PARSER_CONTEXT_INTERFACE_SIZE*2];
+
+ sprintf (interface, "%s%s", proxy_name_prefix, context->interface);
+ fprintf (mf[self].fp, "#define %s %d\n", strupr(interface), context->id ++);
+
+ return METHOD_SUCCESS;
+}
+
+METHOD_TYPE psx_include_epilog (int self, PPARSER_CONTEXT context)
+{
+ fprintf (mf[self].fp, "#define PSX_SYSCALL_APIPORT_COUNT %d\n", context->id ++);
+ fprintf (mf[self].fp, "#endif /* ndef _PSX_SYSCALL_H */\n");
+ fputs ("/* EOF */", mf[self].fp);
+ return METHOD_SUCCESS;
+}
+
+
+/* stubs file methods */
+
+METHOD_TYPE stubs_prologue (int self, PPARSER_CONTEXT context)
+{
+ if (METHOD_FAILURE == mf_open (self))
+ {
+ return METHOD_FAILURE;
+ }
+ fprintf( mf[self].fp,
+ "/* POSIX+ system calls not yet implemented */\n"
+ "/* (machine generated: do not edit!) */\n"
+ "#include <psxss.h>\n");
+ return METHOD_SUCCESS;
+}
+
+METHOD_TYPE stubs_iter (int self, PPARSER_CONTEXT context)
+{
+ if ('-' == context->status)
+ {
+ fprintf (
+ mf[self].fp,
+ "NTSTATUS STDCALL %s%s(PPSX_MAX_MESSAGE Msg){Msg->PsxHeader.Status=STATUS_NOT_IMPLEMENTED;return(STATUS_SUCCESS);}\n",
+ syscall_name_prefix,
+ context->interface
+ );
+ }
+ return METHOD_SUCCESS;
+}
+
+METHOD_TYPE stubs_epilog (int self, PPARSER_CONTEXT context)
+{
+ fputs ("/* EOF */", mf[self].fp);
+ return METHOD_SUCCESS;
+}
+
+
+/* main loop */
+
+METHOD_TYPE mksystab ()
+{
+ int index;
+ int index_top = (sizeof mf / sizeof mf[0]);
+ int iterate = 1;
+ PARSER_CONTEXT context;
+ METHOD_TYPE mt;
+
+ /* initialize the parser's context */
+ context.line_number = 0;
+ context.id = 0;
+
+ /* prologue */
+ for (index = 0; index < index_top; index ++)
+ {
+ if (METHOD_FAILURE == mf[index].prologue (index, & context))
+ {
+ return METHOD_FAILURE;
+ }
+ }
+ /* iter */
+ while (iterate)
+ {
+ for (index = 0; index < index_top; index ++)
+ {
+ mt = mf[index].iter (index, & context);
+ if (METHOD_EOF == mt)
+ {
+ if (0 == index) /* input MUST be 1st MFILE */
+ {
+ iterate = 0;
+ break; /* input reached EOF */
+ }
+ return METHOD_FAILURE;
+ }
+ else if (METHOD_FAILURE == mt)
+ {
+ return METHOD_FAILURE;
+ }
+ }
+ }
+ /* epilog */
+ for (index = 0; index < index_top; index ++)
+ {
+ if (METHOD_FAILURE == mf[index].epilog (index, & context))
+ {
+ return METHOD_FAILURE;
+ }
+ }
+
+ /* done */
+ return METHOD_SUCCESS;
+}
+
+/* entry point */
+
+int main (int argc, char **argv)
+{
+ int status = 0;
+ int index;
+
+ /* Check user parameters */
+ if ((1 + (sizeof mf / sizeof (MFILE))) != argc)
+ {
+ printf ("ReactOS Operating System - POSIX+ Environment Subsystem\n");
+ printf ("Build the system calls table of the POSIX+ server.\n\n");
+ printf ("usage: %s syscall.db syscall.c syscall.h syscall.h stubs.c\n", argv[0]);
+ exit (METHOD_FAILURE);
+ }
+ /* initialize descriptors */
+ for (index = 0; index < (sizeof mf / sizeof mf[0]); index ++)
+ {
+ mf [index].name = argv [index + 1];
+ }
+
+ /* do process them */
+ status = mksystab ();
+
+ return (status);
+}
+
+
+/* EOF */
--- /dev/null
+# $Id: syscall.db,v 1.3 2002/10/29 04:45:58 rex Exp $
+#
+# ReactOS - Operating System
+# Symbolic system calls table for the POSIX+ server.
+#
+# NOTE: the PSXSS server implements only the system calls
+# that can NOT be implemented in full/correctly in the
+# PSXDLL library.
+#
+# ENTRY SYNTAX
+# status interface_name argc
+#
+# status = + | -
+#
+# LEGENDA
+# + means the system call is implemented in the server;
+# - means "{errno=ENOSYS;return -1;}".
+#
++ null 0
+- fork 0
+- authenticateuser 0
+- waitpid 3
++ _exit 1
+- kill 2
+- sigaction 3
+- sigprocmask 3
+- sigpending 1
+- sigsuspend 1
+- alarm 1
+- getpsids 0
+- syscall12 0
+- syscall13 0
+- getgroups 2
+- syscall15 0
+- syscall16 0
+- setsid 0
+- setpgid 2
+- syscall19 0
+- syscall20 0
+- times 1
+- ttyname 3
+- isatty 1
+- sysconf 1
+- open 2
+- umask 1
+- link 2
+- mkdir 2
+- mkfifo 2
+- rmdir 1
+- rename 2
+- stat 2
+- fstat 2
+- access 2
+- chmod 2
+- chown 3
+- utime 2
+- pathconf 2
+- fpathconf 2
+- pipe 1
+- syscall41 0
+- dup2 2
+- close 1
+- read 3
+- write 3
+- fcntl 3
+- lseek 3
+- tcgetattr 2
+- tcsetattr 3
+- tcsendbreak 2
+- tcdrain 1
+- tcflush 2
+- tcflow 2
+- tcgetpgrp 1
+- tcsetpgrp 2
+- getpwuid 1
+- getpwnam 1
+- getgrgid 1
+- getgrnam 1
+- unlink 1
+- readdir 1
+- ftruncate 2
+- syscall63 0
+- semctl 4
+- semget 3
+- semop 3
+- shmat 3
+- shmctl 3
+- shmdt 1
+- shmget 3
+- msgctl 3
+- msgget 2
+- msgrcv 5
+- msgsnd 4
+- socket 3
+- accept 3
+- bind 3
+- connect 3
+- getpeername 3
+- getsockname 3
+- getsockopt 5
+- listen 2
+- recv 4
+- recvfrom 6
+- send 4
+- sendto 6
+- setsockopt 5
+- shutdown 2
+- gethostbyname 1
+- gethostbyaddr 3
+- getprotobyname 1
+- getprotobynumber 1
+- getservbyname 2
+- getservbyport 2
+- select 5
+- statvfs 2
+- fstatvfs 2
+- ptsname 1
+- _fdptcheck 0
+- ioctl 2
+- mmap 6
+- syscall102 0
+- uidtontsid 1
+- gettzenv 0
+- pututxline 1
+- renamewtmpx 0
+- fsync 1
+- setgetitimer 0
+- setuser 0
+- ipcs 0
+# EOF