/*
* Copyright (C) 2004-2006, 2008 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1996, 1998-2001, 2003 Internet Software Consortium.
*
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#if !defined(LINT) && !defined(CODECENTER)
#endif
/* Imports */
#include "port_before.h"
#include <syslog.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <stdarg.h>
#include <fcntl.h>
#include <syslog.h>
#include <ctype.h>
#include <unistd.h>
#include <isc/memcluster.h>
#include <irs.h>
#include <irp.h>
#include "irs_p.h"
#include "irp_p.h"
#include "port_after.h"
/* Forward. */
#if !defined(SUN_LEN)
#endif
/* Public */
/* send errors to syslog if true. */
/*%
* This module handles the irp module connection to irpd.
*
* The client expects a synchronous interface to functions like
* getpwnam(3), so we can't use the ctl_* i/o library on this end of
* the wire (it's used in the server).
*/
/*%
* irs_acc *irs_irp_acc(const char *options);
*
* Initialize the irp module.
*/
struct irs_acc *
return (NULL);
}
return (NULL);
}
#ifdef WANT_IRS_GR
#else
#endif
#ifdef WANT_IRS_PW
#else
#endif
return (acc);
}
int
if (irs_irp_is_connected(cxndata)) {
return (0);
} else if (irs_irp_connect(cxndata) != 0) {
(*warned)++;
}
return (-1);
}
return (0);
}
/*%
* int irs_irp_connect(void);
*
* Sets up the connection to the remote irpd server.
*
* Returns:
*
* 0 on success, -1 on failure.
*
*/
int
int flags;
#ifndef NO_SOCKADDR_UN
#endif
long ipaddr;
const char *irphost;
int code;
int socklen = 0;
perror("fd != 1");
return (-1);
}
#ifndef NO_SOCKADDR_UN
#endif
irphost = "127.0.0.1";
}
#ifndef NO_SOCKADDR_UN
if (irphost[0] == '/') {
#ifdef HAVE_SA_LEN
#endif
} else
#endif
{
perror("inet_pton");
return (-1);
}
#ifdef HAVE_SA_LEN
#endif
}
perror("socket");
return (-1);
}
perror("connect");
return (-1);
}
if (flags < 0) {
perror("close");
return (-1);
}
#if 0
flags |= O_NONBLOCK;
perror("fcntl");
return (-1);
}
#endif
if (code != IRPD_WELCOME_CODE) {
if (irp_log_errors) {
}
return (-1);
}
return (0);
}
/*%
* int irs_irp_is_connected(struct irp_p *pvt);
*
* Returns:
*
* Non-zero if streams are setup to remote.
*
*/
int
}
/*%
* void
* irs_irp_disconnect(struct irp_p *pvt);
*
* Closes streams to remote.
*/
void
}
}
int
int spare;
int i;
int buffpos = 0;
while (left > 0) {
while (p != end && *p != '\n')
p++;
if (p == end) {
/* Found no newline so shift data down if necessary
* and append new data to buffer
*/
}
p = end;
if (i < 0) {
} else if (i == 0) {
return (buffpos);
}
end += i;
while (p != end && *p != '\n')
p++;
}
if (p == end) {
/* full buffer and still no newline */
} else {
/* include newline */
i = p - start + 1;
}
if (i > left)
i = left;
buffpos += i;
if (p != end) {
left = 0;
} else {
left -= i;
}
}
#if 0
#endif
return (buffpos);
}
/*%
* int irp_read_response(struct irp_p *pvt);
*
* Returns:
*
* The number found at the beginning of the line read from
* FP. 0 on failure(0 is not a legal response code). The
* rest of the line is discarded.
*
*/
int
int code;
char *p;
return (0);
}
if (p == NULL) {
return (0);
}
code = 0;
p = line;
while (isspace((unsigned char)*p)) p++;
while (isdigit((unsigned char)*p)) p++;
while (isspace((unsigned char)*p)) p++;
}
return (code);
}
/*%
* char *irp_read_body(struct irp_p *pvt, size_t *size);
*
* Read in the body of a response. Terminated by a line with
* just a dot on it. Lines should be terminated with a CR-LF
* sequence, but we're nt piccky if the CR is missing.
* No leading dot escaping is done as the protcol doesn't
* use leading dots anywhere.
*
* Returns:
*
* Pointer to null-terminated buffer allocated by memget.
* *SIZE is set to the length of the buffer.
*
*/
char *
int idx = 0;
return (NULL);
for (;;) {
goto death;
goto death;
/* We're not strict about missing \r. Should we be?? */
linelen--;
}
return (buffer);
}
if (p == NULL)
goto death;
buffer = p;
}
}
return (NULL);
}
/*%
* int irs_irp_get_full_response(struct irp_p *pvt, int *code,
* char **body, size_t *bodylen);
*
* Gets the response to a command. If the response indicates
* there's a body to follow(code % 10 == 1), then the
* body buffer is allcoated with memget and stored in
* *BODY. The length of the allocated body buffer is stored
* in *BODY. The caller must give the body buffer back to
* memput when done. The results code is stored in *CODE.
*
* Returns:
*
* 0 if a result was read. -1 on some sort of failure.
*
*/
int
if (result == 0) {
return (-1);
}
/* Code that matches 2xx is a good result code.
* Code that matches xx1 means there's a response body coming.
*/
return (-1);
}
}
return (0);
}
/*%
* int irs_irp_send_command(struct irp_p *pvt, const char *fmt, ...);
*
* Sends command to remote connected via the PVT
* structure. FMT and args after it are fprintf-like
* arguments for formatting.
*
* Returns:
*
* 0 on success, -1 on failure.
*/
int
int pos = 0;
int i, todo;
return (-1);
}
exit(1);
}
while (todo > 0) {
#if 0
/* XXX brister */
#endif
if (i < 0) {
return (-1);
}
todo -= i;
}
return (0);
}
/* Methods */
/*%
* void irp_close(struct irs_acc *this)
*
*/
static void
}
}
/*! \file */