privacy.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define AST_PRIVACY_DENY   (1 << 0)
#define AST_PRIVACY_ALLOW   (1 << 1)
#define AST_PRIVACY_KILL   (1 << 2)
#define AST_PRIVACY_TORTURE   (1 << 3)
#define AST_PRIVACY_UNKNOWN   (1 << 16)

Functions

int ast_privacy_check (char *dest, char *cid)
int ast_privacy_set (char *dest, char *cid, int status)
int ast_privacy_reset (char *dest)


Define Documentation

#define AST_PRIVACY_ALLOW   (1 << 1)

Definition at line 22 of file privacy.h.

#define AST_PRIVACY_DENY   (1 << 0)

Definition at line 21 of file privacy.h.

#define AST_PRIVACY_KILL   (1 << 2)

Definition at line 23 of file privacy.h.

#define AST_PRIVACY_TORTURE   (1 << 3)

Definition at line 24 of file privacy.h.

#define AST_PRIVACY_UNKNOWN   (1 << 16)

Definition at line 25 of file privacy.h.


Function Documentation

int ast_privacy_check ( char *  dest,
char *  cid 
)

Definition at line 35 of file privacy.c.

00036 {
00037    char tmp[256] = "";
00038    char *trimcid = "";
00039    char *n, *l;
00040    int res;
00041    char key[256], result[256];
00042    if (cid)
00043       strncpy(tmp, cid, sizeof(tmp) - 1);
00044    ast_callerid_parse(tmp, &n, &l);
00045    if (l) {
00046       ast_shrink_phone_number(l);
00047       trimcid = l;
00048    }
00049    snprintf(key, sizeof(key), "%s/%s", dest, trimcid);
00050    res = ast_db_get("privacy", key, result, sizeof(result));
00051    if (!res) {
00052       if (!strcasecmp(result, "allow"))
00053          return AST_PRIVACY_ALLOW;
00054       if (!strcasecmp(result, "deny"))
00055          return AST_PRIVACY_DENY;
00056       if (!strcasecmp(result, "kill"))
00057          return AST_PRIVACY_KILL;
00058       if (!strcasecmp(result, "torture"))
00059          return AST_PRIVACY_TORTURE;
00060    }
00061    return AST_PRIVACY_UNKNOWN;
00062 }

int ast_privacy_reset ( char *  dest  ) 

Definition at line 64 of file privacy.c.

00065 {
00066    if (!dest)
00067       return -1;
00068    return ast_db_deltree("privacy", dest);
00069 }

int ast_privacy_set ( char *  dest,
char *  cid,
int  status 
)

Definition at line 71 of file privacy.c.

00072 {
00073    char tmp[256] = "";
00074    char *trimcid = "";
00075    char *n, *l;
00076    int res;
00077    char key[256];
00078    if (cid)
00079       strncpy(tmp, cid, sizeof(tmp) - 1);
00080    ast_callerid_parse(tmp, &n, &l);
00081    if (l) {
00082       ast_shrink_phone_number(l);
00083       trimcid = l;
00084    }
00085    if (ast_strlen_zero(trimcid)) {
00086       /* Don't store anything for empty Caller*ID */
00087       return 0;
00088    }
00089    snprintf(key, sizeof(key), "%s/%s", dest, trimcid);
00090    if (status == AST_PRIVACY_UNKNOWN) 
00091       res = ast_db_del("privacy", key);
00092    else if (status == AST_PRIVACY_ALLOW)
00093       res = ast_db_put("privacy", key, "allow");
00094    else if (status == AST_PRIVACY_DENY)
00095       res = ast_db_put("privacy", key, "deny");
00096    else if (status == AST_PRIVACY_KILL)
00097       res = ast_db_put("privacy", key, "kill");
00098    else if (status == AST_PRIVACY_TORTURE)
00099       res = ast_db_put("privacy", key, "torture");
00100    else
00101       res = -1;
00102    return res;
00103 }


Generated on Wed Oct 28 17:01:00 2009 for Asterisk by  doxygen 1.5.6