MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / db_http_init

Function db_http_init

modules/db_http/http_dbase.c:987–1155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

985}
986
987db_con_t* db_http_init(const str* url)
988{
989#define DB_HTTP_BUFF_SIZE 1024
990 char* path;
991 char user_pass[DB_HTTP_BUFF_SIZE];
992 char modified_url[DB_HTTP_BUFF_SIZE];
993 str tmp;
994 int off, ret;
995
996 db_con_t * ans = NULL;
997 http_conn_t * curl = NULL;
998 int i;
999 struct db_id * id;
1000
1001
1002 memset(modified_url,0,DB_HTTP_BUFF_SIZE);
1003 memcpy(modified_url,url->s,url->len);
1004
1005 strcat(modified_url,"/x");
1006 tmp.s = modified_url;
1007 tmp.len = strlen(tmp.s);
1008
1009 user_pass[0] = 0;
1010
1011
1012 path = (char*)pkg_malloc(DB_HTTP_BUFF_SIZE);
1013
1014 if( path == NULL )
1015 {
1016 LM_ERR("Out of memory\n");
1017 return NULL;
1018 }
1019
1020 memset(path,0,DB_HTTP_BUFF_SIZE);
1021
1022
1023 id = new_db_id( &tmp );
1024
1025 if( id == NULL)
1026 {
1027 pkg_free(path);
1028 LM_ERR("Incorrect db_url\n");
1029 return NULL;
1030 }
1031
1032
1033
1034 if( id->username && id->password)
1035 {
1036 ret = snprintf(user_pass, DB_HTTP_BUFF_SIZE, "%s:%s", id->username, id->password);
1037 if (ret < 0 || ret >= DB_HTTP_BUFF_SIZE) goto error;
1038 }
1039
1040
1041
1042 curl = (http_conn_t * ) pkg_malloc(sizeof(http_conn_t));
1043
1044 if( curl == NULL )

Callers

nothing calls this directly

Calls 1

new_db_idFunction · 0.85

Tested by

no test coverage detected