char * str_relpath(char *f,char *t) /* This function is written in order to provide proper freeing of the * auxiliary chains of structures */ { struct pathnode *p; struct pathnode *r; struct pathnode *q; char *w; p = strtopath(f); q = strtopath(t); r = relpath(strtopath(f),strtopath(t)); w = pathtostr(r); freepath(p); freepath(q); freepath(r); return w; }
void setpath(char *path) { short bytes; freepath(); bytes=strlen(path+1); defpathname = (char *) AllocMem(bytes,0); msgf("Path len %d\n",bytes-1); strcpy(defpathname, path); msgf("New path: %s\n",defpathname); }
void synccleanup(Syncpath *s) { Syncpath *up; int i; /* * Update the parent counts. Once all the parent's * kids finish successfully, the parent finishes * successfully. */ up = s->parent; if(up){ if(!s->a.complete) up->a.complete = 0; if(!s->b.complete) up->b.complete = 0; if(s->state != SyncDone) up->finishstate = s->state; if(--up->npend == 0){ up->state = up->finishstate; syncfinish(up); } } /* * Free our own kids, if there are any. */ for(i=0; i<s->nkid; i++){ freestat(s->kid[i].a.s); freestat(s->kid[i].b.s); freepath(s->kid[i].p); free(s->kid[i].err); } free(s->kid); s->kid = nil; }
/* * whereis name * look for source, documentation and binaries */ int main(int argc, char **argv) { setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); atexit(close_stdout); argc--, argv++; if (argc == 0) usage(stderr); do if (argv[0][0] == '-') { register char *cp = argv[0] + 1; while (*cp) switch (*cp++) { case 'f': break; case 'S': getlist(&argc, &argv, &Sflag, &Scnt); break; case 'B': getlist(&argc, &argv, &Bflag, &Bcnt); break; case 'M': getlist(&argc, &argv, &Mflag, &Mcnt); break; case 's': zerof(); sflag++; continue; case 'u': uflag++; continue; case 'b': zerof(); bflag++; continue; case 'm': zerof(); mflag++; continue; case 'V': printf(_("%s from %s\n"), program_invocation_short_name, PACKAGE_STRING); return EXIT_SUCCESS; case 'h': usage(stdout); default: usage(stderr); } argv++; } else { if (Bcnt == 0 && pathdir == NULL) fillpath(); lookup(*argv++); } while (--argc > 0); freepath(); return EXIT_SUCCESS; }