* Europagate, 1995
*
* $Log: urp.c,v $
- * Revision 1.27 1995/04/19 10:46:19 adam
+ * Revision 1.31 1995/05/01 12:43:38 adam
+ * First work on resource monitor program.
+ *
+ * Revision 1.30 1995/04/20 16:10:47 adam
+ * Modified to work with non-blocking zass-api. Not using non-blocking
+ * facility yet.
+ *
+ * Revision 1.29 1995/04/19 16:01:58 adam
+ * Some hacks to get the FIFO communication work!! Isn't reliable.
+ * Resource gw.account added - default account info.
+ *
+ * Revision 1.28 1995/04/19 13:19:09 adam
+ * New command: account - for authentication.
+ *
+ * Revision 1.27 1995/04/19 10:46:19 adam
* Persistency works much better now. New command: status - history-like
*
* Revision 1.26 1995/04/19 07:31:12 adam
#include <unistd.h>
#include <fcntl.h>
+#include <lgets.h>
#include <ttyemit.h>
#include <strqueue.h>
#include "kernel.h"
tty_emit (*s++);
}
-int lgets (char *buf, int max, int fd)
-{
- int r, no = 0;
-
- --max;
- while (no <= max)
- {
- if ((r=read (fd, buf+no, 1)) != 1)
- {
- if (r == -1)
- gw_log (GW_LOG_WARN|GW_LOG_ERRNO, KERNEL_LOG, "read fail");
- buf[no] = '\0';
- return 0;
- }
- if (buf[no] == 1)
- return 0;
- if (buf[no++] == '\n')
- break;
- }
- buf[no] = '\0';
- return 1;
-}
-
int reopen_target (void)
{
const char *v;
if (info.zass)
gw_log (GW_LOG_WARN, KERNEL_LOG, "Zass free...");
gw_log (GW_LOG_DEBUG, KERNEL_LOG, "reopen_target");
- info.zass = zass_open (info.hostname, info.port);
+ info.zass = zass_open (info.hostname, info.port, NULL, /* complete */
+ *info.account ? info.account : NULL);
if (!info.zass)
{
gw_log (GW_LOG_DEBUG, KERNEL_LOG, "Cannot connect to target %s:%d",
{ "cancel", "cancel" },
{ "target", "target" },
{ "stop", "stop" },
+{ "account", "account" },
{ NULL, NULL }
};
return 0;
}
+static int exec_account (struct ccl_token *list)
+{
+ if (list->kind != CCL_TOK_EOL)
+ {
+ int len = list->len;
+ memcpy (info.account, list->name, len);
+ info.target[len] = '\0';
+ }
+ else
+ *info.account = '\0';
+ return 0;
+}
+
static int exec_target (struct ccl_token *list)
{
int len;
if (cmd->kind != CCL_TOK_EOL &&
(no = command_search (command_tab, cmd, "ccl.command.")))
{
- if (!info.zass && no != 9 && no != 4)
+ if (!info.zass && no != 9 && no != 4 && no != 11 && no != 7)
reopen_target ();
fprintf (reply_fd, "\n> %s\n", str);
if (!info.zass && (no == 1 || no == 2 || no == 3))
return exec_status (cmd->next);
case 9:
return exec_target (cmd->next);
+ case 11:
+ return exec_account (cmd->next);
default:
fprintf (reply_fd, "%s\n",
gw_res_get (info.kernel_res, "gw.err.unimplemented",