Fix:vehicle_file:Removed carriage returns
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Mon, 28 Jun 2010 17:01:16 +0000 (17:01 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Mon, 28 Jun 2010 17:01:16 +0000 (17:01 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@3436 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/navit/vehicle/file/vehicle_file.c

index 42f57c0..78f417d 100644 (file)
@@ -88,12 +88,12 @@ struct vehicle_priv {
        int on_eof;
 #ifdef _WIN32
        int no_data_count;
-       struct event_timeout * timeout;\r
-       struct callback *timeout_callback;\r
+       struct event_timeout * timeout;
+       struct callback *timeout_callback;
 #else
-       enum file_type file_type;\r
-       FILE *file;\r
-       struct event_watch *watch;\r
+       enum file_type file_type;
+       FILE *file;
+       struct event_watch *watch;
 #endif
        speed_t baudrate;
        struct attr ** attrs;
@@ -108,16 +108,16 @@ struct vehicle_priv {
        int valid;
 };
 
-//***************************************************************************\r
-/** @fn static int vehicle_win32_serial_track(struct vehicle_priv *priv)\r
-*****************************************************************************\r
-* @b Description: Callback of the plugin\r
-*****************************************************************************\r
-* @param      priv : pointer on the private data of the plugin\r
-*****************************************************************************\r
-* @return     always 1\r
-*****************************************************************************\r
-**/\r
+//***************************************************************************
+/** @fn static int vehicle_win32_serial_track(struct vehicle_priv *priv)
+*****************************************************************************
+* @b Description: Callback of the plugin
+*****************************************************************************
+* @param      priv : pointer on the private data of the plugin
+*****************************************************************************
+* @return     always 1
+*****************************************************************************
+**/
 #ifdef _WIN32
 static int vehicle_win32_serial_track(struct vehicle_priv *priv)
 {
@@ -125,15 +125,15 @@ static int vehicle_win32_serial_track(struct vehicle_priv *priv)
     static int current_index = 0;
     const int chunk_size = 1024;
     int rc = 0;
-\r
-    dbg(1, "enter, *priv='%x', priv->source='%s'\n", priv, priv->source);\r
+
+    dbg(1, "enter, *priv='%x', priv->source='%s'\n", priv, priv->source);
 
     if ( priv->no_data_count > 5 )
     {
         vehicle_file_close( priv );
         priv->no_data_count = 0;
-        vehicle_file_open( priv );\r
-        vehicle_file_enable_watch(priv);\r
+        vehicle_file_open( priv );
+        vehicle_file_enable_watch(priv);
     }
 
     //if ( priv->fd <= 0 )
@@ -159,8 +159,8 @@ static int vehicle_win32_serial_track(struct vehicle_priv *priv)
             char return_buffer[1024];
             int bytes_to_copy = return_pos - buffer + 1;
             memcpy( return_buffer, buffer, bytes_to_copy );
-            return_buffer[ bytes_to_copy + 1 ] = '\0';\r
-            return_buffer[ bytes_to_copy ] = '\0';\r
+            return_buffer[ bytes_to_copy + 1 ] = '\0';
+            return_buffer[ bytes_to_copy ] = '\0';
 
             // printf( "received %d : '%s' bytes to copy\n", bytes_to_copy, return_buffer );
             rc += vehicle_file_parse( priv, return_buffer );
@@ -168,11 +168,11 @@ static int vehicle_win32_serial_track(struct vehicle_priv *priv)
             current_index -= bytes_to_copy;
             memmove( buffer, &buffer[ bytes_to_copy ] , sizeof( buffer ) - bytes_to_copy );
         }
-        if (rc) {\r
+        if (rc) {
             priv->no_data_count = 0;
             callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
             if (rc > 1)
-                dbg(0, "Can not keep with gps data delay is %d seconds\n", rc - 1);\r
+                dbg(0, "Can not keep with gps data delay is %d seconds\n", rc - 1);
 
         }
     }
@@ -180,22 +180,22 @@ static int vehicle_win32_serial_track(struct vehicle_priv *priv)
     {
         priv->no_data_count++;
     }
-    dbg(2, "leave, return '1', priv->no_data_count='%d'\n", priv->no_data_count);\r
+    dbg(2, "leave, return '1', priv->no_data_count='%d'\n", priv->no_data_count);
     return 1;
 }
 #endif
 
-//***************************************************************************\r
-/** @fn static int vehicle_file_open(struct vehicle_priv *priv)\r
-*****************************************************************************\r
-* @b Description: open dialogue with the GPS\r
-*****************************************************************************\r
-* @param      priv : pointer on the private data of the plugin\r
-*****************************************************************************\r
-* @return     1 if ok\r
-*             0 if error\r
-*****************************************************************************\r
-**/\r
+//***************************************************************************
+/** @fn static int vehicle_file_open(struct vehicle_priv *priv)
+*****************************************************************************
+* @b Description: open dialogue with the GPS
+*****************************************************************************
+* @param      priv : pointer on the private data of the plugin
+*****************************************************************************
+* @return     1 if ok
+*             0 if error
+*****************************************************************************
+**/
 static int
 vehicle_file_open(struct vehicle_priv *priv)
 {
@@ -217,12 +217,12 @@ vehicle_file_open(struct vehicle_priv *priv)
 
             priv->fd=serial_io_init( strport, strsettings );
         }
-        g_free( raw_setting_str );\r
-\r
-        // Add the callback\r
-        dbg(2, "Add the callback ...\n", priv->source);\r
-               priv->timeout_callback=callback_new_1(callback_cast(vehicle_win32_serial_track), priv);\r
-    }\r
+        g_free( raw_setting_str );
+
+        // Add the callback
+        dbg(2, "Add the callback ...\n", priv->source);
+               priv->timeout_callback=callback_new_1(callback_cast(vehicle_win32_serial_track), priv);
+    }
 #else
        char *name;
        struct stat st;
