Routines in Abbr_rtn.c

The file contains the following routines:

They all revolve around an in-memory table which is basically an organised copy of ABBREV.CVT (and ABBREV.NEW) containing:

struct abbstr {
char abbrec[ABBSIZ+1]; /* Room for abbreviation */
char lowabb[ABBSIZ+1]; /* and a lower-case version */
char abbtyp; /* abbreviation type */
char abbdtyp; /* and date type expected */
char *titl_ptr; /* Pointer to title */
char *srttl_ptr; /* Pointer to sort title */
char *covr_ptr; /* Pointer to cover scan version of title */
char *ttad_ptr; /* Pointer to title additional */
char *auth_ptr; /* Pointer to authors/editors */
char *type_ptr; /* Type pointer */
char *publ_ptr; /* Pointer to publisher */
char start_date[3][9]; /* Up to 3 Start Year/Month/Day */
char end_date[3][9]; /* Up to 3 End Year/Month/Day */
};

FIND_ABBREV: Routine to find the abbreviation for a given magazine name

/************************************************************************/
/*									*/
/*    FIND_ABBREV - Find the abbreviation corresponding to a given	*/
/*			magazine name and year.				*/
/*									*/
/*    Calling Format:							*/
/*									*/
/*	status = FIND_ABBREV (inpbuf_ptr, year_ptr, abbrev_ptr,		*/
/*				dattyp_ptr, prtfil_ptr);		*/
/*									*/
/*    Where:								*/
/*									*/
/*	status       = PSP_TRUE if abbreviation was found		*/
/*		     = PSP_FALSE otherwise				*/
/*	inpbuf_ptr   = Pointer to null-terminated buffer to parse	*/
/*	year_ptr     = Pointer to null-terminated year/month/day string	*/
/*	abbrev_ptr   = Pointer to buffer to hold abbreviation		*/
/*	dattyp_ptr   = Pointer to char to hold preferred date type:	*/
/*			'M' if MMMDD					*/
/*			'#' if #nnn					*/
/*			'v' if vnnmm					*/
/*	prtfil_ptr   = Diagnostics file pointer				*/
/*									*/
/*    The routine will report any errors detected.			*/
/*									*/
/************************************************************************/

FREE_ABBREV: Routine to free up data structures allocated by PARSE_ABBREV

/************************************************************************/
/*					      				*/
/*    FREE_ABBREV - Free memory allocated to abbreviations	  	*/
/*		                                    			*/
/*    Calling Format:                       				*/
/*							                */
/*	    FREE_ABBREV ();						*/
/*									*/
/*    This routine simply checks the abbreviation structures, freeing	*/
/*	  up any allocated memory.	                               	*/
/*									*/
/************************************************************************/

GET_ABB_ABBTYP: Routine to get the abbreviation type for a particular abbreviation

/************************************************************************/
/*									*/
/*    GET_ABB_ABBTYP - Get abbreviation type for abbreviation		*/
/*									*/
/*    Calling Format:							*/
/*									*/
/*	abbtyp = GET_ABB_ABBTYP (inpbuf_ptr, prtfil_ptr);		*/
/*									*/
/*    Where:								*/
/*									*/
/*	abbtyp     = Abbreviation type:					*/
/*			'B' if a book					*/
/*			'M' if a magazine				*/
/*			'P' if a publisher				*/
/*			'X' if an oddment				*/
/*			'O' if obsolete					*/
/*	inpbuf_ptr = Buffer containing abbreviation; if an empty string	*/
/*			 then we're just here to validate the files.	*/
/*	prtfil_ptr = Diagnostics file pointer				*/
/*									*/
/*    This routine returns the abbreviation type for the abbreviation	*/
/*    at the start of the input buffer.					*/
/*									*/
/*    The routine will report any errors detected.			*/
/*									*/
/************************************************************************/

GET_ABB_DATTYP: Routine to get the default date type for a particular abbreviation

