server->proxy_host = nmem_strdup(nmem, (const char *) host);
if (myurl)
server->myurl = nmem_strdup(nmem, (const char *) myurl);
-#ifdef GAGA
- else
- {
- yaz_log(YLOG_FATAL, "Must specify @myurl for proxy");
- return 0;
- }
-#endif
xmlFree(port);
xmlFree(host);
xmlFree(myurl);
}
}
-#ifdef GAGA
-// Calculate length of chain
-static int http_buf_len(struct http_buf *b)
-{
- int sum = 0;
- for (; b; b = b->next)
- sum += b->len;
- return sum;
-}
-#endif
-
static struct http_buf *http_buf_bybuf(char *b, int len)
{
struct http_buf *res = 0;
}
}
-#ifdef GAGA
-// If this hostname contains our proxy host as a prefix, replace with myurl
-static char *sub_hostname(struct http_channel *c, char *buf)
-{
- char tmp[1024];
- if (strlen(buf) > 1023)
- return buf;
- if (strncmp(buf, "http://", 7))
- return buf;
- if (!strncmp(buf + 7, proxy_url, strlen(proxy_url)))
- {
- strcpy(tmp, myurl);
- strcat(tmp, buf + strlen(proxy_url) + 7);
- return nmem_strdup(c->nmem, tmp);
- }
- return buf;
-}
-#endif
-
// Handles I/O on a client connection to a backend web server (proxy mode)
static void proxy_io(IOCHAN pi, int event)
{
htbuf->buf[res] = '\0';
htbuf->offset = 0;
htbuf->len = res;
-#ifdef GAGA
- if (pc->first_response) // Check if this is a redirect
- {
- int len;
- if ((len = package_check(htbuf->buf)))
- {
- struct http_response *res = http_parse_response_buf(hc, htbuf->buf, len);
- if (res)
- {
- const char *location = http_lookup_header(
- res->header, "Location");
- if (location)
- {
- // We found a location header. Rewrite it.
- struct http_buf *buf;
- h->value = sub_hostname(hc, location);
- buf = http_serialize_response(hc, res);
- yaz_log(YLOG_LOG, "Proxy rewrite");
- http_buf_enqueue(&hc->oqueue, buf);
- htbuf->offset = len;
- break;
- }
- }
- }
- pc->first_response = 0;
- }
-#endif
// Write any remaining payload
if (htbuf->len - htbuf->offset > 0)
http_buf_enqueue(&hc->oqueue, htbuf);
if (this_max > (*wheretoput)->data.number.max)
(*wheretoput)->data.number.max = this_max;
}
-#ifdef GAGA
- if (ser_sk)
- {
- union data_types *sdata
- = cluster->sortkeys[sk_field_id];
- yaz_log(YLOG_LOG, "SK range: %d-%d",
- sdata->number.min, sdata->number.max);
- }
-#endif
}
r->doc_frequency_vec[0]++;
}
-#ifdef GAGA
-#ifdef FLOAT_REL
-static int comp(const void *p1, const void *p2)
-{
- float res;
- struct record **r1 = (struct record **) p1;
- struct record **r2 = (struct record **) p2;
- res = (*r2)->relevance - (*r1)->relevance;
- if (res > 0)
- return 1;
- else if (res < 0)
- return -1;
- else
- return 0;
-}
-#else
-static int comp(const void *p1, const void *p2)
-{
- struct record_cluster **r1 = (struct record_cluster **) p1;
- struct record_cluster **r2 = (struct record_cluster **) p2;
- return (*r2)->relevance - (*r1)->relevance;
-}
-#endif
-#endif
-
// Prepare for a relevance-sorted read
void relevance_prepare_read(struct relevance *rel, struct reclist *reclist)
{
}
rec->relevance = (int) (relevance * 100000);
}
-#ifdef GAGA
- qsort(reclist->flatlist, reclist->num_records, sizeof(struct record*), comp);
-#endif
reclist->pointer = 0;
xfree(idfvec);
}
if (!match_zurl(db->url, set->target))
return;
-#ifdef GAGA
- // Initialize settings array if it doesn't exist.
- // If so, also set the 'id' automatic setting
- if (!db->settings)
- {
- struct setting *id = nmem_malloc(nmem, sizeof(struct setting));
-
- db->settings = nmem_malloc(nmem, sizeof(struct settings*) * dictionary->num);
- memset(db->settings, 0, sizeof(struct settings*) * dictionary->num);
- id->precedence = 0;
- id->name = "pz:id";
- id->target = id->value = db->url;
- id->next = 0;
- db->settings[PZ_ID] = id;
- }
-#endif
if ((offset = settings_offset_cprefix(set->name)) < 0)
abort(); // Should never get here