diff --git a/rigs/dorji/dra818.c b/rigs/dorji/dra818.c index 8cf4e93e4..4f684b7ef 100644 --- a/rigs/dorji/dra818.c +++ b/rigs/dorji/dra818.c @@ -100,7 +100,7 @@ static void dra818_subaudio(RIG *rig, char *subaudio, int subaudio_len, static int dra818_setgroup(RIG *rig) { - const struct dra818_priv *priv = rig->state.priv; + const struct dra818_priv *priv = STATE(rig)->priv; char cmd[80]; char subtx[8] = { 0 }; char subrx[8] = { 0 }; @@ -121,7 +121,7 @@ static int dra818_setgroup(RIG *rig) static int dra818_setvolume(RIG *rig) { - const struct dra818_priv *priv = rig->state.priv; + const struct dra818_priv *priv = STATE(rig)->priv; char cmd[80]; SNPRINTF(cmd, sizeof(cmd), "AT+DMOSETVOLUME=%1d\r\n", priv->vol); @@ -136,14 +136,14 @@ int dra818_init(RIG *rig) rig_debug(RIG_DEBUG_VERBOSE, "%s: dra818_init called\n", __func__); - rig->state.priv = calloc(sizeof(*priv), 1); + STATE(rig)->priv = calloc(sizeof(*priv), 1); - if (!rig->state.priv) + if (!STATE(rig)->priv) { return -RIG_ENOMEM; } - priv = rig->state.priv; + priv = STATE(rig)->priv; switch (rig->caps->rig_model) { @@ -174,7 +174,7 @@ int dra818_cleanup(RIG *rig) { rig_debug(RIG_DEBUG_VERBOSE, "%s: dra818_cleanup called\n", __func__); - free(rig->state.priv); + free(STATE(rig)->priv); return RIG_OK; } @@ -214,7 +214,7 @@ int dra818_open(RIG *rig) int dra818_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { - struct dra818_priv *priv = rig->state.priv; + struct dra818_priv *priv = STATE(rig)->priv; /* Nearest channel */ shortfreq_t sfreq = ((freq + priv->bw / 2) / priv->bw); @@ -252,7 +252,7 @@ int dra818_set_freq(RIG *rig, vfo_t vfo, freq_t freq) int dra818_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) { - struct dra818_priv *priv = rig->state.priv; + struct dra818_priv *priv = STATE(rig)->priv; if (width > 12500) { @@ -270,7 +270,7 @@ int dra818_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) int dra818_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) { - const struct dra818_priv *priv = rig->state.priv; + const struct dra818_priv *priv = STATE(rig)->priv; *mode = RIG_MODE_FM; *width = priv->bw; @@ -280,7 +280,7 @@ int dra818_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) int dra818_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd) { - const struct dra818_priv *priv = rig->state.priv; + const struct dra818_priv *priv = STATE(rig)->priv; hamlib_port_t *rp = RIGPORT(rig); char cmd[80]; char response[8]; @@ -313,7 +313,7 @@ int dra818_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd) int dra818_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) { - const struct dra818_priv *priv = rig->state.priv; + const struct dra818_priv *priv = STATE(rig)->priv; switch (vfo) { @@ -334,7 +334,7 @@ int dra818_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) int dra818_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) { - struct dra818_priv *priv = rig->state.priv; + struct dra818_priv *priv = STATE(rig)->priv; priv->split = split; @@ -348,7 +348,7 @@ int dra818_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) int dra818_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo) { - const struct dra818_priv *priv = rig->state.priv; + const struct dra818_priv *priv = STATE(rig)->priv; *split = priv->split; @@ -366,7 +366,7 @@ int dra818_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo) int dra818_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { - const struct dra818_priv *priv = rig->state.priv; + const struct dra818_priv *priv = STATE(rig)->priv; switch (level) { @@ -389,7 +389,7 @@ int dra818_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) int dra818_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) { - struct dra818_priv *priv = rig->state.priv; + struct dra818_priv *priv = STATE(rig)->priv; switch (level) { @@ -434,7 +434,7 @@ int dra818_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) int dra818_set_dcs_code(RIG *rig, vfo_t vfo, tone_t code) { - struct dra818_priv *priv = rig->state.priv; + struct dra818_priv *priv = STATE(rig)->priv; priv->dcs_code = code; @@ -448,7 +448,7 @@ int dra818_set_dcs_code(RIG *rig, vfo_t vfo, tone_t code) int dra818_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone) { - struct dra818_priv *priv = rig->state.priv; + struct dra818_priv *priv = STATE(rig)->priv; priv->ctcss_tone = tone; @@ -462,7 +462,7 @@ int dra818_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone) int dra818_set_dcs_sql(RIG *rig, vfo_t vfo, tone_t code) { - struct dra818_priv *priv = rig->state.priv; + struct dra818_priv *priv = STATE(rig)->priv; priv->dcs_sql = code; @@ -476,7 +476,7 @@ int dra818_set_dcs_sql(RIG *rig, vfo_t vfo, tone_t code) int dra818_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone) { - struct dra818_priv *priv = rig->state.priv; + struct dra818_priv *priv = STATE(rig)->priv; priv->ctcss_sql = tone; @@ -490,7 +490,7 @@ int dra818_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone) int dra818_get_ctcss_sql(RIG *rig, vfo_t vfo, tone_t *tone) { - const struct dra818_priv *priv = rig->state.priv; + const struct dra818_priv *priv = STATE(rig)->priv; *tone = priv->ctcss_sql; return RIG_OK; @@ -498,7 +498,7 @@ int dra818_get_ctcss_sql(RIG *rig, vfo_t vfo, tone_t *tone) int dra818_get_dcs_sql(RIG *rig, vfo_t vfo, tone_t *code) { - const struct dra818_priv *priv = rig->state.priv; + const struct dra818_priv *priv = STATE(rig)->priv; *code = priv->dcs_sql; return RIG_OK; @@ -506,7 +506,7 @@ int dra818_get_dcs_sql(RIG *rig, vfo_t vfo, tone_t *code) int dra818_get_dcs_code(RIG *rig, vfo_t vfo, tone_t *code) { - const struct dra818_priv *priv = rig->state.priv; + const struct dra818_priv *priv = STATE(rig)->priv; *code = priv->dcs_code; return RIG_OK; @@ -514,7 +514,7 @@ int dra818_get_dcs_code(RIG *rig, vfo_t vfo, tone_t *code) int dra818_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone) { - const struct dra818_priv *priv = rig->state.priv; + const struct dra818_priv *priv = STATE(rig)->priv; *tone = priv->ctcss_tone; return RIG_OK; diff --git a/rigs/drake/drake.c b/rigs/drake/drake.c index f9796ea4e..416c51a77 100644 --- a/rigs/drake/drake.c +++ b/rigs/drake/drake.c @@ -97,14 +97,14 @@ int drake_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, int drake_init(RIG *rig) { struct drake_priv_data *priv; - rig->state.priv = calloc(1, sizeof(struct drake_priv_data)); + STATE(rig)->priv = calloc(1, sizeof(struct drake_priv_data)); - if (!rig->state.priv) + if (!STATE(rig)->priv) { return -RIG_ENOMEM; } - priv = rig->state.priv; + priv = STATE(rig)->priv; priv->curr_ch = 0; @@ -113,7 +113,7 @@ int drake_init(RIG *rig) int drake_cleanup(RIG *rig) { - struct drake_priv_data *priv = rig->state.priv; + struct drake_priv_data *priv = STATE(rig)->priv; free(priv); @@ -552,7 +552,7 @@ int drake_set_mem(RIG *rig, vfo_t vfo, int ch) { int ack_len, retval; char buf[16], ackbuf[16]; - struct drake_priv_data *priv = rig->state.priv; + struct drake_priv_data *priv = STATE(rig)->priv; priv->curr_ch = ch; @@ -576,7 +576,7 @@ int drake_set_mem(RIG *rig, vfo_t vfo, int ch) */ int drake_get_mem(RIG *rig, vfo_t vfo, int *ch) { - struct drake_priv_data *priv = rig->state.priv; + struct drake_priv_data *priv = STATE(rig)->priv; int mdbuf_len, retval; char mdbuf[BUFSZ]; int chan; @@ -612,7 +612,7 @@ int drake_get_mem(RIG *rig, vfo_t vfo, int *ch) */ int drake_set_chan(RIG *rig, vfo_t vfo, const channel_t *chan) { - const struct drake_priv_data *priv = rig->state.priv; + const struct drake_priv_data *priv = STATE(rig)->priv; vfo_t old_vfo; int old_chan; char mdbuf[16], ackbuf[16]; @@ -668,7 +668,7 @@ int drake_set_chan(RIG *rig, vfo_t vfo, const channel_t *chan) */ int drake_get_chan(RIG *rig, vfo_t vfo, channel_t *chan, int read_only) { - const struct drake_priv_data *priv = rig->state.priv; + const struct drake_priv_data *priv = STATE(rig)->priv; vfo_t old_vfo; int old_chan; char mdbuf[BUFSZ], freqstr[BUFSZ]; @@ -880,7 +880,7 @@ int drake_get_chan(RIG *rig, vfo_t vfo, channel_t *chan, int read_only) */ int drake_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) { - const struct drake_priv_data *priv = rig->state.priv; + const struct drake_priv_data *priv = STATE(rig)->priv; char buf[16], ackbuf[16]; int len, ack_len, retval; diff --git a/rigs/elad/elad.c b/rigs/elad/elad.c index 8b9245266..953d9f0f3 100644 --- a/rigs/elad/elad.c +++ b/rigs/elad/elad.c @@ -145,7 +145,7 @@ const struct confparams elad_cfg_params[] = /** * elad_transaction - * Assumes rig!=NULL rig->state!=NULL rig->caps!=NULL + * Assumes rig!=NULL STATE(rig)!=NULL rig->caps!=NULL * * Parameters: * cmdstr: Command to be sent to the rig. cmdstr can also be NULL, @@ -164,7 +164,7 @@ const struct confparams elad_cfg_params[] = */ int elad_transaction(RIG *rig, const char *cmdstr, char *data, size_t datasize) { - struct elad_priv_data *priv = rig->state.priv; + struct elad_priv_data *priv = STATE(rig)->priv; const struct elad_priv_caps *caps = elad_caps(rig); struct rig_state *rs; hamlib_port_t *rp = RIGPORT(rig); @@ -185,7 +185,7 @@ int elad_transaction(RIG *rig, const char *cmdstr, char *data, size_t datasize) return -RIG_EINVAL; } - rs = &rig->state; + rs = STATE(rig); rs->transaction_active = 1; @@ -235,13 +235,13 @@ transaction_write: if (!datasize) { - rig->state.transaction_active = 0; + rs->transaction_active = 0; /* no reply expected so we need to write a command that always gives a reply so we can read any error replies from the actual command being sent without blocking */ - if (RIG_OK != (retval = write_block(rp, - (unsigned char *) priv->verify_cmd, strlen(priv->verify_cmd)))) + if (RIG_OK != (retval = write_block(rp, (unsigned char *) priv->verify_cmd, + strlen(priv->verify_cmd)))) { goto transaction_quit; } @@ -515,14 +515,14 @@ int elad_init(RIG *rig) rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - rig->state.priv = calloc(1, sizeof(struct elad_priv_data)); + STATE(rig)->priv = calloc(1, sizeof(struct elad_priv_data)); - if (rig->state.priv == NULL) + if (STATE(rig)->priv == NULL) { return -RIG_ENOMEM; } - priv = rig->state.priv; + priv = STATE(rig)->priv; memset(priv, 0x00, sizeof(struct elad_priv_data)); strcpy(priv->verify_cmd, RIG_MODEL_XG3 == rig->caps->rig_model ? ";" : "ID;"); @@ -551,15 +551,15 @@ int elad_cleanup(RIG *rig) { rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - free(rig->state.priv); - rig->state.priv = NULL; + free(STATE(rig)->priv); + STATE(rig)->priv = NULL; return RIG_OK; } int elad_open(RIG *rig) { - struct elad_priv_data *priv = rig->state.priv; + struct elad_priv_data *priv = STATE(rig)->priv; int err, i; char *idptr; char id[ELAD_MAX_BUF_LEN]; @@ -699,7 +699,7 @@ int elad_open(RIG *rig) int elad_close(RIG *rig) { - const struct elad_priv_data *priv = rig->state.priv; + const struct elad_priv_data *priv = STATE(rig)->priv; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -734,7 +734,7 @@ int elad_get_id(RIG *rig, char *buf) */ static int elad_get_if(RIG *rig) { - struct elad_priv_data *priv = rig->state.priv; + struct elad_priv_data *priv = STATE(rig)->priv; const struct elad_priv_caps *caps = elad_caps(rig); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -754,7 +754,7 @@ int elad_set_vfo(RIG *rig, vfo_t vfo) char cmdbuf[6]; int retval; char vfo_function; - const struct elad_priv_data *priv = rig->state.priv; + const struct elad_priv_data *priv = STATE(rig)->priv; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -906,7 +906,7 @@ int elad_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo) { // this is a bogus suppress which complains priv is not used -- but it is 20231012 // cppcheck-suppress unreadVariable - struct elad_priv_data *priv = rig->state.priv; + struct elad_priv_data *priv = STATE(rig)->priv; char cmdbuf[6]; int retval; unsigned char vfo_function; @@ -1004,7 +1004,7 @@ int elad_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo) */ int elad_set_split(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo) { - struct elad_priv_data *priv = rig->state.priv; + struct elad_priv_data *priv = STATE(rig)->priv; char cmdbuf[6]; int retval; @@ -1033,7 +1033,7 @@ int elad_set_split(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo) */ int elad_get_split_vfo_if(RIG *rig, vfo_t rxvfo, split_t *split, vfo_t *txvfo) { - struct elad_priv_data *priv = rig->state.priv; + struct elad_priv_data *priv = STATE(rig)->priv; int retval; int transmitting; @@ -1132,7 +1132,7 @@ int elad_get_split_vfo_if(RIG *rig, vfo_t rxvfo, split_t *split, vfo_t *txvfo) int elad_get_vfo_if(RIG *rig, vfo_t *vfo) { int retval; - struct elad_priv_data *priv = rig->state.priv; + struct elad_priv_data *priv = STATE(rig)->priv; int split_and_transmitting; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -1184,13 +1184,13 @@ int elad_set_freq(RIG *rig, vfo_t vfo, freq_t freq) unsigned char vfo_letter = '\0'; vfo_t tvfo; int err; - const struct elad_priv_data *priv = rig->state.priv; + const struct elad_priv_data *priv = STATE(rig)->priv; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); tvfo = (vfo == RIG_VFO_CURR - || vfo == RIG_VFO_VFO) ? rig->state.current_vfo : vfo; + || vfo == RIG_VFO_VFO) ? STATE(rig)->current_vfo : vfo; if (RIG_VFO_CURR == tvfo) { @@ -1270,7 +1270,7 @@ int elad_set_freq(RIG *rig, vfo_t vfo, freq_t freq) int elad_get_freq_if(RIG *rig, vfo_t vfo, freq_t *freq) { - const struct elad_priv_data *priv = rig->state.priv; + const struct elad_priv_data *priv = STATE(rig)->priv; char freqbuf[50]; int retval; @@ -1314,7 +1314,7 @@ int elad_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) } tvfo = (vfo == RIG_VFO_CURR - || vfo == RIG_VFO_VFO) ? rig->state.current_vfo : vfo; + || vfo == RIG_VFO_VFO) ? STATE(rig)->current_vfo : vfo; if (RIG_VFO_CURR == tvfo) { @@ -1370,7 +1370,7 @@ int elad_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit) { int retval; char buf[6]; - const struct elad_priv_data *priv = rig->state.priv; + const struct elad_priv_data *priv = STATE(rig)->priv; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -1503,7 +1503,7 @@ static int elad_set_filter(RIG *rig, pbwidth_t width) */ int elad_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) { - const struct elad_priv_data *priv = rig->state.priv; + const struct elad_priv_data *priv = STATE(rig)->priv; struct elad_priv_caps *caps = elad_caps(rig); char buf[6]; char kmode; @@ -1705,7 +1705,7 @@ static int elad_get_filter(RIG *rig, pbwidth_t *width) */ int elad_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) { - struct elad_priv_data *priv = rig->state.priv; + struct elad_priv_data *priv = STATE(rig)->priv; struct elad_priv_caps *caps = elad_caps(rig); char cmd[4]; char modebuf[10]; @@ -1824,7 +1824,7 @@ int elad_get_mode_if(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) { int err; struct elad_priv_caps *caps = elad_caps(rig); - const struct elad_priv_data *priv = rig->state.priv; + const struct elad_priv_data *priv = STATE(rig)->priv; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -1919,9 +1919,9 @@ int elad_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) { int foundit = 0; - for (i = 0; i < HAMLIB_MAXDBLSTSIZ && rig->state.attenuator[i]; i++) + for (i = 0; i < HAMLIB_MAXDBLSTSIZ && STATE(rig)->attenuator[i]; i++) { - if (val.i == rig->state.attenuator[i]) + if (val.i == STATE(rig)->attenuator[i]) { SNPRINTF(levelbuf, sizeof(levelbuf), "RA%02d", i + 1); foundit = 1; @@ -1948,9 +1948,9 @@ int elad_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) { int foundit = 0; - for (i = 0; i < HAMLIB_MAXDBLSTSIZ && rig->state.preamp[i]; i++) + for (i = 0; i < HAMLIB_MAXDBLSTSIZ && STATE(rig)->preamp[i]; i++) { - if (val.i == rig->state.preamp[i]) + if (val.i == STATE(rig)->preamp[i]) { SNPRINTF(levelbuf, sizeof(levelbuf), "PA%01d", i + 1); foundit = 1; @@ -2133,7 +2133,7 @@ int elad_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { for (i = 0; i < lvl && i < HAMLIB_MAXDBLSTSIZ; i++) { - if (rig->state.attenuator[i] == 0) + if (STATE(rig)->attenuator[i] == 0) { rig_debug(RIG_DEBUG_ERR, "%s: " "unexpected att level %d\n", @@ -2147,7 +2147,7 @@ int elad_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) return -RIG_EINTERNAL; } - val->i = rig->state.attenuator[i - 1]; + val->i = STATE(rig)->attenuator[i - 1]; } break; @@ -2170,7 +2170,7 @@ int elad_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) for (i = 0; i < lvl && i < HAMLIB_MAXDBLSTSIZ; i++) { - if (rig->state.preamp[i] == 0) + if (STATE(rig)->preamp[i] == 0) { rig_debug(RIG_DEBUG_ERR, "%s: " "unexpected preamp level %d\n", @@ -2184,7 +2184,7 @@ int elad_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) return -RIG_EINTERNAL; } - val->i = rig->state.preamp[i - 1]; + val->i = STATE(rig)->preamp[i - 1]; } else { @@ -2559,11 +2559,11 @@ int elad_set_ctcss_tone_tn(RIG *rig, vfo_t vfo, tone_t tone) /* * elad_get_ctcss_tone - * Assumes rig->state.priv != NULL + * Assumes STATE(rig)->priv != NULL */ int elad_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone) { - const struct elad_priv_data *priv = rig->state.priv; + const struct elad_priv_data *priv = STATE(rig)->priv; struct rig_caps *caps; char tonebuf[3]; int i, retval; @@ -2908,7 +2908,7 @@ int elad_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, */ int elad_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) { - struct elad_priv_data *priv = rig->state.priv; + struct elad_priv_data *priv = STATE(rig)->priv; int retval; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -3367,7 +3367,7 @@ int elad_get_mem_if(RIG *rig, vfo_t vfo, int *ch) { int err; char buf[4]; - const struct elad_priv_data *priv = rig->state.priv; + const struct elad_priv_data *priv = STATE(rig)->priv; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -3614,7 +3614,7 @@ int elad_set_ext_parm(RIG *rig, hamlib_token_t token, value_t val) int elad_get_ext_parm(RIG *rig, hamlib_token_t token, value_t *val) { int err; - struct elad_priv_data *priv = rig->state.priv; + struct elad_priv_data *priv = STATE(rig)->priv; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); diff --git a/rigs/elad/elad.h b/rigs/elad/elad.h index 423ffb93a..4e0da053b 100644 --- a/rigs/elad/elad.h +++ b/rigs/elad/elad.h @@ -170,7 +170,7 @@ extern struct rig_caps fdm_duo_caps; /* use when not interested in the answer, but want to check its len */ static int inline elad_simple_transaction(RIG *rig, const char *cmd, size_t expected) { - struct elad_priv_data *priv = rig->state.priv; + struct elad_priv_data *priv = STATE(rig)->priv; return elad_safe_transaction(rig, cmd, priv->info, ELAD_MAX_BUF_LEN, expected); } #endif diff --git a/rigs/flexradio/dttsp.c b/rigs/flexradio/dttsp.c index 50de1461a..c51e824c4 100644 --- a/rigs/flexradio/dttsp.c +++ b/rigs/flexradio/dttsp.c @@ -335,7 +335,7 @@ static int send_command(RIG *rig, const char *cmdstr, size_t buflen) static int fetch_meter(RIG *rig, int *label, float *data, int npts) { - struct dttsp_priv_data *priv = (struct dttsp_priv_data *)rig->state.priv; + struct dttsp_priv_data *priv = (struct dttsp_priv_data *)STATE(rig)->priv; int ret, buf_len; if (priv->meter_port.type.rig == RIG_PORT_UDP_NETWORK) @@ -398,14 +398,14 @@ static int fetch_meter(RIG *rig, int *label, float *data, int npts) /* - * Assumes rig!=NULL, rig->state.priv!=NULL + * Assumes rig!=NULL, STATE(rig)->priv!=NULL */ int dttsp_set_conf(RIG *rig, hamlib_token_t token, const char *val) { struct dttsp_priv_data *priv; struct rig_state *rs; - rs = &rig->state; + rs = STATE(rig); priv = (struct dttsp_priv_data *)rs->priv; switch (token) @@ -436,7 +436,7 @@ int dttsp_set_conf(RIG *rig, hamlib_token_t token, const char *val) /* * assumes rig!=NULL, - * Assumes rig!=NULL, rig->state.priv!=NULL + * Assumes rig!=NULL, STATE(rig)->priv!=NULL * and val points to a buffer big enough to hold the conf value. */ int dttsp_get_conf2(RIG *rig, hamlib_token_t token, char *val, int val_len) @@ -444,7 +444,7 @@ int dttsp_get_conf2(RIG *rig, hamlib_token_t token, char *val, int val_len) struct dttsp_priv_data *priv; struct rig_state *rs; - rs = &rig->state; + rs = STATE(rig); priv = (struct dttsp_priv_data *)rs->priv; switch (token) @@ -487,15 +487,15 @@ int dttsp_init(RIG *rig) rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - rig->state.priv = (struct dttsp_priv_data *)calloc(1, + STATE(rig)->priv = (struct dttsp_priv_data *)calloc(1, sizeof(struct dttsp_priv_data)); - if (!rig->state.priv) + if (!STATE(rig)->priv) { return -RIG_ENOMEM; } - priv = rig->state.priv; + priv = STATE(rig)->priv; priv->tuner = NULL; priv->tuner_model = RIG_MODEL_DUMMY; @@ -527,11 +527,12 @@ int dttsp_init(RIG *rig) int dttsp_open(RIG *rig) { - struct dttsp_priv_data *priv = (struct dttsp_priv_data *)rig->state.priv; + struct dttsp_priv_data *priv = (struct dttsp_priv_data *)STATE(rig)->priv; int ret; char *p; char *meterpath; hamlib_port_t *rp = RIGPORT(rig); + struct rig_state *rs = STATE(rig); rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__); @@ -622,12 +623,12 @@ int dttsp_open(RIG *rig) */ #if 1 - rig->state.has_set_func |= priv->tuner->state.has_set_func; - rig->state.has_get_func |= priv->tuner->state.has_get_func; - rig->state.has_set_level |= priv->tuner->state.has_set_level; - rig->state.has_get_level |= priv->tuner->state.has_get_level; - rig->state.has_set_parm |= priv->tuner->state.has_set_parm; - rig->state.has_get_parm |= priv->tuner->state.has_get_parm; + rs->has_set_func |= STATE(priv->tuner)->has_set_func; + rs->has_get_func |= STATE(priv->tuner)->has_get_func; + rs->has_set_level |= STATE(priv->tuner)->has_set_level; + rs->has_get_level |= STATE(priv->tuner)->has_get_level; + rs->has_set_parm |= STATE(priv->tuner)->has_set_parm; + rs->has_get_parm |= STATE(priv->tuner)->has_get_parm; #endif @@ -645,7 +646,7 @@ int dttsp_open(RIG *rig) int dttsp_close(RIG *rig) { - struct dttsp_priv_data *priv = (struct dttsp_priv_data *)rig->state.priv; + struct dttsp_priv_data *priv = (struct dttsp_priv_data *)STATE(rig)->priv; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -657,7 +658,7 @@ int dttsp_close(RIG *rig) int dttsp_cleanup(RIG *rig) { - struct dttsp_priv_data *priv = (struct dttsp_priv_data *)rig->state.priv; + struct dttsp_priv_data *priv = (struct dttsp_priv_data *)STATE(rig)->priv; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -667,9 +668,9 @@ int dttsp_cleanup(RIG *rig) priv->tuner = NULL; } - free(rig->state.priv); + free(STATE(rig)->priv); - rig->state.priv = NULL; + STATE(rig)->priv = NULL; return RIG_OK; } @@ -680,7 +681,7 @@ int dttsp_cleanup(RIG *rig) */ int dttsp_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { - struct dttsp_priv_data *priv = (struct dttsp_priv_data *)rig->state.priv; + struct dttsp_priv_data *priv = (struct dttsp_priv_data *)STATE(rig)->priv; freq_t tuner_freq; int ret; char fstr[20]; @@ -740,7 +741,7 @@ int dttsp_set_freq(RIG *rig, vfo_t vfo, freq_t freq) int dttsp_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) { - struct dttsp_priv_data *priv = (struct dttsp_priv_data *)rig->state.priv; + struct dttsp_priv_data *priv = (struct dttsp_priv_data *)STATE(rig)->priv; freq_t tuner_freq; int ret; @@ -859,7 +860,7 @@ static int agc_level2dttsp(enum agc_level_e agc) */ int dttsp_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) { - struct dttsp_priv_data *priv = (struct dttsp_priv_data *)rig->state.priv; + struct dttsp_priv_data *priv = (struct dttsp_priv_data *)STATE(rig)->priv; int ret = RIG_OK; char buf[32]; @@ -882,7 +883,7 @@ int dttsp_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) int dttsp_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { - struct dttsp_priv_data *priv = (struct dttsp_priv_data *)rig->state.priv; + struct dttsp_priv_data *priv = (struct dttsp_priv_data *)STATE(rig)->priv; int ret = RIG_OK; char buf[32]; float rxm[MAXRX][RXMETERPTS]; @@ -913,7 +914,7 @@ int dttsp_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) if (level == RIG_LEVEL_STRENGTH) { - val->i = (int)rig_raw2val(val->i, &rig->state.str_cal); + val->i = (int)rig_raw2val(val->i, &STATE(rig)->str_cal); } ret = RIG_OK; @@ -930,7 +931,7 @@ int dttsp_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) int dttsp_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) { - struct dttsp_priv_data *priv = (struct dttsp_priv_data *)rig->state.priv; + struct dttsp_priv_data *priv = (struct dttsp_priv_data *)STATE(rig)->priv; char buf[32]; const char *cmd; int ret; @@ -991,7 +992,7 @@ int dttsp_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit) int dttsp_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) { - struct dttsp_priv_data *priv = (struct dttsp_priv_data *)rig->state.priv; + struct dttsp_priv_data *priv = (struct dttsp_priv_data *)STATE(rig)->priv; rig_debug(RIG_DEBUG_TRACE, "%s: ant %u, try tuner\n", __func__, ant); diff --git a/rigs/flexradio/sdr1k.c b/rigs/flexradio/sdr1k.c index 3489651d2..1981186af 100644 --- a/rigs/flexradio/sdr1k.c +++ b/rigs/flexradio/sdr1k.c @@ -194,17 +194,18 @@ struct rig_caps sdr1k_rig_caps = int sdr1k_init(RIG *rig) { struct sdr1k_priv_data *priv; + struct rig_state *rs = STATE(rig); - rig->state.priv = (struct sdr1k_priv_data *)calloc(1, sizeof( + rs->priv = (struct sdr1k_priv_data *)calloc(1, sizeof( struct sdr1k_priv_data)); - if (!rig->state.priv) + if (!rs->priv) { /* whoops! memory shortage! */ return -RIG_ENOMEM; } - priv = rig->state.priv; + priv = rs->priv; priv->dds_freq = RIG_FREQ_NONE; priv->xtal = DEFAULT_XTAL; @@ -221,7 +222,7 @@ static void pdelay(RIG *rig) int sdr1k_open(RIG *rig) { - struct sdr1k_priv_data *priv = (struct sdr1k_priv_data *)rig->state.priv; + struct sdr1k_priv_data *priv = (struct sdr1k_priv_data *)STATE(rig)->priv; priv->shadow[0] = 0; priv->shadow[1] = 0; @@ -242,14 +243,14 @@ int sdr1k_close(RIG *rig) int sdr1k_cleanup(RIG *rig) { - struct sdr1k_priv_data *priv = (struct sdr1k_priv_data *)rig->state.priv; + struct sdr1k_priv_data *priv = (struct sdr1k_priv_data *)STATE(rig)->priv; if (priv) { free(priv); } - rig->state.priv = NULL; + STATE(rig)->priv = NULL; return RIG_OK; } @@ -299,7 +300,7 @@ static int set_band(RIG *rig, freq_t freq) */ int sdr1k_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { - struct sdr1k_priv_data *priv = (struct sdr1k_priv_data *)rig->state.priv; + struct sdr1k_priv_data *priv = (struct sdr1k_priv_data *)STATE(rig)->priv; int i; double ftw; double DDS_step_size; @@ -380,7 +381,7 @@ int sdr1k_set_freq(RIG *rig, vfo_t vfo, freq_t freq) int sdr1k_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) { - struct sdr1k_priv_data *priv = (struct sdr1k_priv_data *)rig->state.priv; + struct sdr1k_priv_data *priv = (struct sdr1k_priv_data *)STATE(rig)->priv; *freq = priv->dds_freq; rig_debug(RIG_DEBUG_TRACE, "%s: %"PRIll"\n", __func__, (int64_t)priv->dds_freq); @@ -452,7 +453,7 @@ int sdr1k_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) int write_latch(RIG *rig, latch_t which, unsigned value, unsigned mask) { - struct sdr1k_priv_data *priv = (struct sdr1k_priv_data *)rig->state.priv; + struct sdr1k_priv_data *priv = (struct sdr1k_priv_data *)STATE(rig)->priv; hamlib_port_t *pport = RIGPORT(rig); if (!(L_EXT <= which && which <= L_DDS1)) diff --git a/rigs/wj/wj.c b/rigs/wj/wj.c index 3396f7d64..f1a847237 100644 --- a/rigs/wj/wj.c +++ b/rigs/wj/wj.c @@ -66,7 +66,7 @@ const struct confparams wj_cfg_params[] = */ static int wj_transaction(RIG *rig, int monitor) { - struct wj_priv_data *priv = (struct wj_priv_data *)rig->state.priv; + struct wj_priv_data *priv = (struct wj_priv_data *)STATE(rig)->priv; hamlib_port_t *rp = RIGPORT(rig); unsigned char buf[CMDSZ] = { 0x8, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -209,15 +209,15 @@ int wj_init(RIG *rig) return -RIG_EINVAL; } - rig->state.priv = (struct wj_priv_data *)calloc(1, sizeof(struct wj_priv_data)); + STATE(rig)->priv = (struct wj_priv_data *)calloc(1, sizeof(struct wj_priv_data)); - if (!rig->state.priv) + if (!STATE(rig)->priv) { /* whoops! memory shortage! */ return -RIG_ENOMEM; } - priv = rig->state.priv; + priv = STATE(rig)->priv; priv->receiver_id = 0; priv->freq = kHz(500); @@ -239,12 +239,12 @@ int wj_cleanup(RIG *rig) return -RIG_EINVAL; } - if (rig->state.priv) + if (STATE(rig)->priv) { - free(rig->state.priv); + free(STATE(rig)->priv); } - rig->state.priv = NULL; + STATE(rig)->priv = NULL; return RIG_OK; } @@ -252,11 +252,11 @@ int wj_cleanup(RIG *rig) /* - * Assumes rig!=NULL, rig->state.priv!=NULL + * Assumes rig!=NULL, STATE(rig)->priv!=NULL */ int wj_set_conf(RIG *rig, hamlib_token_t token, const char *val) { - struct wj_priv_data *priv = (struct wj_priv_data *)rig->state.priv; + struct wj_priv_data *priv = (struct wj_priv_data *)STATE(rig)->priv; switch (token) { @@ -273,12 +273,12 @@ int wj_set_conf(RIG *rig, hamlib_token_t token, const char *val) /* * assumes rig!=NULL, - * Assumes rig!=NULL, rig->state.priv!=NULL + * Assumes rig!=NULL, STATE(rig)->priv!=NULL * and val points to a buffer big enough to hold the conf value. */ int wj_get_conf2(RIG *rig, hamlib_token_t token, char *val, int val_len) { - const struct wj_priv_data *priv = (struct wj_priv_data *)rig->state.priv; + const struct wj_priv_data *priv = (struct wj_priv_data *)STATE(rig)->priv; switch (token) { @@ -304,7 +304,7 @@ int wj_get_conf(RIG *rig, hamlib_token_t token, char *val) */ int wj_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { - struct wj_priv_data *priv = (struct wj_priv_data *)rig->state.priv; + struct wj_priv_data *priv = (struct wj_priv_data *)STATE(rig)->priv; priv->freq = freq; @@ -317,7 +317,7 @@ int wj_set_freq(RIG *rig, vfo_t vfo, freq_t freq) */ int wj_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) { - const struct wj_priv_data *priv = (struct wj_priv_data *)rig->state.priv; + const struct wj_priv_data *priv = (struct wj_priv_data *)STATE(rig)->priv; int retval; retval = wj_transaction(rig, 1); @@ -338,7 +338,7 @@ int wj_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) */ int wj_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) { - struct wj_priv_data *priv = (struct wj_priv_data *)rig->state.priv; + struct wj_priv_data *priv = (struct wj_priv_data *)STATE(rig)->priv; priv->mode = mode; @@ -361,7 +361,7 @@ int wj_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) */ int wj_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) { - const struct wj_priv_data *priv = (struct wj_priv_data *)rig->state.priv; + const struct wj_priv_data *priv = (struct wj_priv_data *)STATE(rig)->priv; int retval; retval = wj_transaction(rig, 1); @@ -385,7 +385,7 @@ int wj_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) */ int wj_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) { - struct wj_priv_data *priv = (struct wj_priv_data *)rig->state.priv; + struct wj_priv_data *priv = (struct wj_priv_data *)STATE(rig)->priv; switch (level) { @@ -415,7 +415,7 @@ int wj_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) */ int wj_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { - struct wj_priv_data *priv = (struct wj_priv_data *)rig->state.priv; + struct wj_priv_data *priv = (struct wj_priv_data *)STATE(rig)->priv; int retval = RIG_OK; retval = wj_transaction(rig, 1);