Hi Andreas, > +static void reset_buf(char *buf, char *buf_2, int buf_len) > +{ > + memset(buf, '\0', buf_len); > + memset(buf_2, '\0', buf_len); > +} > + > +static int get_topics_len(const char *topics) > +{ > + int i = 0; > + int k = 0; > + int length = 0; > + char buf[6]; > + char buf_2[6]; > + > + reset_buf(buf, buf_2, 6); > + > + while (*topics != '\0') { > + if (*topics == ',') { > + reset_buf(buf, buf_2, 6); > + k = 0; > + length++; > + } else if (*topics != ',' && *topics != '-') { > + buf[k] = *topics; > + k++; > + } else if (*topics == '-') { > + topics++; > + i++; > + k = 0; > + > + while (*topics != ',' && *topics != '\0') { > + buf_2[k] = *topics; > + topics++; > + i++; > + k++; > + } > + > + length = length + atoi(buf_2) - atoi(buf) + 1; > + k = 0; > + } > + > + topics++; > + i++; > + } > + > + topics = topics - i; > + return length; > +} > + > +static void parse_topics(const char *topics, gint16 *topics_parsed) > +{ > + int j = 0; > + int k = 0; > + char buf[6]; > + char buf_2[6]; > + > + reset_buf(buf, buf_2, 6); > + > + while (*topics != '\0') { > + if (*topics != ',' && *topics != '-') { > + buf[j] = *topics; > + j++; > + } else if (*topics == '-') { > + topics++; > + j = 0; > + > + while (*topics != ',' && *topics != '\0') { > + buf_2[j] = *topics; > + topics++; > + j++; > + } > + > + for (j = 0; j <= (atoi(buf_2) - atoi(buf)); j++) { > + topics_parsed[k] = atoi(buf) + j; > + topics_parsed[k] = g_ntohs(topics_parsed[k]); > + k++; > + } > + > + j = 0; > + } else if (*topics == ',') { > + topics_parsed[k] = atoi(buf); > + topics_parsed[k] = g_ntohs(topics_parsed[k]); > + reset_buf(buf, buf_2, 6); > + j = 0; > + k++; > + } > + > + topics++; > + } > +} > +
Have you thought of adapting cbs_extract_topic_ranges function for all of this somehow? Regards, -Denis _______________________________________________ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono