Allow commands to carry user-defined data

This commit is contained in:
Pierre Pronchery 2010-05-27 16:49:45 +00:00
parent b83ab8c414
commit af6a5ef514
2 changed files with 18 additions and 0 deletions

View File

@ -34,6 +34,7 @@ struct _GSMCommand
unsigned int timeout;
GSMError error;
GSMCommandCallback callback;
void * data;
GSMMode mode;
};
@ -55,6 +56,7 @@ GSMCommand * gsm_command_new(char const * command)
gsmc->timeout = 2000;
gsmc->error = GSM_ERROR_UNKNOWN;
gsmc->callback = NULL;
gsmc->data = NULL;
gsmc->mode = GSM_MODE_COMMAND;
/* check errors */
if(gsmc->command == NULL)
@ -92,6 +94,13 @@ char const * gsm_command_get_command(GSMCommand * gsmc)
}
/* gsm_command_get_data */
void * gsm_command_get_data(GSMCommand * gsmc)
{
return gsmc->data;
}
/* gsm_command_get_error */
GSMError gsm_command_get_error(GSMCommand * gsmc)
{
@ -128,6 +137,13 @@ void gsm_command_set_callback(GSMCommand * gsmc,
}
/* gsm_command_set_data */
void gsm_command_set_data(GSMCommand * gsmc, void * data)
{
gsmc->data = data;
}
/* gsm_command_set_error */
void gsm_command_set_error(GSMCommand * gsmc, GSMError error)
{

View File

@ -31,12 +31,14 @@ void gsm_command_delete(GSMCommand * gsmc);
/* accessors */
GSMCommandCallback gsm_command_get_callback(GSMCommand * gsmc);
char const * gsm_command_get_command(GSMCommand * gsmc);
void * gsm_command_get_data(GSMCommand * gsmc);
GSMError gsm_command_get_error(GSMCommand * gsmc);
GSMMode gsm_command_get_mode(GSMCommand * gsmc);
GSMPriority gsm_command_get_priority(GSMCommand * gsmc);
unsigned int gsm_command_get_timeout(GSMCommand * gsmc);
void gsm_command_set_callback(GSMCommand * gsmc, GSMCommandCallback callback);
void gsm_command_set_data(GSMCommand * gsmc, void * data);
void gsm_command_set_error(GSMCommand * gsmc, GSMError error);
void gsm_command_set_mode(GSMCommand * gsmc, GSMMode mode);
void gsm_command_set_priority(GSMCommand * gsmc, GSMPriority priority);