Exemplo n.º 1
0
void DeletePermanent(Permanent* permanent) {
    if (permanent->equipment)
        DeleteList(permanent->equipment);
    if (permanent->abilities)
        DeleteList(permanent->abilities);
    free(permanent);
    
}
Exemplo n.º 2
0
bool MTGPlayer_tap(MTGPlayer* player,Permanent* permanent) {
    List* options = InitList();
    char buffer[256];
    char* c = buffer;
    for (unsigned int i=0;i<permanent->abilities->size;i++) {
        char* s = c;
        Ability* a = permanent->abilities->entries[i];
        for (unsigned int j=0;j<a->manaCost->size;j++) {
            Manacost* m = a->manaCost->entries[j];
            char color;
            switch (m->color1) {
                case WHITE:
                    color = 'W';
                    break;
                case BLUE:
                    color = 'U';
                    break;
                case BLACK:
                    color = 'B';
                    break;
                case RED:
                    color = 'R';
                    break;
                case GREEN:
                    color = 'G';
                    break;
                case COLORLESS:
                    color = ' ';
                    break;
            }
            c += sprintf(c,"{%d%c}",m->num,color);
        }
        c += sprintf(c,"%s",a->needs_tap?"{T}":"") + 1;
        AppendToList(options, s);
    }
    if (permanent->subtypes.is_land) {
        if (permanent->subtypes.is_plains) AppendToList(options, "W");
        if (permanent->subtypes.is_island) AppendToList(options, "U");
        if (permanent->subtypes.is_swamp) AppendToList(options, "B");
        if (permanent->subtypes.is_mountain) AppendToList(options, "R");
        if (permanent->subtypes.is_forest) AppendToList(options, "G");
        if (permanent->source == cd.DarksteelCitadel) AppendToList(options, "C");
        permanent->is_tapped = true;
    }
    if (options->size > 1) {
        if (player == player1)
            selectAbility(permanent,options);
        else
            AI_selectAbility(permanent,options);
        DeleteList(options);
        return false;
    } else {
        permanent->selectedAbility = 1;
        DeleteList(options);
        return true;
    }
}
Exemplo n.º 3
0
void main()
{
	struct node* a = PushAtHead(10);
	PrintList(a);
	struct node* b = PushAtHead(5);
	PrintList(b);
	Append(&a, &b);
	PrintList(a);
	PrintList(b);
	DeleteList(&a);
	DeleteList(&b);
}
Exemplo n.º 4
0
bool OperCFThread::DeleteDir( FS* fs, FSPath& path )
{
	if ( Info()->Stopped() ) { return false; }

	FSList list;

	while ( true )
	{
		int ret_err;
		int ret = fs->ReadDir( &list, path, &ret_err, Info() );

		if ( ret == -2 ) { return false; }

		if ( !ret ) { break; }

		switch ( RedMessage( _LT( "Can`t open directory:\n" ), fs->Uri( path ).GetUtf8(), bRetrySkipCancel, fs->StrError( ret_err ).GetUtf8() ) )
		{
			case CMD_SKIP:
				return true;

			case CMD_RETRY:
				continue;

			default:
				return false;
		}
	}

	return DeleteList( fs, path, list );
}
Exemplo n.º 5
0
// 5 — InsertNth()
void InsertNthTest() {
	struct node* head = NULL; // start with the empty list
	InsertNth(&head, 0, 13); // build {13)
	InsertNth(&head, 1, 42); // build {13, 42}
	InsertNth(&head, 1, 5); // build {13, 5, 42}
	DeleteList(&head); // clean up after ourselves
}
main()
{
	struct node *head = malloc(sizeof(struct node));
	head = Build(); // {1,2,3}
	len(head);
	DeleteList(&head);
}
Exemplo n.º 7
0
// 17 — Reverse()
void ReverseTest() {
	struct node* head;
	head = BuildOneTwoThree();
	Reverse(&head);
	// head now points to the list {3, 2, 1}
	DeleteList(&head); // clean up after ourselves
}
Exemplo n.º 8
0
static void cancelDownloadCallback(GtkWidget *button, BrowserDownloadDialog *dialog)
{
    GtkTreeModel * model;
    GtkTreeIter iter;
    WebKitDownload *wkDownload;

    if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(dialog->select), &model, &iter))
    {
        gtk_tree_model_get (GTK_TREE_MODEL(dialog->model), &iter, 7, &wkDownload, -1);
        if(wkDownload)
        {
            webkit_download_cancel(WEBKIT_DOWNLOAD(wkDownload));
            gtk_list_store_remove(dialog->model, &iter);
            return;
        }

        char *treeviewIndex = g_strdup_printf("%s", gtk_tree_model_get_string_from_iter(GTK_TREE_MODEL(dialog->model), &iter));
        if(treeviewIndex)
        {
            size_t listIndex = atoi(treeviewIndex);
            DeleteList(dialog->download,listIndex);
        }
        g_printerr("store_remove\n");
        gtk_list_store_remove(dialog->model, &iter);
    }
}
Exemplo n.º 9
0
CDialogList::~CDialogList()
{
	DeleteList();
	
	if(m_pMalloc)
		m_pMalloc->Release();
}
Exemplo n.º 10
0
// CreateList assumes the pointer is at the head of the list.
// Only pass m_head through here!!!
void EndpointAddrlist::CreateList( struct addrinfo* list )
{
        int count = 1;
        DeleteList();

        // curList_addr = current node in 'list'
//  EndpointAddress *curList_addr = (EndpointAddress*) list;
        addrinfo *curList_addr = list;
        // curM_addr = current node in our class' vector
        EndpointAddress curM_addr;

        if( !list ) {
                return;
        }

        while( curList_addr != NULL ) {
                count++;
                curM_addr = *curList_addr;

                // explicitly set ai_next = 0 since the vector iterators are used instead.
                curM_addr.ai_next = 0;

                //finalize
                m_addrlist.push_back(curM_addr);
                curList_addr = (EndpointAddress*) curList_addr->ai_next;
        }
        m_addrs = m_addrlist.begin();

        return;
}
Exemplo n.º 11
0
int main()
{
	List L;
	Position P;
	int X;

	L = (Position) malloc(sizeof(struct Node));
	L->Next = NULL;
	L->Element = -1;

	initList(L);
	printf("print list:\n");
	PrintList(L);

	return 0;

	printf("input a num:");
	scanf("%d", &X);

	P = FindPrevious(X, L);
	if(P == NULL)
		printf("can't find the num:%d previous num\n", X);
	else
		printf("Previous num is:%d, address is :0x%p\n", P->Element, P->Next);

	DeleteList(L);

	return 0;
}
Exemplo n.º 12
0
void CheckAce(char *type, char *name, Bool verbose)
{
  char *args[2], buf[BUFSIZ];
  int status;

  if (strcmp(type, "LIST"))
    return;		/* If the ace is not a list the ignore it. */

  args[0] = type;
  args[1] = name;
  status = do_mr_query("get_ace_use", 2, args, NULL, NULL);
  if (status != MR_NO_MATCH)
    return;			/* If this query fails the ace will
				   not be deleted even if it is empty. */
  if (verbose)
    {
      sprintf(buf, "Delete the unused Access Control Entity (ACE) %s? ", name);
      if (YesNoQuestion(buf, FALSE) != TRUE)
	{
	  Put_message("Aborting Deletion!");
	  return;
	}
    }
  /*
   * Delete the ACE.
   *
   * NOTE: Delete list expects only the name of the list to delete in argv[1].
   *       since, 'args' already satisfies this, there is no need to create
   *       a special argument list.
   */
  DeleteList(2, args);
}
Exemplo n.º 13
0
int DeleteUserGroup(char *name, Bool verbose)
{
  int status, ans;
  char buf[BUFSIZ], *args[10];

  status = do_mr_query("get_list_info", 1, &name, NULL, NULL);
  if (!status)
    {
      if (verbose)
	{
	  sprintf(buf, "There is also a list named %s, delete it?", name);
	  ans = YesNoQuestion(buf, FALSE);
	  if (ans == FALSE)
	    {
	      Put_message("Leaving group alone.");
	      return SUB_NORMAL;
	    }
	  if (ans < 0)
	    {
	      Put_message("Aborting...");
	      return SUB_ERROR;
	    }
	}
      /* ans == TRUE  || ~verbose */
      args[0] = "foo";	/* not used. */
      args[1] = name;
      DeleteList(2, args);
    }
  else if (status != MR_NO_MATCH)
    {
      com_err(program_name, status, " Aborting Delete User.");
      return SUB_ERROR;
    }
  return SUB_NORMAL;
}
Exemplo n.º 14
0
void main()
{	
	struct node* head = AddAtTail();
	printf("List len = %d\n", ListLen(head));
	PrintList(head);
	DeleteList(head);
}
Exemplo n.º 15
0
int main()
{
	char ch[10],num[5];
	LinkList head;
	head=CreatList();
	printlist(head);
	printf(" Delete node (y/n):");
	scanf("%s",num);
	if(strcmp(num,"y")==0||strcmp(num,"Y")==0) 
	{
		printf("Please input Delete_data:");
		scanf("%s",ch);
		DeleteList(head,ch);
		printlist(head);
	}
	printf("Add node ? (y/n): ");
	scanf("%s",ch);
	if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0)
	{
		head=AddNode(head);
	}
	printlist(head);
	system("pause");
	DeleteAll(head);
}
Exemplo n.º 16
0
int main (int argc, char* argv[])
{
  int dataInt[] = {1, 2, 3, 4, 5};
  CSinglyListNode* head = CreateTestList(dataInt, 5);
  PrintList(head);

  // RemoveHead
  RemoveHead(&head);
  PrintList(head);
  RemoveHead(&head);
  PrintList(head);
  RemoveHead(&head);
  PrintList(head);
  RemoveHead(&head);
  PrintList(head);
  RemoveHead(&head);
  PrintList(head);
  RemoveHead(&head);
  PrintList(head);

  std::cout << "DeleteList..." << std::endl;
  DeleteList(&head);
  std::cout << "head now : " << head << std::endl;
  PrintList(head);

  std::cout << "bye" << std::endl;
  return 0;
}
bool
BF_GUI_FilesPanel_DeleteTask::DeleteList(BF_NodeCollection & lo_Node)
{
    BF_Node  	*poNode;
    status_t	uRes;
    BL_String   s;

    for(int i=0; i<lo_Node.CountItems(); i++) {
        poNode = (BF_Node*)lo_Node.ItemAt(i);

        if(poNode->iType==BF_NODE_TYPE_DIR) {
            // check folder_path+name //
            ASSERT(lo_Node.poPath);
            s = lo_Node.poPath->Path();
            s << "/";
            s << poNode->sName;
            if(!CheckFolder_ForSys(s.String())) {
                return false;
            }
        }

        if(poNode->ploChild) {
            DeleteList(*poNode->ploChild);
        }
        // check, remove file or move it to trash
        if(BF_FILESPANEL_DELETE_TO_VOID==iDeleteType) {
            BF_Roster_RemoveNode(*lo_Node.poPath,poNode);
        } else if(BF_FILESPANEL_DELETE_TO_TRASH==iDeleteType) {
            int64		iIndex = 1;
            char		*pcName=NULL;
            while(TRUE) {
                uRes = BF_Roster_MoveNode(*lo_Node.poPath,poNode,sTrashPath.String(),pcName);
                if(B_OK==uRes) break;
                /* try to move to new name */
                if(B_FILE_EXISTS==uRes) {
                    s=poNode->sName;
                    s<<" ";
                    s<<iIndex++;
                    pcName = (char*)s.String();
                    continue;
                }
                /* ups....some error */
                BL_System_TranslError(uRes,s);

                BL_List	*ploMenu = new BL_List();
                ploMenu->AddItem(new BF_GUI_ViewMenu_Item(BF_DictAt(BF_DICT_TRYAGAIN),"try"));
                ploMenu->AddItem(new BF_GUI_ViewMenu_Item(BF_DictAt(BF_DICT_SKIP),"skip"));

                if(1==Ask_Message(s.String(),ploMenu)) break;
            }
        }
        //
        SetProgress(++iOperIndex,iOperCount);
        /* check for cancel_process */
        if(Canceled()) return false;

    }
    return true;
}
Exemplo n.º 18
0
MainObject::MainObject(QObject *parent,const char *name)
    : QObject(parent,name)
{
    //
    // Read Command Options
    //
    RDCmdSwitch *cmd=
        new RDCmdSwitch(qApp->argc(),qApp->argv(),"sas_filter",SAS_FILTER_USAGE);
    delete cmd;

    rd_config=new RDConfig(RD_CONF_FILE);
    rd_config->load();
    filter_switch_count=0;
    filter_macro_count=0;

    //
    // Open Database
    //
    QString err(tr("sas_filter: "));
    filter_db=RDInitDb (&err);
    if(!filter_db) {
        fprintf(stderr,"%s\n",err.ascii());
        exit(1);
    }

    //
    // RIPCD Connection
    //
    filter_ripc=new RDRipc("");
    filter_ripc->connectHost("localhost",RIPCD_TCP_PORT,rd_config->password());

    //
    // Station Configuration
    //
    filter_rdstation=new RDStation(rd_config->stationName());

    //
    // RDCatchd Connection
    //
    filter_connect=new RDCatchConnect(0,this,"filter_connect");
    filter_connect->connectHost("localhost",RDCATCHD_TCP_PORT,
                                rd_config->password());

    //
    // Read Switches
    //
    if((qApp->argc()==2)&&(!strcmp(qApp->argv()[1],"-d"))) {   // Delete List
        DeleteList();
        filter_connect->reset();
        exit(0);
    }
    if((qApp->argc()==3)&&(!strcmp(qApp->argv()[1],"-i"))) {   // Insert List
        InsertList();
        filter_connect->reset();
        exit(0);
    }
    fprintf(stderr,"\nsas_filter %s\n",SAS_FILTER_USAGE);
    exit(1);
}
Exemplo n.º 19
0
int main(void)
{
    printf("string : %s\n", string);
    ReverseWordsInAString(string);
    printf("Reverse string : %s\n", string);
    DeleteList(&head);
    return 0x00;
}
Exemplo n.º 20
0
void RayTracer::DeleteList() {
	AnObject *obj;
	ALight *lobj;

	while (objectList) {
		DeleteList(objectList->obj);
		DeleteList(objectList->negobj);
		obj = objectList->next;
		delete objectList;
		objectList = obj;
	}
	while (lightList) {
		lobj = (ALight *)lightList->next;
		delete lightList;
		lightList = lobj;
	}
}
Exemplo n.º 21
0
void ReverseTest() {
	struct node* head;
	head = BuildOneTwoThree();
	display(head);
	Reverse(&head);
	display(head);
	
	DeleteList(&head); 
}
Exemplo n.º 22
0
void DeleteHashTable(int NUM_OF_ENTRY, int *hdTable){
	int i;
	int *hdList;
	for(i = 0; i < NUM_OF_ENTRY; i++){
		hdList = ReadHashTable(hdTable, i);	
		hdList = DeleteList(hdList);
	}		
	SysFree(hdTable);
}
Exemplo n.º 23
0
List MakeEmpty(List L) {
    if (L != NULL) {
        DeleteList(L);
    }
    L = malloc(sizeof(struct Node));
    if (L == NULL) {
        
    }
}
Exemplo n.º 24
0
main()
{
	struct node* head = build123();
	printdata(head);
	printf("1 occur %d times\n",count(head,1));
	printf("3 occur %d times\n",count(head,3));
	printf("10 occur %d times\n",count(head,10));
	printf("0th element is %d \n",GetNth(head,0));
	DeleteList(&head);
}
Exemplo n.º 25
0
void DeleteMap(Map* mp) {
	if (!mp) return;
	unsigned int i;
	for (i=0; i<mp->tb->size; i++) {
		void* ls = mp->tb->entries[i];
		if (ls&&ls!=mp->tb->dummy) DeleteList(ls);	
	}
	DeleteHashTable(mp->tb);
	free(mp);
}
Exemplo n.º 26
0
/*=====empties and deletes the list======*/
head MakeEmpty( head h )
{
  if( h != NULL )
    DeleteList( h );
  h = malloc( sizeof( struct Node ) );
  if( h == NULL )
    printf( "Out of memory!" );
  h->next = NULL;
  return h;
}
Exemplo n.º 27
0
List MakeEmpty(List list)
{
    if(list != NULL)
        DeleteList(list);
    list = malloc(sizeof(struct Node));
    if (list == NULL)
        printf("out of memory!");
    list->next = NULL;
    return list;
}
Exemplo n.º 28
0
void main()
{
	LIST *Cur,*First=new LIST;
	First->next=NULL;
	srand(time(NULL));
	for(int i=0;i<10;++i)
	{
		if(!First->next)
		{
			Cur=new LIST;
			First->next=Cur;
		}
		else
		{
			Cur->next=new LIST;
			Cur=Cur->next;
		}
		CreateList(Cur);
	}
	Cur=First;
	PrintList(Cur);
	int b;
	int n;
	while(1)
	{
		printf("\n\n1-add\n2-delete\n3-count\n");
		scanf("%d",&b);
		switch(b)
		{
		case 1:
			printf("\nNumber of elem\n");
			scanf("%d",&n);
			Cur=First;
			AddList(Cur,n);
			Cur=First;
			PrintList(Cur);
			break;
		case 2:
			printf("\nNumber of elem\n");
			scanf("%d",&n);
			Cur=First;
			DeleteList(Cur,n);
			Cur=First;
			PrintList(Cur);
			break;
		case 3:
			printf("\nNumber of elem\n");
			scanf("%d",&n);
			Cur=First;
			GetCount(Cur,n);
			break;
		}
	}
	
}
Exemplo n.º 29
0
 List
 MakeEmpty( List L )
 {
     if( L != NULL )
         DeleteList( L );
     L = malloc( sizeof( struct Node ) );
     if( L == NULL )
         FatalError( "Out of memory!" );
     L->Next = NULL;
     return L;
 }
Exemplo n.º 30
0
void InsertNthTest() {
	struct node* head = NULL; 
	InsertNth(&head, 0, 13); 
	InsertNth(&head, 1, 42);
	InsertNth(&head, 1, 5); 
	int len = Length(head);
	printf("%d\n", len);
	DeleteList(&head); 
	len = Length(head);
	printf("%d\n", len);
}