fixed a few files as coding style. 06/42206/1 tizen_3.0.m1_mobile accepted/tizen/mobile/20150625.054729 accepted/tizen/tv/20151027.231813 submit/tizen_mobile/20150625.025248 submit/tizen_tv/20151027.084504 submit/tizen_wearable/20150714.084151 tizen_3.0.m1_mobile_release tizen_3.0.m2.a1_mobile_release
authorIckhee Woo <ickhee.woo@samsung.com>
Wed, 24 Jun 2015 11:15:58 +0000 (20:15 +0900)
committerIckhee Woo <ickhee.woo@samsung.com>
Wed, 24 Jun 2015 11:15:58 +0000 (20:15 +0900)
Change-Id: Iad005f204eeec638d74baa39a77ee741f3a75425
Signed-off-by: Ickhee Woo <ickhee.woo@samsung.com>
TC/utc-oauth2.c
sample/oauth2sample/src/main.c
sample/oauth2sample/src/oauth2_handler.c
src/oauth2_manager.c
src/oauth2_response.c
src/oauth2_util.c

index 2cf323c08cf60e7aaf2db816181925684b53c2fa..4755885453d48d343ea65be144353af5bfdda07a 100644 (file)
@@ -1,12 +1,10 @@
 #include "assert.h"
 #include <oauth2.h>
 #include <string.h>
-#include <glib-2.0/glib.h>
-#include <dlog.h>
 
-#define OAUTH2_FREE(ptr)       \
-               if (ptr != NULL) {      \
-                       free(ptr);      \
+#define OAUTH2_FREE(ptr) \
+               if (ptr != NULL) { \
+                       free(ptr); \
                        ptr = NULL; \
                }
 
@@ -14,30 +12,18 @@ static bool manager_created = false;
 static bool request_created = false;
 static oauth2_manager_h manager = NULL;
 static oauth2_request_h request = NULL;
-static GMainLoop* mainloop = NULL;
 static int _is_fail = true;
 
-static gboolean timeout_cb(gpointer data) {
-       printf("timeout!\n");
-       _is_fail = true;
-       g_main_loop_quit((GMainLoop*)data);
-       return FALSE;
-}
-
 void utc_oauth2_startup(void)
 {
        int ret = OAUTH2_ERROR_NONE;
        ret = oauth2_manager_create(&manager);
        if (ret == OAUTH2_ERROR_NONE)
-       {
                manager_created = true;
-       }
 
        ret = oauth2_request_create(&request);
        if (ret == OAUTH2_ERROR_NONE)
-       {
                request_created = true;
-       }
 }
 
 void utc_oauth2_cleanup(void)
@@ -45,15 +31,15 @@ void utc_oauth2_cleanup(void)
        int ret = OAUTH2_ERROR_NONE;
        ret = oauth2_manager_destroy(manager);
        if (ret == OAUTH2_ERROR_NONE)
-       {
                manager_created = false;
-       }
+
+       manager = NULL;
 
        ret = oauth2_request_destroy(request);
        if (ret == OAUTH2_ERROR_NONE)
-       {
                request_created = false;
-       }
+
+       request = NULL;
 }
 
 int utc_oauth2_manager_create_p(void)
@@ -74,24 +60,23 @@ int utc_oauth2_manager_create_n(void)
 
 int oauth2_manager_destroy_p(void)
 {
-       assert(manager_created);
-       utc_oauth2_cleanup();
+       oauth2_manager_h manager_local = NULL;
 
-       assert(!manager_created);
+       int ret = oauth2_manager_create(&manager_local);
+       assert_eq(ret, OAUTH2_ERROR_NONE);
 
-       utc_oauth2_startup();
+       ret = oauth2_manager_destroy(manager_local);
+       assert_eq(ret, OAUTH2_ERROR_NONE);
 
        return 0;
 }
 
 int oauth2_manager_destroy_n(void)
 {
-       // TODO
-       /*
        int ret = OAUTH2_ERROR_NONE;
        ret = oauth2_manager_destroy(NULL);
        assert_eq(ret, OAUTH2_ERROR_INVALID_PARAMETER);
-       */
+
        return 0;
 }
 
@@ -140,21 +125,8 @@ int oauth2_manager_is_request_in_progress_n(void)
        int ret = OAUTH2_ERROR_NONE;
 
        ret = oauth2_manager_is_request_in_progress(NULL);
