|
@@ -7,20 +7,28 @@ void printAuthors(const char *authorName, const char *anonName) {
|
|
printf("\"%s\" is now \"%s\"\n", authorName, anonName);
|
|
printf("\"%s\" is now \"%s\"\n", authorName, anonName);
|
|
}
|
|
}
|
|
|
|
|
|
-char* anonymizeAuthor(binn *authors, const xmlChar *authorName) {
|
|
|
|
|
|
+char* anonymizeAuthor(binn *anonAuthors, const xmlChar *authorName) {
|
|
static int authorsCount = 0;
|
|
static int authorsCount = 0;
|
|
|
|
|
|
char *name = (char*)authorName;
|
|
char *name = (char*)authorName;
|
|
- char *newName = binn_object_str(authors, name);
|
|
|
|
|
|
+ char *newName = binn_object_str(anonAuthors, name);
|
|
|
|
|
|
if (newName)
|
|
if (newName)
|
|
return newName;
|
|
return newName;
|
|
|
|
|
|
asprintf(&newName, "Author%d", ++authorsCount);
|
|
asprintf(&newName, "Author%d", ++authorsCount);
|
|
- binn_object_set_str(authors, name, newName);
|
|
|
|
|
|
+ binn_object_set_str(anonAuthors, name, newName);
|
|
|
|
+ binn_object_set_str(anonAuthors, newName, name);
|
|
printAuthors(name, newName);
|
|
printAuthors(name, newName);
|
|
free(newName);
|
|
free(newName);
|
|
- return binn_object_str(authors, name);
|
|
|
|
|
|
+
|
|
|
|
+ return binn_object_str(anonAuthors, name);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void saveAuthors(binn *anonAuthors) {
|
|
|
|
+ FILE *fp = fopen(binnFile, "w");
|
|
|
|
+ fwrite(binn_ptr(anonAuthors), binn_size(anonAuthors), 1, fp);
|
|
|
|
+ fclose(fp);
|
|
}
|
|
}
|
|
|
|
|
|
int processAuthors(const xmlXPathObjectPtr authors) {
|
|
int processAuthors(const xmlXPathObjectPtr authors) {
|
|
@@ -33,7 +41,8 @@ int processAuthors(const xmlXPathObjectPtr authors) {
|
|
xmlNodeSetContent(authors->nodesetval->nodeTab[i], (xmlChar*)anonAuthor);
|
|
xmlNodeSetContent(authors->nodesetval->nodeTab[i], (xmlChar*)anonAuthor);
|
|
xmlFree(authorName);
|
|
xmlFree(authorName);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ saveAuthors(anonAuthors);
|
|
binn_free(anonAuthors);
|
|
binn_free(anonAuthors);
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|