// Copyright 2016 Google Inc. All Rights Reserved.
// Licensed under the Apache License, Version 2.0 (the "License");
#include <stdint.h>
#include <stdlib.h>
#include <string>
#include <stdio.h>
#include <cstdlib>


int test_func(const uint8_t *Data, size_t Size) {
  unsigned char *buf;
  int buflen;
  std::string s(reinterpret_cast<const char *>(Data), Size);
  ares_create_query(s.c_str(), ns_c_in, ns_t_a, 0x1234, 0, &buf, &buflen, 0);
  free(buf);
  return 0;
}


int main(int argc, char *argv[]){
  if(argc==1){
    printf("%s\n", "usage");
    return 0;
  }

  char* file_path = argv[1];
  FILE *fp;
  if((fp=fopen(file_path, "rb")) == NULL){
    printf("cannot open file:%s\n", file_path);
    return 0;
  }

  fseek(fp, 0, SEEK_END);
  size_t file_len = ftell(fp);
  uint8_t *tmp = (uint8_t*)malloc(sizeof(uint8_t) * file_len);
  fseek(fp, 0, SEEK_SET);
  fread(tmp, file_len, sizeof(uint8_t), fp);
  fclose(fp);

  test_func(tmp, file_len);

  return 0;

}