-       assert_eq(ret, FALSE);
-
-       return 0;
-}
-
-int oauth2_manager_clear_cookies_p(void)
-{
-       // TODO
-/*
-       assert(manager_created);
-       int ret = OAUTH2_ERROR_NONE;
+       assert_eq(ret, false);
 
-       ret = oauth2_manager_clear_cookies(manager);
-       assert_eq(ret, OAUTH2_ERROR_NONE);
-*/
        return 0;
 }
 
@@ -168,19 +140,6 @@ int oauth2_manager_clear_cookies_n(void)
        return 0;
 }
 
-int oauth2_manager_clear_cache_p(void)
-{
-       // TODO
-/*
-       assert(manager_created);
-       int ret = OAUTH2_ERROR_NONE;
-
-       ret = oauth2_manager_clear_cache(manager);
-       assert_eq(ret, OAUTH2_ERROR_NONE);
-*/
-       return 0;
-}
-
 int oauth2_manager_clear_cache_n(void)
 {
        int ret = OAUTH2_ERROR_NONE;
@@ -226,12 +185,10 @@ int oauth2_request_destroy_p(void)
 
 int oauth2_request_destroy_n(void)
 {
-       // TODO
-       /*
        int ret = OAUTH2_ERROR_NONE;
        ret = oauth2_request_destroy(NULL);
        assert_eq(ret, OAUTH2_ERROR_INVALID_PARAMETER);
-       */
+
        return 0;
 }
 
@@ -576,7 +533,6 @@ int oauth2_request_set_password_n(void)
 
 int oauth2_request_add_custom_data_p(void)
 {
-       // TODO
        assert(request);
 
        int ret = OAUTH2_ERROR_NONE;
@@ -589,7 +545,6 @@ int oauth2_request_add_custom_data_p(void)
 
 int oauth2_request_add_custom_data_n(void)
 {
-       // TODO
        assert(request);
 
        int ret = OAUTH2_ERROR_NONE;
@@ -615,7 +570,6 @@ int oauth2_request_get_auth_end_point_url_p(void)
 
        assert_eq(strcmp("www.example.com", url), 0);
 
-       OAUTH2_FREE(url);
        return 0;
 }
 
@@ -647,7 +601,6 @@ int oauth2_request_get_token_end_point_url_p(void)
 
        assert_eq(strcmp("www.example.com", url), 0);
 
-       OAUTH2_FREE(url);
        return 0;
 }
 
@@ -679,7 +632,6 @@ int oauth2_request_get_redirection_url_p(void)
 
        assert_eq(strcmp("www.example.com", url), 0);
 
-       OAUTH2_FREE(url);
        return 0;
 }
 
@@ -711,7 +663,6 @@ int oauth2_request_get_refresh_token_url_p(void)
 
        assert_eq(strcmp("www.example.com", url), 0);
 
-       OAUTH2_FREE(url);
        return 0;
 }
 
@@ -743,7 +694,6 @@ int oauth2_request_get_refresh_token_p(void)
 
        assert_eq(strcmp("refresh_token", token), 0);
 
-       OAUTH2_FREE(token);
        return 0;
 }
 
@@ -807,7 +757,6 @@ int oauth2_request_get_client_id_p(void)
 
        assert_eq(strcmp("client_id", id), 0);
 
-       OAUTH2_FREE(id);
        return 0;
 }
 
@@ -839,7 +788,6 @@ int oauth2_request_get_client_secret_p(void)
 
        assert_eq(strcmp("client_secret", secret), 0);
 
-       OAUTH2_FREE(secret);
        return 0;
 }
 
@@ -871,7 +819,6 @@ int oauth2_request_get_scope_p(void)
 
        assert_eq(strcmp("email", scope), 0);
 
-       OAUTH2_FREE(scope);
        return 0;
 }
 
@@ -903,7 +850,6 @@ int oauth2_request_get_state_p(void)
 
        assert_eq(strcmp("sample_state", state), 0);
 
-       OAUTH2_FREE(state);
        return 0;
 }
 
@@ -967,7 +913,6 @@ int oauth2_request_get_authorization_code_p(void)
 
        assert_eq(strcmp("auth_code", code), 0);
 
-       OAUTH2_FREE(code);
        return 0;
 }
 
