merge from master branch's latest code.
[apps/core/preloaded/ciss.git] / src / ciss-parser.c
index 0ec236a..9a1f458 100644 (file)
@@ -33,9 +33,9 @@ static int __ciss_find_si_fields(char *user_input, char *sc, char *sia, char *si
        input = user_input;\r
        sc_len = strspn(input, "0123456789");\r
        DBG("\n [CISS-ENGINE] sc_len : %d", sc_len);\r
-       if (sc_len > MAX_SC_LEN)\r
+       if (sc_len > MAX_SC_LEN) {\r
                return FALSE;\r
-       else {\r
+       else {\r
                memcpy(sc, input, sc_len);\r
                sc[sc_len] = '\0';\r
        }\r
@@ -45,7 +45,7 @@ static int __ciss_find_si_fields(char *user_input, char *sc, char *sia, char *si
                sia_len = strspn((input + sia_offset), "+1234567890");\r
                if (input[sia_offset + sia_len] == '*') {       /* 2nd Seperator */\r
                        sib_offset = sia_offset + sia_len + 1;\r
-                       sib_len = strspn (input + sib_offset, "+1234567890");\r
+                       sib_len = strspn(input + sib_offset, "+1234567890");\r
                        if (input[sib_offset + sib_len] == '*') {       /* 3rd Seperator */\r
                                sic_offset = sib_offset + sib_len + 1;\r
                                sic_len = strspn(input + sic_offset, "+1234567890");\r
@@ -69,10 +69,11 @@ static int __ciss_find_si_fields(char *user_input, char *sc, char *sia, char *si
        }\r
 \r
        if ((sib_len > MAX_SIB_LEN) ||\r
-           (sia_len > MAX_SIA_LEN) ||\r
-           (sic_len > MAX_SIC_LEN))\r
+                       (sia_len > MAX_SIA_LEN) ||\r
+                       (sic_len > MAX_SIC_LEN)) {\r
                return FALSE;\r
-    return TRUE;\r
+       }\r
+       return TRUE;\r
 }\r
 \r
 static unsigned char __ciss_parse_mmi_string(ciss_mmi_context_t *mmi_ctx, int *error_code)\r
@@ -113,9 +114,10 @@ static unsigned char __ciss_parse_mmi_string(ciss_mmi_context_t *mmi_ctx, int *e
        ss_str_len = mmi_ctx->user_string_length;\r
 \r
        if (((memcmp(sups_str, "*31#", 4) == 0) ||\r
-           (memcmp(sups_str, "#31#", 4) == 0)) &&\r
-           (sups_str[ss_str_len - 1] != '#'))\r
+                       (memcmp(sups_str, "#31#", 4) == 0)) &&\r
+                       (sups_str[ss_str_len - 1] != '#')) {\r
                return NULL_SS_OPERATION;\r
+       }\r
 \r
        if (sups_str[0] == '*') {\r
                if (ISDIGIT(sups_str [1])) {\r
@@ -185,10 +187,10 @@ static unsigned char __ciss_parse_mmi_string(ciss_mmi_context_t *mmi_ctx, int *e
 \r
        strncpy(mmi_ctx->ss_code, ss_code, MAX_SC_LEN);\r
        if ((ss_operation != registerPassword) &&\r
-           (ss_operation != NULL_SS_OPERATION)) {\r
-               if (!_ciss_convert_sc_to_tapi_flavor(ss_code, &tapi_flavor, &ss_type))\r
+                       (ss_operation != NULL_SS_OPERATION)) {\r
+               if (!_ciss_convert_sc_to_tapi_flavor(ss_code, &tapi_flavor, &ss_type)) {\r
                        ss_operation = NULL_SS_OPERATION;\r
-               else {\r
+               else {\r
                        mmi_ctx->ss_flavor = tapi_flavor;\r
                        mmi_ctx->ss_type = ss_type;\r
                }\r
@@ -196,26 +198,26 @@ static unsigned char __ciss_parse_mmi_string(ciss_mmi_context_t *mmi_ctx, int *e
 \r
        if (ss_operation != NULL_SS_OPERATION) {\r
                if ((ss_operation != registerPassword)&&\r
-                   ((ss_type == CISS_SERVICE_FORWARDING)||\r
-                   (ss_type == CISS_SERVICE_BARRING))) {\r
-                       if (ss_operation == interrogateSS)\r
-                               strncpy(bsg, sia, MAX_SIA_LEN);\r
-                       else\r
+                               ((ss_type == CISS_SERVICE_FORWARDING)||\r
+                                (ss_type == CISS_SERVICE_BARRING))) {\r
                                strncpy(bsg, sib, MAX_SIB_LEN);\r
                } else if (ss_type == CISS_SERVICE_WAITING) {\r
-                       if ((sib[0] !=0) || (sic[0] != 0))\r
+                       if ((sib[0] !=0) || (sic[0] != 0)) {\r
                                ss_operation = NULL_SS_OPERATION;\r
-                       else\r
+                       } else {\r
                                strncpy(bsg, sia, MAX_SIA_LEN);\r
-               } else\r
+                       }\r
+               } else {\r
                        bsg[0] = '\0';\r
+               }\r
 \r
                if ((ss_operation != registerPassword) &&\r
-                   (ss_operation != NULL_SS_OPERATION)) {\r
-                       if (_ciss_convert_bsg_to_tapi_bsg(bsg, &tapi_bsg))\r
+                               (ss_operation != NULL_SS_OPERATION)) {\r
+                       if (_ciss_convert_bsg_to_tapi_bsg(bsg, &tapi_bsg)) {\r
                                mmi_ctx->tapi_bsg = tapi_bsg;\r
-                       else\r
+                       } else {\r
                                ss_operation = NULL_SS_OPERATION;\r
+                       }\r
                }\r
        }\r
 \r
@@ -229,26 +231,28 @@ static unsigned char __ciss_parse_mmi_string(ciss_mmi_context_t *mmi_ctx, int *e
        }\r
 \r
        if (((ss_operation == activateSS) || (ss_operation == registerSS)) &&\r
-           (ss_type == CISS_SERVICE_FORWARDING) &&\r
-           ((tapi_flavor == CISS_FLAVOR_FORWARD_ALL_FLAVORS) ||\r
-           (tapi_flavor == CISS_FLAVOR_FORWARD_ALL_CONDITIONAL_FLAVORS) ||\r
-           (tapi_flavor == TAPI_SS_CF_WHEN_CFNRy))) {\r
-               if (sic[0] != '\0')\r
+                       (ss_type == CISS_SERVICE_FORWARDING) &&\r
+                       ((tapi_flavor == CISS_FLAVOR_FORWARD_ALL_FLAVORS) ||\r
+                        (tapi_flavor == CISS_FLAVOR_FORWARD_ALL_CONDITIONAL_FLAVORS) ||\r
+                        (tapi_flavor == TAPI_SS_CF_WHEN_CFNRy))) {\r
+               if (sic[0] != '\0') {\r
                        mmi_ctx->nr_timer = atoi(sic);\r
-               else\r
+               } else {\r
                        mmi_ctx->nr_timer = 0;\r
+               }\r
        }\r
 \r
        if (ss_operation == activateSS) {\r
-               if (mmi_ctx->forward_number[0] > 0)\r
+               if (mmi_ctx->forward_number[0] > 0) {\r
                        ss_operation = registerSS;\r
-               else if (mmi_ctx->nr_timer != 0)\r
+               } else if (mmi_ctx->nr_timer != 0) {\r
                        ss_operation = registerSS;\r
+               }\r
        }\r
 \r
        if (ss_operation != NULL_SS_OPERATION) {\r
                if ((ss_type == CISS_SERVICE_BARRING) ||\r
-                   (ss_operation == registerPassword)) {\r
+                               (ss_operation == registerPassword)) {\r
                        if (strlen(sia) > 4) {\r
                                DBG("\n [CISS-ENGINE] Too long password");\r
                                ss_operation = NULL_SS_OPERATION;\r
@@ -258,7 +262,7 @@ static unsigned char __ciss_parse_mmi_string(ciss_mmi_context_t *mmi_ctx, int *e
                }\r
 \r
                if ((ss_type == CISS_SERVICE_BARRING) &&\r
-                   (ss_operation != registerPassword)) {\r
+                               (ss_operation != registerPassword)) {\r
                        if (ss_operation != interrogateSS) {\r
                                if (strlen(sia) < 4) {\r
                                        DBG("\n [CISS-ENGINE] Pwd Too Short : %d",strlen(sia));\r
@@ -280,8 +284,8 @@ static unsigned char __ciss_parse_mmi_string(ciss_mmi_context_t *mmi_ctx, int *e
 \r
        if (ss_operation == registerPassword) {\r
                if ((strlen(sia) != 4) ||\r
-                   (strlen(sib) != 4) ||\r
-                   (strlen(sic) != 4)) {\r
+                               (strlen(sib) != 4) ||\r
+                               (strlen(sic) != 4)) {\r
                        DBG("\n [CISS-ENGINE] Pwd Length Incorrect : %d %d %d", strlen(sia), strlen(sib), strlen(sic));\r
                        memset(mmi_ctx->ss_password, '\0', CISS_MAX_PASSWORD_LEN + 1);\r
                        memset(mmi_ctx->ss_new_password, '\0', CISS_MAX_PASSWORD_LEN + 1);\r
@@ -301,9 +305,10 @@ static unsigned char __ciss_parse_mmi_string(ciss_mmi_context_t *mmi_ctx, int *e
 \r
        if (ss_operation == NULL_SS_OPERATION) {\r
                if ((ss_str_len <= MAX_USS_CHAR) &&\r
-                   (ss_str_len > 2) &&\r
-                   (sups_str[ss_str_len - 1] == '#'))\r
+                               (ss_str_len > 2) &&\r
+                               (sups_str[ss_str_len - 1] == '#')) {\r
                        ss_operation = processUnstructuredSS_Request;\r
+               }\r
        }\r
        return (ss_operation);\r
 }\r
@@ -314,9 +319,9 @@ int _ciss_parse_req_string(char *pszSS, ciss_mmi_context_t *mmi_ctx)
        memset(mmi_ctx, 0x0, sizeof(ciss_mmi_context_t));\r
        DBG("\n [CISS-ENGINE] received string = %s", pszSS);\r
        mmi_ctx->user_string_length = strlen(pszSS);\r
-       if (mmi_ctx->user_string_length > 0)\r
+       if (mmi_ctx->user_string_length > 0) {\r
                memcpy(mmi_ctx->user_string, pszSS, mmi_ctx->user_string_length);\r
-       else {\r
+       else {\r
                DBG("\n [CISS-ENGINE] User String Length should be non-zero");\r
                return CISS_ERR_UNKNOWN;\r
        }\r
@@ -326,18 +331,19 @@ int _ciss_parse_req_string(char *pszSS, ciss_mmi_context_t *mmi_ctx)
        if (mmi_ctx->opcode == processUnstructuredSS_Request) {\r
                mmi_ctx->ussd_type = TAPI_SS_USSD_TYPE_USER_INIT;\r
        }\r
-       DBG("\n [CISS-ENGINE] Parsed opcode = %d", mmi_ctx->opcode);\r
-       DBG("\n [CISS-ENGINE] Parsed SSCode = %x", mmi_ctx->ss_flavor);\r
-       DBG("\n [CISS-ENGINE] Parsed SStype = %x", mmi_ctx->ss_type);\r
-       DBG("\n [CISS-ENGINE] Parsed BS Code = %x  ", mmi_ctx->tapi_bsg);\r
-       DBG("\n [CISS-ENGINE] Parsed NR Timer = %d", mmi_ctx->nr_timer);\r
-       DBG("\n [CISS-ENGINE] Parsed Forwarded No = %s", mmi_ctx->forward_number);\r
-       DBG("\n [CISS-ENGINE] Parsed SS Pwd = %s", mmi_ctx->ss_password);\r
-       DBG("\n [CISS-ENGINE] Parsed SS New Pwd = %s", mmi_ctx->ss_new_password);\r
-       DBG("\n [CISS-ENGINE] Parsed SS New Pwd cnf = %s", mmi_ctx->ss_new_password2);\r
+       DBG(" [CISS-ENGINE] Parsed opcode = 0x%x", mmi_ctx->opcode);\r
+       DBG(" [CISS-ENGINE] Parsed SSCode = 0x%x", mmi_ctx->ss_flavor);\r
+       DBG(" [CISS-ENGINE] Parsed SStype = 0x%x", mmi_ctx->ss_type);\r
+       DBG(" [CISS-ENGINE] Parsed BS Code = 0x%x  ", mmi_ctx->tapi_bsg);\r
+       DBG(" [CISS-ENGINE] Parsed NR Timer = %d", mmi_ctx->nr_timer);\r
+       DBG(" [CISS-ENGINE] Parsed Forwarded No = %s", mmi_ctx->forward_number);\r
+       DBG(" [CISS-ENGINE] Parsed SS Pwd = %s", mmi_ctx->ss_password);\r
+       DBG(" [CISS-ENGINE] Parsed SS New Pwd = %s", mmi_ctx->ss_new_password);\r
+       DBG(" [CISS-ENGINE] Parsed SS New Pwd cnf = %s", mmi_ctx->ss_new_password2);\r
        if ((mmi_ctx->opcode == NULL_SS_OPERATION) &&\r
-           (error_code == CISS_ERR_NONE))\r
+                       (error_code == CISS_ERR_NONE)) {\r
                error_code = CISS_ERR_ILLEGAL_SS_OPER;\r
+       }\r
 \r
        return error_code;\r
 }\r