#include <cstdio>
#include <cstdlib>
#include <cstring>
#include "schema.h"
#include "error.h"


int main(){
  char rel_name[MAX_NAME], f_name[MAX_NAME];
  relation_info *rel_info;
  int status;
  
  memset(rel_name, 0, MAX_NAME);
  memset(f_name, 0, MAX_NAME);
  
  printf("Enter the relation name: ");
  scanf("%s", rel_name);
  printf("File name entered: %s\n", rel_name);
  sprintf(f_name, "schemas/%s.sf", rel_name);
  printf("Accessing schema file: %s\n", f_name);

  rel_info =  get_relation_info(f_name, status);
  if (status == OK){
    print_relation_schema(rel_info);
  }
  else if (status == FILE_NOT_FOUND){
    printf("File %s was not found.\n", f_name);
  }
  else if (status == ILLEGAL_FILE_FORMAT){
    printf("File %s has an illegal format.\n", f_name);
  }
  else if (status == NO_MEMORY){
    printf("Program ran out of memory.\n");
  }
  exit(0);
}
