Beispiel #1
0
/******************************************************************
 *		source_new
 *
 * checks if source exists. if not, add it
 */
unsigned source_new(struct module* module, const char* base, const char* name)
{
    unsigned    ret;
    const char* full;
    char*       tmp = NULL;

    if (!name) return (unsigned)-1;
    if (!base || *name == '/')
        full = name;
    else
    {
        unsigned bsz = strlen(base);

        tmp = HeapAlloc(GetProcessHeap(), 0, bsz + 1 + strlen(name) + 1);
        if (!tmp) return (unsigned)-1;
        full = tmp;
        strcpy(tmp, base);
        if (tmp[bsz - 1] != '/') tmp[bsz++] = '/';
        strcpy(&tmp[bsz], name);
    }
    if (!module->sources || (ret = source_find(module, full)) == (unsigned)-1)
    {
        int len = strlen(full) + 1;
        if (module->sources_used + len + 1 > module->sources_alloc)
        {
            if (!module->sources)
            {
                module->sources_alloc = (module->sources_used + len + 1 + 255) & ~255;
                module->sources = HeapAlloc(GetProcessHeap(), 0, module->sources_alloc);
            }
            else
            {
                module->sources_alloc = max( module->sources_alloc * 2,
                                             (module->sources_used + len + 1 + 255) & ~255 );
                module->sources = HeapReAlloc(GetProcessHeap(), 0, module->sources,
                                              module->sources_alloc);
            }
        }
        ret = module->sources_used;
        memcpy(module->sources + module->sources_used, full, len);
        module->sources_used += len;
        module->sources[module->sources_used] = '\0';
    }
    HeapFree(GetProcessHeap(), 0, tmp);
    return ret;
}
Beispiel #2
0
mixed can_drink_str_from_obj( string fluid ){
  return source_find(fluid);
}
Beispiel #3
0
void do_drink_str_from_obj( string fluid ){
  source_find(fluid) -> drink_from_it( fluid );
}
Beispiel #4
0
mixed can_drink_str( string fluid ){// Is the character in the presence of a fluid source?
  return source_find(fluid);
}