@@ -254,26 +254,26 @@ vehicle_file_open(struct vehicle_priv *priv)
                priv->file_type = file_type_pipe;
        }
 #endif
-    return(priv->fd != -1);\r
+    return(priv->fd != -1);
 }
 
-//***************************************************************************\r
-/** @fn static void vehicle_file_close(struct vehicle_priv *priv)\r
-*****************************************************************************\r
-* @b Description: close dialogue with the GPS\r
-*****************************************************************************\r
-* @param      priv : pointer on the private data of the plugin\r
-*****************************************************************************\r
-**/\r
+//***************************************************************************
+/** @fn static void vehicle_file_close(struct vehicle_priv *priv)
+*****************************************************************************
+* @b Description: close dialogue with the GPS
+*****************************************************************************
+* @param      priv : pointer on the private data of the plugin
+*****************************************************************************
+**/
 static void
 vehicle_file_close(struct vehicle_priv *priv)
 {
-    dbg(1, "enter, priv->fd='%d'\n", priv->fd);\r
-       vehicle_file_disable_watch(priv);\r
-#ifdef _WIN32\r
-    if (priv->timeout_callback) {\r
-               callback_destroy(priv->timeout_callback);\r
-               priv->timeout_callback=NULL;    // dangling pointer! prevent double freeing.\r
+    dbg(1, "enter, priv->fd='%d'\n", priv->fd);
+       vehicle_file_disable_watch(priv);
+#ifdef _WIN32
+    if (priv->timeout_callback) {
+               callback_destroy(priv->timeout_callback);
+               priv->timeout_callback=NULL;    // dangling pointer! prevent double freeing.
     }
        serial_io_shutdown( priv->fd );
 #else
@@ -281,21 +281,21 @@ vehicle_file_close(struct vehicle_priv *priv)
                pclose(priv->file);
        else if (priv->fd >= 0)
                close(priv->fd);
-       priv->file = NULL;\r
+       priv->file = NULL;
 #endif
        priv->fd = -1;
 }
 
-//***************************************************************************\r
-/** @fn static int vehicle_file_enable_watch_timer(struct vehicle_priv *priv)\r
-*****************************************************************************\r
-* @b Description: Enable watch timer to get GPS data\r
-*****************************************************************************\r
-* @param      priv : pointer on the private data of the plugin\r
-*****************************************************************************\r
-* @return     always 0\r
-*****************************************************************************\r
-**/\r
+//***************************************************************************
+/** @fn static int vehicle_file_enable_watch_timer(struct vehicle_priv *priv)
+*****************************************************************************
+* @b Description: Enable watch timer to get GPS data
+*****************************************************************************
+* @param      priv : pointer on the private data of the plugin
+*****************************************************************************
+* @return     always 0
+*****************************************************************************
+**/
 static int
 vehicle_file_enable_watch_timer(struct vehicle_priv *priv)
 {
@@ -306,19 +306,19 @@ vehicle_file_enable_watch_timer(struct vehicle_priv *priv)
 }
 
 
-//***************************************************************************\r
-/** @fn static int vehicle_file_parse( struct vehicle_priv *priv,\r
-*                                      char *buffer)\r
-*****************************************************************************\r
-* @b Description: Parse the buffer\r
-*****************************************************************************\r
-* @param      priv : pointer on the private data of the plugin\r
-* @param      buffer : data buffer (null terminated)\r
-*****************************************************************************\r
-* @return     1 if The GPRMC Sentence is found\r
-*             0 if not found\r
-*****************************************************************************\r
-**/\r
+//***************************************************************************
+/** @fn static int vehicle_file_parse( struct vehicle_priv *priv,
+*                                      char *buffer)
+*****************************************************************************
+* @b Description: Parse the buffer
+*****************************************************************************
+* @param      priv : pointer on the private data of the plugin
+* @param      buffer : data buffer (null terminated)
+*****************************************************************************
+* @return     1 if The GPRMC Sentence is found
+*             0 if not found
+*****************************************************************************
+**/
 static int
 vehicle_file_parse(struct vehicle_priv *priv, char *buffer)
 {
@@ -338,9 +338,9 @@ vehicle_file_parse(struct vehicle_priv *priv, char *buffer)
                }
                if (buffer[len - 1] == '\r' || buffer[len - 1] == '\n') {
                        buffer[--len] = '\0';
-            if (buffer[len - 1] == '\r')\r
-                buffer[--len] = '\0';\r
-        } else\r
+            if (buffer[len - 1] == '\r')
+                buffer[--len] = '\0';
+        } else
                        break;
        }
        if (buffer[0] != '$') {
@@ -404,8 +404,8 @@ vehicle_file_parse(struct vehicle_priv *priv, char *buffer)
 
                        if (!strcasecmp(item[5],"W"))
                                priv->geo.lng=-priv->geo.lng;
-                       priv->valid=attr_position_valid_valid;\r
-            dbg(2, "latitude '%2.4f' longitude %2.4f\n", priv->geo.lat, priv->geo.lng);\r
+                       priv->valid=attr_position_valid_valid;
+            dbg(2, "latitude '%2.4f' longitude %2.4f\n", priv->geo.lat, priv->geo.lng);
 
                } else
                        priv->valid=attr_position_valid_invalid;
