extern void init_objects (void) { objects = init_string_list(); ld_args_objs = init_string_list(); lib_objects = init_string_list(); cxx_prelinker_objects = init_string_list(); ar_objects = init_string_list(); library_dirs = init_string_list(); }
void init_error_list(void) { error_list = init_string_list(); }
int main(int argc, char * argv[]) { char * filename; char * basedir; FILE *fd; char line[PATH_MAX]; if (argc < 3) { fprintf(stderr, "Usage: trFilelist synclist_filename basedir\n"); exit(-1); } filename = argv[1]; basedir = argv[2]; init_string_list(&file_list, 10); init_uint_list(&ino_list, 10); init_string_list(&dir_list, 100); init_string_list(&softlink_list, 10); init_string_list(&newdir_list, 100); get_dir_softlinks(filename, basedir); if ((fd = fopen(filename, "r")) == NULL) { fprintf(stderr, "Cannot open file -- %s \n", filename); return -1; } while (1) { /* for each line in the file */ char *pc; char fn[PATH_MAX]; struct stat st; int newdir_flag; if (fgets(line, PATH_MAX, fd)==NULL) break; strip(line); if (strlen(line) == 0) continue; /* skip blank line */ if (strcmp(line, ".")==0) continue; if (strcmp(line, "./")==0) continue; /* first we look for deleting entry */ if (strncmp(line, "deleting ", 9)==0) { /* deleting (directory) file_path */ char * p1, *p2, *pf; p1 = strstr(line, " "); /* the first space */ p2 = strstr(p1+1, " "); /* deleting directory filepath * 20070912 this is old */ pf = (p2) ? p2+1 : p1+1;/* it's always p1+1 */ newdir_flag = has_newdir(pf, &newdir_list); if ((has_sub_string(pf, &softlink_list)<0) && newdir_flag<0) { /* see comments above get_dir_softlinks() */ printf("deleting %s\n", pf); } else if (newdir_flag>=0) { /* temporary action */ /*** we can simply skip this block later. 20070912 ***/ /***/ fprintf(stderr, "CRITICAL ERROR: An old softlink has been changed to a directory!\n"); fprintf(stderr, " For now, we crash this code for human intervention\n"); fprintf(stderr, " line= %s\n", line); exit(-1); /***/ } continue; } /* the softlink case is indicated by -> */ pc= strstr(line, " -> "); if (pc) { *pc = '\0'; output_subs(line); printf("%s\n", line); continue; } /* if rsync's -H is turned on, the output may contain file => tar_hardlink_file (relative address) */ pc= strstr(line, " => "); if (pc) { *pc = '\0'; output_subs(line); printf("%s %s\n", line, pc+4); continue; } /* the rest of the entries should be valid paths */ sprintf(fn, "%s/%s", basedir, line); if (lstat(fn, &st)<0) continue; /* We skip this bad entry - (1) the header and tail lines (2) perhaps the file no longer exists */ /* is this a hardlink? */ if (st.st_nlink > 1) { int index; output_subs(line); if ((index = find_unit((unsigned int)st.st_ino, &ino_list))<0) { append_uint_list((unsigned int)st.st_ino, &ino_list); append_string_list(line, &file_list); /* relative path */ printf("%s\n", line); } else { printf("%s %s\n", line, file_list.str[index]); } continue; } /* all others */ output_subs(line); printf("%s\n", line); } /* end of one line */ fclose(fd); return 0; }