summaryrefslogtreecommitdiff
path: root/kconf2h/kconf2h.c
diff options
context:
space:
mode:
authorArtur Artamonov <freeartman@wechall.net>2014-06-29 19:14:44 +0300
committerArtur Artamonov <freeartman@wechall.net>2014-06-29 19:14:44 +0300
commit8db5030a687b9a91ca39296edb6cd4728e5d71bf (patch)
tree15af5652df82d83f0513817a1702c4f95414874e /kconf2h/kconf2h.c
downloaddwm-fancy-8db5030a687b9a91ca39296edb6cd4728e5d71bf.tar.gz
dwm-fancy-8db5030a687b9a91ca39296edb6cd4728e5d71bf.zip
Initial commit
Diffstat (limited to 'kconf2h/kconf2h.c')
-rw-r--r--kconf2h/kconf2h.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/kconf2h/kconf2h.c b/kconf2h/kconf2h.c
new file mode 100644
index 0000000..91ef6c7
--- /dev/null
+++ b/kconf2h/kconf2h.c
@@ -0,0 +1,50 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <sys/stat.h>
+
+#include "kconf2h.h"
+
+int main( int argc, char **argv )
+{
+ FILE *fin = NULL;
+ FILE *fout = NULL;
+ struct stat st;
+
+ char *buf=NULL;
+ if ( argc == 3 )
+ {
+ fin = fopen( argv[1], "r+" );
+ fout = fopen( argv[2], "w+" );
+ fseek( fin, 0, SEEK_SET );
+ if ( fin && fout )
+ {
+ if ( stat( argv[1], &st ) )
+ {
+ goto error_exit;
+ }
+ buf = malloc( st.st_size ); memset( buf, 0, st.st_size );
+ size_t r_size = fread( buf, 1, st.st_size, fin );
+ if ( r_size > 0 )
+ {
+ int ret = parse_kconf2h( buf, fout );
+ printf("Kconfig file parsed %d %d bytes\n", ret, r_size );
+ } else
+ {
+ printf("ERR: while reading file %s [%d]\n", argv[1], r_size);
+ }
+error_exit:
+ if ( buf ) free( buf );
+ fclose( fin );
+ fclose( fout );
+ } else
+ {
+ printf("ERR: Cannot open file\n");
+ }
+ } else
+ {
+ printf("ERR: usage ./kconf2h [conffile] [outputheader]\n");
+ return -1;
+ }
+ return 0;
+}