# include <dvo.h>

PhotCode_Elixir *PhotCode_Internal_To_Elixir (PhotCode *in, int Nvalues) {

  int i;
  PhotCode_Elixir *out;

  ALLOCATE (out, PhotCode_Elixir, Nvalues);

  for (i = 0; i < Nvalues; i++) {
    strncpy (out[i].name, in[i].name, 31); // out[32], in[32]
    out[i].name[31] = 0; // force termination

    out[i].code = in[i].code;         
    out[i].type = in[i].type;         
    out[i].C = in[i].C;            
    out[i].dC = in[i].dC;           
    out[i].dX = in[i].dX;           
    out[i].K = in[i].K;            
    out[i].c1 = in[i].c1;           
    out[i].c2 = in[i].c2;           
    out[i].equiv = in[i].equiv;        
    out[i].Nc = in[i].Nc;           
    memcpy (out[i].X, in[i].X, 4*sizeof(float));            
  }
  return (out);
}

PhotCode *PhotCode_Elixir_To_Internal (PhotCode_Elixir *in, int Nvalues) {

  int i;
  PhotCode *out;

  ALLOCATE (out, PhotCode, Nvalues);

  for (i = 0; i < Nvalues; i++) {
    strncpy (out[i].name, in[i].name, 31); // out[32], in[32]
    out[i].name[31] = 0; // force termination

    out[i].code = in[i].code;         
    out[i].type = in[i].type;         
    out[i].C = in[i].C;            
    out[i].dC = in[i].dC;           
    out[i].dX = in[i].dX;           
    out[i].K = in[i].K;            
    out[i].c1 = in[i].c1;           
    out[i].c2 = in[i].c2;           
    out[i].equiv = in[i].equiv;        
    out[i].Nc = in[i].Nc;           
    memcpy (out[i].X, in[i].X, 4*sizeof(float));            

    // not defined in Elixir:
    out[i].astromScale = 1.0;
    out[i].photSysErr = 1.0;
  }
  return (out);
}
