Last active
December 24, 2015 15:19
-
-
Save yusukemihara/6819445 to your computer and use it in GitHub Desktop.
% ./testjson.c # コンパイル
% ./testjson /usr/lib/jma-receipt/record/M00.rec # 実行
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #if 0 | |
| #!/bin/bash | |
| src=$0 | |
| obj=${src%.*} | |
| gcc -g -Wl,--no-as-needed `pkg-config --cflags --libs libmondai` -o $obj $src | |
| $obj | |
| exit | |
| #endif | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #include <libmondai.h> | |
| #include <RecParser.h> | |
| int | |
| main(int argc,char *argv[]) | |
| { | |
| ValueStruct *value; | |
| char *vname; | |
| size_t size; | |
| char *buf; | |
| if (argc < 2) { | |
| fprintf(stderr,"./testjson screen.rec\n"); | |
| exit(-1); | |
| } | |
| RecParserInit(); | |
| value = RecParseValue(argv[1],&vname); /* レコード定義体をパースしてValueStruct作成 */ | |
| fprintf(stderr,"vname:%s\n",vname); | |
| InitializeValue(value); | |
| size = JSON_SizeValue(NULL,value); /* JSON_Packした後のサイズを取得,libmondai内部でじつはPack実行 */ | |
| buf = malloc(size+1); | |
| memset(buf,0,size+1); | |
| JSON_PackValue(NULL,buf,value); /* バッファにPack結果を詰める */ | |
| fprintf(stderr,"%s\n\n",buf); | |
| free(buf); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment