5
* Copyright (c) 1998 peter memishian (meem), meem@gnu.org
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2, or (at your option)
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* General Public License for more details.
17
* $Id: util.h,v 1.4 1999/05/04 01:45:24 meem Exp $
20
#include <sys/types.h>
21
#include <sys/socket.h>
22
#include <netinet/in.h>
25
#define MAX(a, b) ((a) > (b) ? (a) : (b))
29
#define MIN(a, b) ((a) < (b) ? (a) : (b))
32
#define R_BUFMAX 1024 /* bytes */
33
#define R_TIMEOUT_DEFAULT 25 /* seconds */
35
typedef enum { R_READ, R_WRITE } rlpr_io_type_e;
36
typedef enum { R_IO_EOF = 1, R_IO_TIMEOUT, R_IO_ERROR } rlpr_io_status_e;
38
typedef int (*timeout_handler_t)(unsigned int, ssize_t, size_t);
40
/* utility functions */
42
const char ** string_to_args(char *, int *);
44
int bind_try_range(struct sockaddr_in *, int, u_short, u_short);
46
const char * h_strerror(void);
48
int init_sockaddr_in(struct sockaddr_in *, const char *, u_short);
50
void toggle_root(void);
52
int check_ack(int, const char *, int);
56
int copy_file(int, int, int, off_t, const char *);
58
int connect_timed(int, struct sockaddr_in *, int);
60
/* full-i/o operations */
62
ssize_t full_write(int, const void *, size_t, rlpr_io_status_e *);
64
ssize_t full_read_timed(int, void *, size_t, int, timeout_handler_t,
67
ssize_t full_write_timed(int, const void *, size_t, int,
68
timeout_handler_t, rlpr_io_status_e *);