@@ -445,7 +445,7 @@ vehicle_file_parse(struct vehicle_priv *priv, char *buffer)
                if (valid) {
                        priv->direction = g_ascii_strtod( item[1], NULL );
                        priv->speed = g_ascii_strtod( item[7], NULL );
-                       dbg(2,"direction %lf, speed %2.1lf\n", priv->direction, priv->speed);\r
+                       dbg(2,"direction %lf, speed %2.1lf\n", priv->direction, priv->speed);
                }
        }
        if (!strncmp(buffer, "$GPRMC", 6)) {
@@ -542,21 +542,21 @@ vehicle_file_parse(struct vehicle_priv *priv, char *buffer)
        return ret;
 }
 
-//***************************************************************************\r
-/** @fn static void vehicle_file_io(struct vehicle_priv *priv)\r
-*****************************************************************************\r
-* @b Description: function to get data from GPS\r
-*****************************************************************************\r
-* @param      priv : pointer on the private data of the plugin\r
-*****************************************************************************\r
-* @remarks Not used on WIN32 operating system\r
-*****************************************************************************\r
-**/\r
+//***************************************************************************
+/** @fn static void vehicle_file_io(struct vehicle_priv *priv)
+*****************************************************************************
+* @b Description: function to get data from GPS
+*****************************************************************************
+* @param      priv : pointer on the private data of the plugin
+*****************************************************************************
+* @remarks Not used on WIN32 operating system
+*****************************************************************************
+**/
 static void
 vehicle_file_io(struct vehicle_priv *priv)
 {
-       dbg(1, "vehicle_file_io : enter\n");\r
-#ifndef _WIN32\r
+       dbg(1, "vehicle_file_io : enter\n");
+#ifndef _WIN32
        int size, rc = 0;
        char *str, *tok;
 
@@ -601,50 +601,50 @@ vehicle_file_io(struct vehicle_priv *priv)
        }
        if (rc)
                callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
