> /*@noaccess bool@*/
< mMGRS, fMGRS, mNON, fNON --- > KND_MMGRS, KND_FMGRS, KND_MNON, KND_FNON
< # define firstERC mMGRS --- > # define firstERC KND_MMGRS
< # define lastERC fNON --- > # define lastERC KND_FNON
< return erefNIL; --- > return eref_undefined;
< if (!eref_equal (er, erefNIL)) --- > > if (eref_isDefined (er))
< return erefNIL; --- > return eref_undefined;
< db_status hire (employee e) --- > db_status db_hire (employee e)
< if (e.gen == gender_ANY) < return genderERR; --- > if (e.gen == GENDER_UNKNOWN) > return DBS_GENDERERR;
< if (e.j == job_ANY) < return jobERR; --- > if (e.j == JOB_UNKNOWN) > return DBS_JOBERR;
< return salERR; --- > return DBS_SALERR;
< if (!eref_equal (db_keyGet (e.ssNum), erefNIL)) < return duplERR; --- > if (eref_isDefined (db_keyGet (e.ssNum))) > return DBS_DUPLERR;
< uncheckedHire (e); < return db_OK; --- > db_uncheckedHire (e); > return DBS_OK;
< void uncheckedHire (employee e) --- > void db_uncheckedHire (employee e)
< erc_insert (db[(int) mMGRS], er); --- > erc_insert (db[(int) KND_MMGRS], er);
< erc_insert (db[(int) mNON], er); --- > erc_insert (db[(int) KND_MNON], er);
< erc_insert (db[(int) fMGRS], er); --- > erc_insert (db[(int) KND_FMGRS], er);
< erc_insert (db[(int) fNON], er); --- > erc_insert (db[(int) KND_FNON], er);
< bool fire (int ssNum) --- > bool db_fire (int ssNum)
< bool promote (int ssNum) --- > bool db_promote (int ssNum)
< er = db_ercKeyGet (db[(int) mNON], ssNum); --- > er = db_ercKeyGet (db[(int) KND_MNON], ssNum);
< if (eref_equal (er, erefNIL)) --- > if (!eref_isDefined (er))
< er = db_ercKeyGet (db[(int) fNON], ssNum); < if (eref_equal (er, erefNIL)) --- > er = db_ercKeyGet (db[(int) KND_FNON], ssNum); > if (!eref_isDefined (er))
< erc_delete (db[(int) mNON], er); < erc_insert (db[(int) mMGRS], er); --- > erc_delete (db[(int) KND_MNON], er); > erc_insert (db[(int) KND_MMGRS], er);
< erc_delete (db[(int) fNON], er); < erc_insert (db[(int) fMGRS], er); --- > erc_delete (db[(int) KND_FNON], er); > erc_insert (db[(int) KND_FMGRS], er);
< db_status setSalary (int ssNum, int sal) --- > db_status db_setSalary (int ssNum, int sal)
< return salERR; --- > return DBS_SALERR;
< if (eref_equal (er, erefNIL)) --- > if (!eref_isDefined (er))
< return missERR; --- > return DBS_MISSERR;
< return db_OK; --- > return DBS_OK;
< int query (db_q q, empset s) --- > int db_query (db_q q, empset s)
< case gender_ANY: --- > case GENDER_UNKNOWN:
< case job_ANY: --- > case JOB_UNKNOWN:
< numAdded = db_addEmpls (db[(int) mMGRS], l, h, s); < numAdded += db_addEmpls (db[(int) fMGRS], l, h, s); --- > numAdded = db_addEmpls (db[(int) KND_MMGRS], l, h, s); > numAdded += db_addEmpls (db[(int) KND_FMGRS], l, h, s);
< numAdded = db_addEmpls (db[(int) mNON], l, h, s); < numAdded += db_addEmpls (db[(int) fNON], l, h, s); --- > numAdded = db_addEmpls (db[(int) KND_MNON], l, h, s); > numAdded += db_addEmpls (db[(int) KND_FNON], l, h, s);
< case job_ANY: < numAdded = db_addEmpls (db[(int) mMGRS], l, h, s); < numAdded += db_addEmpls (db[(int) mNON], l, h, s); --- > case JOB_UNKNOWN: > numAdded = db_addEmpls (db[(int) KND_MMGRS], l, h, s); > numAdded += db_addEmpls (db[(int) KND_MNON], l, h, s);
< return db_addEmpls (db[(int) mMGRS], l, h, s); --- > return db_addEmpls (db[(int) KND_MMGRS], l, h, s);
< return db_addEmpls (db[(int) mNON], l, h, s); --- > return db_addEmpls (db[(int) KND_MNON], l, h, s);
< case job_ANY: < numAdded = db_addEmpls (db[(int) fMGRS], l, h, s); < numAdded += db_addEmpls (db[(int) fNON], l, h, s); --- > case JOB_UNKNOWN: > numAdded = db_addEmpls (db[(int) KND_FMGRS], l, h, s); > numAdded += db_addEmpls (db[(int) KND_FNON], l, h, s);
< return db_addEmpls (db[(int) fMGRS], l, h, s); --- > return db_addEmpls (db[(int) KND_FMGRS], l, h, s);
< return db_addEmpls (db[(int) fNON], l, h, s); --- > return db_addEmpls (db[(int) KND_FNON], l, h, s);
< typedef enum {db_OK, salERR, genderERR, jobERR, < duplERR, missERR} db_status; --- > typedef enum { DBS_OK, DBS_SALERR, DBS_GENDERERR, DBS_JOBERR, > DBS_DUPLERR, DBS_MISSERR } db_status;
< db_status hire(employee e) db d; --- > db_status db_hire (employee e) db d;
< void uncheckedHire(employee e) db d; --- > void db_uncheckedHire (employee e) db d;
< bool fire(int ssNum) db d; --- > bool db_fire (int ssNum) db d;
< int query(db_q q, empset s) db d; --- > int db_query (db_q q, empset s) db d;
< bool promote(int ssNum) db d; --- > bool db_promote (int ssNum) db d;
< db_status setSalary(int ssNum, int sal) db d; --- > db_status db_setSalary (int ssNum, int sal) db d;
>
< check (hire(e) == db_OK); --- > check (db_hire(e) == DBS_OK);
< uncheckedHire(e); status = hire(e); --- > db_uncheckedHire(e); status = db_hire(e);
< bool_unparse (/*@-usedef@*/ status == duplERR /*@=usedef@*/)); --- > bool_unparse (/*@-usedef@*/ status == DBS_DUPLERR /*@=usedef@*/));
< check (fire(17)); < q.g = FEMALE; q.j = job_ANY; q.l = 158; q.h = 185; --- > check (db_fire(17)); > q.g = FEMALE; q.j = JOB_UNKNOWN; q.l = 158; q.h = 185;
< i = query(q, em1 = empset_create()); --- > i = db_query(q, em1 = empset_create());
< i = query(q, em2 = empset_create()); --- > i = db_query(q, em2 = empset_create());
< check (fire(empset_choose(em3).ssNum)); --- > check (db_fire(empset_choose(em3).ssNum));
< (void) sprintf (s, employeeFormat, e.ssNum, e.name, --- > (void) sprintf (s, FORMATEMPLOYEE, e.ssNum, e.name,
< # define employeeFormat "%9d %-20s %-6s %-11s %6d.00" --- > # define FORMATEMPLOYEE "%9d %-20s %-6s %-11s %6d.00"
< typedef enum { MALE, FEMALE, gender_ANY } gender; < typedef enum { MGR, NONMGR, job_ANY } job; --- > typedef enum { MALE, FEMALE, GENDER_UNKNOWN } gender; > typedef enum { MGR, NONMGR, JOB_UNKNOWN } job;
< return erefNIL; --- > return eref_undefined;
< return (!eref_equal(empset_get (e, s), erefNIL)); --- > return (eref_isDefined (empset_get (e, s)));
< if (!eref_equal (empset_get (e, s), erefNIL)) --- > if (eref_isDefined (empset_get (e, s)))
< if (eref_equal (er, erefNIL)) --- > if (!eref_isDefined (er))
< if (eref_equal (er, erefNIL)) --- > if (!eref_isDefined (er))
>
< static eref_ERP eref_Pool; /* private */ --- > static erefTable eref_Pool; /* private */
< for (i=0; (eref_Pool.status[i] == used) && (i < eref_Pool.size); i++); --- > for (i=0; (eref_Pool.status[i] == ST_USED) && (i < eref_Pool.size); i++);
< (eref_status *) realloc (eref_Pool.status, < 2 * eref_Pool.size * sizeof (eref_status)); --- > (erefStatus *) realloc (eref_Pool.status, > 2 * eref_Pool.size * sizeof (erefStatus));
< eref_Pool.status[i] = avail; --- > eref_Pool.status[i] = ST_AVAIL;
< eref_Pool.status[res] = used; --- > eref_Pool.status[res] = ST_USED;
< eref_Pool.status = (eref_status *) malloc (size * sizeof (eref_status)); --- > eref_Pool.status = (erefStatus *) malloc (size * sizeof (erefStatus));
< eref_Pool.status[i] = avail; --- > eref_Pool.status[i] = ST_AVAIL;
< eref_Pool.status[er] = avail; --- > eref_Pool.status[er] = ST_AVAIL;
< typedef enum { used, avail } eref_status; --- > typedef enum { ST_USED, ST_AVAIL } erefStatus;
< /*@only@*/ eref_status *status; --- > /*@only@*/ erefStatus *status;
< } eref_ERP; --- > } erefTable;
< # define erefNIL -1 --- > # define eref_undefined -1 > > # define eref_isDefined(e) ((e) != eref_undefined)
>
> constant eref eref_undefined; >
< constant eref erefNIL;
> > bool eref_isDefined (eref er) map m; { }
< return erefNIL; --- > > return eref_undefined;