3 /* gras_datadesc.c - manipulating datadescriptors */
5 /* Authors: Martin Quinson */
6 /* Copyright (C) 2003 the OURAGAN project. */
8 /* This program is free software; you can redistribute it and/or modify it
9 under the terms of the license (GNU LGPL) which comes with this package. */
11 #include "gras_private.h"
13 void *gras_datadesc_copy_data(const DataDescriptor *dd, unsigned int c,
15 size_t s=DataSize(dd,c,HOST_FORMAT);
19 fprintf(stderr,"grasDataDescCpyData: malloc of %d bytes failed.\n",s);
28 int gras_datadesc_cmp(const DataDescriptor *dd1, unsigned int c1,
29 const DataDescriptor *dd2, unsigned int c2) {
36 if (!dd1 && !dd2) return 0;
37 if (!dd1 || !dd2) return 1;
40 if (dd1[i].type != dd2[i].type)
41 return dd1[i].type < dd2[i].type;
42 if (dd1[i].repetitions != dd2[i].repetitions)
43 return dd1[i].repetitions < dd2[i].repetitions;
44 if (dd1[i].type == STRUCT_TYPE) {
45 subcmp = gras_datadesc_cmp(dd1[i].members, dd1[i].length,
46 dd2[i].members, dd2[i].length);
55 void gras_datadesc_dump(const DataDescriptor *dd, unsigned int c) {
61 fprintf(stderr,"DD[%d] = {%s,repetitions=%d,offset=%d,members=%p,len=%d,pad=%d}\n",
63 (dd[i].type == CHAR_TYPE ? "char" :
64 (dd[i].type == DOUBLE_TYPE ? "double" :
65 (dd[i].type == FLOAT_TYPE ? "float" :
66 (dd[i].type == INT_TYPE ? "int" :
67 (dd[i].type == LONG_TYPE ? "long" :
68 (dd[i].type == SHORT_TYPE ? "short" :
69 (dd[i].type == UNSIGNED_INT_TYPE ? "uint" :
70 (dd[i].type == UNSIGNED_LONG_TYPE ? "ulong" :
71 (dd[i].type == UNSIGNED_SHORT_TYPE ? "ushort":
72 (dd[i].type == STRUCT_TYPE ? "struct" : "UNKNOWN")))))))))),
73 dd[i].repetitions, dd[i].offset,
74 dd[i].members, dd[i].length,
76 if (dd[i].type == STRUCT_TYPE) {
77 gras_datadesc_dump(dd[i].members, dd[i].length);