zte's code,first commit
Change-Id: I9a04da59e459a9bc0d67f101f700d9d7dc8d681b
diff --git a/ap/lib/libzte_pbm/libzte_pbm.h b/ap/lib/libzte_pbm/libzte_pbm.h
new file mode 100755
index 0000000..7944b5e
--- /dev/null
+++ b/ap/lib/libzte_pbm/libzte_pbm.h
@@ -0,0 +1,324 @@
+#ifndef LIBZTE_PBM
+#define LIBZTE_PBM
+
+//#include "comdef.h"
+
+//typedef unsigned char uint8;
+//typedef unsigned short uint16;
+//typedef unsigned char boolean;
+
+#ifndef uint8
+#define uint8 unsigned char
+#endif
+
+#ifndef uint16
+#define uint16 unsigned short
+#endif
+
+#ifndef boolean
+#define boolean unsigned char
+#endif
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+
+
+//db path
+#ifdef _MBB_OS_UCLINUX
+#define ZTE_PBM_DB_DIR "/mnt/jffs2/etc_rw/config"
+#define ZTE_PBM_DB_PATH "/mnt/jffs2/etc_rw/config/pbm.db"
+#else
+#define ZTE_PBM_DB_DIR "/etc_rw/"
+//#ifdef WEBS_SECURITY
+#define ZTE_PBM_DB_PATH_SEC "/tmp/pbm.db"
+//#else
+#define ZTE_PBM_DB_PATH "/etc_rw/pbm.db"
+//#endif
+#endif
+
+#define ZTE_DB_PBM_TABLE "pbm"
+#define ZTE_DB_PBM_DEVICE_TABLE "pbm_device"
+#define ZTE_DB_PBM_SIM_TABLE "pbm_sim"
+#define ZTE_DB_PBM_SIM_CAPABILITY_TABLE "pbm_sim_capability"
+#define ZTE_DB_PBM_DEVICE_CAPABILITY_TABLE "pbm_device_capability"
+
+#define MAX_NUMBER_OF_BYTES_FOR_SQL 1024
+
+
+//socket parameters
+//socket path
+#ifndef ZTE_PBM_PATH
+#define ZTE_PBM_PATH "zte_pbm"
+#endif
+
+//socket buffer size
+#ifndef ZTE_SOCKET_DATA_BUF_MAX
+#define ZTE_SOCKET_DATA_BUF_MAX 1024
+#endif
+
+//socket max liscen num
+#ifndef ZTE_SOCKET_MAX_LISCEN_NUM
+#define ZTE_SOCKET_MAX_LISCEN_NUM 50
+#endif
+
+//web ui pbm
+#ifndef PBM_MAX_DEL_LEN
+#define PBM_MAX_DEL_LEN 50
+#endif
+
+#ifndef ZTE_PB_INDEX_MAX
+#define ZTE_PB_INDEX_MAX 500
+#endif
+
+#ifndef ZTE_WEB_PBM_REC_LEN
+#define ZTE_WEB_PBM_REC_LEN 5
+#endif
+
+#ifndef PBM_WEB_MAX_CHAR_LEN
+#define PBM_WEB_MAX_CHAR_LEN ZTE_WEB_PBM_REC_LEN*ZTE_PB_INDEX_MAX
+#endif
+
+//number length
+#ifndef PBM_MAX_NUM_LENGTH
+#define PBM_MAX_NUM_LENGTH 40
+#endif
+
+#ifndef PBM_NUM_SIZE
+#define PBM_NUM_SIZE (PBM_MAX_NUM_LENGTH+2) /* + and null for string */
+#endif
+
+//name length
+#ifndef PBM_MAX_TEXT_LENGTH
+#define PBM_MAX_TEXT_LENGTH 90
+#endif
+
+#ifndef PBM_TEXT_SIZE_CHARS
+#define PBM_TEXT_SIZE_CHARS (PBM_MAX_TEXT_LENGTH+1) /* Null terminated string */
+#endif
+
+#ifndef PBM_TEXT_SIZE_BYTES
+#define PBM_TEXT_SIZE_BYTES (PBM_TEXT_SIZE_CHARS*sizeof(uint16)) /* size in bytes */
+#endif
+
+//the max numbers of record in modem location
+#define PBM_PC_MAX_RECORD 100
+
+
+#define PBM_OPERATE_SUC "0"
+#define PBM_LOADING "1"
+#define PBM_NEWING "2"
+#define PBM_DELING "3"
+#define PBM_MUT_DELING "4"
+#define PBM_ALL_DELING "5"
+#define PBM_LOAD_ERROR "6"
+#define PBM_NEW_ERROR "7"
+#define PBM_DEL_ERROR "8"
+#define PBM_NEW_ERROR_MEM_FULL "9"
+#define PBM_ERROR_CONVERT_CHEST "10"
+#define PBM_LOCATION_IS_NULL "11"
+#define ZTE_SUPPORT_SIM_PBM "12"
+#define ZTE_SUPPORT_USIM_PBM "13"
+#define ZTE_PBM_ERROR "14"
+#define PBM_MUL_DEL_PART_SUC "15"
+
+
+#define ZTE_PBM_NVCFG_LEN 15
+
+//the nvconfig of pbm module
+#ifndef ZTE_PBM_NV
+#define ZTE_PBM_NV "pbm_write_flag"
+#endif
+
+#ifndef ZTE_PBM_GROUP_NV
+#define ZTE_PBM_GROUP_NV "pbm_group"
+#endif
+
+#ifndef ZTE_SUPPORT_PBM_NV
+#define ZTE_SUPPORT_PBM_NV "support_pbm_flag"
+#endif
+
+#ifndef ZTE_PBM_INIT_NV
+#define ZTE_PBM_INIT_NV "pbm_init_flag"
+#endif
+
+
+
+//the location of pbm in web ui
+//#define PBM_LOCATION_DEVICE 1
+//#define PBM_LOCATION_SIM 0
+
+typedef enum
+{
+ PBM_LOCATION_SIM = 0, //sim card only,exsit in database
+ PBM_LOCATION_DEVICE = 1, //device only,exit in database
+ PBM_LOCATION_ALL = 2, //sim card and device, not exsit in database, only use in pbm code
+ PBM_LOCATION_GROUP = 3, //group in device,for example:common,family and so on,not exsit in database, only use in pbm code
+
+ PBM_LOCATION_MAX
+} zte_pbm_location_e_type;
+
+
+typedef enum
+{
+ ZTE_PBM_FAILURE = -1,
+ ZTE_PBM_SUCCESS = 0,
+ ZTE_PBM_NOT_SUPPORT = 1, //do not support web ui pbm
+
+ ZTE_PBM_MAX
+} zte_pbm_return_e_type;
+
+
+
+typedef struct
+{
+ int sim_type;
+ int max_record_number;
+ int used_record_number;
+ int max_name_len;
+ int max_number_len;
+ int max_anr_num;
+ int max_anr_len;
+ int max_anr1_num;
+ int max_anr1_len;
+ int max_email_num;
+ int max_email_len;
+ int max_sne_len;
+} zte_pbm_sim_capability_s_type;
+
+
+
+typedef struct
+{
+ int max_record_number;
+ int used_record_number;
+} zte_pbm_device_capability_s_type;
+
+//////*******///these structs must define in the libzte_mc.h begin
+#ifndef ZTE_MC_PBM_TYPE
+#define ZTE_MC_PBM_TYPE
+#ifdef ZTE_MC_PBM_TYPE
+typedef struct zte_pbm_create_ext_record_s_type
+{
+ int zte_pbm_id; //the id in the pbm table,unique,ASC
+ int zte_pbm_index;
+ int zte_pbm_location;
+ char zte_pbm_name[PBM_TEXT_SIZE_BYTES];
+ char zte_pbm_number[PBM_NUM_SIZE];
+ int zte_pbm_type;
+ char zte_pbm_anr[PBM_NUM_SIZE];
+ char zte_pbm_anr1[PBM_NUM_SIZE];
+ char zte_pbm_email[PBM_TEXT_SIZE_BYTES];
+ //char zte_pbm_sne[PBM_TEXT_SIZE_BYTES];
+ //char zte_pbm_group[PBM_TEXT_SIZE_BYTES];
+ char zte_pbm_sne[32];// 91*2 ---> 32 ÔÝʱδÓõ½¸Ã²ÎÊý
+ char zte_pbm_group[32]; // 91*2 ---> 32
+ int zte_pbm_del_id;
+} zte_pbm_create_ext_record_s_type;
+
+
+typedef struct zte_pbm_del_multi_records_s_type
+{
+ int zte_del_pbm_id[PBM_MAX_DEL_LEN];
+ int zte_del_pbm_total;
+ int zte_del_pbm_location;
+ int zte_del_pbm_index[PBM_MAX_DEL_LEN];
+} zte_pbm_del_multi_records_s_type;
+#endif
+#endif
+
+//////*******///these structs must define in the libzte_mc.h end
+
+/*
+typedef enum zte_pbm_cmd_e_type
+{
+ ZTE_PBM_LOAD_REC_MSG=0,-
+ ZTE_PBM_WRITE_REC_MSG,-
+ ZTE_PBM_DEL_A_REC_MSG,-
+ ZTE_PBM_DEL_MUTI_REC_MSG,-
+ ZTE_PBM_DEL_ALL_REC_MSG,-
+ ZTE_PBM_SLEEP_MSG,
+ ZTE_PBM_WAKEUP_MSG,
+ ZTE_PBM_LOAD_WITHOUT_SIM_MSG,-
+ ZTE_PBM_MAX_MSG,
+} zte_pbm_cmd_e_type;
+*/
+
+/*
+typedef union zte_pbm_data_u_type
+{
+ zte_pbm_create_ext_record_s_type zte_new_pbm_data;
+ zte_pbm_del_multi_records_s_type zte_del_pbm_data;
+
+} zte_pbm_data_u_type;
+*/
+
+/*
+typedef struct zte_pbm_msg_s_type
+{
+ zte_pbm_cmd_e_type zte_pbm_msg;
+ zte_pbm_data_u_type zte_pbm_data;
+
+} zte_pbm_msg_s_type;
+*/
+
+typedef struct zte_pbm_header_s_type
+{
+ int zte_id; //the id in the pbm table,unique,ASC
+ int zte_index;
+ int zte_location;
+} zte_pbm_header_s_type;
+
+
+
+typedef struct
+{
+ uint8 page;
+ uint8 num_per_page;
+ zte_pbm_location_e_type location;
+ boolean asc_flag;
+ uint8 order_by;
+} zte_pbm_query_req_s_type;
+
+typedef struct
+{
+ uint8 count;
+ zte_pbm_create_ext_record_s_type data[0];/*lint !e1501*/
+} zte_pbm_query_resp_s_type;
+
+
+//////*******///these functions must define in the libzte_mc.h begin
+#ifndef ZTE_MC_PBM_TYPE
+#define ZTE_MC_PBM_TYPE
+#ifdef ZTE_MC_PBM_TYPE
+//void zte_mc_pbm_load_rec();
+//void zte_mc_pbm_write_rec(zte_pbm_create_ext_record_s_type *pbm_recv_record);
+//void zte_mc_pbm_del_a_rec(zte_pbm_del_multi_records_s_type *pbm_recv_record);
+//void zte_mc_pbm_del_multi_recs(zte_pbm_del_multi_records_s_type *pbm_recv_record);
+//void zte_mc_pbm_del_all_recs(zte_pbm_del_multi_records_s_type *pbm_recv_record);
+//void zte_mc_pbm_load_if_no_sim();
+void aaa(int i);
+#endif
+#endif
+//////*******///these functions must define in the libzte_mc.h end
+
+//void zte_mc_pbm_sleep_wakeup(zte_pbm_cmd_e_type pbm_msg_type);
+
+//////the interface for get pbm data and capability for web server
+int zte_libpbm_get_capability
+(
+ zte_pbm_query_req_s_type *req,
+ zte_pbm_sim_capability_s_type *sim_para,
+ zte_pbm_device_capability_s_type *device_para
+);
+int zte_libpbm_get_rec_data (zte_pbm_query_req_s_type *req, zte_pbm_query_resp_s_type*resp);
+int zte_libpbm_get_name_by_number(char *pbm_number, char *pbm_name);
+
+
+#endif
+