/** @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);
	vehicle_file_disable_watch(priv);
#ifdef _WIN32
    if(priv->file_type == file_type_serial)
    {
        if (priv->timeout_callback) {
   		callback_destroy(priv->timeout_callback);
		priv->timeout_callback=NULL;	// dangling pointer! prevent double freeing.
        }
	serial_io_shutdown( priv->fd );
    }
    else
#endif
    {
	if (priv->file) {
#ifndef _MSC_VER
		pclose(priv->file);
#endif /* _MSC_VER */
    }
	else if (priv->fd >= 0) {
		close(priv->fd);
    }
	priv->file = NULL;
	priv->fd = -1;
    }
}
Example #2
0
/** @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);
	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
	if (priv->file)
		pclose(priv->file);
	else if (priv->fd >= 0)
		close(priv->fd);
	priv->file = NULL;
#endif
	priv->fd = -1;
}