83 #include <sys/types.h> 97 int main(
int argc,
char **argv)
120 while ((optch = getopt(argc, argv,
"")) != -1) {
124 fd = open(path, O_RDONLY);
126 err(EX_NOINPUT,
"cannot open \"%s\"", path);
127 result = fstat(
fd, &
buf);
129 err(EX_UNAVAILABLE,
"cannot fstat \"%s\"", path);
130 addr = mmap(
NULL,
buf.st_size, PROT_READ, MAP_SHARED,
fd, 0);
131 if (
addr == MAP_FAILED)
132 err(EX_OSERR,
"cannot mmap \"%s\"", path);
134 scratch =
fmt(
"%s", path);
135 len = strlen(scratch);
136 if (len > 3 && strcmp(scratch + len - 3,
".ff") == 0)
137 *(scratch + len - 3) = 0;
139 out_h =
fmt(
"%s_ff.h", scratch);
140 out_c =
fmt(
"%s_ff.c", scratch);
142 bname = basename(scratch);
143 gname =
fmt(
"__MOTR_%s_%s_FF_H__", basename(dirname(scratch)),
bname);
145 for (
ch = gname; *
ch != 0;
ch++) {
147 if (strchr(
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_", *
ch) ==
NULL)
154 c = fopen(out_c,
"w");
156 err(EX_CANTCREAT,
"cannot open \"%s\" for writing", out_c);
158 h = fopen(out_h,
"w");
160 err(EX_CANTCREAT,
"cannot open \"%s\" for writing", out_h);
162 memset(&
ctx, 0,
sizeof ctx);
163 memset(&
ff, 0,
sizeof ff);
168 err(EX_DATAERR,
"cannot parse");
188 result = munmap(
addr,
buf.st_size);
190 warn(
"cannot munmap");
193 warn(
"cannot close");
M0_INTERNAL int struct dentry struct kstat * stat
void ff2c_context_fini(struct ff2c_context *ctx)
void ff2c_sem_fini(struct ff2c_ff *ff)
const char * go_guardname
static int ff(struct ff2c_context *ctx, struct ff2c_term *term)
int ff2c_c_gen(const struct ff2c_ff *ff, const struct ff2c_gen_opt *opt)
static struct m0_addb2_callback c
static struct m0_thread t[8]
int main(int argc, char **argv)
int ff2c_h_gen(const struct ff2c_ff *ff, const struct ff2c_gen_opt *opt)
char * fmt(const char *format,...) __attribute__((format(printf
void ff2c_sem_init(struct ff2c_ff *ff, struct ff2c_term *top)
static const char * bname(const struct btype *bt)
struct m0t1fs_filedata * fd
void ff2c_term_fini(struct ff2c_term *term)
void ff2c_context_init(struct ff2c_context *ctx, const char *buf, size_t size)
int ff2c_parse(struct ff2c_context *ctx, struct ff2c_term **out)