Skip to content
Snippets Groups Projects
source.html 30.13 KiB
<HTML><HEAD>
<title>Synchronet Source Code</title>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content="Microsoft FrontPage 5.0" name=GENERATOR><meta name="Microsoft Border" content="tb, default">
</HEAD>
<BODY><!--msnavigation--><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td>
<p><a href="../overview.html" target="Body">
<img border="0" src="../images/synchronet2.png" align="middle" width="676" height="210"></a></p>

</td></tr><!--msnavigation--></table><!--msnavigation--><table dir="ltr" border="0" cellpadding="0" cellspacing="0" width="100%"><tr><!--msnavigation--><td valign="top">
<p align="left"><font face="Arial Black" color="#808080"><i>Synchronet - Source 
Code</i></font>
<hr>
<font face="Arial", "Helvetica">
<H2>Availability</H2>The <A href="http://www.synchro.net/">Synchronet</A> source code is 
<A href="http://www.synchro.net/copyright.html">freely</A> available:
<UL>
	<LI>Anonymous FTP (for official source code releases): 
	<UL>
		<LI><A href="ftp://vert.synchro.net/Synchronet_Archive/ssrc230b.zip">v2.30b for DOS and OS/2</A> (1997)
		<LI><A href="ftp://vert.synchro.net/Synchronet_Archive/ssrc300c.zip">v3.00c for Win32</A> (2001) 
		<LI><A href="ftp://vert.synchro.net/Synchronet_Archive/ssrc312a.zip">v3.12a for Win32</A> (2004) 
		<LI><a href="ftp://vert.synchro.net/Synchronet/ssrc314a.zip">v3.14a for 
        Win32</a> (2006)<LI><A href="ftp://vert.synchro.net/Synchronet/sbbs_src.zip">Nightly-archive for Win32</A> (Current) 
		<LI><A href="ftp://vert.synchro.net/Synchronet/sbbs_src.tgz">Nightly-archive for Linux-x86</A> (Current)
	</UL>
	<p>
  	<LI>Anonymous <A href="http://www.cvshome.org/">CVS</A> 
		(for <i>current</i> source code or previous releases by label): 
  	<ul>
  		<li>Repository: <tt>cvs.synchro.net:/cvsroot/sbbs</tt>
		<li>Mirror: <tt>cvs-mirror.synchro.net:/cvsroot/sbbs</tt>
		<li>Required modules for <i>building</i> Synchronet:
		<ul>
			<li><tt>src-sbbs3</tt> (alias for several modules)
			<li><tt>lib/mozilla/js/<i><b>os</b></i>.release (or .debug)
				<br>example: lib/mozilla/js/linux.release</tt>
			<li><tt>lib/mozilla/nspr/<i><b>os</b></i>.release (or .debug)
				<br>example: lib/mozilla/nspr/win32.release</tt>
			<li>Or you may use one of the following module aliases<br>
				 (for all required libraries for the specified OS and build type):
			<ul><tt>
				<li>lib-linux.debug
				<li>lib-linux.release
				<li>lib-win32.debug
				<li>lib-win32.release
			</tt>
			</ul>
		</ul>
		<li>Required modules for <i>running</i> Synchronet (if you don't already have Synchronet installed):
		<ul>
			<li><tt>run-sbbs3</tt> (alias for several modules)
		</ul>
	<li>Example labels (for checking-out a specific release):
	<ul><tt>
		<li>sbbs300c
		<li>sbbs310k
	</tt>
	</ul>
	<li>CVS command-line example:
	<ul>
	    <LI><tt>cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs co 
	    	src/sbbs3</tt>
	</ul>
	    <li>Win32 batch file to get/update required modules using the
        <a href="ftp://ftp.synchro.net/cvs-win32.zip">
        Win32 command-line CVS client</a>:<ul>
  		<li>
        <a href="http://cvs.synchro.net/cgi-bin/viewcvs.cgi/*checkout*/install/checkout.bat">
        checkout.bat</a></li>
	</UL>
	    </li>
	</UL>
	<p>
    <LI>Web-based CVS access, particularly useful for browsing the repository and visually comparing revisions of files ("diff'ing")<br>
    <a href="http://cvs.synchro.net/cgi-bin/viewcvs.cgi">
    http://cvs.synchro.net/cgi-bin/viewcvs.cgi</a>
    <br><br>
    <LI>Log of recent commits (changes/additions) to the CVS repository<br>
    <a href="http://vert.synchro.net/commitlog.ssjs">
    http://vert.synchro.net/commitlog.ssjs</a>
    <br><br>
    <LI>Rob's to-do list<br>
    <a href="http://vert.synchro.net/todolist.ssjs">
    http://vert.synchro.net/todolist.ssjs</a>
    <br><br>

	<li>Step-by-step instructions on how to download, build, and run the current
    	source code on Unix (Linux, FreeBSD, and OpenBSD), 
		see<br><a href="http://www.synchro.net/docs/sbbsunix.txt">http://www.synchro.net/docs/sbbsunix.txt</a></li><br>
	<br>
</UL>
<hr>
<H2>Building on Windows</H2>
Unlike on Unix, a combination of compilers may be utilized to build <i>Synchronet for Win32</i>.
If you have Borland's <a href="http://www.borland.com/bcppbuilder/freecompiler/"> free command-line C++ compiler</a>
 (v5.5) installed, 
you can build almost everything except the GUI portions (e.g. <i>Synchronet Control Panel</i>),
which require <i>Borland C++ Builder</i>, and the FOSSIL drivers, which require <i>Microsoft Visual C++</i>.
<p>
I use <i>Microsoft Visual C++ 6</i> for most of the non-GUI portions of Synchronet
because it has a better debugger and more solid IDE (in my opinion).
However, Borland provides a much better GUI framework (VCL) with <i>C++ Builder</i> and 
a handy console I/O library (conio) not present in Microsoft's C run-time library
(Note: Stephen Hurd has created a portable conio-compatible library for Win32, so this Microsoft omission
is no longer a factor).
<p>
Even though I use <i>Microsoft Visual C++</i> to build most of the Synchronet command-line utilities
and all the DLLs, you may use <i>Borland C++</i> or <i>C++ Builder</i> instead, if you prefer.
But note: if you rebuild any of the DLLs, you must also re-link <tt>sbbsctrl.exe</tt> with the
Borland import libraries for those DLLs (see <tt>src/sbbs3/ctrl/makelibs.bat</tt>
for details). 
<p>
<b>Caveat:</b> There is a known limitation with the Borland C run-time library (RTL) which may effect any Synchronet
system built soley with Borland C++: The Borland C RTL is limited to <i>50</i> open files.
Microsoft's C RTL does not have this limitation. The solution requires you have the
source code to the Borland C RTL (normally in the <tt>Source\rtl</tt> directory):
<ul>
<li>Increase the value for the <tt>_NFILE</tt> definition in <tt>include/_nfile.h</tt>
<li>Compile <tt>rtl\Source\io\files.c</tt> and <tt>files2.c</tt>
<li>Link <tt>files.obj</tt> and <tt>files2.obj</tt> with your Synchronet executable
	(i.e. <tt>sbbs.exe</tt> or <tt>sbbsmono.exe</tt>)
</ul>
<p>
As for the build files: the <tt>.dsp</tt> and <tt>.dsw</tt> files are used by <i> Microsoft Visual
C++</i>,
the <tt>Makefiles</tt> are used by <i>Borland C++ 5.5</i> (or <i>C++ Builder</i>),
and the <tt>.bpr</tt> files are used by <i> C++ Builder</i>.
<p>
<table border="1">
<tr><th>Project<th>Build File<th>Compiler
<tr valign=top><td rowspan=2>sbbs.exe, ftpsrvr.dll, mailsrvr.dll, services.dll,
    and most utilities (e.g. addfiles.exe, baja.exe, etc.)
	<td>src/sbbs3/build.bat<br>src/sbbs3/sbbs3.dsw<br>src/sbbs3/*.dsp<td>msvc6
<tr valign=top><td>src/sbbs3/Makefile<td>bcc32
<tr valign=top><td rowspan=2>scfg.exe<td>src/sbbs3/scfg/build.bat<br>src/sbbs3/scfg/scfg.dsw<br>src/sbbs3/scfg/scfg.dsp<br>
	<td>msvc6
<tr valign=top><td>src/sbbs3/scfg/Makefile<td>bcc32
<tr valign=top><td>echocfg.exe<td>src/sbbs3/Makefile<td>bcc32
<tr valign=top><td>sbbsctrl.exe<td>src/sbbs3/ctrl/build.bat<br>src/sbbs3/ctrl/sbbsctrl.bpr<td>bcb6
<tr valign=top><td>chat.exe<td>src/sbbs3/chat/chat.bpr<td>bcb6
<tr valign=top><td>useredit.exe<td>src/sbbs3/useredit/useredit.dpr<td>delphi6
<tr valign=top><td>dosxtrn.exe<td>src/sbbs3/dosxtrn/make.bat<td>msvc15
<tr valign=top><td>sbbsexec.dll<td>src/sbbs3/sbbsexec.dsp<td>msvc6
<tr valign=top><td>sbbsexec.vxd<td>src/sbbs3/execvxd/makefile<td>msvc6 and VtoolsD
</table> 
<p>
Compiler legend:<br>
<table border=1>
<tr><th>Abbreviation<th>Full Product Name
<tr><td>bcb6<td><a href="http://www.borland.com/bcppbuilder/">Borland C++ Builder 6</a>
<tr><td>bcc32<td><a href="http://www.borland.com/bcppbuilder/freecompiler/">
	Borland C++ Compiler 5.5</a> (<b>Free!</b>) or Borland C++ Builder
<tr><td>delphi6<td><a href="http://www.borland.com/delphi/">Borland Delphi 6</a>
<tr><td>msvc6<td><a href="http://msdn.microsoft.com/visualc/">Microsoft Visual C++ 6</a>
    or <a href="http://msdn.microsoft.com/vstudio/express/visualc/download/">Visual C++ Express</a>
	with the <a href="http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/">Platform SDK</a>
	(<b>Free!</b>)
<tr><td>msvc15<td>Microsoft Visual C++ 1.5 (16-bit)
</table>
<p>
<h3>Step-by-step Instructions (using Microsoft Visual C++ 6.0)</h3>
<ol>
<li>Install Visual C++ (if you haven't already)
<li>Get the Synchronet source and library files (if you haven't already)
<li>Edit <tt>src\sbbs3\build.bat</tt> (if necessary) to point to your MSVC installation directory
<li>At a command prompt, go to the Synchronet <tt>src\sbbs3</tt> directory and run <tt>build.bat</tt>
<li>At a command prompt, go to the Synchronet <tt>src\sbbs3\scfg</tt> directory and run <tt>build.bat</tt>
</ol>
You can now copy the DLL and executables from the following directories into your Synchronet <tt>EXEC</tt> directory:
<ul><tt>
<li>src\sbbs3\msvc.win32.dll.release
<li>src\sbbs3\msvc.win32.exe.release
<li>src\sbbs3\scfg\msvc.win32.exe.release
<li>src\sbbs3\scfg\msvc.win32.exe.release\scfghelp.*
</tt></ul>
<p>
If the DLLs you just built are from a more recent version of Synchronet than your Synchronet Control Panel executable (<tt>sbbsctrl.exe</tt>),
you will need to use <tt>sbbs.exe</tt> or <tt>sbbsNTsvcs.exe</tt> instead of <tt>sbbsctrl.exe</tt> to run Synchronet.
<p>
See <tt>docs\sbbscon.txt</tt> for more details on using the console mode version of Synchronet.
<br>
See <tt>docs\sbbsNTsvcs.txt</tt> for more details on using the NT services version of Synchronet.
<p>
<h3>Step-by-step Instructions (using Borland C++ Builder)</h3>
<ol>
<li>Install C++ Builder (if you haven't already)
<li>Make sure your C++ Builder <tt>bin\bcc32.cfg</tt> file (create the file if necessary) contains the correct <i>include</i> and <i>lib</i> paths.
<br>Example:<pre>-Ic:\borland\bcc55\include
-Lc:\borland\bcc55\lib</pre>
<li>Get the Synchronet source and library files (if you haven't already)
<li>At a command prompt, go to the Synchronet <tt>src\sbbs3</tt> directory and run <tt>make</tt>
<li>At a command prompt, go to the Synchronet <tt>src\sbbs3\scfg</tt> directory and run <tt>make</tt>
<li>At a command prompt, go to the Synchronet <tt>src\sbbs3\ctrl</tt> directory and run <tt>build.bat</tt>
</ol>
You can now copy the DLL and executables from the following directories into your Synchronet <tt>EXEC</tt> directory:
<ul><tt>
<li>src\sbbs3\bcc.win32.dll.release
<li>src\sbbs3\bcc.win32.exe.release
<li>src\sbbs3\scfg\bcc.win32.release
<li>src\sbbs3\ctrl
<li>lib\mozilla\js\win32.release
<li>lib\mozilla\nspr\win32.release
</tt></ul>
If you wish to build binaries with debugging information, add <tt>DEBUG=1</tt> to your <tt>make</tt> command-lines and
copy the binaries from the <tt>.debug</tt> instead of <tt>.release</tt> directories.
<p>
If you only have the free Borland command-line C++ compiler, all of the above steps still apply except for those
referencing the <tt>src\sbbs3\ctrl</tt> directory. Also, if the DLLs you built are from a more recent version of
Synchronet than your Synchronet Control Panel executable (<tt>sbbsctrl.exe</tt>), you will need to use <tt>sbbs.exe</tt> (or <tt>sbbsNTsvcs.exe</tt>)
to run Synchronet.
<p>
See <tt>docs\sbbscon.txt</tt> for more details on using the console mode version of Synchronet.
<br>
See <tt>docs\sbbsNTsvcs.txt</tt> for more details on using the NT services version of Synchronet.
<p>
<hr>
<H2>History (as of October 2000)</H2>
<H3>The Beginning</H3>I, <a href="http://synchro.net/docs/author.html">Rob 
Swindell</a>, started writing Synchronet BBS Software from scratch in 1990 (at 
the age of 20). At that time, I had been programming in C for about a year and a 
half. Needless to say, some of the early design decisions, I would've made 
differently today (hindsight is always 20/20). When browsing the code, keep in 
mind there are still portions of the source that have remained unchanged for the 
past ten years (a virtual eternity in modern software). This should also explain any perceived 
inconsistencies in programming style or design approach. 
<H3>Version 1</H3>Synchronet v1 was written almost entirely in C with a couple 
of small portions written in x86 assembler. Synchronet was an entirely "hard-coded"
BBS, that is, the user menu structure and command key sequences were hard-coded into the source
code (the ASCII/ANSI/RIP menu files themselves were sysop
replaceable/customizable). 
Synchronet v1 was a copyrighted commercial software package, and as such, was not 
distributed with source code. Synchronet v1 utilized an inefficient message 
storage method, using a separate file for each message (for both private e-mail 
and public message forums). Synchronet v1 was available as a 16-bit console-mode 
DOS program only.<BR><BR>Multi-node features (chat, multi-user games, etc) were 
abundant from the very first release, but each node required a separate instance 
of the program. Because of this requirement, local area networks (LANs) were 
often utilized for connecting multiple PCs as part of a single BBS as well as 
DESQview, Windows, and OS/2 for their DOS multi-tasking abilities. 
<H3>Version 2</H3>Synchronet v2 incorporated a programmable command and menu 
structure (<i>PCMS</i>), mostly doing away with hard-coded user commands. This allowed 
emulation of competing BBS packages (from the user's perspective) as well as 
sysop-customizable menus and dynamically loaded modules. A module/script 
compiler called <I>Baja</I> was included that utilized a high-level BASIC-like 
programming language.<BR><BR>Synchronet v2 also incorporated a new 
database-style message base format called <I>SMB</I> (Synchronet Message Base). 
The specifications and C library were released free to the public in hopes of 
encouraging competing BBS packages and utility authors to adopt SMB as a 
favorable alternative to the prolific Hudson, JAM, and Squish message base 
formats.
<p>A binary configuration file format (.cnf) was introduced in v2 to speed up
the loading of configuration files and improve extensibility.<BR><BR>Although a 32-bit console-mode OS/2 version of Synchronet v2 was 
released in 1995, it retained the same multi-node design as its DOS counterpart 
and required a separate instance of the program for each node. It was also 
during the active development life of Synchronet v2 that I began to release 
32-bit extended DOS (DPMI), OS/2, and Win32 flavors of many of the utilities 
included with Synchronet.<BR><BR>Synchronet v2 remained commercial software 
until it was released as Freeware in early 1997 and the source code was 
documented, packaged, and released to the <a href="http://www.fsf.org/philosophy/categories.html#PublicDomainSoftware">Public 
Domain</a> later that same year (the Digital Dynamics' copyright was officially
relinquished at this time). In December of 1999, I released a public beta 
of v2.30c for DOS and OS/2 (in binary form) that fixed a few millennium bugs and 
introduced some of the minor features I had incorporated thus far in my 
development of Synchronet v3.</p>
<H3>Version 3</H3>Synchronet was significantly redesigned in the fall of 1999 as 
a multi-threaded/multi-user telnet server for Win32 platforms. To aid the 
transition from the single-node-per-process model to a single-node-per-thread model, 
most of the source modules were converted from C to C++ so they could 
automatically inherit the current node's properties (previously implemented as 
global variables). Serial/modem/dial-up user support was not migrated from v2 to 
v3, so only telnet logins were supported. Configuration and database file compatibility
with v2 was consciously maintained to allow mixing v2 and v3 nodes 
on the same live BBS. The main BBS module and telnet server was implemented as 
a single Win32 dynamic link library (DLL) built with <a href="http://msdn.microsoft.com/visualc/"> Microsoft Visual
C++</a>.<BR><BR>Integrated FTP and Mail (SMTP/POP3) servers were also created for 
v3. The FTP and Mail servers were implemented as individual Win32 DLLs built with 
Microsoft Visual C++.<BR><BR>A GUI front-end called the 
<I>Synchronet Control Panel</I> was created using <a href="http://www.borland.com/bcppbuilder/"> Borland C++ Builder</a> and the 
VCL visual framework. The Synchronet Control Panel (SBBSCTRL.EXE) married the
separate server DLLs and provided a uniform place for the sysop to view the
various log files, real-time status and statistics, and perform system
configuration and maintenance functions. It provided the functional equivalent
of the &quot;Wait for call screen&quot; in v2.<BR><BR>A GUI user editor was also created using
<a href="http://www.borland.com/delphi/"> Borland 
Delphi</a> and the VCL. Delphi was chosen for this project in anticipation of the 
Borland <A href="http://www.borland.com/kylix/">Kylix</A> release and it 
represents my very first Pascal programming effort.<BR><BR>Synchronet v3 still has some 
reliance on some of the v2 utilities (most notably, SCFG.EXE), but moving as 
much code as possible to 32-bit (GUI where appropriate) is an increasing 
priority. Additionally, keeping as much of the code base as modular and portable 
as possible is a high priority. Reliance on the 16-bit assembler modules used in 
v2 has been eliminated.<BR><BR>The first official release of Synchronet v3 was 
v3.00b for Win32 (Windows 95-OSR2, 98, 98-SE, NT4, 2000, and Millennium Edition), 
released on June 25th, 2000. This release was simply Freeware, was not 
copyrighted, and did not include source code or any implied licensing (GNU GPL 
or otherwise). At this point, no proper revision control system had ever been 
utilized for Synchronet development. 
<H3>Today (October 2000)</H3>Synchronet for Unix is considered by myself and many others to be a 
potentially highly-desirable "product". From the onset of v3 design and 
development I have kept an eye towards <a href="http://www.gnu.org/gnu/linux-and-gnu.html">GNU</a>/<a href="http://www.linux.org/">Linux</a> (and other free Unix-like OSes). The 
Unix/Linux community is increasingly biased towards <a href="http://www.fsf.org/philosophy/free-sw.html">free</a>/<a href="http://www.opensource.org/osd.html">open-source</a> software, so 
I've been planning for some time to make Synchronet an open-source project, but 
was leaning towards waiting until after the Unix/Linux port was complete. In the 
mean-time, I've been getting increasingly frequent offers from Linux developers to assist in the 
porting effort. Since I had no proper revision control system in place, it 
would've been a logistical nightmare to co-develop Synchronet with anyone in a 
geographically undesirable location. Additionally, I had no copyright or licensing in place 
to protect the Synchronet source code from <a href="http://www.fsf.org/philosophy/categories.html#ProprietarySoftware"> proprietary
software</a> developers.
<p>This is not to suggest that only Unix/Linux sysops would potentially benefit
from Synchronet becoming an open-source project. It's just that Unix users are
traditionally more likely to be willing (and able) to mess with the source code,
and hence, more likely to submit useful modifications to the project. In
addition, development tools (i.e. C/C++ compiler, Make utility, CVS, etc) are
usually included free with Unix-like operating systems, while they are not
typically as readily available to Windows users.<BR><BR>So I created a revision control database (repository) using 
<A href="http://www.cvshome.org/">CVS</A> and checked-in the v2.3 and v3 source 
code trees along with all the various menus, text files, and documents included 
in Synchronet distributions. I chose CVS as the revision control system because 
it is free software and is the tool of choice among most free/open-source 
software developers. I would've preferred to use one of the commercial revision 
control systems I've become accustomed to using in my professional development 
career, but their price and status as proprietary software would have 
potentially deterred valued open-source developers from contributing to the 
project.<BR><BR>I also <a href="copyright.html"> copyrighted</a> all of the source code (as Rob Swindell) and put the majority of the v3 source code files under the 
<A href="http://www.fsf.org/copyleft/gpl.html">GNU General Public License</A> to 
protect them from inclusion in proprietary projects. I put the XSDK and SMBLIB 
modules under the <A href="http://www.fsf.org/copyleft/lesser.html">GNU Lesser 
General Public License</A>, which allows them to be linked with proprietary 
projects.</p>
<hr>
<h2>Modifications</h2>
<p>Presumably, you are reading this file because you want access to the source
code. And you want access to the source code because you plan on making
modifications (or maybe you just want to verify there aren't any &quot;back
doors&quot;). In any case, if and when you make useful modifications to the
source code, you are encouraged to submit those changes to <a href="mailto:mods&#64synchro.net">mods&#64synchro.net</a>
for possible inclusion in a future Synchronet release. Frequent contributors may
become official co-developers and be given direct read/write access to the CVS
repository by <a href="http://synchro.net/docs/author.html">me</a>, the maintainer of the project.</p>
<h3>Custom Modifications</h3>
<p>If you are modifying the code for use on a single BBS and do not wish to give
those modifications to anyone else, you have that right. To make synchronization
of your version with the official Synchronet releases easier, it is highly
recommended that you predefine a preprocessor symbol (e.g. MYMODS) and then wrap
your modifications in a conditional compilation statement. Example:</p>
<pre>#ifdef MYMODS
    bprintf(&quot;You are experiencing my custom modification.\r\n&quot;);
#endif</pre>
<p>If you are changing existing lines of code, it is recommended that you
include both the original and modified versions in your source and use
conditional compilation statements to determine which version will be used.
Example:</p>
<pre>#ifdef MYMODS
	i = j/100;
#else /* Original code */
	i = j/50;
#endif	</pre>
<p>This allows you to easily <i>&quot;</i>undo<i>&quot;</i> your modifications
for testing purposes (by simply undefining MYMODS) as well as clearly marking,
for future reference, which parts of the code were modified by you.</p>
<h3>Coding Style</h3>
<p>If you'd like to submit your modifications for possible inclusion in a future
Synchronet release, it would be beneficial if the programming style was
consistent with the style of the existing code base. Consistency of style helps
improve readability and maintainability of the source code.</p>
<p>Prior to Synchronet v3, I used a form of &quot;condensed&quot; <a href="http://cm.bell-labs.com/cm/cs/cbook/index.html">K&amp;R</a>
style to get as much code in an 80x25 character display as possible while
maintaining some degree of readability.&nbsp;</p>
<pre><b>Example (K&amp;R style):</b>

main()
{
    char line[MAXLINE];
    int found = 0;

    while (getline(line, MAXLINE) &gt; 0)
	if (strindex(line, pattern) &gt;= 0) {
	    printf(&quot;%s&quot;, line);
	    found++;
	}
    return found;
}

<b>Example (Synchronet v2 style):</b>

main()
{
    char line[MAXLINE];
    int  found=0;

while(getline(line,MAXLINE)&gt;0)
    if(strindex(line,pattern)&gt;=0) {
	printf(&quot;%s&quot;,line);
	found++; }
return(found);
}
</pre>
<p>As you've probably noticed, in the Synchronet v2 style, the body of the
function is not indented and the closing curly brace is not on its own line.
Additionally, unnecessary white-space characters have been removed from within
the body of the expressions. While the above examples do not demonstrate the
potential advantages of compressing white-space in a C coding style, you can
imagine how the limitations of an 80 column display could make heavily nested
expressions difficult without resulting to such measures.</p>
<p>In Synchronet v3, I've taken advantage of modern GUI text editors capable of
displaying more than 80 characters on a line and have&nbsp;
&quot;uncompressed&quot; the style to a degree:</p>
<pre><b>Example (Synchronet v3 style):</b>

main()
{
    char line[MAXLINE];
    int  found=0;

    while(getline(line,MAXLINE)&gt;0)
        if(strindex(line,pattern)&gt;=0) {
	    printf(&quot;%s&quot;,line);
	    found++; 
	}
    return(found);
}
</pre>
<p>Now the body of the function is indented and the closing curly brace has been
placed on its own line (as in the K&amp;R style), but the unnecessary
white-space characters remain compressed (eliminated from the body of the
expressions). You may still find v2 style closing braces in some of the v3
source files, but indentation and all other style elements should be consistent
with the v3 style shown above.</p>
<h4>Style Guidelines</h4>
<ol>
  <li>Use the Synchronet v3 indentation, white-space, and brace style (as
    described above).</li>
  <li>Configure your text editor for 4 space tab stops and keep the physical
    tabs in the files (do not replace them with spaces).</li>
  <li>Use the Synchronet copyright comment block (including the
  <a href="http://synchro.net/ptsc_hdr.html">PT/SC
    headers</a>) when creating new source files.</li>
  <li>Do not extend lines beyond column 100.</li>
  <li>Add comments around or near any code you add or modify explaining the
    rationale behind the modification.</li>
  <li>Use descriptive symbol (function and variable) and pre-processor macro names.</li>
  <li>Use symbol and macro naming styles consistent with those already used in
    the project/source file you are modifying.</li>
  <li>Do not use unnecessary global variables (use class members or function
    parameters to pass values).</li>
  <li>Use return types and variable types consistent with the data to be stored
    or returned (e.g. use bool/BOOL for true/false type values).</li>
  <li>Do not embed important numeric constants in your code; use macros (e.g.
    #define SPECIAL_VALUE 128) or configurable variables instead.</li>
</ol>
<h3>Backwards Compatibility</h3>
<p>There are two very important areas of compatibility that must be maintained
when modifying the code:</p>
<ol>
  <li>Data and configuration file compatibility with older Synchronet versions
    (v2+)</li>
  <li>Builds for other compilers and platforms</li>
</ol>
<p>On the first point, you must take care not to alter structure definitions or
file formats that will cause the resulting file not to operate in a compatible
way with Synchronet v2. If you need additional data storage, try to use unused
or reserved elements, bit-fields, or data fields in existing structure or file
definitions (without changing the overall size of the structure or data record)
or create auxiliary data files that contain the additional required data. All
binary words and double-words are to be stored in little endian (Intel)
byte-order and there are currently no provisions in the source code to account
for byte-order translations on big endian systems.</p>
<p>On the second point, it is critical that you do not add system calls or
system-dependant functionality in a non-portable fashion. If you are adding code
that is only supported on a specific platform and when built with a specific
compiler or run-time library, be sure to wrap that code in&nbsp; conditional
compilation statements that test for the appropriate pre-processor definitions.
In addition, take care to add error conditions, warnings, or alternate behavior
when the code is built on an unsupported platform or with an unsupported tool.
For example:</p>
<pre>#if defined(__MSDOS__)
	mswait(1);
#elif defined(__OS2__)
	DosSleep(1);
#elif defined (_WIN32)
	Sleep(1);
#else
	#error &quot;No Sleep Function for target platform!&quot;
#endif</pre>
<h3>Portability</h3>
<p>To maintain as much compiler and platform compatibility as possible, do not
unnecessarily restrict code portions to a specific Unix-like operating system (Linux for example)
when the code will (or should) compile with most Unix-like operating systems. For example:</p>
<pre>#if defined(__unix__)
	this_code_for_any_unix_variant;
#endif

#if defined(__linux__)
	this_code_only_for_linux;
#endif</pre>
<p>Also, be sure to separate <b>compiler</b> dependancies from <b>platform</b> dependancies. For example:</P>
<pre>#if defined(__GNUC__)
	this_code_only_for_gcc;
#else
	this_code_for_all_others;
#endif</pre>
<p><b>Please use the following pre-processor symbols to determine the target platform:</b></p>
<table>
<COLGROUP align=center>
<COLGROUP align=left>
<th width="150">Symbol<th>Target Platform
<tr><td>
    <p align="center"><b><code>__unix__</code></b><td>Any Unix-like OS
<tr><td>
    <p align="center"><b><code>__linux__</code></b><td>GNU/Linux (use sparingly)
<tr><td>
    <p align="center"><b><code>__FreeBSD__</code></b><td>FreeBSD (use sparingly)
<tr><td>
    <p align="center"><b><code>BSD</code></b><td>Any BSD-based Unix
<tr><td>
    <p align="center"><b><code>_WIN32</code></b><td>Win32-based OS
<tr><td>
    <p align="center"><b><code>__OS2__</code></b><td>OS/2
<tr><td>
    <p align="center"><b><code>__MSDOS__</code></b><td>MS-DOS
<tr><td>
    <p align="center"><b><code>__DOS4G__</code></b><td>Rational 32-bit DOS extender
<tr><td>
    <p align="center"><b><code>__FLAT__</code></b><td>Other 32-bit DOS extender
</table>
<p><b>Please use the following pre-processor symbols to determine the compiler:</b></p>
<table>
<COLGROUP align=center>
<COLGROUP align=left>
<th width="150">Symbol<th>Compiler
<tr><td>
    <p align="center"><b><code>__GNUC__</code></b><td>GNU C/C++ Compiler
<tr><td>
    <p align="center"><b><code>__BORLANDC__</code></b><td>Borland C++ or C++ Builder Compiler
<tr><td>
    <p align="center"><b><code>__WATCOM__</code></b><td>Watcom C++
<tr><td>
    <p align="center"><b><code>_MSC_VER</code></b><td>Microsoft Visual C++
</table>
<p>Little-endian/80386-class target CPUs are assumed, so no testing for CPU-type is required at this time.</p>
<h3>Submissions</h3>
<p>When you've created a modification that you think other Synchronet sysops or
users may find useful, you are encouraged to submit this modification to <a href="mailto:mods&#64synchro.net">mods&#64synchro.net</a>.
Modifications should be submitted in the Unix <a href="http://www.gnu.org/software/diffutils/diffutils.html">diff</a>
format. Currently, I am the sole judge of which submissions will be merged into
the code base and which ones will not. If I determine that a submission should
not be merged into the code base for any reason, I will make my best effort to
explain to the submitting developer the reasons why and offer advice on how to
remedy the situation, if at all possible. </p>
</font>
<p align="right"><font face="Arial" size="1">Copyright  2009 Rob Swindell
<br>$Id: source.html,v 1.18 2009/01/31 21:27:29 rswindell Exp $</font></p>
</BODY>
</HTML>