specified; then tries to read .yazclientrc in current directory.
Failing that, it reads .yazclientrc from user's home directory.
+Fixed bug #1157: yaz-client does not read .yazclientrc from current
+directory. yaz-client now reads commands from file given by option -f
+if specified; then tries to read .yazclientrc in current directory.
+Failing that, it reads .yazclientrc from user's home directory.
+
Added support for correlationInfo Note and ID for Record Update via
ZOOM C.
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: client.c,v 1.343 2007-06-03 08:06:31 adam Exp $
+ * $Id: client.c,v 1.344 2007-06-03 14:59:34 adam Exp $
*/
/** \file client.c
* \brief yaz-client program
return 1;
}
-void source_rcfile(void)
+void source_rc_file(const char *rc_file)
{
- /* Look for .yazclientrc and read it if it exists.
+ /* If rc_file != NULL, source that. Else
+ Look for .yazclientrc and read it if it exists.
If it does not exist, read $HOME/.yazclientrc instead */
struct stat statbuf;
- char fname[1000];
- strcpy(fname, ".yazclientrc");
- if (stat(fname, &statbuf)==0)
+ if (rc_file)
{
- cmd_source(fname, 0);
+ if (stat(rc_file, &statbuf) == 0)
+ cmd_source(rc_file, 0);
+ else
+ {
+ fprintf(stderr, "yaz_client: cannot source '%s'\n", rc_file);
+ exit(1);
+ }
}
else
{
- const char* homedir = getenv("HOME");
- if (homedir)
+ char fname[1000];
+ strcpy(fname, ".yazclientrc");
+ if (stat(fname, &statbuf)==0)
{
- sprintf(fname, "%.800s/%s", homedir, ".yazclientrc");
- if (stat(fname, &statbuf)==0)
- cmd_source(fname, 0);
+ cmd_source(fname, 0);
+ }
+ else
+ {
+ const char* homedir = getenv("HOME");
+ if (homedir)
+ {
+ sprintf(fname, "%.800s/%s", homedir, ".yazclientrc");
+ if (stat(fname, &statbuf)==0)
+ cmd_source(fname, 0);
+ }
}
}
}
#endif
}
-static void initialize(void)
+static void initialize(const char *rc_file)
{
FILE *inf;
int i;
cmd_format("usmarc");
- source_rcfile();
+ source_rc_file(rc_file);
file_history = file_history_new();
file_history_load(file_history);
const char *connection_head = z_HTTP_header_lookup(hres->headers,
"Connection");
if (!yaz_srw_check_content_type(hres))
- printf("Content type does not appear to be XML");
+ printf("Content type does not appear to be XML\n");
else
{
Z_SOAP *soap_package = 0;
char *open_command = 0;
char *auth_command = 0;
char *arg;
+ const char *rc_file = 0;
int ret;
#if HAVE_LOCALE_H
ODR_MASK_SET(&z3950_options, Z_Options_delSet);
ODR_MASK_SET(&z3950_options, Z_Options_negotiationModel);
- while ((ret = options("k:c:q:a:b:m:v:p:u:t:Vxd:", argv, argc, &arg)) != -2)
+ while ((ret = options("k:c:q:a:b:m:v:p:u:t:Vxd:f:", argv, argc, &arg)) != -2)
{
switch (ret)
{
case 'v':
yaz_log_init(yaz_log_mask_str(arg), "", 0);
break;
+ case 'f':
+ rc_file = arg;
+ break;
case 'V':
show_version();
break;
exit (1);
}
}
- initialize();
+ initialize(rc_file);
if (auth_command)
{
#ifdef HAVE_GETTIMEOFDAY
<!ENTITY % idcommon SYSTEM "common/common.ent">
%idcommon;
]>
-<!-- $Id: yaz-client-man.xml,v 1.15 2007-06-03 08:06:32 adam Exp $ -->
+<!-- $Id: yaz-client-man.xml,v 1.16 2007-06-03 14:59:34 adam Exp $ -->
<refentry id="yaz-client">
<refentryinfo>
<productname>YAZ</productname>
<arg choice="opt"><option>-b <replaceable>filename</replaceable></option></arg>
<arg choice="opt"><option>-c <replaceable>filename</replaceable></option></arg>
<arg choice="opt"><option>-d <replaceable>dump</replaceable></option></arg>
+ <arg choice="opt"><option>-f <replaceable>cmdfile</replaceable></option></arg>
<arg choice="opt"><option>-k <replaceable>size</replaceable></option></arg>
<arg choice="opt"><option>-m <replaceable>filename</replaceable></option></arg>
<arg choice="opt"><option>-p <replaceable>addr</replaceable></option></arg>
</refsynopsisdiv>
- <refsect1><title>DESCRIPTION</title>
- <para>
- <command>yaz-client</command> is a Z39.50/SRU client (origin) with a
- simple command line interface that allows you to test behavior and
- performance of Z39.50 targets and SRU servers.
- </para>
- <para>
- If the <replaceable>addr</replaceable> is specified, the client creates
- a connection to the Z39.50/SRU target at the address given.
- </para>
+ <refsect1><title>DESCRIPTION</title>
<para>
- When <command>yaz-client</command> is invoked it attemps to read
- <filename>.yazclientrc</filename> from current working directory.
- If <filename>.yazclientrc</filename> does not exist in current directory
- YAZ client reads <filename>.yazclientrc</filename> from the
- home directory, where the home directory is given by environment
- variable <literal>HOME</literal>.
- For those files that are readable, the YAZ client executes commands
- in those files. See COMMANDS section for description of commands.
+ <command>yaz-client</command> is a Z39.50/SRU client (origin) with a
+ simple command line interface that allows you to test behavior and
+ performance of Z39.50 targets and SRU servers.
+ </para>
+ <para>
+ If the <replaceable>addr</replaceable> is specified, the client creates
+ a connection to the Z39.50/SRU target at the address given.
+ </para>
+ <para>
+ When <command>yaz-client</command> is started it tries to read
+ commands from one of the following files:
+ <itemizedlist>
+ <listitem><para>
+ Command file if it is given by option -f.
+ </para></listitem>
+ <listitem><para>
+ <filename>.yazclientrc</filename> in current working directory.
+ </para></listitem>
+ <listitem><para>
+ <filename>.yazclientrc</filename> in the user's home directory.
+ The value of the <literal>HOME</literal> is used to determine
+ the home directory. Normally, <literal>HOME</literal> is only set
+ on POSIX systems such as Linux, FreeBSD, Solaris.
+ </para></listitem>
+ </itemizedlist>
</para>
</refsect1>
<refsect1>
where DDD is 001, 002, 003, ..
</para></listitem>
</varlistentry>
+
+ <varlistentry>
+ <term>-f <replaceable>cmdfile</replaceable></term>
+ <listitem><para>
+ Reads commands from <replaceable>cmdfile</replaceable>. When
+ this option is used, YAZ client does not read .yazclientrc
+ from current directory or home directory.
+ </para></listitem>
+ </varlistentry>
+
<varlistentry>
<term>-k <replaceable>size</replaceable></term>
<listitem><para>