Difference between revisions of "Dbrewind()"
From Recital Documentation Wiki
Yvonnemilne (Talk | contribs) |
Yvonnemilne (Talk | contribs) |
||
Line 36: | Line 36: | ||
<code lang="c"> | <code lang="c"> | ||
#include "dbl.h" | #include "dbl.h" | ||
− | char *ndx; | + | char *ndx; /* .NDX file descriptor */ |
− | char key[100]; /* Key buffer | + | char key[100]; /* Key buffer */ |
− | long recnum; /* Record number | + | long recnum; /* Record number */ |
− | int rc; /* Return code | + | int rc; /* Return code */ |
rc = dbrewind(ndx); | rc = dbrewind(ndx); | ||
− | if (rc = = SUCCESS){ | + | if (rc == SUCCESS){ |
rc = dbnkey(nfxfd, key, recnum); | rc = dbnkey(nfxfd, key, recnum); | ||
− | if (rc = = SUCCESS) printf("key read n"); | + | if (rc == SUCCESS) printf("key read \n"); |
else { | else { | ||
− | printf("error number %d n", rc); | + | printf("error number %d \n", rc); |
exit(1); | exit(1); | ||
} | } |
Revision as of 14:28, 1 May 2009
PURPOSE
rewind index file
SYNOPSIS
#include "dbl.h" int dbrewind(ndx) <input parameter> char *ndx; /* .NDX file descriptor */ <output parameter> none
RETURN VALUE
The dbrewind() function returns 0 for success, or < 0 if an error occurs. See the section on return code values for a detailed list of return codes.
DESCRIPTION
This function positions the access pointer at the beginning of the .NDX file. The subsequent dbnkey() locates the first key.
EXAMPLE
This example rewinds the .NDX file whose file descriptor is in "char *ndx" and then reads the first key from the file.
#include "dbl.h" char *ndx; /* .NDX file descriptor */ char key[100]; /* Key buffer */ long recnum; /* Record number */ int rc; /* Return code */ rc = dbrewind(ndx); if (rc == SUCCESS){ rc = dbnkey(nfxfd, key, recnum); if (rc == SUCCESS) printf("key read \n"); else { printf("error number %d \n", rc); exit(1); } }