home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
SOURCE
/
CSSRC
/
MSYSDO.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-03-28
|
2KB
|
88 lines
/*
msysdo.c
% msys_do
C-scape 3.2
Copyright (c) 1988, by Oakland Group, Inc.
ALL RIGHTS RESERVED.
Revision History:
-----------------
11/25/88 jdc created
6/01/89 jdc added MSYS_GETBOB message
7/15/89 ted Moved cast to right side in 'data = sed_GetFieldBob'.
7/26/89 jmd LOCK message is now passed a (byte *)
12/12/89 jmd Added msys_Lock() function.
3/28/90 jmd ansi-fied
*/
#include <stdio.h>
#include <ctype.h>
#include "cscape.h"
#include "oaktag.h" /* For IDs in msys.h */
#include "msys.h"
/* -------------------------------------------------------------------------- */
boolean msys_Lock(sed_type sed, int *code, byte attr)
/*
"lock" a menu choice.
*/
{
return(msys_do(sed, code, MSYS_LOCK, (VOID *) &attr));
}
/* -------------------------------------------------------------------------- */
boolean msys_do(sed_type sed, int *code, int msg, VOID *data)
/*
Find the nested menu field specified by the string of field numbers in
'code', and perform an operation on it specified by 'msg'.
The 'code' string must be terminated by a -1.
*/
{
int i;
bob_type bob;
boolean ret = TRUE;
if (code[0] == -1) {
return(FALSE);
}
/* Trace the tree down to the specified bob and field */
for (i = 0; code[i+1] != -1; i++) {
bob = sed_GetFieldBob(sed, code[i]);
if (bob == NULL || !bob_IsSed(bob)) {
return(FALSE);
}
}
if (code[i] >= sed_GetFieldCount(bob)) {
return(FALSE);
}
switch (msg) {
case MSYS_LOCK:
sed_ProtectField(bob, code[i]);
sed_MarkField(bob, code[i], *((byte *) data), *((byte *) data));
sed_UpdateField(bob, code[i]);
break;
case MSYS_UNLOCK:
sed_UnProtectField(bob, code[i]);
sed_UnMarkField(bob, code[i]);
sed_UpdateField(bob, code[i]);
break;
case MSYS_ISLOCKED:
ret = sed_IsProtectedField(bob, code[i]);
break;
case MSYS_SETBOB:
sed_SetFieldBob(bob, code[i], (bob_type)data);
break;
case MSYS_GETBOB:
data = (VOID *) sed_GetFieldBob(bob, code[i]);
break;
}
return(ret);
}
/* -------------------------------------------------------------------------- */