source: branches/prototype-v0/zoo-project/zoo-kernel/sshapi.c @ 851

Last change on this file since 851 was 851, checked in by djay, 7 years ago

Invoke callback asynchronously. Still the ZOO-Kernel has still to wait for every requests to finish before stoping its execution.

  • Property svn:keywords set to Id
File size: 19.1 KB
Line 
1/*
2 *
3 * Author : Gérald FENOY
4 *
5 * Copyright 2017 GeoLabs SARL. All rights reserved.
6 *
7 * This work was supported by public funds received in the framework of GEOSUD,
8 * a project (ANR-10-EQPX-20) of the program "Investissements d'Avenir" managed
9 * by the French National Research Agency
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this software and associated documentation files (the "Software"), to deal
13 * in the Software without restriction, including without limitation the rights
14 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 * copies of the Software, and to permit persons to whom the Software is
16 * furnished to do so, subject to the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 * THE SOFTWARE.
28 */
29
30#include "sshapi.h"
31
32SSHCON *sessions[MAX_PARALLEL_SSH_CON];
33
34/**
35 * Wait until one or more file descriptor has been changed for the socket for a
36 * time defined by timeout
37 * @param socket_fd int defining the sockket file descriptor
38 * @param session an exeisting LIBSSH2_SESSION
39 */ 
40int waitsocket(int socket_fd, LIBSSH2_SESSION *session)
41{
42    struct timeval timeout;
43    int rc;
44    fd_set fd;
45    fd_set *writefd = NULL;
46    fd_set *readfd = NULL;
47    int dir;
48 
49    timeout.tv_sec = 10;
50    timeout.tv_usec = 0;
51 
52    FD_ZERO(&fd);
53 
54    FD_SET(socket_fd, &fd);
55 
56    /* now make sure we wait in the correct direction */ 
57    dir = libssh2_session_block_directions(session);
58
59 
60    if(dir & LIBSSH2_SESSION_BLOCK_INBOUND)
61        readfd = &fd;
62 
63    if(dir & LIBSSH2_SESSION_BLOCK_OUTBOUND)
64        writefd = &fd;
65 
66    rc = select(socket_fd + 1, readfd, writefd, NULL, &timeout);
67 
68    return rc;
69}
70
71/**
72 * Connect to a remote host using SSH protocol
73 * @param conf maps The main configuration maps
74 * @return the libssh2 sessions pointer or NULL in case any failure occured.
75 */
76SSHCON *ssh_connect(maps* conf){
77  unsigned long hostaddr;
78  int i, use_pw = 1;
79  struct sockaddr_in sin;
80  const char *fingerprint;
81  SSHCON *result=(SSHCON*)malloc((2*sizeof(int))+sizeof(LIBSSH2_SESSION*)+sizeof(LIBSSH2_SFTP*));
82  result->sock_id=NULL;
83  result->index=NULL;
84  result->session=NULL;
85  result->sftp_session=NULL;
86  const char *user;
87  const char *password=NULL;
88  const char *public_key;
89  char *private_key;
90  int rc;
91  FILE *local;
92  char mem[1024 * 1000];
93  char error[1024];
94  int port=22;
95
96  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
97  fflush(stderr);
98
99  map* hpc_host=getMapFromMaps(conf,"HPC","host");
100  map* hpc_port=getMapFromMaps(conf,"HPC","port");
101  map* hpc_user=getMapFromMaps(conf,"HPC","user");
102  map* hpc_password=getMapFromMaps(conf,"HPC","password");
103  map* hpc_public_key=getMapFromMaps(conf,"HPC","key");
104
105  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
106  fflush(stderr);
107
108#ifdef WIN32
109  WSADATA wsadata;
110  int err;
111  err = WSAStartup(MAKEWORD(2,0), &wsadata);
112  if (err != 0) {
113    sprintf(error, "WSAStartup failed with error: %d\n", err);
114    setMapInMaps(conf,"lenv","message",error);
115    return NULL;
116  }
117#endif
118
119  // TODO: fetch ip address for the hostname
120  if (hpc_host != NULL) {
121    hostaddr = inet_addr(hpc_host->value);
122  } else {
123    setMapInMaps(conf,"lenv","message","No host parameter found in your main.cfg file!\n");
124    return NULL;
125  }
126
127  // Default port is 22
128  if(hpc_port!=NULL){
129    port=atoi(hpc_port->value);
130  }
131
132  // In case there is no HPC > user the it must failed
133  if (hpc_user != NULL) {
134    user = hpc_user->value;
135  }else{
136    setMapInMaps(conf,"lenv","message","No user parameter found in your main.cfg file!");
137    return NULL;
138  }
139
140  // TODO: in case password is available but there is also the public key
141  // defined, then we can consider this password as the pass phrase.
142  if (hpc_password != NULL) {
143    password = hpc_password->value;
144  }else{
145    use_pw=-1;
146    if (hpc_public_key != NULL) {
147      public_key = hpc_public_key->value;
148      private_key = strdup(hpc_public_key->value);
149      private_key[strlen(public_key)-4]=0;
150    }else{
151      setMapInMaps(conf,"lenv","message","No method found to authenticate!");
152      return NULL;
153    }
154  }
155
156  rc = libssh2_init (0);
157  if (rc != 0) {
158    sprintf (error, "libssh2 initialization failed (%d)\n", rc);
159    setMapInMaps(conf,"lenv","message",error);
160    return NULL;
161  }
162
163  result->sock_id = socket(AF_INET, SOCK_STREAM, 0);
164  sin.sin_family = AF_INET;
165  sin.sin_port = htons(port);
166  sin.sin_addr.s_addr = hostaddr;
167  if (connect(result->sock_id, (struct sockaddr*)(&sin),sizeof(struct sockaddr_in)) != 0) {
168    setMapInMaps(conf,"lenv","message","Failed to connect to remote host!");
169    return NULL;
170  }
171
172  result->session = libssh2_session_init();
173  result->sftp_session = NULL;
174  map* tmp=getMapFromMaps(conf,"lenv","nb_sessions");
175  if(tmp!=NULL){
176    char nb_sessions[10];
177    int nb_sess=atoi(tmp->value);
178    sprintf(nb_sessions,"%d",nb_sess+1);
179    setMapInMaps(conf,"lenv","nb_sessions",nb_sessions);
180    result->index=nb_sess+1;
181    sessions[nb_sess+1]=result;
182  }else{
183    setMapInMaps(conf,"lenv","nb_sessions","0");
184    sessions[0]=result;
185    result->index=0;
186  }
187
188  if (!result->session)
189    return NULL;
190
191  libssh2_session_set_blocking(result->session, 0);
192
193  while ((rc = libssh2_session_handshake(result->session, result->sock_id))
194         == LIBSSH2_ERROR_EAGAIN);
195
196  if (rc) {
197    sprintf(error, "Failure establishing SSH session: %d\n", rc);
198    setMapInMaps(conf,"lenv","message",error);
199    return NULL;
200  }
201
202  fingerprint = libssh2_hostkey_hash(result->session, LIBSSH2_HOSTKEY_HASH_SHA1);
203 
204  if (use_pw>0) {
205    while ((rc = libssh2_userauth_password(result->session, user, password)) ==
206           LIBSSH2_ERROR_EAGAIN);
207    if (rc) {
208      setMapInMaps(conf,"lenv","message","Authentication by password failed.");
209      ssh_close(conf);
210      return NULL;
211    }
212  } else {
213    while ((rc = libssh2_userauth_publickey_fromfile(result->session, user,
214                                                     public_key,
215                                                     private_key,
216                                                     password)) ==
217           LIBSSH2_ERROR_EAGAIN);
218    if (rc) {
219      setMapInMaps(conf,"lenv","message","Authentication by public key failed");
220      ssh_close(conf);
221      return NULL;
222    }
223    free(private_key);
224  }
225
226  return result;
227
228}
229
230/**
231 * Get the number of opened SSH connections
232 * @param conf maps pointer to the main configuration maps
233 * @return the number of opened SSH connections
234 */
235int ssh_get_cnt(maps* conf){
236  int result=0;
237  map* myMap=getMapFromMaps(conf,"lenv","cnt_session");
238  if(myMap!=NULL){
239    result=atoi(myMap->value);
240  }
241  return result;
242}
243
244/**
245 * Verify if a file exists on the remote host
246 * @param conf maps pointer to the main configuration maps
247 * @param targetPath const char* defining the path for storing the file on the
248 * remote host
249 * @return true in case of success, false if failure occured
250 */
251size_t ssh_file_exists(maps* conf,const char* targetPath,int cnt){
252  size_t result=-1;
253  if(cnt>0)
254    cnt-=1;
255  int rc;
256  LIBSSH2_SFTP_ATTRIBUTES attrs;
257  LIBSSH2_SFTP_HANDLE *sftp_handle;
258  do{
259    sftp_handle =
260      libssh2_sftp_open(sessions[cnt]->sftp_session, targetPath, LIBSSH2_FXF_READ,
261                        LIBSSH2_SFTP_S_IRUSR|LIBSSH2_SFTP_S_IWUSR|
262                        LIBSSH2_SFTP_S_IRGRP|LIBSSH2_SFTP_S_IROTH);
263    if (!sftp_handle) {
264      fprintf(stderr, "Unable to open file with SFTP: %d %ld\n",__LINE__,
265              libssh2_sftp_last_error(sessions[cnt]->sftp_session));
266      return 0;
267    }
268  }while(!sftp_handle);
269  fprintf(stderr, "libssh2_sftp_open() is done, get file information\n");
270  do {
271  rc = libssh2_sftp_stat_ex(sessions[cnt]->sftp_session, targetPath, strlen(targetPath),
272                            LIBSSH2_SFTP_LSTAT, &attrs );
273  if (rc<0 &&
274      (libssh2_session_last_errno(sessions[cnt]->session) != LIBSSH2_ERROR_EAGAIN))
275    {
276      fprintf(stderr, "error trying to fstat_ex, returned %d\n", rc);
277      break;
278    }
279  else
280    {
281      fprintf(stderr, "Stat Data: RetCode=%d\n", rc);
282      fprintf(stderr, "Stat Data: Size=%llu\n", attrs.filesize);
283      fprintf(stderr, "Stat Data: Perm=%lx\n",  attrs.permissions);
284      fprintf(stderr, "Stat Data: mtime=%lu\n",  attrs.mtime);
285      if(rc==0)
286        break;
287      result=attrs.filesize;
288    }
289  } while (true);
290  libssh2_sftp_close(sftp_handle);
291  //libssh2_sftp_shutdown(sessions[cnt]->sftp_session);
292
293  return result;
294}
295
296/**
297 * Upload a file over an opened SSH connection
298 * @param conf maps pointer to the main configuration maps
299 * @param localPath const char* defining the local path for accessing the file
300 * @param targetPath const char* defining the path for storing the file on the
301 * remote host
302 * @return true in case of success, false if failure occured
303 */
304bool ssh_copy(maps* conf,const char* localPath,const char* targetPath,int cnt){
305  char mem[1024 * 1000];
306  size_t nread;
307  size_t memuse=0;
308  time_t start;
309  long total = 0;
310  int duration;
311  int rc;
312  LIBSSH2_SFTP_HANDLE *sftp_handle;
313  //map* myMap=getMapFromMaps(conf,"lenv","cnt_session");
314  if(getMapFromMaps(conf,"lenv","cnt_session")!=NULL){
315    char tmp[10];
316    sprintf(tmp,"%d",cnt+1);
317    setMapInMaps(conf,"lenv","cnt_session",tmp);
318  }else
319    setMapInMaps(conf,"lenv","cnt_session","0");
320  FILE *local = fopen(localPath, "rb");
321  if (!local) {
322    fprintf(stderr, "Can't open local file %s\n", localPath);
323    return false;
324  }
325
326  do {
327    sessions[cnt]->sftp_session = libssh2_sftp_init(sessions[cnt]->session);
328    if (!sessions[cnt]->sftp_session &&
329        (libssh2_session_last_errno(sessions[cnt]->session) != LIBSSH2_ERROR_EAGAIN)) {
330     
331      fprintf(stderr, "Unable to init SFTP session\n");
332      return false;
333    }
334  } while (!sessions[cnt]->sftp_session);
335
336  do {
337    sftp_handle =
338      libssh2_sftp_open(sessions[cnt]->sftp_session, targetPath,
339                        LIBSSH2_FXF_WRITE|LIBSSH2_FXF_CREAT|LIBSSH2_FXF_TRUNC,
340                        LIBSSH2_SFTP_S_IRUSR|LIBSSH2_SFTP_S_IWUSR|
341                        LIBSSH2_SFTP_S_IRGRP|LIBSSH2_SFTP_S_IROTH);
342
343    if (!sftp_handle &&
344        (libssh2_session_last_errno(sessions[cnt]->session) != LIBSSH2_ERROR_EAGAIN)) {
345     
346      fprintf(stderr, "Unable to open file with SFTP\n");
347      return false;
348    }
349  } while (!sftp_handle);
350  start = time(NULL);
351 
352  do {
353    nread = fread(&mem[memuse], 1, sizeof(mem)-memuse, local);
354    if (nread <= 0) {
355      if (memuse > 0)
356        nread = 0;
357      else
358        break;
359    }
360    memuse += nread;
361    total += nread;
362   
363    while ((rc = libssh2_sftp_write(sftp_handle, mem, memuse)) ==
364           LIBSSH2_ERROR_EAGAIN) {
365      waitsocket(sessions[cnt]->sock_id, sessions[cnt]->session);
366    }
367    if(rc < 0)
368      break;
369   
370    if(memuse - rc) {
371      memmove(&mem[0], &mem[rc], memuse - rc);
372      memuse -= rc;
373    }
374    else
375      memuse = 0;
376   
377  } while (rc > 0);
378 
379  duration = (int)(time(NULL)-start);
380  fclose(local);
381  libssh2_sftp_close_handle(sftp_handle);
382
383  libssh2_sftp_shutdown(sessions[cnt]->sftp_session);
384  return true;
385}
386
387/**
388 * Download a file over an opened SSH connection
389 * @param conf maps pointer to the main configuration maps
390 * @param localPath const char* defining the local path for storing the file
391 * @param targetPath const char* defining the path for accessing the file on the
392 * remote host
393 * @return true in case of success, false if failure occured
394 */
395int ssh_fetch(maps* conf,const char* localPath,const char* targetPath,int cnt){
396  char mem[1024];
397  size_t nread;
398  size_t memuse=0;
399  time_t start;
400  long total = 0;
401  int duration;
402  int rc;
403  LIBSSH2_SFTP_HANDLE *sftp_handle;
404  FILE *local = fopen(localPath, "wb");
405  if (!local) {
406    fprintf(stderr, "Can't open local file %s\n", localPath);
407    return -1;
408  }
409
410  do {
411    sessions[cnt]->sftp_session = libssh2_sftp_init(sessions[cnt]->session);
412    if (!sessions[cnt]->sftp_session &&
413        (libssh2_session_last_errno(sessions[cnt]->session) != LIBSSH2_ERROR_EAGAIN)) {
414     
415      fprintf(stderr, "Unable to init SFTP session\n");
416      return false;
417    }
418  } while (!sessions[cnt]->sftp_session);
419    do {
420        sftp_handle = libssh2_sftp_open(sessions[cnt]->sftp_session, targetPath,
421
422                                        LIBSSH2_FXF_READ, 0);
423 
424        if (!sftp_handle) {
425            if (libssh2_session_last_errno(sessions[cnt]->session) != LIBSSH2_ERROR_EAGAIN) {
426                fprintf(stderr, "Unable to open file with SFTP\n");
427                return -1;
428            }
429            else {
430                fprintf(stderr, "non-blocking open\n");
431                waitsocket(sessions[cnt]->sock_id, sessions[cnt]->session); 
432            }
433        }
434    } while (!sftp_handle);
435 
436    int result=1;
437    do {
438        do {
439            rc = libssh2_sftp_read(sftp_handle, mem, sizeof(mem));
440            /*fprintf(stderr, "libssh2_sftp_read returned %d\n",
441              rc);*/
442            if(rc > 0) {
443              //write(2, mem, rc);
444                fwrite(mem, rc, 1, local);
445            }
446        } while (rc > 0);
447 
448        if(rc != LIBSSH2_ERROR_EAGAIN) {
449          result=-1;
450          break;
451        }
452
453        struct timeval timeout;
454        fd_set fd;
455        timeout.tv_sec = 10;
456        timeout.tv_usec = 0;
457 
458        FD_ZERO(&fd);
459 
460        FD_SET(sessions[cnt]->sock_id, &fd);
461 
462        rc = select(sessions[cnt]->sock_id+1, &fd, &fd, NULL, &timeout);
463        if(rc <= 0) {
464          if(rc==0)
465            fprintf(stderr, "SFTP download timed out: %d\n", rc);
466          else
467            fprintf(stderr, "SFTP download error: %d\n", rc);
468          result=-1;
469          break;
470        }
471 
472    } while (1);
473  duration = (int)(time(NULL)-start);
474  fclose(local);
475  libssh2_sftp_close_handle(sftp_handle);
476
477  libssh2_sftp_shutdown(sessions[cnt]->sftp_session);
478  return 0;
479}
480
481/**
482 * Execute a command over an opened SSH connection
483 * @param conf maps pointer to the main configuration maps
484 * @param command const char pointer to the command to be executed
485 * @return bytecount resulting from the execution of the command
486 */
487int ssh_exec(maps* conf,const char* command,int cnt){
488  LIBSSH2_CHANNEL *channel;
489  int rc;
490  int bytecount = 0;
491  int exitcode;
492  char *exitsignal=(char *)"none";
493  while( (channel = libssh2_channel_open_session(sessions[cnt]->session)) == NULL &&
494         libssh2_session_last_error(sessions[cnt]->session,NULL,NULL,0) == LIBSSH2_ERROR_EAGAIN ) {
495      waitsocket(sessions[cnt]->sock_id, sessions[cnt]->session);
496  }
497  if( channel == NULL ){
498    fprintf(stderr,"Error\n");
499    return 1;
500  }
501  while( (rc = libssh2_channel_exec(channel, command)) == LIBSSH2_ERROR_EAGAIN ) {
502    waitsocket(sessions[cnt]->sock_id, sessions[cnt]->session);
503  }
504  if( rc != 0 ) {
505    fprintf(stderr,"Error\n");
506    return -1;
507  }
508
509  map* tmpPath=getMapFromMaps(conf,"main","tmpPath");
510  map* uuid=getMapFromMaps(conf,"lenv","usid");
511  char *logPath=(char*)malloc((strlen(tmpPath->value)+strlen(uuid->value)+11)*sizeof(char));
512  sprintf(logPath,"%s/exec_out_%s",tmpPath->value,uuid->value);
513  FILE* logFile=fopen(logPath,"wb");
514  free(logPath);
515  while(true){
516    int rc;
517    do {
518      char buffer[0x4000];
519      rc = libssh2_channel_read( channel, buffer, sizeof(buffer) );
520     
521      if( rc > 0 ){
522        int i;
523        bytecount += rc;
524        buffer[rc]=0;
525        fprintf(logFile,"%s",buffer);
526        fflush(logFile);
527      }
528    }
529    while( rc > 0 );
530   
531    if( rc == LIBSSH2_ERROR_EAGAIN ) {
532      waitsocket(sessions[cnt]->sock_id, sessions[cnt]->session);
533    }
534    else
535      break;
536  }
537  fclose(logFile);
538  exitcode = 127;
539  while( (rc = libssh2_channel_close(channel)) == LIBSSH2_ERROR_EAGAIN )
540    waitsocket(sessions[cnt]->sock_id, sessions[cnt]->session);
541 
542  if( rc == 0 ) {
543    exitcode = libssh2_channel_get_exit_status( channel );
544    libssh2_channel_get_exit_signal(channel, &exitsignal,
545                                    NULL, NULL, NULL, NULL, NULL);
546  }
547 
548  if (exitsignal)
549    fprintf(stderr, "\nGot signal: %s\n", exitsignal);
550  else
551    fprintf(stderr, "\nEXIT: %d bytecount: %d\n", exitcode, bytecount);
552 
553  libssh2_channel_free(channel);
554
555  return bytecount;
556}
557
558/**
559 * Close an opened SSH connection
560 * @param conf maps pointer to the main configuration maps
561 * @param con SSHCON pointer to the SSH connection
562 * @return true in case of success, false if failure occured
563 */
564bool ssh_close_session(maps* conf,SSHCON* con){
565  while (libssh2_session_disconnect(con->session, "Normal Shutdown, Thank you for using the ZOO-Project sshapi")
566         == LIBSSH2_ERROR_EAGAIN);
567#ifdef WIN32
568  closesocket(con->sock_id);
569#else
570  close(con->sock_id);
571#endif
572  libssh2_session_free(con->session);
573  return true;
574}
575
576/**
577 * Close all the opened SSH connections
578 * @param conf maps pointer to the main configuration maps
579 * @return true in case of success, false if failure occured
580 */
581bool ssh_close(maps* conf){
582  int i,nb_sessions;
583  map* tmp=getMapFromMaps(conf,"lenv","nb_sessions");
584  if(tmp!=NULL){
585    nb_sessions=atoi(tmp->value);
586    for(i=0;i<nb_sessions;i++)
587      ssh_close_session(conf,sessions[i]);
588  }
589  libssh2_exit();
590  return true;
591}
592
593bool addToUploadQueue(maps** conf,maps* input){
594  map* queueMap=getMapFromMaps(*conf,"uploadQueue","length");
595  if(queueMap==NULL){
596    maps* queueMaps=createMaps("uploadQueue");
597    queueMaps->content=createMap("length","0");
598    addMapsToMaps(conf,queueMaps);
599    freeMaps(&queueMaps);
600    free(queueMaps);
601    queueMap=getMapFromMaps(*conf,"uploadQueue","length");
602  }
603  maps* queueMaps=getMaps(*conf,"uploadQueue");
604  int queueIndex=atoi(queueMap->value);
605  if(input!=NULL){
606    if(getMap(input->content,"cache_file")!=NULL){
607      map* length=getMap(input->content,"length");
608      if(length==NULL){
609        addToMap(input->content,"length","1");
610        length=getMap(input->content,"length");
611      }
612      int len=atoi(length->value);
613      int i=0;
614      for(i=0;i<len;i++){
615       
616        map* tmp[2]={getMapArray(input->content,"localPath",i),
617                     getMapArray(input->content,"targetPath",i)};
618
619        setMapArray(queueMaps->content,"input",queueIndex,input->name);
620        setMapArray(queueMaps->content,"localPath",queueIndex,tmp[0]->value);
621        setMapArray(queueMaps->content,"targetPath",queueIndex,tmp[1]->value);
622        queueIndex+=1;
623      }
624    }
625  }
626#ifdef DEBUG 
627  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
628  fflush(stderr);
629  dumpMaps(queueMaps);
630  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
631  fflush(stderr);
632  dumpMaps(*conf);
633  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
634  fflush(stderr);
635#endif
636  return true;
637}
638
639bool runUpload(maps** conf){
640  SSHCON *test=ssh_connect(*conf);
641  if(test==NULL){
642    return false;
643  }
644#ifdef DEBUG
645  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
646  fflush(stderr);
647  dumpMaps(getMaps(*conf,"uploadQueue"));
648  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
649  fflush(stderr);
650#endif
651  map* queueLengthMap=getMapFromMaps(*conf,"uploadQueue","length");
652  maps* queueMaps=getMaps(*conf,"uploadQueue");
653  if(queueLengthMap!=NULL){
654    int cnt=atoi(queueLengthMap->value);
655    int i=0;
656    for(i=0;i<cnt;i++){
657      map* argv[3]={
658        getMapArray(queueMaps->content,"input",i),
659        getMapArray(queueMaps->content,"localPath",i),
660        getMapArray(queueMaps->content,"targetPath",i)
661      };
662      fprintf(stderr,"%s %d %s %s\n",__FILE__,__LINE__,argv[1]->value,argv[2]->value);
663      ssh_copy(*conf,argv[1]->value,argv[2]->value,ssh_get_cnt(*conf));
664    }   
665  }
666  return true; 
667}
Note: See TracBrowser for help on using the repository browser.

Search

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png