Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

privacy.h File Reference

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.

Referenced by ast_privacy_check(), and ast_privacy_set().

#define AST_PRIVACY_DENY   (1 << 0)
 

Definition at line 21 of file privacy.h.

Referenced by ast_privacy_check(), and ast_privacy_set().

#define AST_PRIVACY_KILL   (1 << 2)
 

Definition at line 23 of file privacy.h.

Referenced by ast_privacy_check(), and ast_privacy_set().

#define AST_PRIVACY_TORTURE   (1 << 3)
 

Definition at line 24 of file privacy.h.

Referenced by ast_privacy_check(), and ast_privacy_set().

#define AST_PRIVACY_UNKNOWN   (1 << 16)
 

Definition at line 25 of file privacy.h.

Referenced by ast_privacy_check(), and ast_privacy_set().


Function Documentation

int ast_privacy_check char *  dest,
char *  cid
 

Definition at line 34 of file privacy.c.

References ast_callerid_parse(), ast_db_get(), AST_PRIVACY_ALLOW, AST_PRIVACY_DENY, AST_PRIVACY_KILL, AST_PRIVACY_TORTURE, AST_PRIVACY_UNKNOWN, ast_shrink_phone_number(), and key().

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

int ast_privacy_reset char *  dest  ) 
 

Definition at line 63 of file privacy.c.

References ast_db_deltree().

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

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

Definition at line 70 of file privacy.c.

References ast_callerid_parse(), ast_db_del(), ast_db_put(), AST_PRIVACY_ALLOW, AST_PRIVACY_DENY, AST_PRIVACY_KILL, AST_PRIVACY_TORTURE, AST_PRIVACY_UNKNOWN, ast_shrink_phone_number(), and key().

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


Generated on Fri Oct 31 07:05:16 2003 for Asterisk by doxygen 1.3.4