src/mk_mdns_client.c
int mk_get_dotted_str_to_dns_name(char* src, unsigned char* dest)
{
  int count=0;
  int n=0;
  int dnsL=0;

  if ((!src) || (!dest)) {
     return -1;
  }

  while (n < MAX_NAME_SZ) {
    if(src[n] == '.'){
      dest[n-count] = count;
      count=0;
      n++;
    }
    else if(src[n] == 0){
      dest[n-count] = count;
      dest[n+1] = src[n];
      dnsL = n+2; //1+1 for prefix and terminating 0
      break;
    }
    else {
      dest[n+1] = src[n];
      n++;
      count++;
    }
  }

  return dnsL; 
}
//returns the number of bytes written into dest including terminating 0
returns the number of bytes written into dest including terminating 0
returns the number of bytes written into dest including terminating 0
int mk_get_dotted_str_to_dns_name(char* src, unsigned char* dest)
{
  int count=0;
  int n=0;
  int dnsL=0;
  if ((!src) || (!dest)) {
     return -1;
  }
  while (n < MAX_NAME_SZ) {
    if(src[n] == '.'){
      dest[n-count] = count;
      count=0;
      n++;
    }
    else if(src[n] == 0){
      dest[n-count] = count;
      dest[n+1] = src[n];
      dnsL = n+2; 
      break;
    }
    else {
      dest[n+1] = src[n];
      n++;
      count++;
    }
  }
  return dnsL; 
}
int mk_get_dotted_str_to_dns_name ( char * src , unsigned char * dest ) { int count = 0 ; int n = 0 ; int dnsL = 0 ; if ( ( ! src ) || ( ! dest ) ) { return -1 ; } while ( n < MAX_NAME_SZ ) { if ( src [ n ] == ' ' ) { dest [ n - count ] = count ; count = 0 ; n ++ ; } else if ( src [ n ] == 0 ) { dest [ n - count ] = count ; dest [ n + 1 ] = src [ n ] ; dnsL = n + 2 ; break ; } else { dest [ n + 1 ] = src [ n ] ; n ++ ; count ++ ; } } return dnsL ; }
returns the number of bytes written into dest including terminating 0
returns the number of bytes written into dest including terminating 0
//1+1 for prefix and terminating 0