yuezonghe | 824eb0c | 2024-06-27 02:32:26 -0700 | [diff] [blame] | 1 | /*********************************************************************************** |
| 2 | * Description: define handle function for CELL BROADCAST module |
| 3 | * Modify Date Version Author Modification |
| 4 | * 2013/01/08 V1.0 chenyi create |
| 5 | ***********************************************************************************/ |
| 6 | #include "message.h" |
| 7 | #include "zte_web_cell_broadcast.h" |
| 8 | #include "zte_web_interface.h" |
| 9 | //#include "../../sms_pbm/libzte_wms.h" |
| 10 | |
| 11 | #define ZTE_CBM_DELETE_COUNT_MAX 100 |
| 12 | #define CBM_MSG_ID_LEN 11 |
| 13 | #define CBM_SEPARATOR_CHARACTER ';' |
| 14 | |
| 15 | static void zte_web_feed_back_cb_msg_empty(webs_t wp); |
| 16 | |
| 17 | /****************************************************** |
| 18 | * Function: parseStrBySeparator() |
| 19 | * Description: separate the string by a specific character |
| 20 | * Input: |
| 21 | * Output: |
| 22 | * Return: -1--->failed, 0--->successful |
| 23 | * Others: |
| 24 | * Modify Date Version Author Modification |
| 25 | * 2010/10/27 V1.0 huangmin create |
| 26 | 2012/06/20 v2.0 chenyi modify |
| 27 | *******************************************************/ |
| 28 | static unsigned int parseStrBySeparator |
| 29 | ( |
| 30 | unsigned char* input, |
| 31 | unsigned char* output, |
| 32 | int destLen, |
| 33 | unsigned char separator |
| 34 | ) |
| 35 | { |
| 36 | int i, j, k; |
| 37 | int srcLen = 0; |
| 38 | i = j = k = 0; |
| 39 | |
| 40 | if (NULL == input || NULL == output || destLen == 0 || strlen(input) == 0) { |
| 41 | slog(MISC_PRINT, SLOG_DEBUG, "parseStrBySemicolon: param is null!\n"); |
| 42 | return 0; |
| 43 | } |
| 44 | |
| 45 | srcLen = strlen(input) + 1;//which contains the '\0' |
| 46 | |
| 47 | for (i = 0; i < srcLen; i++) { |
| 48 | if ('\0' == input[i]) { |
| 49 | if (k <= (destLen - 1)) { |
| 50 | *(output + destLen * j + k) = '\0'; |
| 51 | } else { |
| 52 | *(output + destLen * j + (destLen - 1)) = '\0'; |
| 53 | } |
| 54 | |
| 55 | return j + 1; |
| 56 | } |
| 57 | |
| 58 | if (separator == input[i]) { |
| 59 | if (k <= (destLen - 1)) { |
| 60 | *(output + destLen * j + k) = '\0'; |
| 61 | } else { |
| 62 | *(output + destLen * j + (destLen - 1)) = '\0'; |
| 63 | } |
| 64 | |
| 65 | if ('\0' != input[i + 1]) { |
| 66 | k = 0; |
| 67 | j++; |
| 68 | } |
| 69 | } else { |
| 70 | if (k < (destLen - 1)) { |
| 71 | *(output + destLen * j + k) = input[i]; |
| 72 | k++; |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | return j; |
| 78 | } |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | /********************************************************************** |
| 86 | * Function: zte_web_feed_back_cb_msg_empty |
| 87 | * Description: to write empty cb msg to web |
| 88 | * Input: the web para |
| 89 | * Output: |
| 90 | * Return: |
| 91 | * Others: |
| 92 | * Modify Date Version Author Modification |
| 93 | * ----------------------------------------------- |
| 94 | * 2013/01/08 V1.0 chenyi first version |
| 95 | **********************************************************************/ |
| 96 | static void zte_web_feed_back_cb_msg_empty(webs_t wp) |
| 97 | { |
| 98 | if (NULL == wp) { |
| 99 | return; |
| 100 | } |
| 101 | |
| 102 | web_feedback_header(wp); |
| 103 | (void)websWrite(wp, T("{\"%s\":[]}"), CB_MSG); |
| 104 | } |
| 105 | |