/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- * * The contents of this file are subject to the Netscape Public License * Version 1.0 (the "NPL"); you may not use this file except in * compliance with the NPL. You may obtain a copy of the NPL at * http://www.mozilla.org/NPL/ * * Software distributed under the NPL is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL * for the specific language governing rights and limitations under the * NPL. * * The Initial Developer of this code under the NPL is Netscape * Communications Corporation. Portions created by Netscape are * Copyright (C) 1998 Netscape Communications Corporation. All Rights * Reserved. */ /* This project is rather, um, creative in the way it works. Here's why. There are two goals here (which should probably be separated out): 1. Make a shared library which exports a bunch of symbols which are IDs of error strings: MacXPStrings.c is preprocessed and compiled in the normal way for a C file, and ends up simple assigning numerical values to lots of exported ints, e.g. "int MK_BAD_CONNECT = (-205)". These ints are exported by name from the shared library. The dummy function MacintoshForever() is there because there is apparently a CFM bug that causes a crash loading shared libraries with no exported code symbols. 2. Make a file called "Mozilla resources" which contains a bunch of 'STR ' resources containing the strings defined in allxpstr.h, and some other resources. This is achieved by the .xps file which, if you look at the File Mapping prefs, is processed by ToolFrontEnd. The ToolFrontEnd prefs panel specifies that the following command: Execute "{{SourceFile}}_Make" is send to ToolServer, so xpstring.xps_Make will get executed. xpstring.xps_Make preprocesses this file (xpstrings.xps) with the MWCPPC tool, outputting the result to a .r file Temp_XPStrings.r: MWCPPC -nodefaults -i- -e2 -D _XP_Core_ {IncludeFiles} "{{SourceFile}}" ¶ > "{{ResourceDir}}Temp_XPStrings.r" Temp_XPStrings.r is then Perlized by resdef.pl to create xpstring.r: perl resdef.pl Temp_XPStrings.r xpstring.r is then Rez'd to create Mozilla Resources: Rez -t 'NSPL' -c MOZZ -i "{RIncludes}" ¶ -o "{{TargetDir}}Essential Files:Mozilla Resources" ¶ xpstring.r We then Rez MacSTR.r, which itself includes all the other .r files here: Rez -append -i "{RIncludes}" -i "{{mozilla}}cmd:macfe:include:" ¶ -o "{{TargetDir}}Essential Files:Mozilla Resources" ¶ MacSTR.r That's basically it. Phew! Some things to be careful of: MacXPStrings.c is preprocessed by the IDE, so in prefix file specified in the prefs is included. When this file is preprocessed by MWCPPC, the prefix file is ignored so we include "MacCommonPrefix.h" ourselves. */ #define RESOURCE_STR /* Manually include the prefix file, so that MWCPPC picks it up */ #include "MacConfigInclude.h" /* the prefix file should have already defined OTUNIXERRORS at this stage */ #include "OpenTransport.h" /* allxpstr.h have to be in the last one */ #include "allxpstr.h" /* The real stuff is here... */ #ifdef rez /* ** These are included here to force CodeWarrior to rebuild if they change. The ** include should not actually happen during the build phase, only when the #include ** scanner is doing its thing. */ #include "MacSTR.r" #include "::rsrc:communicator:Communicator.rsrc" /* sounds of nail-biting */ #endif