-#endif\r
+#endif
 }
 
-//***************************************************************************\r
-/** @fn static void vehicle_file_enable_watch(struct vehicle_priv *priv)\r
-*****************************************************************************\r
-* @b Description: Enable watch\r
-*****************************************************************************\r
-* @param      priv : pointer on the private data of the plugin\r
-*****************************************************************************\r
-**/\r
+//***************************************************************************
+/** @fn static void vehicle_file_enable_watch(struct vehicle_priv *priv)
+*****************************************************************************
+* @b Description: Enable watch
+*****************************************************************************
+* @param      priv : pointer on the private data of the plugin
+*****************************************************************************
+**/
 static void
 vehicle_file_enable_watch(struct vehicle_priv *priv)
 {
-       dbg(1, "enter\n");\r
-#ifdef _WIN32\r
-       // add an event : don't use glib timers and g_timeout_add\r
+       dbg(1, "enter\n");
+#ifdef _WIN32
+       // add an event : don't use glib timers and g_timeout_add
        if (priv->timeout_callback != NULL)
-        priv->timeout = event_add_timeout(500, 1, priv->timeout_callback);\r
+        priv->timeout = event_add_timeout(500, 1, priv->timeout_callback);
     else
-        dbg(1, "error : watch not enabled : priv->timeout_callback is null\n");\r
+        dbg(1, "error : watch not enabled : priv->timeout_callback is null\n");
 #else
        if (! priv->watch)
                priv->watch = event_add_watch((void *)priv->fd, event_watch_cond_read, priv->cb);
 #endif
 }
 
-//***************************************************************************\r
-/** @fn static void vehicle_file_disable_watch(struct vehicle_priv *priv)\r
-*****************************************************************************\r
-* @b Description: Disable watch\r
-*****************************************************************************\r
-* @param      priv : pointer on the private data of the plugin\r
-*****************************************************************************\r
-**/\r
+//***************************************************************************
+/** @fn static void vehicle_file_disable_watch(struct vehicle_priv *priv)
+*****************************************************************************
+* @b Description: Disable watch
+*****************************************************************************
+* @param      priv : pointer on the private data of the plugin
+*****************************************************************************
+**/
 static void
 vehicle_file_disable_watch(struct vehicle_priv *priv)
 {
-       dbg(1, "vehicle_file_disable_watch : enter\n");\r
-#ifdef _WIN32\r
-    if (priv->timeout) {\r
-               event_remove_timeout(priv->timeout);\r
-               priv->timeout=NULL;             // dangling pointer! prevent double freeing.\r
-    }\r
+       dbg(1, "vehicle_file_disable_watch : enter\n");
+#ifdef _WIN32
+    if (priv->timeout) {
+               event_remove_timeout(priv->timeout);
+               priv->timeout=NULL;             // dangling pointer! prevent double freeing.
+    }
 #else
        if (priv->watch)
                event_remove_watch(priv->watch);
@@ -652,16 +652,16 @@ vehicle_file_disable_watch(struct vehicle_priv *priv)
 #endif
 }
 
