home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frostbyte's 1980s DOS Shareware Collection
/
floppyshareware.zip
/
floppyshareware
/
DOOG
/
CBASE09.ZIP
/
LSEQ.ZIP
/
LSINSERT.C
< prev
next >
Wrap
Text File
|
1989-08-30
|
2KB
|
85 lines
/* Copyright (c) 1989 Citadel */
/* All Rights Reserved */
/* #ident "lsinsert.c 1.1 - 89/07/03" */
#include <blkio.h>
#include <errno.h>
/* #include <string.h> */
#include "lseq_.h"
/*man---------------------------------------------------------------------------
NAME
lsinsert - lseq insert
SYNOPSIS
#include <lseq.h>
int lsinsert(lsp, buf)
lseq_t *lsp;
void *buf;
DESCRIPTION
The lsinsert function inserts the record pointed to by buf into lseq
lsp. The record is inserted as the last record. The cursor is set to
the inserted record.
lsinsert will fail if one or more of the following is true:
[EINVAL] lsp is not a valid lseq pointer.
[EINVAL] buf is the NULL pointer.
[LSELOCK] lsp is not write locked.
[LSENOPEN] lsp is not open.
SEE ALSO
lsdelcur, lsinscur, lssearch.
DIAGNOSTICS
Upon successful completion, a value of 0 is returned. Otherwise, a
value of -1 is returned and errno is set to indicate the error.
------------------------------------------------------------------------------*/
int lsinsert(lsp, buf)
lseq_t * lsp;
void * buf;
{
int rs = 0;
errno = 0;
/* validate arguments */
if ((!ls_valid(lsp)) || (buf == NULL)) {
errno = EINVAL;
return -1;
}
/* check if not open */
if (!(lsp->flags & LSOPEN)) {
errno = LSENOPEN;
return -1;
}
/* check if not write locked */
if (!(lsp->flags & LSWRLCK)) {
errno = LSELOCK;
return -1;
}
/* set cursor to last record */
rs = lslast(lsp);
if (rs == -1) {
LSEPRINT;
return -1;
}
/* insert record */
rs = lsinscur(lsp, buf);
if (rs == -1) {
LSEPRINT;
return -1;
}
errno = 0;
return 0;
}