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