Пример #1
0
void test_linkListHeadRemove_the_element_of_head_was_removed_and_the_head_point_the_next_of_head(void){

  Tcb* temp;

  LinkedlistTcb* root = &tcbRoot;



  addList(root,&task1Tcb);

  addList(root,&task2Tcb);

  addList(root,&taskCPU);



  temp = linkListHeadRemove(root);



  UnityAssertEqualNumber((_U_SINT)(_UP)((&task2Tcb)), (_U_SINT)(_UP)((root->head)), (((void *)0)), (_U_UINT)(75), UNITY_DISPLAY_STYLE_HEX32);

  UnityAssertEqualNumber((_U_SINT)(_UP)((&task1Tcb)), (_U_SINT)(_UP)((temp)), (((void *)0)), (_U_UINT)(76), UNITY_DISPLAY_STYLE_HEX32);

  if ((((temp->next)) == ((void *)0))) {} else {UnityFail( (((" Expected NULL"))), (_U_UINT)((_U_UINT)((_U_UINT)(77))));};

}
Пример #2
0
void test_addList_add_task1Tcb_task2Tcb_and_taskCPU_into_linked_list_The_list_should_contain_three_element(void){

  LinkedlistTcb* root = &tcbRoot;

  initTask1Tcb(taskOne);

  initTask2Tcb(taskTwo);

  initTaskCPU();

  tcbRootInit();

  addList(root,&task1Tcb);

  addList(root,&task2Tcb);

  addList(root,&taskCPU);

  UnityAssertEqualNumber((_U_SINT)(_UP)((&task1Tcb)), (_U_SINT)(_UP)((root->head)), (((void *)0)), (_U_UINT)(59), UNITY_DISPLAY_STYLE_HEX32);

  UnityAssertEqualNumber((_U_SINT)(_UP)((&task2Tcb)), (_U_SINT)(_UP)((root->head->next)), (((void *)0)), (_U_UINT)(60), UNITY_DISPLAY_STYLE_HEX32);

  UnityAssertEqualNumber((_U_SINT)(_UP)((&taskCPU)), (_U_SINT)(_UP)((root->head->next->next)), (((void *)0)), (_U_UINT)(61), UNITY_DISPLAY_STYLE_HEX32);

}
Пример #3
0
// Build up the stored settings into the passed DOM objects
void PDFOptionsIO::buildSettings()
{
	addElem(m_root, "firstUse", m_opts->firstUse);
	addElem(m_root, "thumbnails", m_opts->Thumbnails);
	addElem(m_root, "articles", m_opts->Articles);
	addElem(m_root, "useLayers", m_opts->useLayers);
	addElem(m_root, "compress", m_opts->Compress);
	addElem(m_root, "compressMethod", m_opts->CompressMethod);
	addElem(m_root, "quality", m_opts->Quality);
	addElem(m_root, "recalcPic", m_opts->RecalcPic);
	addElem(m_root, "bookmarks", m_opts->Bookmarks);
	addElem(m_root, "picRes", m_opts->PicRes);
	addElem(m_root, "embedPDF", m_opts->embedPDF);
	QString pdfVersString;
	switch (m_opts->Version)
	{
		case PDFOptions::PDFVersion_X3:
			pdfVersString = "X3";
			break;
		default:
			pdfVersString = QString::number(m_opts->Version);
			break;
	}
	addElem(m_root, "pdfVersion", pdfVersString);
	addElem(m_root, "resolution", m_opts->Resolution);
	addElem(m_root, "binding", m_opts->Binding);
	addList(m_root, "embedFonts", m_opts->EmbedList);
	addList(m_root, "subsetFonts", m_opts->SubsetList);
	addElem(m_root, "mirrorH", m_opts->MirrorH);
	addElem(m_root, "mirrorV", m_opts->MirrorV);
	addElem(m_root, "rotateDegrees", m_opts->RotateDeg);
	addElem(m_root, "presentMode", m_opts->PresentMode);
	addPresentationData();
	addElem(m_root, "filename", m_opts->fileName);
	addElem(m_root, "isGrayscale", m_opts->isGrayscale);
	addElem(m_root, "useRGB", m_opts->UseRGB);
	addElem(m_root, "useProfiles", m_opts->UseProfiles);
	addElem(m_root, "useProfiles2", m_opts->UseProfiles2);
	addElem(m_root, "useLPI", m_opts->UseLPI);
	addElem(m_root, "useSpotColors", m_opts->UseSpotColors);
	addElem(m_root, "doMultiFile", m_opts->doMultiFile);
	addLPISettings();
	addElem(m_root, "solidProf", m_opts->SolidProf);
	addElem(m_root, "sComp", m_opts->SComp);
	addElem(m_root, "imageProf", m_opts->ImageProf);
	addElem(m_root, "embeddedI", m_opts->EmbeddedI);
	addElem(m_root, "intent2", m_opts->Intent2);
	addElem(m_root, "printProf", m_opts->PrintProf);
	addElem(m_root, "info", m_opts->Info);
	addElem(m_root, "intent", m_opts->Intent);
	addElem(m_root, "bleedTop", m_opts->bleeds.Top);
	addElem(m_root, "bleedLeft", m_opts->bleeds.Left);
	addElem(m_root, "bleedRight", m_opts->bleeds.Right);
	addElem(m_root, "bleedBottom", m_opts->bleeds.Bottom);
	addElem(m_root, "encrypt", m_opts->Encrypt);
	addElem(m_root, "passOwner", m_includePasswords ? m_opts->PassOwner : "");
	addElem(m_root, "passUser", m_includePasswords ? m_opts->PassUser : "");
	addElem(m_root, "permissions", m_opts->Permissions);
}
void check_patients_assess_par(struct Village *village) 
{
	struct Patient *list = village->hosp.assess;
	float rand;
	struct Patient *p;

	//printf("check_patients\n");
	while (list != NULL) 
	{
		printf("check in patients\n");
		p = list;
		list = list->forward; 
		p->time_left--;

		if (p->time_left == 0) 
		{ 
			rand = my_rand(&(p->seed));
			/* sim_covalescense_p % */
			if (rand < sim_convalescence_p)
			{
				rand = my_rand(&(p->seed));
				/* !sim_realloc_p % or root hospital */
				printf("rand(%f) > sim_relloc_p(%f) || vl(%d) = sl(%d)\n", 
						rand, 
						sim_realloc_p, 
						village->level, 
						sim_level);
				if (rand > sim_realloc_p || village->level == sim_level) 
				{
					printf("here\n");
					removeList(&(village->hosp.assess), p);
					addList(&(village->hosp.inside), p);
					p->time_left = sim_convalescence_time;
					p->time += p->time_left;
				}
				else /* move to upper level hospital !!! */
				{
					village->hosp.free_personnel++;
					removeList(&(village->hosp.assess), p);
					omp_set_lock(&(village->hosp.realloc_lock));
					//hpx_lco_sema_p(village->hosp.mutex);
					//hpx_lco_sema_p(mutex);
					printf("In critical region.\n");
					addList(&(village->back->hosp.realloc), p); 
					//hpx_lco_sema_v_sync(mutex);
					//hpx_lco_sema_v_sync(village->hosp.mutex);
					omp_unset_lock(&(village->hosp.realloc_lock));
				} 
			}
			else /* move to village */
			{
				village->hosp.free_personnel++;
				removeList(&(village->hosp.assess), p);
				addList(&(village->population), p); 
			}
		}
	} 
}
Пример #5
0
StructurePermissionList::StructurePermissionList() {
	permissionLists.setNoDuplicateInsertPlan();

	//TODO: Load these from the structure template script.
	addList("ADMIN");
	addList("ENTRY");
	addList("HOPPER");
	addList("BAN");
	addList("VENDOR");
}
Пример #6
0
/*
 * Doc du lieu tu file
 * Tra ve List cac map cung voi cac doi tuong ben trong map
 */
