[2] | 1 | /*
|
---|
| 2 | ** A small container to hold a set of user block declaration
|
---|
| 3 | **
|
---|
| 4 | * Written by Paul Lebrun, Aug 2001
|
---|
| 5 | */
|
---|
| 6 | #include <stdio.h>
|
---|
| 7 | #include <string.h>
|
---|
| 8 | #include <sys/param.h>
|
---|
| 9 | #include <rpc/types.h>
|
---|
| 10 | #include <sys/types.h>
|
---|
| 11 | #include <rpc/xdr.h>
|
---|
| 12 | #include <limits.h>
|
---|
| 13 | #include <stdlib.h>
|
---|
| 14 | #include "mcfio_UserDictionary.h"
|
---|
| 15 |
|
---|
| 16 | #define NUMUSERBLOCKDEFAULT 100
|
---|
| 17 |
|
---|
| 18 | allMCFIO_UserBlockDecl *AllMCFIO_UserBlockDecl = NULL;
|
---|
| 19 |
|
---|
| 20 |
|
---|
| 21 | char *mcfioC_UserBlockDescript(int blkn)
|
---|
| 22 | {
|
---|
| 23 | int i;
|
---|
| 24 | if (AllMCFIO_UserBlockDecl == NULL) return NULL;
|
---|
| 25 | for (i=0; i<AllMCFIO_UserBlockDecl->num; i++) {
|
---|
| 26 | if (AllMCFIO_UserBlockDecl->decls[i]->blkNum == blkn)
|
---|
| 27 | return AllMCFIO_UserBlockDecl->decls[i]->title;
|
---|
| 28 | }
|
---|
| 29 | return NULL;
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | void mcfioC_DefineUserBlock(int blkN, char *descr){
|
---|
| 33 | aUserBlockDecl *abd;
|
---|
| 34 |
|
---|
| 35 | if (AllMCFIO_UserBlockDecl == NULL) {
|
---|
| 36 |
|
---|
| 37 | AllMCFIO_UserBlockDecl = (allMCFIO_UserBlockDecl *) malloc (
|
---|
| 38 | sizeof(allMCFIO_UserBlockDecl));
|
---|
| 39 | AllMCFIO_UserBlockDecl->numPreAlloc = NUMUSERBLOCKDEFAULT;
|
---|
| 40 | AllMCFIO_UserBlockDecl->num = 0;
|
---|
| 41 | AllMCFIO_UserBlockDecl->decls = (aUserBlockDecl **) malloc(
|
---|
| 42 | NUMUSERBLOCKDEFAULT * sizeof(aUserBlockDecl *));
|
---|
| 43 | }
|
---|
| 44 | if (AllMCFIO_UserBlockDecl->num == AllMCFIO_UserBlockDecl->numPreAlloc) {
|
---|
| 45 | AllMCFIO_UserBlockDecl->numPreAlloc += NUMUSERBLOCKDEFAULT;
|
---|
| 46 | AllMCFIO_UserBlockDecl->decls =
|
---|
| 47 | (aUserBlockDecl **) realloc (((void *) AllMCFIO_UserBlockDecl->decls),
|
---|
| 48 | (AllMCFIO_UserBlockDecl->numPreAlloc * sizeof(aUserBlockDecl *)));
|
---|
| 49 | }
|
---|
| 50 | AllMCFIO_UserBlockDecl->decls[AllMCFIO_UserBlockDecl->num] =
|
---|
| 51 | (aUserBlockDecl *) malloc (sizeof(aUserBlockDecl));
|
---|
| 52 | abd = AllMCFIO_UserBlockDecl->decls[AllMCFIO_UserBlockDecl->num];
|
---|
| 53 | AllMCFIO_UserBlockDecl->num++;
|
---|
| 54 | abd->blkNum = blkN;
|
---|
| 55 | abd->title = (char *) malloc (sizeof(char) * (strlen(descr) + 1));
|
---|
| 56 | strcpy(abd->title, descr);
|
---|
| 57 | }
|
---|