Ejemplo n.º 1
0
/**
* @brief DeleteList \n
* 删除双向链表,查询节点位置,将前后地址相连接,然后free此节点位置
* @param[in]	*List			双向链表默认链表接口
* @param[in]	*data			需要被删除的无类型数据指针
* @param[in]	*CallBackCmp	各种类型的回调函数接口
*/
void DeleteList(DLNode *List, void *data, int (*CallBackCmp)(const void *, const void *))
{
	DLNode *p = NULL;
	p = (DLNode *)malloc(sizeof(DLNode));

	if( p == NULL )
	{
		printf ("Create MEM ERROR!\n");
	}
	else
	{
		p = SearchList(List, data, CallBackCmp);
		p->back->next = p->next;
		p->next->back = p->back;
		free(p->data);
		p->data = NULL;
		DLNode *temp = NULL;
		temp = p;
		p = p->next;
		free(temp);
		if( SearchList(List, data, CallBackCmp ) == 0)
		{
			printf("Delete Error!\n");
		}
		else
			printf("Delete OK!\n");	
	}
}
Ejemplo n.º 2
0
void Application::Admin_select()
{
	y -= 3;
	ClientData data;	// 고객 정보 임시 저장장소
	account temp;	// 계좌 임시 저장소
	switch(y)
	{
	case 1:
		data.GetClientData();		// 고객 정보 입력
		m_ClientList.InsertItem(data); // 고객 추가 함수
		data.PutClientData();	// 고객 정부 화면 출력
		break;
	case 2:
		DeleteClient();	// 고객 리스트 제거 함수
		break;
	case 3:
		if(!SearchList(data))	// 고객 검색
			break;
		data.PutClientData();	// 고객정보 화면에 띄우기
		break;
	case 4:
		OpenAccount();	// 계좌 열기
		break;
	case 5:
		if(!SearchList(data))	// 고객 검색
			break;
		data.CloseAccount();
		break;
	case 6:
		return;
	}
}
Ejemplo n.º 3
0
/*
 * CheckForFax()
 *
 * Since FaxModems don't set carrier high, we have to deal with this problem
 * that Citadel isn't set up for.  This function is called when Citadel detects
 * something on the serial port while carrier is not high.  If it's a FAX call,
 * this function is responsible for dealing with it.
 */
void CheckForFax()
{
	char c;
	NumToString *temp;

	if (MIReady()) {
		if ((c = Citinp()) == '\r' || c == '\n') {
			if ((temp = SearchList(&ResList, IdBuffer)) != NULL) {
				if (temp->num == R_FAX) {
					RunFax();
				}
				else {
					AddData(&ReceivedResults,
						strdup(IdBuffer), NULL, FALSE);
				}
			}
			memset(IdBuffer, 0, sizeof IdBuffer);
		}
		else if (c != '\n') {
			IdBuffer[strlen(IdBuffer)] = c;
			if (strlen(IdBuffer) >= BA_BUF_SIZE - 4) {
				memset(IdBuffer, 0, sizeof IdBuffer);
			}
		}
	}
}
Ejemplo n.º 4
0
/*
 * RunRemoteEditor()
 *
 * This function will run any of the extended editors.
 */
