All pastes #476695 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-05-08 08:48 UTC
rendered paste body
bool czor_register_hash (char *hash, bool spam)

{

        czor_d db_record;

        // Check firstly if the hash is present

        if (czor_key_exists (hash)) {

                // The hash is in the database so load it and update the record

                if (czor_load_record (hash, &db_record) == FALSE) {

                        printf ("Failed to load...\n");
                        return (FALSE);

                }

                printf ("Key Exists!!!!\n");
                return (TRUE);

        }

        // The hash is not present, so we need to create a new entry

        printf ("Key does not exist, so I am going to create an entry!\n");
        return (TRUE);

}





/****************************************
*   Load given keys data to a record    *
****************************************/

bool czor_load_record (char *hash, struct czor_d *dest)

{

        datum key, data;

        key.dsize = strlen (hash);
        key.dptr = hash;
        data = gdbm_fetch (dbf, key);

        if (data.dsize == 0) {

                printf ("ERROR: Failed to load record of hash %s\n", hash);
                exit (2);

        }

        // Data loaded, now convert the ASCII values to respective structure values
        dest->client_version = 1;


-----------------------------