4 ** The author disclaims copyright to this source code. In place of a
5 ** legal notice, here is a blessing:
7 ** * May you do good and not evil.
8 ** * May you find forgiveness for yourself and forgive others.
9 ** * May you share freely, never taking more than you give.
11 *************************************************************************
12 ** This file simply outputs sqlite3 version information in JSON form,
13 ** intended for embedding in the sqlite3 JS API build.
17 #define SQLITE_VERSION "X.Y.Z"
18 #define SQLITE_VERSION_NUMBER TEST_VERSION
19 #define SQLITE_SOURCE_ID "dummy"
25 static void usage(const char *zAppName
){
26 puts("Emits version info about the sqlite3 it is built against.");
27 printf("Usage: %s [--quote] --INFO-FLAG:\n\n", zAppName
);
28 puts(" --version Emit SQLITE_VERSION (3.X.Y)");
29 puts(" --version-number Emit SQLITE_VERSION_NUMBER (30XXYYZZ)");
30 puts(" --download-version Emit /download.html version number (3XXYYZZ)");
31 puts(" --source-id Emit SQLITE_SOURCE_ID");
32 puts(" --json Emit all info in JSON form");
33 puts("\nThe non-JSON formats may be modified by:\n");
34 puts(" --quote Add double quotes around output.");
37 int main(int argc
, char const * const * argv
){
40 int fVersionNumber
= 0;
48 for( i
= 1; i
< argc
; ++i
){
49 const char * zArg
= argv
[i
];
50 while('-'==*zArg
) ++zArg
;
51 if( 0==strcmp("version", zArg
) ){
53 }else if( 0==strcmp("version-number", zArg
) ){
55 }else if( 0==strcmp("download-version", zArg
) ){
57 }else if( 0==strcmp("source-id", zArg
) ){
59 }else if( 0==strcmp("json", zArg
) ){
61 }else if( 0==strcmp("quote", zArg
) ){
65 printf("Unhandled flag: %s\n", argv
[i
]);
72 if( 0==nFlags
) fJson
= 1;
75 const int v
= SQLITE_VERSION_NUMBER
;
76 int ver
[4] = {0,0,0,0};
77 ver
[0] = (v
/ 1000000) * 1000000;
78 ver
[1] = v
% 1000000 / 100 * 1000;
79 ver
[2] = v
% 100 * 100;
80 dlVersion
= ver
[0] + ver
[1] + ver
[2] + ver
[3];
83 printf("{\"libVersion\": \"%s\", "
84 "\"libVersionNumber\": %d, "
85 "\"sourceId\": \"%s\","
86 "\"downloadVersion\": %d}"/*missing newline is intentional*/,
88 SQLITE_VERSION_NUMBER
,
92 if(fQuote
) printf("%c", '"');
94 printf("%s", SQLITE_VERSION
);
95 }else if( fVersionNumber
){
96 printf("%d", SQLITE_VERSION_NUMBER
);
97 }else if( fSourceInfo
){
98 printf("%s", SQLITE_SOURCE_ID
);
99 }else if( fDlVersion
){
100 printf("%d", dlVersion
);
102 if(fQuote
) printf("%c", '"');