void RunRemoteEditor(int s)
{
    Editor *TheEditor;

    if ((TheEditor = SearchList(&ExtEditors, &s)) != NULL)
	OutsideEditorWork(TheEditor->CmdLine);
}
Ejemplo n.º 5
0
PreformedMessage *DataBase_GetSystemPatch(long version, long patchNum)
{
SDBSystem		*sys;
ListNode		*node;
SDBSystemNode	*sn;

	sys = SDB_GetSystem(gSDB);
	ASSERT(sys);

	ASSERT_MESG(patchNum >= 0, "Negative patch numbers are illegal");

	node = SearchList(sys->list, version);
	if(node)
	{
		sn = (SDBSystemNode *)GetListNodeData(node);
		ASSERT_MESG(patchNum < sn->numPatches, "Requested system patch number is out of range");
		if(patchNum >= sn->numPatches)
			return(NULL);	// big error
		
		return(sn->patches[patchNum]);
	}

	//WARNING_MESG("No such system version?!?");
	Logmsg("No such system version?!?\n");

	return(NULL);
}
Ejemplo n.º 6
0
/*====================================================================================
// Function	: Delete an Clients in list
// Pre		: none
// Post		: if the Clients is in list then the Clients is deleted from list.
=====================================================================================*/
void Application::DeleteClient()
{
	ClientData temp;
	SearchList(temp);
	m_ClientList.DeleteItem(temp);
	cout << endl << "\t 고객 정보가 성공적으로 삭제되었습니다!" << endl;
}
Ejemplo n.º 7
0
void Application::Client_select()
{
	ClientData data;
	y -= 3;
	switch(y)
	{
	case 1:
		CW.AddCW();
		break;
	case 2:
		InputMoney();
		break;
	case 3:
		OutputMoney();
		break;
	case 4:
		BorrowMoney();
		break;
	case 5:
		InputMoney();
		break;
	case 6:
		if(!SearchList(data))
			break;
		data.ApartApplication();
		break;
	case 7:
		return;
	}
}
Ejemplo n.º 8
0
PUBLIC THREAD *findthread(DEBUG *debug, int id)
{
  THREAD *thread;

  if ((thread = (THREAD *)SearchList(&debug->threadlist, (WordFnPtr)cmpthread, id)) == NULL)
    return newthread(debug, id);
  return thread;
}
Ejemplo n.º 9
0
void InsertHashTable(hashTablePrivate *ht, void *value, void *arg) {

    int pos = ht->hashFun(value, arg);
    if(SearchList(ht->table[abs(pos%ht->M)],value)) {
//		printf("Same! ");
        return;
    }
    InsertValueList(ht->table[abs(pos%ht->M)], value);
    ht->size++;
}
Ejemplo n.º 10
0
SelectableResource::SelectableResource(QWidget *parent, QString name) :
    QDialog(parent),
    ui(new Ui::SelectableResource)
{
    ui->setupUi(this);

    connect(ui->search,    SIGNAL(textChanged(QString)), this, SLOT(SearchList()));
    connect(ui->buttonBox, SIGNAL(accepted()),           this, SLOT(SelectedItem()));
    connect(ui->buttonBox, SIGNAL(rejected()),           this, SLOT(hide()));
    setModal(true);
    setWindowTitle("Select " + name);
}
Ejemplo n.º 11
0
//
// Appropriates the patch... does not copy it when it adds to the DB.
//
Err DataBase_AddSystemPatch(long version, long patchNum, PreformedMessage *patch)
{
SDBSystem		*sys;
ListNode		*node;
SDBSystemNode	*sn;

	sys = SDB_GetSystem(gSDB);
	ASSERT(sys);

	ASSERT_MESG(patchNum >= 0, "Negative patch numbers are illegal");

	node = SearchList(sys->list, version);
	if(node)
	{
		sn = (SDBSystemNode *)GetListNodeData(node);
		ASSERT(sn);
		ASSERT_MESG(patchNum == sn->numPatches, "Patches must be added in linear order... what's up!?");
		if(patchNum != sn->numPatches)
			return(kAddingSystemPatchIsFucked);	// big error
		
		sn->numPatches++;
		sn->patches = (PreformedMessage **)realloc(sn->patches, sn->numPatches * sizeof(PreformedMessage *));
		ASSERT(sn->patches);

		sn->patches[patchNum] = patch;
		return(kNoError);
	}

	ASSERT(patchNum == 0);

	// malloc a node
	// set its numpatches to 1
	// copy in this patch.

	sn = (SDBSystemNode *)malloc(sizeof(SDBSystemNode));
	ASSERT(sn);
	
	sn->numPatches = 1;
	sn->version = version;
	sn->keyframe = 1;				// as a hack for now, every system release is a keyframe. 6/29/94  dj

	sn->patches = (PreformedMessage **)malloc(sizeof(PreformedMessage *));
	ASSERT(sn->patches);

	sn->patches[0] = patch;

	node = NewSortedListNode((Ptr)sn, sn->version);
	AddListNodeToSortedList(sys->list, node);

	return(kNoError);

}
Ejemplo n.º 12
0
void Application::OpenAccount()
{
	ClientData data;
	ClientData data2;
	account temp;
	account temp2;
	if(!SearchList(data))
		return;
	data2.Copy(data);
	temp.Getaccount(data.GetCredit());
	data.Account.InsertItem(temp);
	m_ClientList.DeleteItem(data2);
	m_ClientList.InsertItem(data);
}
Ejemplo n.º 13
0
/*
 * CheckAutoDoor()
 *
 * This function checks to see if the given login name has an autodoor that
 * should be executed.  It returns -1 if no such autodoor exists, otherwise
 * it returns the EvExitVal value associated with the autodoor entry.  This
 * function resides in here rather than the door source because autodoors
 * are implemented as #events.
 */
