1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2 * Copyright by The HDF Group. *
3 * Copyright by the Board of Trustees of the University of Illinois. *
4 * All rights reserved. *
5 * *
6 * This file is part of HDF5. The full HDF5 copyright notice, including *
7 * terms governing use, modification, and redistribution, is contained in *
8 * the files COPYING and Copyright.html. COPYING can be found at the root *
9 * of the source code distribution tree; Copyright.html can be found at the *
10 * root level of an installed copy of the electronic HDF5 document set and *
11 * is linked from the top-level documents page. It can also be found at *
12 * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
13 * access to either file, you may request a copy from help@hdfgroup.org. *
14 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15
16 /*
17 * Programmer: Robb Matzke <matzke@llnl.gov>
18 * Wednesday, April 15, 1998
19 *
20 * Purpose: Data filter pipeline message.
21 */
22
23 #define H5O_PACKAGE /*suppress error about including H5Opkg */
24 #define H5Z_PACKAGE /*suppress error about including H5Zpkg */
25
26 #include "H5private.h" /* Generic Functions */
27 #include "H5Dprivate.h" /* Datasets */
28 #include "H5Eprivate.h" /* Error handling */
29 #include "H5FLprivate.h" /* Free Lists */
30 #include "H5MMprivate.h" /* Memory management */
31 #include "H5Opkg.h" /* Object headers */
32 #include "H5Zpkg.h" /* Data filters */
33
34
35 /* PRIVATE PROTOTYPES */
36 static herr_t H5O_pline_encode(H5F_t *f, uint8_t *p, const void *mesg);
37 static void *H5O_pline_decode(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh,
38 unsigned mesg_flags, unsigned *ioflags, const uint8_t *p);
39 static void *H5O_pline_copy(const void *_mesg, void *_dest);
40 static size_t H5O_pline_size(const H5F_t *f, const void *_mesg);
41 static herr_t H5O_pline_reset(void *_mesg);
42 static herr_t H5O_pline_free(void *_mesg);
43 static herr_t H5O_pline_pre_copy_file(H5F_t *file_src,
44 const void *mesg_src, hbool_t *deleted, const H5O_copy_t *cpy_info, void *_udata);
45 static herr_t H5O_pline_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg,
46 FILE * stream, int indent, int fwidth);
47
48 /* Set up & include shared message "interface" info */
49 #define H5O_SHARED_TYPE H5O_MSG_PLINE
50 #define H5O_SHARED_DECODE H5O_pline_shared_decode
51 #define H5O_SHARED_DECODE_REAL H5O_pline_decode
52 #define H5O_SHARED_ENCODE H5O_pline_shared_encode
53 #define H5O_SHARED_ENCODE_REAL H5O_pline_encode
54 #define H5O_SHARED_SIZE H5O_pline_shared_size
55 #define H5O_SHARED_SIZE_REAL H5O_pline_size
56 #define H5O_SHARED_DELETE H5O_pline_shared_delete
57 #undef H5O_SHARED_DELETE_REAL
58 #define H5O_SHARED_LINK H5O_pline_shared_link
59 #undef H5O_SHARED_LINK_REAL
60 #define H5O_SHARED_COPY_FILE H5O_pline_shared_copy_file
61 #undef H5O_SHARED_COPY_FILE_REAL
62 #define H5O_SHARED_POST_COPY_FILE H5O_pline_shared_post_copy_file
63 #undef H5O_SHARED_POST_COPY_FILE_REAL
64 #undef H5O_SHARED_POST_COPY_FILE_UPD
65 #define H5O_SHARED_DEBUG H5O_pline_shared_debug
66 #define H5O_SHARED_DEBUG_REAL H5O_pline_debug
67 #include "H5Oshared.h" /* Shared Object Header Message Callbacks */
68
69 /* This message derives from H5O message class */
70 const H5O_msg_class_t H5O_MSG_PLINE[1] = {{
71 H5O_PLINE_ID, /* message id number */
72 "filter pipeline", /* message name for debugging */
73 sizeof(H5O_pline_t), /* native message size */
74 H5O_SHARE_IS_SHARABLE|H5O_SHARE_IN_OHDR, /* messages are sharable? */
75 H5O_pline_shared_decode, /* decode message */
76 H5O_pline_shared_encode, /* encode message */
77 H5O_pline_copy, /* copy the native value */
78 H5O_pline_shared_size, /* size of raw message */
79 H5O_pline_reset, /* reset method */
80 H5O_pline_free, /* free method */
81 H5O_pline_shared_delete, /* file delete method */
82 H5O_pline_shared_link, /* link method */
83 NULL, /* set share method */
84 NULL, /*can share method */
85 H5O_pline_pre_copy_file, /* pre copy native value to file */
86 H5O_pline_shared_copy_file, /* copy native value to file */
87 H5O_pline_shared_post_copy_file, /* post copy native value to file */
88 NULL, /* get creation index */
89 NULL, /* set creation index */
90 H5O_pline_shared_debug /* debug the message */
91 }};
92
93
94 /* Declare a free list to manage the H5O_pline_t struct */
95 H5FL_DEFINE(H5O_pline_t);
96
97
98 /*-------------------------------------------------------------------------
99 * Function: H5O_pline_decode
100 *
101 * Purpose: Decodes a filter pipeline message.
102 *
103 * Return: Success: Ptr to the native message.
104 * Failure: NULL
105 *
106 * Programmer: Robb Matzke
107 * Wednesday, April 15, 1998
108 *
109 *-------------------------------------------------------------------------
110 */
111 static void *
H5O_pline_decode(H5F_t UNUSED * f,hid_t UNUSED dxpl_id,H5O_t UNUSED * open_oh,unsigned UNUSED mesg_flags,unsigned UNUSED * ioflags,const uint8_t * p)112 H5O_pline_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh,
113 unsigned UNUSED mesg_flags, unsigned UNUSED *ioflags, const uint8_t *p)
114 {
115 H5O_pline_t *pline = NULL; /* Pipeline message */
116 H5Z_filter_info_t *filter; /* Filter to decode */
117 size_t name_length; /* Length of filter name */
118 size_t i; /* Local index variable */
119 void *ret_value; /* Return value */
120
121 FUNC_ENTER_NOAPI_NOINIT
122
123 /* check args */
124 HDassert(p);
125
126 /* Allocate space for I/O pipeline message */
127 if(NULL == (pline = H5FL_CALLOC(H5O_pline_t)))
128 HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
129
130 /* Version */
131 pline->version = *p++;
132 if(pline->version < H5O_PLINE_VERSION_1 || pline->version > H5O_PLINE_VERSION_LATEST)
133 HGOTO_ERROR(H5E_PLINE, H5E_CANTLOAD, NULL, "bad version number for filter pipeline message")
134
135 /* Number of filters */
136 pline->nused = *p++;
137 if(pline->nused > H5Z_MAX_NFILTERS)
138 HGOTO_ERROR(H5E_PLINE, H5E_CANTLOAD, NULL, "filter pipeline message has too many filters")
139
140 /* Reserved */
141 if(pline->version == H5O_PLINE_VERSION_1)
142 p += 6;
143
144 /* Allocate array for filters */
145 pline->nalloc = pline->nused;
146 if(NULL == (pline->filter = (H5Z_filter_info_t *)H5MM_calloc(pline->nalloc * sizeof(pline->filter[0]))))
147 HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
148
149 /* Decode filters */
150 for(i = 0, filter = &pline->filter[0]; i < pline->nused; i++, filter++) {
151 /* Filter ID */
152 UINT16DECODE(p, filter->id);
153
154 /* Length of filter name */
155 if(pline->version > H5O_PLINE_VERSION_1 && filter->id < H5Z_FILTER_RESERVED)
156 name_length = 0;
157 else {
158 UINT16DECODE(p, name_length);
159 if(pline->version == H5O_PLINE_VERSION_1 && name_length % 8)
160 HGOTO_ERROR(H5E_PLINE, H5E_CANTLOAD, NULL, "filter name length is not a multiple of eight")
161 } /* end if */
162
163 /* Filter flags */
164 UINT16DECODE(p, filter->flags);
165
166 /* Number of filter parameters ("client data elements") */
167 UINT16DECODE(p, filter->cd_nelmts);
168
169 /* Filter name, if there is one */
170 if(name_length) {
171 size_t actual_name_length; /* Actual length of name */
172
173 /* Determine actual name length (without padding, but with null terminator) */
174 actual_name_length = HDstrlen((const char *)p) + 1;
175 HDassert(actual_name_length <= name_length);
176
177 /* Allocate space for the filter name, or use the internal buffer */
178 if(actual_name_length > H5Z_COMMON_NAME_LEN) {
179 filter->name = (char *)H5MM_malloc(actual_name_length);
180 if(NULL == filter->name)
181 HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for filter name")
182 } /* end if */
183 else
184 filter->name = filter->_name;
185
186 HDstrncpy(filter->name, (const char *)p, actual_name_length);
187 p += name_length;
188 } /* end if */
189
190 /* Filter parameters */
191 if(filter->cd_nelmts) {
192 size_t j; /* Local index variable */
193
194 /* Allocate space for the client data elements, or use the internal buffer */
195 if(filter->cd_nelmts > H5Z_COMMON_CD_VALUES) {
196 filter->cd_values = (unsigned *)H5MM_malloc(filter->cd_nelmts * sizeof(unsigned));
197 if(NULL == filter->cd_values)
198 HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for client data")
199 } /* end if */
200 else
201 filter->cd_values = filter->_cd_values;
202
203 /*
204 * Read the client data values and the padding
205 */
206 for(j = 0; j < filter->cd_nelmts; j++)
207 UINT32DECODE(p, filter->cd_values[j]);
208 if(pline->version == H5O_PLINE_VERSION_1)
209 if(filter->cd_nelmts % 2)
210 p += 4; /*padding*/
211 } /* end if */
212 } /* end for */
213
214 /* Set return value */
215 ret_value = pline;
216
217 done:
218 if(NULL == ret_value && pline) {
219 H5O_pline_reset(pline);
220 H5O_pline_free(pline);
221 } /* end if */
222
223 FUNC_LEAVE_NOAPI(ret_value)
224 } /* end H5O_pline_decode() */
225
226
227 /*-------------------------------------------------------------------------
228 * Function: H5O_pline_encode
229 *
230 * Purpose: Encodes message MESG into buffer P.
231 *
232 * Return: Non-negative on success/Negative on failure
233 *
234 * Programmer: Robb Matzke
235 * Wednesday, April 15, 1998
236 *
237 *-------------------------------------------------------------------------
238 */
239 static herr_t
H5O_pline_encode(H5F_t UNUSED * f,uint8_t * p,const void * mesg)240 H5O_pline_encode(H5F_t UNUSED *f, uint8_t *p/*out*/, const void *mesg)
241 {
242 const H5O_pline_t *pline = (const H5O_pline_t*)mesg; /* Pipeline message to encode */
243 const H5Z_filter_info_t *filter; /* Filter to encode */
244 size_t i, j; /* Local index variables */
245
246 FUNC_ENTER_NOAPI_NOINIT_NOERR
247
248 /* Check args */
249 HDassert(p);
250 HDassert(mesg);
251
252 /* Message header */
253 *p++ = (uint8_t)pline->version;
254 *p++ = (uint8_t)(pline->nused);
255 if(pline->version == H5O_PLINE_VERSION_1) {
256 *p++ = 0; /*reserved 1*/
257 *p++ = 0; /*reserved 2*/
258 *p++ = 0; /*reserved 3*/
259 *p++ = 0; /*reserved 4*/
260 *p++ = 0; /*reserved 5*/
261 *p++ = 0; /*reserved 6*/
262 } /* end if */
263
264 /* Encode filters */
265 for(i = 0, filter = &pline->filter[0]; i < pline->nused; i++, filter++) {
266 const char *name; /* Filter name */
267 size_t name_length; /* Length of filter name */
268
269 /* Filter ID */
270 UINT16ENCODE(p, filter->id);
271
272 /* Skip writing the name length & name if the filter is an internal filter */
273 if(pline->version > H5O_PLINE_VERSION_1 && filter->id < H5Z_FILTER_RESERVED) {
274 name_length = 0;
275 name = NULL;
276 } /* end if */
277 else {
278 H5Z_class2_t *cls; /* Filter class */
279
280 /*
281 * Get the filter name. If the pipeline message has a name in it then
282 * use that one. Otherwise try to look up the filter and get the name
283 * as it was registered.
284 */
285 if(NULL == (name = filter->name) && (cls = H5Z_find(filter->id)))
286 name = cls->name;
287 name_length = name ? HDstrlen(name) + 1 : 0;
288
289 /* Filter name length */
290 UINT16ENCODE(p, pline->version == H5O_PLINE_VERSION_1 ? H5O_ALIGN_OLD(name_length) : name_length);
291 } /* end else */
292
293 /* Filter flags */
294 UINT16ENCODE(p, filter->flags);
295
296 /* # of filter parameters */
297 UINT16ENCODE(p, filter->cd_nelmts);
298
299 /* Encode name, if there is one to encode */
300 if(name_length > 0) {
301 /* Store name, with null terminator */
302 HDmemcpy(p, name, name_length);
303 p += name_length;
304
305 /* Pad out name to alignment, in older versions */
306 if(pline->version == H5O_PLINE_VERSION_1)
307 while(name_length++ % 8)
308 *p++ = 0;
309 } /* end if */
310
311 /* Filter parameters */
312 for(j = 0; j < filter->cd_nelmts; j++)
313 UINT32ENCODE(p, filter->cd_values[j]);
314
315 /* Align the parameters for older versions of the format */
316 if(pline->version == H5O_PLINE_VERSION_1)
317 if(filter->cd_nelmts % 2)
318 UINT32ENCODE(p, 0);
319 } /* end for */
320
321 FUNC_LEAVE_NOAPI(SUCCEED)
322 } /* end H5O_pline_encode() */
323
324
325 /*-------------------------------------------------------------------------
326 * Function: H5O_pline_copy
327 *
328 * Purpose: Copies a filter pipeline message from SRC to DST allocating
329 * DST if necessary. If DST is already allocated then we assume
330 * that it isn't initialized.
331 *
332 * Return: Success: Ptr to DST or allocated result.
333 *
334 * Failure: NULL
335 *
336 * Programmer: Robb Matzke
337 * Wednesday, April 15, 1998
338 *
339 *-------------------------------------------------------------------------
340 */
341 static void *
H5O_pline_copy(const void * _src,void * _dst)342 H5O_pline_copy(const void *_src, void *_dst/*out*/)
343 {
344 const H5O_pline_t *src = (const H5O_pline_t *)_src; /* Source pipeline message */
345 H5O_pline_t *dst = (H5O_pline_t *)_dst; /* Destination pipeline message */
346 size_t i; /* Local index variable */
347 H5O_pline_t *ret_value; /* Return value */
348
349 FUNC_ENTER_NOAPI_NOINIT
350
351 /* Allocate pipeline message, if not provided */
352 if(!dst && NULL == (dst = H5FL_MALLOC(H5O_pline_t)))
353 HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
354
355 /* Shallow copy basic fields */
356 *dst = *src;
357
358 /* Copy over filters, if any */
359 dst->nalloc = dst->nused;
360 if(dst->nalloc) {
361 /* Allocate array to hold filters */
362 if(NULL == (dst->filter = (H5Z_filter_info_t *)H5MM_calloc(dst->nalloc * sizeof(dst->filter[0]))))
363 HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
364
365 /* Deep-copy filters */
366 for(i = 0; i < src->nused; i++) {
367 /* Basic filter information */
368 dst->filter[i] = src->filter[i];
369
370 /* Filter name */
371 if(src->filter[i].name) {
372 size_t namelen; /* Length of source filter name, including null terminator */
373
374 namelen = HDstrlen(src->filter[i].name) + 1;
375
376 /* Allocate space for the filter name, or use the internal buffer */
377 if(namelen > H5Z_COMMON_NAME_LEN) {
378 dst->filter[i].name = (char *)H5MM_strdup(src->filter[i].name);
379 if(NULL == dst->filter[i].name)
380 HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for filter name")
381 } /* end if */
382 else
383 dst->filter[i].name = dst->filter[i]._name;
384 } /* end if */
385
386 /* Filter parameters */
387 if(src->filter[i].cd_nelmts > 0) {
388 /* Allocate space for the client data elements, or use the internal buffer */
389 if(src->filter[i].cd_nelmts > H5Z_COMMON_CD_VALUES) {
390 if(NULL == (dst->filter[i].cd_values = (unsigned *)H5MM_malloc(src->filter[i].cd_nelmts* sizeof(unsigned))))
391 HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
392
393 HDmemcpy(dst->filter[i].cd_values, src->filter[i].cd_values,
394 src->filter[i].cd_nelmts * sizeof(unsigned));
395 } /* end if */
396 else
397 dst->filter[i].cd_values = dst->filter[i]._cd_values;
398 } /* end if */
399 } /* end for */
400 } /* end if */
401 else
402 dst->filter = NULL;
403
404 /* Set return value */
405 ret_value = dst;
406
407 done:
408 if(!ret_value && dst) {
409 H5O_pline_reset(dst);
410 if(!_dst)
411 H5O_pline_free(dst);
412 } /* end if */
413
414 FUNC_LEAVE_NOAPI(ret_value)
415 } /* end H5O_pline_copy() */
416
417
418 /*-------------------------------------------------------------------------
419 * Function: H5O_pline_size
420 *
421 * Purpose: Determines the size of a raw filter pipeline message.
422 *
423 * Return: Success: Size of message.
424 *
425 * Failure: zero
426 *
427 * Programmer: Robb Matzke
428 * Wednesday, April 15, 1998
429 *
430 *-------------------------------------------------------------------------
431 */
432 static size_t
H5O_pline_size(const H5F_t UNUSED * f,const void * mesg)433 H5O_pline_size(const H5F_t UNUSED *f, const void *mesg)
434 {
435 const H5O_pline_t *pline = (const H5O_pline_t*)mesg; /* Pipeline message */
436 size_t i; /* Local index variable */
437 size_t ret_value; /* Return value */
438
439 FUNC_ENTER_NOAPI_NOINIT_NOERR
440
441 /* Message header */
442 ret_value = 1 + /*version */
443 1 + /*number of filters */
444 (pline->version == H5O_PLINE_VERSION_1 ? 6 : 0); /*reserved */
445
446 /* Calculate size of each filter in pipeline */
447 for(i = 0; i < pline->nused; i++) {
448 size_t name_len; /* Length of filter name */
449 const char *name; /* Filter name */
450
451 /* Don't write the name length & name if the filter is an internal filter */
452 if(pline->version > H5O_PLINE_VERSION_1 && pline->filter[i].id < H5Z_FILTER_RESERVED)
453 name_len = 0;
454 else {
455 H5Z_class2_t *cls; /* Filter class */
456
457 /* Get the name of the filter, same as done with H5O_pline_encode() */
458 if(NULL == (name = pline->filter[i].name) && (cls = H5Z_find(pline->filter[i].id)))
459 name = cls->name;
460 name_len = name ? HDstrlen(name) + 1 : 0;
461 } /* end else */
462
463 ret_value += 2 + /*filter identification number */
464 (size_t)((pline->version == H5O_PLINE_VERSION_1 || pline->filter[i].id >= H5Z_FILTER_RESERVED) ? 2 : 0) + /*name length */
465 2 + /*flags */
466 2 + /*number of client data values */
467 (pline->version == H5O_PLINE_VERSION_1 ? (size_t)H5O_ALIGN_OLD(name_len) : name_len); /*length of the filter name */
468
469 ret_value += pline->filter[i].cd_nelmts * 4;
470 if(pline->version == H5O_PLINE_VERSION_1)
471 if(pline->filter[i].cd_nelmts % 2)
472 ret_value += 4;
473 } /* end for */
474
475 FUNC_LEAVE_NOAPI(ret_value)
476 } /* end H5O_pline_size() */
477
478
479 /*-------------------------------------------------------------------------
480 * Function: H5O_pline_reset
481 *
482 * Purpose: Resets a filter pipeline message by clearing all filters.
483 * The MESG buffer is not freed.
484 *
485 * Return: Non-negative on success/Negative on failure
486 *
487 * Programmer: Robb Matzke
488 * Wednesday, April 15, 1998
489 *
490 *-------------------------------------------------------------------------
491 */
492 static herr_t
H5O_pline_reset(void * mesg)493 H5O_pline_reset(void *mesg)
494 {
495 H5O_pline_t *pline = (H5O_pline_t*)mesg; /* Pipeline message */
496 size_t i; /* Local index variable */
497
498 FUNC_ENTER_NOAPI_NOINIT_NOERR
499
500 HDassert(pline);
501
502 /* Free information for each filter */
503 for(i = 0; i < pline->nused; i++) {
504 if(pline->filter[i].name && pline->filter[i].name != pline->filter[i]._name)
505 HDassert((HDstrlen(pline->filter[i].name) + 1) > H5Z_COMMON_NAME_LEN);
506 if(pline->filter[i].name != pline->filter[i]._name)
507 pline->filter[i].name = (char *)H5MM_xfree(pline->filter[i].name);
508 if(pline->filter[i].cd_values && pline->filter[i].cd_values != pline->filter[i]._cd_values)
509 HDassert(pline->filter[i].cd_nelmts > H5Z_COMMON_CD_VALUES);
510 if(pline->filter[i].cd_values != pline->filter[i]._cd_values)
511 pline->filter[i].cd_values = (unsigned *)H5MM_xfree(pline->filter[i].cd_values);
512 } /* end for */
513
514 /* Free filter array */
515 if(pline->filter)
516 pline->filter = (H5Z_filter_info_t *)H5MM_xfree(pline->filter);
517
518 /* Reset # of filters */
519 pline->nused = pline->nalloc = 0;
520
521 /* Reset version # of pipeline message */
522 pline->version = H5O_PLINE_VERSION_1;
523
524 FUNC_LEAVE_NOAPI(SUCCEED)
525 } /* end H5O_pline_reset() */
526
527
528 /*-------------------------------------------------------------------------
529 * Function: H5O_pline_free
530 *
531 * Purpose: Free's the message
532 *
533 * Return: Non-negative on success/Negative on failure
534 *
535 * Programmer: Quincey Koziol
536 * Saturday, March 11, 2000
537 *
538 *-------------------------------------------------------------------------
539 */
540 static herr_t
H5O_pline_free(void * mesg)541 H5O_pline_free(void *mesg)
542 {
543 FUNC_ENTER_NOAPI_NOINIT_NOERR
544
545 HDassert(mesg);
546
547 mesg = H5FL_FREE(H5O_pline_t, mesg);
548
549 FUNC_LEAVE_NOAPI(SUCCEED)
550 } /* end H5O_pline_free() */
551
552
553 /*-------------------------------------------------------------------------
554 * Function: H5O_pline_pre_copy_file
555 *
556 * Purpose: Perform any necessary actions before copying message between
557 * files
558 *
559 * Return: Success: Non-negative
560 *
561 * Failure: Negative
562 *
563 * Programmer: Peter Cao
564 * December 27, 2005
565 *
566 *-------------------------------------------------------------------------
567 */
568 static herr_t
H5O_pline_pre_copy_file(H5F_t UNUSED * file_src,const void * mesg_src,hbool_t UNUSED * deleted,const H5O_copy_t UNUSED * cpy_info,void * _udata)569 H5O_pline_pre_copy_file(H5F_t UNUSED *file_src, const void *mesg_src,
570 hbool_t UNUSED *deleted, const H5O_copy_t UNUSED *cpy_info, void *_udata)
571 {
572 const H5O_pline_t *pline_src = (const H5O_pline_t *)mesg_src; /* Source datatype */
573 H5O_copy_file_ud_common_t *udata = (H5O_copy_file_ud_common_t *)_udata; /* Object copying user data */
574 herr_t ret_value = SUCCEED; /* Return value */
575
576 FUNC_ENTER_NOAPI_NOINIT
577
578 /* check args */
579 HDassert(pline_src);
580
581 /* If the user data is non-NULL, assume we are copying a dataset or group
582 * and make a copy of the filter pipeline for later in
583 * the object copying process.
584 */
585 if(udata)
586 if(NULL == (udata->src_pline = (H5O_pline_t *)H5O_pline_copy(pline_src, NULL)))
587 HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to copy")
588
589 done:
590 FUNC_LEAVE_NOAPI(ret_value)
591 } /* end H5O_pline_pre_copy_file() */
592
593
594 /*-------------------------------------------------------------------------
595 * Function: H5O_pline_debug
596 *
597 * Purpose: Prints debugging information for filter pipeline message MESG
598 * on output stream STREAM. Each line is indented INDENT
599 * characters and the field name takes up FWIDTH characters.
600 *
601 * Return: Non-negative on success/Negative on failure
602 *
603 * Programmer: Robb Matzke
604 * Wednesday, April 15, 1998
605 *
606 *-------------------------------------------------------------------------
607 */
608 static herr_t
H5O_pline_debug(H5F_t UNUSED * f,hid_t UNUSED dxpl_id,const void * mesg,FILE * stream,int indent,int fwidth)609 H5O_pline_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *mesg, FILE *stream,
610 int indent, int fwidth)
611 {
612 const H5O_pline_t *pline = (const H5O_pline_t *)mesg;
613 size_t i, j;
614
615 FUNC_ENTER_NOAPI_NOINIT_NOERR
616
617 /* check args */
618 HDassert(f);
619 HDassert(pline);
620 HDassert(stream);
621 HDassert(indent >= 0);
622 HDassert(fwidth >= 0);
623
624 HDfprintf(stream, "%*s%-*s %Zu/%Zu\n", indent, "", fwidth,
625 "Number of filters:",
626 pline->nused,
627 pline->nalloc);
628
629 /* Loop over all the filters */
630 for(i = 0; i < pline->nused; i++) {
631 char name[32];
632
633 HDsnprintf(name, sizeof(name), "Filter at position %u", (unsigned)i);
634 HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, name);
635 HDfprintf(stream, "%*s%-*s 0x%04x\n", indent + 3, "", MAX(0, fwidth - 3),
636 "Filter identification:",
637 (unsigned)(pline->filter[i].id));
638 if(pline->filter[i].name)
639 HDfprintf(stream, "%*s%-*s \"%s\"\n", indent + 3, "", MAX(0, fwidth - 3),
640 "Filter name:",
641 pline->filter[i].name);
642 else
643 HDfprintf(stream, "%*s%-*s NONE\n", indent + 3, "", MAX(0, fwidth - 3),
644 "Filter name:");
645 HDfprintf(stream, "%*s%-*s 0x%04x\n", indent + 3, "", MAX(0, fwidth - 3),
646 "Flags:",
647 pline->filter[i].flags);
648 HDfprintf(stream, "%*s%-*s %Zu\n", indent + 3, "", MAX(0, fwidth - 3),
649 "Num CD values:",
650 pline->filter[i].cd_nelmts);
651
652 /* Filter parameters */
653 for(j = 0; j < pline->filter[i].cd_nelmts; j++) {
654 char field_name[32];
655
656 HDsnprintf(field_name, sizeof(field_name), "CD value %lu", (unsigned long)j);
657 HDfprintf(stream, "%*s%-*s %u\n", indent + 6, "", MAX(0, fwidth - 6),
658 field_name,
659 pline->filter[i].cd_values[j]);
660 } /* end for */
661 } /* end for */
662
663 FUNC_LEAVE_NOAPI(SUCCEED)
664 } /* end H5O_pline_debug() */
665
666
667 /*-------------------------------------------------------------------------
668 * Function: H5O_pline_set_latest_version
669 *
670 * Purpose: Set the encoding for a I/O filter pipeline to the latest version.
671 *
672 * Return: Non-negative on success/Negative on failure
673 *
674 * Programmer: Quincey Koziol
675 * Tuesday, July 24, 2007
676 *
677 *-------------------------------------------------------------------------
678 */
679 herr_t
H5O_pline_set_latest_version(H5O_pline_t * pline)680 H5O_pline_set_latest_version(H5O_pline_t *pline)
681 {
682 FUNC_ENTER_NOAPI_NOINIT_NOERR
683
684 /* Sanity check */
685 HDassert(pline);
686
687 /* Set encoding of I/O pipeline to latest version */
688 pline->version = H5O_PLINE_VERSION_LATEST;
689
690 FUNC_LEAVE_NOAPI(SUCCEED)
691 } /* end H5O_pline_set_latest_version() */
692
693