1lfc_perl(3)               Perl    Programmers   Reference   Guide
2lfc_perl(3)
3
4
5
6[1mNAME[0m
7       lfc ‐ Perl interface to the LFC
8
9[1mSYNOPSIS[0m
10       [1muse lfc;[0m
11       [1mprintf "CNS_LIST_BEGIN is %d0, $lfc::CNS_LIST_BEGIN;[0m
12
13[1mDESCRIPTION[0m
14       The lfc module permits you to access the LFC client inter‐
15face from perl
16       programs.  The lfc module is a swig wrapping of the  stan‐
17dard  C  inter‐
18       face.   For  detailed  descriptions of each  function  see
19the individual
20       man page of each function.
21
22       There  follows a series of examples of how to use selected
23functions and
24       how  to retrieve the information returned by  them:  Exam‐
25ples are finding
26       the  GUID  of an existing entry, listing the replicas of a
27given GUID and
28       setting and retrieving the comment associated with an  en‐
29try.
30
31[1mEXAMPLE[0m
32       #!/usr/bin/perl ‐w
33       use strict;
34       use lfc;
35
36       # stat an existing entry in the LFC and print the GUID
37       my ($name,$stat,$guid,$res);
38       $name = "/grid/dteam/my.test";
39
40       $stat = lfcc::new_lfc_filestatg();
41       $res = lfc::lfc_statg($name,undef,$stat);
42
43       if ($res == 0) {
44         $guid = lfcc::lfc_filestatg_guid_get($stat);
45         print "The GUID for $name is $guid0;
46       } else {
47         my $err_num = $lfc::serrno;
48         my $err_string = lfc::sstrerror($err_num);
49         print "There was an error while looking for $name: Error
50$err_num ($err_string)0;
51         exit(1);
52       }
53       lfcc::delete_lfc_filestatg($stat);
54
55[1mEXAMPLE[0m
56       #!/usr/bin/perl ‐w
57       use strict;
58       use lfc;
59
60       # list the replicas of a given entry,  starting  from  the
61GUID
62       my ($guid,$listp,$flag,$num_replicas);
63       $guid = "6a3164e0‐a4d7‐4abe‐9f76‐e3b8882735d1";
64
65       $listp = lfcc::new_lfc_list();
66       $flag =  $lfc::CNS_LIST_BEGIN;
67
68       print "Listing replicas for GUID $guid:0;
69
70       $num_replicas=0;
71
72       while(1) {
73         my         $res        =        lfc::lfc_listreplica(un‐
74def,$guid,$flag,$listp);
75         $flag = $lfc::CNS_LIST_CONTINUE;
76
77         if (!defined $res) {
78           last;
79         } else {
80           my $rep_name = lfcc::lfc_filereplica_sfn_get($res);
81           print "Replica: $rep_name0;
82           $num_replicas++;
83         }
84       }
85       lfc::lfc_listreplica(un‐
86def,$guid,$lfc::CNS_LIST_END,$listp);
87       lfcc::delete_lfc_list($listp);
88
89       print "Found $num_replicas replica(s)0;
90
91[1mEXAMPLE[0m
92       #!/usr/bin/perl ‐w
93       use strict;
94       use lfc;
95
96       # setting and retrieving a comment on a file
97       my ($file,$res,$bufspec,$buffer,$comment);
98       $file = "/grid/dteam/my.test";
99
100       $comment = "MyComment";
101       $res = lfc::lfc_setcomment($file,$comment);
102
103       if ($res != 0) {
104         my $err_num = $lfc::serrno;
105         my $err_string = lfc::sstrerror($err_num);
106         print  "Problem  while  setting comment for $file: Error
107$err_num ($err_string)0;
108         exit(1);
109       }
110
111       $bufspec =  "x".($lfc::CA_MAXCOMMENTLEN+1);
112       $buffer = pack($bufspec);
113       $res = lfc::lfc_getcomment($file,$buffer);
114
115       if ($res != 0) {
116         my $err_num = $lfc::serrno;
117         my $err_string = lfc::sstrerror($err_num);
118         print "Problem while reading the comment for $file:  Er‐
119ror $err_num ($err_string)0;
120         exit(1);
121       }
122
123       $comment = unpack("Z*", $buffer);
124       print "Read back comment $comment0;
125
126[1mNOTES[0m
127       The     current     interface    to   the   [1mlfc_getcom‐
128ment(3)[22m,  [1mlfc_getcwd(3)[22m,
129       [1mlfc_readlink(3)[22m,  [1mlfc_seterrbuf(3)  [22mrequires
130the passing  of  a  suitably
131       allocated  buffer  (in  a similar way to the C functions).
132However this is
133       rather non standard in PERL. A future version of lfc  perl
134interface may
135       do   away   with   the  need  to  setup  the buffer before
136the call and to
137       explicitly unpack the result afterwards.
138
139[1mSEE ALSO[0m
140       [1mLFC C interface man pages[0m
141
142
143
144LFC                         $Date:    2007/02/23    10:03:07    $
145lfc_perl(3)
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
Impressum