1lfc_perl(3)            Perl Programmers Reference Guide            lfc_perl(3)
2
3
4

NAME

6       lfc - Perl interface to the LFC
7

SYNOPSIS

9       use lfc;
10       printf "CNS_LIST_BEGIN is %d\n", $lfc::CNS_LIST_BEGIN;
11

DESCRIPTION

13       The lfc module permits you to access the LFC client interface from perl
14       programs. The lfc module is a swig wrapping of the  standard  C  inter‐
15       face.   For  detailed  descriptions of each function see the individual
16       man page of each function.
17
18       There follows a series of examples of how to use selected functions and
19       how  to retrieve the information returned by them: Examples are finding
20       the GUID of an existing entry, listing the replicas of a given GUID and
21       setting and retrieving the comment associated with an entry.
22

EXAMPLE

24       #!/usr/bin/perl -w
25       use strict;
26       use lfc;
27
28       # stat an existing entry in the LFC and print the GUID
29       my ($name,$stat,$guid,$res);
30       $name = "/grid/dteam/my.test";
31
32       $stat = lfcc::new_lfc_filestatg();
33       $res = lfc::lfc_statg($name,undef,$stat);
34
35       if ($res == 0) {
36         $guid = lfcc::lfc_filestatg_guid_get($stat);
37         print "The GUID for $name is $guid\n";
38       } else {
39         my $err_num = $lfc::serrno;
40         my $err_string = lfc::sstrerror($err_num);
41         print "There was an error while looking for $name: Error $err_num ($err_string)\n";
42         exit(1);
43       }
44       lfcc::delete_lfc_filestatg($stat);
45

EXAMPLE

47       #!/usr/bin/perl -w
48       use strict;
49       use lfc;
50
51       # list the replicas of a given entry, starting from the GUID
52       my ($guid,$listp,$flag,$num_replicas);
53       $guid = "6a3164e0-a4d7-4abe-9f76-e3b8882735d1";
54
55       $listp = lfcc::new_lfc_list();
56       $flag =  $lfc::CNS_LIST_BEGIN;
57
58       print "Listing replicas for GUID $guid:\n";
59
60       $num_replicas=0;
61
62       while(1) {
63         my $res = lfc::lfc_listreplica(undef,$guid,$flag,$listp);
64         $flag = $lfc::CNS_LIST_CONTINUE;
65
66         if (!defined $res) {
67           last;
68         } else {
69           my $rep_name = lfcc::lfc_filereplica_sfn_get($res);
70           print "Replica: $rep_name\n";
71           $num_replicas++;
72         }
73       }
74       lfc::lfc_listreplica(undef,$guid,$lfc::CNS_LIST_END,$listp);
75       lfcc::delete_lfc_list($listp);
76
77       print "Found $num_replicas replica(s)\n";
78

EXAMPLE

80       #!/usr/bin/perl -w
81       use strict;
82       use lfc;
83
84       # setting and retrieving a comment on a file
85       my ($file,$res,$bufspec,$buffer,$comment);
86       $file = "/grid/dteam/my.test";
87
88       $comment = "MyComment";
89       $res = lfc::lfc_setcomment($file,$comment);
90
91       if ($res != 0) {
92         my $err_num = $lfc::serrno;
93         my $err_string = lfc::sstrerror($err_num);
94         print "Problem while setting comment for $file: Error $err_num ($err_string)\n";
95         exit(1);
96       }
97
98       $bufspec =  "x".($lfc::CA_MAXCOMMENTLEN+1);
99       $buffer = pack($bufspec);
100       $res = lfc::lfc_getcomment($file,$buffer);
101
102       if ($res != 0) {
103         my $err_num = $lfc::serrno;
104         my $err_string = lfc::sstrerror($err_num);
105         print "Problem while reading the comment for $file: Error $err_num ($err_string)\n";
106         exit(1);
107       }
108
109       $comment = unpack("Z*", $buffer);
110       print "Read back comment $comment\n";
111

NOTES

113       The   current   interface   to  the  lfc_getcomment(3),  lfc_getcwd(3),
114       lfc_readlink(3), lfc_seterrbuf(3) requires the passing  of  a  suitably
115       allocated buffer (in a similar way to the C functions). However this is
116       rather non standard in PERL. A future version of lfc perl interface may
117       do  away  with  the  need  to  setup  the buffer before the call and to
118       explicitly unpack the result afterwards.
119

SEE ALSO

121       LFC C interface man pages
122
123
124
125LFC                      $Date: 2007/02/23 10:03:07 $              lfc_perl(3)
Impressum