int CheckAutoDoor(char *name)
{
    EvDoorRec rec;

    rec.Evt = GetDynamic(sizeof (EVENT));	/* get around possible bug */
    strcpy(rec.Evt->vars.EvUserName, name);

    if ((Cur = SearchList(&AutoDoors, &rec)) != NULL) {
	free(rec.Evt);
	return (int) Cur->EvExitVal;
    }

    free(rec.Evt);
    return ERROR;
}
Ejemplo n.º 14
0
/*
 * RedirectFile()
 *
 * This function is used to discover if the given file should be redirected from
 * the normal file reception area to somewhere else.
 *
 * If it should be then a pointer is returned to a string representing the new
 * location; otherwise, NULL is returned.
 */
char *RedirectFile(char *filename, char *systemname)
{
    EvDoorRec rec;

    rec.Evt = GetDynamic(sizeof (EVENT));	/* get around possible bug */

	/* prepare for search */
    strcpy(rec.Evt->vars.Redirect.EvFilename, filename);
    strcpy(rec.Evt->vars.Redirect.EvSystem, systemname);

    Cur = SearchList(&Redirected, &rec);
    free(rec.Evt);

    return (Cur != NULL) ? cfg.codeBuf + Cur->vars.Redirect.EvHomeDir : NULL;
}
Ejemplo n.º 15
0
/**
* @brief UpdateList \n
* 更新双向链表,通过查询原始的节点位置,修改数据
* @param[in]	*List				双向链表默认链表接口
* @param[in]	*data_search		需要被更新的初始无类型数据指针
* @param[in]	*data_change		需要更新的无类型数据指针
* @param[in]	*CallBackCmp		各种类型的回调函数接口
*/
void UpdateList(DLNode *List, void *data_search, void *data_change, int (*CallBackCmp)(const void *, const void *))
{
	DLNode *p = NULL;

	p = SearchList(List, data_search, CallBackCmp);
	if(p != NULL)
	{
		p->data = data_change;
		printf("Update OK!\n");
		//free(p);
	}
	else
	{
		printf("ERROR Find REEOR!\n");
	}
}
Ejemplo n.º 16
0
/*====================================================================================
// Function : search the Clients information in list.
// Pre		: list has to have one Clients at least.
// Post		: display the Clients information if found.
=====================================================================================*/
void Application::BorrowMoney()
{
	ClientData data;
	ClientData data2;
	account temp;
	account temp2;
	if(!SearchList(data))
		return;
	data2.Copy(data);
	if(!data.SearchAccount(temp))
		return;
	temp2.Copy(temp);
	temp.Borrow();
	data.Account.DeleteItem(temp2);
	data.Account.InsertItem(temp);
	m_ClientList.DeleteItem(data2);
	m_ClientList.InsertItem(data);
}
Ejemplo n.º 17
0
/*
 * FindSpeed()
 *
 * This function helps check the list of received stuff from the modem
 * to see if any of it is any good for speed determination.
 */
