Logo Search packages:      
Sourcecode: tablix2 version File versions  Download package

int res_get_matrix ( resourcetype restype,
int *  width,
int *  height 
)

Finds the dimensions of a matrix of resources.

This function finds the width and height of a matrix of resources that was defined by the res_new_matrix() function. There must be no other resources defined in the specified resource type.

Parameters:
restype Pointer to the resource type structure.
width Width of the matrix.
height Height of the matrix.
Returns:
0 on success (width and height are set to correct values) and -1 on error (this resource type does not contain a matrix of resources - width and height are not touched.

Definition at line 633 of file data.c.

References resource_t::name, resourcetype_t::res, and resourcetype_t::resnum.

{
      int result;
      int resid;
      int w,h;
      int n,m;

      assert(restype!=NULL);
      assert(width!=NULL);
      assert(height!=NULL);
      
      resid=0;
      h=-1;
      while(resid<restype->resnum) {
            result=sscanf(restype->res[resid].name, "%d %d", &n, &m);
            if(result!=2) return(-1);

            if(m>h) {
                  if(n!=0) return(-1);
                  h=m;
            } else {
                  break;
            }

            resid++;
      }
      h++;

      w=1;
      while(resid<restype->resnum) {
            for(m=0;m<h;m++) {
                  if(resid>=restype->resnum) return(-1);

                  result=sscanf(restype->res[resid].name,"%d %d",&n,&m);
                  if(result!=2) return(-1);
                  if(w!=n) return(-1);

                  resid++;
            }
            w++;
      }

      *width=w;
      *height=h;

      return(0);
}


Generated by  Doxygen 1.6.0   Back to index