/[LeafOK_CVS]/lbbs/src/test_file_loader.c
ViewVC logotype

Diff of /lbbs/src/test_file_loader.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.2 by sysadm, Sat May 17 05:54:42 2025 UTC Revision 1.4 by sysadm, Sun May 18 08:17:25 2025 UTC
# Line 35  int main(int argc, char *argv[]) Line 35  int main(int argc, char *argv[])
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          {          {
# Line 71  int main(int argc, char *argv[]) Line 75  int main(int argc, char *argv[])
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);
85    
86                          if (shmdt(p_file_shm) == -1)                          for (int j = 0; j < line_total; j++)
87                          {                          {
88                                  log_error("shmdt() error (%d)\n", errno);                                  printf("Line %d: %ld ~ %ld\n", j, p_line_offsets[j], p_line_offsets[j + 1]);
89                          }                          }
90                  }                  }
91          }          }
# Line 121  int main(int argc, char *argv[]) Line 125  int main(int argc, char *argv[])
125          {          {
126                  if (i % 2 != 0)                  if (i % 2 != 0)
127                  {                  {
128                          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)
129                          {                          {
130                                  printf("Get file shm %s error\n", files[i]);                                  printf("Get file shm %s error\n", files[i]);
131                          }                          }
132                          else                          else
133                          {                          {
134                                  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);  
                                 }  
135                          }                          }
136                  }                  }
137          }          }


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1