Commit 1b8f4045 authored by saeed's avatar saeed
Browse files

modification on getobs

parent f24c960c
...@@ -10,7 +10,7 @@ if [ $issh -eq 1 ];then ...@@ -10,7 +10,7 @@ if [ $issh -eq 1 ];then
fi fi
if [ $iobs -eq 1 ];then if [ $iobs -eq 1 ];then
gcc -o getobs -O2 -march=native -std=c99 -Wall -D_GNU_SOURCE getobs.c gcc -o getobs -O2 -march=native -std=c99 -Wall -D_GNU_SOURCE -Dsort=1 getobs.c
fi fi
if [ $isvg -eq 1 ];then if [ $isvg -eq 1 ];then
......
...@@ -17,7 +17,7 @@ int main(int argc,char *argv[]) ...@@ -17,7 +17,7 @@ int main(int argc,char *argv[])
int portno = 80; int portno = 80;
char *host = "oceandata.smhi.se"; char *host = "oceandata.smhi.se";
//char message[] = "GET /ssh/viken/OBSERVATION?from=2017100100&too=2018032000 HTTP/1.1\r\nHost: oceandata.smhi.se\r\nConnection:close\r\n\r\n"; //char message[] = "GET /ssh/viken/OBSERVATION?from=2017100100&too=2018032000 HTTP/1.1\r\nHost: oceandata.smhi.se\r\nConnection:close\r\n\r\n";
char message[] = "GET /ssh/goteborg/OBSERVATION?from=2017010100&too=2018032800 HTTP/1.0\r\nHost: oceandata.smhi.se\r\n\r\n"; char message[] = "GET /ssh/goteborg/OBSERVATION?from=2017030100&too=2018030100 HTTP/1.0\r\nHost: oceandata.smhi.se\r\n\r\n";
int M = sizeof(message); int M = sizeof(message);
//printf("%s\n",message); //printf("%s\n",message);
//printf("%d\n",M); //printf("%d\n",M);
...@@ -146,35 +146,40 @@ int main(int argc,char *argv[]) ...@@ -146,35 +146,40 @@ int main(int argc,char *argv[])
int icom = 0, iicom = 0; int icom = 0, iicom = 0;
char **cout =split(st, ',', &icom); char **cout =split(st, ',', &icom);
char **ccout = NULL; if ( icom > 1){
int *atime = (int *)malloc(sizeof(int)*icom); char **ccout = NULL;
float *adata = (float *)malloc(sizeof(float)*icom); int *atime = (int *)malloc(sizeof(int)*icom);
float *adata = (float *)malloc(sizeof(float)*icom);
for (int i=0; i < (icom); ++i){ for (int i=0; i < (icom); ++i){
ccout = split(cout[i], ':', &iicom); ccout = split(cout[i], ':', &iicom);
rtrim(ccout[2],'}'); rtrim(ccout[2],'}');
ltrim(ccout[0],'\"'); ltrim(ccout[0],'\"');
rtrim(ccout[0],'\"'); rtrim(ccout[0],'\"');
//printf("%d\t%s\t%f\t%f\n",stoi(ccout[0]),ccout[2],atof(ccout[2]),stof(ccout[2])); //printf("%d\t%s\t%f\t%f\n",stoi(ccout[0]),ccout[2],atof(ccout[2]),stof(ccout[2]));
//printf("%d\t%f\n",stoi(ccout[0]) ,stof(ccout[2])); //printf("%d\t%f\n",stoi(ccout[0]) ,stof(ccout[2]));
atime[i] = stoi(ccout[0]); atime[i] = stoi(ccout[0]);
adata[i] = stof(ccout[2]); adata[i] = stof(ccout[2]);
free(ccout); free(ccout);
} }
free(content);
free(cout); #if sort
sortfull(atime,adata,icom); sortfull(atime,adata,icom);
#endif
for (int i=0; i < (icom); ++i){ for (int i=0; i < (icom); ++i){
printf("%d\t%f\n",atime[i] ,adata[i]); printf("%d\t%f\n",atime[i] ,adata[i]);
} }
free(atime); free(atime);
free(adata); free(adata);
}
//printf("%s",content); //printf("%s",content);
free(content);
free(cout);
/* process response */ /* process response */
//printf("Response:\n%s\n",response); //printf("Response:\n%s\n",response);
......
Supports Markdown
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