@@ -999,7 +944,6 @@ int oauth2_request_get_user_name_p(void)
 
        assert_eq(strcmp("user_name", user_name), 0);
 
-       OAUTH2_FREE(user_name);
        return 0;
 }
 
@@ -1031,7 +975,6 @@ int oauth2_request_get_password_p(void)
 
        assert_eq(strcmp("password", password), 0);
 
-       OAUTH2_FREE(password);
        return 0;
 }
 
@@ -1084,19 +1027,6 @@ int oauth2_request_get_custom_data_n(void)
  * response
  */
 
-int oauth2_response_destroy_p(void)
-{
-       // TODO
-/*
-       int ret = OAUTH2_ERROR_NONE;
-       oauth2_response_h response = NULL;
-
-       ret = oauth2_response_destroy(response);
-       assert_eq(ret, OAUTH2_ERROR_NONE);
-*/
-       return 0;
-}
-
 int oauth2_response_destroy_n(void)
 {
        int ret = OAUTH2_ERROR_NONE;
@@ -1107,20 +1037,6 @@ int oauth2_response_destroy_n(void)
        return 0;
 }
 
-int oauth2_response_get_authorization_code_p(void)
-{
-       // TODO
-/*
-       int ret = OAUTH2_ERROR_NONE;
-       oauth2_response_h response = NULL;
-       char *code = NULL;
-
-       ret = oauth2_response_get_authorization_code(response, &code);
-       assert_eq(ret, OAUTH2_ERROR_NONE);
-*/
-       return 0;
-}
-
 int oauth2_response_get_authorization_code_n(void)
 {
        int ret = OAUTH2_ERROR_NONE;
@@ -1132,20 +1048,6 @@ int oauth2_response_get_authorization_code_n(void)
        return 0;
 }
 
-int oauth2_response_get_state_p(void)
-{
-       // TODO
-/*
-       int ret = OAUTH2_ERROR_NONE;
-       oauth2_response_h response = NULL;
-       char *state = NULL;
-
-       ret = oauth2_response_get_state(response, &state);
-       assert_eq(ret, OAUTH2_ERROR_NONE);
-*/
-       return 0;
-}
-
 int oauth2_response_get_state_n(void)
 {
        int ret = OAUTH2_ERROR_NONE;
@@ -1157,20 +1059,6 @@ int oauth2_response_get_state_n(void)
        return 0;
 }
 
-int oauth2_response_get_access_token_p(void)
-{
-       // TODO
-/*
-       int ret = OAUTH2_ERROR_NONE;
-       oauth2_response_h response = NULL;
-       char *token = NULL;
-
-       ret = oauth2_response_get_access_token(response, &token);
-       assert_eq(ret, OAUTH2_ERROR_NONE);
-*/
-       return 0;
-}
-
 int oauth2_response_get_access_token_n(void)
 {
        int ret = OAUTH2_ERROR_NONE;
@@ -1182,20 +1070,6 @@ int oauth2_response_get_access_token_n(void)
        return 0;
 }
 
-int oauth2_response_get_token_type_p(void)
-{
-       // TODO
-/*
-       int ret = OAUTH2_ERROR_NONE;
-       oauth2_response_h response = NULL;
-       char *type = NULL;
-
-       ret = oauth2_response_get_token_type(response, &type);
-       assert_eq(ret, OAUTH2_ERROR_NONE);
-*/
-       return 0;
-}
-
 int oauth2_response_get_token_type_n(void)
 {
        int ret = OAUTH2_ERROR_NONE;
@@ -1207,20 +1081,6 @@ int oauth2_response_get_token_type_n(void)
        return 0;
 }
 
-int oauth2_response_get_expires_in_p(void)
-{
-       // TODO
-/*
-       int ret = OAUTH2_ERROR_NONE;
-       oauth2_response_h response = NULL;
-       long long expires_in = 0;
-
-       ret = oauth2_response_get_expires_in(response, &expires_in);
-       assert_eq(ret, OAUTH2_ERROR_NONE);
-*/
-       return 0;
-}
-
 int oauth2_response_get_expires_in_n(void)
 {
        int ret = OAUTH2_ERROR_NONE;
@@ -1232,107 +1092,100 @@ int oauth2_response_get_expires_in_n(void)
        return 0;
 }
 
