File tree Expand file tree Collapse file tree 1 file changed +30
-5
lines changed Expand file tree Collapse file tree 1 file changed +30
-5
lines changed Original file line number Diff line number Diff line change 1
1
#include "libsql.h"
2
2
#include <assert.h>
3
3
#include <stdio.h>
4
+ #include <string.h>
4
5
5
6
int main (int argc , char * argv [])
6
7
{
7
8
libsql_connection_t conn ;
8
9
libsql_rows_t rows ;
9
10
libsql_row_t row ;
10
11
libsql_database_t db ;
12
+ libsql_config config ;
11
13
const char * err = NULL ;
12
14
int retval = 0 ;
15
+ char db_path [1024 ];
13
16
14
- retval = libsql_open_ext (":memory:" , & db , & err );
15
- if (retval != 0 ) {
16
- fprintf (stderr , "%s\n" , err );
17
- goto quit ;
18
- }
17
+ if (argc > 1 ) {
18
+ char * url = argv [1 ];
19
+ char auth_token [1024 ];
20
+ auth_token [0 ] = '\0' ;
21
+ if (argc > 2 ) {
22
+ strncpy (auth_token , argv [2 ], strlen (argv [2 ]));
23
+ }
24
+ strncpy (db_path , "test.db" , strlen ("test.db" ));
25
+ config .db_path = db_path ;
26
+ config .primary_url = url ;
27
+ config .auth_token = auth_token ;
28
+ config .read_your_writes = 0 ;
29
+ config .encryption_key = NULL ;
30
+ config .sync_interval = 0 ;
31
+ config .with_webpki = 0 ;
32
+ retval = libsql_open_sync_with_config (config , & db , & err );
33
+ if (retval != 0 ) {
34
+ fprintf (stderr , "%s\n" , err );
35
+ goto quit ;
36
+ }
37
+ } else {
38
+ retval = libsql_open_ext (":memory:" , & db , & err );
39
+ if (retval != 0 ) {
40
+ fprintf (stderr , "%s\n" , err );
41
+ goto quit ;
42
+ }
43
+ }
19
44
20
45
retval = libsql_connect (db , & conn , & err );
21
46
if (retval != 0 ) {
You can’t perform that action at this time.
0 commit comments