Convert tests/* to pointers

pull/1522/head
George Baltz N3GB 2024-02-29 20:58:51 -05:00
rodzic 55db73894f
commit 07f8023d17
19 zmienionych plików z 51 dodań i 52 usunięć

Wyświetl plik

@ -353,13 +353,13 @@ int main(int argc, char *argv[])
if (amp_file)
{
strncpy(my_amp->state.ampport.pathname, amp_file, HAMLIB_FILPATHLEN - 1);
strncpy(AMPPORT(my_amp)->pathname, amp_file, HAMLIB_FILPATHLEN - 1);
}
/* FIXME: bound checking and port type == serial */
if (serial_rate != 0)
{
my_amp->state.ampport.parm.serial.rate = serial_rate;
AMPPORT(my_amp)->parm.serial.rate = serial_rate;
}
/*

Wyświetl plik

@ -77,9 +77,9 @@ int main(int argc, char *argv[])
/* Set up serial port, baud rate */
rig_file = argv[2]; // your serial device
strncpy(my_rig->state.rigport.pathname, rig_file, HAMLIB_FILPATHLEN - 1);
strncpy(RIGPORT(my_rig)->pathname, rig_file, HAMLIB_FILPATHLEN - 1);
my_rig->state.rigport.parm.serial.rate = baud; // your baud rate
RIGPORT(my_rig)->parm.serial.rate = baud; // your baud rate
/* Open my rig */
retcode = rig_open(my_rig);

Wyświetl plik

@ -44,7 +44,7 @@ int main(int argc, const char *argv[])
/* Set up serial port, baud rate */
rig_file = "127.0.0.1:4532"; // your serial device
strncpy(my_rig->state.rigport.pathname, rig_file, HAMLIB_FILPATHLEN - 1);
strncpy(RIGPORT(my_rig)->pathname, rig_file, HAMLIB_FILPATHLEN - 1);
/* Open my rig */
retcode = rig_open(my_rig);

Wyświetl plik

@ -12,7 +12,7 @@ int callback(const struct rig_caps *caps, rig_ptr_t rigp)
}
const char *port = "/dev/pts/3";
strcpy(rig->state.rigport.pathname, port);
strcpy(RIGPORT(rig)->pathname, port);
printf("%20s:", caps->model_name);
fflush(stdout);

Wyświetl plik

