示例#1
0
//Cte radku dane 4+12 bitove adresy ze swapu
//------------------------------------------
char *ie_getswap(XSWAP adr)
{
 XSWAP lswap,ladr;

 if(adr==IE_NULL)
  return NULL;

 lswap = adr & 0xFC00;
 lswap >>= 10;
 ladr  = adr & 0x3FF;
 
 if(ladr>swaplen[lswap] || ladr > IE_MAXLS) 
 {
//  printf("Illegal xSwap handler ! (swaplen[%d]=%d)\n",lswap,swaplen[lswap]);
  return NULL;
 }
 if(ie_swap(lswap)!=1)
 {
//  printf("Failed to get xSwap buffer !\n");
  return NULL;
 }
 if(swapidx[ladr]<IE_SWAPSTART)
 {
  printf("Illegal xSwap offset !\n");
//  return NULL; //chybna adresa ! (implicitne je tam totiz nula)
 }

 return(&swapstr[swapidx[ladr]]);
}//end sub
示例#2
0
文件: IE_FCE.C 项目: ifilex/SRC
//initialization
//--------------
int ie_initswap(void)
{
 int i;
#ifndef POSIX 
 if ( swapstr == NULL ) swapstr = (char *)farmalloc( IE_MAXSWAPLEN+IE_SWAPSTART+1);
 if ( swapstr == NULL) return 2;
#endif

 swapidx=(unsigned *)swapstr;
 swapcount=0; //0 lines
 i=0;
 do
 {
  swaplen[i]=0;
  swapsize[i]=0;
#ifndef POSIX
  swapbufflag[i]=0;
#else
  swapbuf[i]=NULL; 
#endif
  swapcontext[i]=-1;
 }
 while(++i<IE_MAXSWAP);
 swapnum=-1;
 ie_swap(0);
 firstswap=0;

 return 1;
}//end sub
示例#3
0
文件: IE_FCE.C 项目: ifilex/SRC
//smaz radek dane 4+12 adresy ! (tr.: delete line of given 4+12 address !)
//-----------------------------
int ie_delswap(XSWAP adr, int l)
{
 XSWAP lswap,ladr;
 unsigned i,pom;

 lswap = adr & 0xFC00;
 lswap >>= 10;
 ladr  = adr & 0x3FF;
 if(ladr>swaplen[lswap]) return 2; //erroneous address !
 if(ie_swap(lswap)!=1) return 2;
 if(swapidx[ladr]<IE_SWAPSTART) return 2; //(implicitne je tam totiz nula)
   // tr.: because implicitely there is zero

 pom=swapidx[ladr];
 if(l==-1) l=strlen(&swapstr[pom]);

 if (ladr<swaplen[lswap])
 {
  memmove(&swapstr[pom],&swapstr[pom+l+1],swapsize[lswap]-(pom-IE_SWAPSTART+1));
 }//endif

 swapsize[lswap]-=l+1;
 swapmod=1;
 i=0;
 while (i<swaplen[lswap])
 {
  if(swapidx[i]>pom)swapidx[i]-=l+1;
  i++;
 }//loop
 swapidx[ladr]=IE_NULL; //empty
 return 1;
}
示例#4
0
XSWAP ie_putswap(char *line, unsigned l, int context)
{
 XSWAP ladr;
 unsigned newswap=firstswap;

 //printf("***storing %u bytes....",l);
 
 retry: //prohledavani dalsiho bufferu
 ladr=0;

 if((long)swapsize[swapnum]+(long)l>IE_MAXSWAPLEN || (swapcontext[swapnum]!=context))
  goto newswap;

 while (ladr<swaplen[swapnum] && swapidx[ladr]>=IE_SWAPSTART) ladr++;

 if(ladr==swaplen[swapnum])
 {
  if (swaplen[swapnum]>IE_MAXLS)
  {
   newswap++;

   newswap:

   while( newswap<IE_MAXSWAP &&
          ((swapcontext[newswap]>=0 && swapcontext[newswap]!=context)
           || (long)swapsize[newswap]+(long)l>IE_MAXSWAPLEN) )
    newswap++;

   // zrejme uz to bylo prohledany vsechno,vrat jedinou neplatnou adresu radky
   if (newswap>=IE_MAXSWAP)
     return IE_NULL;

   swapcontext[newswap]=context;
   ie_swap(newswap);

   goto retry;
   // drive tady bylo rovnou: ladr=swaplen[swapnum];
  }//endif
  swaplen[swapnum]++;
 }//endif

 swapidx[ladr]=IE_SWAPSTART+swapsize[swapnum];
 swapsize[swapnum]+=(l+1);
 if(line) //line=NULL ... just allocate, do not copy
  memcpy(&swapstr[swapidx[ladr]],line,l);
 swapstr[swapidx[ladr]+l]='\0';
 swapcontext[swapnum]=context;
 swapmod=1;

 //printf("stored to swap %u at position %u\n",newswap,swapidx[ladr]);

 return (swapnum << 10 ) | ladr;
}//end sub
示例#5
0
文件: IE_FCE.C 项目: ifilex/SRC
//Meni j*z existujici radku (tr.: changes already existing line)
//-------------------------
XSWAP ie_chngswap(char*line, XSWAP adr, int context)
{
 char *ptr;
 XSWAP lswap,ladr;

 ptr=ie_getswap(adr);
 if(ptr!=NULL)
 {
  if(strlen(ptr)==strlen(line))
  {
   lswap = adr & 0xFC00;
   lswap >>= 10;
   ladr  = adr & 0x3FF;
   if(ladr>swaplen[lswap]) return IE_NULL; //erroneous address !
   if(ie_swap(lswap)!=1) return IE_NULL;
   if(swapidx[ladr]<IE_SWAPSTART) return IE_NULL; //(implicitne je tam totiz nula)
          // tr.: because implicitely there is zero
   strcpy(&swapstr[swapidx[ladr]],line);
   swapmod=1;
   return adr;
  }
  else
   if (ie_delswap(adr,-1)!=1) return IE_NULL;