VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/nsprpub/pr/include/prwin16.h@ 26515

Last change on this file since 26515 was 1, checked in by vboxsync, 55 years ago

import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.4 KB
Line 
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is the Netscape Portable Runtime (NSPR).
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998-2000
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38#ifndef prwin16_h___
39#define prwin16_h___
40
41/*
42** Condition use of this header on platform.
43*/
44#if (defined(XP_PC) && !defined(_WIN32) && !defined(XP_OS2) && defined(MOZILLA_CLIENT)) || defined(WIN16)
45#include <stdio.h>
46
47PR_BEGIN_EXTERN_C
48/*
49** Win16 stdio special case.
50** To get stdio to work for Win16, all calls to printf() and related
51** things must be called from the environment of the .EXE; calls to
52** printf() from the .DLL send output to the bit-bucket.
53**
54** To make sure that PR_fprintf(), and related functions, work correctly,
55** the actual stream I/O to stdout, stderr, stdin must be done in the
56** .EXE. To do this, a hack is placed in _MD_Write() such that the
57** fd for stdio handles results in a call to the .EXE.
58**
59** file w16stdio.c contains the functions that get called from NSPR
60** to do the actual I/O. w16stdio.o must be statically linked with
61** any application needing stdio for Win16.
62**
63** The address of these functions must be made available to the .DLL
64** so he can call back to the .EXE. To do this, function
65** PR_MD_RegisterW16StdioCallbacks() is called from the .EXE.
66** The arguments are the functions defined in w16stdio.c
67** At runtime, MD_Write() calls the registered functions, if any
68** were registered.
69**
70** prinit.h contains a macro PR_STDIO_INIT() that calls the registration
71** function for Win16; For other platforms, the macro is a No-Op.
72**
73** Note that stdio is not operational at all on Win16 GUI applications.
74** This special case exists to provide stdio capability from the NSPR
75** .DLL for command line applications only. NSPR's test cases are
76** almost exclusively command line applications.
77**
78** See also: w16io.c, w16stdio.c
79*/
80typedef PRInt32 (PR_CALLBACK *PRStdinRead)( void *buf, PRInt32 amount);
81typedef PRInt32 (PR_CALLBACK *PRStdoutWrite)( void *buf, PRInt32 amount);
82typedef PRInt32 (PR_CALLBACK *PRStderrWrite)( void *buf, PRInt32 amount);
83
84NSPR_API(PRStatus)
85PR_MD_RegisterW16StdioCallbacks(
86 PRStdinRead inReadf, /* i: function pointer for stdin read */
87 PRStdoutWrite outWritef, /* i: function pointer for stdout write */
88 PRStderrWrite errWritef /* i: function pointer for stderr write */
89 );
90
91NSPR_API(PRInt32)
92_PL_W16StdioWrite( void *buf, PRInt32 amount );
93
94NSPR_API(PRInt32)
95_PL_W16StdioRead( void *buf, PRInt32 amount );
96
97#define PR_STDIO_INIT() PR_MD_RegisterW16StdioCallbacks( \
98 _PL_W16StdioRead, _PL_W16StdioWrite, _PL_W16StdioWrite ); \
99 PR_INIT_CALLBACKS();
100
101/*
102** Win16 hackery.
103**
104*/
105struct PRMethodCallbackStr {
106 int (PR_CALLBACK *auxOutput)(const char *outputString);
107 size_t (PR_CALLBACK *strftime)(char *s, size_t len, const char *fmt, const struct tm *p);
108 void * (PR_CALLBACK *malloc)( size_t size );
109 void * (PR_CALLBACK *calloc)(size_t n, size_t size );
110 void * (PR_CALLBACK *realloc)( void* old_blk, size_t size );
111 void (PR_CALLBACK *free)( void *ptr );
112 void * (PR_CALLBACK *getenv)( const char *name);
113 int (PR_CALLBACK *putenv)( const char *assoc);
114/* void * (PR_CALLBACK *perror)( const char *prefix ); */
115};
116
117NSPR_API(void) PR_MDRegisterCallbacks(struct PRMethodCallbackStr *);
118
119int PR_CALLBACK _PL_W16CallBackPuts( const char *outputString );
120size_t PR_CALLBACK _PL_W16CallBackStrftime(
121 char *s,
122 size_t len,
123 const char *fmt,
124 const struct tm *p );
125void * PR_CALLBACK _PL_W16CallBackMalloc( size_t size );
126void * PR_CALLBACK _PL_W16CallBackCalloc( size_t n, size_t size );
127void * PR_CALLBACK _PL_W16CallBackRealloc(
128 void *old_blk,
129 size_t size );
130void PR_CALLBACK _PL_W16CallBackFree( void *ptr );
131void * PR_CALLBACK _PL_W16CallBackGetenv( const char *name );
132int PR_CALLBACK _PL_W16CallBackPutenv( const char *assoc );
133
134/*
135** Hackery!
136**
137** These functions are provided as static link points.
138** This is to satisfy the quick port of Gromit to NSPR 2.0
139** ... Don't do this! ... alas, It may never go away.
140**
141*/
142NSPR_API(int) PR_MD_printf(const char *, ...);
143NSPR_API(void) PR_MD_exit(int);
144NSPR_API(size_t) PR_MD_strftime(char *, size_t, const char *, const struct tm *);
145NSPR_API(int) PR_MD_sscanf(const char *, const char *, ...);
146NSPR_API(void*) PR_MD_malloc( size_t size );
147NSPR_API(void*) PR_MD_calloc( size_t n, size_t size );
148NSPR_API(void*) PR_MD_realloc( void* old_blk, size_t size );
149NSPR_API(void) PR_MD_free( void *ptr );
150NSPR_API(char*) PR_MD_getenv( const char *name );
151NSPR_API(int) PR_MD_putenv( const char *assoc );
152NSPR_API(int) PR_MD_fprintf(FILE *fPtr, const char *fmt, ...);
153
154#define PR_INIT_CALLBACKS() \
155 { \
156 static struct PRMethodCallbackStr cbf = { \
157 _PL_W16CallBackPuts, \
158 _PL_W16CallBackStrftime, \
159 _PL_W16CallBackMalloc, \
160 _PL_W16CallBackCalloc, \
161 _PL_W16CallBackRealloc, \
162 _PL_W16CallBackFree, \
163 _PL_W16CallBackGetenv, \
164 _PL_W16CallBackPutenv, \
165 }; \
166 PR_MDRegisterCallbacks( &cbf ); \
167 }
168
169
170/*
171** Get the exception context for Win16 MFC applications threads
172*/
173NSPR_API(void *) PR_W16GetExceptionContext(void);
174/*
175** Set the exception context for Win16 MFC applications threads
176*/
177NSPR_API(void) PR_W16SetExceptionContext(void *context);
178
179PR_END_EXTERN_C
180#else
181/*
182** For platforms other than Win16, define
183** PR_STDIO_INIT() as a No-Op.
184*/
185#define PR_STDIO_INIT()
186#endif /* WIN16 || MOZILLA_CLIENT */
187
188#endif /* prwin16_h___ */
189
190
191
192
193
194
195
196
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette