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

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2005 by CERN
00003  */
00004 
00005 /*
00006  * @(#)$RCSfile: gfal_testget.c,v $ $Revision: 1.1.1.1 $ $Date: 2006/09/06 08:54:53 $ CERN Jean-Philippe Baud
00007  */
00008 
00009 #include <stdio.h>
00010 #include <stdlib.h>
00011 #include <sys/types.h>
00012 #include "gfal_api.h"
00013 #define DEFPOLLINT 10
00014 
00015 main(argc, argv)
00016 int argc;
00017 char **argv;
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:47 2006 for GFAL by  doxygen 1.4.6