|
|
1.1 ! root 1: /* ftamconctl.c - FPM: encode/decode concurrency control */ ! 2: ! 3: #ifndef lint ! 4: static char *rcsid = "$Header: /f/osi/ftam/RCS/ftamconctl.c,v 7.2 90/07/09 14:36:42 mrose Exp $"; ! 5: #endif ! 6: ! 7: /* ! 8: * $Header: /f/osi/ftam/RCS/ftamconctl.c,v 7.2 90/07/09 14:36:42 mrose Exp $ ! 9: * ! 10: * ! 11: * $Log: ftamconctl.c,v $ ! 12: * Revision 7.2 90/07/09 14:36:42 mrose ! 13: * sync ! 14: * ! 15: * Revision 7.1 90/03/23 10:54:01 mrose ! 16: * update ! 17: * ! 18: * Revision 7.0 89/11/23 21:53:31 mrose ! 19: * Release 6.0 ! 20: * ! 21: */ ! 22: ! 23: /* ! 24: * NOTICE ! 25: * ! 26: * Acquisition, use, and distribution of this module and related ! 27: * materials are subject to the restrictions of a license agreement. ! 28: * Consult the Preface in the User's Manual for the full terms of ! 29: * this agreement. ! 30: * ! 31: */ ! 32: ! 33: /* LINTLIBRARY */ ! 34: ! 35: #include <stdio.h> ! 36: #include "fpkt.h" ! 37: ! 38: /* DATA */ ! 39: ! 40: static int fc2lock[] = { ! 41: int_FTAM_Lock_shared, int_FTAM_Lock_exclusive, ! 42: int_FTAM_Lock_not__required, int_FTAM_Lock_no__access ! 43: }; ! 44: ! 45: static int lock2fc[] = { ! 46: FLOCK_NOTREQD, FLOCK_SHARED, FLOCK_EXCLUSIVE, FLOCK_NOACCESS ! 47: }; ! 48: ! 49: ! 50: #define FCON_NOTREQD 0x01 ! 51: #define FCON_SHARED 0x02 ! 52: #define FCON_EXCLUSIVE 0x04 ! 53: #define FCON_NOACCESS 0x08 ! 54: ! 55: struct pair fconctl_pairs [] = { ! 56: FCON_NOTREQD, bit_FTAM_Concurrency__Key_not__required, ! 57: FCON_SHARED, bit_FTAM_Concurrency__Key_shared, ! 58: FCON_EXCLUSIVE, bit_FTAM_Concurrency__Key_exclusive, ! 59: FCON_NOACCESS, bit_FTAM_Concurrency__Key_no__access, ! 60: 0, 0 ! 61: }; ! 62: ! 63: /* */ ! 64: ! 65: struct type_FTAM_Concurrency__Control *conctl2fpm (fsb, fc, fti) ! 66: register struct ftamblk *fsb; ! 67: register struct FTAMconcurrency *fc; ! 68: struct FTAMindication *fti; ! 69: { ! 70: register struct type_FTAM_Concurrency__Control *fpm; ! 71: ! 72: if ((fpm = (struct type_FTAM_Concurrency__Control *) ! 73: calloc (1, sizeof *fpm)) == NULL) { ! 74: no_mem: ; ! 75: (void) ftamlose (fti, FS_GEN (fsb), 1, NULLCP, "out of memory"); ! 76: if (fpm) ! 77: free_FTAM_Concurrency__Control (fpm); ! 78: return NULL; ! 79: } ! 80: ! 81: #define dolock(s,t) \ ! 82: { \ ! 83: if ((fpm -> s = (struct type_FTAM_Lock *) \ ! 84: calloc (1, sizeof *fpm -> s)) \ ! 85: == NULL) \ ! 86: goto no_mem; \ ! 87: fpm -> s -> parm = fc2lock [fc -> t & FLOCK_MASK]; \ ! 88: } ! 89: dolock (read, fc_readlock); ! 90: dolock (insert, fc_insertlock); ! 91: dolock (replace, fc_replacelock); ! 92: dolock (extend, fc_extendlock); ! 93: dolock (erase, fc_eraselock); ! 94: dolock (read__attribute, fc_readattrlock); ! 95: dolock (change__attribute, fc_chngattrlock); ! 96: dolock (delete, fc_deletelock); ! 97: #undef dolock ! 98: ! 99: return fpm; ! 100: } ! 101: ! 102: /* */ ! 103: ! 104: /* ARGSUSED */ ! 105: ! 106: int fpm2conctl (fsb, fpm, fc, fti) ! 107: struct ftamblk *fsb; ! 108: register struct type_FTAM_Concurrency__Control *fpm; ! 109: register struct FTAMconcurrency *fc; ! 110: struct FTAMindication *fti; ! 111: { ! 112: FCINIT (fc); ! 113: ! 114: #define dolock(s,t) \ ! 115: { \ ! 116: fc -> t = lock2fc [fpm -> s -> parm]; \ ! 117: } ! 118: dolock (read, fc_readlock); ! 119: dolock (insert, fc_insertlock); ! 120: dolock (replace, fc_replacelock); ! 121: dolock (extend, fc_extendlock); ! 122: dolock (erase, fc_eraselock); ! 123: dolock (read__attribute, fc_readattrlock); ! 124: dolock (change__attribute, fc_chngattrlock); ! 125: dolock (delete, fc_deletelock); ! 126: #undef dolock ! 127: ! 128: return OK; ! 129: } ! 130: ! 131: /* */ ! 132: ! 133: struct type_FTAM_Concurrency__Access *conacc2fpm (fsb, fc, fti) ! 134: register struct ftamblk *fsb; ! 135: register struct FTAMconcurrency *fc; ! 136: struct FTAMindication *fti; ! 137: { ! 138: register struct type_FTAM_Concurrency__Access *fpm; ! 139: int key; ! 140: ! 141: if ((fpm = (struct type_FTAM_Concurrency__Access *) ! 142: calloc (1, sizeof *fpm)) == NULL) { ! 143: (void) ftamlose (fti, FS_GEN (fsb), 1, NULLCP, "out of memory"); ! 144: if (fpm) ! 145: free_FTAM_Concurrency__Access (fpm); ! 146: return NULL; ! 147: } ! 148: ! 149: #define dolock(s,t) \ ! 150: { \ ! 151: key = (int) (fc -> t & FLOCK_MASK); \ ! 152: fpm -> s = bits2fpm (fsb, fconctl_pairs, key, fti); \ ! 153: } ! 154: ! 155: dolock (read, fc_readlock); ! 156: dolock (insert, fc_insertlock); ! 157: dolock (replace, fc_replacelock); ! 158: dolock (extend, fc_extendlock); ! 159: dolock (erase, fc_eraselock); ! 160: dolock (read__attribute, fc_readattrlock); ! 161: dolock (change__attribute, fc_chngattrlock); ! 162: dolock (delete, fc_deletelock); ! 163: #undef dolock ! 164: ! 165: return fpm; ! 166: } ! 167: ! 168: ! 169: int fpm2conacc (fsb, fpm, fc, fti) ! 170: struct ftamblk *fsb; ! 171: register struct type_FTAM_Concurrency__Access *fpm; ! 172: register struct FTAMconcurrency *fc; ! 173: struct FTAMindication *fti; ! 174: { ! 175: int key; ! 176: ! 177: FCINIT (fc); ! 178: ! 179: #define dolock(s,t) \ ! 180: { \ ! 181: key = fc -> t; \ ! 182: (void) fpm2bits (fsb, fconctl_pairs, fpm -> s, &key, fti); \ ! 183: } ! 184: dolock (read, fc_readlock); ! 185: dolock (insert, fc_insertlock); ! 186: dolock (replace, fc_replacelock); ! 187: dolock (extend, fc_extendlock); ! 188: dolock (erase, fc_eraselock); ! 189: dolock (read__attribute, fc_readattrlock); ! 190: dolock (change__attribute, fc_chngattrlock); ! 191: dolock (delete, fc_deletelock); ! 192: #undef dolock ! 193: ! 194: return OK; ! 195: ! 196: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.