feat: implement extern libs data writing
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
#include <common/fzl_extern.h>
|
||||
#include <compiler/internals/writer.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
// Writer external lib names
|
||||
bool wr_extern_libs(FILE *fd, fzl_extern_lib_t *libs, size_t libs_count)
|
||||
{
|
||||
if (!fd || !libs)
|
||||
return false;
|
||||
|
||||
for (size_t i = 0; i < libs_count; i++)
|
||||
{
|
||||
fzl_extern_lib_t *lib = &libs[i];
|
||||
|
||||
if (!lib || !lib->name)
|
||||
return false;
|
||||
|
||||
size_t len = strlen(lib->name);
|
||||
if (len < 1)
|
||||
return false;
|
||||
|
||||
fwrite(&len, sizeof(size_t), 1, fd);
|
||||
fwrite(lib->name, sizeof(char), len, fd);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user