List<Map<List<Object> > > *readData() {
	ifstream ifs("data.map");

	List<Map<List<Object> > > *listMap = new List<Map<List<Object> > >;
	Map<List<Object> > *map;
	List<Object> *listObj;
	Object *obj;

	string id;
	string objID;
	string str;

	while (ifs >> str) {
		if (str.find("MAP") == 0) {
			if (id != "") {
				addList(listMap, id, map);
			}

			map = new Map<List<Object> >;
			listObj = new List<Object>;
			id = str;
		}

		if (str.find("OBJ") == 0) {
			objID = str;
			obj = new Object;
			obj->id = objID;
			ifs >> obj->name;
			ifs >> obj->directory;
			ifs >> obj->position;
			ifs >> obj->scale;
			ifs >> obj->swivelAngle;

			addList(listObj, objID, obj);
		}

		if (str.find("GOTO") == 0) {
			SpecialObject *spclObj = new SpecialObject;
			spclObj->objID = objID;
			spclObj->id = str;
			ifs >> spclObj->gotoMap;
			ifs >> spclObj->positionMap;
			ifs >> spclObj->positionObj;
			ifs >> spclObj->distance;
			obj->spclObj = spclObj;

			string mapID = "MAP" + spclObj->gotoMap;

			putMap(map, mapID, new List<Object>);
		}
int main() {
    N = 100*(getchar()-'0')+10*(getchar()-'0')+getchar()-'0';
    targetx = targety  = N - 1;
    for (i = 0; i < N; i ++)
        for (j = 0; j < N; j ++)
        step[i][j] = -1;
    while (head <= tail) {
        x = xlist[head];
        y = ylist[head];
        now = step[x][y];
        addList(x-1, y-2);
        addList(x-1, y+2);
        addList(x+1, y-2);
        addList(x+1, y+2);
        addList(x-2, y-1);
        addList(x-2, y+1);
        addList(x+2, y-1);
        addList(x+2, y+1);
        if (ok == 1) break;
        head = head + 1;
    }
    if (ok == 1) printf("%d\n", step[targetx][targety]);
    else printf("no solution!\n");
    return 0;
}
Пример #8
0
bool Msg1::addRecord ( char *rec , 
		       int32_t recSize , 
		       char          rdbId             ,
		       collnum_t collnum ,
		       void         *state             ,
		       void (* callback)(void *state)  ,
		       int32_t          niceness          ) {

	key_t sk;
	key_t ek;
	sk.setMin();
	ek.setMax();
	//RdbList list;
	m_tmpList.set ( rec , 
		   recSize ,
		   rec ,
		   recSize ,
		   (char *)&sk,
		   (char *)&ek,
		   -1 , // fixed data size
		   false , // owndata?
		   false , // use half keys?
		   sizeof(key_t));
	return addList ( &m_tmpList ,
			 rdbId ,
			 collnum,//g_collectiondb.m_recs[collnum]->m_coll ,
			 state ,
			 callback ,
			 false , // force local?
			 niceness );
}
void SelectionList::copyList( SelectionList &source_list )
{
    unGroup();

    addList(source_list);

}
Пример #10
0
player *
WOPR_addPlayer( game *aGame, char *name )
{
    player *aPlayer;

    aPlayer = allocStruct( player );

    setName( aPlayer, name );
    aPlayer->pswd = strdup( "none" );
    aPlayer->addr = strdup( "none" );
    aPlayer->realName = strdup( "none" );
    aPlayer->pswdstate = 1;
    aPlayer->drive = 1;
    aPlayer->weapons = 1;
    aPlayer->shields = 1;
    aPlayer->cargo = 1;
    aPlayer->msize = aGame->galaxysize;
    aPlayer->flags =
        F_ANONYMOUS | F_AUTOUNLOAD | F_PRODTABLE | F_SORTGROUPS |
        F_GROUPFORECAST | F_PLANETFORECAST | F_SHIPTYPEFORECAST |
        F_ROUTESFORECAST | F_BATTLEPROTOCOL;
    /* Should check if the player exists already... */
    addList( &( aGame->players ), aPlayer );
    return aPlayer;
}
Пример #11
0
// Driver program to test above functions
int main()
{
    node *head1 = NULL, *head2 = NULL, *result = NULL;
 
    int arr1[] = {9, 9, 9};
    int arr2[] = {1, 8};
 
    int size1 = sizeof(arr1) / sizeof(arr1[0]);
    int size2 = sizeof(arr2) / sizeof(arr2[0]);
 
    // Create first list as 9->9->9
    int i;
    for (i = size1-1; i >= 0; --i)
        push(&head1, arr1[i]);
 
    // Create second list as 1->8
    for (i = size2-1; i >= 0; --i)
        push(&head2, arr2[i]);
 
    addList(head1, head2, &result);
 
    printList(result);
 
    return 0;
}
Пример #12
0
ArrayList* reachble_cities(Graph *g, Graph *atual){
    if(!g || !atual){
        return NULL;
    }
    ArrayList *l = newList();
    if(!atual->edges)
        return l;
    l = addList(l, atual->edges->to);
    ArrayList *p = l;
    Graph *aux;
    while(p){
        aux = findGraph(g, p->id);
        if(!aux){
            p = p->prox;
            continue;
        }
        Edge *v = aux->edges;
        while(v){
            l = add_if_not_existList(l, v->to);
            v = v->next;
        }
        p = p->next;
    }
    return l;
}
void Selection::setList(std::vector<SPItem*> const &list) {
    // Clear and add, or just clear with emit.
    if (!list.empty()) {
        _clear();
        addList(list);
    } else clear();
}
Пример #14
0
void CSVSortList::EnumObject(string &szIndex, int &nType)
{
    m_lsOld.clear();
    m_lsCurrent.clear();

    m_sortList.clear();

    m_nType = nType;

    switch(nType)
    {
    case Tree_SE:
        break;
    case Tree_GROUP:
        enumGroup(szIndex);
        break;
    case Tree_DEVICE:
        enumDevice(szIndex);
        break;
    case Tree_MONITOR:
        enumMonitor(szIndex);
        break;
    }
    addList();
}
Пример #15
0
void KWMailMergeKABC::load( QDomElement& parentElem )
{
    clear();
    QDomNode contentNode=parentElem.namedItem("CONTENT");
    if( contentNode.isNull() )
        return;
    for( QDomNode rec=contentNode.firstChild(); !rec.isNull(); rec=rec.nextSibling() )
    {
        if( rec.nodeName()== "RECORD" )
        {
            for( QDomElement recEnt=rec.firstChild().toElement(); !recEnt.isNull();
                    recEnt=recEnt.nextSibling().toElement() )
            {
                addEntry( recEnt.attribute( QString::fromLatin1("uid") ) );
            }
        }
        else if( rec.nodeName() == "LIST" )
        {
            for( QDomElement recEnt=rec.firstChild().toElement(); !recEnt.isNull();
                    recEnt=recEnt.nextSibling().toElement() )
            {
                addList( recEnt.attribute( QString::fromLatin1("listid") ) );
            }
        }
        else
            kdDebug() << "rec.nodeName(): " << rec.nodeName() << endl;
    }
}
Пример #16
0
void TestbedExitDialog::init() {
	_xOffset = 25;
	_yOffset = 0;
	Common::String text = "Thank you for using ScummVM testbed! Here are yor summarized results:";
	addText(450, 20, text, Graphics::kTextAlignCenter, _xOffset, 15);
	Common::Array<Common::String> strArray;
	GUI::ListWidget::ColorList colors;

	for (Common::Array<Testsuite *>::const_iterator i = _testsuiteList.begin(); i != _testsuiteList.end(); ++i) {
		strArray.push_back(Common::String::format("%s :", (*i)->getDescription()));
		colors.push_back(GUI::ThemeEngine::kFontColorNormal);
		if ((*i)->isEnabled()) {
			strArray.push_back(Common::String::format("Passed: %d  Failed: %d Skipped: %d", (*i)->getNumTestsPassed(), (*i)->getNumTestsFailed(), (*i)->getNumTestsSkipped()));
		} else {
			strArray.push_back("Skipped");
		}
		colors.push_back(GUI::ThemeEngine::kFontColorAlternate);
	}

	addList(0, _yOffset, 500, 200, strArray, &colors);
	text = "More Details can be viewed in the Log file : " + ConfParams.getLogFilename();
	addText(450, 20, text, Graphics::kTextAlignLeft, 0, 0);
	if (ConfParams.getLogDirectory().size()) {
		text = "Directory : " + ConfParams.getLogDirectory();
	} else {
		text = "Directory : .";
	}
	addText(500, 20, text, Graphics::kTextAlignLeft, 0, 0);
	_yOffset += 5;
	addButtonXY(_xOffset + 80, _yOffset, 120, 24, "Rerun test suite", kCmdRerunTestbed);
	addButtonXY(_xOffset + 240, _yOffset, 60, 24, "Close", GUI::kCloseCmd);
}
Пример #17
0
/****f* ROBOhdrs/parseCtagsX
*  NAME
*    parseCtagsX
*  SYNOPSIS
*    static int parseCtagsX(FILE *fp)
*  SOURCE
*/
static int
parseCtagsX( FILE * fp )
{
    char                buf[MAXLINE + 1];
    int                 lnum = 0, tagsParsed = 0;

    while ( fgets( buf, MAXLINE, fp ) != NULL )
    {
        char                decl[MAXNAME + 1], name[MAXNAME + 1];
        char                fname[MAXNAME + 1], type[MAXNAME + 1];
        int                 linenum;

        lnum++;
        /* extract info from a line */
        if ( parseCtagsXLine( buf, fname, name, decl, type, &linenum ) )
        {
            printf( "error parsing line (%d)", lnum );
        }
        else
        {
            addList( ctags, fname, name, decl, type, linenum );
            tagsParsed++;
        }
    }                           /* end while() */
    fclose( fp );

    return tagsParsed;
}
Пример #18
0
void parseChunkFile(char* chunkfile, linkedList* list){
	cleanChunkList(list);
	FILE* fp;
	char locBuf[100];
	unsigned int id;
	char hash[sizeofHash];
	/* parse chunkfile*/
	if((fp = fopen(chunkfile, "r")) == NULL){
		fprintf(stderr,"Error opening %s",chunkfile);
		exit(1);
	}
	list->length = 0;
	list->finished = 0;
	while(fgets(locBuf, sizeof(locBuf),fp)){
		/* read each line in chunkfile */
		if(sscanf(locBuf,"%d %40c",&id,hash) < 2){
			fprintf(stderr,"Malformed chunkfile %s\n",chunkfile);
		}
		
		/* add new chunk entry in list */
		chunkEle* ele = initChunkEle(id,hash);
		node* newNode = initNode(ele);
		addList(newNode, list);
	}
	fclose(fp);
}
Пример #19
0
void put_in_hosp(struct Hosp *hosp, struct Patient *patient) 
{  
	(patient->hosps_visited)++;

	if (hosp->free_personnel > 0) 
	{
		hosp->free_personnel--;
		addList(&(hosp->assess), patient); 
		patient->time_left = sim_assess_time;
		patient->time += patient->time_left;
	} 
	else 
	{
		addList(&(hosp->waiting), patient); 
	}
}
Пример #20
0
int main(int argc, char* argv[]) {
    if( argc != 2 ) return 0;

    struct linkedList * b = createLinkedList();

    /* Test Area Start
    printf("For starters_ front: %d, back: %d \n", frontList(b), backList(b));
    printf("empty: %d \n", isEmptyList(b));
    addFrontList(b,24);
    addFrontList(b,33);
    printf("front: %d, back: %d \n", frontList(b), backList(b));

    addBackList(b,69);
    printf("front: %d, back: %d \n", frontList(b), backList(b));

    removeBackList(b);
    printf("front: %d, back: %d \n", frontList(b), backList(b));

    removeFrontList(b);
    printf("front: %d, back: %d \n", frontList(b), backList(b));

    printf("empty: %d \n", isEmptyList(b));

    removeFrontList(b);
    printf("front: %d, back: %d \n", frontList(b), backList(b));
    printf("empty: %d \n", isEmptyList(b));

    //bag interface

    addList(b,13);
    addList(b,8);

    printf("contains (0): %d \n", containsList(b,1));
    printf("contains (1): %d \n", containsList(b,13));
    printf("contains (2): %d \n", containsList(b,8));

    removeList(b,13);
    printf("contains (0): %d \n", containsList(b,13));


    addList(b,663);
    removeList(b,8);
    printf("contains (0): %d \n", containsList(b,8));



    Test Area End */


    int n = atoi(argv[1]);/*number of elements to add*/
    int i;
    for( i = 0 ; i < n; i++)
        addList(b, (TYPE)i);/*Add elements*/
    double t1 = getMilliseconds();/*Time before contains()*/
    for(i=0; i<n; i++)
        containsList(b, i);
    double t2 = getMilliseconds();/*Time after contains()*/
    printf("%d %g\n", n, t2-t1);
    return 0;
}
Пример #21
0
int main(int argc, char* argv[]) {
        struct linkedList *b;
        int n, i;
        double t1, t2;

        for(n=1000; n < 200000; n=n*2) /* outer loop */
        {

			b = createLinkedList();

			for( i = 0 ; i < n; i++) {
					addList(b, (TYPE)i); /*Add elements*/
			}

			t1 = getMilliseconds();/*Time before contains()*/

			for(i=0; i<n; i++) {
					removeList(b, i);
			}

			t2 = getMilliseconds();/*Time after contains()*/

			printf("Time for running contains() on %d elements: %g ms\n", n, t2-t1);

			/* delete DynArr */
			deleteLinkedList(b);
        }
        return 0;
}
Пример #22
0
int main(int argc, char *argv[]) {
    if (argc != 3) {
        printf("Usage ./%s <num1> <num2>", argv[0]);
        return (-1);
    }

    Node *num1 = NULL;
    Node *num2 = NULL;
    num1 = (Node *) malloc(sizeof (Node));
    num2 = (Node *) malloc(sizeof (Node));
    num1->dig = argv[1][0] - '0';
    num2->dig = argv[2][0] - '0';
    num1->next = NULL;
    num2->next = NULL;
    makeList(num1, argv[1]);
    makeList(num2, argv[2]);
    Node *num3;
    num3 = addList(num1, num2);
    Node *temp = num3;
    while (temp) {
        printf("%d", temp->dig);
        temp = temp->next;
    }
    printf("\n");
    freeMem(num1);
    freeMem(num2);
    freeMem(num3);
    return (0);
}
Пример #23
0
/*
* Routine: MakeListExpr()
* Purpose: add LIST/RANGE modifiers to an expression
* Algorithm:
* Data Structures:
*
* Params:
* Returns:
* Called By: 
* Calls: 
* Assumptions:
* Side Effects:
* TODO: None
*/
expr_t *
MakeListExpr(int nModifier, expr_t *pExpr, int nArg)
{
	expr_t *pArgExpr;

	switch(nModifier)
	{
	case KW_LIST:
		pExpr->nValueCount = nArg;
      pExpr->nFlags |= EXPR_FL_LIST;
		break;
	case KW_ULIST:
		pExpr->nValueCount = nArg;
      pExpr->nFlags |= EXPR_FL_ULIST;
		break;
	case KW_RANGE:
		pExpr->nValueCount = 2;
      pExpr->nFlags |= EXPR_FL_RANGE;
		break;
	default:
		INTERNAL("Bad modifier in MakeListExpr()");
		break;
	}

	pArgExpr = MakeIntConstant(nArg);
	addList(pExpr->ArgList, pArgExpr);

	return(pExpr);
}
Пример #24
0
void check_patients_assess_par(struct Village *village) 
{
   struct Patient *list = village->hosp.assess;
   float rand;
   struct Patient *p;

   while (list != NULL) 
   {
      p = list;
      list = list->forward; 
      p->time_left--;

      if (p->time_left == 0) 
      { 
         rand = my_rand(&(p->seed));
         /* sim_covalescense_p % */
         if (rand < sim_convalescence_p)
         {
            rand = my_rand(&(p->seed));
            /* !sim_realloc_p % or root hospital */
            if (rand > sim_realloc_p || village->level == sim_level) 
            {
               removeList(&(village->hosp.assess), p);
               addList(&(village->hosp.inside), p);
               p->time_left = sim_convalescence_time;
               p->time += p->time_left;
            }
            else /* move to upper level hospital !!! */
            {
               village->hosp.free_personnel++;
               removeList(&(village->hosp.assess), p);
               int err = pthread_mutex_lock(&(village->hosp.realloc_lock));
               assert(err == 0);
               addList(&(village->back->hosp.realloc), p); 
               err = pthread_mutex_unlock(&(village->hosp.realloc_lock));
               assert(err == 0);
            } 
         }
         else /* move to village */
         {
            village->hosp.free_personnel++;
            removeList(&(village->hosp.assess), p);
            addList(&(village->population), p); 
         }
      }
   } 
}
Пример #25
0
void FilelistApi::on(DirectoryListingManagerListener::ListingCreated, const DirectoryListingPtr& aList) noexcept {
    addList(aList);
    if (!subscriptionActive("filelist_created")) {
        return;
    }

    send("filelist_created", serializeList(aList));
}
Пример #26
0
int wl_probe(char *name)
{
	int ret, val;

	if (isListed("probe_blacklist", name))
		return -1;

#if 0				//defined(linux)
	char buf[DEV_TYPE_LEN];

	if ((ret = wl_get_dev_type(name, buf, DEV_TYPE_LEN)) < 0) {
//              fprintf(stderr,"dev type=%s fail\n",name);
		addList("probe_blacklist", name);
		return ret;
	}
	/*
	 * Check interface 
	 */
//      fprintf(stderr,"dev type=%s\n",buf);
	if (strncmp(buf, "wl", 2)) {
		addList("probe_blacklist", name);
		return -1;
	}
#else
	/*
	 * Check interface 
	 */
	if ((ret = wl_ioctl(name, WLC_GET_MAGIC, &val, sizeof(val)))) {
		//    fprintf(stderr,"magic fail\n");
		addList("probe_blacklist", name);
		return ret;
	}
#endif
	if ((ret = wl_ioctl(name, WLC_GET_VERSION, &val, sizeof(val)))) {
		//    fprintf(stderr,"version fail\n");
		addList("probe_blacklist", name);
		return ret;
	}
	if (val > WLC_IOCTL_VERSION) {
		//    fprintf(stderr,"version fail %d\n",val);
		addList("probe_blacklist", name);
		return -1;
	}
	return ret;
}
Пример #27
0
void test_linked_list_return_5(void)
{
	LinkList* NewLink =  malloc(sizeof(LinkList*));
	NewLink = createLinkedList();
	NewLink = addList(NewLink, 5, NULL);
	TEST_ASSERT_EQUAL(5,NewLink->head->value);
	TEST_ASSERT_NULL(NewLink->head->next);
	printf("NewLink->head->value = %i \nNewLink->head->next = %i",NewLink->head->value, NewLink->head->next);
}
Пример #28
0
void
b_order( game *aGame, player *P, strlist **s )
{
    group *g;                   /* pointer to named group */
    group *g2;                  /* pointer to new group */
    int i;                      /* int value for number of ships */
    char *ns;                   /* char value for number of ships */

    DBUG_ENTER( "b_order" );

    /* find the named group */
    g = findgroup( P, getstr( 0 ) );
    if ( !g ) {
        mistake( P, INFO, *s, "Group not recognized." );
        DBUG_VOID_RETURN;
    }

    /* check to see if we're detaching from a fleet */
    ns = getstr( 0 );
    if ( noCaseStrncmp( ns, "fleet", 5 ) == 0 ) {
        if ( !epsilon( g->dist, 0.0, 0.0001 ) ) {
            mistake( P, WARNING, *s, "Fleet is in hyperspace." );
            DBUG_VOID_RETURN;
        }
        g->thefleet = 0;
        DBUG_VOID_RETURN;
    }

    /* are there enough ships to detach? */
    i = atoi( ns );
    if ( i > g->ships ) {       /* FS Dec 1998 */
        mistake( P, INFO, *s, "Not enough ships in group." );
        DBUG_VOID_RETURN;
    }

    /* this was an odd problem */
    if ( i < 0 ) {              /* KDW July 1999 */
        mistake( P, WARNING, *s, "Can't have negative number of ships." );
        DBUG_VOID_RETURN;
    }

    /* create a new group for what's being broken off and add it to
     * the list of groups the player owns
     */
    g2 = allocStruct( group );
    *g2 = *g;
    g2->ships = i;
    g->ships -= i;
    g2->thefleet = 0;
    g2->next = NULL;
    numberGroup( P, g2 );
    g2->name = ( char * ) malloc( 8 );
    sprintf( g2->name, "%d", g2->number );
    addList( &P->groups, g2 );

    DBUG_VOID_RETURN;
}
Пример #29
0
void
wopr_allies( game *aGame, char *playerName1, char *playerName2 )
{
    player *aPlayer1;
    player *aPlayer2;
    alliance *a;

    aPlayer1 = findElement( player, aGame->players, playerName1 );
    aPlayer2 = findElement( player, aGame->players, playerName2 );

    a = allocStruct( alliance );
    a->who = aPlayer1;
    addList( &aPlayer2->allies, a );

    a = allocStruct( alliance );
    a->who = aPlayer2;
    addList( &aPlayer1->allies, a );
}
Пример #30
0
int main() {
    int N;
    int head, startx, starty;
    int targetx, targety;
    int x, y;
    int *xlist, *ylist, *tail, *ok, *now, *dx, *dy;
    int** step;
    int i, j;
    
    N = 100;
    tail = malloc(1 * sizeof(int));
    ok = malloc(1 * sizeof(int));
    now = malloc(1 * sizeof(int));
    head = tail[0] = startx = starty = 0;
    targetx = targety  = N - 1;
    x = y = 0;
    now[0] = ok[0] = 0;
    xlist = malloc(N * N * sizeof(int));
    for (i = 0; i < N * N; i = i + 1)
        xlist[i] = 0;
    ylist = malloc(N * N * sizeof(int));
    for (i = 0; i < N * N; i = i + 1)
        ylist[i] = 0;
    step = malloc(N * sizeof(int*));
    for (i = 0; i < N; i =  i + 1) {
        step[i] = malloc(N * sizeof(int));
        for (j = 0; j < N; j = j + 1)
        step[i][j] = -1;
    
    }
    xlist[0] = startx;
    ylist[0] = starty;
    step[startx][starty] == 0;
    dx = malloc(8 * sizeof(int));
    dy = malloc(9 * sizeof(int));
    dx[0] = -2; dy[0] = -1;
    dx[1] = -2; dy[1] = 1;
    dx[2] = 2; dy[2] = -1;
    dx[3] = 2; dy[3] = 1;
    dx[4] = -1; dy[4] = -2;
    dx[5] = -1; dy[5] = 2;
    dx[6] = 1; dy[6] = -2;
    dx[7] = 1; dy[7] = 2;
    while (head <= tail[0]) {
        x = xlist[head];
        y = ylist[head];
        now[0] = step[x][y];
        for (j = 0;j < 8;j = j + 1)
            addList(x + dx[j], y + dy[j], N, step, tail, ok, now, xlist, ylist, targetx, targety);
        if (ok[0] == 1) break;
        head = head + 1;
    }
    if (ok[0] == 1) printf("%d", step[targetx][targety]);
    else printf("no solution!");
    return 0;
}