Lines Matching defs:scan
208 * open a scan stream
216 Dllscan_t* scan;
243 if (!(scan = vmnewof(vm, 0, Dllscan_t, 1, i)) || !(scan->tmp = sfstropen()))
248 scan->vm = vm;
250 scan->flags = info->flags;
253 scan->lib = (char**)(scan + 1);
254 s = *scan->lib = (char*)(scan->lib + 2);
262 scan->flags |= DLL_MATCH_NAME;
266 if (!(scan->pb = vmnewof(vm, 0, char, t - (char*)name, 2)))
268 memcpy(scan->pb, name, t - (char*)name);
293 scan->flags |= DLL_MATCH_VERSION;
304 scan->flags |= DLL_MATCH_VERSION;
305 sfsprintf(scan->nam, sizeof(scan->nam), "%s%s%s", info->prefix, name, info->suffix);
307 else if (scan->flags & DLL_INFO_PREVER)
309 sfprintf(scan->tmp, "%s%s", info->prefix, name);
312 sfputc(scan->tmp, *s);
313 sfprintf(scan->tmp, "%s", info->suffix);
314 if (!(s = sfstruse(scan->tmp)))
316 sfsprintf(scan->nam, sizeof(scan->nam), "%s", s);
319 sfsprintf(scan->nam, sizeof(scan->nam), "%s%s%s.%s", info->prefix, name, info->suffix, version);
320 if (scan->flags & (DLL_MATCH_NAME|DLL_MATCH_VERSION))
322 if (scan->flags & DLL_INFO_PREVER)
335 sfsprintf(scan->pat, sizeof(scan->pat), "%s%s%s%s", info->prefix, name, version, info->suffix);
338 sfsprintf(scan->pat, sizeof(scan->pat), "%s%s@(%s([-.])%s%s|%s.%s)", info->prefix, name, strchr(version, '.') ? "@" : "?", version, info->suffix, info->suffix, version);
342 sfsprintf(scan->pat, sizeof(scan->pat), "%s%s@(?([-.])%s%s|%s%s)", info->prefix, name, version, info->suffix, info->suffix, version);
345 scan->sp = scan->sb = (scan->lib ? scan->lib : info->sibling);
346 scan->prelen = strlen(info->prefix);
347 scan->suflen = strlen(info->suffix);
348 return scan;
350 dllsclose(scan);
355 * close a scan stream
359 dllsclose(Dllscan_t* scan)
361 if (!scan)
363 if (scan->fts)
364 fts_close(scan->fts);
365 if (scan->dict)
366 dtclose(scan->dict);
367 if (scan->tmp)
368 sfclose(scan->tmp);
369 if (scan->vm)
370 vmclose(scan->vm);
375 * return the next scan stream entry
379 dllsread(register Dllscan_t* scan)
388 if (scan->flags & DLL_MATCH_DONE)
393 while (!scan->ent || !(scan->ent = scan->ent->fts_link))
395 if (scan->fts)
397 fts_close(scan->fts);
398 scan->fts = 0;
400 if (!scan->pb)
401 scan->pb = pathbin();
402 else if (!*scan->sp)
404 scan->sp = scan->sb;
405 if (!*scan->pe++)
407 scan->pb = scan->pe;
409 for (p = scan->pp = scan->pb; *p && *p != ':'; p++)
411 scan->pp = p;
412 scan->pe = p;
413 if (*scan->sp == bin)
414 scan->off = sfprintf(scan->tmp, "%-.*s", scan->pe - scan->pb, scan->pb);
416 scan->off = sfprintf(scan->tmp, "%-.*s/%s", scan->pp - scan->pb, scan->pb, *scan->sp);
417 scan->sp++;
418 if (!(scan->flags & DLL_MATCH_NAME))
420 sfprintf(scan->tmp, "/%s", scan->nam);
421 if (!(p = sfstruse(scan->tmp)))
425 b = scan->nam;
431 if (scan->flags & (DLL_MATCH_NAME|DLL_MATCH_VERSION))
433 sfstrseek(scan->tmp, scan->off, SEEK_SET);
434 if (!(t = sfstruse(scan->tmp)))
436 if ((scan->fts = fts_open((char**)t, FTS_LOGICAL|FTS_NOPOSTORDER|FTS_ONEPATH, vercmp)) && (scan->ent = fts_read(scan->fts)) && (scan->ent = fts_children(scan->fts, FTS_NOSTAT)))
440 } while (!strmatch(scan->ent->fts_name, scan->pat));
441 b = scan->ent->fts_name;
442 sfstrseek(scan->tmp, scan->off, SEEK_SET);
443 sfprintf(scan->tmp, "/%s", b);
444 if (!(p = sfstruse(scan->tmp)))
447 b = scan->buf + sfsprintf(scan->buf, sizeof(scan->buf), "%s", b + scan->prelen);
448 if (!(scan->flags & DLL_INFO_PREVER))
449 while (b > scan->buf)
455 b -= scan->suflen;
456 if (b > (scan->buf + 2) && (*(b - 1) == 'g' || *(b - 1) == 'O') && *(b - 2) == '-')
459 for (t = b; t > scan->buf; t--)
492 if (m || (scan->flags & DLL_INFO_PREVER))
496 if (!*(b = scan->buf))
498 if (scan->uniq)
500 if (!scan->dict)
502 scan->disc.key = offsetof(Uniq_t, name);
503 scan->disc.size = 0;
504 scan->disc.link = offsetof(Uniq_t, link);
505 if (!(scan->dict = dtopen(&scan->disc, Dthash)))
507 dtinsert(scan->dict, scan->uniq);
509 if (dtmatch(scan->dict, b))
511 if (!(u = vmnewof(scan->vm, 0, Uniq_t, 1, strlen(b))))
514 dtinsert(scan->dict, u);
516 else if (!(scan->flags & DLL_MATCH_NAME))
517 scan->flags |= DLL_MATCH_DONE;
518 else if (!(scan->uniq = vmnewof(scan->vm, 0, Uniq_t, 1, strlen(b))))
521 strcpy(scan->uniq->name, b);
522 scan->entry.name = b;
523 scan->entry.path = p;
524 return &scan->entry;