Lines 60-69
Link Here
|
60 |
static int emulate = false; |
60 |
static int emulate = false; |
61 |
|
61 |
|
62 |
enum { |
62 |
enum { |
63 |
VERSION_1 = '3', |
63 |
PROTOCOL_VERSION_1 = '3', |
64 |
VERSION_2 = '5' |
64 |
PROTOCOL_VERSION_2 = '5' |
65 |
} protocol_version = 0; |
65 |
} protocol_version = 0; |
66 |
|
66 |
|
|
|
67 |
#define CONTROLLER_MAJOR_VERSION 1 |
68 |
#define CONTROLLER_MID_VERSION 1 |
69 |
#define CONTROLLER_MINOR_VERSION 1 |
70 |
|
67 |
static struct timeval fs_skew; |
71 |
static struct timeval fs_skew; |
68 |
|
72 |
|
69 |
typedef struct connection_data { |
73 |
typedef struct connection_data { |
Lines 383-389
Link Here
|
383 |
} |
387 |
} |
384 |
// VERSION_2: format is as in printf("%c %d %d %d %s", kind, length, seconds, milliseconds, path) |
388 |
// VERSION_2: format is as in printf("%c %d %d %d %s", kind, length, seconds, milliseconds, path) |
385 |
// so the beginning is the same, and two long values are inserted before path |
389 |
// so the beginning is the same, and two long values are inserted before path |
386 |
if (protocol_version == VERSION_2) { |
390 |
if (protocol_version == PROTOCOL_VERSION_2) { |
387 |
file_time->tv_sec = string2num(filename, buffer+bufsize, &filename); |
391 |
file_time->tv_sec = string2num(filename, buffer+bufsize, &filename); |
388 |
if (file_time->tv_sec < 0) { |
392 |
if (file_time->tv_sec < 0) { |
389 |
return false; |
393 |
return false; |
Lines 412-418
Link Here
|
412 |
int namelen = strlen(filename); |
416 |
int namelen = strlen(filename); |
413 |
int realpath_len = strlen(real_path); |
417 |
int realpath_len = strlen(real_path); |
414 |
int size = sizeof(file_elem) + namelen + realpath_len + 2; |
418 |
int size = sizeof(file_elem) + namelen + realpath_len + 2; |
415 |
file_elem *fe = (file_elem*) malloc(size); |
419 |
file_elem *fe = (file_elem*) malloc_wrapper(size); |
416 |
fe->next = NULL; |
420 |
fe->next = NULL; |
417 |
strcpy(fe->filename, filename); |
421 |
strcpy(fe->filename, filename); |
418 |
fe->state = state; |
422 |
fe->state = state; |
Lines 519-526
Link Here
|
519 |
} |
523 |
} |
520 |
|
524 |
|
521 |
static int init() { |
525 |
static int init() { |
522 |
trace("Initialization. Sending supported versions: %c %c\n", VERSION_1, VERSION_2); |
526 |
trace("Initialization. Sending supported versions: %c %c\n", PROTOCOL_VERSION_1, PROTOCOL_VERSION_2); |
523 |
fprintf(stdout, "VERSIONS %c %c 6\n", VERSION_1, VERSION_2); |
527 |
fprintf(stdout, "CONTROLLER VERSION %i.%i.%i (%s %s)\n", CONTROLLER_MAJOR_VERSION, CONTROLLER_MID_VERSION, CONTROLLER_MINOR_VERSION, __DATE__, __TIME__); |
|
|
528 |
fprintf(stdout, "VERSIONS %c %c\n", PROTOCOL_VERSION_1, PROTOCOL_VERSION_2); |
524 |
fflush(stdout); |
529 |
fflush(stdout); |
525 |
int bufsize = 256; |
530 |
int bufsize = 256; |
526 |
char buffer[bufsize]; |
531 |
char buffer[bufsize]; |
Lines 530-536
Link Here
|
530 |
return false; |
535 |
return false; |
531 |
} |
536 |
} |
532 |
protocol_version = buffer[8]; |
537 |
protocol_version = buffer[8]; |
533 |
if (protocol_version != VERSION_1 && protocol_version != VERSION_2) { |
538 |
if (protocol_version != PROTOCOL_VERSION_1 && protocol_version != PROTOCOL_VERSION_2) { |
534 |
report_error("protocol error: unexpected version: %s\n", buffer); |
539 |
report_error("protocol error: unexpected version: %s\n", buffer); |
535 |
return false; |
540 |
return false; |
536 |
} |
541 |
} |
Lines 784-790
Link Here
|
784 |
|
789 |
|
785 |
while (1) { |
790 |
while (1) { |
786 |
/* wait for a client to talk to us */ |
791 |
/* wait for a client to talk to us */ |
787 |
connection_data* conn_data = (connection_data*) malloc(sizeof (connection_data)); |
792 |
connection_data* conn_data = (connection_data*) malloc_wrapper(sizeof (connection_data)); |
788 |
socklen_t addrlen = sizeof (conn_data->pin); |
793 |
socklen_t addrlen = sizeof (conn_data->pin); |
789 |
if ((conn_data->sd = accept(sd, (struct sockaddr *) & conn_data->pin, &addrlen)) == -1) { |
794 |
if ((conn_data->sd = accept(sd, (struct sockaddr *) & conn_data->pin, &addrlen)) == -1) { |
790 |
perror("accept"); |
795 |
perror("accept"); |