@ -57,7 +57,7 @@ int main(int argc, const char *argv[])
exit(1); /* whoops! something went wrong (mem alloc?) */
}
strncpy(my_rig->state.rigport.pathname, SERIAL_PORT, HAMLIB_FILPATHLEN - 1);
strncpy(RIGPORT(my_rig)->pathname, SERIAL_PORT, HAMLIB_FILPATHLEN - 1);
if (rig_open(my_rig))
{

Wyświetl plik

@ -592,7 +592,7 @@ int main(int argc, char *argv[])
if (rig_file)
{
strncpy(my_rig->state.rigport.pathname, rig_file, HAMLIB_FILPATHLEN - 1);
strncpy(RIGPORT(my_rig)->pathname, rig_file, HAMLIB_FILPATHLEN - 1);
}
/*
@ -600,7 +600,7 @@ int main(int argc, char *argv[])
*/
if (ptt_type != RIG_PTT_NONE)
{
my_rig->state.pttport.type.ptt = ptt_type;
PTTPORT(my_rig)->type.ptt = ptt_type;
}
if (dcd_type != RIG_DCD_NONE)
@ -610,7 +610,7 @@ int main(int argc, char *argv[])
if (ptt_file)
{
strncpy(my_rig->state.pttport.pathname, ptt_file, HAMLIB_FILPATHLEN - 1);
strncpy(PTTPORT(my_rig)->pathname, ptt_file, HAMLIB_FILPATHLEN - 1);
}
if (dcd_file)
@ -621,7 +621,7 @@ int main(int argc, char *argv[])
/* FIXME: bound checking and port type == serial */
if (serial_rate != 0)
{
my_rig->state.rigport.parm.serial.rate = serial_rate;
RIGPORT(my_rig)->parm.serial.rate = serial_rate;
my_rig->state.rigport_deprecated.parm.serial.rate = serial_rate;
}

Wyświetl plik

@ -512,7 +512,7 @@ int main(int argc, char *argv[])
if (rig_file)
{
strncpy(my_rig->state.rigport.pathname, rig_file, HAMLIB_FILPATHLEN - 1);
strncpy(RIGPORT(my_rig)->pathname, rig_file, HAMLIB_FILPATHLEN - 1);
}
if (!rig_file2)
@ -528,7 +528,7 @@ int main(int argc, char *argv[])
*/
if (ptt_type != RIG_PTT_NONE)
{
my_rig->state.pttport.type.ptt = ptt_type;
PTTPORT(my_rig)->type.ptt = ptt_type;
}
if (dcd_type != RIG_DCD_NONE)
@ -538,7 +538,7 @@ int main(int argc, char *argv[])
if (ptt_file)
{
strncpy(my_rig->state.pttport.pathname, ptt_file, HAMLIB_FILPATHLEN - 1);
strncpy(PTTPORT(my_rig)->pathname, ptt_file, HAMLIB_FILPATHLEN - 1);
}
if (dcd_file)
@ -549,7 +549,7 @@ int main(int argc, char *argv[])
/* FIXME: bound checking and port type == serial */
if (serial_rate != 0)
{
my_rig->state.rigport.parm.serial.rate = serial_rate;
RIGPORT(my_rig)->parm.serial.rate = serial_rate;
}
if (serial_rate2 != 0)

Wyświetl plik

@ -691,7 +691,7 @@ int main(int argc, char *argv[])
if (rig_file)
{
strncpy(my_rig->state.rigport.pathname, rig_file, HAMLIB_FILPATHLEN - 1);
strncpy(RIGPORT(my_rig)->pathname, rig_file, HAMLIB_FILPATHLEN - 1);
}
my_rig->state.twiddle_timeout = twiddle_timeout;
@ -706,7 +706,7 @@ int main(int argc, char *argv[])
*/
if (ptt_type != RIG_PTT_NONE)
{
my_rig->state.pttport.type.ptt = ptt_type;
PTTPORT(my_rig)->type.ptt = ptt_type;
my_rig->state.pttport_deprecated.type.ptt = ptt_type;
// This causes segfault since backend rig_caps are const
// rigctld will use the rig->state version of this for clients
@ -721,7 +721,7 @@ int main(int argc, char *argv[])
if (ptt_file)
{
strncpy(my_rig->state.pttport.pathname, ptt_file, HAMLIB_FILPATHLEN - 1);
strncpy(PTTPORT(my_rig)->pathname, ptt_file, HAMLIB_FILPATHLEN - 1);
strncpy(my_rig->state.pttport_deprecated.pathname, ptt_file,
HAMLIB_FILPATHLEN - 1);
}
@ -736,7 +736,7 @@ int main(int argc, char *argv[])
/* FIXME: bound checking and port type == serial */
if (serial_rate != 0)
{
my_rig->state.rigport.parm.serial.rate = serial_rate;
RIGPORT(my_rig)->parm.serial.rate = serial_rate;
my_rig->state.rigport_deprecated.parm.serial.rate = serial_rate;
}

Wyświetl plik

@ -540,11 +540,11 @@ int main(int argc, char *argv[])
if (rig_file)
{
strncpy(my_rig->state.rigport.pathname, rig_file, HAMLIB_FILPATHLEN - 1);
strncpy(RIGPORT(my_rig)->pathname, rig_file, HAMLIB_FILPATHLEN - 1);
}
fprintf(stderr, "rig to send frequency to: %s\n", rig_file2);
strncpy(my_rig_sync->state.rigport.pathname, rig_file2, HAMLIB_FILPATHLEN - 1);
strncpy(RIGPORT(my_rig_sync)->pathname, rig_file2, HAMLIB_FILPATHLEN - 1);
#if 0
@ -553,7 +553,7 @@ int main(int argc, char *argv[])
*/
if (ptt_type != RIG_PTT_NONE)
{
my_rig->state.pttport.type.ptt = ptt_type;
PTTPORT(my_rig)->type.ptt = ptt_type;
}
if (dcd_type != RIG_DCD_NONE)
@ -563,7 +563,7 @@ int main(int argc, char *argv[])
if (ptt_file)
{
strncpy(my_rig->state.pttport.pathname, ptt_file, HAMLIB_FILPATHLEN - 1);
strncpy(PTTPORT(my_rig)->pathname, ptt_file, HAMLIB_FILPATHLEN - 1);
}
if (dcd_file)
@ -576,12 +576,12 @@ int main(int argc, char *argv[])
/* FIXME: bound checking and port type == serial */
if (serial_rate != 0)
{
my_rig->state.rigport.parm.serial.rate = serial_rate;
RIGPORT(my_rig)->parm.serial.rate = serial_rate;
}
if (serial_rate2 != 0)
{
my_rig_sync->state.rigport.parm.serial.rate = serial_rate2;
RIGPORT(my_rig_sync)->parm.serial.rate = serial_rate2;
}

Wyświetl plik

@ -82,7 +82,7 @@ int main(int argc, const char *argv[])
exit(1); /* whoops! something went wrong (mem alloc?) */
}
strncpy(my_rig->state.rigport.pathname, argv[2], HAMLIB_FILPATHLEN - 1);
rig_set_conf(my_rig, rig_token_lookup(my_rig, "rig_pathname"), argv[2]);
retcode = rig_open(my_rig);

Wyświetl plik

@ -283,13 +283,13 @@ int main(int argc, char *argv[])
if (rig_file)
{
strncpy(rig->state.rigport.pathname, rig_file, HAMLIB_FILPATHLEN - 1);
strncpy(RIGPORT(rig)->pathname, rig_file, HAMLIB_FILPATHLEN - 1);
}
/* FIXME: bound checking and port type == serial */
if (serial_rate != 0)
{
rig->state.rigport.parm.serial.rate = serial_rate;
RIGPORT(rig)->parm.serial.rate = serial_rate;
}
if (civaddr)

Wyświetl plik

@ -25,11 +25,11 @@ int main(int argc, const char *argv[])
}
#ifdef _WIN32
strncpy(rig->state.rigport.pathname, "COM37", HAMLIB_FILPATHLEN - 1);
strncpy(RIGPORT(rig)->pathname, "COM37", HAMLIB_FILPATHLEN - 1);
#else
strncpy(rig->state.rigport.pathname, "/dev/ttyUSB0", HAMLIB_FILPATHLEN - 1);
strncpy(RIGPORT(rig)->pathname, "/dev/ttyUSB0", HAMLIB_FILPATHLEN - 1);
#endif
rig->state.rigport.parm.serial.rate = 38400;
RIGPORT(rig)->parm.serial.rate = 38400;
rig_open(rig);
// disabled until we change this to the other multicast capability
#if 0

