Esempio n. 1
0
void test_List_Remove(void **state)
{
    struct list_node_t nodes[3];
    struct list_t list = List_New(1);

    List_Append(&list, &nodes[0]);
    List_Append(&list, &nodes[1]);
    List_Append(&list, &nodes[2]);

    /* Try to remove a node not in the list. */
    List_Remove(&list, &nodes[3]);
    assert_ptr_equal(list.root, &nodes[0]);
    assert_ptr_equal(nodes[0].next, &nodes[1]);
    assert_ptr_equal(nodes[1].next, &nodes[2]);

    List_Remove(&list, &nodes[1]);
    assert_ptr_equal(list.root, &nodes[0]);
    assert_ptr_equal(nodes[0].next, &nodes[2]);

    List_Remove(&list, &nodes[0]);
    assert_ptr_equal(list.root, &nodes[2]);

    List_Remove(&list, &nodes[2]);
    assert_null(list.root);
}
Esempio n. 2
0
void test_List_Remove_NULL(void **state)
{
    struct list_t list;
    struct list_node_t node;

    expect_assert_failure(List_Remove(NULL, NULL));
    expect_assert_failure(List_Remove(&list, NULL));
    expect_assert_failure(List_Remove(NULL, &node));
}
Esempio n. 3
0
void PF_UnlinkEdict(edict_t *ent)
{
    if (!ent->area.prev)
        return;        // not linked in anywhere
    List_Remove(&ent->area);
    ent->area.prev = ent->area.next = NULL;
}
Esempio n. 4
0
ClcGroup* fnRemoveItemFromGroup(HWND hwnd, ClcGroup *group, ClcContact *contact, int updateTotalCount)
{
	int iContact;
	if ((iContact = List_IndexOf((SortedList*)&group->cl, contact)) == -1)
		return group;

	if (contact->type == CLCIT_CONTACT) {
		if (updateTotalCount)
			group->totalMembers--;

		ClcCacheEntry *p = cli.pfnGetCacheEntry(contact->hContact);
		if (p != NULL)
			replaceStrT(p->tszGroup, NULL);
	}

	cli.pfnFreeContact(group->cl.items[iContact]);
	mir_free(group->cl.items[iContact]);
	List_Remove((SortedList*)&group->cl, iContact);

	if ((GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_HIDEEMPTYGROUPS) && group->cl.count == 0 && group->parent != NULL)
		for (int i=0; i < group->parent->cl.count; i++)
			if (group->parent->cl.items[i]->type == CLCIT_GROUP && group->parent->cl.items[i]->groupId == group->groupId)
				return cli.pfnRemoveItemFromGroup(hwnd, group->parent, group->parent->cl.items[i], 0);

	return group;
}
Esempio n. 5
0
static INT_PTR svcHotkeyUnregister(WPARAM, LPARAM lParam)
{
	int i;
	char *pszName = (char *)lParam;
	char pszNamePrefix[MAXMODULELABELLENGTH];
	size_t cbNamePrefix;
	mir_snprintf(pszNamePrefix, _countof(pszNamePrefix), "%s$", pszName);
	cbNamePrefix = mir_strlen(pszNamePrefix);

	for (i = 0; i < hotkeys.getCount(); i++) {
		char *pszCurrentName = hotkeys[i]->rootHotkey ?
			hotkeys[i]->rootHotkey->pszName :
			hotkeys[i]->pszName;
		if (!pszCurrentName) continue;

		hotkeys[i]->UnregisterHotkey =
			!mir_strcmp(pszCurrentName, pszName) ||
			!strncmp(pszCurrentName, pszNamePrefix, cbNamePrefix);
	}

	if (g_hwndHkOptions)
		SendMessage(g_hwndHkOptions, WM_HOTKEYUNREGISTERED, 0, 0);

	for (i = 0; i < hotkeys.getCount(); i++)
		if (hotkeys[i]->UnregisterHotkey) {
			FreeHotkey(hotkeys[i]);
			List_Remove((SortedList *)&hotkeys, i);
			--i;
		}

	return 0;
}
Esempio n. 6
0
MIR_CORE_DLL(int) List_RemovePtr(SortedList* list, void* p)
{
	int idx = -1;
	if (List_GetIndex(list, p, &idx))
		List_Remove(list, idx);

	return idx;
}
Esempio n. 7
0
void _MeshVariable_Destroy( void* meshVariable, void* data ) {
   MeshVariable*	self = (MeshVariable*)meshVariable;
   
   if( self->mesh && List_Exists( self->mesh->vars, self ) )
       List_Remove( self->mesh->vars, self );

   _StgVariable_Destroy( self, data );
}
Esempio n. 8
0
void li_RemoveDestruct(SortedList *pList, int index, ItemDestuctor pItemDestructor)
{																																
	if (index>=0 && index<pList->realCount)	
	{
		pItemDestructor(pList->items[index]);
		List_Remove(pList, index);
	}
}
Esempio n. 9
0
void
List_Free(List *a) {
    while(List_Length(a) > 0) {
        List_Remove(a, 0);
    }
    Spinlock p = a->spin;
    kfree(a);
    FreeSpinlock(p);
}
Esempio n. 10
0
File: List.c Progetto: SzAllen/Arch
void List_RemoveAll(List* pNode)
{
	List* pTemp = pNode;

	while(pTemp)
	{
		pTemp = List_Remove(pNode);
	}
}
Esempio n. 11
0
void _MEM_free(void *vmem, char *file, int line) 
{
  MemHead *mem = (MemHead*)vmem;
  MemTail *tail;
  
  pthread_mutex_lock(&mem_mutex);

  if (!vmem) {
    fprintf(stderr, "Warning: tried to free NULL pointer!\n");
    fprintf(stderr, "  at line %d: file: %s\n", line, file); 
    pthread_mutex_unlock(&mem_mutex);
    return;
  }
  
  mem--;
  
  if (mem->code1 == FREECODE) {
    fprintf(stderr, "Error: Double free!\n");
    fprintf(stderr, "  at line %d: file: %s\n", line, file); 
    pthread_mutex_unlock(&mem_mutex);
    return;
  }
  
  if (!_MEM_check(vmem, file, line)) {
    tail = GET_TAIL(mem);

    fprintf(stderr, "MEM_free: Error: Corrupted memory block %p!\n", vmem);
    fprintf(stderr, "  at line %d: file: %s\n", line, file); 
    //fprintf(stderr, "[h1=%s, h2=%s, t1=%s, t2=%s] ", mem->code1, mem->code2, tail->code1, tail->code2);
    pthread_mutex_unlock(&mem_mutex);
    return;
  }
  
  tail = GET_TAIL(mem);
  
  List_Remove(&MemHeads, mem);
  List_Remove(&MemTails, tail);
  
  mem->code1 = mem->code2 = FREECODE;
  tail->code1 = tail->code2 = FREECODE;
  
  free(mem);
  pthread_mutex_unlock(&mem_mutex);
}
Esempio n. 12
0
File: evdev.c Progetto: m4son/q2pro
static void evdev_remove(evdev_t *dev)
{
    Com_DPrintf("Removing %s [%s]\n", dev->path, dev->name);

    close(dev->fd);
    Z_Free(dev->path);
    Z_Free(dev->name);
    List_Remove(&dev->entry);
    Z_Free(dev);
}
Esempio n. 13
0
static void SortGroup(struct ClcData *dat, ClcGroup *group, int useInsertionSort)
{
	int i, sortCount;

	for (i = group->cl.count - 1; i >= 0; i--) {
		if (group->cl.items[i]->type == CLCIT_DIVIDER) {
			mir_free(group->cl.items[i]);
			List_Remove((SortedList*)&group->cl, i);
		}
	}

	for (i=0; i < group->cl.count; i++)
		if (group->cl.items[i]->type != CLCIT_INFO)
			break;
	if (i > group->cl.count - 2)
		return;
	if (group->cl.items[i]->type == CLCIT_GROUP) {
		if (dat->exStyle & CLS_EX_SORTGROUPSALPHA) {
			for (sortCount = 0; i + sortCount < group->cl.count; sortCount++)
				if (group->cl.items[i + sortCount]->type != CLCIT_GROUP)
					break;
			qsort(group->cl.items + i, sortCount, sizeof(void*), GroupSortProc);
			i = i + sortCount;
		}
		for (; i < group->cl.count; i++)
			if (group->cl.items[i]->type == CLCIT_CONTACT)
				break;
		if (group->cl.count - i < 2)
			return;
	}
	for (sortCount = 0; i + sortCount < group->cl.count; sortCount++)
		if (group->cl.items[i + sortCount]->type != CLCIT_CONTACT)
			break;
	if (useInsertionSort)
		InsertionSort(group->cl.items + i, sortCount, ContactSortProc);
	else
		qsort(group->cl.items + i, sortCount, sizeof(void*), ContactSortProc);
	if (dat->exStyle & CLS_EX_DIVIDERONOFF) {
		int prevContactOnline = 0;
		for (i=0; i < group->cl.count; i++) {
			if (group->cl.items[i]->type != CLCIT_CONTACT)
				continue;
			if (group->cl.items[i]->flags & CONTACTF_ONLINE)
				prevContactOnline = 1;
			else {
				if (prevContactOnline) {
					i = cli.pfnAddItemToGroup(group, i);
					group->cl.items[i]->type = CLCIT_DIVIDER;
					mir_tstrcpy(group->cl.items[i]->szText, TranslateT("Offline"));
				}
				break;
			}
		}
	}
}
Esempio n. 14
0
void deleteModel(char *modelname)
{
    s_model *temp;
    assert(modellist);
    assert(modelname);
    makelowercp(modelname);
    if(List_FindByName(modellist, convertbuf) && (temp = List_Retrieve(modellist)))
    {
        List_Remove(modellist);
        free(temp);
    }
}
Esempio n. 15
0
static void
removeItem(int color, List_Links *list)
{
  Item *i;
  assert(!List_IsEmpty(list));
  assert(((Item *)List_First(list))->color == color);
  i = (Item *)List_First(list);
  List_Remove((List_Links *)i);
  assert(i->color == color);
  free(i);
  return;
}
Esempio n. 16
0
ListNode* List_RemoveAndReturnNext(List* list, ListNode* node)
{
	ListNode* removedNode;
	
	removedNode = List_Remove(list, node);

	if (removedNode != null)
	{
		removedNode = removedNode->nextNode;
	}

	return removedNode;
}
Esempio n. 17
0
ListNode* List_RemoveAndReturnPrev(List* list, ListNode* node)
{
	ListNode* removedNode;
	
	removedNode = List_Remove(list, node);

	if (removedNode != null)
	{
		removedNode = removedNode->prevNode;
	}

	return removedNode;
}
Esempio n. 18
0
void li_ZeroQuickList(SortedList *pList)
{
	int i;
	for (i=0; i<pList->realCount; i++)
	{
		QuickData * qd=(QuickData *)pList->items[i];
		qd->dwPos=0;
		qd->bIsService=0;
		qd->ptszValue=NULL;
		qd->ptszValueName=NULL;
		List_Remove(pList, i);
		i--;
	}
}
void
FreeFileDescriptor(uint64_t fd){

	if(fd >= fd_base)
		return;

	uint64_t index = List_Find(fds, finder, (void*)fd);
	if(index == -1)
		return;

	FileDescriptor *f_desc = List_EntryAt(fds, index);
	List_Remove(fds, index);
	free(f_desc);

	return;
}
Esempio n. 20
0
bool NavRep_PathOptimize(navmeshsize_t navmeshsize, navpath_t* navpath)
{
	navmesh_t* navmesh = &navrep.navmeshes[navmeshsize];

	navpathwaypt_t* waypoint = navpath->waypoint;
	bool bOptimized = false;

	if ( !waypoint ) return bOptimized;

	while ( waypoint->next )
	{
		navpathwaypt_t* waypoint_next = waypoint->next;

		if ( waypoint->bridge )
		{
			break;
		}
		
		if ( NavMesh_Trace(navmesh, navpath->pos, waypoint_next->position) )
		{
			bOptimized = true;

			navpath->waypoint = waypoint_next;
			List_Remove(&navpath->waypoints, waypoint);
			NavPathWaypt_Destroy(waypoint);
		}
		else 
		{
			vec2_t pos_trace;
			M_ClosestPointToSegment2d(waypoint->position, waypoint_next->position, navpath->pos, pos_trace);

			if ( NavMesh_Trace(navmesh, navpath->pos, pos_trace) )
			{
				bOptimized = true;

				M_CopyVec2(pos_trace, navpath->waypoint->position);
			}

			break;
		}

		waypoint = waypoint_next;
	}

	return bOptimized;
}
Esempio n. 21
0
void test_List_GetLength(void **state)
{
    const size_t nr_nodes = 4;
    struct list_node_t nodes[nr_nodes];
    struct list_t list = List_New(1);

    for (size_t i = 0; i < nr_nodes; ++i)
    {
        assert_int_equal(List_GetLength(&list), i);
        List_Append(&list, &nodes[i]);
    }

    for (size_t i = 0; i < nr_nodes; ++i)
    {
        assert_int_equal(List_GetLength(&list), nr_nodes - i);
        List_Remove(&list, &nodes[i]);
    }
}
Esempio n. 22
0
void GUI_Attach( TGUINode * node, TGUINode * parent ) {    
    if( parent ) {
        node->parent = parent;
        List_Add( &parent->childs, node );
        // special attachment for compound objects
        if( node->button ){
            GUI_Attach( node->button->background, parent );
            GUI_Attach( node->button->text, parent );
        } else if( node->slider ){
            GUI_Attach( node->slider->background, parent );
        }
    } else { // detach
        if( node->parent ) {
            List_Remove( &node->parent->childs, node );
        }
        node->parent = 0;
    }
}
void ListSuite_TestRemove( ListSuiteData* data ) {
   Index idx;
   Index listIndex=0;

   for( idx = 0; idx < NUM_ITEMS; idx++ ) {
      List_Append( data->list, &data->arrayData[idx] );
   }
   for( idx = 0; idx < NUM_ITEMS; idx++ ) {
      if ( idx % 2 == 0 ) {
         List_Remove( data->list, &data->arrayData[idx] );
      }
   }

   pcu_check_true( data->list->nItems == NUM_ITEMS/2 );
   listIndex=0;
   for( idx = 0; idx < NUM_ITEMS; idx++ ) {
      if ( idx % 2 == 1 ) {
         pcu_check_true( *(int*)List_GetItem( data->list, listIndex ) == idx );
         listIndex++;
      }
   }
}
Esempio n. 24
0
SO_PUBLIC void
Thread_Destroy (struct Thread *p_pThread) {
	List_Lock(sg_threadList);
	Thread_Lock(p_pThread);
//	rzb_log(LOG_ERR, "%s: Thread ref count: %d", __func__, p_pThread->refs);
	// Referece count should not drop below 1 as the list holds a ref.
	ASSERT(p_pThread->refs >= 1);
	if (p_pThread->refs > 1) {
		p_pThread->refs--;
		Thread_Unlock(p_pThread);
		List_Unlock(sg_threadList);
		return;
	}

	List_Remove(sg_threadList, p_pThread);
	// destroy running mutex
	Thread_Unlock(p_pThread);
	List_Unlock(sg_threadList);

	Mutex_Destroy (p_pThread->mMutex);

	free (p_pThread);
}
Esempio n. 25
0
void Stack_Pop(Stack *stack )
{
    List_Reset(stack);
    List_Remove(stack);
}
Esempio n. 26
0
static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	TRichUtil *ru = NULL, tru;
	int idx;
	LRESULT ret;

	tru.hwnd = hwnd;
	{
		mir_cslock lck(csRich);
		if (List_GetIndex(&sListInt, &tru, &idx))
			ru = (TRichUtil *)sListInt.items[idx];
	}

	switch (msg) {
	case WM_THEMECHANGED:
	case WM_STYLECHANGED:
		RichUtil_ClearUglyBorder(ru);
		break;

	case WM_NCPAINT:
		ret = mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam);
		if (ru->hasUglyBorder && IsThemeActive())
		{
			HANDLE hTheme = OpenThemeData(ru->hwnd, L"EDIT");

			if (hTheme) {
				RECT rcBorder;
				RECT rcClient;
				int nState;
				HDC hdc = GetWindowDC(ru->hwnd);

				GetWindowRect(hwnd, &rcBorder);
				rcBorder.right -= rcBorder.left; rcBorder.bottom -= rcBorder.top;
				rcBorder.left = rcBorder.top = 0;
				CopyRect(&rcClient, &rcBorder);
				rcClient.left += ru->rect.left;
				rcClient.top += ru->rect.top;
				rcClient.right -= ru->rect.right;
				rcClient.bottom -= ru->rect.bottom;
				ExcludeClipRect(hdc, rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);

				if (IsThemeBackgroundPartiallyTransparent(hTheme, EP_EDITTEXT, ETS_NORMAL))
					DrawThemeParentBackground(hwnd, hdc, &rcBorder);

				if (!IsWindowEnabled(hwnd))
					nState = ETS_DISABLED;
				else if (SendMessage(hwnd, EM_GETOPTIONS, 0, 0) & ECO_READONLY)
					nState = ETS_READONLY;
				else nState = ETS_NORMAL;

				DrawThemeBackground(hTheme, hdc, EP_EDITTEXT, nState, &rcBorder, NULL);
				CloseThemeData(hTheme);
				ReleaseDC(hwnd, hdc);
				return 0;
			}
		}
		return ret;

	case WM_NCCALCSIZE:
		{
			ret = mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam);
			NCCALCSIZE_PARAMS *ncsParam = (NCCALCSIZE_PARAMS *)lParam;

			if (ru->hasUglyBorder && IsThemeActive()) {
				HANDLE hTheme = OpenThemeData(hwnd, L"EDIT");
				if (hTheme) {
					RECT rcClient = {0};
					HDC hdc = GetDC(GetParent(hwnd));

					if (GetThemeBackgroundContentRect(hTheme, hdc, EP_EDITTEXT, ETS_NORMAL, &ncsParam->rgrc[0], &rcClient) == S_OK) {
						ru->rect.left = rcClient.left - ncsParam->rgrc[0].left;
						ru->rect.top = rcClient.top - ncsParam->rgrc[0].top;
						ru->rect.right = ncsParam->rgrc[0].right - rcClient.right;
						ru->rect.bottom = ncsParam->rgrc[0].bottom - rcClient.bottom;
						ncsParam->rgrc[0] = rcClient;

						CloseThemeData(hTheme);
						ReleaseDC(GetParent(hwnd), hdc);
						return WVR_REDRAW;
					}
					ReleaseDC(GetParent(hwnd), hdc);
					CloseThemeData(hTheme);
				}
			}
		}
		return ret;

	case WM_ENABLE:
		RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_NOCHILDREN | RDW_UPDATENOW | RDW_FRAME);
		break;

	case WM_GETDLGCODE:
		return mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam) & ~DLGC_HASSETSEL;

	case WM_NCDESTROY:
		ret = mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam);
		{
			mir_cslock lck(csRich);
			List_Remove(&sListInt, idx);
		}
		mir_free(ru);
		return ret;
	}
	return mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam);
}
Esempio n. 27
0
 LIST_FORALL_SAFE(movedNodes, elem, next) {
    MovedNode *fn = List_Entry(elem, MovedNode, list);
    BitClear(nodesBitmap, fn->from);
    List_Remove(elem);
    free(fn);
 }
