Commit fea3947f authored by Ruben Garcia Hernndez's avatar Ruben Garcia Hernndez

Add support for wget (https, etc) in CAVE

parent 7aed483c
......@@ -325,7 +325,7 @@ r=sscanf (f, "http://%2047[^/:]:%d%2047[^\n]", host, &port, page);
if (r==1)
r=sscanf (f, "http://%2047[^/]%2047[^\n]", host, page);
if (r<2) {
#if defined(WIN32)
#if defined(WIN32) || defined(CAVE)
//possibly https or other unsupported protocol, fall back to wget
return readAtomsJsonURLwget (f, numatoms, timesteps, pos, abc, clonedAtoms, token);
#else
......@@ -387,23 +387,20 @@ while( conn.outstanding() )
#endif
fclose(out);
#if defined(WIN32)
#if defined(WIN32) || defined(CAVE)
return readAtomsJsonURLwget (f, numatoms, timesteps, pos, abc, clonedAtoms, token);
#endif
return -3;
}
fclose(out);
//sprintf (cmd, "wget %s/cells -O material_cells.json", f);
//system(cmd);
//sprintf (cmd, "wget %s/elements -O material_elements.json", f);
//system(cmd);
char file [2048];
sprintf (file, "%s%s", TMPDIR, "material");
//eprintf ("readAtomsJsonURL before return");
return readAtomsJson (file, numatoms, timesteps, pos, abc, clonedAtoms, token);
}
#if defined(WIN32)
#if defined(WIN32) || defined(CAVE)
//base64 encoded token
int readAtomsJsonURLwget (const char *const f, int **numatoms, int *timesteps, float ***pos, float abc[3][3],
std::vector<float>** clonedAtoms, const char *const token)
......@@ -411,20 +408,21 @@ int readAtomsJsonURLwget (const char *const f, int **numatoms, int *timesteps, f
char cmd[2048];
int ret;
if (token)
sprintf (cmd, "wget --header \"Authorization:Basic %s\" %s/cells?pagination=off -O material_cells.json", token, f);
sprintf (cmd, "wget --no-check-certificate --header \"Authorization:Basic %s\" %s/cells?pagination=off -O %s/material_cells.json", token, f, TMPDIR);
else
sprintf (cmd, "wget %s/cells?pagination=off -O material_cells.json", f);
sprintf (cmd, "wget %s/cells?pagination=off -O %s/material_cells.json", f, TMPDIR);
ret=system(cmd);
if (ret!=0)
return (-3);
if (token)
sprintf (cmd, "wget --header \"Authorization:Basic %s\" %s/elements?pagination=off -O material_elements.json", token, f);
sprintf (cmd, "wget --no-check-certificate --header \"Authorization:Basic %s\" %s/elements?pagination=off -O %s/material_elements.json", token, f, TMPDIR);
else
sprintf (cmd, "wget %s/elements?pagination=off -O material_elements.json", f);
sprintf (cmd, "wget %s/elements?pagination=off -O %s/material_elements.json", f, TMPDIR);
ret=system(cmd);
if (ret!=0)
return(-3);
return readAtomsJson ("material", numatoms, timesteps, pos, abc, clonedAtoms, token);
sprintf (cmd, "%s/material", TMPDIR);
return readAtomsJson (cmd, numatoms, timesteps, pos, abc, clonedAtoms, token);
}
#endif
......
......@@ -17,7 +17,7 @@ int readAtomsXYZ(const char *const file, int **numatoms, int *timesteps, float *
int readAtomsCube(const char *const file, int **numatoms, int *timesteps, float ***pos);
int readAtomsJson (const char *const file, int **numatoms, int *timesteps, float ***pos, float abc[3][3], std::vector<float>** clonedAtoms, const char *const token=0);
int readAtomsJsonURL (const char *const f, int **numatoms, int *timesteps, float ***pos, float abc[3][3], std::vector<float>** clonedAtoms, const char *const token=0);
#if defined(WIN32)
#if defined(WIN32) || defined(CAVE)
int readAtomsJsonURLwget (const char *const f, int **numatoms, int *timesteps, float ***pos, float abc[3][3], std::vector<float>** clonedAtoms, const char *const token=0);
#endif
const float MISSINGRADIUS=0.2f;
......@@ -34,4 +34,4 @@ void discardline (FILE *F);
void Clone (float tmppos[3], float k, std::vector<float>* clonedAtoms);
void TransformAtoms(std::vector<float>* clonedAtoms, const float abc[3][3]);
#endif //__ATOMS_H
\ No newline at end of file
#endif //__ATOMS_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment