Exemple #1
0
/* delete commands from the head */
int DelCmd(tLinkTable *head, const char * cmd)
{
    tDataNode *p;
    p = FindCmd(head, (char*)cmd);
    if(p==NULL)
    {
         printf("command is not exist!\n");
         return FAILURE;
    }
    else
    {
        DelLinkTableNode(head,(tLinkTableNode *)p);
        free(p);
        p=NULL;
        return SUCCESS;
    }

}
Exemple #2
0
/* Delete Cmd from linklist */
int DelCmd(char *cmd)
{
    tDataNode *pNode = NULL;
    
    if(head == NULL || cmd == NULL)
    {
        return FAILURE;
    }
    
    pNode = FindCmd(cmd);
    /* Check if the cmd is existence */
    if(pNode == NULL)
    {
        return FAILURE;
    }

    return DelLinkTableNode(head, (tLinkTableNode *)pNode);
}
Exemple #3
0
/*
 * run del cmd
 */
int Del(tLinkTable * pLinkTable)
{
    char DelCmd[CMD_MAX_LEN];
    tDataNode * pTempNode;
    if(pLinkTable == NULL)
    {
        return FAILURE;
    }
    printf("Plase input DelCmd name > ");
    scanf("%s", DelCmd);
    pTempNode = FindCmd(pLinkTable, DelCmd);
    if(pTempNode == NULL)
    {
        printf("Cmd is not existed!\n");
        return FAILURE;
    }
    DelLinkTableNode(pLinkTable, (tLinkTableNode * )pTempNode);
    
    return SUCCESS;
}
Exemple #4
0
int main()
{
    int i;
    tLinkTable * pLinkTable = CreateLinkTable();
    for(i = 0; i < 10; i++)
    {
        tNode* pNode = (tNode*)malloc(sizeof(tNode));
        pNode->data = i;
        debug("AddLinkTableNode\n");
        AddLinkTableNode(pLinkTable,(tLinkTableNode *)pNode);
    }
    /* search by callback */
    debug("SearchLinkTableNode\n");
    tNode* pTempNode = (tNode*)SearchLinkTableNode(pLinkTable,SearchConditon);
    printf("%d\n",pTempNode->data);
    /* search one by one */
    pTempNode = Search(pLinkTable);
    printf("%d\n",pTempNode->data);
    debug("DelLinkTableNode\n");
    DelLinkTableNode(pLinkTable,(tLinkTableNode *)pTempNode);
    free(pTempNode);
    DeleteLinkTable(pLinkTable);
}
Exemple #5
0
/* Delete MenuItem from Menu */
int DeleteMenuItem(tLinkTable * head, char* cmdname)
{
    tMenuItem* p = SearchMenuItem(head, cmdname);
    return DelLinkTableNode(head,(tLinkTableNode *) p);
}