Esempio n. 28
0
File: Arch.c Progetto: SzAllen/Arch
void Arch_MsgIfRemove(MsgIf* pMsgIf)
{
	g_pArch->m_pMsgIfList = List_Remove((List*)pMsgIf);
}
Esempio n. 29
0
File: script.c Progetto: m4son/q2pro
static qboolean Parse_File(const char *path, int depth)
{
    char *raw, *data, *p, *cmd;
    int argc;
    menuFrameWork_t *menu = NULL;
    qerror_t ret;

    ret = FS_LoadFile(path, (void **)&raw);
    if (!raw) {
        if (ret != Q_ERR_NOENT || depth) {
            Com_WPrintf("Couldn't %s %s: %s\n", depth ? "include" : "load",
                        path, Q_ErrorString(ret));
        }
        return qfalse;
    }

    data = raw;
    COM_Compress(data);

    while (*data) {
        p = strchr(data, '\n');
        if (p) {
            *p = 0;
        }

        Cmd_TokenizeString(data, qtrue);

        argc = Cmd_Argc();
        if (argc) {
            cmd = Cmd_Argv(0);
            if (menu) {
                if (!strcmp(cmd, "end")) {
                    if (menu->nitems) {
                        List_Append(&ui_menus, &menu->entry);
                    } else {
                        Com_WPrintf("Menu entry without items\n");
                        menu->free(menu);
                    }
                    menu = NULL;
                } else if (!strcmp(cmd, "title")) {
                    if (menu->title) {
                        Z_Free(menu->title);
                    }
                    menu->title = UI_CopyString(Cmd_Argv(1));
                } else if (!strcmp(cmd, "plaque")) {
                    Parse_Plaque(menu);
                } else if (!strcmp(cmd, "banner")) {
                    Parse_Banner(menu);
                } else if (!strcmp(cmd, "background")) {
                    Parse_Background(menu);
                } else if (!strcmp(cmd, "style")) {
                    Parse_Style(menu);
                } else if (!strcmp(cmd, "values")) {
                    Parse_Spin(menu, MTYPE_SPINCONTROL);
                } else if (!strcmp(cmd, "strings")) {
                    Parse_Spin(menu, MTYPE_STRINGS);
                } else if (!strcmp(cmd, "pairs")) {
                    Parse_Pairs(menu);
                } else if (!strcmp(cmd, "range")) {
                    Parse_Range(menu);
                } else if (!strcmp(cmd, "action")) {
                    Parse_Action(menu);
                } else if (!strcmp(cmd, "bitmap")) {
                    Parse_Bitmap(menu);
                } else if (!strcmp(cmd, "bind")) {
                    Parse_Bind(menu);
                } else if (!strcmp(cmd, "savegame")) {
                    Parse_Savegame(menu, MTYPE_SAVEGAME);
                } else if (!strcmp(cmd, "loadgame")) {
                    Parse_Savegame(menu, MTYPE_LOADGAME);
                } else if (!strcmp(cmd, "toggle")) {
                    Parse_Toggle(menu);
                } else if (!strcmp(cmd, "field")) {
                    Parse_Field(menu);
                } else if (!strcmp(cmd, "blank")) {
                    Parse_Blank(menu);
                } else {
                    Com_WPrintf("Unknown keyword '%s'\n", cmd);
                }
            } else {
                if (!strcmp(cmd, "begin")) {
                    char *s = Cmd_Argv(1);
                    if (!*s) {
                        Com_WPrintf("Expected menu name after '%s'\n", cmd);
                        break;
                    }
                    menu = UI_FindMenu(s);
                    if (menu) {
                        if (menu->free) {
                            menu->free(menu);
                        }
                        List_Remove(&menu->entry);
                    }
                    menu = UI_Mallocz(sizeof(*menu));
                    menu->name = UI_CopyString(s);
                    menu->push = Menu_Push;
                    menu->pop = Menu_Pop;
                    menu->free = Menu_Free;
                    menu->image = uis.backgroundHandle;
                    menu->color.u32 = uis.color.background.u32;
                    menu->transparent = uis.transparent;
                } else if (!strcmp(cmd, "include")) {
                    char *s = Cmd_Argv(1);
                    if (!*s) {
                        Com_WPrintf("Expected file name after '%s'\n", cmd);
                        break;
                    }
                    if (depth == 16) {
                        Com_WPrintf("Includes too deeply nested\n");
                    } else {
                        Parse_File(s, depth + 1);
                    }
                } else if (!strcmp(cmd, "color")) {
                    Parse_Color();
                } else if (!strcmp(cmd, "background")) {
                    char *s = Cmd_Argv(1);

                    if (SCR_ParseColor(s, &uis.color.background)) {
                        uis.backgroundHandle = 0;
                        uis.transparent = uis.color.background.u8[3] != 255;
                    } else {
                        uis.backgroundHandle = R_RegisterPic(s);
                        uis.transparent = R_GetPicSize(NULL, NULL, uis.backgroundHandle);
                    }
                } else if (!strcmp(cmd, "font")) {
                    uis.fontHandle = R_RegisterFont(Cmd_Argv(1));
                } else if (!strcmp(cmd, "cursor")) {
                    uis.cursorHandle = R_RegisterPic(Cmd_Argv(1));
                    R_GetPicSize(&uis.cursorWidth,
                                 &uis.cursorHeight, uis.cursorHandle);
                } else if (!strcmp(cmd, "weapon")) {
                    Cmd_ArgvBuffer(1, uis.weaponModel, sizeof(uis.weaponModel));
                } else {
                    Com_WPrintf("Unknown keyword '%s'\n", cmd);
                    break;
                }
            }
        }

        if (!p) {
            break;
        }

        data = p + 1;
    }

    FS_FreeFile(raw);

    if (menu) {
        Com_WPrintf("Menu entry without 'end' terminator\n");
        menu->free(menu);
    }

    return qtrue;
}
Esempio n. 30
0
static INT_PTR CALLBACK FtMgrPageDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	struct TFtPageData *dat = (struct TFtPageData *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
	int i;

	switch (msg) {
	case WM_INITDIALOG:
		{
			// Force scrollbar visibility
			SCROLLINFO si = {0};
			si.cbSize = sizeof(si);
			si.fMask = SIF_DISABLENOSCROLL;
			SetScrollInfo(hwnd, SB_VERT, &si, TRUE);

			dat = (struct TFtPageData *)mir_alloc(sizeof(struct TFtPageData));
			dat->wnds = (struct TLayoutWindowList *)List_Create(0, 1);
			dat->scrollPos = 0;
			dat->runningCount = 0;
			SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)dat);
		}
		break;

	case WM_FT_ADD:
		{
			TLayoutWindowInfo *wnd = (struct TLayoutWindowInfo *)mir_alloc(sizeof(struct TLayoutWindowInfo));
			wnd->hwnd = (HWND)lParam;
			GetWindowRect(wnd->hwnd, &wnd->rc);
			List_Insert((SortedList *)dat->wnds, wnd, dat->wnds->realCount);
			LayoutTransfers(hwnd, dat);
			dat->runningCount++;
			PostMessage(GetParent(hwnd), WM_TIMER, 1, NULL);
		}
		break;

	case WM_FT_RESIZE:
		for (i=0; i < dat->wnds->realCount; ++i)
			if (dat->wnds->items[i]->hwnd == (HWND)lParam) {
				GetWindowRect(dat->wnds->items[i]->hwnd, &dat->wnds->items[i]->rc);
				break;
			}
		LayoutTransfers(hwnd, dat);
		break;

	case WM_FT_REMOVE:
		for (i=0; i < dat->wnds->realCount; ++i)
			if (dat->wnds->items[i]->hwnd == (HWND)lParam) {
				mir_free(dat->wnds->items[i]);
				List_Remove((SortedList *)dat->wnds, i);
				break;
			}
		LayoutTransfers(hwnd, dat);
		break;

	case WM_FT_COMPLETED:
		//wParam: { ACKRESULT_SUCCESS | ACKRESULT_FAILED | ACKRESULT_DENIED }
		dat->runningCount--;
		for (i=0; i < dat->wnds->realCount; i++) {
			// no error when canceling (WM_FT_REMOVE is send first, check if hwnd is still registered)
			if (dat->wnds->items[i]->hwnd == (HWND)lParam) {
				SendMessage(GetParent(hwnd), WM_TIMER, 1, (LPARAM)wParam);
				break;
			}
		}
		if (i == dat->wnds->realCount)
			PostMessage(GetParent(hwnd), WM_TIMER, 1, NULL);

		if(dat->runningCount == 0 && wParam == ACKRESULT_SUCCESS && db_get_b(NULL, "SRFile", "AutoClose", 0))
			ShowWindow(hwndFtMgr, SW_HIDE);
		break;

	case WM_FT_CLEANUP:
		for (i=0; i < dat->wnds->realCount; ++i)
			SendMessage(dat->wnds->items[i]->hwnd, WM_FT_CLEANUP, wParam, lParam);
		break;

	case WM_SIZE:
		LayoutTransfers(hwnd, dat);
		break;

	case WM_MOUSEWHEEL:
		{
			int zDelta = GET_WHEEL_DELTA_WPARAM(wParam);
			if (zDelta) {
				int nScrollLines = 0;
				SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, (void*)&nScrollLines, 0);
				for (i=0; i < (nScrollLines + 1) / 2; i++)
					SendMessage(hwnd, WM_VSCROLL, (zDelta < 0) ? SB_LINEDOWN : SB_LINEUP, 0);
			}

			SetWindowLongPtr(hwnd, DWLP_MSGRESULT, 0);
			return TRUE;
		}

	case WM_VSCROLL:
		{
			int pos = dat->scrollPos;
			switch (LOWORD(wParam)) {
			case SB_LINEDOWN:
				pos += 15;
				break;
			case SB_LINEUP:
				pos -= 15;
				break;
			case SB_PAGEDOWN:
				pos += dat->height - 10;
				break;
			case SB_PAGEUP:
				pos -= dat->height - 10;
				break;
			case SB_THUMBTRACK:
				pos = HIWORD(wParam);
				break;
			}

			if (pos > dat->dataHeight - dat->height) pos = dat->dataHeight - dat->height;
			if (pos < 0) pos = 0;

			if (dat->scrollPos != pos) {
				ScrollWindow(hwnd, 0, dat->scrollPos - pos, NULL, NULL);
				SetScrollPos(hwnd, SB_VERT, pos, TRUE);
				dat->scrollPos = pos;
			}
			break;
		}

	case M_PRESHUTDOWN:
		for (i=0; i < dat->wnds->realCount; ++i)
			PostMessage(dat->wnds->items[i]->hwnd, WM_COMMAND, MAKEWPARAM(IDCANCEL, BN_CLICKED), 0);
		break;

	case M_CALCPROGRESS:
		{
			TFtProgressData *prg = (TFtProgressData *)wParam;
			for (i=0; i < dat->wnds->realCount; ++i) {
				FileDlgData *trdat = (FileDlgData *)GetWindowLongPtr(dat->wnds->items[i]->hwnd, GWLP_USERDATA);
				if (trdat->transferStatus.totalBytes && trdat->fs && !trdat->send && (trdat->transferStatus.totalBytes == trdat->transferStatus.totalProgress))
					prg->scan++;
				else if (trdat->transferStatus.totalBytes && trdat->fs) { // in progress
					prg->run++;
					prg->totalBytes += trdat->transferStatus.totalBytes;
					prg->totalProgress += trdat->transferStatus.totalProgress;
				}
				else if (trdat->fs) // starting
					prg->init++;
			}
		}
		break;

	case WM_DESTROY:
		for (i=0; i < dat->wnds->realCount; ++i)
			mir_free(dat->wnds->items[i]);
		List_Destroy((SortedList *)dat->wnds);
		mir_free(dat->wnds);
		mir_free(dat);
		break;
	}

	return FALSE;
}