int main(int argc,char** argv)
{
	queue *p=createqueue();
	if(p==NULL){
		exit(EXIT_FAILURE);
	}
	else{
		int i;
		for(i=0;i<9;i++){
			element e;
			e.key=i*2;
			addqueue(p,e);
		}

		for(i=0;i<6;i++){
			delqueue(p);
		}
		for(i=0;i<6;i++){
			element e;
			e.key=i*5;
			addqueue(p,e);
		}
		//delnum(p,5);
		element e;
		e.key=100;
		insnum(p,5,e);
		for(i=0;i<10;i++)
			delqueue(p);
	}

	return 0;
}
Esempio n. 2
0
int main()
{
    Element data = 0;
    Ptrqueue  q = Queue_Creat();
    intoqueue(q, 5);
    intoqueue(q, 9);
    intoqueue(q, 6);
    PrintQueue(q);
    delqueue(q, &data);
    PrintQueue(q);
    printf("%d ",data);
    delqueue(q, &data);
    delqueue(q, &data);PrintQueue(q);
}
Esempio n. 3
0
void main( )
{
	struct queue a ;
	int i ;

	clrscr( ) ;

	initqueue ( &a ) ;

	addq ( &a, 11 ) ;
	addq ( &a, -8 ) ;
	addq ( &a, 23 ) ;
	addq ( &a, 19 ) ;
	addq ( &a, 15 ) ;
	addq ( &a, 16 ) ;
	addq ( &a, 28 ) ;

	i = delq ( &a ) ;
	printf ( "\nItem extracted: %d", i ) ;

	i = delq ( &a ) ;
	printf ( "\nItem extracted: %d", i ) ;

	i = delq ( &a ) ;
	printf ( "\nItem extracted: %d", i ) ;

	delqueue ( &a ) ;

	getch( ) ;
}
Esempio n. 4
0
int main(){	
	// create queue
	int queue[QUEUE_SIZE]={0};
	int rear = 0;
	int front = 0;
	int choice;
	while(1){
		showInitile();
		choice = getChoice();
		switch(choice){
			case 1:
				displayQueue(queue);
				break;
			case 2:
				Enqueue(queue, &rear, &front);
				break;
			case 3:
				delqueue(queue, &rear, &front);
				break;
			case 4:
				system("CLS");
				break;
			default:
				printf("你壞壞\n");
				break;
		}
	}
	system("pause");
	return 0;
}
Esempio n. 5
0
struct plane apdelqueue ( struct airport *ap, char type )
{
	struct plane p1 ;

	switch ( tolower ( type ) )
	{
		case 'l' :
			  p1 = delqueue ( ap -> pl ) ;
			  break ;

		case 't' :
			  p1 = delqueue ( ap -> pl ) ;
			  break ;
	}

	return p1 ;
}
Esempio n. 6
0
void
bounce(struct qitem *it, const char *reason)
{
	struct queue bounceq;
	char line[1000];
	size_t pos;
	int error;

	/* Don't bounce bounced mails */
	if (it->sender[0] == 0) {
		syslog(LOG_INFO, "can not bounce a bounce message, discarding");
		exit(1);
	}

	bzero(&bounceq, sizeof(bounceq));
	LIST_INIT(&bounceq.queue);
	bounceq.sender = "";
	if (add_recp(&bounceq, it->sender, EXPAND_WILDCARD) != 0)
		goto fail;

	if (newspoolf(&bounceq) != 0)
		goto fail;

	syslog(LOG_ERR, "delivery failed, bouncing as %s", bounceq.id);
	setlogident("%s", bounceq.id);

	error = fprintf(bounceq.mailf,
		"Received: from MAILER-DAEMON\n"
		"\tid %s\n"
		"\tby %s (%s);\n"
		"\t%s\n"
		"X-Original-To: <%s>\n"
		"From: MAILER-DAEMON <>\n"
		"To: %s\n"
		"Subject: Mail delivery failed\n"
		"Message-Id: <%s@%s>\n"
		"Date: %s\n"
		"\n"
		"This is the %s at %s.\n"
		"\n"
		"There was an error delivering your mail to <%s>.\n"
		"\n"
		"%s\n"
		"\n"
		"%s\n"
		"\n",
		bounceq.id,
		hostname(), VERSION,
		rfc822date(),
		it->addr,
		it->sender,
		bounceq.id, hostname(),
		rfc822date(),
		VERSION, hostname(),
		it->addr,
		reason,
		config.features & FULLBOUNCE ?
		    "Original message follows." :
		    "Message headers follow.");
	if (error < 0)
		goto fail;

	if (fseek(it->mailf, 0, SEEK_SET) != 0)
		goto fail;
	if (config.features & FULLBOUNCE) {
		while ((pos = fread(line, 1, sizeof(line), it->mailf)) > 0) {
			if (fwrite(line, 1, pos, bounceq.mailf) != pos)
				goto fail;
		}
	} else {
		while (!feof(it->mailf)) {
			if (fgets(line, sizeof(line), it->mailf) == NULL)
				break;
			if (line[0] == '\n')
				break;
			if (fwrite(line, strlen(line), 1, bounceq.mailf) != 1)
				goto fail;
		}
	}

	if (linkspool(&bounceq) != 0)
		goto fail;
	/* bounce is safe */

	delqueue(it);

	run_queue(&bounceq);
	/* NOTREACHED */

fail:
	syslog(LOG_CRIT, "error creating bounce: %m");
	delqueue(it);
	exit(1);
}