53 while ( current_elem != NULL )
55 if ( current_elem->
text ) free(current_elem->
text);
56 tmp_elem = current_elem->
next;
58 current_elem = tmp_elem;
67 if ( minute_digit_count <= -2 )
75 return retval * pow(10, -1*minute_digit_count);
94 unsigned int const matchcount = 3;
95 regmatch_t matches[matchcount];
105 if ( regexec(&fapint_regex_nmea_dst, packet->
dst_callsign, matchcount, (regmatch_t*)&matches, 0) == 0 )
108 len = matches[2].rm_eo - matches[2].rm_so;
109 memset(leftover_str, 0, 3);
110 memcpy(leftover_str, packet->
dst_callsign+matches[2].rm_so, len);
112 type = leftover_str[0];
116 if ( type ==
'C' || type ==
'E' )
119 memset(numberid_str, 0, 3);
120 numberid_str[0] = leftover_str[1];
121 numberid_str[1] = leftover_str[2];
122 numberid = atoi(numberid_str);
125 if ( numberid > 0 && numberid < 95 )
147 dst_type[0] = leftover_str[0];
148 dst_type[1] = leftover_str[1];
149 overlay = leftover_str[2];
150 if ( (type ==
'O' || type ==
'A' || type ==
'N' ||
151 type ==
'D' || type ==
'S' || type ==
'Q') &&
176 tmp_2b[0] = leftover_str[0];
177 tmp_2b[1] = leftover_str[1];
208 if ( input[0] ==
'B' )
267 if ( input[0] ==
'P' )
275 if ( isdigit(input[1]) || isupper(input[1]) )
277 output[1] = input[1];
283 if ( input[0] ==
'M' )
318 if ( input[0] ==
'H' )
350 if ( input[0] ==
'L' )
358 if ( isupper(input[1]) )
360 output[1] = tolower(input[1]);
366 if ( input[0] ==
'J' )
401 if ( !input )
return 0;
403 for ( i = 0; i < strlen(input); ++i )
405 if ( !isdigit(input[i]) || ( i==0 && (input[i]==
'-' || input[i]==
'+') ) )
return 0;
415 return year < 10000 && month <= 12 && day <= 31;
429 unsigned int matchcount = 4;
430 regmatch_t matches[matchcount];
434 if ( !packet || !field1 || !field2 )
440 if ( regexec(&fapint_regex_nmea_flag, field2, matchcount, (regmatch_t*)&matches, 0) == 0 )
442 direction = field2[matches[1].rm_so];
454 if ( regexec(&fapint_regex_nmea_coord, field1, matchcount, (regmatch_t*)&matches, 0) == 0 )
456 len = matches[1].rm_eo - matches[1].rm_so;
457 tmp_str = malloc(len+1);
458 if ( !tmp_str )
return 0;
459 memcpy(tmp_str, field1+matches[1].rm_so, len);
461 tmp_us = atoi(tmp_str);
464 len = matches[2].rm_eo - matches[2].rm_so;
465 tmp_str = malloc(len+1);
466 if ( !tmp_str )
return 0;
467 memcpy(tmp_str, field1+matches[2].rm_so, len);
469 value = atof(tmp_str);
472 len = matches[3].rm_eo - matches[3].rm_so;
474 value = tmp_us + value/60;
490 switch ( toupper(direction) )
494 if ( value > 179.999999 )
500 if ( toupper(direction) ==
'W' )
504 packet->
longitude = malloc(
sizeof(
double));
510 if ( value > 89.999999 )
516 if ( toupper(direction) ==
'S' )
520 packet->
latitude = malloc(
sizeof(
double));
531 short fapint_valid_com_telem_char(
char c)
533 if ( c >=
'!' && c <=
'{' )
548 unsigned int const matchcount = 8;
549 regmatch_t matches[matchcount];
551 if ( rest == 0 || *rest == 0 || rest_len == 0 || *rest_len == 0 )
557 if ( regexec(&fapint_regex_base91_telemetry, *rest, matchcount, (regmatch_t*)&matches, 0) == 0 )
567 *packet->
telemetry->
seq = ((*rest)[matches[1].rm_so] - 33) * 91 + (*rest)[matches[1].rm_so+1] - 33;
570 *packet->
telemetry->
val1 = ((*rest)[matches[2].rm_so] - 33) * 91 + (*rest)[matches[2].rm_so+1] - 33;
573 if ( matches[3].rm_eo - matches[3].rm_so > 0 )
577 *packet->
telemetry->
val2 = ((*rest)[matches[3].rm_so] - 33) * 91 + (*rest)[matches[3].rm_so+1] - 33;
579 if ( matches[4].rm_eo - matches[4].rm_so > 0 )
583 *packet->
telemetry->
val3 = ((*rest)[matches[4].rm_so] - 33) * 91 + (*rest)[matches[4].rm_so+1] - 33;
585 if ( matches[5].rm_eo - matches[5].rm_so > 0 )
589 *packet->
telemetry->
val4 = ((*rest)[matches[5].rm_so] - 33) * 91 + (*rest)[matches[5].rm_so+1] - 33;
591 if ( matches[6].rm_eo - matches[6].rm_so > 0 )
595 *packet->
telemetry->
val5 = ((*rest)[matches[6].rm_so] - 33) * 91 + (*rest)[matches[6].rm_so+1] - 33;
599 if ( matches[7].rm_eo - matches[7].rm_so > 0 )
601 for (tmp = 0; tmp < 8; tmp++ ) packet->
telemetry->
bits[tmp] =
'0';
602 tmp = ((*rest)[matches[7].rm_so] - 33) * 91 + (*rest)[matches[7].rm_so+1] - 33;
615 tmp_str =
fapint_remove_part(*rest, tmp_us, matches[0].rm_so, matches[0].rm_eo, rest_len);
628 wx_report->
temp = NULL;
638 wx_report->
soft = NULL;
645 tlm_report->
seq = NULL;
646 tlm_report->
val1 = NULL;
647 tlm_report->
val2 = NULL;
648 tlm_report->
val3 = NULL;
649 tlm_report->
val4 = NULL;
650 tlm_report->
val5 = NULL;
656 unsigned int const part_so,
unsigned int const part_eo,
657 unsigned int* result_len)
659 unsigned int i, part_i;
664 if( !input || !input_len || part_so >= input_len || part_eo > input_len || part_so >= part_eo )
671 *result_len = input_len - (part_eo - part_so);
672 if ( *result_len == 0 )
678 result = malloc(*result_len+1);
685 for ( i = 0; i < input_len; ++i )
688 if ( i < part_so || i >= part_eo )
690 result[part_i] = input[i];
696 result[*result_len] = 0;