File: general.h

package info (click to toggle)
ezbounce 0.99.12-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 712 kB
  • ctags: 776
  • sloc: cpp: 7,243; makefile: 182; sh: 153; ansic: 102
file content (88 lines) | stat: -rw-r--r-- 2,014 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//  general.h
/* 
 *  part of ezbounce
 */

#ifndef __general_h
#define __general_h


#undef SUPER_MY_STRDUP

#include <sys/types.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <unistd.h>
#ifdef HAVE_STDARG_H
#include <stdarg.h>
#endif
#include <netinet/in.h>
#include <sys/socket.h>
#ifdef HAVE_SYS_TIME_H
#include <time.h>
#endif
#include <arpa/inet.h>
#include <netdb.h>
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif

extern int   gettok(const char *text, char *buffer, unsigned long, char sep, int, bool = 0);
extern int   fdprintf(int, const char *format, ...);
extern int   safe_strcpy(char *dest, const char *src, unsigned long maxsize);
extern int   wild_match(const char *mask,const char *name);
extern int   fill_in_addr(const char *, struct in_addr *); 
extern int   recv_test(int);
extern bool  resolve_address(const char *, struct sockaddr_in *);
extern bool  reverse_lookup(const char *host, char *buffer, u_long );
extern void  duration(time_t, bool, char *, unsigned long);

#ifdef SUPER_MY_STRDUP
extern       char * my_strdup(const char *, u_long = 0);
#else
extern       char * my_strdup(const char *);
#endif
extern const char * no_leading(const char *orig);
extern const char * timestamp(bool = 0);
extern const char * remove_path(const char *);
extern const char * strtrunc(const char *, unsigned long);
extern void  set_dns_timeout(int);
extern int   daemon(bool);


#define nopath remove_path

inline void remove_tabs(char *text)
{
    do {
        if (*text == 9)
            *text = ' ';
    } while (*text++);
}

/* Attempts to make a file descriptor non blocking */
inline bool nonblocking(int fd)
{
    return (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL,0) | O_NONBLOCK) != -1);
}


/* Some systems appear to define this */
#ifdef MAX
#   undef MAX
#endif
inline int MAX(int a, int b)
{
    return (a > b) ? a : b;
}

inline int MAX3(int a, int b, int c)
{
    int d = MAX(a,b);
    return MAX(c,d);
}

#endif  /* __general_h */