Пример #1
0
bool 
engine::compare_status(ham_status_t st[2])
{
    if (st[0]!=st[1]) {
        TRACE(("status mismatch - %d vs %d\n"
            "       ----> (%s) vs (%s)\n", 
            st[0], st[1],
            ham_strerror(st[0]), ham_strerror(st[1])));
        return false;
    }

    return (true);
}
Пример #2
0
void
error(const char *foo, ham_status_t st)
{
#if UNDER_CE
    wchar_t title[1024];
    wchar_t text[1024];

    MultiByteToWideChar(CP_ACP, 0, foo, -1, title,
            sizeof(title)/sizeof(wchar_t));
    MultiByteToWideChar(CP_ACP, 0, ham_strerror(st), -1, text,
            sizeof(text)/sizeof(wchar_t));

    MessageBox(0, title, text, 0);
#endif
    printf("%s() returned error %d: %s\n", foo, st, ham_strerror(st));
    exit(-1);
}
Пример #3
0
void
read_config(const char *configfile, config_table_t **params)
{
    ham_status_t st;
    char *buf;
    FILE *fp;
    long len;

    hlog(LOG_DBG, "Parsing configuration file %s\n", configfile);

    /* read the whole file into 'buf' */
    fp=fopen(configfile, "rt");
    if (!fp) {
        hlog(LOG_FATAL, "Failed to open config file %s: %s\n", 
                configfile, strerror(errno));
        exit(-1);
    }
    fseek(fp, 0, SEEK_END);
    len=ftell(fp);
    fseek(fp, 0, SEEK_SET);
    buf=(char *)malloc(len+1); /* for zero-terminating byte */
    if (fread(buf, 1, len, fp)!=len) {
        hlog(LOG_FATAL, "Failed to read config file %s: %s\n", 
                configfile, strerror(errno));
        exit(-1);
    }
    fclose(fp);
    buf[len]='\0';

    /* parse the file */
    st=config_parse_string(buf, params);
    if (st) {
        hlog(LOG_FATAL, "failed to read configuration file: %s\n", 
                ham_strerror(st));
        exit(-1);
    }

    /* clean up */
    free(buf);
}
Пример #4
0
void
error(const char *foo, ham_status_t st) {
  printf("%s() returned error %d: %s\n", foo, st, ham_strerror(st));
  exit(-1);
}
Пример #5
0
 /** Returns an English error description. */
 const char *get_string() const {
     return (ham_strerror(m_errno));
 }