Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Applies to: WG3.x

Editor's note: this chapter is new in the WG3 layer. It is from section 6 ("Year 2000 issues") of the Developer's Addendum for Worldgroup 3.12 (wg312dev; the earlier 3.10 edition, devad3, is the same text apart from "3.10" for "3.12", BC5 for BC50, InstallShield V5.0 for V5.1 and spelling). The addendum has no figures. Prose is unrewritten; "Header check" notes record where the printed text disagrees with the WG3.2 headers. The client-side paragraphs (date entry, date output, date input) are tagged WG1-3.x (Client); see also chapter 20. Related: chapters 8, 9 and 11.

...

Fortunately, all Galacticomm modules use the same function to validate birthdates:

Code Block
INT                                /*   returns TRUE if valid              */
okbday(                            /* is this a valid birthday?            */
CHAR *stg);                        /*   date str buffer (must be DATSIZ)   */

This function can be found in SIGNUP.C. It has been modified to do the following:

...

The current age of a user can be calculated using the following function:

Code Block
INT
calcage(                           /* compute age (in years) as of today   */
const CHAR *birthd);               /*   birth date (YYYYMMDD or MM/DD/YY)  */

This function also existed in earlier versions of Worldgroup, but it has been modified to accept either the new or the old date format (YYYYMMDD or MM/DD/YY). Again, 1900 is assumed for the century if the date is in the old format.

Two new functions have also been added specifically for dealing with user birth dates:

Code Block
GBOOL                              /*   returns TRUE if modified           */
fixBirthdate(                      /* fix date from MM/DD/YY to YYYYMMDD   */
CHAR *strDate);                    /*   birth date string (must be DATSIZ) */
Code Block
const CHAR *                       /*   returns pointer to static buffer   */
strBirthdate(                      /* format birthdate into "MM/DD/YYYY"   */
const CHAR *strDate);              /*   birth date string                  */

The first function is specifically for converting old format dates to the new format. It examines the input and converts it to the new date format if it is in the old format. It does not accept four-digit years in the old format and it always assumes 1900 as the century. This function is called each time the user account is loaded to ensure that the birth date is in the correct format.

...

Four-digit years obviously require more storage space than two-digit years. There is a global define that specifies the amount of space required to store a date string in MM/DD/YY format:

Code Block
#define DATSIZ 9                   /* size of a date in MM/DD/YY format    */

This define was originally in USRACC.H. It has been moved to DNTAPI.H. To accommodate dates with four-digit years, a new define was created:

Code Block
#define LDATSIZ 11                 /* size of a date in MM/DD/YYYY format  */

The primary function for decoding a string into a DOS binary date is dcdate(). This function was already reasonably well-behaved. It accepted only two-digit years, but it would assume years less-than 80 were in the 2000s and years greater-than or equal-to 80 were in the 1900s. This functionality has been retained, but it has also been modified to accept four-digit years.

...

Add-ons that read from the Audit Trail will require changes, however. The Audit Trail API provides generic access to Audit Trail files. When reading from the Major BBS Audit Trail, always use the global handle which is opened by the baseline. This handle is declared in MAJORBBS.H and imported through WGSERVER.LIB:

Code Block
HAUDFILE WGSEXP hAuditTrail;       /* Audit Trail file handle             */

Offline utilities that operate only while the Worldgroup Server is not running can open the file themselves. There is a define in MAJORBBS.H that can be used to get the name of the file:

Code Block
#define AUDITFILE "wgsaudit.adt"   /* Audit Trail file name                */

See the Audit Trail API documentation for details on opening and closing Audit Trail files.

Audit Trail files are treated by the API as binary files containing records. The records are numbered from zero to the one less than the total number of records. You can get the number of records by calling the following function:

Code Block
ULONG
audfNumRecs(                       /* get number of records in file        */
HAUDFILE haud);                    /*   Audit Trail file to use            */

The format of records in the new Audit Trail is very similar to that in the old one. The main differences are the format of the time stamp and that the maximum length of the detailed information has been increased. The new format has also been formalized using the following structure:

Code Block
struct audEntry {                  /* Audit Trail record format            */
     CHAR stamp[AUDSTAMPSIZ];      /*   time stamp ("YYYYMMDD HHMMSS")     */
     CHAR brief[AUDBRIEFSIZ];      /*   brief description                  */
     CHAR channel[AUDCHANSIZ];     /*   channel/console/event/cleanup      */
     CHAR detail[AUDDETSIZ];       /*   detailed description               */
};

The main function to read a single record by number is:

Code Block
INT                                /*   returns result code                */
audfReadEntry(                     /* read an entry by record number       */
HAUDFILE haud,                     /*   Audit Trail file to use            */
ULONG recNum,                      /*   record number to read              */
struct audEntry *buf,              /*   buffer to receive data             */
size_t bufSiz);                    /*   size of destination buffer         */

If you have a large amount of existing code that deals with the old Audit Trail record format and you don't want to change it all to work with the new format, you can use the following function instead:

Code Block
INT                                /*   returns result code                */
audfReadOldStyle(                  /* read an old-style entry              */
HAUDFILE haud,                     /*   Audit Trail file to use            */
ULONG recNum,                      /*   record number to read              */
struct audOldStyle *buf,           /*   buffer to receive data             */
size_t bufSiz);                    /*   size of destination buffer         */

The audOldStyle structure is simply a formalization of the old record format. You can pass a character buffer and simply typecast it when using this function.

...

Modules that read the birth date may need to be able to handle both formats. Modules written only for the Major BBS version 3.12 and later should call fixBirthdate() before using the birth date field, especially if the account record is read directly from the data file. Then the birth date can be decoded using sDateDecode(). Modules that must remain compatible with the Major BBS version 3.0 can use the GCOMM library function alldgs() to determine whether a birth date is in the new format or the old format. For example:

Code Block
     INT year,month,day;
Code Block
     if (alldgs(usaptr-
>birthd
>birthd)) {
          /* it's the new format */
          sscanf(usaptr-
>birthd
>birthd,"%4d%2d%2d",&year,&month,&day);
     }
     else {
          /* it's the old format */
          sscanf(usaptr-
>birthd
>birthd,"%d/%d/%d",&month,&day,&year);
     }

Using the New Audit Trail

...

Applies to: WG3.x

Header check: audbb appears in no WG3.2 header; it is the WG3.0 name of the old Btrieve audit file pointer (WGSAUDT2.DAT) and is mentioned here as history. New code uses AUDITFILE (MAJORBBS.H:430) and the audf*() API (chapter 26).

- Online modules should read from the Audit Trail using hAuditTrail.

...

On the client, use a regular text box instead of a masked edit box for date entry fields. When decoding the date string to VB binary format, use the standard VB library function DateValue().

...

Previous: Major BBS v10: 23 InstallShield  |  Contents  |  Next: Major BBS v10: 25 Searchable Memory Blocks