k/textops/api.h

00001 /* Copyright (C) 2008 Telecats BV
00002  *
00003  * This file is part of openser, a free SIP server.
00004  *
00005  * openser is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * openser is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018  *
00019  *
00020  * History:
00021  * ---------
00022  *  2008-07-14 first version (Ardjan Zwartjes)
00023  */
00024 
00025 
00026 #ifndef TEXTOPS_API_H_
00027 #define TEXTOPS_API_H_
00028 #include "../../str.h"
00029 #include "../../sr_module.h"
00030 
00031 
00032 typedef int (*append_hf_t)(struct sip_msg*, str*);
00033 typedef int (*remove_hf_t)(struct sip_msg*, str*);
00034 typedef int (*search_append_t)(struct sip_msg*, str*, str*);
00035 typedef int (*search_t)(struct sip_msg*, str*);
00036 typedef int (*is_privacy_t)(struct sip_msg*, str*);
00037 
00038 /*
00039  * Struct with the textops api.
00040  */
00041 typedef struct textops_binds {
00042         append_hf_t     append_hf; // Append a header to the message.
00043         remove_hf_t     remove_hf; // Remove a header with the specified name from the message.
00044         search_append_t search_append; // Append a str after a match of the specified regex.
00045         search_t search; // Check if the regex matches a part of the message.
00046         is_privacy_t    is_privacy;
00047 } textops_api_t;
00048 
00049 typedef int (*bind_textops_f)(textops_api_t*);
00050 
00051 /*
00052  * function exported by module - it will load the other functions
00053  */
00054 int bind_textops(textops_api_t*);
00055 
00056 /*
00057  * Function to be called direclty from other modules to load
00058  * the textops API.
00059  */
00060 inline static int load_textops_api(textops_api_t *tob){
00061         bind_textops_f bind_textops_exports;
00062         if(!(bind_textops_exports=(bind_textops_f)find_export("bind_textops",0,0))){
00063                 LM_ERR("Failed to import bind_textops\n");
00064                 return -1;
00065         }
00066         return bind_textops_exports(tob);
00067 }
00068 
00069 #endif /*TEXT_OPS_API_H_*/