Code cleanup
This commit is contained in:
parent
324ceb9f0d
commit
0bba887367
@ -187,7 +187,6 @@ static int _hayes_queue_command(Hayes * hayes, HayesChannel * channel,
|
|||||||
static int _hayes_queue_command_full(Hayes * hayes,
|
static int _hayes_queue_command_full(Hayes * hayes,
|
||||||
char const * attention, HayesCommandCallback callback);
|
char const * attention, HayesCommandCallback callback);
|
||||||
#endif
|
#endif
|
||||||
static void _hayes_queue_flush(Hayes * hayes, HayesChannel * channel);
|
|
||||||
static int _hayes_queue_pop(Hayes * hayes, HayesChannel * channel);
|
static int _hayes_queue_pop(Hayes * hayes, HayesChannel * channel);
|
||||||
static int _hayes_queue_push(Hayes * hayes, HayesChannel * channel);
|
static int _hayes_queue_push(Hayes * hayes, HayesChannel * channel);
|
||||||
|
|
||||||
@ -614,7 +613,7 @@ static void _stop_channel(Hayes * hayes, HayesChannel * channel)
|
|||||||
if(channel->fp != NULL)
|
if(channel->fp != NULL)
|
||||||
fclose(channel->fp);
|
fclose(channel->fp);
|
||||||
channel->fp = NULL;
|
channel->fp = NULL;
|
||||||
_hayes_queue_flush(hayes, channel);
|
hayeschannel_queue_flush(channel);
|
||||||
_stop_giochannel(channel->channel);
|
_stop_giochannel(channel->channel);
|
||||||
channel->channel = NULL;
|
channel->channel = NULL;
|
||||||
_stop_giochannel(channel->rd_ppp_channel);
|
_stop_giochannel(channel->rd_ppp_channel);
|
||||||
@ -1178,32 +1177,6 @@ static int _hayes_queue_command_full(Hayes * hayes,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* hayes_queue_flush */
|
|
||||||
static void _hayes_queue_flush(Hayes * hayes, HayesChannel * channel)
|
|
||||||
{
|
|
||||||
g_slist_foreach(channel->queue_timeout, (GFunc)hayes_command_delete,
|
|
||||||
NULL);
|
|
||||||
g_slist_free(channel->queue_timeout);
|
|
||||||
channel->queue_timeout = NULL;
|
|
||||||
g_slist_foreach(channel->queue, (GFunc)hayes_command_delete, NULL);
|
|
||||||
g_slist_free(channel->queue);
|
|
||||||
channel->queue = NULL;
|
|
||||||
free(channel->rd_buf);
|
|
||||||
channel->rd_buf = NULL;
|
|
||||||
channel->rd_buf_cnt = 0;
|
|
||||||
_hayes_reset_source(&channel->rd_source);
|
|
||||||
free(channel->wr_buf);
|
|
||||||
channel->wr_buf = NULL;
|
|
||||||
channel->wr_buf_cnt = 0;
|
|
||||||
_hayes_reset_source(&channel->wr_source);
|
|
||||||
_hayes_reset_source(&channel->rd_ppp_source);
|
|
||||||
_hayes_reset_source(&channel->wr_ppp_source);
|
|
||||||
channel->authenticate_count = 0;
|
|
||||||
_hayes_reset_source(&channel->authenticate_source);
|
|
||||||
_hayes_reset_source(&channel->timeout);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* hayes_queue_pop */
|
/* hayes_queue_pop */
|
||||||
static int _hayes_queue_pop(Hayes * hayes, HayesChannel * channel)
|
static int _hayes_queue_pop(Hayes * hayes, HayesChannel * channel)
|
||||||
{
|
{
|
||||||
|
@ -15,10 +15,17 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "command.h"
|
||||||
#include "channel.h"
|
#include "channel.h"
|
||||||
|
|
||||||
|
|
||||||
/* HayesChannel */
|
/* HayesChannel */
|
||||||
|
/* private */
|
||||||
|
/* prototypes */
|
||||||
|
static void _hayeschannel_reset_source(guint * source);
|
||||||
|
|
||||||
|
|
||||||
/* public */
|
/* public */
|
||||||
/* functions */
|
/* functions */
|
||||||
/* hayeschannel_init */
|
/* hayeschannel_init */
|
||||||
@ -40,3 +47,44 @@ void hayeschannel_destroy(HayesChannel * channel)
|
|||||||
{
|
{
|
||||||
(void) channel;
|
(void) channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* useful */
|
||||||
|
/* queue management */
|
||||||
|
/* hayeschannel_queue_flush */
|
||||||
|
void hayeschannel_queue_flush(HayesChannel * channel)
|
||||||
|
{
|
||||||
|
g_slist_foreach(channel->queue_timeout, (GFunc)hayes_command_delete,
|
||||||
|
NULL);
|
||||||
|
g_slist_free(channel->queue_timeout);
|
||||||
|
channel->queue_timeout = NULL;
|
||||||
|
g_slist_foreach(channel->queue, (GFunc)hayes_command_delete, NULL);
|
||||||
|
g_slist_free(channel->queue);
|
||||||
|
channel->queue = NULL;
|
||||||
|
free(channel->rd_buf);
|
||||||
|
channel->rd_buf = NULL;
|
||||||
|
channel->rd_buf_cnt = 0;
|
||||||
|
_hayeschannel_reset_source(&channel->rd_source);
|
||||||
|
free(channel->wr_buf);
|
||||||
|
channel->wr_buf = NULL;
|
||||||
|
channel->wr_buf_cnt = 0;
|
||||||
|
_hayeschannel_reset_source(&channel->wr_source);
|
||||||
|
_hayeschannel_reset_source(&channel->rd_ppp_source);
|
||||||
|
_hayeschannel_reset_source(&channel->wr_ppp_source);
|
||||||
|
channel->authenticate_count = 0;
|
||||||
|
_hayeschannel_reset_source(&channel->authenticate_source);
|
||||||
|
_hayeschannel_reset_source(&channel->timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* private */
|
||||||
|
/* functions */
|
||||||
|
/* hayeschannel_reset_source */
|
||||||
|
static void _hayeschannel_reset_source(guint * source)
|
||||||
|
{
|
||||||
|
/* XXX duplicated from _hayes_reset_source() */
|
||||||
|
if(*source == 0)
|
||||||
|
return;
|
||||||
|
g_source_remove(*source);
|
||||||
|
*source = 0;
|
||||||
|
}
|
||||||
|
@ -88,4 +88,7 @@ typedef struct _HayesChannel
|
|||||||
void hayeschannel_init(HayesChannel * channel, ModemPlugin * modem);
|
void hayeschannel_init(HayesChannel * channel, ModemPlugin * modem);
|
||||||
void hayeschannel_destroy(HayesChannel * channel);
|
void hayeschannel_destroy(HayesChannel * channel);
|
||||||
|
|
||||||
|
/* queue management */
|
||||||
|
void hayeschannel_queue_flush(HayesChannel * channel);
|
||||||
|
|
||||||
#endif /* PHONE_MODEM_HAYES_CHANNEL_H */
|
#endif /* PHONE_MODEM_HAYES_CHANNEL_H */
|
||||||
|
@ -30,7 +30,7 @@ install=$(LIBDIR)/Phone/modem
|
|||||||
depends=hayes/channel.h,hayes/command.h,hayes/quirks.h,hayes.h
|
depends=hayes/channel.h,hayes/command.h,hayes/quirks.h,hayes.h
|
||||||
|
|
||||||
[hayes/channel.c]
|
[hayes/channel.c]
|
||||||
depends=hayes/channel.h
|
depends=hayes/channel.h,hayes/command.h
|
||||||
|
|
||||||
[hayes/command.c]
|
[hayes/command.c]
|
||||||
depends=hayes/command.h
|
depends=hayes/command.h
|
||||||
|
Loading…
Reference in New Issue
Block a user