static void FindSpeed(char *str, NumToString **temp)
{
	if (*temp == NULL) {
		*temp = SearchList(&ResList, str);
		if (*temp != NULL)
			switch ((*temp)->num) {
			case R_300:
			case R_1200:
			case R_2400:
			case R_4800:
			case R_9600:
			case R_14400:
			case R_19200:
			case R_FAX:
				return;
			}
		*temp = NULL;
	}
}
Ejemplo n.º 18
0
long DataBase_GetSystemNumPatches(long version)
{
SDBSystem		*sys;
ListNode		*node;
SDBSystemNode	*sn;

	sys = SDB_GetSystem(gSDB);

	node = SearchList(sys->list, version);
	if(node)
	{
		sn = (SDBSystemNode *)GetListNodeData(node);
		return(sn->numPatches);
	}

	//WARNING_MESG("No such system version?!?");
	Logmsg("No such system version?!?\n");

	return(0);
}
Ejemplo n.º 19
0
/**
* @brief main \n
* 测试程序的主函数,进行int以及char的创建、增、删、改、查、排序、清空操作。
* @param[in]	argc		带int参数形式
* @param[in]	*argv[]		带char参数形式
* @return		函数默认返回值
*/
int main( int argc, char *argv[] )
{
	DLNode *List;
	/* 进行int 数组测试 */
	int num[1000],i = 0;
	for(i = 0; i < 1000; i++)
	{
		//srand(time(NULL));
		num[i] = rand();
	}
	List = CreateList();
	if (List == NULL)
		printf("Error!\n");
	else
		printf("OK!Create OK!\n");
	for(i = 0; i < 1000; i++)
		InsertList(List,(void *)&num[i]);//(num + i));
	ShowList(List,0);
	sleep(1);
	SequenceList(List,0,CallBackSequence);
	ShowList(List,0);
	sleep(1);
	SearchList(List,&num[1],0,CallBackSearch);
	UpdateList(List,&num[1],&num[5],0);
	ShowList(List,0);
	sleep(1);
	DeleteList(List,&num[5],0);
	ShowList(List,0);
	sleep(1);
	DropList(List);
	ShowList(List,0);
	sleep(1);
	/* 进行char * 字符串测试 */
	char *test1 = "test1";
	char *test2 = "test2";
	char *test3 = "test3";
	char *test5 = "test5";
	List = CreateList();
	if (List == NULL)
		printf("Error!\n");
	else
		printf("OK!Create OK!\n");
	InsertList(List,test1);
	InsertList(List,test2);
	InsertList(List,test3);
	ShowList(List,2);
	sleep(1);
	SequenceList(List,2,CallBackSequence);
	SearchList(List,test2,2,CallBackSearch);
	UpdateList(List,test1,test5,2);
	ShowList(List,2);
	sleep(1);
	DeleteList(List,test5,2);
	ShowList(List,2);
	sleep(1);
	DropList(List);
	ShowList(List,2);
	sleep(1);
	/* 进行char 字符测试 */
	char ch[1000];
	int chascii;
	for(i = 0; i< 1000; i++)
	{
		//srand(time(NULL));
		chascii = rand()%25; //生成0-25的值
		ch[i] = chascii + 'a';
	}
	for(i = 0; i < 1000; i++)
		InsertList(List,(void *)&ch[i]);//(num + i));
	ShowList(List,1);
	sleep(1);
	SequenceList(List,1,CallBackSequence);
	ShowList(List,1);
	sleep(1);
	SearchList(List,&ch[1],1,CallBackSearch);
	UpdateList(List,&ch[1],&ch[5],1);
	ShowList(List,1);
	sleep(1);
	DeleteList(List,&ch[5],1);
	ShowList(List,1);
	sleep(1);
	DropList(List);
	ShowList(List,1);
	
	return 0;
}
Ejemplo n.º 20
0
void* SearchHashTable(hashTablePrivate *ht, void *value) {

    int bucket = (ht->hashFun(value))%ht->M;
    return SearchList(ht->table[bucket], value);

}
Ejemplo n.º 21
0
/*
 * getModemId()
 *
 * This tries to read the baud id from modem.
 */
int getModemId()
{
	NumToString *temp = NULL;
	char c;
	extern FILE *netLog;
	TimePacket ff;
	int i;
	void FindSpeed();

	RunListA(&ReceivedResults, FindSpeed, &temp);
	KillList(&ReceivedResults);

	if (temp != NULL) {
		BaudFlags = temp->num2;
		if (R_FAX == temp->num) RunFax();
		memset(IdBuffer, 0, sizeof IdBuffer);
		return temp->num;
	}

	setTimer(&ff);

	i = strlen(IdBuffer);
	while (timeSince(&ff) < 5l) {
		if (MIReady()) {
			if ((c = Citinp()) == '\r' || c == '\n') {
				IdBuffer[i] = 0;
				temp = SearchList(&ResList, IdBuffer);
				if (temp != NULL)
					switch (temp->num) {
					case R_300:
					case R_1200:
					case R_2400:
					case R_4800:
					case R_9600:
					case R_14400:
					case R_19200:
						BaudFlags = temp->num2;
						memset(IdBuffer, 0, sizeof IdBuffer);
						return temp->num;
					case R_FAX:
						RunFax();
						IdBuffer[0] = 0;
						memset(IdBuffer, 0, sizeof IdBuffer);
						return ERROR;
					}
else printf("Search for %s failed\n", IdBuffer);
				i = 0;	/* restart buffer filling */
			}
			else {
				if (c != '\n') {
		    			IdBuffer[i++] = c;
				}
				if (c == '\n' ||i >= BA_BUF_SIZE - 4) { /* Fudge factor */
					memset(IdBuffer, 0, sizeof IdBuffer);
		    			i = 0;
				}
			}
		}
	}
	IdBuffer[i] = 0;      /* debug for now */
	splitF(netLog, "autobaud failure, modem spat -%s-\n", IdBuffer);
	memset(IdBuffer, 0, sizeof IdBuffer);
	return ERROR;
}