File: dli_testlistReplicas.c

package info (click to toggle)
dpm-postgres 1.7.4.7-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 13,788 kB
  • ctags: 10,782
  • sloc: ansic: 146,136; sh: 13,362; perl: 11,142; python: 5,529; cpp: 5,113; sql: 1,790; makefile: 955; fortran: 113
file content (79 lines) | stat: -rw-r--r-- 1,624 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <getopt.h>
#include <string.h>
#include "dliH.h"
#include "DataLocationInterface.nsmap"

int errflg;
int helpflg;
int verbose;

main(int argc, char **argv)
{
	int c;
	char *data_type;
	const char *endpoint;
	int i;
	static struct option longopts[] = {
		{"endpoint", required_argument, 0, 'e'},
		{"help", no_argument, &helpflg, 1},
		{"verbose", no_argument, &verbose, 1},
		{0, 0, 0, 0}
	};
	struct ns1__listReplicasResponse out;
	char *src_file;
	struct soap soap;
	int verbose = 0;

	opterr = 0;
	while((c = getopt_long(argc, argv, "hv", longopts, NULL)) != EOF) {
	  switch(c) {
	  case 'e':
	    endpoint = optarg;
	    break;
	  case 'h':
	    helpflg = 1;
	    break;
	  case 'v':
	    verbose = 1;
	    break;
	  case '?':
	    errflg++;
	    break;
	  default:
	    break;
	  }
	}
	if(optind >= argc)
	  errflg++;
	if(errflg | helpflg) {
	  fprintf (stderr, "usage: %s %s%s", argv[0],
		   "[-v | --verbose] [-h | --help]",
		   "[-e | --endpoint endpoint] logical_file\n");
	  exit (errflg ? 1 : 0);
	}
	src_file = argv[optind];
	if (strncmp (src_file, "guid:", 5) == 0)
		data_type = "guid";
	else if (strncmp (src_file, "lfn:", 4) == 0)
		data_type = "lfn";
	else {
		fprintf (stderr, "Bad URL syntax\n");
		exit (1);
	}

	if(verbose)
	  printf("Contacting endpoint : %s\n", endpoint);

	soap_init (&soap);
	if (soap_call_ns1__listReplicas (&soap, endpoint, "listReplicas",
	    data_type, src_file, &out)) {
		soap_print_fault (&soap, stderr);
		soap_end (&soap);
		exit (1);
	}

	for (i = 0; i < out.urlList->__size; i++)
		printf ("%s\n", out.urlList->__ptritem[i]);
	soap_end (&soap);
	exit (0);
}