void FAR reverse(ParamBlk FAR *parm) { int i; MHANDLE mh_out; char FAR * in_string; char FAR * out_string; // Check to see if we can allocate the memory needed if ((mh_out = _AllocHand(parm->p[0].val.ev_length+1)) == 0) _Error(182); /* "Insufficient memory." */ /* Since this routine does not call any functions which cause memory reorganization, it is not necessary to _HLock the handles prior to dereferencing them (_HandToPtr). */ in_string = _HandToPtr(parm->p[0].val.ev_handle); out_string = (char FAR *) _HandToPtr(mh_out) + parm->p[0].val.ev_length; *(out_string--) = '\0'; /* _RetChar() needs null terminated string */ for (i = 0; i < parm->p[0].val.ev_length; i++) *(out_string--) = *(in_string++); _HLock(mh_out); /* Lock MHANDLE during callback. */ _RetChar(out_string+1); _FreeHand(mh_out); /* Free MHANDLEs we allocate, but not handles passed in ParamBlk. */ }
void CStringz::Create(Value *Val) { if (Val->ev_type != 'C') { //null mh=0; str = '\0'; } else { mh=_AllocHand(Val->ev_length+1); if (mh==NULL) _Error(182); _HLock(mh); str=(char *)_HandToPtr(mh); _HLock(Val->ev_handle); _MemMove(str,_HandToPtr(Val->ev_handle),Val->ev_length); str[Val->ev_length]='\0'; _HUnLock(Val->ev_handle); _HUnLock(mh); } IsLocked=FALSE; }
CStringz::CStringz (char *s) { //constructor mh=_AllocHand(strlen(s)+1); _HLock(mh); str=(char *)_HandToPtr(mh); strcpy(str,s); _HUnLock(mh); IsLocked=FALSE; }
CStringz::CStringz(CStringz &s) {//copy cons mh=_AllocHand(strlen(s.str)+1); _HLock(mh); str=(char *)_HandToPtr(mh); s.Refresh(); strcpy(str,s.str); _HUnLock(mh); IsLocked=FALSE; }
void CStringz::Lock() { if (!IsLocked) { _HLock(mh); str=(char *)_HandToPtr(mh); /* if (!str) { _UserError("5"); } */ IsLocked=TRUE; } }
CStringz operator +(CStringz&p1,CStringz &p2){ //add CStringz temp; temp.mh=_AllocHand(strlen(p1.str)+strlen(p2.str)+1); if (temp.mh==0) _Error(182); _HLock(temp.mh); temp.str=(char *)_HandToPtr(temp.mh); p1.Refresh(); strcpy(temp.str,p1.str); p2.Refresh(); strcat(temp.str,p2.str); _HUnLock(temp.mh); return temp; }
void FAR memrepl(ParamBlk FAR *param) { Locator locate; Value val; int memchan,skip; long memseek, memread, memfind; locate.l_type = 'R'; locate.l_where = 1; locate.l_NTI = 1; // Store the offset of the memo field. locate.l_offset = param->p[0].val.ev_long - 1; memchan = _MemoChan(WORKAREA); // Get the FCHAN to the memo file if((memfind = _FindMemo(&locate)) < 0) // Find the offset of the memo _Error((int) memfind); memread = _MemoSize(&locate); // Find the size of the memo field memseek = _FSeek(memchan, memfind, 0); // Move the file pointer // Read in the memo field into our handle. if ((dbhand = _AllocHand((unsigned) memread)) == BADHANDLE) // Read from the memo file _Error(182); // Insufficient Memory. memread = _FRead(memchan, _HandToPtr(dbhand), (int) memread); val.ev_type = 'C'; val.ev_handle = dbhand; val.ev_length = memread; // Move to the correct record in the database. if (param->pCount == 2) _DBRead(WORKAREA, param->p[1].val.ev_long); else _DBSkip(WORKAREA, 1); skip = _DBReplace(&locate,&val); // Replace the memo field. _FreeHand(dbhand); // Free the handle previously allocated. }
CStringz & CStringz::operator =(Value * v) { //assignment if (v->ev_type!='C') _UserError("Value: Wrong type"); UnLock(); if (!mh) { mh=_AllocHand(v->ev_length+1); } else { _SetHandSize(mh,v->ev_length+1); } if (!mh) _Error(182); Lock(); _HLock(v->ev_handle); _MemMove(str,(char *)_HandToPtr(v->ev_handle),v->ev_length); str[v->ev_length]='\0'; _HUnLock(v->ev_handle); UnLock(); return *this; }