Ups, there were some wrong usages of path/buf in the last code example. Sorry.
> key_t > ftok(const char *path, int id) > { > struct stat statbuf; > // call stat() only as file existing check > if (stat(path, &statbuf)) > { > /* stat set the appropriate errno for us */ > return (key_t) -1; > } > #ifdef CASE1 > char buf[MAX_PATH]; > sprintf(buf,"%s%08x",path,id); > return hash_path_name(0,buf); > #else /* CASE2 */ > return hash_path_name(id,path); > #endif > }