Back to index

lightning-sunbird  0.9+nobinonly
xp.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #ifndef __XP_H__
00039 #define __XP_H__
00040 
00041 /**************************************************/
00042 /*                                                */
00043 /*                   Windows                      */
00044 /*                                                */
00045 /**************************************************/
00046 #ifdef XP_WIN
00047 
00048 #include <windows.h>
00049 #include <io.h>
00050 #include <stdio.h>
00051 
00052 #include "npapi.h"
00053 #include "npupp.h"
00054 
00055 #define XP_HFILE HFILE
00056 
00057 #endif //XP_WIN
00058 
00059 /**************************************************/
00060 /*                                                */
00061 /*                     OS/2                       */
00062 /*                                                */
00063 /**************************************************/
00064 #ifdef XP_OS2
00065 
00066 #define INCL_PM
00067 #define INCL_WIN
00068 
00069 #include <os2.h>
00070 #include <io.h>
00071 #include <stdio.h>
00072 #include <string.h>
00073 #include <ctype.h>
00074 #include <sys/types.h>    /* stat() */
00075 #include <sys/stat.h>
00076 
00077 #include "npapi.h"
00078 #include "npupp.h"
00079 
00080 #define XP_HFILE FILE*
00081 
00082 #endif //XP_OS2
00083 
00084 /**************************************************/
00085 /*                                                */
00086 /*                    Unix                        */
00087 /*                                                */
00088 /**************************************************/
00089 #ifdef XP_UNIX
00090 
00091 #include <stdio.h>
00092 #include <string.h>       /* strcat() */
00093 #include <sys/types.h>    /* stat() */
00094 #include <sys/stat.h>
00095 #include <stdlib.h>       /* atoi() */
00096 #include <assert.h>       /* assert() */
00097 #include <ctype.h>        /* isprint() */
00098 
00099 #include "npapi.h"
00100 #include "npupp.h"
00101 
00102 #define XP_HFILE FILE*
00103 
00104 #define HIBYTE(i) (i >> 8)
00105 #define LOBYTE(i) (i & 0xff)
00106 
00107 #endif //XP_UNIX
00108 
00109 /**************************************************/
00110 /*                                                */
00111 /*                     Mac                        */
00112 /*                                                */
00113 /**************************************************/
00114 #ifdef XP_MAC
00115 
00116 #include <Processes.h>
00117 #include <Gestalt.h>
00118 #include <CodeFragments.h>
00119 #include <Timer.h>
00120 #include <Resources.h>
00121 #include <ToolUtils.h>
00122 
00123 // A4Stuff.h contains the definition of EnterCodeResource and 
00124 // EnterCodeResource, used for setting up the code resourcešs
00125 // globals for 68K (analagous to the function SetCurrentA5
00126 // defined by the toolbox).
00127 //
00128 #include <A4Stuff.h>
00129 
00130 #include "jri.h"
00131 #include "npapi.h"
00132 
00133 // The Mixed Mode procInfos defined in npupp.h assume Think C-
00134 // style calling conventions.  These conventions are used by
00135 // Metrowerks with the exception of pointer return types, which
00136 // in Metrowerks 68K are returned in A0, instead of the standard
00137 // D0. Thus, since NPN_MemAlloc and NPN_UserAgent return pointers,
00138 // Mixed Mode will return the values to a 68K plugin in D0, but 
00139 // a 68K plugin compiled by Metrowerks will expect the result in
00140 // A0.  The following pragma forces Metrowerks to use D0 instead.
00141 //
00142 #ifdef __MWERKS__
00143 #ifndef powerc
00144 #pragma pointers_in_D0
00145 #endif
00146 #endif
00147 
00148 #include "npupp.h"
00149 
00150 #ifdef __MWERKS__
00151 #ifndef powerc
00152 #pragma pointers_in_A0
00153 #endif
00154 #endif
00155 
00156 // The following fix for static initializers (which fixes a preious
00157 // incompatibility with some parts of PowerPlant, was submitted by 
00158 // Jan Ulbrich.
00159 #ifdef __MWERKS__
00160        #ifdef __cplusplus
00161        extern "C" {
00162        #endif
00163               #ifndef powerc
00164                      extern void   __InitCode__(void);
00165               #else
00166                      extern void __sinit(void);
00167                      #define __InitCode__ __sinit
00168               #endif
00169               extern void   __destroy_global_chain(void);
00170        #ifdef __cplusplus
00171        }
00172        #endif // __cplusplus
00173 #endif // __MWERKS__
00174 
00175 // Wrapper functions for all calls from Netscape to the plugin.
00176 // These functions let the plugin developer just create the APIs
00177 // as documented and defined in npapi.h, without needing to 
00178 // install those functions in the function table or worry about
00179 // setting up globals for 68K plugins.
00180 NPError Private_Initialize(void);
00181 void    Private_Shutdown(void);
00182 NPError Private_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved);
00183 NPError Private_Destroy(NPP instance, NPSavedData** save);
00184 NPError Private_SetWindow(NPP instance, NPWindow* window);
00185 NPError Private_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype);
00186 NPError Private_DestroyStream(NPP instance, NPStream* stream, NPError reason);
00187 int32   Private_WriteReady(NPP instance, NPStream* stream);
00188 int32   Private_Write(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer);
00189 void    Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname);
00190 void    Private_Print(NPP instance, NPPrint* platformPrint);
00191 int16   Private_HandleEvent(NPP instance, void* event);
00192 void    Private_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData);
00193 jref    Private_GetJavaClass(void);
00194 NPError Private_GetValue(NPP instance, NPPVariable variable, void *result);
00195 NPError Private_SetValue(NPP instance, NPNVariable variable, void *value);
00196 
00197 #define XP_HFILE FILE*
00198 
00199 #endif //XP_MAC
00200 
00201 /**************************************************/
00202 /*                                                */
00203 /*                     Misc                       */
00204 /*                                                */
00205 /**************************************************/
00206 #if defined(XP_OS2)
00207 typedef unsigned short WORD;
00208 typedef char* LPSTR;
00209 typedef unsigned long DWORD;
00210 typedef void *LPVOID;
00211 
00212 #define wsprintf sprintf
00213 #define IDYES MBID_YES
00214 #define MB_ICONERROR MB_ERROR
00215 #endif
00216 
00217 #if !defined(XP_WIN) && !defined(XP_OS2)
00218 
00219 #ifndef FALSE
00220 #define FALSE false
00221 #endif
00222 
00223 #ifndef TRUE
00224 #define TRUE true
00225 #endif
00226 
00227 #ifndef DWORD
00228 #define DWORD unsigned long
00229 #endif
00230 
00231 #ifndef UINT
00232 #define UINT unsigned int
00233 #endif
00234 
00235 #ifndef LPSTR
00236 #define LPSTR char*
00237 #endif
00238 
00239 #ifndef WORD
00240 #define WORD unsigned short
00241 #endif
00242 
00243 #ifndef BOOL
00244 #define BOOL bool
00245 #endif
00246 
00247 #if (defined XP_UNIX) /* For IRIX */
00248 #ifndef bool
00249 #define bool unsigned char
00250 #endif
00251 #endif
00252 
00253 #endif //!XP_WIN && !XP_OS2
00254 
00255 // File utilities
00256 BOOL XP_IsFile(LPSTR szFileName);
00257 XP_HFILE XP_CreateFile(LPSTR szFileName);
00258 XP_HFILE XP_OpenFile(LPSTR szFileName);
00259 void XP_CloseFile(XP_HFILE hFile);
00260 void XP_DeleteFile(LPSTR szFileName);
00261 DWORD XP_WriteFile(XP_HFILE hFile, void * pBuf, int iSize);
00262 void XP_FlushFileBuffers(XP_HFILE hFile);
00263 
00264 // Private profile utilities
00265 DWORD XP_GetPrivateProfileString(LPSTR szSection, LPSTR szKey, LPSTR szDefault, LPSTR szString, DWORD dwSize, LPSTR szFileName);
00266 int XP_GetPrivateProfileInt(LPSTR szSection, LPSTR szKey, int iDefault, LPSTR szFileName);
00267 BOOL XP_WritePrivateProfileString(LPSTR szSection, LPSTR szKey, LPSTR szString, LPSTR szFileName);
00268 BOOL XP_WritePrivateProfileInt(LPSTR szSection, LPSTR szKey, int iValue, LPSTR szFileName);
00269 
00270 // Misc utilities
00271 DWORD XP_GetTickCount();
00272 void XP_Sleep(DWORD dwSleepTime);
00273 
00274 #endif // __XP_H__