+
+ /* determine host name and port no */
+ sprintf (resource_name, "gw.target.%s", info.target);
+ if (*info.target && ! gw_res_get (info.kernel_res, resource_name, NULL))
+ {
+ /* target is specified, and there is no sub-resource for it... */
+ const char *split;
+
+ if ((split = strchr (info.target, ':')))
+ {
+ memcpy (info.hostname, info.target, split-info.target);
+ info.hostname[split-info.target] = '\0';
+ info.port = atoi (split+1);
+ }
+ else
+ {
+ strcpy (info.hostname, info.target);
+ info.port = gw_res_int (info.kernel_res, "gw.portno", 210);
+ }
+ }
+ else
+ { /* resources gw.hostname and gw.portno will be used */
+ strncpy (info.hostname, gw_res_get (info.kernel_res,
+ "gw.hostname", "localhost"),
+ sizeof(info.hostname)-1);
+ info.port = gw_res_int (info.kernel_res, "gw.portno", 210);
+ strcpy (info.account, gw_res_get (info.kernel_res, "gw.account", ""));
+ info.account_in_session = 0;
+ }
+ /* set info.databases (all available databases for target) */
+ /* set info.database (first database for target) */
+ if (info.databases)
+ free (info.databases);
+ if (info.database)
+ free (info.database);
+ v = gw_res_get (info.kernel_res, "gw.databases", "");
+ info.databases = gw_strdup (v);
+ for (cp = info.databases; (cp = strchr (cp, ' ')); cp++)
+ *cp = ',';
+ v = gw_res_get (info.kernel_res, "gw.database", "");
+ if (*v == '\0' && *info.databases)
+ {
+ int len;
+ cp = strchr (info.databases, ',');
+
+ len = cp ? (cp-info.databases) : strlen (info.databases);
+ info.database = malloc (len+1);
+ assert (info.database);
+ memcpy (info.database, info.databases, len);
+ info.database[len] = '\0';
+ }
+ else
+ {
+ info.database = gw_strdup (v);
+ for (cp = info.database; (cp = strchr (cp, ' ')); cp++)
+ *cp = ',';
+ }
+
+ /* the port no can be explicitly overridden by a command line option */
+ if (info.override_portno)
+ info.port = atoi (info.override_portno);
+
+ /* the hostname can be explicitly overridden by a command line option */
+ if (info.override_hostname)
+ strncpy (info.hostname, info.override_hostname,
+ sizeof(info.hostname)-1);
+
+ ccl_token_and = gw_res_get (info.kernel_res, "ccl.token.and", "and");
+ ccl_token_or = gw_res_get (info.kernel_res, "ccl.token.or", "or");
+ ccl_token_not = gw_res_get (info.kernel_res, "ccl.token.not", "not");
+ ccl_token_set = gw_res_get (info.kernel_res, "ccl.token.set", "set");
+
+ /* determine if more than one result-set names is supported */
+ if (gw_res_bool (info.kernel_res, "gw.result.set", 1))
+ info.setno = 0;
+ else
+ info.setno = -1;
+#if USE_FML
+ if (!info.fml)
+ {
+ v = gw_res_get (info.kernel_res, "gw.fml", "default.fml");
+ fml_inf = fopen (v, "r");
+ if (!fml_inf)
+ gw_log (GW_LOG_WARN, KERNEL_LOG, "cannot open fml script %s", v);
+ else
+ {
+ info.fml = fml_open ();
+ info.fml->read_func = fml_inf_read;
+ info.fml->write_func = fml_inf_write;
+ fml_preprocess (info.fml);
+ fml_exec (info.fml);
+ fclose (fml_inf);
+ }
+ }
+#endif