Ejemplo n.º 1
0
/*
data_t first = {INT, 1, &z};
data_t *first_p = &first;

data_t second = {INT, 2, &y};
data_t *second_p = &second;

data_t third = {INT, 2, &x};
data_t *third_p = &third;
*/
int main(void){
  
  data_t *p_list = init_property_list(5);
  //  memcpy(&property_list[0], first_p, sizeof(property_list[0])); //this is cool
  set_property(p_list, 1, INT, 2, &y);
  set_property(p_list, 2, CHAR, 2, &x);
    
  /*
  int s_first = sizeof(*first_p);
  int s_second = sizeof(*second_p);
  printf("size first: %i \n", s_first);
  printf("size second: %i \n", s_second);
  */

  /*  
  a = (*property_list)[1].type;
  b = (*property_list)[1].length;
  c = *(int*)(*property_list)[1].data;
  a = 1;
  printf("type %i \n", a);
  printf("length %i \n", b);
  printf("data %i \n", c);
  */
  
  get_property(p_list, 0);
  get_property(p_list, 1);
  get_property(p_list, 2);
  
  return 0;
};
Ejemplo n.º 2
0
/*******************************************************************
*   Write Properties to disk, and save seek pointers
*
*   DB_WriteProperty - should write filenum:propID as the key
*   DB_WritePropPositions - writes the stored positions
*
*
*
*********************************************************************/
void     WritePropertiesToDisk( SWISH *sw , FileRec *fi )
{
    IndexFILE       *indexf = sw->indexlist;
    INDEXDATAHEADER *header = &indexf->header;
    docProperties   *docProperties = fi->docProperties;
    propEntry       *prop;
    int             uncompressed_len;
    unsigned char   *buf;
    int             buf_len;
    int             count;
    int             i;
    

    /* initialize the first time called */
    if ( header->property_count == 0 )
    {
        /* Get the current seek position in the index, since will now write the file info */
        DB_InitWriteProperties(sw, indexf->DB);

        /* build a list of properties that are in use */
        /* And create the prop index to propID (metaID) mapping arrays */
        init_property_list(header);
    }


    if ( (count = header->property_count) <= 0)
        return;


    /* any props exist, unlikely, but need to save a space. */
    if ( !docProperties )
    {
        DB_WritePropPositions( sw, indexf, fi, indexf->DB);
        return;
    }


    for( i = 0; i < count; i++ )
    {
        /* convert the count to a propID */
        int propID = header->propIDX_to_metaID[i];  // here's the array created in init_property_list()


        /* Here's why I need to redo the properties so it's always header->property_count size in the fi rec */
        /* The mapping is all a temporary kludge */
        if ( propID >= docProperties->n ) // Does this file have this many properties?
            continue;


        if ( !(prop = docProperties->propEntry[propID])) // does this file have this prop?
            continue;

        buf = compress_property( prop, sw, &buf_len, &uncompressed_len );

        DB_WriteProperty( sw, indexf, fi, propID, (char *)buf, buf_len, uncompressed_len, indexf->DB );
    }




    /* Write the position data */
    DB_WritePropPositions( sw, indexf, fi, indexf->DB);

    freeDocProperties( docProperties );
    fi->docProperties = NULL;

       

}