/************************************************************************/
/*									*/
/*    GET_ABB_DATTYP - Get preferred date type for abbreviation		*/
/*									*/
/*    Calling Format:							*/
/*									*/
/*	abbdtyp = GET_ABB_DATTYP (inpbuf_ptr, prtfil_ptr);		*/
/*									*/
/*    Where:								*/
/*									*/
/*	abbdtyp     = Preferred date type:				*/
/*			'M' if MMMDD					*/
/*			'#' if #nnn					*/
/*			'v' if vnnmm					*/
/*	inpbuf_ptr = Buffer containing abbreviation			*/
/*	prtfil_ptr = Diagnostics file pointer				*/
/*									*/
/*    This routine returns the preferred date type for the abbreviation	*/
/*    at the start of the input buffer.					*/
/*									*/
/*    The routine will report any errors detected.			*/
/*									*/
/************************************************************************/

GET_ABB_DATES: Routine to get the valid date range for a particular abbreviation

/************************************************************************/
/*									*/
/*    GET_ABB_DATES - Get date range for a given abbreviation.		*/
/*									*/
/*    Calling Format:							*/
/*									*/
/*	GET_ABB_DATES (abbrev_ptr, start_date1_ptr, end_date1_ptr,	*/
/*		       start_date2_ptr, end_date2_ptr, start_date3_ptr,	*/
/*		       end_date3_ptr, abbtyp_ptr, prtfil_ptr);		*/
/*									*/
/*    Where:								*/
/*									*/
/*	abbrev_ptr      = Pointer to null-terminated abbreviation	*/
/*	start_date1_ptr = Pointer to char[9] for first start date	*/
/*	end_date1_ptr   = Pointer to char[9] for first end date		*/
/*	start_date2_ptr = Pointer to char[9] for second start date	*/
/*	end_date2_ptr   = Pointer to char[9] for second end date	*/
/*	start_date3_ptr = Pointer to char[9] for third start date	*/
/*	end_date3_ptr   = Pointer to char[9] for third end date		*/
/*	abbtyp_ptr      = Pointer to char for abbreviation type		*/
/*	prtfil_ptr      = Diagnostics file pointer			*/
/*									*/
/************************************************************************/

GET_ABB_DETAILS: Routine to get abbreviation details

/************************************************************************/
/*									*/
/*    GET_ABB_DETAILS - Return details for a specified abbreviation.	*/
/*									*/
/*    Calling Format:							*/
/*									*/
/*	status = GET_ABB_DETAILS (abbrev_ptr, abbtyp_ptr, titl_ptr_ptr,	*/
/*				  ttad_ptr_ptr,	auth_ptr_ptr,		*/
/*				  publ_ptr_ptr, date_ptr_ptr,		*/
/*				  type_ptr_ptr, prtfil_ptr);		*/
/*									*/
/*    Where:								*/
/*									*/
/*	status       = PSP_TRUE if publication details are valid	*/
/*		     = PSP_FALSE otherwise				*/
/*	inpbuf_ptr   = Pointer to null-terminated abbreviation		*/
/*	abbtyp_ptr   = Pointer to char to hold abbreviation type	*/
/*	titl_ptr_ptr = Pointer to buffer to hold pointer to title	*/
/*	ttad_ptr_ptr = Pointer to buffer to hold pointer to title addl	*/
/*	auth_ptr_ptr = Pointer to buffer to hold pointer to auth(s)	*/
/*	publ_ptr_ptr = Pointer to buffer to hold pointer to publisher	*/
/*	date_ptr_ptr = Pointer to buffer to hold pointer to 1st st date	*/
/*	type_ptr_ptr = Pointer to buffer to hold pointer to item type	*/
/*	prtfil_ptr   = Diagnostics file pointer				*/
/*									*/
/*    Note that any of the pointers (except abbrev_ptr) may be NULL.	*/
/*    Note that the author names are returned as in ABBREV.CVT		*/
/*									*/
/*    The routine will report any errors detected.			*/
/*									*/
/************************************************************************/

GET_ABB_NAME: Routine to get (sort) title for a particular (lower case) abbreviation

/************************************************************************/
/* */
/* GET_ABB_NAME - Return ABBREV.CVT entry a specified abbreviation. */
/* */
/* Calling Format: */
/* */
/* title_ptr = GET_ABB_NAME (lowabb_ptr); */
/* */
/* Where: */
/* */
/* title_ptr = Pointer to title; NULL if no match */
/* lowabb_ptr = Pointer to lowercase abbreviation */
/* */
/************************************************************************/

