MCPcopy Create free account
hub / github.com/Hamlib/Hamlib / rot_sprintf_status

Function rot_sprintf_status

src/sprintflst.c:808–851  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

806}
807
808int rot_sprintf_status(char *str, int nlen, rot_status_t status)
809{
810 int len = 0;
811 unsigned long i;
812
813 rig_debug(RIG_DEBUG_TRACE, "%s: status=%08x\n", __func__, status);
814 *str = '\0';
815
816 if (status == ROT_STATUS_NONE)
817 {
818 return 0;
819 }
820
821 for (i = 0; i < HAMLIB_MAX_ROTORS; i++)
822 {
823 const char *sv = rot_strstatus(status & ROT_STATUS_N(i));
824
825 if (sv && sv[0] && (strstr(sv, "None") == 0))
826 {
827 int written = snprintf(str + len, nlen - len, "%s ", sv);
828
829 if (written < 0 || written >= nlen - len)
830 {
831 // Truncate and break if there's no space left
832 rig_debug(RIG_DEBUG_ERR, "%s: buffer overflow\n", __func__);
833 len = nlen - 1;
834 str[len] = '\0';
835 break;
836 }
837
838 len += written;
839 }
840
841 if (len >= nlen)
842 {
843 // Ensure null-termination and avoid overflow
844 rig_debug(RIG_DEBUG_ERR, "%s: buffer overflow\n", __func__);
845 str[nlen - 1] = '\0';
846 break;
847 }
848 }
849
850 return len;
851}
852
853
854int rig_sprintf_spectrum_modes(char *str, int nlen,

Callers 2

dumpcaps_rotFunction · 0.85
rotctl_parse.cFile · 0.85

Calls 2

rig_debugFunction · 0.85
rot_strstatusFunction · 0.85

Tested by

no test coverage detected