Re: help needed



Jerry Avins wrote:
dew wrote:

...

Yes, i will be storing only a few string on the database of specified
length.and yes, linear search would do.and like u said, i don think
packing is necessary.

All right. Whether you use pointer arithmetic or array notation, set up the database to look like a two-dimensional array of chars; an array of strings. For linear search, null termination is nearly as efficient as a stored count and will probably produce simpler code. Making the string storage large enough to append a NULL to the longest entry will make a test for maximum length unnecessary. A NULL then always terminates the comparison.

Set the database-entry index to zero (first element).

Get the first character of the database entry. Of it is NULL go on to the next database entry. Without this test, a NULL password will pass unless all database entries contain valid passwords.

1) Set character index to zero.

2) Compare the indexed character of the buffer to the indexed character
of the database entry.

If they match, compare to NULL
If it is NULL, you have a valid password; exit(FOUND)
Otherwise, advance the character index
Otherwise, advance the database-entry index;
set the character index to zero

3) If the data-base index is still in bounds go to (2)
Otherwise exit(NO_MATCH)

Remarks: the buffer and data-base areas should be cleared to NULL before being loaded with data. (If it isn't data, it's NULL.)

CAVEAT: I haven't actually coded this. Take it for what it's worth.

A bug in the numbering, and an efficiency by reordering:

1) Set the database-entry index to zero (first element).

2) Set character index to zero.

3) Get the first character of the database entry. Of it is NULL go on to
the next database entry. Without this test, a NULL password will pass
unless all database entries contain valid passwords.

4) Compare the indexed character of the buffer to the indexed character
of the database entry.

If they match, compare to NULL
If it is NULL, you have a valid password; exit(FOUND)
Otherwise, advance the character index
Otherwise, advance the database-entry index

5) If the data-base index is still in bounds go to (2)
Otherwise exit(NO_MATCH)

Jerry
--
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
.



Relevant Pages

  • Re: Reading messy files with Fortran
    ... In my case the messy files are csv extracts from a database (whose ... I discovered that Fortran sees spurious EOR markers within ... character fields and I couldn't see a rhyme or reason why. ...
    (comp.lang.fortran)
  • Re: Loading a data file containing character fields with different encodings
    ... UTF-8 characters along with Latin-1 characters. ... One containing the latin-1 character set column, the second containing the utf-8 column and of course both files containing the primary key information. ... it would be just as easy to write the loader script that converts the encoding to a "unicode" intermediate format and then load with the correct database encoding. ... This caused that no conversion was done, but you were puting CP1252 characters into an 819 database! ...
    (comp.databases.informix)
  • Re: Are there performancebenefits to reorganizing database-using export/import?
    ... time we had done full export of 8.1.7 database and then created 9.2. ... those warnings are well defined in "Expert Oracle Database ... What happens if you accidentally change the character set when you ... exactly 30 characters long with an empty set character in the column ...
    (comp.databases.oracle.server)
  • Re: Reading messy files with Fortran
    ... In my case the messy files are csv extracts from a database (whose ... I discovered that Fortran sees spurious EOR markers within ... character fields and I couldn't see a rhyme or reason why. ...
    (comp.lang.fortran)
  • Re: help needed
    ... the next database entry. ... unless all database entries contain valid passwords. ... Otherwise, advance the character index ...
    (comp.dsp)