db_id.c File Reference

Functions for parsing a database URL and work with db identifier. More...

#include "db_id.h"
#include "../dprint.h"
#include "../mem/mem.h"
#include "../ut.h"
#include <stdlib.h>
#include <string.h>

Include dependency graph for db_id.c:

Go to the source code of this file.

Defines

#define SHORTEST_DB_URL   "s://a/b"
#define SHORTEST_DB_URL_LEN   (sizeof(SHORTEST_DB_URL) - 1)

Functions

unsigned char cmp_db_id (const struct db_id *id1, const struct db_id *id2)
static int dupl_string (char **dst, const char *begin, const char *end)
void free_db_id (struct db_id *id)
struct db_idnew_db_id (const str *url)
static int parse_db_url (struct db_id *id, const str *url)


Detailed Description

Functions for parsing a database URL and work with db identifier.

Definition in file db_id.c.


Define Documentation

#define SHORTEST_DB_URL   "s://a/b"

#define SHORTEST_DB_URL_LEN   (sizeof(SHORTEST_DB_URL) - 1)

Referenced by parse_db_url().


Function Documentation

unsigned char cmp_db_id ( const struct db_id id1,
const struct db_id id2 
)

Compare two connection identifiers

Parameters:
id1 first identifier
id2 second identifier
Returns:
one if both are equal, zero otherwise

Definition at line 259 of file db_id.c.

References db_id::database, db_id::host, db_id::password, db_id::port, db_id::scheme, and db_id::username.

Referenced by pool_get().

static int dupl_string ( char **  dst,
const char *  begin,
const char *  end 
) [static]

Duplicate a string

Parameters:
dst destination
begin start of the string
end end of the string

Definition at line 44 of file db_id.c.

References NULL, pkg_free, and pkg_malloc.

Referenced by parse_db_url().

void free_db_id ( struct db_id id  ) 

Free a connection identifier

Parameters:
id identifier

Definition at line 285 of file db_id.c.

References db_id::database, db_id::host, db_id::password, pkg_free, db_id::scheme, and db_id::username.

Referenced by db_do_init(), db_mysql_free_connection(), db_oracle_free_connection(), and db_postgres_free_connection().

struct db_id* new_db_id ( const str url  )  [read]

Create a new connection identifier

Parameters:
url database URL
Returns:
connection identifier, or zero on error

Definition at line 224 of file db_id.c.

References _str::len, LM_ERR, parse_db_url(), pkg_free, pkg_malloc, and _str::s.

Referenced by db_do_init().

static int parse_db_url ( struct db_id id,
const str url 
) [static]

Parse a database URL of form scheme://[username[:password]@]hostname[:port]/database

Parameters:
id filled id struct
url parsed URL
Returns:
0 if parsing was successful and -1 otherwise

Definition at line 67 of file db_id.c.

References db_id::database, dupl_string(), db_id::host, _str::len, len, db_id::password, pkg_free, _str::s, db_id::scheme, SHORTEST_DB_URL_LEN, str2s(), and db_id::username.

Referenced by new_db_id().


Generated on Mon May 21 18:00:38 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6