void display( struct listnode *p,int i)
{
     int count=0,x=160,y=100;

		setfillstyle(SOLID_FILL,BLACK);
		bar(145,70,640,400);

     while(p!=0)
     {
	   /* to display maximam 4 nodes in row */

		if(count<4)
		{
			count++;
			drawnode(x,y,p,i);
			x+=120;

			if(count>1)
			nlink(x-240,y,0);
		}
		else
		{
			newlink(520,y,0);
			drawnode(160,y+100,p,i);
			x=280;y+=100;
			count=1;
		}

		p=p->next;
	}
}
Example #2
0
static int
CputrripPX(Cdimg *cd, Direc *d, int dot, int dowrite)
{
	assert(cd!=0);

	if(dowrite) {
		Cputc(cd, 'P');             /* PX field marker */
		Cputc(cd, 'X');
		Cputc(cd, 36);              /* Length          */
		Cputc(cd, 1);               /* Version         */
	
		Cputn(cd, mode(d, dot), 4); /* POSIX File mode */
		Cputn(cd, nlink(d), 4);     /* POSIX st_nlink  */
		Cputn(cd, d?d->uidno:0, 4);  /* POSIX st_uid    */
		Cputn(cd, d?d->gidno:0, 4);  /* POSIX st_gid    */
	}

	return 36;
}
Example #3
0
void file_info(char* fileName){
 
 
  struct stat buf;
  int ret = stat(fileName, &buf);
  
  if(S_ISDIR(buf.st_mode)) 
      printf("d");
  else
      printf("-");
  info(buf);
  
  nlink(buf);
  printf(" %s ",get_uid(buf));
  printf("%s ",get_gid(buf));
  get_size(buf);
  get_time(buf);
  printf("  %s ",fileName);
  printf("\n");
  
}
struct listnode *dellink(struct listnode *head,int t)
{
	 int position,count=0,x,y,i;
	 struct listnode *p,*temp;
	 char ch[50];

		if(head==0)
		{
			getdata(300,400,0,"LIST IS EMPTY");
			return head;
		}

	 for(count=0,p=head;p!=0;count++,p=p->next)
		temp=p;

	 position=getdata(300,400,2,"WHICH POSITION TO DELETE");
		if(position==0||position>count)
		{
			getdata(300,400,0,"           INVALID POSITION");
			return head;
		}

	 if(position==1)
	 {
	  opmessage( 160, 400, ' ',"Move Head to Head->next Node",LIGHTGREEN);
			nlink(160,100,1);
			delay(1000);

			temp=head;
			head=head->next;
			free(temp);

			head->pre=0;
			head->padd=0;
	opmessage( 160, 400, ' ',"Move Head to Head->next Node",BLACK);

			display(head,t);
			return head;
	 }

	 sprintf(ch,"Put Link %d Node  To %d Node",position-1,position+1);
	 opmessage( 160, 400, ' ',ch,LIGHTGREEN);


	 for( i=2,p=head;i<position;i++,p=p->next);

	 if(position==5&&count==position||position==9&&position==count)
	 {
		if(position==5)
			newlink(520,100,1);
		else
			newlink(520,200,1);

			temp=p->next;
			p->next=0;
			p->nadd=0;
			free(temp);
			sleep(1);

	   opmessage( 160, 400, ' ',ch,BLACK);

			display(head,t);
			return head;
	 }

	 if(count==position)
	 {
		if(position<13)
			y=300;
		if(position<9)
			y=200;
		if(position<5)
			y=100;

		if(position==2||position==10||position==6)
			x=160;
		if(position==3||position==11||position==7)
			x=280;
		if(position==4||position==12||position==8)
			x=400;

		temp=p->next;
		p->next=0;
		p->nadd=0;
		free(temp);

		nlink(x,y,1);
		sleep(1);
	   opmessage( 160, 400, ' ',ch,BLACK);

		display(head,t);
		return head;
	 }

		temp=p->next;
		p->next=p->next->next;
		p->next->pre=p;
		p->next->padd=p->add;
		p->nadd=p->next->add;

		free(temp);

     if(position==4||position==8)
	{
	  if(position==4)
		y=100;
	  else
		y=200;

			x=400;

		newlink(520,y,1);
		nlink(400,y,1);
		d4link(x,y);
		sleep(1);
	opmessage( 160, 400, ' ',ch,BLACK);

		display(head,t);
		return head;
	}

     if(position==5||position==9)
	{
		if(position==5)
			y=100;
		else
			y=200;

				x=520;

		newlink(520,y,1);
		d5link(x,y);
		sleep(1);
	 opmessage( 160, 400, ' ',ch,BLACK);

		display(head,t);
		return head;
	}

