Go to the source code of this file.
Defines | |
#define | AST_PRIVACY_ALLOW (1 << 1) |
#define | AST_PRIVACY_DENY (1 << 0) |
#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_reset (char *dest) |
int | ast_privacy_set (char *dest, char *cid, int status) |
Definition in file privacy.h.
#define AST_PRIVACY_ALLOW (1 << 1) |
#define AST_PRIVACY_DENY (1 << 0) |
#define AST_PRIVACY_KILL (1 << 2) |
#define AST_PRIVACY_TORTURE (1 << 3) |
#define AST_PRIVACY_UNKNOWN (1 << 16) |
int ast_privacy_check | ( | char * | dest, | |
char * | cid | |||
) |
Definition at line 51 of file privacy.c.
References ast_callerid_parse(), ast_copy_string(), ast_db_get(), AST_PRIVACY_ALLOW, AST_PRIVACY_DENY, AST_PRIVACY_KILL, AST_PRIVACY_TORTURE, AST_PRIVACY_UNKNOWN, and ast_shrink_phone_number().
00052 { 00053 char tmp[256] = ""; 00054 char *trimcid = ""; 00055 char *n, *l; 00056 int res; 00057 char key[256], result[256]; 00058 if (cid) 00059 ast_copy_string(tmp, cid, sizeof(tmp)); 00060 ast_callerid_parse(tmp, &n, &l); 00061 if (l) { 00062 ast_shrink_phone_number(l); 00063 trimcid = l; 00064 } 00065 snprintf(key, sizeof(key), "%s/%s", dest, trimcid); 00066 res = ast_db_get("privacy", key, result, sizeof(result)); 00067 if (!res) { 00068 if (!strcasecmp(result, "allow")) 00069 return AST_PRIVACY_ALLOW; 00070 if (!strcasecmp(result, "deny")) 00071 return AST_PRIVACY_DENY; 00072 if (!strcasecmp(result, "kill")) 00073 return AST_PRIVACY_KILL; 00074 if (!strcasecmp(result, "torture")) 00075 return AST_PRIVACY_TORTURE; 00076 } 00077 return AST_PRIVACY_UNKNOWN; 00078 }
int ast_privacy_reset | ( | char * | dest | ) |
Definition at line 80 of file privacy.c.
References ast_db_deltree().
00081 { 00082 if (!dest) 00083 return -1; 00084 return ast_db_deltree("privacy", dest); 00085 }
int ast_privacy_set | ( | char * | dest, | |
char * | cid, | |||
int | status | |||
) |
Definition at line 87 of file privacy.c.
References ast_callerid_parse(), ast_copy_string(), 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 ast_strlen_zero().
00088 { 00089 char tmp[256] = ""; 00090 char *trimcid = ""; 00091 char *n, *l; 00092 int res; 00093 char key[256]; 00094 if (cid) 00095 ast_copy_string(tmp, cid, sizeof(tmp)); 00096 ast_callerid_parse(tmp, &n, &l); 00097 if (l) { 00098 ast_shrink_phone_number(l); 00099 trimcid = l; 00100 } 00101 if (ast_strlen_zero(trimcid)) { 00102 /* Don't store anything for empty Caller*ID */ 00103 return 0; 00104 } 00105 snprintf(key, sizeof(key), "%s/%s", dest, trimcid); 00106 if (status == AST_PRIVACY_UNKNOWN) 00107 res = ast_db_del("privacy", key); 00108 else if (status == AST_PRIVACY_ALLOW) 00109 res = ast_db_put("privacy", key, "allow"); 00110 else if (status == AST_PRIVACY_DENY) 00111 res = ast_db_put("privacy", key, "deny"); 00112 else if (status == AST_PRIVACY_KILL) 00113 res = ast_db_put("privacy", key, "kill"); 00114 else if (status == AST_PRIVACY_TORTURE) 00115 res = ast_db_put("privacy", key, "torture"); 00116 else 00117 res = -1; 00118 return res; 00119 }