Browse Source

+ sorted entries

michael 27 years ago
parent
commit
35c2815722
6 changed files with 658 additions and 622 deletions
  1. 2 1
      docs/Makefile
  2. 102 106
      docs/crt.tex
  3. 32 30
      docs/getopts.tex
  4. 223 217
      docs/go32.tex
  5. 208 177
      docs/sockets.tex
  6. 91 91
      docs/strings.tex

+ 2 - 1
docs/Makefile

@@ -149,7 +149,7 @@ clean:
 	-$(MAKE) -C printex clean
 	-$(MAKE) -C stringex clean
 	-$(MAKE) -C sockex clean
-
+	-$(MAKE) -C mouseex clean
 unitex.chk:
 	$(MAKE) -C crtex tex
 	$(MAKE) -C linuxex tex
@@ -158,6 +158,7 @@ unitex.chk:
 	$(MAKE) -C printex tex
 	$(MAKE) -C stringex tex
 	$(MAKE) -C sockex tex
+	$(MAKE) -C mouseex tex
 	touch unitex.chk
 
 refex.chk:

+ 102 - 106
docs/crt.tex

@@ -107,6 +107,7 @@ var lastmode : Word;
 \end{verbatim}
 
 \section{Procedures and Functions}
+
 \procedure{AssignCrt}{(Var F: Text)}
 {
 Assigns a file F to the console. Everything written to the file F goes to
@@ -117,6 +118,37 @@ to the window instead.
 
 \input{crtex/ex1.tex}
 
+\Procedure{BigCursor}{Makes the cursor a big rectangle. 
+
+Not implemented on \linux.}
+{None.}{\seep{CursorOn}, \seep{CursorOff}}
+
+\Procedure {ClrEol}
+{ ClrEol clears the current line, starting from the cursor position, to the
+end of the window. The cursor doesn't move}
+{None.}{\seep{DelLine}, \seep{InsLine}, \seep{ClrScr}}
+
+\input{crtex/ex9.tex}
+
+\procedure {ClrScr}{}
+{ ClrScr clears the current window (using the current colors), 
+and sets the cursor in the top left
+corner of the current window.}
+{None.}{ \seep{Window} }
+
+\input{crtex/ex8.tex}
+
+\Procedure{CursorOff}{Switches the cursor off (i.e. the cursor is no
+longer visible). 
+
+Not implemented on \linux.}
+{None.}{\seep{CursorOn}, \seep{BigCursor}}
+
+\Procedure{CursorOn}{Switches the cursor on. 
+
+Not implemented on \linux.}
+{None.}{\seep{BigCursor}, \seep{CursorOff}}
+
 \procedure{Delay}{(DTime: Word)}
 {Delay waits a specified number of milliseconds. The number of specified
 seconds is a approximation, and may be off a lot, if system load is high.}
@@ -124,25 +156,22 @@ seconds is a approximation, and may be off a lot, if system load is high.}
 
 \input{crtex/ex15.tex}
 
-\procedure {TextColor}{(CL: Byte)}
-{
-TextColor sets the foreground color to \var{CL}. \var{CL} can be one of the
-predefined color constants.
-}
-{None.}{ \seep{TextBackground}, \seep{HighVideo}, \seep{LowVideo},
-\seep{NormVideo}}
+\Procedure {DelLine}
+{ DelLine removes the current line. Lines following the current line are 
+scrolled 1 line up, and an empty line is inserted at the bottom of the
+current window. The cursor doesn't move.}
+{None.}{\seep{ClrEol}, \seep{InsLine}, \seep{ClrScr}}
 
-\input{crtex/ex12.tex}
+\input{crtex/ex11.tex}
 
-\procedure {TextBackground}{(CL: Byte)}
-{
-TextBackground sets the background color to \var{CL}. \var{CL} can be one of the
-predefined color constants.
+\procedure {GotoXY}{(X: Byte; Y: Byte)}
+{ Positions the cursor at \var{(X,Y)}, \var{X} in horizontal, \var{Y} in
+vertical direction relative to the origin of the current window. The origin
+is located at \var{(1,1)}, the upper-left corner of the window.
 }
-{None.}{ \seep{TextColor}, \seep{HighVideo}, \seep{LowVideo},
-\seep{NormVideo}}
+{None.}{ \seef{WhereX}, \seef{WhereY}, \seep{Window} }
 
-\input{crtex/ex13.tex}
+\input{crtex/ex6.tex}
 
 \procedure {HighVideo}{}
 { HighVideo switches the output to highlighted text. (It sets the high
@@ -153,6 +182,26 @@ intensity bit of the video attribute)
 
 \input{crtex/ex14.tex}
 
+\procedure {InsLine}{}
+{ InsLine inserts an empty line at the current cursor position. 
+Lines following the current line are scrolled 1 line down, 
+causing the last line to disappear from the window. 
+The cursor doesn't move.}
+{None.}{\seep{ClrEol}, \seep{DelLine}, \seep{ClrScr}}
+
+\input{crtex/ex10.tex}
+
+\Function {KeyPressed}{Boolean}
+{ The Keypressed function scans the keyboard buffer and sees if a key has
+been pressed. If this is the case, \var{True} is returned. If not,
+\var{False} is returned. The \var{Shift, Alt, Ctrl} are not reported.
+The key is not removed from the buffer, and can hence still be read after
+the KeyPressed function has been called.
+}
+{None.}{\seef{ReadKey}}
+
+\input{crtex/ex2.tex}
+
 \Procedure {LowVideo}
 { LowVideo switches the output to non-highlighted text. (It clears the high
 intensity bit of the video attribute)
@@ -171,30 +220,52 @@ defaults are read from the cursor position at startup)
 
 For an example, see \seep{HighVideo}
 
-\Procedure{BigCursor}{Makes the cursor a big rectangle. 
+\Procedure{NoSound}{
+Stops the speaker sound.
 
-Not implemented on \linux.}
-{None.}{\seep{CursorOn}, \seep{CursorOff}}
+This is not supported in \linux}{None.}{\seep{Sound}}
 
-\Procedure{CursorOn}{Switches the cursor on. 
+\input{crtex/ex16.tex}
 
-Not implemented on \linux.}
-{None.}{\seep{BigCursor}, \seep{CursorOff}}
+\Function  {ReadKey}{Char}
+{
+The ReadKey function reads 1 key from the keyboard buffer, and returns this.
+If an extended or function key has been pressed, then the zero ASCII code is 
+returned. You can then read the scan code of the key with a second ReadKey
+call.
 
-\Procedure{CursorOff}{Switches the cursor off (i.e. the cursor is no
-longer visible). 
+\textbf{Remark.} Key mappings under Linux can cause the wrong key to be
+reported by ReadKey, so caution is needed when using ReadKey.  
+}
+{None.}{\seef{KeyPressed}}
 
-Not implemented on \linux.}
-{None.}{\seep{CursorOn}, \seep{BigCursor}}
+\input{crtex/ex3.tex}
 
-\procedure {GotoXY}{(X: Byte; Y: Byte)}
-{ Positions the cursor at \var{(X,Y)}, \var{X} in horizontal, \var{Y} in
-vertical direction relative to the origin of the current window. The origin
-is located at \var{(1,1)}, the upper-left corner of the window.
+
+\procedure{Sound}{(hz : word)}
+{ Sounds the speaker at a frequency of \var{hz}.
+
+This is not supported in \linux}{None.}{\seep{NoSound}}
+
+\procedure {TextBackground}{(CL: Byte)}
+{
+TextBackground sets the background color to \var{CL}. \var{CL} can be one of the
+predefined color constants.
 }
-{None.}{ \seef{WhereX}, \seef{WhereY}, \seep{Window} }
+{None.}{ \seep{TextColor}, \seep{HighVideo}, \seep{LowVideo},
+\seep{NormVideo}}
 
-\input{crtex/ex6.tex}
+\input{crtex/ex13.tex}
+
+\procedure {TextColor}{(CL: Byte)}
+{
+TextColor sets the foreground color to \var{CL}. \var{CL} can be one of the
+predefined color constants.
+}
+{None.}{ \seep{TextBackground}, \seep{HighVideo}, \seep{LowVideo},
+\seep{NormVideo}}
+
+\input{crtex/ex12.tex}
 
 \Function  {WhereX}{Byte}
 {
@@ -232,15 +303,6 @@ are relative to the window's top left corner.
 \input{crtex/ex5.tex}
 
 
-\procedure {ClrScr}{}
-{ ClrScr clears the current window (using the current colors), 
-and sets the cursor in the top left
-corner of the current window.}
-{None.}{ \seep{Window} }
-
-\input{crtex/ex8.tex}
-
-
 %\procedure {ScrollWindow}{(X1,Y1,X2,Y2 : Byte; Count : Longint)}
 %{ ScrollWindow scrolls the contents of the window defined by the upper-left
 %\var{(X1,Y1)} and lower-right \var{(X2,Y2)} corners \var{count} lines up if
@@ -275,69 +337,3 @@ corner of the current window.}
 %The memory pointed to by \var{P} is NOT freed.}{None}
 %{\seef{SaveScreenRegion}, \seep{Window} }
 
-
-\Procedure {ClrEol}
-{ ClrEol clears the current line, starting from the cursor position, to the
-end of the window. The cursor doesn't move}
-{None.}{\seep{DelLine}, \seep{InsLine}, \seep{ClrScr}}
-
-\input{crtex/ex9.tex}
-
-
-\Procedure {DelLine}
-{ DelLine removes the current line. Lines following the current line are 
-scrolled 1 line up, and an empty line is inserted at the bottom of the
-current window. The cursor doesn't move.}
-{None.}{\seep{ClrEol}, \seep{InsLine}, \seep{ClrScr}}
-
-\input{crtex/ex11.tex}
-
-
-\procedure {InsLine}{}
-{ InsLine inserts an empty line at the current cursor position. 
-Lines following the current line are scrolled 1 line down, 
-causing the last line to disappear from the window. 
-The cursor doesn't move.}
-{None.}{\seep{ClrEol}, \seep{DelLine}, \seep{ClrScr}}
-
-\input{crtex/ex10.tex}
-
-
-\Function {KeyPressed}{Boolean}
-{ The Keypressed function scans the keyboard buffer and sees if a key has
-been pressed. If this is the case, \var{True} is returned. If not,
-\var{False} is returned. The \var{Shift, Alt, Ctrl} are not reported.
-The key is not removed from the buffer, and can hence still be read after
-the KeyPressed function has been called.
-}
-{None.}{\seef{ReadKey}}
-
-\input{crtex/ex2.tex}
-
-
-\Function  {ReadKey}{Char}
-{
-The ReadKey function reads 1 key from the keyboard buffer, and returns this.
-If an extended or function key has been pressed, then the zero ASCII code is 
-returned. You can then read the scan code of the key with a second ReadKey
-call.
-
-\textbf{Remark.} Key mappings under Linux can cause the wrong key to be
-reported by ReadKey, so caution is needed when using ReadKey.  
-}
-{None.}{\seef{KeyPressed}}
-
-\input{crtex/ex3.tex}
-
-
-\procedure{Sound}{(hz : word)}
-{ Sounds the speaker at a frequency of \var{hz}.
-
-This is not supported in \linux}{None.}{\seep{NoSound}}
-\Procedure{NoSound}{
-Stops the speaker sound.
-
-This is not supported in \linux}{None.}{\seep{Sound}}
-
-\input{crtex/ex16.tex}
-

+ 32 - 30
docs/getopts.tex

@@ -70,35 +70,6 @@ messages.\\
 \var{OptOpt:Char} \  In case of an error, contains the character causing the 
 error.
 \section {Procedures and functions}
-\function {Getopt}{(Shortopts : String)}{Char}
-{
-Returns the next option found on the command-line. If no more options are
-found, returns \var{EndOfOptions}. If the option requires an argument, it is
-returned in the \var{OptArg} variable.
-
-\var{ShortOptions} is a string containing all possible one-letter options.
-If a letter is followed by a colon (:), then that option needs an argument.
-If a letter is followed by 2 colons, the option has an optional argument.
-
-If the first character of \var{shortoptions} is a \var{'+'} then options following a non-option are
-regarded as non-options (standard Unix behavior). If it is a \var{'-'},
-then all non-options are treated as arguments of a option with character
-\var{\#0}. This is useful for applications that require their options in
-the exact order as they appear on the command-line.
-
-If the first character of \var{shortoptions} is none of the above, options
-and non-options are permuted, so all non-options are behind all options.
-This allows options and non-options to be in random order on the command
-line.
-}
-{ 
-Errors are reported through giving back a \var{'?'} character. \var{OptOpt}
-then gives the character which caused the error. If \var{OptErr} is
-\var{True} then getopt prints an error-message to \var{stdout}.
-}
-{\seef{GetLongOpts}, \seem{getopt}{3}}
-
-\input{optex/optex.tex}
 
 \function {GetLongOpts}{(Shortopts : String, LongOpts : POption; var Longint
 : Integer )}{Char}
@@ -132,4 +103,35 @@ Optional arguments can only be specified through the first method.
 }
 { see \seef{Getopt}, \seem{getopt}{3}}
 
-For an example, see \seef{Getopt}
+For an example, see \seef{Getopt}
+
+\function {Getopt}{(Shortopts : String)}{Char}
+{
+Returns the next option found on the command-line. If no more options are
+found, returns \var{EndOfOptions}. If the option requires an argument, it is
+returned in the \var{OptArg} variable.
+
+\var{ShortOptions} is a string containing all possible one-letter options.
+If a letter is followed by a colon (:), then that option needs an argument.
+If a letter is followed by 2 colons, the option has an optional argument.
+
+If the first character of \var{shortoptions} is a \var{'+'} then options following a non-option are
+regarded as non-options (standard Unix behavior). If it is a \var{'-'},
+then all non-options are treated as arguments of a option with character
+\var{\#0}. This is useful for applications that require their options in
+the exact order as they appear on the command-line.
+
+If the first character of \var{shortoptions} is none of the above, options
+and non-options are permuted, so all non-options are behind all options.
+This allows options and non-options to be in random order on the command
+line.
+}
+{ 
+Errors are reported through giving back a \var{'?'} character. \var{OptOpt}
+then gives the character which caused the error. If \var{OptErr} is
+\var{True} then getopt prints an error-message to \var{stdout}.
+}
+{\seef{GetLongOpts}, \seem{getopt}{3}}
+
+\input{optex/optex.tex}
+

+ 223 - 217
docs/go32.tex

@@ -240,109 +240,6 @@ Selector to the \dos memory. The whole \dos memory is mapped to a
 single segment. This function will only work in DPMI mode.
 
 \section{Functions and Procedures}
-\procedure {Disable}{}{
-Clears the interrupt flag with CLD and disables the interrupts.
-}
-{None.}{\seep{Enable}}
-\par {\bf NOTE: }This
-function works only in DPMI mode\par 
-
-\procedure{Enable}{}{
-Sets the interrupt flag with STI and allows the processor to handle
-interrupts.
-}{None.}{\seep{Disable}}
-
-\procedurel{get\_meminfo}{GetMeminfo}{(var meminfo : tmeminfo)}{
-Returns the current state of memory allocation of the \dos extender.
-
-\textbf{NOTE: }This procedure has nothing to do with the Pascal function 
-\var{maxavail} and \var{memavail}.}{None.} 
-{\htmlref{tmeminfo}{ty:tmeminfo}} 
-
-\procedurel{get\_pm\_interrupt}{GetPmInterrupt}{(vector : byte;var intaddr : tseginfo)}
-{
-Returns the address of the current protected mode handler for the interrupt
-\var{vector}.}{None.}
-{\seep{SetPmInterrupt},\htmlref{tseginfo}{ty:tseginfo}}
-
-\functionl{get\_run\_mode}{GetRunMode}{}{word}{
-This function returns the mode which the extender is currently running. 
-The function is mostly used to determine if DPMI is supported. 
-
-
-}{None.}
-{\htmlref{rm}{co:rmmode}}
-Example :
-\begin{verbatim}
-uses
-   go32;
-
-begin
-   if get_run_mode=rm_dpmi then
-     writeln('DPMI available')
-   else
-     writeln('No DPMI available');
-end.
-\end{verbatim}
-
-\functionl{get\_cs}{GetCs}{}{word}{Returns the value of the CS
-register.}{None.}{\seef{GetDs},\seef{GetSs}}
-
-\functionl{get\_ds}{GetDs}{}{word}{Returns the value of the DS
-register.}{None.}{\seef{GetCs},\seef{GetSs}}
-
-\functionl{get\_ss}{GetSs}{word}{Returns the value of the SS
-register.}{None.}{\seef{GetDs},\seef{GetCs}}
-
-\function{inportb}{(port : word)}{byte}{Reads a byte from the given I/O
-port.}{None.}{\seep{outportb},\seef{inportw},\seef{inportl}}
-
-\function{inportw}{(port : word)}{word}{Reads a word from the given I/O
-port.}{None.}{\seep{outportw},\seef{inportb},\seef{inportl}}
-
-\function{inportl}{(port : word)}{longint}{Reads a longint from the given I/O
-port.}{None.}{\seep{outportl},\seef{inportw},\seef{inportb}}
-
-\procedure{outportb}{(port : word;data : byte)}{Writes a byte to the
-specified port.}{None.}{\seef{inportb},\seep{outportw},\seep{outportl}}
-
-\procedure{outportw}{(port : word;data : word)}{Writes a word to the
-specified port.}{None.}{\seef{inportw},\seep{outportb},\seep{outportl}}
-
-\procedure{outportl}{(port : word;data : longint)}{Writes a longint to the
-specified port.}{None.}{\seef{inportl},\seep{outportb},\seep{outportw}}
-
-\procedure{realintr}{(intnr : word;var regs : trealregs)}{
-\textbf {NOTE: }This procedure works only in DPMI mode.} 
-{None.}{}
-
-\procedurel{seg\_fillchar}{SegFillChar}{(seg : word;ofs : longint;count : longint;c :
-char)}
-{Fills a memory area specified by a 48 bit pointer with the given number
-of chars.
-
-\textbf {NOTE:} Be careful using this function in non-DPMI mode. 
-}{None.}{\seep{SegFillWord}, \seep{SegMove}}
-
-\procedurel {seg\_fillword}{SegFillWord}{(seg : word;ofs : longint;count : longint;w :
-word)}{Fills a memory area specified by a 48 bit pointer with the given number
-of words.
-
-\textbf {NOTE:} Be careful using this function in non-DPMI mode. 
-}{None.}{\seep{SegFillChar}, \seep{SegMove}}
-
-\procedurel{seg\_move}{SegMove}{(sseg : word;source : longint;dseg : word;dest : longint;count :
-longint)}
-{This procedure copies data when the source and destination are specified
-by 48 bit pointers. For example, this function is used by the DPMI version
-of \var{dosmemget} and \var{dosmemput}. }{The procedure checks only
-for overlapping if source selector equals the destination selector. 
-Be also careful using this function in non-DPMI
-mode.}{\seep{SegFillWord},\seep{SegFillChar}}
-
-\procedurel{set\_pm\_interrupt}{SetPmInterrupt}{(vector : byte;const intaddr : tseginfo)}
-{Sets a new protected mode handler for the interrupt \var{vector}.}
-{None.}{\seep{GetPmInterrupt}, \htmlref{tseginfo}{ty:tseginfo}} 
 
 \functionl{Allocate\_Ldt\_Descriptors}{AllocateLdtDescriptors}{(Count :
 word)}{word}
@@ -408,6 +305,52 @@ end.
 \end{verbatim}
 \end{FPCList}
 
+\functionl{Create\_Code\_Segment\_Alias\_Descriptor}
+{CreateCodeSegmentAliasDescriptor}{(Des : Word)}{Word}
+{\var{Create\_Code\_Segment\_Alias\_Descriptor}
+Creates a new descriptor that has the same base and limit as the
+specified descriptor.  In effect, the function returns a copy of the
+descriptor.
+
+{\em Notes:}
+\begin{itemize}
+\item Only works under real DPMI.
+\item The descriptor alias returned by this function will not track changes
+to the original descriptor. In other words, if an alias is created with
+this function, and the base or limit of the original segment is then
+changed, the two descriptors will no longer map the same memory.
+\end{itemize}
+}
+{None.}
+{}
+\begin{FPCList}
+\item[Example]
+\begin{verbatim}
+uses go32;
+
+var copysel : word;
+
+begin
+     copysel := create_code_segment_alias_descriptor(get_ds);
+     {...}
+     free_ldt_descriptor(copysel);
+end.
+\end{verbatim}
+\end{FPCList}
+
+
+\procedure {Disable}{}{
+Clears the interrupt flag with CLD and disables the interrupts.
+}
+{None.}{\seep{Enable}}
+\par {\bf NOTE: }This
+function works only in DPMI mode\par 
+
+\procedure{Enable}{}{
+Sets the interrupt flag with STI and allows the processor to handle
+interrupts.
+}{None.}{\seep{Disable}}
+
 \procedurel{Free\_Ldt\_Descriptor}{FreeLdtDescriptor}{(Sel : word)}
 {
 \var{Free\_Ldt\_Descriptor} frees a previously allocated selector
@@ -429,50 +372,36 @@ a part of a contiguous array of descriptors.
 
 For an example, see \seef{AllocateLdtDescriptors}.
 
-\functionl{Segment\_To\_Descriptor}{SegmentToDescriptor}{(Seg : Word)}{Word}
-{\var{Segment\_To\_Descriptor} Maps a real mode segment (paragraph) address 
-(in \var{Seg}) onto an descriptor that can be used by a protected mode 
-program to access  the same memory.
 
-The function returns a selector to the DOS real-mode segment.
+\functionl{get\_cs}{GetCs}{}{word}{Returns the value of the CS
+register.}{None.}{\seef{GetDs},\seef{GetSs}}
+
+\functionl{Get\_Descriptor\_Access\_right}{GetDescriptorAccesRight}{(Des: word)}{Longint}
+{\var{Get\_Descriptor\_Access\_right} gets the access rights of a
+descriptor \var{Des}.}
+{None.}{seef{SetDescriptorAccesRight}}
+
+\functionl{get\_ds}{GetDs}{}{word}{Returns the value of the DS
+register.}{None.}{\seef{GetCs},\seef{GetSs}}
+
+\functionl{Get\_Linear\_Addr}{GetLinearAddr}{(PhysAddr : longint;Size : longint)}{longint}
+{\var{Get\_Linear\_Addr} converts a physical address \var{PhysAddr} into 
+a linear address.
 
 {\em Notes:}
 \begin{itemize}
-\item Only works with real DPMI.
-\item The descriptors limit will be set to 64KB.
-\item multiple calls to this function with the same segment address will
-  return the same selector.
-\item Descriptors created by this function can never be modified or freed.
-For this reason this function shouldn't be used too often. Programs
-which need to examine various real mode addresses using the same
-selector should use the function \var{allocate\_ldt\_descriptors} and change
-the base address as necessary.
+\item Only works under real DPMI.
 \end{itemize}
-}
-{None.}
-{}
-\begin{FPCList}
-\item[Example]
-\begin{verbatim}
-uses go32;
+}{None.}{}
 
-var r : trealregs;
-    VGAsel : word;
+For an example, see \seef{AllocateLdtDescriptors}.
 
-begin
-     r.realeax := $13; realintr($10, r); 
-     { set VGA mode 13h }
-     VGASel := segment_to_descriptor($A000);
-     {...}
-     seg_fillchar(VGAsel, 100*320+6, 1, #15); 
-     { put a pixel at (6/100) in color 15 }
-     readln;
-     {...} 
-     r.realeax := $3; realintr($10, r);
-end.
-\end{verbatim}
-\end{FPCList}
+\procedurel{get\_meminfo}{GetMeminfo}{(var meminfo : tmeminfo)}{
+Returns the current state of memory allocation of the \dos extender.
 
+\textbf{NOTE: }This procedure has nothing to do with the Pascal function 
+\var{maxavail} and \var{memavail}.}{None.} 
+{\htmlref{tmeminfo}{ty:tmeminfo}} 
 
 \Functionl{Get\_Next\_Selector\_Increment\_Value}
 {GetNextSelectorIncrementValue}{word}
@@ -493,107 +422,62 @@ for subsequent descriptors in the array.
 {None.}
 {\seef{AllocateLdtDescriptors}}
 
-\functionl{Get\_Segment\_Base\_Address}{GetSegmentBaseAddress}{(Sel: word)}{Longint}
+
+\procedurel{get\_pm\_interrupt}{GetPmInterrupt}{(vector : byte;var intaddr : tseginfo)}
 {
-\var{Get\_Segment\_Base\_Address} returns the 32-bit linear base address 
-from the LDT descriptor for the specified segment (\var{Sel}).
+Returns the address of the current protected mode handler for the interrupt
+\var{vector}.}{None.}
+{\seep{SetPmInterrupt},\htmlref{tseginfo}{ty:tseginfo}}
 
 
-{\em Notes:}
-\begin{itemize}
-\item Only works under real DPMI.
-\end{itemize}
-}
-{None.}
-{\seep{SetSegmentBaseAddress}}
 
-\begin{FPCList}
-\item[Example:]
+\functionl{get\_run\_mode}{GetRunMode}{}{word}{
+This function returns the mode which the extender is currently running. 
+The function is mostly used to determine if DPMI is supported. 
+
+
+}{None.}
+{\htmlref{rm}{co:rmmode}}
+Example :
 \begin{verbatim}
-uses go32;
+uses
+   go32;
 
 begin
-     Writeln(get_segment_base_address(get_ds));
+   if get_run_mode=rm_dpmi then
+     writeln('DPMI available')
+   else
+     writeln('No DPMI available');
 end.
 \end{verbatim}
-\end{FPCList}
 
-\procedurel{Set\_Segment\_Base\_Address}{SetSegmentBaseAddress}
-{(var Des : word;Sel : longint)}
-{\var{{Set\_Segment\_Base\_Address}} sets the 32-bit linear base address 
-of the descriptor \var{Des} for the specified selector \var{Sel}.
-
-{\em Notes:}
-\begin{itemize}
-\item only works under real DPMI
-\end{itemize}
-}
-{None.}
-{ \seef{AllocateLdtDescriptors}, \seep{SetSegmentLimit}}
-
-For an example, see \seef{AllocateLdtDescriptors}.
-
-\procedurel{Set\_Segment\_Limit}{SetSegmentLimit}{(Des : word;Len : longint)}
-{\var{Set\_Segment\_Limit} sets the limit of the descriptor \var{Des} 
-to the specified length \var{Len}
-
-{\em Notes:}
-\begin{itemize}
-\item Only works under real DPMI.
-\item The new limit is the byte length of the segment-1.
-\item Segment limits bigger than or equal to 1MB must be page aligned, they
-must have the lower 12 bits set.
-\end{itemize}
-}
-{None}
-{ \seep{SetSegmentBaseAddress}, \seef{AllocateLdtDescriptors}}
-
-For an example, see \seef{AllocateLdtDescriptors}.
+\functionl{Get\_Segment\_Base\_Address}{GetSegmentBaseAddress}{(Sel: word)}{Longint}
+{
+\var{Get\_Segment\_Base\_Address} returns the 32-bit linear base address 
+from the LDT descriptor for the specified segment (\var{Sel}).
 
-\functionl{Create\_Code\_Segment\_Alias\_Descriptor}
-{CreateCodeSegmentAliasDescriptor}{(Des : Word)}{Word}
-{\var{Create\_Code\_Segment\_Alias\_Descriptor}
-Creates a new descriptor that has the same base and limit as the
-specified descriptor.  In effect, the function returns a copy of the
-descriptor.
 
 {\em Notes:}
 \begin{itemize}
 \item Only works under real DPMI.
-\item The descriptor alias returned by this function will not track changes
-to the original descriptor. In other words, if an alias is created with
-this function, and the base or limit of the original segment is then
-changed, the two descriptors will no longer map the same memory.
 \end{itemize}
 }
 {None.}
-{}
+{\seep{SetSegmentBaseAddress}}
+
 \begin{FPCList}
-\item[Example]
+\item[Example:]
 \begin{verbatim}
 uses go32;
 
-var copysel : word;
-
 begin
-     copysel := create_code_segment_alias_descriptor(get_ds);
-     {...}
-     free_ldt_descriptor(copysel);
+     Writeln(get_segment_base_address(get_ds));
 end.
 \end{verbatim}
 \end{FPCList}
 
-\functionl{Get\_Linear\_Addr}{GetLinearAddr}{(PhysAddr : longint;Size : longint)}{longint}
-{\var{Get\_Linear\_Addr} converts a physical address \var{PhysAddr} into 
-a linear address.
-
-{\em Notes:}
-\begin{itemize}
-\item Only works under real DPMI.
-\end{itemize}
-}{None.}{}
-
-For an example, see \seef{AllocateLdtDescriptors}.
+\functionl{get\_ss}{GetSs}{word}{Returns the value of the SS
+register.}{None.}{\seef{GetDs},\seef{GetCs}}
 
 \functionl{Global\_Dos\_Alloc}{GlobalDosAlloc}{(Len : longint)}{longint}
 {\var{Global\_Dos\_Alloc}
@@ -668,12 +552,134 @@ block, described by selector \var{Sel}.
 
 For an example, see \seef{GlobalDosAlloc}.
 
+\function{inportb}{(port : word)}{byte}{Reads a byte from the given I/O
+port.}{None.}{\seep{outportb},\seef{inportw},\seef{inportl}}
+
+\function{inportl}{(port : word)}{longint}{Reads a longint from the given I/O
+port.}{None.}{\seep{outportl},\seef{inportw},\seef{inportb}}
+
+\function{inportw}{(port : word)}{word}{Reads a word from the given I/O
+port.}{None.}{\seep{outportw},\seef{inportb},\seef{inportl}}
+
+\procedure{outportb}{(port : word;data : byte)}{Writes a byte to the
+specified port.}{None.}{\seef{inportb},\seep{outportw},\seep{outportl}}
+
+\procedure{outportl}{(port : word;data : longint)}{Writes a longint to the
+specified port.}{None.}{\seef{inportl},\seep{outportb},\seep{outportw}}
+
+\procedure{outportw}{(port : word;data : word)}{Writes a word to the
+specified port.}{None.}{\seef{inportw},\seep{outportb},\seep{outportl}}
+
+\procedure{realintr}{(intnr : word;var regs : trealregs)}{
+\textbf {NOTE: }This procedure works only in DPMI mode.} 
+{None.}{}
+
+\procedurel{seg\_fillchar}{SegFillChar}{(seg : word;ofs : longint;count : longint;c :
+char)}
+{Fills a memory area specified by a 48 bit pointer with the given number
+of chars.
+
+\textbf {NOTE:} Be careful using this function in non-DPMI mode. 
+}{None.}{\seep{SegFillWord}, \seep{SegMove}}
+
+\procedurel {seg\_fillword}{SegFillWord}{(seg : word;ofs : longint;count : longint;w :
+word)}{Fills a memory area specified by a 48 bit pointer with the given number
+of words.
+
+\textbf {NOTE:} Be careful using this function in non-DPMI mode. 
+}{None.}{\seep{SegFillChar}, \seep{SegMove}}
+
+\functionl{Segment\_To\_Descriptor}{SegmentToDescriptor}{(Seg : Word)}{Word}
+{\var{Segment\_To\_Descriptor} Maps a real mode segment (paragraph) address 
+(in \var{Seg}) onto an descriptor that can be used by a protected mode 
+program to access  the same memory.
+
+The function returns a selector to the DOS real-mode segment.
+
+{\em Notes:}
+\begin{itemize}
+\item Only works with real DPMI.
+\item The descriptors limit will be set to 64KB.
+\item multiple calls to this function with the same segment address will
+  return the same selector.
+\item Descriptors created by this function can never be modified or freed.
+For this reason this function shouldn't be used too often. Programs
+which need to examine various real mode addresses using the same
+selector should use the function \var{allocate\_ldt\_descriptors} and change
+the base address as necessary.
+\end{itemize}
+}
+{None.}
+{}
+\begin{FPCList}
+\item[Example]
+\begin{verbatim}
+uses go32;
+
+var r : trealregs;
+    VGAsel : word;
+
+begin
+     r.realeax := $13; realintr($10, r); 
+     { set VGA mode 13h }
+     VGASel := segment_to_descriptor($A000);
+     {...}
+     seg_fillchar(VGAsel, 100*320+6, 1, #15); 
+     { put a pixel at (6/100) in color 15 }
+     readln;
+     {...} 
+     r.realeax := $3; realintr($10, r);
+end.
+\end{verbatim}
+\end{FPCList}
+
+\procedurel{seg\_move}{SegMove}{(sseg : word;source : longint;dseg : word;dest : longint;count :
+longint)}
+{This procedure copies data when the source and destination are specified
+by 48 bit pointers. For example, this function is used by the DPMI version
+of \var{dosmemget} and \var{dosmemput}. }{The procedure checks only
+for overlapping if source selector equals the destination selector. 
+Be also careful using this function in non-DPMI
+mode.}{\seep{SegFillWord},\seep{SegFillChar}}
+
 \functionl{Set\_Descriptor\_Access\_right}{SetDescriptorAccesRight}{(Des: word; W: word)}{Longint}
 {\var{Set\_Descriptor\_Access\_right} sets the access rights of a
 descriptor \var{Des}.}
 {None.}{seef{GetDescriptorAccesRight}}
 
-\functionl{Get\_Descriptor\_Access\_right}{GetDescriptorAccesRight}{(Des: word)}{Longint}
-{\var{Get\_Descriptor\_Access\_right} gets the access rights of a
-descriptor \var{Des}.}
-{None.}{seef{SetDescriptorAccesRight}}
+\procedurel{set\_pm\_interrupt}{SetPmInterrupt}{(vector : byte;const intaddr : tseginfo)}
+{Sets a new protected mode handler for the interrupt \var{vector}.}
+{None.}{\seep{GetPmInterrupt}, \htmlref{tseginfo}{ty:tseginfo}} 
+
+\procedurel{Set\_Segment\_Base\_Address}{SetSegmentBaseAddress}
+{(var Des : word;Sel : longint)}
+{\var{{Set\_Segment\_Base\_Address}} sets the 32-bit linear base address 
+of the descriptor \var{Des} for the specified selector \var{Sel}.
+
+{\em Notes:}
+\begin{itemize}
+\item only works under real DPMI
+\end{itemize}
+}
+{None.}
+{ \seef{AllocateLdtDescriptors}, \seep{SetSegmentLimit}}
+
+For an example, see \seef{AllocateLdtDescriptors}.
+
+\procedurel{Set\_Segment\_Limit}{SetSegmentLimit}{(Des : word;Len : longint)}
+{\var{Set\_Segment\_Limit} sets the limit of the descriptor \var{Des} 
+to the specified length \var{Len}
+
+{\em Notes:}
+\begin{itemize}
+\item Only works under real DPMI.
+\item The new limit is the byte length of the segment-1.
+\item Segment limits bigger than or equal to 1MB must be page aligned, they
+must have the lower 12 bits set.
+\end{itemize}
+}
+{None}
+{ \seep{SetSegmentBaseAddress}, \seef{AllocateLdtDescriptors}}
+
+For an example, see \seef{AllocateLdtDescriptors}.
+

+ 208 - 177
docs/sockets.tex

@@ -99,129 +99,6 @@ TSockArray = Array[1..2] of Longint;
 
 \section {Functions and Procedures}
 
-\function{Socket}{(Domain,SocketType,Protocol:Longint)}{Longint}
-{\var{Socket} creates a new socket in domain \var{Domain}, from type
-\var{SocketType} using protocol \var{Protocol}.
-
-The Domain, Socket type and Protocol can be specified using predefined
-constants (see the section on constants for available constants)
-
-If succesfull, the function returns a socket descriptor, which can be passed
-to a subsequent \seef{Bind} call. If unsuccesfull, the function returns -1.
-}
-{Errors are returned in \var{SocketError}, and include the follwing:
-\begin{description}
-\item[SYS\_EPROTONOSUPPORT]
-The protocol type or the specified protocol is not
-supported within this domain.
-\item[SYS\_EMFILE]
-The per-process descriptor table is full.
-\item[SYS\_ENFILE]
-The system file table is full.
-\item[SYS\_EACCESS]
- Permission  to  create  a  socket of the specified
- type and/or protocol is denied.
-\item[SYS\_ENOBUFS]
- Insufficient  buffer  space  is  available.    The
- socket   cannot   be   created   until  sufficient
- resources are freed.
-\end{description}}
-{\seef{SocketPair}, \seem{socket}{2}}
-for an example, see \seef{Accept}.
-\function{Send}{(Sock:Longint;Var Addr;AddrLen,Flags:Longint)}{Longint}
-{\var{Send} sends \var{AddrLen} bytes starting from address \var{Addr}
-to socket \var{Sock}. \var{Sock} must be in a connected state.
-
-The function returns the number of bytes sent, or -1 if a detectable 
-error occurred.
-
-\var{Flags} can be one of the following:
-\begin{description}
-\item [1] : Process out-of band data.
-\item [4] : Bypass routing, use a direct interface.
-\end{description}
-}
-{Errors are reported in \var{SocketError}, and include the following:
-\begin{description}
-\item[SYS\_EBADF] The socket descriptor is invalid.
-\item[SYS\_ENOTSOCK] The descriptor is not a socket.
-\item[SYS\_EFAULT] The address is outside your address space.
-\item[SYS\_EMSGSIZE] The message cannot be sent atomically.
-\item[SYS\_EWOULDBLOCK] The requested operation would block the process.
-\item[SYS\_ENOBUFS] The system doesn't have enough free buffers available.
-\end{description}
-}{\seef{Recv}, \seem{send}{2}}
-
-\function{Recv}{(Sock:Longint;Var Addr;AddrLen,Flags:Longint)}{Longint}
-{\var{Recv} reads at most \var{Addrlen} bytes from socket \var{Sock} into
-address \var{Addr}. The socket must be in a connected state.
-
-\var{Flags} can be one of the following:
-\begin{description}
-\item [1] : Process out-of band data.
-\item [4] : Bypass routing, use a direct interface.
-\item [??] : Wait for full request or report an error.
-\end{description}
-
-The functions returns the number of bytes actually read from the socket, or
--1 if a detectable error occurred.}
-{Errors are reported in \var{SocketError}, and include the following:
-\begin{description}
-\item[SYS\_EBADF] The socket descriptor is invalid.
-\item[SYS\_ENOTCONN] The socket isn't connected.
-\item[SYS\_ENOTSOCK] The descriptor is not a socket.
-\item[SYS\_EFAULT] The address is outside your address space.
-\item[SYS\_EMSGSIZE] The message cannot be sent atomically.
-\item[SYS\_EWOULDBLOCK] The requested operation would block the process.
-\item[SYS\_ENOBUFS] The system doesn't have enough free buffers available.
-\end{description}
-}{\seef{Send}}
-
-\function{Bind}{(Sock:Longint;Var Addr;AddrLen:Longint)}{Boolean}
-{\var{Bind} binds the socket \var{Sock} to address \var{Addr}. \var{Addr}
-has length \var{Addrlen}.
-
-The function returns \var{True} if the call was succesful, \var{False} if
-not.
-}
-{Errors are returned in \var{SocketError} and include the following:
-\begin{description}
-\item[SYS\_EBADF] The socket descriptor is invalid.
-\item[SYS\_EINVAL] The socket is already bound to an address,
-\item[SYS\_EACCESS] Address is protected and you don't have permission to
-open it.
-\end{description}
-More arrors can be found in the Unix man pages.
-}{\seef{Socket}}
-
-\functionl{Bind}{AltBind}{(Sock:longint;const addr:string)}{boolean}
-{This is an alternate form of the \var{Bind} command.
-This form of the \var{Bind} command is equivalent to subsequently 
-calling \seep{Str2UnixSockAddr} and the regular \seef{Bind} function.
-
-The function returns \var{True} if successfull, \var{False} otherwise.
-}
-{Errors are those of the regular \seef{Bind} command.}
-{\seef{Bind}}
-
-
-\function{Listen}{(Sock,MaxConnect:Longint)}{Boolean}
-{\var{Listen} listens for up to \var{MaxConnect} connections from socket
-\var{Sock}. The socket \var{Sock} must be of type \var{SOCK\_STREAM} or
-\var{Sock\_SEQPACKET}.
-
-The function returns \var{True} if a connection was accepted, \var{False} 
-if an error occurred.
-}
-{Errors are reported in \var{SocketError}, and include the following:
-\begin{description}
-\item[SYS\_EBADF] The socket descriptor is invalid.
-\item[SYS\_ENOTSOCK] The descriptor is not a socket.
-\item[SYS\_EOPNOTSUPP] The socket type doesn't support the \var{Listen}
-operation.
-\end{description}
-}{\seef{Socket}, \seef{Bind}, \seef{Connect}}
-
 \function{Accept}{(Sock:Longint;Var Addr;Var Addrlen:Longint)}{Longint}
 {\var{Accept} accepts a connection from a socket \var{Sock}, which was
 listening for a connection. The accepted socket may NOT be used to accept
@@ -261,6 +138,8 @@ The function returns \var{True} if successfull, \var{False} otherwise.
 It is equivalent
 to subsequently calling the regular \seef{Accept} function and the 
 \seep{Sock2File} function.
+The \var{Addr} parameter contains the name of the unix socket file to be
+opened. 
 
 The function returns \var{True} if successfull, \var{False} otherwise.
 }
@@ -268,6 +147,46 @@ The function returns \var{True} if successfull, \var{False} otherwise.
 {\seef{Accept}}
 
 
+\functionl{Accept}{AltCAccept}{(Sock:longint;var addr:TInetSockAddr;var SockIn,SockOut:File)}{Boolean}
+{ This is an alternate form of the \seef{Accept} command. 
+It is equivalent
+to subsequently calling the regular \seef{Accept} function and the 
+\seep{Sock2File} function.
+The \var{Addr} parameter contains the parameters of the internet socket that
+should be opened.
+
+The function returns \var{True} if successfull, \var{False} otherwise.
+}
+{The errors are those of \seef{Accept}.}
+{\seef{Accept}}
+
+\function{Bind}{(Sock:Longint;Var Addr;AddrLen:Longint)}{Boolean}
+{\var{Bind} binds the socket \var{Sock} to address \var{Addr}. \var{Addr}
+has length \var{Addrlen}.
+
+The function returns \var{True} if the call was succesful, \var{False} if
+not.
+}
+{Errors are returned in \var{SocketError} and include the following:
+\begin{description}
+\item[SYS\_EBADF] The socket descriptor is invalid.
+\item[SYS\_EINVAL] The socket is already bound to an address,
+\item[SYS\_EACCESS] Address is protected and you don't have permission to
+open it.
+\end{description}
+More arrors can be found in the Unix man pages.
+}{\seef{Socket}}
+
+\functionl{Bind}{AltBind}{(Sock:longint;const addr:string)}{boolean}
+{This is an alternate form of the \var{Bind} command.
+This form of the \var{Bind} command is equivalent to subsequently 
+calling \seep{Str2UnixSockAddr} and the regular \seef{Bind} function.
+
+The function returns \var{True} if successfull, \var{False} otherwise.
+}
+{Errors are those of the regular \seef{Bind} command.}
+{\seef{Bind}}
+
 \function{Connect}{(Sock:Longint;Var Addr;Addrlen:Longint)}{Boolean}
 {\var{Connect} opens a connection to a peer, whose address is described by
 var{Addr}. \var{AddrLen} contains the length of the address.
@@ -291,35 +210,48 @@ The function returns \var{True} if successfull, \var{False} otherwise.
 {\seef{Connect}}
 
 \functionl{Connect}{AltBConnect}{(Sock:longint;const addr:string;var SockIn,SockOut:file)}{Boolean}
-{ This is an alternate form of the \seef{Connect} command. 
+{ This is an alternate form of the \seef{Connect} command. The parameter
+\var{addr} contains the name of the unix socket file to be opened. 
+It is equivalent to subsequently calling the regular \seef{Connect} 
+function and the  \seep{Sock2File} function.
+
+The function returns \var{True} if successfull, \var{False} otherwise.
+}{The errors are those of \seef{Connect}.}
+{\seef{Connect}}
+
+
+\functionl{Connect}{AltCConnect}{(Sock:longint;const addr: TInetSockAddr;var SockIn,SockOut:file)}{Boolean}
+{ This is another alternate form of the \seef{Connect} command. 
 It is equivalent
 to subsequently calling the regular \seef{Connect} function and the 
-\seep{Sock2File} function.
+\seep{Sock2File} function. The \var{Addr} parameter contains the parameters
+of the internet socket to connect to.
 
 The function returns \var{True} if successfull, \var{False} otherwise.
 }{The errors are those of \seef{Connect}.}
 {\seef{Connect}}
 
+\input{sockex/pfinger.tex}
 
-\function{Shutdown}{(Sock:Longint;How:Longint)}{Longint}
-{\var{ShutDown} closes one end of a full duplex socket connection, described
-by \var{Sock}. \var{How} determines how the connection will be shut down,
-and can be one of the following:
-\begin{description}
-\item[0] : Further receives are disallowed.
-\item[1] : Further sends are disallowed.
-\item[2] : Sending nor receiving are allowed.
-\end{description}
-
-On succes, the function returns 0, on error -1 is returned.
+\function{GetPeerName}{(Sock:Longint;Var Addr;Var Addrlen:Longint)}{Longint}
+{\var{GetPeerName} returns the name of the entity connected to the 
+specified socket \var{Sock}. The Socket must be connected for this call to
+work. 
+\var{Addr} should point to enough space to store the name, the
+amount of space pointed to should be set in \var{Addrlen}. 
+When the function returns succesfully, \var{Addr} will be filled with the 
+name, and \var{Addrlen} will be set to the length of \var{Addr}.
 }
-{\var{SocketError} is used to report errors, and includes the following:
+{Errors are reported in \var{SocketError}, and include the following:
 \begin{description}
 \item[SYS\_EBADF] The socket descriptor is invalid.
-\item[SYS\_ENOTCONN] The socket isn't connected.
+\item[SYS\_ENOBUFS] The system doesn't have enough buffers to perform the
+operation.
 \item[SYS\_ENOTSOCK] The descriptor is not a socket.
+\item[SYS\_EFAULT] \var{Addr} points outside your address space.
+\item[SYS\_ENOTCONN] The socket isn't connected.
 \end{description}
-}{\seef{Socket}, \seef{Connect}}
+}{\seef{Connect}, \seef{Socket}, \seem{connect}{2}}
 
 \function{GetSocketName}{(Sock:Longint;Var Addr;Var Addrlen:Longint)}{Longint}
 {\var{GetSockName} returns the current name of the specified socket
@@ -337,25 +269,92 @@ operation.
 \end{description}
 }{\seef{Bind}}
 
-\function{GetPeerName}{(Sock:Longint;Var Addr;Var Addrlen:Longint)}{Longint}
-{\var{GetPeerName} returns the name of the entity connected to the 
-specified socket \var{Sock}. The Socket must be connected for this call to
-work. 
-\var{Addr} should point to enough space to store the name, the
-amount of space pointed to should be set in \var{Addrlen}. 
-When the function returns succesfully, \var{Addr} will be filled with the 
-name, and \var{Addrlen} will be set to the length of \var{Addr}.
+
+\function{GetSocketOptions}{(Sock,Level,OptName:Longint;Var OptVal;optlen:longint)}{Longint}
+{\var{GetSocketOptions} gets the connection options for socket \var{Sock}.
+The socket may be obtained from different levels, indicated by \var{Level},
+which can be one of the following:
+\begin{description}
+\item[SOL\_SOCKET] From the socket itself. 
+\item[XXX] set \var{Level} to \var{XXX}, the protocol number of the protocol
+which should interprete the option.
+ \end{description}
+For more information on this call, refer to the unix manual page \seem{getsockopt}{2}.
 }
 {Errors are reported in \var{SocketError}, and include the following:
 \begin{description}
 \item[SYS\_EBADF] The socket descriptor is invalid.
-\item[SYS\_ENOBUFS] The system doesn't have enough buffers to perform the
-operation.
 \item[SYS\_ENOTSOCK] The descriptor is not a socket.
-\item[SYS\_EFAULT] \var{Addr} points outside your address space.
+\item[SYS\_EFAULT] \var{OptVal} points outside your address space.
+\end{description}
+}
+{\seef{GetSocketOptions}}
+
+\function{Listen}{(Sock,MaxConnect:Longint)}{Boolean}
+{\var{Listen} listens for up to \var{MaxConnect} connections from socket
+\var{Sock}. The socket \var{Sock} must be of type \var{SOCK\_STREAM} or
+\var{Sock\_SEQPACKET}.
+
+The function returns \var{True} if a connection was accepted, \var{False} 
+if an error occurred.
+}
+{Errors are reported in \var{SocketError}, and include the following:
+\begin{description}
+\item[SYS\_EBADF] The socket descriptor is invalid.
+\item[SYS\_ENOTSOCK] The descriptor is not a socket.
+\item[SYS\_EOPNOTSUPP] The socket type doesn't support the \var{Listen}
+operation.
+\end{description}
+}{\seef{Socket}, \seef{Bind}, \seef{Connect}}
+
+\function{Recv}{(Sock:Longint;Var Addr;AddrLen,Flags:Longint)}{Longint}
+{\var{Recv} reads at most \var{Addrlen} bytes from socket \var{Sock} into
+address \var{Addr}. The socket must be in a connected state.
+
+\var{Flags} can be one of the following:
+\begin{description}
+\item [1] : Process out-of band data.
+\item [4] : Bypass routing, use a direct interface.
+\item [??] : Wait for full request or report an error.
+\end{description}
+
+The functions returns the number of bytes actually read from the socket, or
+-1 if a detectable error occurred.}
+{Errors are reported in \var{SocketError}, and include the following:
+\begin{description}
+\item[SYS\_EBADF] The socket descriptor is invalid.
 \item[SYS\_ENOTCONN] The socket isn't connected.
+\item[SYS\_ENOTSOCK] The descriptor is not a socket.
+\item[SYS\_EFAULT] The address is outside your address space.
+\item[SYS\_EMSGSIZE] The message cannot be sent atomically.
+\item[SYS\_EWOULDBLOCK] The requested operation would block the process.
+\item[SYS\_ENOBUFS] The system doesn't have enough free buffers available.
 \end{description}
-}{\seef{Connect}, \seef{Socket}, \seem{connect}{2}}
+}{\seef{Send}}
+
+\function{Send}{(Sock:Longint;Var Addr;AddrLen,Flags:Longint)}{Longint}
+{\var{Send} sends \var{AddrLen} bytes starting from address \var{Addr}
+to socket \var{Sock}. \var{Sock} must be in a connected state.
+
+The function returns the number of bytes sent, or -1 if a detectable 
+error occurred.
+
+\var{Flags} can be one of the following:
+\begin{description}
+\item [1] : Process out-of band data.
+\item [4] : Bypass routing, use a direct interface.
+\end{description}
+}
+{Errors are reported in \var{SocketError}, and include the following:
+\begin{description}
+\item[SYS\_EBADF] The socket descriptor is invalid.
+\item[SYS\_ENOTSOCK] The descriptor is not a socket.
+\item[SYS\_EFAULT] The address is outside your address space.
+\item[SYS\_EMSGSIZE] The message cannot be sent atomically.
+\item[SYS\_EWOULDBLOCK] The requested operation would block the process.
+\item[SYS\_ENOBUFS] The system doesn't have enough free buffers available.
+\end{description}
+}{\seef{Recv}, \seem{send}{2}}
 
 \function{SetSocketOptions}{(Sock,Level,OptName:Longint;Var OptVal;optlen:longint)}{Longint}
 {\var{SetSocketOptions} sets the connection options for socket \var{Sock}.
@@ -377,25 +376,71 @@ For more information on this call, refer to the unix manual page \seem{setsockop
 }
 {\seef{GetSocketOptions}}
 
-\function{GetSocketOptions}{(Sock,Level,OptName:Longint;Var OptVal;optlen:longint)}{Longint}
-{\var{GetSocketOptions} gets the connection options for socket \var{Sock}.
-The socket may be obtained from different levels, indicated by \var{Level},
-which can be one of the following:
+\function{Shutdown}{(Sock:Longint;How:Longint)}{Longint}
+{\var{ShutDown} closes one end of a full duplex socket connection, described
+by \var{Sock}. \var{How} determines how the connection will be shut down,
+and can be one of the following:
 \begin{description}
-\item[SOL\_SOCKET] From the socket itself. 
-\item[XXX] set \var{Level} to \var{XXX}, the protocol number of the protocol
-which should interprete the option.
- \end{description}
-For more information on this call, refer to the unix manual page \seem{getsockopt}{2}.
+\item[0] : Further receives are disallowed.
+\item[1] : Further sends are disallowed.
+\item[2] : Sending nor receiving are allowed.
+\end{description}
+
+On succes, the function returns 0, on error -1 is returned.
 }
-{Errors are reported in \var{SocketError}, and include the following:
+{\var{SocketError} is used to report errors, and includes the following:
 \begin{description}
 \item[SYS\_EBADF] The socket descriptor is invalid.
+\item[SYS\_ENOTCONN] The socket isn't connected.
 \item[SYS\_ENOTSOCK] The descriptor is not a socket.
-\item[SYS\_EFAULT] \var{OptVal} points outside your address space.
 \end{description}
+}{\seef{Socket}, \seef{Connect}}
+
+\procedure{Sock2File}{(Sock:Longint;Var SockIn,SockOut:File)}
+{\var{Sock2File} transforms a socket \var{Sock} into 2 Pascal file
+descriptors of type \var{File}, one for reading from the socket
+(\var{SockIn}), one for writing to the socket (\var{SockOut}).}
+{None.}
+{\seef{Socket}, \seep{Sock2Text}}
+
+\procedure{Sock2Text}{(Sock:Longint;Var SockIn,SockOut: Text)}
+{\var{Sock2Text} transforms a socket \var{Sock} into 2 Pascal file
+descriptors of type \var{Text}, one for reading from the socket
+(\var{SockIn}), one for writing to the socket (\var{SockOut}).}
+{None.}
+{\seef{Socket}, \seep{Sock2File}}
+
+
+
+\function{Socket}{(Domain,SocketType,Protocol:Longint)}{Longint}
+{\var{Socket} creates a new socket in domain \var{Domain}, from type
+\var{SocketType} using protocol \var{Protocol}.
+
+The Domain, Socket type and Protocol can be specified using predefined
+constants (see the section on constants for available constants)
+
+If succesfull, the function returns a socket descriptor, which can be passed
+to a subsequent \seef{Bind} call. If unsuccesfull, the function returns -1.
 }
-{\seef{GetSocketOptions}}
+{Errors are returned in \var{SocketError}, and include the follwing:
+\begin{description}
+\item[SYS\_EPROTONOSUPPORT]
+The protocol type or the specified protocol is not
+supported within this domain.
+\item[SYS\_EMFILE]
+The per-process descriptor table is full.
+\item[SYS\_ENFILE]
+The system file table is full.
+\item[SYS\_EACCESS]
+ Permission  to  create  a  socket of the specified
+ type and/or protocol is denied.
+\item[SYS\_ENOBUFS]
+ Insufficient  buffer  space  is  available.    The
+ socket   cannot   be   created   until  sufficient
+ resources are freed.
+\end{description}}
+{\seef{SocketPair}, \seem{socket}{2}}
+for an example, see \seef{Accept}.
 
 \function{SocketPair}{(Domain,SocketType,Protocol:Longint;var Pair:TSockArray)}{Longint}
 {\var{SocketPair} creates 2 sockets in domain \var{Domain}, from type
@@ -407,20 +452,6 @@ The function returns -1 upon error and 0 upon success.
 }
 {Errors are reported in \var{SocketError}, and are the same as in \seef{Socket}}
 
-\procedure{Sock2Text}{(Sock:Longint;Var SockIn,SockOut: Text)}
-{\var{Sock2Text} transforms a socket \var{Sock} into 2 Pascal file
-descriptors of type \var{Text}, one for reading from the socket
-(\var{SockIn}), one for writing to the socket (\var{SockOut}).}
-{None.}
-{\seef{Socket}, \seep{Sock2File}}
-
-\procedure{Sock2File}{(Sock:Longint;Var SockIn,SockOut:File)}
-{\var{Sock2File} transforms a socket \var{Sock} into 2 Pascal file
-descriptors of type \var{File}, one for reading from the socket
-(\var{SockIn}), one for writing to the socket (\var{SockOut}).}
-{None.}
-{\seef{Socket}, \seep{Sock2Text}}
-
 \procedure{Str2UnixSockAddr}{(const addr:string;var t:TUnixSockAddr;var len:longint)}
 {\var{Str2UnixSockAddr} transforms a Unix socket address in a string to a
 \var{TUnixSockAddr} sturcture which can be passed to the \seef{Bind} call.

+ 91 - 91
docs/strings.tex

@@ -28,32 +28,37 @@ with an explanation.
 
 \section{Functions and procedures.}
 
-\function{StrLen}{(p : PChar)}{Longint}
+\procedure{StrAlloc}{(Len : Longint)}{PChar}
 {
-Returns the length of the null-terminated string \var{P}.
+\var{StrAlloc} reserves memory on the heap for a string with length \var{Len},
+terminating \var{\#0} included, and returns a pointer to it.
 }
-{None.}{\seem{Length}{}}
 
-\input{stringex/ex1.tex}
+For an example, see \seef{StrPCopy}.
 
-\function{StrPCopy}{(Dest : PChar; Const Source : String)}{PChar}
+\function{StrCat}{(Dest,Source : PChar)}{PChar}
 {
-Converts the Pascal string in \var{Source} to a Null-terminated 
-string, and copies it to \var{Dest}. \var{Dest} needs enough room to contain
-the string \var{Source}, i.e. \var{Length(Source)+1} bytes.
+Attaches \var{Source} to \var{Dest} and returns \var{Dest}.
 }
-{No length checking is performed.}{ \seef{StrPas}}
+{No length checking is performed.}
+{\seem{Concat}{}}
 
-\input{stringex/ex2.tex}
+\input{stringex/ex11.tex}
 
-\function {StrPas}{(P : PChar)}{String}
+\function{StrComp}{(S1,S2 : PChar)}{Longint}
 {
-Converts a null terminated string in \var{P} to a Pascal string, and returns
-this string. The string is truncated at 255 characters.
+Compares the null-terminated strings \var{S1} and \var{S2}.
+
+The result is 
+\begin{itemize}
+\item A negative \var{Longint} when \var{S1<S2}.
+\item 0 when \var{S1=S2}.
+\item A positive \var{Longint} when \var{S1>S2}.
+\end{itemize}
 }
-{None.}{ \seef{StrPCopy}}
+{None.}{\seef{StrLComp}, \seef{StrIComp}, \seef{StrLIComp}}
 
-\input{stringex/ex3.tex}
+For an example, see \seef{StrLComp}.
 
 \function {StrCopy}{(Dest,Source : PChar)}{PChar}
 { 
@@ -65,15 +70,13 @@ returns a pointer to \var{Dest}. \var{Dest} needs enough room to contain
 
 \input{stringex/ex4.tex}
 
-\function{StrLCopy}{(Dest,Source : PChar; MaxLen : Longint)}{PChar}
+\procedure{StrDispose}{(P : PChar)}
 {
-Copies \var{MaxLen} characters from \var{Source} to \var{Dest}, and makes
-\var{Dest} a null terminated string. 
+Removes the string in \var{P} from the heap and releases the memory.
 }
-{No length checking is performed.}
-{\seef{StrCopy}, \seef{StrECopy}}
- 
-\input{stringex/ex5.tex}
+{None.}{\seem{Dispose}{}, \seef{StrNew}}
+
+\input{stringex/ex17.tex}
 
 \function{StrECopy}{(Dest,Source : PChar)}{PChar}
 {
@@ -95,18 +98,9 @@ null-character.
 
 \input{stringex/ex7.tex}
 
-\function{StrCat}{(Dest,Source : PChar)}{PChar}
-{
-Attaches \var{Source} to \var{Dest} and returns \var{Dest}.
-}
-{No length checking is performed.}
-{\seem{Concat}{}}
-
-\input{stringex/ex11.tex}
-
-\function{StrComp}{(S1,S2 : PChar)}{Longint}
+\function{StrIComp}{(S1,S2 : PChar)}{Longint}
 {
-Compares the null-terminated strings \var{S1} and \var{S2}.
+Compares the null-terminated strings \var{S1} and \var{S2}, ignoring case.
 
 The result is 
 \begin{itemize}
@@ -115,9 +109,18 @@ The result is
 \item A positive \var{Longint} when \var{S1>S2}.
 \end{itemize}
 }
-{None.}{\seef{StrLComp}, \seef{StrIComp}, \seef{StrLIComp}}
+{None.}{\seef{StrLComp}, \seef{StrComp}, \seef{StrLIComp}}
 
-For an example, see \seef{StrLComp}.
+\input{stringex/ex8.tex}
+
+\function{StrLCat}{(Dest,Source : PChar; MaxLen : Longint)}{PChar}
+{
+Adds \var{MaxLen} characters from \var{Source} to \var{Dest}, and adds a
+terminating null-character. Returns \var{Dest}.
+}
+{None.}{\seef{StrCat}}
+
+\input{stringex/ex12.tex}
 
 \function{StrLComp}{(S1,S2 : PChar; L : Longint)}{Longint}
 {
@@ -135,20 +138,23 @@ The result is
 
 \input{stringex/ex8.tex}
 
-\function{StrIComp}{(S1,S2 : PChar)}{Longint}
+\function{StrLCopy}{(Dest,Source : PChar; MaxLen : Longint)}{PChar}
 {
-Compares the null-terminated strings \var{S1} and \var{S2}, ignoring case.
+Copies \var{MaxLen} characters from \var{Source} to \var{Dest}, and makes
+\var{Dest} a null terminated string. 
+}
+{No length checking is performed.}
+{\seef{StrCopy}, \seef{StrECopy}}
+ 
+\input{stringex/ex5.tex}
 
-The result is 
-\begin{itemize}
-\item A negative \var{Longint} when \var{S1<S2}.
-\item 0 when \var{S1=S2}.
-\item A positive \var{Longint} when \var{S1>S2}.
-\end{itemize}
+\function{StrLen}{(p : PChar)}{Longint}
+{
+Returns the length of the null-terminated string \var{P}.
 }
-{None.}{\seef{StrLComp}, \seef{StrComp}, \seef{StrLIComp}}
+{None.}{\seem{Length}{}}
 
-\input{stringex/ex8.tex}
+\input{stringex/ex1.tex}
 
 \function{StrLIComp}{(S1,S2 : PChar; L : Longint)}{Longint}
 {
@@ -166,6 +172,14 @@ The result is
 
 For an example, see \seef{StrIComp}
 
+\function{StrLower}{(P : PChar)}{PChar}
+{
+Converts \var{P} to an all-lowercase string. Returns \var{P}.
+}
+{None.}{\seem{Upcase}{}, \seef{StrUpper}}
+
+\input{stringex/ex14.tex}
+
 \function{StrMove}{(Dest,Source : PChar; MaxLen : Longint)}{PChar}
 {
 Copies \var{MaxLen} characters from \var{Source} to \var{Dest}. No
@@ -176,50 +190,33 @@ Returns \var {Dest}.
 
 \input{stringex/ex10.tex}
 
-\function{StrLCat}{(Dest,Source : PChar; MaxLen : Longint)}{PChar}
-{
-Adds \var{MaxLen} characters from \var{Source} to \var{Dest}, and adds a
-terminating null-character. Returns \var{Dest}.
-}
-{None.}{\seef{StrCat}}
-
-\input{stringex/ex12.tex}
-
-\function{StrScan}{(P : PChar; C : Char)}{PChar}
-{
-Returns a pointer to the first occurrence of the character \var{C} in the
-null-terminated string \var{P}. If \var{C} does not occur, returns
-\var{Nil}.
-}
-{None.}{\seem{Pos}{}, \seef{StrRScan}, \seef{StrPos}}
-
-\input{stringex/ex13.tex}
-
-\function{StrRScan}{(P : PChar; C : Char)}{PChar}
+\function{StrNew}{(P : PChar)}{PChar}
 {
-Returns a pointer to the last occurrence of the character \var{C} in the
-null-terminated string \var{P}. If \var{C} does not occur, returns
-\var{Nil}.
+Copies \var{P} to the Heap, and returns a pointer to the copy.
 }
-{None.}{\seem{Pos}{}, \seef{StrScan}, \seef{StrPos}}
+{Returns \var{Nil} if no memory was available for the copy.}
+{\seem{New}{}, \seef{StrCopy}, \seep{StrDispose}}
 
-For an example, see \seef{StrScan}.
+\input{stringex/ex16.tex}
 
-\function{StrLower}{(P : PChar)}{PChar}
+\function {StrPas}{(P : PChar)}{String}
 {
-Converts \var{P} to an all-lowercase string. Returns \var{P}.
+Converts a null terminated string in \var{P} to a Pascal string, and returns
+this string. The string is truncated at 255 characters.
 }
-{None.}{\seem{Upcase}{}, \seef{StrUpper}}
+{None.}{ \seef{StrPCopy}}
 
-\input{stringex/ex14.tex}
+\input{stringex/ex3.tex}
 
-\function{StrUpper}{(P : PChar)}{PChar}
+\function{StrPCopy}{(Dest : PChar; Const Source : String)}{PChar}
 {
-Converts \var{P} to an all-uppercase string. Returns \var{P}.
+Converts the Pascal string in \var{Source} to a Null-terminated 
+string, and copies it to \var{Dest}. \var{Dest} needs enough room to contain
+the string \var{Source}, i.e. \var{Length(Source)+1} bytes.
 }
-{None.}{\seem{Upcase}{}, \seef{StrLower}}
+{No length checking is performed.}{ \seef{StrPas}}
 
-For an example, see \seef{StrLower}
+\input{stringex/ex2.tex}
 
 \function{StrPos}{(S1,S2 : PChar)}{PChar}
 {
@@ -230,27 +227,30 @@ If \var{S2} does not occur in \var{S1}, returns \var{Nil}.
 
 \input{stringex/ex15.tex}
 
-\function{StrNew}{(P : PChar)}{PChar}
+\function{StrRScan}{(P : PChar; C : Char)}{PChar}
 {
-Copies \var{P} to the Heap, and returns a pointer to the copy.
+Returns a pointer to the last occurrence of the character \var{C} in the
+null-terminated string \var{P}. If \var{C} does not occur, returns
+\var{Nil}.
 }
-{Returns \var{Nil} if no memory was available for the copy.}
-{\seem{New}{}, \seef{StrCopy}, \seep{StrDispose}}
+{None.}{\seem{Pos}{}, \seef{StrScan}, \seef{StrPos}}
 
-\input{stringex/ex16.tex}
+For an example, see \seef{StrScan}.
 
-\procedure{StrDispose}{(P : PChar)}
+\function{StrScan}{(P : PChar; C : Char)}{PChar}
 {
-Removes the string in \var{P} from the heap and releases the memory.
+Returns a pointer to the first occurrence of the character \var{C} in the
+null-terminated string \var{P}. If \var{C} does not occur, returns
+\var{Nil}.
 }
-{None.}{\seem{Dispose}{}, \seef{StrNew}}
+{None.}{\seem{Pos}{}, \seef{StrRScan}, \seef{StrPos}}
 
-\input{stringex/ex17.tex}
+\input{stringex/ex13.tex}
 
-\procedure{StrAlloc}{(Len : Longint)}{PChar}
+\function{StrUpper}{(P : PChar)}{PChar}
 {
-\var{StrAlloc} reserves memory on the heap for a string with length \var{Len},
-terminating \var{\#0} included, and returns a pointer to it.
+Converts \var{P} to an all-uppercase string. Returns \var{P}.
 }
+{None.}{\seem{Upcase}{}, \seef{StrLower}}
 
-For an example, see \seef{StrPCopy}.
+For an example, see \seef{StrLower}