+ sprintf (resource_name, "gw.target.%s", info.target);
+ if (*info.target && ! gw_res_get (info.kernel_res, resource_name, NULL))
+ {
+ /* target is there, and there is no sub-resource for it... */
+ char *split;
+
+ if ((split = strchr (info.target, ':')))
+ *split++ = '\0';
+ strncpy (info.hostname, info.target, sizeof(info.hostname)-1);
+ if (split)
+ info.port = atoi (split);
+ else
+ info.port = atoi (gw_res_get
+ (info.kernel_res, "gw.portno", "210"));
+ }
+ else
+ {
+ strncpy (info.hostname, gw_res_get (info.kernel_res,
+ "gw.hostname", "localhost"),
+ sizeof(info.hostname)-1);
+ info.port = atoi (gw_res_get (info.kernel_res,
+ "gw.portno", "210"));
+ }
+ 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 = ',';
+ }
+ if (info.override_portno)
+ info.port = atoi (info.override_portno);
+ if (info.override_hostname)
+ strncpy (info.hostname, info.override_hostname,
+ sizeof(info.hostname)-1);
+ v = gw_res_get (info.kernel_res, "gw.result.set", NULL);
+ info.setno = v ? -1 : 0;
+#if USE_FML
+ if (!info.fml)
+ {
+ v = gw_res_get (info.kernel_res, "gw.fml", "default.fml");
+ sprintf (fname, "%s/%s", path_prefix, v);
+ fml_inf = fopen (fname, "r");
+ if (!fml_inf)
+ gw_log (GW_LOG_WARN, KERNEL_LOG,
+ "cannot open fml script %s", fname);
+ 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