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. */
}
예제 #2
0
CStringz::CStringz (ParamBlk *parm,int pnum) {//Constructor
	Value val;
	if (pnum<parm->pCount) {
		if (parm->p[pnum].val.ev_type=='R') {
			_Load(&parm->p[pnum].loc,&val);
			Create(&val);
			_FreeHand(val.ev_handle);
		} else {
			Create(&parm->p[pnum].val);
		}
	} else {
		CStringz();
	}
}
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.

}
예제 #4
0
CStringz::~CStringz() {	//destructor
	UnLock();
	if (mh)	{
		_FreeHand(mh);
	}
}