~ubuntu-branches/ubuntu/lucid/rlpr/lucid

« back to all changes in this revision

Viewing changes to src/util.h

  • Committer: Bazaar Package Importer
  • Author(s): Brian Mays
  • Date: 2002-03-20 11:21:15 UTC
  • Revision ID: james.westby@ubuntu.com-20020320112115-whl7m242ig71nu3h
Tags: upstream-2.02
ImportĀ upstreamĀ versionĀ 2.02

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef UTIL_H
 
2
#define UTIL_H
 
3
 
 
4
/*
 
5
 * Copyright (c) 1998 peter memishian (meem), meem@gnu.org
 
6
 *
 
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)
 
10
 * any later version.
 
11
 *
 
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.
 
16
 *
 
17
 * $Id: util.h,v 1.4 1999/05/04 01:45:24 meem Exp $
 
18
 */
 
19
 
 
20
#include <sys/types.h>
 
21
#include <sys/socket.h>
 
22
#include <netinet/in.h>
 
23
 
 
24
#ifndef MAX
 
25
#define MAX(a, b)       ((a) > (b) ? (a) : (b))
 
26
#endif
 
27
 
 
28
#ifndef MIN
 
29
#define MIN(a, b)       ((a) < (b) ? (a) : (b))
 
30
#endif
 
31
 
 
32
#define R_BUFMAX                1024            /* bytes */
 
33
#define R_TIMEOUT_DEFAULT       25              /* seconds */
 
34
 
 
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;
 
37
 
 
38
typedef int   (*timeout_handler_t)(unsigned int, ssize_t, size_t);
 
39
 
 
40
/* utility functions */
 
41
 
 
42
const char **   string_to_args(char *, int *);
 
43
 
 
44
int             bind_try_range(struct sockaddr_in *, int, u_short, u_short);
 
45
 
 
46
const char *    h_strerror(void);
 
47
 
 
48
int             init_sockaddr_in(struct sockaddr_in *, const char *, u_short);
 
49
 
 
50
void            toggle_root(void);
 
51
 
 
52
int             check_ack(int, const char *, int);
 
53
 
 
54
off_t           file_size(int);
 
55
 
 
56
int             copy_file(int, int, int, off_t, const char *);
 
57
 
 
58
int             connect_timed(int, struct sockaddr_in *, int);
 
59
 
 
60
/* full-i/o operations */
 
61
 
 
62
ssize_t         full_write(int, const void *, size_t, rlpr_io_status_e *);
 
63
 
 
64
ssize_t         full_read_timed(int, void *, size_t, int, timeout_handler_t,
 
65
                                rlpr_io_status_e *);
 
66
 
 
67
ssize_t         full_write_timed(int, const void *, size_t, int,
 
68
                                 timeout_handler_t, rlpr_io_status_e *);
 
69
#endif /* UTIL_H */