-int oauth2_response_get_refresh_token_p(void)
+int oauth2_response_get_refresh_token_n(void)
 {
-       // TODO
-/*
        int ret = OAUTH2_ERROR_NONE;
-       oauth2_response_h response = NULL;
        char *token = NULL;
 
-       ret = oauth2_response_get_refresh_token(response, &token);
-       assert_eq(ret, OAUTH2_ERROR_NONE);
-*/
+       ret = oauth2_response_get_refresh_token(NULL, &token);
+       assert_eq(ret, OAUTH2_ERROR_INVALID_PARAMETER);
+
        return 0;
 }
 
-int oauth2_response_get_refresh_token_n(void)
+int oauth2_response_get_scope_n(void)
 {
        int ret = OAUTH2_ERROR_NONE;
-       char *token = NULL;
+       char *scope = NULL;
 
-       ret = oauth2_response_get_refresh_token(NULL, &token);
+       ret = oauth2_response_get_scope(NULL, &scope);
        assert_eq(ret, OAUTH2_ERROR_INVALID_PARAMETER);
 
        return 0;
 }
 
-int oauth2_response_get_scope_p(void)
+int oauth2_response_get_error_n(void)
 {
-       // TODO
-/*
        int ret = OAUTH2_ERROR_NONE;
-       oauth2_response_h response = NULL;
-       char *scope = NULL;
+       oauth2_error_h err = NULL;
+
+       ret = oauth2_response_get_error(NULL, &err);
+       assert_eq(ret, OAUTH2_ERROR_INVALID_PARAMETER);
 
-       ret = oauth2_response_get_scope(response, &scope);
-       assert_eq(ret, OAUTH2_ERROR_NONE);
-*/
        return 0;
 }
 
-int oauth2_response_get_scope_n(void)
+int oauth2_response_get_custom_data_n(void)
 {
+       assert(request);
+
        int ret = OAUTH2_ERROR_NONE;
-       char *scope = NULL;
 
-       ret = oauth2_response_get_scope(NULL, &scope);
+       char *val = NULL;
+       ret = oauth2_response_get_custom_data(NULL, "key", &val);
        assert_eq(ret, OAUTH2_ERROR_INVALID_PARAMETER);
 
        return 0;
 }
 
-int oauth2_response_get_error_p(void)
-{
-       // TODO
+
 /*
+ * error
+ */
+
+int oauth2_error_get_code_n(void)
+{
        int ret = OAUTH2_ERROR_NONE;
-       oauth2_response_h response = NULL;
-       oauth2_error_h err = NULL;
 
-       ret = oauth2_response_get_error(response, &err);
-       assert_eq(ret, OAUTH2_ERROR_NONE);
-*/
+       int val1 = 0;
+       int val2 = 0;
+
+       ret = oauth2_error_get_code(NULL, &val1, &val2);
+       assert_eq(ret, OAUTH2_ERROR_INVALID_PARAMETER);
+
        return 0;
 }
 
-int oauth2_response_get_error_n(void)
+int oauth2_error_get_description_n(void)
 {
        int ret = OAUTH2_ERROR_NONE;
-       oauth2_error_h err = NULL;
+       char *description = NULL;
 
-       ret = oauth2_response_get_error(NULL, &err);
+       ret = oauth2_error_get_description(NULL, &description);
        assert_eq(ret, OAUTH2_ERROR_INVALID_PARAMETER);
 
        return 0;
 }
 
-int oauth2_response_get_custom_data_p(void)
+int oauth2_error_get_uri_n(void)
 {
-       // TODO
-/*
-       assert(request);
-
        int ret = OAUTH2_ERROR_NONE;
+       char *uri = NULL;
 
-       char *val = NULL;
-       ret = oauth2_response_get_custom_data(request, "c_key", &val);
-       assert_eq(ret, OAUTH2_ERROR_NONE);
+       ret = oauth2_error_get_uri(NULL, &uri);
+       assert_eq(ret, OAUTH2_ERROR_INVALID_PARAMETER);
 
-       assert_eq(strcmp("c_val", val), 0);
-*/
        return 0;
 }
 
-int oauth2_response_get_custom_data_n(void)
+int oauth2_error_get_custom_data_n(void)
 {
-       assert(request);
-
        int ret = OAUTH2_ERROR_NONE;
 
        char *val = NULL;
-       ret = oauth2_response_get_custom_data(NULL, "key", &val);
+       ret = oauth2_error_get_custom_data(NULL, "key", &val);
        assert_eq(ret, OAUTH2_ERROR_INVALID_PARAMETER);
 
        return 0;
 }
+
index a8f8d83c5043feddc06d6e78b721ccb977075e05..e560215137cf946272bdff1edeeef32d12899be8 100644 (file)
@@ -75,14 +75,14 @@ create_list_view(appdata_s *ad)
         * [Client Credential]
        */
 
-       /* 
+       /*
         * elm_list_item_append(list, "[Password] TODO", NULL, NULL, NULL, nf);
         */
        /* Google uses Password authentication grant type. [Password] */
 
        elm_list_item_append(list, "Google [Refresh Token]", NULL, NULL,
                start_google_refresh_token_cb, nf);
-       /* 
+       /*
         * Gets Google Refresh Token authentication grant type.
         * [Refresh Token]
         */
index 4ede5220d2c6ed4c81dc27eaba733e3b879cddda..b9d2768f0bf4be77be94fe2d51bf677397d05831 100644 (file)
@@ -172,7 +172,7 @@ create_button_view(Evas_Object *parent)
                (void *)4);
        evas_object_show(btn);
        elm_box_pack_end(box, btn);
