Lines Matching refs:dp
60 static void addmapping(register Dosdisc_t *dp)
62 static void addmapping(dp)
63 register Dosdisc_t *dp;
67 if((n=dp->maptop++)>=dp->mapsize)
69 dp->mapsize *= 2;
70 if(!(dp->maptable=(struct map*)realloc((void*)dp->maptable,(dp->mapsize+1)*sizeof(struct map))))
72 dp->maptop--;
73 dp->mapsize *= 2;
77 dp->maptable[n].physical = dp->phere;
78 dp->maptable[n].logical = dp->lhere;
79 dp->maptable[dp->maptop].logical=0;
83 static struct map *getmapping(Dosdisc_t *dp, Sfoff_t offset, register int whence)
85 static struct map *getmapping(dp, offset, whence)
86 Dosdisc_t *dp;
93 if(offset <= dp->begin)
98 if(!(mp=dp->maptable))
100 dummy.logical = dp->begin;
118 register Dosdisc_t *dp = (Dosdisc_t*)disc;
121 if(dp->extra)
123 dp->extra=0;
124 *cp = dp->last;
131 dp->plast=dp->phere;
132 dp->phere +=n;
133 dp->llast = dp->lhere;
135 if(dp->last=='\r' && *cp!='\n')
139 dp->last = *cpmax;
142 if(dp->last!='\r')
144 dp->lhere++;
148 if(dp->last=='\r')
150 else if(dp->last!='\n' || cpmax[-1]!='\r')
152 dp->lhere += n;
159 dp->skip = cp-1 - (char*)buff;
163 *cpmax = dp->last;
164 if(!dp->maptable)
165 dp->begin +=n;
166 dp->skip++;
170 if(!dp->maptable)
172 dp->begin += cp - (char*)buff-1;
173 if(dp->maptable=(struct map*)malloc((MINMAP+1)*sizeof(struct map)))
175 dp->mapsize = MINMAP;
176 dp->maptable[0].logical= dp->begin;
177 dp->maptable[0].physical = dp->maptable[0].logical+1;
178 dp->maptable[1].logical=0;
179 dp->maptop = 1;
183 if(count>dp->bsize)
185 if(dp->bsize==0)
186 dp->buff = malloc(count);
188 dp->buff = realloc(dp->buff,count);
189 dp->bsize = count;
190 if(!dp->buff)
193 memcpy(dp->buff, cp, count);
210 cpmax[-count] = dp->last;
211 dp->lhere -= count;
213 if(dp->lhere>dp->lmax)
215 dp->lmax = dp->lhere;
216 dp->pmax = dp->phere;
217 if(dp->maptable && dp->lmax > dp->maptable[dp->maptop-1].logical+CHUNK)
218 addmapping(dp);
230 static Sfoff_t cur_offset(Dosdisc_t *dp, Sfoff_t offset,Sfio_t *iop,register int whence)
232 static Sfoff_t cur_offset(dp, offset, iop, whence)
233 Dosdisc_t *dp;
245 n = offset - dp->plast;
247 offset = dp->llast;
252 n = offset - dp->llast;
253 offset = dp->plast;
256 if((n -= dp->skip) > 0)
259 cp = (char*)dp->buff;
285 register Dosdisc_t *dp = (Dosdisc_t*)disc;
294 if(offset<=dp->begin)
297 if(offset==dp->phere)
298 return(dp->lhere);
299 else if(offset==dp->plast)
300 return(dp->llast);
301 else if(offset<dp->plast || offset>dp->phere)
302 mp = getmapping(dp,offset,whence);
306 if(offset<dp->llast || offset > dp->lhere)
307 mp = getmapping(dp,offset,whence);
310 if(!dp->maptable)
313 mp->physical = dp->plast;
314 mp->logical = dp->llast;
324 dp->phere = mp->physical;
325 dp->lhere = mp->logical;
331 if(whence==SEEK_CUR && dp->phere>=offset)
333 if(whence==SEEK_SET && dp->lhere>=offset)
342 offset = dp->lhere;
350 offset += dp->lhere;
353 physical = cur_offset(dp,offset,iop,whence);
357 dp->phere = physical;
358 dp->lhere = offset;
376 register Dosdisc_t *dp = (Dosdisc_t*)disc;
379 if(dp->bsize>0)
380 free((void*)dp->buff);
381 if(dp->mapsize)
382 free((void*)dp->maptable);