-//***************************************************************************\r
-/** @fn static void vehicle_priv vehicle_file_destroy(struct vehicle_priv *priv)\r
-*****************************************************************************\r
-* @b Description: Function called to uninitialize the plugin\r
-*****************************************************************************\r
-* @param      priv : pointer on the private data of the plugin\r
-*****************************************************************************\r
-* @remarks private data is freed by this function (g_free)\r
-*****************************************************************************\r
-**/\r
+//***************************************************************************
+/** @fn static void vehicle_priv vehicle_file_destroy(struct vehicle_priv *priv)
+*****************************************************************************
+* @b Description: Function called to uninitialize the plugin
+*****************************************************************************
+* @param      priv : pointer on the private data of the plugin
+*****************************************************************************
+* @remarks private data is freed by this function (g_free)
+*****************************************************************************
+**/
 static void
 vehicle_file_destroy(struct vehicle_priv *priv)
 {
@@ -675,21 +675,21 @@ vehicle_file_destroy(struct vehicle_priv *priv)
        g_free(priv);
 }
 
-//***************************************************************************\r
-/** @fn static int vehicle_file_position_attr_get(struct vehicle_priv *priv,\r
-*                                                 enum attr_type type,\r
-*                                                 struct attr *attr)\r
-*****************************************************************************\r
-* @b Description: Function called to get attribute\r
-*****************************************************************************\r
-* @param      priv : pointer on the private data of the plugin\r
-* @param      type : attribute type called\r
-* @param      attr : structure to return the attribute value\r
-*****************************************************************************\r
-* @return     1 if ok\r
-*             0 for unkown or invalid attribute\r
-*****************************************************************************\r
-**/\r
+//***************************************************************************
+/** @fn static int vehicle_file_position_attr_get(struct vehicle_priv *priv,
+*                                                 enum attr_type type,
+*                                                 struct attr *attr)
+*****************************************************************************
+* @b Description: Function called to get attribute
+*****************************************************************************
+* @param      priv : pointer on the private data of the plugin
+* @param      type : attribute type called
+* @param      attr : structure to return the attribute value
+*****************************************************************************
+* @return     1 if ok
+*             0 for unkown or invalid attribute
+*****************************************************************************
+**/
 static int
 vehicle_file_position_attr_get(struct vehicle_priv *priv,
                               enum attr_type type, struct attr *attr)
@@ -759,21 +759,21 @@ vehicle_file_position_attr_get(struct vehicle_priv *priv,
        return 1;
 }
 
