Lines Matching full:csc

90 		    CSC *, char *, char **, size_t *, int *);
91 static int get_paths(SCR *, CSC *);
93 static int parse(SCR *, CSC *, TAGQ *, int *);
94 static int read_prompt(SCR *, CSC *);
95 static int run_cscope(SCR *, CSC *, char *);
97 static int terminate(SCR *, CSC *, int);
197 CSC *csc; in cscope_add() local
260 CALLOC_RET(sp, csc, 1, sizeof(CSC) + len); in cscope_add()
261 csc->dname = csc->buf; in cscope_add()
262 csc->dlen = len; in cscope_add()
263 memcpy(csc->dname, np, len); in cscope_add()
265 csc->mtim = sb.st_mtimespec; in cscope_add()
267 csc->mtim = sb.st_mtim; in cscope_add()
269 csc->mtim.tv_sec = sb.st_mtime; in cscope_add()
270 csc->mtim.tv_nsec = 0; in cscope_add()
274 if (get_paths(sp, csc)) in cscope_add()
278 if (run_cscope(sp, csc, dbname)) in cscope_add()
283 * on error, we have to call terminate, which expects the csc to in cscope_add()
286 SLIST_INSERT_HEAD(exp->cscq, csc, q); in cscope_add()
289 return read_prompt(sp, csc); in cscope_add()
291 err: free(csc); in cscope_add()
301 get_paths(SCR *sp, CSC *csc) in get_paths() argument
320 if ((buf = join(csc->dname, CSCOPE_PATHS)) == NULL) { in get_paths()
327 MALLOC_RET(sp, csc->pbuf, len + 1); in get_paths()
329 read(fd, csc->pbuf, len) != len) { in get_paths()
338 csc->pbuf[len] = '\0'; in get_paths()
341 for (nentries = 0, p = csc->pbuf; *p != '\0'; ++p) in get_paths()
346 CALLOC_GOTO(sp, csc->paths, nentries + 1, sizeof(char **)); in get_paths()
347 for (pathp = csc->paths, p = strtok(csc->pbuf, ":"); in get_paths()
358 if ((csc->pbuf = strdup(csc->dname)) == NULL) { in get_paths()
362 CALLOC_GOTO(sp, csc->paths, 2, sizeof(char *)); in get_paths()
363 csc->paths[0] = csc->pbuf; in get_paths()
367 free(csc->pbuf); in get_paths()
368 csc->pbuf = NULL; in get_paths()
377 run_cscope(SCR *sp, CSC *csc, char *dbname) in run_cscope() argument
391 switch (csc->pid = vfork()) { in run_cscope()
415 if ((dn = quote(csc->dname)) == NULL) in run_cscope()
443 csc->to_fd = to_cs[1]; in run_cscope()
444 csc->to_fp = fdopen(to_cs[1], "w"); in run_cscope()
445 csc->from_fd = from_cs[0]; in run_cscope()
446 csc->from_fp = fdopen(from_cs[0], "r"); in run_cscope()
459 CSC *csc, *csc_next; in cscope_find() local
515 /* Copy next connect here in case csc is killed. */ in cscope_find()
516 SLIST_FOREACH_SAFE(csc, exp->cscq, q, csc_next) { in cscope_find()
523 (void)fprintf(csc->to_fp, "%lu%s\n", search, tqp->tag + 2); in cscope_find()
524 (void)fflush(csc->to_fp); in cscope_find()
527 if (parse(sp, csc, tqp, &matches)) in cscope_find()
671 parse(SCR *sp, CSC *csc, TAGQ *tqp, int *matchesp) in parse() argument
682 if (!fgets(buf, sizeof(buf), csc->from_fp)) in parse()
696 msgq(sp, M_ERR, "%s: \"%s\"", csc->dname, buf); in parse()
700 if (fgets(buf, sizeof(buf), csc->from_fp) == NULL) in parse()
705 while ((ch = getc(csc->from_fp)) != EOF && ch != '\n'); in parse()
739 csc_file(sp, csc, name, &dname, &dlen, &isolder); in parse()
786 return read_prompt(sp, csc); in parse()
788 io_err: if (feof(csc->from_fp)) in parse()
790 msgq_str(sp, M_SYSERR, "%s", csc->dname); in parse()
791 terminate(sp, csc, 0); in parse()
800 csc_file(SCR *sp, CSC *csc, char *name, char **dirp, size_t *dlenp, int *isolderp) in csc_file() argument
812 for (pp = csc->paths; *pp != NULL; ++pp) { in csc_file()
824 &sb.st_mtimespec, &csc->mtim, <); in csc_file()
827 &sb.st_mtim, &csc->mtim, <); in csc_file()
829 *isolderp = sb.st_mtime < csc->mtim.tv_sec; in csc_file()
903 terminate(SCR *sp, CSC *csc, int n) in terminate() argument
907 CSC *cp, *pre_cp = NULL; in terminate()
912 * We either get a csc structure or a number. Locate and remove in terminate()
915 if (csc == NULL && n < 1) in terminate()
919 if (csc == NULL ? i != n : cp != csc) { in terminate()
927 csc = cp; in terminate()
930 if (csc == NULL) { in terminate()
942 if (csc->from_fp != NULL) in terminate()
943 (void)fclose(csc->from_fp); in terminate()
944 if (csc->to_fp != NULL) in terminate()
945 (void)fclose(csc->to_fp); in terminate()
947 (void)kill(csc->pid, SIGTERM); in terminate()
948 (void)waitpid(csc->pid, &pstat, 0); in terminate()
951 free(csc->pbuf); in terminate()
952 free(csc->paths); in terminate()
953 free(csc); in terminate()
994 CSC *csc; in cscope_display() local
1002 SLIST_FOREACH(csc, exp->cscq, q) in cscope_display()
1004 ++i, csc->dname, (u_long)csc->pid); in cscope_display()
1081 read_prompt(SCR *sp, CSC *csc) in read_prompt() argument
1088 getc(csc->from_fp)) != EOF && ch != CSCOPE_PROMPT[0]); in read_prompt()
1090 terminate(sp, csc, 0); in read_prompt()
1093 if (getc(csc->from_fp) != CSCOPE_PROMPT[1]) in read_prompt()
1095 if (getc(csc->from_fp) != CSCOPE_PROMPT[2]) in read_prompt()