-       
+
        /* btn_circle style */
        btn = elm_button_add(box);
        elm_object_style_set(btn, "circle");
@@ -325,7 +325,7 @@ refresh_token_response_cb(oauth2_response_h response, void *user_data)
                oauth2_response_get_error(response, &e_handle);
                char *error_val = NULL;
                oauth2_error_get_custom_data(e_handle, "error", &error_val);
-               if (error_val) 
+               if (error_val)
                        strcpy(displayStr, error_val);
                else {
                        int error_code = 0;
@@ -758,7 +758,7 @@ start_linkedin_oauth_code_cb(void *data, Evas_Object *obj, void *event_info)
                        request, grant_response_cb, request);
 
        }
-} 
+}
 
 void
 start_salesforce_oauth_code_cb(void *data, Evas_Object *obj, void *event_info)
index beae626dcdb771651a7a2a44a242f24d05e2852f..47f81263eea32edd213a9650767897fcc5d4520a 100644 (file)
@@ -349,7 +349,7 @@ __store_curl_response(void *ptr, size_t size, size_t nmemb, void *data)
                *result = calloc(size * nmemb + 1, sizeof(char));
                OAUTH2_RETURN_VAL(*result, {}, OAUTH2_ERROR_OUT_OF_MEMORY,
                        "Out of memory");