Wyświetl plik

@ -368,26 +368,26 @@ int main(int argc, char *argv[])
token = strtok(NULL, ",");
}
hamlib_port_t *rotp = ROTPORT(my_rot);
hamlib_port_t *rotp2 = ROTPORT2(my_rot);
if (rot_file)
{
strncpy(my_rot->state.rotport.pathname, rot_file, HAMLIB_FILPATHLEN - 1);
strncpy(rotp->pathname, rot_file, HAMLIB_FILPATHLEN - 1);
}
if (rot_file2)
{
strncpy(my_rot->state.rotport2.pathname, rot_file2, HAMLIB_FILPATHLEN - 1);
strncpy(rotp2->pathname, rot_file2, HAMLIB_FILPATHLEN - 1);
}
/* FIXME: bound checking and port type == serial */
my_rot->state.rotport2.parm.serial.rate =
my_rot->state.rotport.parm.serial.rate;
my_rot->state.rotport2.parm.serial.data_bits =
my_rot->state.rotport.parm.serial.data_bits;
rotp2->parm.serial.rate = rotp->parm.serial.rate;
rotp2->parm.serial.data_bits = rotp->parm.serial.data_bits;
if (serial_rate != 0)
{
my_rot->state.rotport.parm.serial.rate = serial_rate;
my_rot->state.rotport2.parm.serial.rate = serial_rate;
rotp->parm.serial.rate = serial_rate;
rotp2->parm.serial.rate = serial_rate;
}
/*

Wyświetl plik

@ -2507,7 +2507,7 @@ declare_proto_rot(dump_state)
declare_proto_rot(send_cmd)
{
int retval;
struct rot_state *rs;
hamlib_port_t *rotp = ROTPORT(rot);
int backend_num, cmd_len;
#define BUFSZ 128
unsigned char bufcmd[BUFSZ];
@ -2555,11 +2555,9 @@ declare_proto_rot(send_cmd)
eom_buf[2] = send_cmd_term;
}
rs = &rot->state;
rig_flush(rotp);
rig_flush(&rs->rotport);
retval = write_block(&rs->rotport, bufcmd, cmd_len);
retval = write_block(rotp, bufcmd, cmd_len);
if (retval != RIG_OK)
{
@ -2577,7 +2575,7 @@ declare_proto_rot(send_cmd)
* assumes CR or LF is end of line char
* for all ascii protocols
*/
retval = read_string(&rs->rotport, buf, BUFSZ, eom_buf, strlen(eom_buf), 0, 1);
retval = read_string(rotp, buf, BUFSZ, eom_buf, strlen(eom_buf), 0, 1);
if (retval < 0)
{

Wyświetl plik

@ -376,18 +376,18 @@ int main(int argc, char *argv[])
if (rot_file)
{
strncpy(my_rot->state.rotport.pathname, rot_file, HAMLIB_FILPATHLEN - 1);
strncpy(ROTPORT(my_rot)->pathname, rot_file, HAMLIB_FILPATHLEN - 1);
}
if (rot_file2)
{
strncpy(my_rot->state.rotport2.pathname, rot_file2, HAMLIB_FILPATHLEN - 1);
strncpy(ROTPORT2(my_rot)->pathname, rot_file2, HAMLIB_FILPATHLEN - 1);
}
/* FIXME: bound checking and port type == serial */
if (serial_rate != 0)
{
my_rot->state.rotport.parm.serial.rate = serial_rate;
ROTPORT(my_rot)->parm.serial.rate = serial_rate;
}
/*

Wyświetl plik

@ -2,6 +2,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <hamlib/rig.h>
#define PATH "/dev/pts/4"
int
main()
@ -15,7 +16,7 @@ main()
int retcode;
my_rig = rig_init(2048);
strcpy(my_rig->state.rigport.pathname, "/dev/pts/4");
rig_set_conf(my_rig, rig_token_lookup(my_rig, "rig_pathname"), PATH);
retcode = rig_open(my_rig);

Wyświetl plik

@ -46,7 +46,7 @@ int main(int argc, char *argv[])
/* Set up serial port, baud rate */
strncpy(my_rig->state.rigport.pathname, rig_file, HAMLIB_FILPATHLEN - 1);
rig_set_conf(my_rig, rig_token_lookup(my_rig, "rig_pathname"), rig_file);
/* Open my rig */
retcode = rig_open(my_rig);

Wyświetl plik

@ -68,7 +68,7 @@ int main(int argc, const char *argv[])
exit(1); /* whoops! something went wrong (mem alloc?) */
}
//strncpy(my_rig->state.rigport.pathname, SERIAL_PORT, HAMLIB_FILPATHLEN - 1);
//strncpy(RIGPORT(my_rig)->pathname, SERIAL_PORT, HAMLIB_FILPATHLEN - 1);
retcode = rig_open(my_rig);

Wyświetl plik

@ -30,7 +30,7 @@ int callback(struct rig_caps *caps, rig_ptr_t rigp)
}
const char *port = "/dev/pts/3";
strcpy(rig->state.rigport.pathname, port);
rig_set_conf(rig, rig_token_lookup(rig, "rig_pathname"), port);
printf("%20s:", caps->model_name);
fflush(stdout);