Fixed svace defects
[platform/core/location/maps-plugin-mapquest.git] / src / mapquest / mapquest_route.c
index a4ec225..d9f3c93 100644 (file)
 #include "mapquest_debug.h"
 #include "mapquest_queue.h"
 #include "mapquest_restcurl.h"
+#include "mapquest_util.h"
 
 #define ROUTE_URL       "https://open.mapquestapi.com/directions/v2/route?key=%s&ambiguities=ignore&outFormat=json&shapeFormat=raw&generalize=0"
 
 int query_route(gchar *maps_key, coords_s startPoint, coords_s endPoint, route_type type, route_feature_avoids avoids, route_driving_style style, GList *waypoints, gpointer user_data)
 {
-       char url[1024];
+       char url[1024] = "";
        char tmpStr[512];
 
        if (maps_key != NULL)
@@ -36,40 +37,40 @@ int query_route(gchar *maps_key, coords_s startPoint, coords_s endPoint, route_t
        else
                snprintf(tmpStr, sizeof(tmpStr), ROUTE_URL, "null");
 
-       strcpy(url, tmpStr);
+       STRCPY(url, tmpStr);
 
-       strcat(url, "&unit=m"); /* Keeping default as miles and conversion will be done later */
+       STRCAT(url, "&unit=m"); /* Keeping default as miles and conversion will be done later */
 
        if (type == ROUTE_TYPE_FASTEST)
-               strcat(url, "&routeType=fastest");
+               STRCAT(url, "&routeType=fastest");
        else if (type == ROUTE_TYPE_SHORTEST)
-               strcat(url, "&routeType=shortest");
+               STRCAT(url, "&routeType=shortest");
        else if (type == ROUTE_TYPE_PEDESTRIAN)
-               strcat(url, "&routeType=pedestrian");
+               STRCAT(url, "&routeType=pedestrian");
        else if (type == ROUTE_TYPE_MULTIMODAL)
-               strcat(url, "&routeType=multimodal");
+               STRCAT(url, "&routeType=multimodal");
        else if (type == ROUTE_TYPE_BICYCLE)
-               strcat(url, "&routeType=bicycle");
+               STRCAT(url, "&routeType=bicycle");
 
        if (avoids == ROUTE_AVOID_LIMITED_ACCESS)
-               strcat(url, "&avoids=Limited Access");
+               STRCAT(url, "&avoids=Limited Access");
        else if (avoids == ROUTE_AVOID_TOLL_ROAD)
-               strcat(url, "&avoids=Tollroad");
+               STRCAT(url, "&avoids=Tollroad");
        else if (avoids == ROUTE_AVOID_FERRY)
-               strcat(url, "&avoids=Ferry");
+               STRCAT(url, "&avoids=Ferry");
        else if (avoids == ROUTE_AVOID_UNPAVED)
-               strcat(url, "&avoids=Unpaved");
+               STRCAT(url, "&avoids=Unpaved");
        else if (avoids == ROUTE_AVOID_SEASONAL_CLOSURE)
-               strcat(url, "&avoids=Approximate Seasonal Closure");
+               STRCAT(url, "&avoids=Approximate Seasonal Closure");
        else if (avoids == ROUTE_AVOID_COUNTRY_BORDER_CROSSING)
-               strcat(url, "&avoids=Country border crossing");
+               STRCAT(url, "&avoids=Country border crossing");
 
        if (style == DRIVING_STYLE_NORMAL)
-               strcat(url, "&drivingStyle=2");
+               STRCAT(url, "&drivingStyle=2");
        else if (style == DRIVING_STYLE_CAUTIOUS)
-               strcat(url, "&drivingStyle=1");
+               STRCAT(url, "&drivingStyle=1");
        else if (style == DRIVING_STYLE_AGGRESSIVE)
-               strcat(url, "&drivingStyle=3");
+               STRCAT(url, "&drivingStyle=3");
 
        int length = g_list_length(waypoints);
        if (length != 0) {
@@ -86,7 +87,7 @@ int query_route(gchar *maps_key, coords_s startPoint, coords_s endPoint, route_t
                                        snprintf(tmpStr, sizeof(tmpStr), "&from=%f,%f", data->latitude, data->longitude);
                                else
                                        snprintf(tmpStr, sizeof(tmpStr), "&to=%f,%f", data->latitude, data->longitude);
-                               strcat(url, tmpStr);
+                               STRCAT(url, tmpStr);
                        }
 
                        waypoints_list = g_list_next(waypoints_list);
@@ -94,10 +95,10 @@ int query_route(gchar *maps_key, coords_s startPoint, coords_s endPoint, route_t
                }
        } else {
                snprintf(tmpStr, sizeof(tmpStr), "&from=%f,%f", startPoint.latitude, startPoint.longitude);
-               strcat(url, tmpStr);
+               STRCAT(url, tmpStr);
 
                snprintf(tmpStr, sizeof(tmpStr), "&to=%f,%f", endPoint.latitude, endPoint.longitude);
-               strcat(url, tmpStr);
+               STRCAT(url, tmpStr);
        }
 
        add_handle(url, REQ_TYPE_ROUTE, user_data);