-//***************************************************************************\r
-/** @fn static int vehicle_file_sat_attr_get(struct vehicle_priv *priv,\r
-*                                                 enum attr_type type,\r
-*                                                 struct attr *attr)\r
-*****************************************************************************\r
-* @b Description: Function called to get satellite attribute\r
-*****************************************************************************\r
-* @param      priv : pointer on the private data of the plugin\r
-* @param      type : attribute type called\r
-* @param      attr : structure to return the attribute value\r
-*****************************************************************************\r
-* @return     1 if ok\r
-*             0 for unkown attribute\r
-*****************************************************************************\r
-**/\r
+//***************************************************************************
+/** @fn static int vehicle_file_sat_attr_get(struct vehicle_priv *priv,
+*                                                 enum attr_type type,
+*                                                 struct attr *attr)
+*****************************************************************************
+* @b Description: Function called to get satellite attribute
+*****************************************************************************
+* @param      priv : pointer on the private data of the plugin
+* @param      type : attribute type called
+* @param      attr : structure to return the attribute value
+*****************************************************************************
+* @return     1 if ok
+*             0 for unkown attribute
+*****************************************************************************
+**/
 static int
 vehicle_file_sat_attr_get(void *priv_data, enum attr_type type, struct attr *attr)
 {
@@ -815,23 +815,23 @@ static struct vehicle_methods vehicle_file_methods = {
        vehicle_file_position_attr_get,
 };
 
-//***************************************************************************\r
-/** @fn static struct vehicle_priv * vehicle_file_new_file(\r
-*                                       struct vehicle_methods *meth,\r
-*                                       struct callback_list   *cbl,\r
-*                                       struct attr            **attrs)\r
-*****************************************************************************\r
-* @b Description: Function called to initialize the plugin\r
-*****************************************************************************\r
-* @param      meth  : ?\r
-* @param      cbl   : ?\r
-* @param      attrs : ?\r
-*****************************************************************************\r
-* @return     pointer on the private data of the plugin\r
-*****************************************************************************\r
-* @remarks private data is allocated by this function (g_new0)\r
-*****************************************************************************\r
-**/\r
+//***************************************************************************
+/** @fn static struct vehicle_priv * vehicle_file_new_file(
+*                                       struct vehicle_methods *meth,
+*                                       struct callback_list   *cbl,
+*                                       struct attr            **attrs)
+*****************************************************************************
+* @b Description: Function called to initialize the plugin
+*****************************************************************************
+* @param      meth  : ?
+* @param      cbl   : ?
+* @param      attrs : ?
+*****************************************************************************
+* @return     pointer on the private data of the plugin
+*****************************************************************************
+* @remarks private data is allocated by this function (g_new0)
+*****************************************************************************
+**/
 static struct vehicle_priv *
 vehicle_file_new_file(struct vehicle_methods
                      *meth, struct callback_list
@@ -844,14 +844,14 @@ vehicle_file_new_file(struct vehicle_methods
        struct attr *baudrate;
        struct attr *checksum_ignore;
 
-       dbg(1, "enter\n");\r
+       dbg(1, "enter\n");
 
        source = attr_search(attrs, NULL, attr_source);
        if(source == NULL){
                 dbg(0,"Missing source attribute");
                 return NULL;
     }
-       ret = g_new0(struct vehicle_priv, 1);   // allocate and initialize to 0\r
+       ret = g_new0(struct vehicle_priv, 1);   // allocate and initialize to 0
        ret->fd = -1;
        ret->cbl = cbl;
        ret->source = g_strdup(source->u.str);
@@ -907,28 +907,28 @@ vehicle_file_new_file(struct vehicle_methods
        ret->sat_item.id_hi=ret->sat_item.id_lo=0;
        ret->sat_item.priv_data=ret;
        ret->sat_item.meth=&vehicle_file_sat_methods;
-#ifdef _WIN32\r
-       ret->no_data_count = 0;\r
-#endif\r
-\r
-       dbg(1, "vehicle_file_new_file:open\n");\r
+#ifdef _WIN32
+       ret->no_data_count = 0;
+#endif
+
+       dbg(1, "vehicle_file_new_file:open\n");
        if (!vehicle_file_open(ret)) {
-        dbg(0, "Failed to open '%s'\n", ret->source);\r
+        dbg(0, "Failed to open '%s'\n", ret->source);
        }
-\r
-       vehicle_file_enable_watch(ret);\r
+
+       vehicle_file_enable_watch(ret);
        // vehicle_file_destroy(ret);
-       // return NULL;\r
-       dbg(1, "leave\n");\r
-       return ret;\r
+       // return NULL;
+       dbg(1, "leave\n");
+       return ret;
 }
 
-//***************************************************************************\r
-/** @fn void plugin_init(void)\r
-*****************************************************************************\r
-* @b Description: Initialisation of vehicle_file plugin\r
-*****************************************************************************\r
-**/\r
+//***************************************************************************
+/** @fn void plugin_init(void)
+*****************************************************************************
+* @b Description: Initialisation of vehicle_file plugin
+*****************************************************************************
+**/
 void plugin_init(void)
 {
        dbg(1, "vehicle_file:plugin_init:enter\n");