root/luci2/cbi2/lucic.c @ 5674

Revision 5674, 0.7 KB (checked in by blogic, 3 years ago)

add command line options, integrate lucic, add unix socket

Line 
1#include <stdio.h>
2#include <string.h>
3#include <stdlib.h>
4#include <stdarg.h>
5#include <sys/types.h>
6#include <sys/stat.h>
7#include <unistd.h>
8#include <fcntl.h>
9
10#include "lucip.h"
11#include "lucic.h"
12
13static bool
14buffer_grow(struct blob_buf *buf, int minlen)
15{
16    buf->buflen += ((minlen / 256) + 1) * 256;
17    buf->buf = realloc(buf->buf, buf->buflen);
18    return !!buf->buf;
19}
20
21static struct blob_buf bbuf = {
22    .grow = buffer_grow
23};
24
25int lucic_main(const char *in, const char *out)
26{
27    if(!lucip_load(in, &bbuf))
28    {
29        printf("Ok!\n");
30        if(out)
31            lucip_blob_dump(out, &bbuf);
32        else
33            printf("use -o to save luco file\n");
34    } else {
35        printf("error opening/compiling %s\n", in);
36        return 1;
37    }
38    return 0;
39}
Note: See TracBrowser for help on using the browser.