121363Sdist /* 221363Sdist * Copyright (c) 1983 Regents of the University of California. 334790Sbostic * All rights reserved. 434790Sbostic * 534790Sbostic * Redistribution and use in source and binary forms are permitted 634790Sbostic * provided that the above copyright notice and this paragraph are 734790Sbostic * duplicated in all such forms and that any documentation, 834790Sbostic * advertising materials, and other materials related to such 934790Sbostic * distribution and use acknowledge that the software was developed 1034790Sbostic * by the University of California, Berkeley. The name of the 1134790Sbostic * University may not be used to endorse or promote products derived 1234790Sbostic * from this software without specific prior written permission. 1334790Sbostic * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 1434790Sbostic * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 1534790Sbostic * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 1621363Sdist */ 1721363Sdist 1826604Sdonn #if defined(LIBC_SCCS) && !defined(lint) 19*38435Smckusick static char sccsid[] = "@(#)telldir.c 5.5 (Berkeley) 07/10/89"; 2034790Sbostic #endif /* LIBC_SCCS and not lint */ 215929Smckusick 226370Smckusic #include <sys/param.h> 2336545Smckusick #include <dirent.h> 245929Smckusick 255929Smckusick /* 265929Smckusick * return a pointer into a directory 275929Smckusick */ 285929Smckusick long 295929Smckusick telldir(dirp) 305929Smckusick DIR *dirp; 315929Smckusick { 32*38435Smckusick register int index; 33*38435Smckusick register struct ddloc *lp; 3411827Smckusick 35*38435Smckusick if ((lp = (struct ddloc *)malloc(sizeof(struct ddloc))) == NULL) 36*38435Smckusick return (-1); 37*38435Smckusick index = dirp->dd_loccnt++; 38*38435Smckusick lp->loc_index = index; 39*38435Smckusick lp->loc_seek = dirp->dd_seek; 40*38435Smckusick lp->loc_loc = dirp->dd_loc; 41*38435Smckusick lp->loc_next = dirp->dd_hash[LOCHASH(index)]; 42*38435Smckusick dirp->dd_hash[LOCHASH(index)] = lp; 43*38435Smckusick return (index); 445929Smckusick } 45