0dae401727b2dba987d8eb8c6f538fab56807f30
[platform/upstream/busybox.git] / networking / udhcp / libbb_udhcp.h
1 /* libbb_udhcp.h - busybox compatability wrapper */
2
3 /* bit of a hack, do this no matter what the order of the includes.
4  * (for busybox) */
5
6 #ifdef CONFIG_INSTALL_NO_USR
7 #undef DEFAULT_SCRIPT
8 #define DEFAULT_SCRIPT  "/share/udhcpc/default.script"
9 #endif
10
11 #ifndef _LIBBB_UDHCP_H
12 #define _LIBBB_UDHCP_H
13
14 #ifdef IN_BUSYBOX
15 #include "busybox.h"
16
17 #ifdef CONFIG_FEATURE_UDHCP_SYSLOG
18 #define UDHCP_SYSLOG
19 #endif
20
21 #ifdef CONFIG_FEATURE_UDHCP_DEBUG
22 #define UDHCP_DEBUG
23 #endif
24
25 #define COMBINED_BINARY
26 #include "version.h"
27
28 #define xfopen bb_xfopen
29
30 /* make safe the exported namespace */
31 /* from common.h */
32 #define background              udhcp_background
33 #define start_log_and_pid       udhcp_start_log_and_pid
34 /* from script.h */
35 #define run_script              udhcp_run_script
36 /* from packet.h */
37 #define init_header             udhcp_init_header
38 #define get_packet              udhcp_get_packet
39 #define checksum                udhcp_checksum
40 #define raw_packet              udhcp_raw_packet
41 #define kernel_packet           udhcp_kernel_packet
42 /* from pidfile.h */
43 #define pidfile_acquire         udhcp_pidfile_acquire
44 #define pidfile_write_release   udhcp_pidfile_write_release
45 /* from options.h */
46 #define get_option              udhcp_get_option
47 #define end_option              udhcp_end_option
48 #define add_option_string       udhcp_add_option_string
49 #define add_simple_option       udhcp_add_simple_option
50 #define option_lengths          udhcp_option_lengths
51 /* from socket.h */
52 #define listen_socket           udhcp_listen_socket
53 #define read_interface          udhcp_read_interface
54 /* from dhcpc.h */
55 #define client_config           udhcp_client_config
56 /* from dhcpd.h */
57 #define server_config           udhcp_server_config
58
59 #else /* ! BB_VER */
60
61 #include <stdlib.h>
62 #include <stdio.h>
63 #include <sys/sysinfo.h>
64
65 #define TRUE                    1
66 #define FALSE                   0
67
68 #define xmalloc malloc
69 #define xcalloc calloc
70
71 static inline FILE *xfopen(const char *file, const char *mode)
72 {
73         FILE *fp;
74         if (!(fp = fopen(file, mode))) {
75                 perror("could not open input file");
76                 exit(0);
77         }
78         return fp;
79 }
80
81 #endif /* BB_VER */
82
83 #endif /* _LIBBB_UDHCP_H */