#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "spasm.h"
#include "dbfunc.h"

void spasm_error(int syslevel, char *errstr, ...) {
    va_list arglist;

    va_start(arglist, errstr);
    vfprintf(stderr, errstr, arglist);
    fprintf(stderr, "\n");      /* spasm_error args aren't terminated by \n */
    va_end(arglist);
}

int main(int argc, char **argv) {
    struct spasm_list *first;
    struct spasm_list *cur;
    char *buf;

    if((buf = sp_strcat(DB_WHITELIST_DIR, argv[1])) == NULL) exit(1);
    if((first = db_dump_entries(buf, 1)) != NULL) {
        while(first != NULL) {
            cur = first;
            if(cur->strval != NULL && (strcmp(cur->strval, "1") != 0)) printf("%s //%s\n", cur->entry, cur->strval);
            else printf("%s\n", cur->entry);
            first = cur->next;
            free(cur->entry);
            free(cur->strval);
            free(cur);
        }
    }
    free(buf);
    exit(0);
}