		if(position<12)
			y=300;
		if(position<8)
			y=200;
		if(position<4)
			y=100;

		if(position==2||position==6)
			x=280;
		if(position==3||position==7)
			x=400;

		nlink(x-120,y,1);
		nlink(x,y,1);
		dmlink(x-120,y);
		sleep(1);
	 opmessage( 160, 400, ' ',ch,BLACK);

		display(head,t);

	 return head;

}
struct listnode *insertnode(struct listnode *head,int *address,int t)
{
	 int info,i,x,y,count=0,position;
	 struct listnode *p,*temp;
	 char ch[50];

		if(head==0)
		{
			getdata(300,400,0,"            LIST IS EMPTY");
			return head;
		}

		info=getdata(300,400,2,"ENTER A NUM(2 DIGI)0 EXIT");

	for(count=0,p=head;p!=0;p=p->next,count++);

	sprintf(ch,"ENTER POSITION(1 TO %d)",count+1);
	position=getdata(300,400,2,ch);


	if(position<=0||position>12||count+1<position)
	{
		getdata(300,400,0,"          INVALID POSITION ");
		return head;
	}

     if(count>=12)
     {
	  getdata(300,400,0,"CAN'T TAKE MORE THAN 12 NODES");
	  return head;
     }

	temp=(struct listnode*)calloc(sizeof(struct listnode),1);

	if(temp==0)
	{
	   getdata(100,100,0,"Memory not avilable,con't create node");
	   return head;
	}

	temp->pre=0;
	temp->next=0;
	temp->num=info;
	temp->add=*address;

	*address+=50;
	temp->padd=0;
	temp->nadd=0;

 if(position==1)
   {
opmessage( 160, 400, ' ',"Put Link New Node to Head Node And Set Head Is New Node",MAGENTA);
		drawnode(160,150,temp,t);
		firstlink();
		sleep(1);
opmessage( 160, 400, ' ',"Put Link New Node to Head Node And Set Head Is New Node",BLACK);

		temp->next=head;
		head->pre=temp;
		head->padd=temp->add;
		temp->nadd=head->add;
		head=temp;

		display(head,t);
		return head;

   }

     for( i=2,p=head;i<position&&p->next!=0;i++,p=p->next);

     if(count+1==position)
	{
 opmessage( 160, 400, ' ',"Create New Node And Put Link Last Node to New Node ",MAGENTA);
	 sleep(1);
 opmessage( 160, 400, ' ',"Create New Node And Put Link Last Node to New Node ",BLACK);

		p->next=temp;
		temp->pre=p;
		temp->padd=p->add;
		p->nadd=temp->add;

		display(head,t);

		return head;
	}

   sprintf(ch,"Create New Node And Put Link New Node to  %d Node ",position);
   opmessage( 160, 400, ' ',ch,MAGENTA);
   sprintf(ch," And Put Link  %d Node To New Node ",position-1);
   opmessage( 160, 410, ' ',ch,MAGENTA);
   delay(1000);

			temp->next=p->next;
			p->next->pre=temp;
			temp->nadd=p->next->add;
			p->next->padd=temp->add;
			temp->pre=p;
			temp->padd=p->add;
			p->next=temp;
			p->nadd=temp->add;

		if(position==5||position==9)
		{
			if(position==5)
			y=150;
			else
			y=250;

		  x=520;
		  newlink(x,y-50,1);
		  drawnode(x,y,temp,t);
		  rlinelink(x,y);
		  sleep(1);
		  llinelink(x,y-50);

			sleep(1);
   sprintf(ch,"Create New Node And Put Link New Node to  %d Node ",position);
	   opmessage( 160, 400, ' ',ch,BLACK);
   sprintf(ch," And Put Link  %d Node To New Node ",position-1);
	   opmessage( 160, 410, ' ',ch,BLACK);

			display(head,t);

			return head;
		}

				if(position>1&&position<5)
					y=100;
				if(position>5&&position<9)
					y=200;
				if(position>9&&position<12)
					y=300;

				if(position==2||position==6||position==10)
					x=160;
				if(position==3||position==7||position==11)
					x=280;
				if(position==4||position==8)
					x=400;

		drawnode(x+60,y+50,temp,t);
		nlink(x,y,1);
		rlink(x+120,y);
		sleep(1);

		llink(x,y);

		sleep(1);
   sprintf(ch,"Create New Node And Put Link New Node to  %d Node ",position);
		opmessage( 160, 400, ' ',ch,BLACK);
   sprintf(ch," And Put Link  %d Node To New Node ",position-1);
		opmessage( 160, 410, ' ',ch,BLACK);

		display(head,t);

	   return head;

}