Function to parse a line read from csv file and store the data into appropriate fields of channel_t. The function must be consistent with dump_csv_name and dump_csv_chan. \param rig - a pointer to the rig \param chan - a pointer to channel_t structure with channel data \param line_key_list - a pointer to a table of strings with "keys" \param line_data_list - a pointer
| 735 | \return 0 on success, negative value on error |
| 736 | */ |
| 737 | int set_channel_data(RIG *rig, |
| 738 | channel_t *chan, |
| 739 | char **line_key_list, |
| 740 | char **line_data_list) |
| 741 | { |
| 742 | |
| 743 | int i, j, n; |
| 744 | const channel_cap_t *mem_caps; |
| 745 | struct rig_state *rs = STATE(rig); |
| 746 | |
| 747 | memset(chan, 0, sizeof(channel_t)); |
| 748 | chan->vfo = RIG_VFO_CURR; |
| 749 | |
| 750 | i = find_on_list(line_key_list, "num"); |
| 751 | |
| 752 | if (i < 0) |
| 753 | { |
| 754 | fprintf(stderr, "No channel number\n"); |
| 755 | return -1; |
| 756 | } |
| 757 | |
| 758 | n = chan->channel_num = atoi(line_data_list[ i ]); |
| 759 | |
| 760 | /* find channel caps of appropriate memory group? */ |
| 761 | for (j = 0; j < HAMLIB_CHANLSTSIZ; j++) |
| 762 | { |
| 763 | if (rs->chan_list[j].startc <= n && rs->chan_list[j].endc >= n) |
| 764 | { |
| 765 | break; |
| 766 | } |
| 767 | } |
| 768 | |
| 769 | if (j == HAMLIB_CHANLSTSIZ) |
| 770 | { |
| 771 | return -RIG_EINVAL; |
| 772 | } |
| 773 | |
| 774 | printf("Requested channel number %d, list number %d\n", n, j); |
| 775 | |
| 776 | mem_caps = &rs->chan_list[j].mem_caps; |
| 777 | |
| 778 | if (mem_caps->bank_num) |
| 779 | { |
| 780 | i = find_on_list(line_key_list, "bank_num"); |
| 781 | |
| 782 | if (i >= 0) |
| 783 | { |
| 784 | chan->bank_num = atoi(line_data_list[ i ]); |
| 785 | } |
| 786 | } |
| 787 | |
| 788 | if (mem_caps->channel_desc) |
| 789 | { |
| 790 | i = find_on_list(line_key_list, "channel_desc"); |
| 791 | |
| 792 | if (i >= 0) |
| 793 | { |
| 794 | strncpy(chan->channel_desc, line_data_list[ i ], rig->caps->chan_desc_sz - 1); |
no test coverage detected