Esempio n. 1
0
int yaz_marc_check_marc21_coding(const char *charset,
                                 const char *marc_buf, int sz)
{
    if (charset && (!yaz_matchstr(charset, "MARC8?") ||
         !yaz_matchstr(charset, "MARC8"))  && marc_buf && sz > 25
        && marc_buf[9] == 'a')
        return 1;
    return 0;
}
Esempio n. 2
0
int yaz_srw_str_to_pack(const char *str)
{
    if (!yaz_matchstr(str, "string"))
        return Z_SRW_recordPacking_string;
    if (!yaz_matchstr(str, "xml"))
        return Z_SRW_recordPacking_XML;
    if (!yaz_matchstr(str, "url"))
        return Z_SRW_recordPacking_URL;
    return -1;
}
Esempio n. 3
0
File: charneg.c Progetto: nla/yaz
static int get_form(const char *charset)
{
    int form = -1;

    if (!yaz_matchstr(charset, "UCS-2"))
        form = 2;
    if (!yaz_matchstr(charset, "UCS-4"))
        form = 4;
    if (!yaz_matchstr(charset, "UTF-16"))
        form = 5;
    if (!yaz_matchstr(charset, "UTF-8"))
        form = 8;

    return form;
}
Esempio n. 4
0
File: http.c Progetto: nla/yaz
const char *z_HTTP_header_lookup(const Z_HTTP_Header *hp, const char *n)
{
    for (; hp; hp = hp->next)
        if (!yaz_matchstr(hp->name, n))
            return hp->value;
    return 0;
}
Esempio n. 5
0
yaz_iconv_decoder_t yaz_advancegreek_decoder(const char *name,
                                             yaz_iconv_decoder_t d)
{
    if (!yaz_matchstr(name, "advancegreek"))
    {
        d->read_handle = read_advancegreek;
        return d;
    }
    return 0;
}
Esempio n. 6
0
yaz_iconv_encoder_t yaz_advancegreek_encoder(const char *name,
                                             yaz_iconv_encoder_t e)
{
    if (!yaz_matchstr(name, "advancegreek"))
    {
        e->write_handle = write_advancegreek;
        return e;
    }
    return 0;
}
Esempio n. 7
0
yaz_iconv_decoder_t yaz_iso5426_decoder(const char *fromcode,
                                      yaz_iconv_decoder_t d)
{
    if (!yaz_matchstr(fromcode, "ISO5426"))
        d->read_handle = read_iso5426;
    else
        return 0;
    {
        struct decoder_data *data = (struct decoder_data *)
            xmalloc(sizeof(*data));
        d->data = data;
        d->init_handle = init_iso5426;
        d->destroy_handle = destroy_iso5426;
    }
    return d;
}
Esempio n. 8
0
File: initopt.c Progetto: nla/yaz
int yaz_init_opt_encode(Z_Options *opt, const char *opt_str, int *error_pos)
{
    const char *cp = opt_str;

    ODR_MASK_ZERO(opt);
    while (*cp)
    {
        char this_opt[42];
        size_t i, j;
        if (*cp == ' ' || *cp == ',')
        {
            cp++;
            continue;
        }
        for (i = 0; i < (sizeof(this_opt)-1) &&
                 cp[i] && cp[i] != ' ' && cp[i] != ','; i++)
            this_opt[i] = cp[i];
        this_opt[i] = 0;
        for (j = 0; opt_array[j].name; j++)
        {
            if (yaz_matchstr(this_opt, opt_array[j].name) == 0)
            {
                ODR_MASK_SET(opt, opt_array[j].opt);
                break;
            }
        }
        if (!opt_array[j].name)
        {
            if (error_pos)
            {
                *error_pos = cp - opt_str;
                return -1;
            }
        }
        cp += i;
    }
    return 0;
}
Esempio n. 9
0
static int my_search(void *handle, bend_search_rr *rr)
{
    struct my_handle *my_p = (struct my_handle *) handle;

    if (rr->num_bases != 1)
    {
        rr->errcode = YAZ_BIB1_COMBI_OF_SPECIFIED_DATABASES_UNSUPP;
        return 0;
    }
    /* Throw Database unavailable if other than Default */
    if (!yaz_matchstr (rr->basenames[0], "Default"))
        ;  /* Default is OK in our test */
    else
    {
        rr->errcode = YAZ_BIB1_DATABASE_UNAVAILABLE;
        rr->errstring = rr->basenames[0];
        return 0;
    }

    rr->hits = 123; /* dummy hit count */
    my_p->counter++;
    return 0;
}
Esempio n. 10
0
int ztest_search (void *handle, bend_search_rr *rr)
{
  int err;
  char query[1024];
  char query_final[2048];
  char err_string[255];
  int i;
  
  if (strcmp(rr->setname,"1")) {
    rr->errcode = 2;
    return 0;
  }
    
   //Si la requete n'est pas de type_1
  if (rr->query->which!=2) {
    rr->errcode = 107;
    return 0;
  }

  err=get_query(query,rr->query->u.type_1->RPNStructure,err_string,0);
  if (!err) {  
    yaz_log(LOG_LOG,"Translated Query = %s",query);
  } else {
      rr->errcode = err;
      rr->errstring = err_string;
      return 0;
    }

    if (rr->num_bases != 1)
    {
        rr->errcode = 23;
        return 0;
    }
    if (yaz_matchstr (rr->basenames[0], database))
    {
        rr->errcode = 109;
        rr->errstring = rr->basenames[0];
        return 0;
    }
  
  	/* Lancement de la recherche */
  	sprintf(query_final,"query=%s&command=search",url_encode(query));
  	yaz_log(LOG_LOG,"query:%s",query_final);
  	
  	if (http_get(query_final)) {
  		rr->errcode=2;
  		return 0;	
  	}
  	if (http_err==3) {
  			rr->errcode=114;
  			rr->errstring=http_err_string;
  			return 0;
  	}
  	strcpy(id_set,http_content);
  	
  	n_results=atoi(strtok(id_set,"@"));
  	cur_results=0;
  	i=0;
  	while ((ids[i]=strtok(NULL,"@"))!=NULL) {
  		i++;
  	}
 	
 	rr->hits = n_results;
    return 0;
}
Esempio n. 11
0
int main (int argc, char **argv)
{
    YAZ_CHECK_INIT(argc, argv);

    YAZ_CHECK(yaz_matchstr("x", "x") == 0);
    YAZ_CHECK(yaz_matchstr("x", "X") == 0);
    YAZ_CHECK(yaz_matchstr("a", "b") > 0);
    YAZ_CHECK(yaz_matchstr("b", "a") > 0);
    YAZ_CHECK(yaz_matchstr("aa","a") > 0);
    YAZ_CHECK(yaz_matchstr("a-", "a") > 0);
    YAZ_CHECK(yaz_matchstr("A-b", "ab") == 0);
    YAZ_CHECK(yaz_matchstr("A--b", "ab") > 0);
    YAZ_CHECK(yaz_matchstr("A--b", "a-b") > 0);
    YAZ_CHECK(yaz_matchstr("A--b", "a--b") == 0);
    YAZ_CHECK(yaz_matchstr("a123",  "a?") == 0);
    YAZ_CHECK(yaz_matchstr("a123",   "a1.3") == 0);
    YAZ_CHECK(yaz_matchstr("a123",   "..?") == 0);
    YAZ_CHECK(yaz_matchstr("a123",   "a1.") > 0);
    YAZ_CHECK(yaz_matchstr("a123",   "a...") == 0);

    YAZ_CHECK_TERM;
}