-
-
Save c0nrad/760fd1d34e39b7ed8f4442c622c90160 to your computer and use it in GitHub Desktop.
This file contains 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
#include <mongoc.h> | |
#define MAXBUFLEN 100000 | |
int main (int argc, char *argv[]) { | |
const char *uristr = "mongodb://127.0.0.1/?appname=pool-example"; | |
char *urifile = ""; | |
mongoc_uri_t *uri; | |
// Do I need this? | |
mongoc_init (); | |
if (argc > 1) { | |
urifile = argv[1]; | |
} else { | |
fprintf(stderr, "Where da uri file man?"); | |
} | |
char source[MAXBUFLEN + 1]; | |
FILE *fp = fopen(urifile, "r"); | |
if (fp != NULL) { | |
size_t newLen = fread(source, sizeof(char), MAXBUFLEN, fp); | |
if ( ferror( fp ) != 0 ) { | |
fputs("Error reading file", stderr); | |
} else { | |
source[newLen++] = '\0'; | |
} | |
fclose(fp); | |
} | |
uristr = source; | |
uri = mongoc_uri_new (uristr); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment