Lines Matching refs:csc
101 CSC *, char *, char **, size_t *, int *));
102 static int get_paths __P((SCR *, CSC *));
104 static int parse __P((SCR *, CSC *, TAGQ *, int *));
105 static int read_prompt __P((SCR *, CSC *));
106 static int run_cscope __P((SCR *, CSC *, const char *));
108 static int terminate __P((SCR *, CSC *, int));
208 CSC *csc;
271 CALLOC_RET(sp, csc, CSC *, 1, sizeof(CSC) + len);
272 csc->dname = csc->buf;
273 csc->dlen = len;
274 memcpy(csc->dname, np, len);
275 csc->mtime = sb.st_mtime;
278 if (get_paths(sp, csc))
282 if (run_cscope(sp, csc, dbname))
287 * on error, we have to call terminate, which expects the csc to
290 LIST_INSERT_HEAD(&exp->cscq, csc, q);
293 return read_prompt(sp, csc);
295 err: free(csc);
305 get_paths(SCR *sp, CSC *csc)
324 (void)snprintf(buf, sizeof(buf), "%s/%s", csc->dname, CSCOPE_PATHS);
328 MALLOC_RET(sp, csc->pbuf, char *, len + 1);
330 (size_t)read(fd, csc->pbuf, len) != len) {
337 csc->pbuf[len] = '\0';
340 for (nentries = 0, p = csc->pbuf; *p != '\0'; ++p)
346 csc->paths, char **, nentries + 1, sizeof(char **));
347 for (pathp = csc->paths, p = strtok(csc->pbuf, ":");
357 if ((csc->pbuf = strdup(csc->dname)) == NULL) {
361 CALLOC_GOTO(sp, csc->paths, char **, 2, sizeof(char *));
362 csc->paths[0] = csc->pbuf;
366 if (csc->pbuf != NULL) {
367 free(csc->pbuf);
368 csc->pbuf = NULL;
378 run_cscope(SCR *sp, CSC *csc, const char *dbname)
392 switch (csc->pid = vfork()) {
416 CSCOPE_CMD_FMT, csc->dname, dbname);
430 csc->to_fd = to_cs[1];
431 csc->to_fp = fdopen(to_cs[1], "w");
432 csc->from_fd = from_cs[0];
433 csc->from_fp = fdopen(from_cs[0], "r");
446 CSC *csc, *csc_next;
500 LIST_FOREACH_SAFE(csc, &exp->cscq, q, csc_next) {
507 (void)fprintf(csc->to_fp, "%zu%s\n", search, tqp->tag + 2);
508 (void)fflush(csc->to_fp);
511 if (parse(sp, csc, tqp, &matches)) {
662 parse(SCR *sp, CSC *csc, TAGQ *tqp, int *matchesp)
671 if (!fgets(buf, sizeof(buf), csc->from_fp))
685 msgq(sp, M_ERR, "%s: \"%s\"", csc->dname, buf);
689 if (fgets(buf, sizeof(buf), csc->from_fp) == NULL)
694 while ((ch = getc(csc->from_fp)) != EOF && ch != '\n');
728 csc_file(sp, csc, name, &dname, &dlen, &isolder);
764 return read_prompt(sp, csc);
766 io_err: if (feof(csc->from_fp))
768 msgq_str(sp, M_SYSERR, "%s", csc->dname);
769 terminate(sp, csc, 0);
778 csc_file(SCR *sp, CSC *csc, char *name, char **dirp, size_t *dlenp, int *isolderp)
790 for (pp = csc->paths; *pp != NULL; ++pp) {
795 *isolderp = sb.st_mtime < csc->mtime;
863 terminate(SCR *sp, CSC *csc, int n)
871 * We either get a csc structure or a number. If not provided a
872 * csc structure, find the right one.
874 if (csc == NULL) {
878 LIST_FOREACH(csc, &exp->cscq, q)
881 if (csc == NULL) {
895 if (csc->from_fp != NULL)
896 (void)fclose(csc->from_fp);
897 if (csc->to_fp != NULL)
898 (void)fclose(csc->to_fp);
899 (void)waitpid(csc->pid, &pstat, 0);
902 LIST_REMOVE(csc, q);
903 if (csc->pbuf != NULL)
904 free(csc->pbuf);
905 if (csc->paths != NULL)
906 free(csc->paths);
907 free(csc);
938 CSC *csc;
947 LIST_FOREACH(csc, &exp->cscq, q)
949 "%2d %s (process %lu)\n", i++, csc->dname, (u_long)csc->pid);
1026 read_prompt(SCR *sp, CSC *csc)
1033 getc(csc->from_fp)) != EOF && ch != CSCOPE_PROMPT[0]);
1035 terminate(sp, csc, 0);
1038 if (getc(csc->from_fp) != CSCOPE_PROMPT[1])
1040 if (getc(csc->from_fp) != CSCOPE_PROMPT[2])