Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / workbench / network / stacks / AROSTCP / netlib / dosio_init.c
blobeb07cd5a21bbee46e6db3648075e73add23228d4
1 /* $Id$
3 * dosio_init.c - SAS C auto initialization functions for DOSIO
5 * Copyright © 1994 AmiTCP/IP Group,
6 * Network Solutions Development Inc.
7 * All rights reserved.
8 */
10 #include <exec/execbase.h>
11 extern struct ExecBase *SysBase;
13 #include <dos/dos.h>
14 #include <dos/dosextens.h>
16 #if __SASC
17 #include <proto/dos.h>
18 #elif __GNUC__
19 #include <inline/dos.h>
20 #else
21 #include <clib/dos_protos.h>
22 #endif
25 /****** netd.lib/dosio_init *********************************************
27 NAME
28 dosio_init - (std) io macros to dos.library V37 or newer
30 SYNOPSIS
31 long _STI_500_dosio_init(void)
33 FUNCTION
34 This function initializes the file table used by the stdio
35 look-a-like macros defined in <netinclude:stdio.h>.
37 These macros are taken in to use by defining the symbol
38 `USE_DOSIO' before including any include files. When this is
39 done, the normal stdio prototypes are replaced with macros,
40 which call the corresponding dos.library functions. The
41 netd.lib provides the initialization function mentioned above
42 and the functions VSPrintf(), SPrintf(), VCSPrintf() and
43 CSPrintf(), which are not found from the dos.library.
45 The stdio macros provided are suitable for stdin, stdout and
46 stderr usage. No file opening function (fopen()) is provided,
47 so the use is quite limited.
49 The netd.lib version of the net.lib is compiled with this
50 USE_DOSIO, so you will want to use that instead of the
51 net.lib to make your executable smaller if your own program
52 does not use stdio of the C runtime library.
54 NOTES
55 The stdio macros rely on dos.library 37 or newer being present.
57 The autoinitialization and autotermination functions are features
58 specific to the SAS C6. However, these functions can be used with
59 other (ANSI) C compilers, too. Example follows:
61 \* at start of main() *\
63 if (_STI_500_dosio_init() != 0)
64 exit(20);
66 BUGS
67 The same autoinitialization won't work for both SAS C 6.3 and SAS C
68 6.50 or latter. Only way to terminate an initialization function is
69 by exit() call with SAS C 6.3 binary. If an autoinitialization
70 function is terminated by exit() call with SAS C 6.50 binary, the
71 autotermination functions won't be called. Due this braindamage
72 the libraries must be separately compiled for each compiler version.
74 SEE ALSO
77 *****************************************************************************
80 BPTR __dosio_files[3];
83 * Using __stdargs prevents creation of register arguments entry point.
84 * If both stack args and reg. args entry points are created, this
85 * function is called _twice_, which is not wanted.
87 * The number 500 in the function names is the priority assigned to
88 * stdio autoinitialization functions by SAS/C 6.50.
90 long __stdargs
91 _STI_500_dosio_init(void)
93 struct Process *p = (struct Process *)SysBase->ThisTask;
95 __dosio_files[0] = p->pr_CIS; /* stdin */
96 __dosio_files[1] = p->pr_COS; /* stdout */
97 __dosio_files[2] = p->pr_CES; /* stderr */
99 if (__dosio_files[2] == 0)
100 __dosio_files[2] = __dosio_files[1];
102 return 0;