...
Assembly language functions are prototyped as much as possible:
| Code Block |
|---|
void prf(char *fmat,...); void prfmsg(int msg,...); |
Applies to: WG3.x
Header check: in WG3.2 the format parameter of
prf()isCHAR *fmt(GCOMM.H:806) and is still notconst; see theconst CHAR *hazard note in chapter 28.
There are shareware utilities like PROTOE that will help you generate prototypes for local-use functions in a .C file.
...
Applies to: WG3.x
Header check: the WG3.2 headers define neither
STATIC(WG2GCOMM.H:257:#define STATIC static) norBOOL(WG2AAEF.H:78,GCOMM.H). WritestaticandGBOOL(typedef short GBOOL,GCTYPDEF.H:105), and use theGCTYPDEF.Htype namesINT,UINT,CHAR,SHORT,USHORT,LONG,ULONG,UCHAR,VOID(GCTYPDEF.H:71-105) in place ofint,unsigned,char,short,long,void.GALPORT.EXEperforms these substitutions (chapter 28). Examples in chapters 2-12 that useSTATICorBOOLare WG1/WG2 style and will not compile against the 3.2 headers as printed.
| Code Block |
|---|
localroutine(void) { doessomething(); } |
Routines that need to be called from code in other C source files should be coded normally: void
| Code Block |
|---|
globalroutine(void) { doessomething(); } |
Your init__xxx() routines (page 42) should be coded as EXPORT, as in: void EXPORT
Applies to: v10
In v10
EXPORTis__declspec(dllexport)unless the project definesUSE_DEF_FILE, in which caseEXPORTis empty andinit__xxxmust be listed in the module's.DEFfile (GCTYPDEF.H:60-69). The two-argumentEXPORT_FUNCTION(inout,t,n)andEXPORT_TYPEof WG3.2 are gone (EXPORT_FUNCTION(t, n),GCTYPDEF.H:162). See chapter 29, section 29.5.
| Code Block |
|---|
init__routine(void) { initsomething(); } |
Rebuilding MAJORBBS.EXE and Standard .DLL Files
Applies to: v10
MAJORBBS.EXE,MAKEBBS,TLINK,.LNKfiles andIMPLIB(this section and the next) are the DOS/Borland procedure. v10 buildswgserver.exeand the standard DLLs from the Visual Studio solution (src\server\wgserver), and import libraries are*_lib.libinlib\importlibs(chapter 29, section 29.3). Borland-compiled WG 3.x/NT modules can run through a forwarding DLL (MBBS10.txtsection 3), though some need conversion to native v10.
...
To process a <filename>.MSG file into .MCV and .H files:
| Code Block |
|---|
CD \WGSERV
WGSMSX <filename> -OSRC |
To compile a <filename>.C source file that contributes to MAJORBBS.EXE:
| Code Block |
|---|
CD \WGSERV\SRC
CTPH <filename> |
To compile a <filename>.C source file that contributes to a .DLL file:
| Code Block |
|---|
CD \WGSERV\SRC
CTDLL <filename> |
To link a new MAJORBBS.EXE:
| Code Block |
|---|
CD \WGSERV\SRC
LTPH |
To link a new <filename>.DLL file:
| Code Block |
|---|
CD \WGSERV\SRC
LTDLL <filename> |
You’ll use many of these same steps for compiling and linking your own .DLL files for your own Add-on Option. You can also create a debugging version of MAJORBBS.EXE by running MAKEBBSD.BAT:
...
Applies to: v10
v10 modules are a Visual Studio project producing a
.DLL; exports come from__declspec(dllexport)or, withUSE_DEF_FILE, from a.DEFfile (for exampleGALGSBL_EXP.DEF,ELWBIO_EXP.DEF). Plaincharis unsigned (/J) in 118 of the 138 shipped projects, and struct packing is chosen by the project (StructMemberAlignment8Bytes in 86 projects): chapter 29, section 29.3.
Here are most of the administrative aspects of making a .DLL. The technical considerations will be discussed in later sections.
...
- Create a .LNK file for your .DLL. You can use the file \WGSERV\SRC\GALP&Q.LNK as an example:
| Code Block |
|---|
%PHARLAP%\bc4\lib\c0phdll +
%PHARLAP%\bc4\lib\fpdmy +
galp&q +
galp&qa
%MBBS%\galp&q
%MBBS%\galp&q /m
phapi mathh galimp gmeimp gsblimp /Twd /s /n
%MBBS%\dlib\mathdef |
This links the supporting files which produce the Polls and Questionnaires Add-on Option .DLL. The first two lines of the .LNK file are Phar Lap object files necessary for creating a .DLL.
...
Notice the lines beginning with %PHARLAP% and %MBBS%. Files provided by us with the extension .LNK are not immediately ready to be given to TLINK. Our .LNK files include %environment% variables for the Major BBS, Borland, and Phar Lap directories, not the literal drive:\path names that TLINK is expecting. Our .LNK files must be translated first before being given to TLINK. That’s where our program XLTENV comes in: you use it to convert one of our .LNK files to a tempfile.LNK which is then run through TLINK. Finally, you should delete the tempfile.LNK. For example, if you run XLTENV from within a .MAK file, you could do this:
| Code Block |
|---|
:
xltenv $(MBBS)\src\bbsrpt.lnk $(MBBS)\src\tmpfil.lnk
tlink @$(MBBS)\src\tmpfil.lnk
del $(MBBS)\src\tmpfil.lnk > nul
: |
The .DLL-linking batch file LTDLL.BAT uses XLTENV (so does its debugging twin LTDLLD.BAT). While you should know that our .LNK files need this extra step before TLINK gets them, you can let LTDLL handle the extra step for you.
...
If you use any routines from Borland’s compiler library that we don’t use in MAJORBBS.EXE and export in \WGSERV\DLIB\MAJORBBS.DEF, undefined symbol errors will occur. We use a lot of Borland library routines in the Major BBS, but naturally we don’t use every single one. It may be possible to include BCH286.LIB at the end of the list of libraries in your .LNK file, for example:
| Code Block |
|---|
phapi mathh galimp gmeimp gsblimp bch286 /Twd /s /n |
But this doesn’t always work. Many of the Borland library routines have interdependencies with other library routines or internal data structures. If you use a memory allocation routine, for example, or any kind of file I/O routine, conflicts could arise with the memory or I/O routines used in MAJORBBS.EXE. A truly independent routine will not have this problem, but the only way to know this for sure is if you have the compiler library source code. The safest approach is to find an alternative to using the routine. Perhaps you could write your own version of the routine (giving it a different name to avoid conflicts). Or redesign the calling routine.
...
6. To try out your individual make file, just type the following, where <program name>.MAK is the name of your MAKE file:
| Code Block |
|---|
MAKE -f<program name> |
Assuming you included debugging support in your .MAK file (as we do), use MAKE’s -DDEBUG switch to make a debugging version of your .DLL:
| Code Block |
|---|
MAKE -DDEBUG -f<program name> |
7. You may want to add your .MAK file to \WGSERV\SRC\MAKEBBS.BAT for convenient, centralized recompiling:
...
Once you create your own <program name>.MAK file, you can use MAKE’s -f switch to remake <program name>.DLL:
| Code Block |
|---|
MAKE -f<program name> |
If you wish to make a debugging version of your .DLL, do this:
| Code Block |
|---|
MAKE -DDEBUG -f<program name> |
If you’ve edited MAKEBBS.BAT to make this new .MAK file, then run
| Code Block |
|---|
MAKEBBS |
If you’ve edited MAKEBBSD.BAT to make a debugging version of this new .MAK file, then run
| Code Block |
|---|
MAKEBBSD |
On the other hand, here’s how to do it a piece at a time:
To process a <filename>.MSG file into .MCV and .H files:
| Code Block |
|---|
CD \WGSERV
WGSMSX <filename> -OSRC |
To compile a <filename>.C source file that contributes to your .DLL file:
...
To use MAJORBBS.DEF to create GALIMP.LIB, the following line must first be added to the beginning of MAJORBBS.DEF:
| Code Block |
|---|
LIBRARY MAJORBBS |
Then we use Borland’s IMPLIB to create GALIMP.LIB
| Code Block |
|---|
IMPLIB GALIMP.LIB MAJORBBS.DEF |
Then we remove the LIBRARY command from MAJORBBS.DEF, restoring it to the form that’s useful when linking MAJORBBS.EXE (via LTBBS.LNK).
...
Previous: Major BBS v10: 01 Overview | Contents | Next: Major BBS v10: 03 Operating Environment