Ejemplo n.º 1
0
int HashIdx::Put(const char *key, int length, Db *DbHandle,short numOfPartitions)
{
	if (key == NULL)
	{
		printf("HashIdx:Put: ERROR, Put failed because its input key is NULL!\n");
		return EXIT_FAILURE;
	}
	/*else if (DbHandle == NULL)
	{
		printf("HashIdx:Put: ERROR, Put failed because its input DbHandle is NULL!\n");
		return EXIT_FAILURE;
	}*/
	else if (length==0)
	{
		printf("HashIdx:Put: ERROR, Put failed because its input length is %d!\n",length);
		return EXIT_FAILURE;
	}

	//GlobalDBHandle = DbHandle;
	//return 0;

	struct HashIdx::VElt *res = findobj(key, length);
#ifdef VERBOSE
	printf("HashIdx:Put() invoked with (key=%s, length=%d)\n", 
			*key, length);
	}
Ejemplo n.º 2
0
int main(int argc, string argv[])
{
    stream istr, ostr;
    string itags[MaxBodyFields];

    initparam(argv, defv);
    new_field(&LinkField, IntType, LinkTag);	/* use int's worth of space */
    new_field(&LinkField + 1, NULL, NULL);
    layout_body(bodytags, Precision, NDIM);
    istr = stropen(getparam("in"), "r");
    get_history(istr);
    if (! get_snap(istr, &btab, &nbody, &tnow, itags, TRUE))
        error("%s: snapshot input failed\n", getargv0());
    if (! set_member(itags, PosTag))
        error("%s: %s data missing\n", getargv0(), PosTag);
    if (getbparam("subkey") && ! set_member(itags, KeyTag))
        error("%s: %s data missing\n", getargv0(), KeyTag);
    findobj(getdparam("bcrit"),	getiparam("nmin"), getbparam("subkey"));
    ostr = stropen(getparam("out"), "w");
    put_history(ostr);
    put_snap(ostr, &btab, &nbody, &tnow,
             set_union(itags, set_cons(KeyTag, NULL)));
    strclose(ostr);
    return (0);
}
Ejemplo n.º 3
0
int HashIdx::Delete(const char *key, int length)
{
	struct HashIdx::VElt *res = findobj(key, length);
	if (res == NULL)
	{
		return DB_NOTFOUND;
	}

	deleteobj(key, length);
	return 0;
}
Ejemplo n.º 4
0
bool cell::delobj(playerobj *obj)
{
	if (obj)
	{
		if (findobj(obj))
		{
			m_playerset.erase(obj);
			return true;
		}
	}
	return false;
}
Ejemplo n.º 5
0
Db *HashIdx::Get(const char *key, int length,short &numOfPartitions)
{
	//return GlobalDBHandle;
	int ret = 0;
	struct HashIdx::VElt *res = findobj(key, length);	//=>
	if (res==NULL)
	{
#ifdef VERBOSE
		printf("HashIdx:Get() key=%d not found.", (int) *key);
#endif
		return NULL;
	}
	numOfPartitions= res->numOfPartition;
	return res->dbptr;
}
Ejemplo n.º 6
0
void SetNotifications (void)
{
#if defined(__AROS__)
	h_SettingsHook.h_Entry = ( HOOKFUNC )SettingsHook;
#endif
  DoMethod(Win, MUIM_Notify, MUIA_Window_CloseRequest, MUIV_EveryTime, (ULONG)App, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
  DoMethod(App, MUIM_Notify, MUIA_Application_MenuAction, MENU_QUIT, (ULONG)App, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
/*DoMethod(App, MUIM_Notify, MUIA_Application_MenuAction, MENU_SAVEAS, (ULONG)List, 2, MUIM_CallHook, (ULONG)&h_SaveAsHook);*/
  DoMethod(App, MUIM_Notify, MUIA_Application_MenuAction, MENU_SETTINGS, (ULONG)App, 2, MUIM_CallHook, (ULONG)&h_SettingsHook);
  DoMethod(App, MUIM_Notify, MUIA_Application_MenuAction, MENU_CLEAR,
   (ULONG)List, 1, MUIM_List_Clear);

  /* close prefs window */

  DoMethod(SWin, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, App, 2,
   MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
  DoMethod(findobj(SWin, PREFS_BUTTON_CANCEL), MUIM_Notify, MUIA_Pressed,
   FALSE, App, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
  DoMethod(findobj(SWin, PREFS_BUTTON_USE), MUIM_Notify, MUIA_Pressed,
   FALSE, App, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
  DoMethod(findobj(SWin, PREFS_BUTTON_SAVE), MUIM_Notify, MUIA_Pressed,
   FALSE, App, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);

  /* saving prefs */

  DoMethod(findobj(SWin, PREFS_BUTTON_USE), MUIM_Notify, MUIA_Pressed,
   FALSE, App, 2, MUIM_Application_Save, MUIV_Application_Save_ENV);
  DoMethod(findobj(SWin, PREFS_BUTTON_SAVE), MUIM_Notify, MUIA_Pressed,
   FALSE, App, 2, MUIM_Application_Save, MUIV_Application_Save_ENV);
  DoMethod(findobj(SWin, PREFS_BUTTON_SAVE), MUIM_Notify, MUIA_Pressed,
   FALSE, App, 2, MUIM_Application_Save, MUIV_Application_Save_ENVARC);

  /* list redisplay */

  DoMethod(findobj(SWin, PREFS_BUTTON_USE), MUIM_Notify, MUIA_Pressed,
   FALSE, List, 1, CLL_ChangePens);
  DoMethod(findobj(SWin, PREFS_BUTTON_SAVE), MUIM_Notify, MUIA_Pressed,
   FALSE, List, 1, CLL_ChangePens);

}
Ejemplo n.º 7
0
bool listableGetNext(listtable* tbl, listtableObj* obj, const char* name, bool newmem) {

	if (obj == NULL) return NULL;

	listableLock(tbl);

	listtableObj* cont = NULL;

	if (obj->size == 0) { // first time call

		if (name == NULL) { // full scan

			cont = (tbl->lookupforward) ? tbl->first : tbl->last;
		} else { // name search

			cont = findobj(tbl, name, NULL);
		}

	} else { // next call

		cont = (tbl->lookupforward) ? obj->next : obj->prev;
	}

	if (cont == NULL) {

		errno = ENOENT;
		listableUnlock(tbl);
		return false;
	}

	uint32_t hash = (name != NULL) ? hashmurmur3_32(name, strlen(name)) : 0;
	bool ret = false;

	while (cont != NULL) {
		if (name == NULL || tbl->namematch(cont, name, hash) == true) {
			if (newmem == true) {
				obj->name = strdup(cont->name);
				obj->data = malloc(cont->size);
				if (obj->name == NULL || obj->data == NULL) {
					if (obj->data != NULL) free(obj->data);

					obj->name = NULL;

					if (obj->name != NULL) free(obj->name);

					obj->data = NULL;
					errno = ENOMEM;
					break;
				}

				memcpy(obj->data, cont->data, cont->size);

			} else {
				obj->name = cont->name;
				obj->data = cont->data;
			}

			obj->hash = cont->hash;
			obj->size = cont->size;
			obj->prev = cont->prev;
			obj->next = cont->next;
			ret = true;

			break;
		}

		cont = (tbl->lookupforward) ? cont->next : cont->prev;
	}

	listableUnlock(tbl);

	if (ret == false) {
		errno = ENOENT;
	}

	return ret;
}