339c87aeadccde3f9ae2b7c6cc5dfe1896a3e004
[reactos.git] / reactos / services / dhcp / util.c
1 #include <stdarg.h>
2 #include "rosdhcp.h"
3
4 #define NDEBUG
5 #include <reactos/debug.h>
6
7 char *piaddr( struct iaddr addr ) {
8 struct sockaddr_in sa;
9 memcpy(&sa.sin_addr,addr.iabuf,sizeof(sa.sin_addr));
10 return inet_ntoa( sa.sin_addr );
11 }
12
13 int note( char *format, ... ) {
14 va_list arg_begin;
15 va_start( arg_begin, format );
16 char buf[0x100];
17 int ret;
18
19 ret = vsnprintf( buf, sizeof(buf), format, arg_begin );
20
21 DPRINT("NOTE: %s\n", buf);
22
23 return ret;
24 }
25
26 int debug( char *format, ... ) {
27 va_list arg_begin;
28 va_start( arg_begin, format );
29 char buf[0x100];
30 int ret;
31
32 ret = vsnprintf( buf, sizeof(buf), format, arg_begin );
33
34 DPRINT("DEBUG: %s\n", buf);
35
36 return ret;
37 }
38
39 int warn( char *format, ... ) {
40 va_list arg_begin;
41 va_start( arg_begin, format );
42 char buf[0x100];
43 int ret;
44
45 ret = vsnprintf( buf, sizeof(buf), format, arg_begin );
46
47 DPRINT("WARN: %s\n", buf);
48
49 return ret;
50 }
51
52 int warning( char *format, ... ) {
53 va_list arg_begin;
54 va_start( arg_begin, format );
55 char buf[0x100];
56 int ret;
57
58 ret = vsnprintf( buf, sizeof(buf), format, arg_begin );
59
60 DPRINT("WARNING: %s\n", buf);
61
62 return ret;
63 }
64
65 void error( char *format, ... ) {
66 va_list arg_begin;
67 va_start( arg_begin, format );
68 char buf[0x100];
69
70 vsnprintf( buf, sizeof(buf), format, arg_begin );
71
72 DPRINT1("ERROR: %s\n", buf);
73 }
74
75 int16_t getShort( unsigned char *data ) {
76 return (int16_t) ntohs(*(int16_t*) data);
77 }
78
79 u_int16_t getUShort( unsigned char *data ) {
80 return (u_int16_t) ntohs(*(u_int16_t*) data);
81 }
82
83 int32_t getLong( unsigned char *data ) {
84 return (int32_t) ntohl(*(u_int32_t*) data);
85 }
86
87 u_int32_t getULong( unsigned char *data ) {
88 return ntohl(*(u_int32_t*)data);
89 }
90
91 int addr_eq( struct iaddr a, struct iaddr b ) {
92 return a.len == b.len && !memcmp( a.iabuf, b.iabuf, a.len );
93 }
94
95 void *dmalloc( int size, char *name ) { return malloc( size ); }
96 void dfree( void *v, char *name ) { free( v ); }
97
98 int read_client_conf(void) {
99 error("util.c read_client_conf not implemented!");
100 return 0;
101 }
102
103 struct iaddr broadcast_addr( struct iaddr addr, struct iaddr mask ) {
104 struct iaddr bcast = { 0 };
105 return bcast;
106 }
107
108 struct iaddr subnet_number( struct iaddr addr, struct iaddr mask ) {
109 struct iaddr bcast = { 0 };
110 return bcast;
111 }