/Home/aooliver/work/stagersvc/org.glite.data.lcg_gfal/src/gfal_testget.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include "gfal_api.h"

Go to the source code of this file.

Defines

#define DEFPOLLINT   10

Functions

 main (int argc, char **argv)


Define Documentation

#define DEFPOLLINT   10
 

Definition at line 13 of file gfal_testget.c.

Referenced by main().


Function Documentation

main int  argc,
char **  argv
 

Definition at line 15 of file gfal_testget.c.

References DEFPOLLINT, srm_get(), srm_getstatus(), srm_filestatus::status, srm_filestatus::surl, and srm_filestatus::turl.

00018 {
00019         struct srm_filestatus *filestatuses;
00020         int i;
00021         int nbfiles;
00022         int nbprotocols;
00023         int nbreplies;
00024         static char *protocols[] = {"rfio"};
00025         int r = 0;
00026         int reqid;
00027         char **surls;
00028 
00029         if (argc < 2) {
00030                 fprintf (stderr, "usage: %s SURLs\n", argv[0]);
00031                 exit (1);
00032         }
00033         nbfiles = argc - 1;
00034         surls = &argv[1];
00035 
00036         nbprotocols = sizeof(protocols) / sizeof(char *);
00037 
00038         if ((nbreplies = srm_get (nbfiles, surls, nbprotocols, protocols,
00039             &reqid, NULL, &filestatuses, 0)) < 0) {
00040                 perror ("srm_get");
00041                 exit (1);
00042         }
00043 
00044         /* process files as soon as they are "ready" */
00045 
00046         while (1) {
00047                 for (i = 0; i < nbreplies; i++) {
00048                         if ((filestatuses+i)->status == 1) {    /* file ready */
00049                                 /* process it if not yet done */
00050                         }
00051                         if ((filestatuses+i)->surl)
00052                                 free ((filestatuses+i)->surl);
00053                         if ((filestatuses+i)->turl)
00054                                 free ((filestatuses+i)->turl);
00055                 }
00056                 free (filestatuses);
00057 
00058                 /* if processing complete, break */ if (r) break;
00059 
00060                 sleep ((r++ == 0) ? 1 : DEFPOLLINT);
00061                 if ((nbreplies = srm_getstatus (nbfiles, surls, reqid, NULL,
00062                     &filestatuses, 0)) < 0) {
00063                         perror ("srm_getstatus");
00064                         exit (1);
00065                 }
00066         }
00067         exit (0);
00068 }


Generated on Fri Sep 8 20:20:48 2006 for GFAL by  doxygen 1.4.6