#include <time.h>
#include <loc/format.h>
+#include <loc/network.h>
#include <loc/writer.h>
#include "libloc-private.h"
struct loc_as** as;
size_t as_count;
+
+ struct loc_network_tree* networks;
};
LOC_EXPORT int loc_writer_new(struct loc_ctx* ctx, struct loc_writer** writer) {
return r;
}
+ // Initialize the network tree
+ r = loc_network_tree_new(ctx, &w->networks);
+ if (r) {
+ loc_writer_unref(w);
+ return r;
+ }
+
*writer = w;
return 0;
}
loc_as_unref(writer->as[i]);
}
+ // Release network tree
+ if (writer->networks)
+ loc_network_tree_unref(writer->networks);
+
// Unref the string pool
loc_stringpool_unref(writer->pool);
return 0;
}
+LOC_EXPORT int loc_writer_add_network(struct loc_writer* writer, struct loc_network** network, const char* string) {
+ int r;
+
+ // Create a new network object
+ r = loc_network_new_from_string(writer->ctx, network, string);
+ if (r)
+ return r;
+
+ // Add it to the local tree
+ return loc_network_tree_add_network(writer->networks, *network);
+}
+
static void make_magic(struct loc_writer* writer, struct loc_database_magic* magic) {
// Copy magic bytes
for (unsigned int i = 0; i < strlen(LOC_DATABASE_MAGIC); i++)