pike.git / src / modules / _WhiteFish / blobs.c

version» Context lines:

pike.git/src/modules/_WhiteFish/blobs.c:1: + /* + || This file is part of Pike. For copyright information see COPYRIGHT. + || Pike is distributed under GPL, LGPL and MPL. See the file COPYING + || for more information. + */ +    #include "global.h"   #include "stralloc.h" - #include "global.h" +    #include "pike_macros.h"   #include "interpret.h"   #include "program.h"   #include "object.h"   #include "array.h"   #include "module_support.h"      #include "config.h"      #include "whitefish.h"
pike.git/src/modules/_WhiteFish/blobs.c:102:    *! Add all the words in the 'words' array to the blobs    */   {    int docid;    struct array *words;    int field_id;       int i;    struct blobs *blbl = THIS;    -  get_all_args( "add_words", args, "%d%a%d", +  get_all_args( NULL, args, "%d%a%d",    &docid, &words, &field_id);       for( i = 0; i<words->size; i++ )    if( TYPEOF(words->item[i]) != PIKE_T_STRING )    Pike_error("Illegal element %d in words array\n", i );    else    {    struct hash *x = find_hash( blbl, words->item[i].u.string );    if( !x->buffer )    Pike_error("Read already called\n");
pike.git/src/modules/_WhiteFish/blobs.c:174:    SET_SVAL(a->item[1], PIKE_T_INT, NUMBER_NUMBER, integer, 0);    push_array( a );    return;    }    t->next_h = t->hash[ t->next_ind ];    t->next_ind++;    }       SET_SVAL(a->item[0], PIKE_T_STRING, 0, string, t->next_h->id);    SET_SVAL(a->item[1], PIKE_T_STRING, 0, string, -  make_shared_binary_string( t->next_h->buffer->data, +  make_shared_binary_string0( t->next_h->buffer->data,    t->next_h->buffer->size ));    wf_buffer_free( t->next_h->buffer );    t->next_h->buffer = 0;    t->next_h->id = 0;       push_array( a );       t->next_h = THIS->next_h->next;   }   
pike.git/src/modules/_WhiteFish/blobs.c:196:   static int compare_wordarrays( const void *_a, const void *_b )   {    const struct svalue *a = (struct svalue *)_a;    const struct svalue *b = (struct svalue *)_b;    return my_quick_strcmp( a->u.array->item[0].u.string,    b->u.array->item[0].u.string );   }      /*! @decl array(array(string)) read_all_sorted()    *! -  *! returns ({({ string word1_id, string blob1 }),...}), sorted by word_id in octed order. +  *! Returns ({({ string word1_id, string blob1 }),...}), +  *! sorted by word_id in octet order.    *! -  *! As a side-effect, -  *! this function frees the blobs and the word_ids, so you can only read -  *! the blobs struct once. Also, once you have called @[read] or @[read_all_sorted], -  *! @[add_words] will no longer work as expected. +  *! @note +  *! This function also frees the blobs and the word_ids, so you can only read +  *! the blobs struct once. Also, once you have called @[read] or +  *! @[read_all_sorted], @[add_words] will no longer work as expected.    */   static void f_blobs_read_all_sorted( INT32 UNUSED(args) )   {    struct array *g = allocate_array( THIS->nwords );    int i;    for( i = 0; i<THIS->nwords; i++ )    {    f_blobs_read(0);    g->item[i]=Pike_sp[-1];    Pike_sp--;
pike.git/src/modules/_WhiteFish/blobs.c:225:   }            /*! @endclass    */      /*! @endmodule    */    - static void init_blobs_struct( ) + static void init_blobs_struct(struct object *UNUSED(o))   { -  MEMSET( THIS, 0, sizeof( struct blobs ) ); +     THIS->size = sizeof( struct blobs ) + 128;   }    - static void exit_blobs_struct( ) + static void exit_blobs_struct(struct object *UNUSED(o))   {    int i;    for( i = 0; i<HSIZE; i++ )    if( THIS->hash[i] )    free_hash( THIS->hash[i] ); -  init_blobs_struct(); +    }      static struct program *blobs_program; - void init_blobs_program() + void init_blobs_program(void)   {    start_new_program();    ADD_STORAGE( struct blobs ); -  add_function("add_words",f_blobs_add_words, -  "function(int,array,int:void)",0 ); -  add_function("memsize", f_blobs_memsize, "function(void:int)", 0 ); -  add_function("read", f_blobs_read, "function(void:array(string))", 0); -  add_function("read_all_sorted", f_blobs_read_all_sorted, "function(void:array(array(string)))", 0); +  ADD_FUNCTION("add_words",f_blobs_add_words,tFunc(tInt tArray tInt,tVoid),0 ); +  ADD_FUNCTION("memsize", f_blobs_memsize, tFunc(tVoid,tInt), 0 ); +  ADD_FUNCTION("read", f_blobs_read, tFunc(tVoid,tArr(tStr)), 0); +  ADD_FUNCTION("read_all_sorted", f_blobs_read_all_sorted, tFunc(tVoid,tArr(tArr(tStr))), 0);    set_init_callback( init_blobs_struct );    set_exit_callback( exit_blobs_struct );    blobs_program = end_program( );    add_program_constant( "Blobs", blobs_program, 0 );   }    - void exit_blobs_program() + void exit_blobs_program(void)   {    free_program( blobs_program );   }