Check-in [63e724bd6e]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Updated file_sync-standalone to compile on OpenBSD: - Reordered #includes - Changed implementation of ntohll() to use ntohl() to determine endian-ness
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 63e724bd6edf8906d5b0cef3272646be83ee488f
User & Date: rkeene 2008-11-09 14:42:27
Context
2008-11-09
19:44
Updated file_sync-standalone to use an internal htonll (renamed to avoid conflicts where real htonll implementations exist) check-in: fc476508a4 user: rkeene tags: trunk
14:42
Updated file_sync-standalone to compile on OpenBSD: - Reordered #includes - Changed implementation of ntohll() to use ntohl() to determine endian-ness check-in: 63e724bd6e user: rkeene tags: trunk
2008-11-07
21:33
Added DPRINTF() macro to non-DEBUG builds check-in: dc0365821d user: rkeene tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to tools/file_sync-standalone.c.

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
#define SPOTVAR_X(x) PRINTERR_D(#x " = 0x%x", (unsigned int) x)
#define SPOTVAR_I(x) PRINTERR_D(#x " = %i", (int) x)
#define SPOTVAR_P(x) PRINTERR_D(#x " = %p", x)
#define SPOTVAR_S(x) PRINTERR_D(#x " = \"%s\"", x)
#define PRINTERR(x...) { PRINT_LINE; fprintf(stderr, x); fprintf(stderr, "\n"); fflush(stderr); }
#define LOG(x...) { PRINT_LINE; fprintf(stderr, "LOG: " x); fprintf(stderr, "\n"); }

#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <sys/stat.h>
#include <endian.h>
#include <signal.h>
#include <limits.h>
#include <stdint.h>


#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <fcntl.h>
#include <netdb.h>
#include <time.h>

#ifndef INT_MAX
#define INT_MAX (0x7fffffff)
#endif

#ifndef O_LARGEFILE
#define O_LARGEFILE 0
#endif

#ifndef __BIG_ENDIAN
#define __BIG_ENDIAN 4321
#endif
#ifndef __LITTLE_ENDIAN
#define __LITTLE_ENDIAN 1234
#endif
#ifndef __BYTE_ORDER
#ifdef WORDS_BIGENDIAN
#define __BYTE_ORDER __BIG_ENDIAN
#else
#define __BYTE_ORDER __LITTLE_ENDIAN
#endif
#endif


/* MD4.H FOLLOWS */
/* MD4.H - header file for MD4C.C
 */

/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
   rights reserved.







<
<



<



>
>















<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







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
#define SPOTVAR_X(x) PRINTERR_D(#x " = 0x%x", (unsigned int) x)
#define SPOTVAR_I(x) PRINTERR_D(#x " = %i", (int) x)
#define SPOTVAR_P(x) PRINTERR_D(#x " = %p", x)
#define SPOTVAR_S(x) PRINTERR_D(#x " = \"%s\"", x)
#define PRINTERR(x...) { PRINT_LINE; fprintf(stderr, x); fprintf(stderr, "\n"); fflush(stderr); }
#define LOG(x...) { PRINT_LINE; fprintf(stderr, "LOG: " x); fprintf(stderr, "\n"); }



#include <sys/types.h>
#include <arpa/inet.h>
#include <sys/stat.h>

#include <signal.h>
#include <limits.h>
#include <stdint.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <fcntl.h>
#include <netdb.h>
#include <time.h>

#ifndef INT_MAX
#define INT_MAX (0x7fffffff)
#endif

#ifndef O_LARGEFILE
#define O_LARGEFILE 0
#endif
















/* MD4.H FOLLOWS */
/* MD4.H - header file for MD4C.C
 */

/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
   rights reserved.
101
102
103
104
105
106
107

108
109







110

111
112
113
114

115
116
117
118
119

120
121







122

123
124
125
126

127
128
129
130
131
132
133
134
135
static void rsaref_MD4Final(unsigned char [16], rsaref_MD4_CTX *);
/* MD4.H ENDS */

uint64_t net_bytesout = 0;
uint64_t net_bytesin = 0;

static uint64_t htonll(uint64_t n) {

        uint64_t retval;








#if __BYTE_ORDER == __BIG_ENDIAN

        retval = n;
#else
        retval = ((uint64_t) htonl(n & 0xFFFFFFFFLLU)) << 32;
        retval |= htonl((n & 0xFFFFFFFF00000000LLU) >> 32);

#endif
        return(retval);
}

static uint64_t ntohll(uint64_t n) {

        uint64_t retval;








#if __BYTE_ORDER == __BIG_ENDIAN

        retval = n;
#else
        retval = ((uint64_t) ntohl(n & 0xFFFFFFFFLLU)) << 32;
        retval |= ntohl((n & 0xFFFFFFFF00000000LLU) >> 32);

#endif
        return(retval);
}

static int net_listen(const int port) {
	struct sockaddr_in localname;
	int sockFd;

	sockFd = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);







>
|

>
>
>
>
>
>
>
|
>
|
|
|
|
>
|
|



>
|

>
>
>
>
>
>
>
|
>
|
|
|
|
>
|
|







85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
static void rsaref_MD4Final(unsigned char [16], rsaref_MD4_CTX *);
/* MD4.H ENDS */

uint64_t net_bytesout = 0;
uint64_t net_bytesin = 0;

static uint64_t htonll(uint64_t n) {
	static int swapped_byte_order = -1;
	uint64_t retval;

	if (swapped_byte_order == -1) {
		if (htonl(0xffff0000) == 0xffff0000) {
			swapped_byte_order = 0;
		} else {
			swapped_byte_order = 1;
		}
	}

	if (swapped_byte_order == 0) {
		retval = n;
	} else {
		retval = ((uint64_t) htonl(n & 0xFFFFFFFFLLU)) << 32;
		retval |= htonl((n & 0xFFFFFFFF00000000LLU) >> 32);
	}

	return(retval);
}

static uint64_t ntohll(uint64_t n) {
	static int swapped_byte_order = -1;
	uint64_t retval;

	if (swapped_byte_order == -1) {
		if (htonl(0xffff0000) == 0xffff0000) {
			swapped_byte_order = 0;
		} else {
			swapped_byte_order = 1;
		}
	}

	if (swapped_byte_order == 0) {
		retval = n;
	} else {
		retval = ((uint64_t) ntohl(n & 0xFFFFFFFFLLU)) << 32;
		retval |= ntohl((n & 0xFFFFFFFF00000000LLU) >> 32);
	}

	return(retval);
}

static int net_listen(const int port) {
	struct sockaddr_in localname;
	int sockFd;

	sockFd = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);