This routine is called by IdxGen to return the sort title for an abbreviation so that index files can be sorted into the desired order. Note that the abbreviation is extracted from the associated file name and hence is entirely in lower case. The routine simply pads the abbreviation to the same size as the entries in the table and then scans the table sequentially until it finds a match. If there is no match, or any error occurs, the return value is set to NULL; otherwise it is set to the (sort) title for the abbreviation.

While scanning the table sequentially is not the most efficient way to find a match(!) this is a low usage routine so it's easier than setting up an alternate sort.


PARSE_ABBREV: Routine to parse abbreviation in publication details

/************************************************************************/
/*									*/
/*    PARSE_ABBREV - Parse the abbreviation specified as part of a	*/
/*		     buffer containing publication details.		*/
/*									*/
/*    Calling Format:							*/
/*									*/
/*	status = PARSE_ABBREV (inpbuf_ptr, abbtyp_ptr, dattyp_ptr,	*/
/*			       length_ptr, titl_ptr_ptr, ttad_ptr_ptr,	*/
/*    			       auth_ptr_ptr, publ_ptr_ptr, prtfil_ptr);	*/
/*									*/
/*    Where:								*/
/*									*/
/*	status       = PSP_TRUE if publication details are valid	*/
/*		     = PSP_FALSE otherwise				*/
/*	inpbuf_ptr   = Pointer to null-terminated buffer to parse	*/
/*	abbtyp_ptr   = Pointer to char to hold abbreviation type:	*/
/*			'B' if a book					*/
/*			'M' if a magazine				*/
/*			'P' if a publisher				*/
/*			'X' if an oddment				*/
/*			'O' if obsolete					*/
/*	dattyp_ptr   = Pointer to char to hold preferred date type:	*/
/*			'M' if MMMDD					*/
/*			'#' if #nnn					*/
/*			'v' if vnnmm					*/
/*	length_ptr   = Pointer to int to hold length of abbreviation	*/
/*			parsed						*/
/*	titl_ptr_ptr = Pointer to buffer to hold pointer to title	*/
/*	ttad_ptr_ptr = Pointer to buffer to hold pointer to title addl	*/
/*	auth_ptr_ptr = Pointer to buffer to hold pointer to auth(s)	*/
/*	publ_ptr_ptr = Pointer to buffer to hold pointer to publisher	*/
/*	prtfil_ptr   = Diagnostics file pointer				*/
/*									*/
/*    This routine parses a set of publication details into their	*/
/*    constituent parts.  Allowed formats are:				*/
/*									*/
/*	*AAAAAAA							*/
/*	+BBBBB{xyzzy}							*/
/*	CCC{xyzzy}							*/
/*	|DDDD|{xyzzy}							*/
/*	PPP								*/
/*									*/
/*    Where AAAAAAA is a book acronym					*/
/*	    BBBBB is a 5 character magazine/series abbreviation		*/
/*	    CCC is a 3 character magazine/series abbreviation		*/
/*	    DDDD is a magazine/series abbreviation of any length	*/
/*	    xyzzy is additional date/volume information			*/
/*	    PPP is a publisher abbreviation				*/
/*									*/
/*    Note that any of the pointers (except inpbuf_ptr) may be NULL.	*/
/*    Note that the author names are converted into internal format	*/
/*									*/
/*    The routine will report any errors detected.			*/
/*									*/
/************************************************************************/

PARSE_CVRSCAN: Routine to find the magazine name for a cover scan name

/************************************************************************/
/*									*/
/*    PARSE_CVRSCAN - Find the magazine name corresponding to a given	*/
/*		      cover scan abbreviation.				*/
/*									*/
/*    Calling Format:							*/
/*									*/
/*	status = PARSE_CVRSCAN (inpbuf_ptr, outbuf_ptr_ptr,		*/
/*				dattyp_ptr, prtfil_ptr);		*/
/*									*/
/*    Where:								*/
/*									*/
/*	status         = PSP_TRUE if abbreviation was found		*/
/*		       = PSP_FALSE otherwise				*/
/*	inpbuf_ptr     = Pointer to null-terminated buffer to parse	*/
/*	outbuf_ptr_ptr = Pointer to pointer for output buffer		*/
/*	dattyp_ptr     = Pointer to character to hold date type		*/
/*	prtfil_ptr     = Diagnostics file pointer			*/
/*									*/
/************************************************************************/