| 35 |
{ |
{ |
| 36 |
int ret; |
int ret; |
| 37 |
int i; |
int i; |
| 38 |
const void *p_file_shm; |
const void *p_shm; |
| 39 |
|
size_t data_len; |
| 40 |
|
long line_total; |
| 41 |
|
const void *p_data; |
| 42 |
|
const long *p_line_offsets; |
| 43 |
|
|
| 44 |
if (log_begin("../log/bbsd.log", "../log/error.log") < 0) |
if (log_begin("../log/bbsd.log", "../log/error.log") < 0) |
| 45 |
{ |
{ |
| 75 |
|
|
| 76 |
for (i = 0; i < files_cnt; i++) |
for (i = 0; i < files_cnt; i++) |
| 77 |
{ |
{ |
| 78 |
if ((p_file_shm = get_file_shm(files[i])) == NULL) |
if ((p_shm = get_file_shm(files[i], &data_len, &line_total, &p_data, &p_line_offsets)) == NULL) |
| 79 |
{ |
{ |
| 80 |
printf("Get file shm %s error\n", files[i]); |
printf("Get file shm %s error\n", files[i]); |
| 81 |
} |
} |
| 82 |
else |
else |
| 83 |
{ |
{ |
| 84 |
printf("File: %s size: %ld lines: %ld\n", files[i], *((size_t *)p_file_shm), *((size_t *)(p_file_shm + sizeof(size_t)))); |
printf("File: %s size: %ld lines: %ld\n", files[i], data_len, line_total); |
|
|
|
|
if (shmdt(p_file_shm) == -1) |
|
|
{ |
|
|
log_error("shmdt() error (%d)\n", errno); |
|
|
} |
|
| 85 |
} |
} |
| 86 |
} |
} |
| 87 |
|
|
| 120 |
{ |
{ |
| 121 |
if (i % 2 != 0) |
if (i % 2 != 0) |
| 122 |
{ |
{ |
| 123 |
if ((p_file_shm = get_file_shm(files[i])) == NULL) |
if ((p_shm = get_file_shm(files[i], &data_len, &line_total, &p_data, &p_line_offsets)) == NULL) |
| 124 |
{ |
{ |
| 125 |
printf("Get file shm %s error\n", files[i]); |
printf("Get file shm %s error\n", files[i]); |
| 126 |
} |
} |
| 127 |
else |
else |
| 128 |
{ |
{ |
| 129 |
printf("File: %s size: %ld lines: %ld\n", files[i], *((size_t *)p_file_shm), *((size_t *)(p_file_shm + sizeof(size_t)))); |
printf("File: %s size: %ld lines: %ld\n", files[i], data_len, line_total); |
|
|
|
|
if (shmdt(p_file_shm) == -1) |
|
|
{ |
|
|
log_error("shmdt() error (%d)\n", errno); |
|
|
} |
|
| 130 |
} |
} |
| 131 |
} |
} |
| 132 |
} |
} |