-/*
- * (C) Copyright 1989-1995
- * All Rights Reserved
- *
- * Alan R. Baldwin
- * 721 Berkeley St.
- * Kent, Ohio 44240
- */
+ Copyright (C) 1989-1995 Alan R. Baldwin
+ 721 Berkeley St., Kent, Ohio 44240
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3, or (at your option) any
+later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>. */
-/*)Function VOID getid(id,c)
- *
- * char * id a pointer to a string of
- * maximum length NCPS
- * int c mode flag
- * >=0 this is first character to
- * copy to the string buffer
- * <0 skip white space
- *
- * The function getid() scans the current input text line
- * from the current position copying the next LETTER | DIGIT string
- * into the external string buffer (id). The string ends when a non
- * LETTER or DIGIT character is found. The maximum number of
- * characters copied is NCPS. If the input string is larger than
- * NCPS characters then the string is truncated, if the input string
- * is shorter than NCPS characters then the string is NULL filled.
- * If the mode argument (c) is >=0 then (c) is the first character
- * copied to the string buffer, if (c) is <0 then intervening white
- * space (SPACES and TABS) are skipped.
- *
- * local variables:
- * char * p pointer to external string buffer
- * int c current character value
- *
- * global variables:
- * char ctype[] a character array which defines the
- * type of character being processed.
- * This index is the character
- * being processed.
- *
- * called functions:
- * char get() lklex.c
- * char getnb() lklex.c
- * VOID unget() lklex.c
- *
- * side effects:
- * use of getnb(), get(), and unget() updates the
- * global pointer ip the position in the current
- * input text line.
+/*)Function VOID getid(id,c)
+ *
+ * char * id a pointer to a string of
+ * maximum length NCPS
+ * int c mode flag
+ * >=0 this is first character to
+ * copy to the string buffer
+ * <0 skip white space
+ *
+ * The function getid() scans the current input text line
+ * from the current position copying the next LETTER | DIGIT string
+ * into the external string buffer (id). The string ends when a non
+ * LETTER or DIGIT character is found. The maximum number of
+ * characters copied is NCPS. If the input string is larger than
+ * NCPS characters then the string is truncated, if the input string
+ * is shorter than NCPS characters then the string is NULL filled.
+ * If the mode argument (c) is >=0 then (c) is the first character
+ * copied to the string buffer, if (c) is <0 then intervening white
+ * space (SPACES and TABS) are skipped.
+ *
+ * local variables:
+ * char * p pointer to external string buffer
+ * int c current character value
+ *
+ * global variables:
+ * char ctype[] a character array which defines the
+ * type of character being processed.
+ * This index is the character
+ * being processed.
+ *
+ * called functions:
+ * char get() lklex.c
+ * char getnb() lklex.c
+ * VOID unget() lklex.c
+ *
+ * side effects:
+ * use of getnb(), get(), and unget() updates the
+ * global pointer ip the position in the current
+ * input text line.
- * characters copied is NCPS. If the input string is larger than
- * NCPS characters then the string is truncated, if the input string
- * is shorter than NCPS characters then the string is NULL filled.
- * Intervening white space (SPACES and TABS) are skipped.
- *
- * local variables:
- * char * p pointer to external string buffer
- * int c current character value
- *
- * global variables:
- * char ctype[] a character array which defines the
- * type of character being processed.
- * This index is the character
- * being processed.
- *
- * called functions:
- * char get() lklex.c
- * char getnb() lklex.c
- * VOID unget() lklex.c
- *
- * side effects:
- * use of getnb(), get(), and unget() updates the
- * global pointer ip the position in the current
- * input text line.
+ * characters copied is NCPS. If the input string is larger than
+ * NCPS characters then the string is truncated, if the input string
+ * is shorter than NCPS characters then the string is NULL filled.
+ * Intervening white space (SPACES and TABS) are skipped.
+ *
+ * local variables:
+ * char * p pointer to external string buffer
+ * int c current character value
+ *
+ * global variables:
+ * char ctype[] a character array which defines the
+ * type of character being processed.
+ * This index is the character
+ * being processed.
+ *
+ * called functions:
+ * char get() lklex.c
+ * char getnb() lklex.c
+ * VOID unget() lklex.c
+ *
+ * side effects:
+ * use of getnb(), get(), and unget() updates the
+ * global pointer ip the position in the current
+ * input text line.
-/*)Function VOID getfid(fid,c)
- *
- * char * str a pointer to a string of
- * maximum length PATH_MAX
- * int c this is first character to
- * copy to the string buffer
- *
- * The function getfid() scans the current input text line from
- * the current position copying the next string into the external
- * string buffer (str). The string ends when end of line is found.
- * Trailing spaces are removed. The maximum number of characters
- * copied is PATH_MAX. If the input string is larger than PATH_MAX
- * characters then the string is truncated. The string is NULL
- * terminated.
- *
- * local variables:
- * char * p pointer to external string buffer
- * int c current character value
- *
- * global variables:
- * char ctype[] a character array which defines the
- * type of character being processed.
- * This index is the character
- * being processed.
- *
- * called functions:
- * char get() lklex.c
- *
- * side effects:
- * use of get() updates the global pointer ip
- * the position in the current input text line.
+/*)Function VOID getfid(fid,c)
+ *
+ * char * str a pointer to a string of
+ * maximum length PATH_MAX
+ * int c this is first character to
+ * copy to the string buffer
+ *
+ * The function getfid() scans the current input text line from
+ * the current position copying the next string into the external
+ * string buffer (str). The string ends when end of line is found.
+ * Trailing spaces are removed. The maximum number of characters
+ * copied is PATH_MAX. If the input string is larger than PATH_MAX
+ * characters then the string is truncated. The string is NULL
+ * terminated.
+ *
+ * local variables:
+ * char * p pointer to external string buffer
+ * int c current character value
+ *
+ * global variables:
+ * char ctype[] a character array which defines the
+ * type of character being processed.
+ * This index is the character
+ * being processed.
+ *
+ * called functions:
+ * char get() lklex.c
+ *
+ * side effects:
+ * use of get() updates the global pointer ip
+ * the position in the current input text line.
- * The function getmap() converts the 'C' style characters \b, \f,
- * \n, \r, and \t to their equivalent ascii values and also
- * converts 'C' style octal constants '\123' to their equivalent
- * numeric values. If the first character is equivalent to (d) then
- * a (-1) is returned, if the end of the line is detected then
- * a 'q' error terminates the parse for this line, or if the first
- * character is not a \ then the character value is returned.
+ * The function getmap() converts the 'C' style characters \b, \f,
+ * \n, \r, and \t to their equivalent ascii values and also
+ * converts 'C' style octal constants '\123' to their equivalent
+ * numeric values. If the first character is equivalent to (d) then
+ * a (-1) is returned, if the end of the line is detected then
+ * a 'q' error terminates the parse for this line, or if the first
+ * character is not a \ then the character value is returned.
-/*)Function int lk_getline()
- *
- * The function lk_getline() reads a line of input text from a
- * .rel source text file, a .lnk command file or from stdin.
- * Lines of text are processed from a single .lnk file or
- * multiple .rel files until all files have been read.
- * The input text line is copied into the global string ib[]
- * and converted to a NULL terminated string. The function
- * lk_getline() returns a (1) after succesfully reading a line
- * or a (0) if all files have been read.
- * This function also opens each input .lst file and output
- * .rst file as each .rel file is processed.
- *
- * local variables:
- * int i string length
- * int ftype file type
- * char * fid file name
- *
- * global variables:
- * lfile *cfp The pointer *cfp points to the
- * current lfile structure
- * lfile *filep The pointer *filep points to the
- * beginning of a linked list of
- * lfile structures.
- * int gline get a line from the LST file
- * to translate for the RST file
- * char ib[NINPUT] REL file text line
- * int pass linker pass number
- * int pflag print linker command file flag
- * FILE *rfp The file handle to the current
- * output RST file
- * FILE *sfp The file handle sfp points to the
- * currently open file
- * FILE * stdin c_library
- * FILE * stdout c_library
- * FILE *tfp The file handle to the current
- * LST file being scanned
- * int uflag update listing flag
- *
- * called functions:
- * FILE * afile() lkmain.c
- * int fclose() c_library
- * char * fgets() c_library
- * int fprintf() c_library
- * VOID lkulist() lklist.c
- * VOID lkexit() lkmain.c
- * int strlen() c_library
- *
- * side effects:
- * The input stream is scanned. The .rel files will be
- * opened and closed sequentially scanning each in turn.
+/*)Function int lk_getline()
+ *
+ * The function lk_getline() reads a line of input text from a
+ * .rel source text file, a .lnk command file or from stdin.
+ * Lines of text are processed from a single .lnk file or
+ * multiple .rel files until all files have been read.
+ * The input text line is copied into the global string ib[]
+ * and converted to a NULL terminated string. The function
+ * lk_getline() returns a (1) after succesfully reading a line
+ * or a (0) if all files have been read.
+ * This function also opens each input .lst file and output
+ * .rst file as each .rel file is processed.
+ *
+ * local variables:
+ * int i string length
+ * int ftype file type
+ * char * fid file name
+ *
+ * global variables:
+ * lfile *cfp The pointer *cfp points to the
+ * current lfile structure
+ * lfile *filep The pointer *filep points to the
+ * beginning of a linked list of
+ * lfile structures.
+ * int gline get a line from the LST file
+ * to translate for the RST file
+ * char ib[NINPUT] REL file text line
+ * int pass linker pass number
+ * int pflag print linker command file flag
+ * FILE *rfp The file handle to the current
+ * output RST file
+ * FILE *sfp The file handle sfp points to the
+ * currently open file
+ * FILE * stdin c_library
+ * FILE * stdout c_library
+ * FILE *tfp The file handle to the current
+ * LST file being scanned
+ * int uflag update listing flag
+ *
+ * called functions:
+ * FILE * afile() lkmain.c
+ * int fclose() c_library
+ * char * fgets() c_library
+ * int fprintf() c_library
+ * VOID lkulist() lklist.c
+ * VOID lkexit() lkmain.c
+ * int strlen() c_library
+ *
+ * side effects:
+ * The input stream is scanned. The .rel files will be
+ * opened and closed sequentially scanning each in turn.
- register int ftype;
- register char *fid;
-
-loop: if (pflag && cfp && cfp->f_type == F_STD)
- fprintf(stdout, "ASlink >> ");
-
- if (sfp == NULL || fgets(ib, sizeof ib, sfp) == NULL) {
- if (sfp) {
- fclose(sfp);
- sfp = NULL;
- lkulist(0);
- }
- if (cfp == NULL) {
- cfp = filep;
- } else {
- cfp = cfp->f_flp;
- }
- if (cfp) {
- ftype = cfp->f_type;
- fid = cfp->f_idp;
- if (ftype == F_STD) {
- sfp = stdin;
- } else
- if (ftype == F_LNK) {
- sfp = afile(fid, "lnk", 0);
- } else
- if (ftype == F_REL) {
- sfp = afile(fid, LKOBJEXT, 0);
- /* if a .adb file exists then copy it over */
- if (dflag && sfp && dfp && pass == 0) {
- FILE *xfp = afile(fid,"adb",0); //JCF: Nov 30, 2002
- if (xfp) {
- copyfile(dfp,xfp);
- fclose(xfp);
- }
- }
- if (uflag && pass != 0) {
- SaveLinkedFilePath(fid); //Save the linked path for aomf51
- if ((tfp = afile(fid, "lst", 0)) != NULL) {
- if ((rfp = afile(fid, "rst", 1)) == NULL) {
- fclose(tfp);
- tfp = NULL;
- }
- }
- }
- gline = 1;
- } else {
- fprintf(stderr, "Invalid file type\n");
- lkexit(1);
- }
- if (sfp == NULL) {
- lkexit(1);
- }
- goto loop;
- } else {
- filep = NULL;
- return(0);
- }
- }
- chop_crlf(ib);
- return (1);
+ register int ftype;
+ register char *fid;
+
+loop: if (pflag && cfp && cfp->f_type == F_STD)
+ fprintf(stdout, "ASlink >> ");
+
+ if (sfp == NULL || fgets(ib, sizeof ib, sfp) == NULL) {
+ if (sfp) {
+ fclose(sfp);
+ sfp = NULL;
+ lkulist(0);
+ }
+ if (cfp == NULL) {
+ cfp = filep;
+ } else {
+ cfp = cfp->f_flp;
+ }
+ if (cfp) {
+ ftype = cfp->f_type;
+ fid = cfp->f_idp;
+ if (ftype == F_STD) {
+ sfp = stdin;
+ } else
+ if (ftype == F_LNK) {
+ sfp = afile(fid, "lnk", 0);
+ } else
+ if (ftype == F_REL) {
+ sfp = afile(fid, LKOBJEXT, 0);
+ /* if a .adb file exists then copy it over */
+ if (dflag && sfp && dfp && pass == 0) {
+ FILE *xfp = afile(fid,"adb",0); //JCF: Nov 30, 2002
+ if (xfp) {
+ copyfile(dfp,xfp);
+ fclose(xfp);
+ }
+ }
+ if (uflag && pass != 0) {
+ SaveLinkedFilePath(fid); //Save the linked path for aomf51
+ if ((tfp = afile(fid, "lst", 0)) != NULL) {
+ if ((rfp = afile(fid, "rst", 1)) == NULL) {
+ fclose(tfp);
+ tfp = NULL;
+ }
+ }
+ }
+ gline = 1;
+ } else {
+ fprintf(stderr, "Invalid file type\n");
+ lkexit(1);
+ }
+ if (sfp == NULL) {
+ lkexit(1);
+ }
+ goto loop;
+ } else {
+ filep = NULL;
+ return(0);
+ }
+ }
+ chop_crlf(ib);
+ return (1);