-               memcpy(*result, ptr, size * nmemb); 
+               memcpy(*result, ptr, size * nmemb);
        } else {
                size_t len = strlen(*result);
                *result = realloc(*result, len + size * nmemb + 1);
@@ -414,7 +414,7 @@ __parse_acc_token_response(const char *response_json,
 
                /*
                 * Some svc providers (example: GitHub) do not send json
-                * response, which violates 
+                * response, which violates
                 * http://tools.ietf.org/html/rfc6749#section-4.1.4 and
                 * http://tools.ietf.org/html/rfc6749#section-5.1
                 */
@@ -875,7 +875,7 @@ _on_auth_grant_received(oauth2_manager_s *mgr_handle, const char *response_url)
                        sizeof(oauth2_response_s));
 
                /* Check if its error response or success resopnse */
-               /* 
+               /*
                 * FB sample error: YOUR_REDIRECT_URI?error_reason=user_denied&
                 * error=access_denied&
                 * error_description=The+user+denied+your+request.
@@ -980,7 +980,7 @@ __start_auth_grant_request(oauth2_manager_s *mgr_handle)
        elm_object_text_set(mgr_handle->loading_popup, OAUTH2_LOADING_POP_UP_TEXT);
        elm_popup_orient_set(mgr_handle->loading_popup, ELM_POPUP_ORIENT_BOTTOM);
 
-//     ewk_init();
+    /* ewk_init(); */
 
        Evas *canvas = NULL;
 
@@ -1104,9 +1104,9 @@ oauth2_manager_request_token(oauth2_manager_h handle, oauth2_request_h request,
         * is mentioned
         */
        else {
-               /* 
+               /*
                 * Here authorization grant handling is out of oauth 2.0 RFC, so
-                * unless a custom auth grant handler is set, we will proceed 
+                * unless a custom auth grant handler is set, we will proceed
                 * with access token request directly
                 */
                if (!strcmp(grant_type,
@@ -1211,8 +1211,8 @@ oauth2_manager_request_authorization_grant(oauth2_manager_h handle,
                || !strcmp(grant_type,
                OAUTH2_PARAMETER_VAL_GRANT_TYPE_CLIENT_CREDENTIALS)) {
                /*
-                * No additional grant request needed as per RFC 
-                * (http://tools.ietf.org/html/rfc6749#section-4.3.1 and 
+                * No additional grant request needed as per RFC
+                * (http://tools.ietf.org/html/rfc6749#section-4.3.1 and
                 * http://tools.ietf.org/html/rfc6749#section-4.4.1)
                 */
                return OAUTH2_ERROR_INVALID_PARAMETER;
@@ -1220,7 +1220,7 @@ oauth2_manager_request_authorization_grant(oauth2_manager_h handle,
 
        /* TODO: TBD, extension grant_type / response_type support */
        return OAUTH2_ERROR_NOT_SUPPORTED;
-       /*LCOV_EXCL_STOP*/ 
+       /*LCOV_EXCL_STOP*/
 }
 
 OAUTH2_API int
@@ -1286,7 +1286,7 @@ oauth2_manager_request_access_token(oauth2_manager_h handle,
                 * is mentioned
                 */
 
-               /* 
+               /*
                 * Here authorization grant handling is out of oauth 2.0 RFC, so
                 * unless a custom auth grant handler is set, we will proceed
                 * with access token request directly
@@ -1318,7 +1318,7 @@ oauth2_manager_request_access_token(oauth2_manager_h handle,
        }
 
        return OAUTH2_ERROR_NOT_SUPPORTED;
-       /*LCOV_EXCL_STOP*/ 
+       /*LCOV_EXCL_STOP*/
 }
 
 /*LCOV_EXCL_START*/
@@ -1377,7 +1377,7 @@ _request_refresh_token(oauth2_manager_s *mgr_impl)
        }
        OAUTH2_FREE(post_body);
 }
-/*LCOV_EXCL_STOP*/ 
+/*LCOV_EXCL_STOP*/
 
 OAUTH2_API int
 oauth2_manager_refresh_access_token(oauth2_manager_h handle,
@@ -1437,7 +1437,7 @@ oauth2_manager_refresh_access_token(oauth2_manager_h handle,
        _request_refresh_token(mgr_impl);
 
        return OAUTH2_ERROR_NONE;
-       /*LCOV_EXCL_STOP*/ 
+       /*LCOV_EXCL_STOP*/
 }
 
 OAUTH2_API bool
@@ -1447,7 +1447,7 @@ oauth2_manager_is_request_in_progress(oauth2_manager_h handle)
 
        /*LCOV_EXCL_START*/
        return ((oauth2_manager_s *)handle)->is_active;
-       /*LCOV_EXCL_STOP*/ 
+       /*LCOV_EXCL_STOP*/
 }
 
 OAUTH2_API int
index 764ca1cb440f498fe6fc85577961af31cee8a5b6..6faf95db5bfd5b3f5127054a21467712509c1863 100644 (file)
@@ -23,7 +23,7 @@
 int
 _oauth2_response_create(oauth2_response_s **response)
 {
-       oauth2_response_s *response_temp = 
+       oauth2_response_s *response_temp =
                (oauth2_response_s *)calloc(1, sizeof(oauth2_response_s));
        OAUTH2_RETURN_VAL(response_temp, {}, OAUTH2_ERROR_OUT_OF_MEMORY,
                        "Out of memory");
index a683b65ebcd1a91a9d404be7129f2118307e099d..93fa481c811ac93a259cf145f69b19ffc0e7afb7 100644 (file)
@@ -95,8 +95,7 @@ oauth2_util_get_params(const char *url_part, bundle **params)
 
        int idx = 0;
        gchar **pch = g_strsplit_set(url, "&;", -1);
-       while (pch && pch[idx] && strlen(pch[idx]))
-       {
+       while (pch && pch[idx] && strlen(pch[idx])) {
                char *tmp_start = pch[idx];
                char *tmp_end = tmp_start;
                while (*tmp_end != '\0')