home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
SOURCE
/
CSSRC
/
SDNAMVAR.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-10-04
|
2KB
|
103 lines
/*
sdnamvar.c
% sed_GetNameVar, sed_SetNameVar
C-scape 3.2
Copyright (c) 1986-1989, by Oakland Group, Inc.
ALL RIGHTS RESERVED.
Revision History:
-----------------
3/28/90 jmd ansi-fied
8/24/90 mla changed sd_setnamevar to sed_SetNameVarValue
8/24/90 mla added sed_SetNameVar, sed_SetVarValue
9/16/90 jdc fixed SetNameVar fld == 0 bug
10/04/90 jmd added casts for C++
*/
#include "sed.h"
VOID *sed_GetNameVar(sed_type sed, char *name)
/*
This routine retrieves the location of a named fields variable
It returns NULL if the sed has no field named name
*/
{
int fld;
if ((fld = sed_GetNameNo(sed, name)) < 0) {
return(NULL);
}
return(sed_GetVar(sed, fld));
}
boolean sed_SetNameVar(sed_type sed, char *name, VOID *var)
/*
This routine sets a named fields variable to point to a given var space
It returns TRUE if the sed contains a field with the given name
and FALSE if not
*/
{
int fld;
if ((fld = sed_GetNameNo(sed, name)) < 0) {
return(FALSE);
}
else {
sed_SetVar(sed, fld, var);
return(TRUE);
}
}
boolean sed_SetNameVarValue(sed_type sed, char *name, VOID *var)
/*
This routine copies a new value into a named fields variable space
It's return value indicates success or failure
*/
{
int fld;
if ((fld = sed_GetNameNo(sed, name)) < 0) {
return(FALSE);
}
return(sed_SetVarValue(sed, fld, var));
}
boolean sed_SetVarValue(sed_type sed, int fld, VOID *var)
/*
This routine copies a new value into a fields variable space
It return value indicates success or failure
*/
{
int len;
if (var == NULL) {
return(FALSE);
}
switch((len = (int) field_GetVarSize(menu_GetField(sed_GetMenu(sed), fld)))) {
case ((int) VAR_STRING):
if ((len = sed_GetRecordLen(sed, fld) + 1) > 0) {
strncpy((char *) sed_GetVar(sed, fld), (char *) var, len);
break;
}
/* fall through */
case ((int) VAR_INVALID):
case ((int) VAR_TED):
len = 0;
default:
if (len <= 0) {
return(FALSE);
}
memcpy(sed_GetVar(sed, fld), var, len);
break;
}
return(TRUE);
}