home *** CD-ROM | disk | FTP | other *** search
-
- SUBROUTINE ptkf_inithashtables()
- C /*
- C ** \blurb{This function initialises the table in which the details of
- C ** hashtables created by the application are kept. This function
- C ** must be called before any other hashtable functions.}
- C */
- external ptk_inithashtables !$PRAGMA C(ptk_inithashtables)
-
- call ptk_inithashtables()
-
- RETURN
- END
-
- LOGICAL FUNCTION ptkf_hashtableused(str)
- C /*
- C ** \parambegin
- C ** \param{CHARACTER*(*)}{str}{name of hashtable}{IN}
- C ** \paramend
- C ** \blurb{This function checks if a hashtable named \pardesc{str}
- C ** already exists in the table of
- C ** hashtables, returning TRUE if the hashtable exists, otherwise FALSE.}
- C */
- CHARACTER*(*) str
- LOGICAL*1 ptk_hashtableused, ans
- external ptk_hashtableused !$PRAGMA C(ptk_hashtableused)
-
- ans = ptk_hashtableused(str)
- if (ans .eq. 1) then
- ptkf_hashtableused = .TRUE.
- else
- ptkf_hashtableused = .FALSE.
- endif
-
- RETURN
- END
-
- SUBROUTINE ptkf_createhashtable(tablestr, minid, maxid)
- C /*
- C ** \parambegin
- C ** \param{CHARACTER*(*)}{tablestr}{hashtable name}{IN}
- C ** \param{INTEGER}{minid}{lower limit of string-integer range}{IN}
- C ** \param{INTEGER}{maxid}{upper limit of string-integer range}{IN}
- C ** \paramend
- C ** \blurb{This function creates a new hashtable, with the name
- C ** \pardesc{tablestr}.
- C ** \pardesc{minid} and \pardesc{maxid} respectively specify the lower and
- C ** upper limits of the range of
- C ** integers to which strings hashed into the hashtable will be mapped.}
- C */
- CHARACTER*(*) tablestr
- INTEGER minid, maxid
- external ptk_createhashtable !$PRAGMA C(ptk_createhashtable)
-
- call ptk_createhashtable(tablestr, %val(minid), %val(maxid))
-
- RETURN
- END
-
- SUBROUTINE ptkf_inttostring(tablestr, stint, size, strbuffer,
- & buffersize)
- C /*
- C ** \parambegin
- C ** \param{CHARACTER*(*)}{tablestr}{hashtable name}{IN}
- C ** \param{INTEGER}{stint}{string identifier to search hashtable for}{IN}
- C ** \param{INTEGER}{size}{number of bytes allocated by the user for the
- C ** string}{IN}
- C ** \param{CHARACTER*(*)}{strbuffer}{pointer to space allocated by the user
- C ** for the string}{OUT}
- C ** \param{INTEGER}{buffersize}{actual size of buffer required}{OUT}
- C ** \paramend
- C ** \blurb{This function returns the string in hashtable \pardesc{tablestr}
- C ** which has been allocated the integer
- C ** \pardesc{stint}. The string is returned in the buffer
- C ** \pardesc{strbuffer},
- C ** which must be allocated by the application. The number of bytes
- C ** actually used
- C ** in the buffer is returned in \pardesc{buffersize}, as
- C ** the length of string + 1 (for `\\0' character),
- C ** or 0 if no string was returned.}
- C */
- CHARACTER*(*) tablestr
- INTEGER stint, size
- CHARACTER*(*) strbuffer
- INTEGER buffersize
- CHARACTER*255 inbuf
- external ptk_inttostring !$PRAGMA C(ptk_inttostring)
-
- call ptk_inttostring(tablestr, %val(stint), 255, inbuf,
- & buffersize)
- buffersize = buffersize - 1
- if (size .le. 255) then
- strbuffer = inbuf(1:buffersize)
- endif
-
- RETURN
- END
-
- INTEGER FUNCTION ptkf_stringtoint(tablestr, str)
- C /*
- C ** \parambegin
- C ** \param{CHARACTER*(*)}{tablestr}{name of hashtable}{IN}
- C ** \param{CHARACTER*(*)}{str}{string to be searched for in string table}{IN}
- C ** \paramend
- C ** \blurb{This function returns the integer allocated for the string
- C ** \pardesc{str}
- C ** in hashtable \pardesc{tablestr}.
- C ** If the string has not already been allocated an integer,
- C ** then it is allocated one and this value is
- C ** returned.}
- C */
- CHARACTER*(*) tablestr, str
- INTEGER ptk_stringtoint
- CHARACTER*255 inbuf
- external ptk_stringtoint !$PRAGMA C(ptk_stringtoint)
-
- inbuf = str//'\0'
- ptkf_stringtoint = ptk_stringtoint(tablestr, inbuf)
-
- RETURN
- END
-
- LOGICAL FUNCTION ptkf_delstring(tablestr, str)
- C /*
- C ** \parambegin
- C ** \param{CHARACTER*(*)}{tablestr}{name of hashtable}{IN}
- C ** \param{CHARACTER*(*)}{delstr}{string to be deleted from string table}{IN}
- C ** \paramend
- C ** \blurb{This function deletes the string \pardesc{delstr} from hashtable
- C ** \pardesc{tablestr}. The result of the function is
- C ** TRUE if the string was deleted, otherwise FALSE.}
- C */
- CHARACTER*(*) tablestr, str
- LOGICAL*1 ptk_delstring, ans
- CHARACTER*255 inbuf
- external ptk_delstring !$PRAGMA C(ptk_delstring)
-
- inbuf = str//'\0'
- ans = ptk_delstring(tablestr, inbuf)
- if (ans .eq. 1) then
- ptkf_delstring = .TRUE.
- else
- ptkf_delstring = .FALSE.
- endif
-
- RETURN
- END
-
- LOGICAL FUNCTION ptkf_delhashtable(tablestr)
- C /*
- C ** \parambegin
- C ** \param{CHARACTER*(*)}{tablestr}{name of table to be deleted}{IN}
- C ** \paramend
- C ** \blurb{This function deletes hashtable \pardesc{tablestr} from the
- C ** table of hashtables,
- C ** returning TRUE if the table was deleted, otherwise FALSE.}
- C */
- CHARACTER*(*) tablestr
- LOGICAL*1 ptk_delhashtable, ans
- external ptk_delhashtable !$PRAGMA C(ptk_delhashtable)
-
- ans = ptk_delhashtable(tablestr)
- if (ans .eq. 1) then
- ptkf_delhashtable = .TRUE.
- else
- ptkf_delhashtable = .FALSE.
- endif
-
- RETURN
- END
-
- LOGICAL FUNCTION ptkf_stringused(tablestr, str)
- C /*
- C ** \parambegin
- C ** \param{CHARACTER*(*)}{tablestr}{name of hashtable}{IN}
- C ** \param{CHARACTER*(*)}{str}{string to search for in string table}{IN}
- C ** \paramend
- C ** \blurb{This function checks if the string \pardesc{str}
- C ** has already been used in hashtable \pardesc{tablestr},
- C ** Returning TRUE if string was used in the hashtable, otherwise FALSE.}
- C */
- CHARACTER*(*) tablestr, str
- LOGICAL*1 ptk_stringused, ans
- external ptk_stringused !$PRAGMA C(ptk_stringused)
-
- ans = ptk_stringused(tablestr, str)
- if (ans .eq. 1) then
- ptkf_stringused = .TRUE.
- else
- ptkf_stringused = .FALSE.
- endif
-
- RETURN
- END
-
- SUBROUTINE ptkf_storehashtable(fileptr, tablestr)
- C /*
- C ** \parambegin
- C ** \param{INTEGER}{fileptr}{pointer to a file}{IN}
- C ** \param{CHARACTER*(*)}{table}{hashtable to store}{IN}
- C ** \paramend
- C ** \blurb{The function writes the hashtable \pardesc{tablestr} to the
- C ** file \pardesc{fileptr}, which should be opened for writing.}
- C */
- INTEGER fileptr
- CHARACTER*(*) tablestr
- external ptk_storehashtable !$PRAGMA C(ptk_storehashtable)
-
- call ptk_storehashtable(getfilep(fileptr), tablestr)
-
- RETURN
- END
-
- SUBROUTINE ptkf_storeallhashtables(fileptr)
- C /*
- C ** \parambegin
- C ** \param{INTEGER}{fileptr}{pointer to a file}{IN}
- C ** \paramend
- C ** \blurb{The function writes all the hashtables in the table of hashtables
- C ** to the
- C ** file \pardesc{fileptr}, which should be opened for writing.}
- C */
- INTEGER fileptr
- external ptk_storeallhashtables
- & !$PRAGMA C(ptk_storeallhashtables)
-
- call ptk_storeallhashtables(getfilep(fileptr))
-
- RETURN
- END
-
- SUBROUTINE ptkf_restorehashtable(fileptr, tablestr)
- C /*
- C ** \parambegin
- C ** \param{INTEGER}{fileptr}{pointer to a file}{IN}
- C ** \param{CHARACTER*(*)}{tablestr}{hashtable to insert data from file}{IN}
- C ** \paramend
- C ** \blurb{This function reads a hashtable from the file \pardesc{fileptr},
- C ** and creates it with the name \pardesc{tablestr}. If the hashtable
- C ** already exists,
- C ** it is deleted, and then recreated from the file. The file should be open
- C ** for reading when this function is called.}
- C */
- INTEGER fileptr
- CHARACTER*(*) tablestr
- external ptk_restorehashtable !$PRAGMA C(ptk_restorehashtable)
-
- call ptk_restorehashtable(getfilep(fileptr), tablestr)
-
- RETURN
- END
-
- SUBROUTINE ptkf_restoreallhashtables(fileptr)
- C /*
- C ** \parambegin
- C ** \param{INTEGER}{fileptr}{pointer to a file}{IN}
- C ** \paramend
- C ** \blurb{This function restores all hashtables from a file. Effectively,
- C ** \pardesc{ptk\_restorehashtable} (q.v.) is called for each hashtable in
- C ** the file. The file should
- C ** be open for reading when this function is called.}
- C */
- INTEGER fileptr
- external ptk_restoreallhashtables
- & !$PRAGMA C(ptk_restoreallhashtables)
-
- call ptk_restoreallhashtables(getfilep(fileptr))
-
- RETURN
- END
-
- C end of hash.f
-
-