home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual Foxpro 6.0 (Ent. Edition) / Vf6ent Extractor.EXE / API / SAMPLES / REVERSE.C < prev   
Encoding:
C/C++ Source or Header  |  1998-05-26  |  1.6 KB  |  61 lines

  1. /*
  2. **
  3. *
  4. * REVERSE.C - Sample API routine.
  5. *
  6. * Copyright (c) 1989-1993 Microsoft Corporation as an unpublished
  7. * licensed proprietary work.  All rights reserved.
  8. *
  9. * Description: Contains one external routine REVERSE(<expC>).
  10. *   Returns <expC> reversed.
  11. *
  12. **
  13. */
  14. #include <pro_ext.h>
  15.  
  16.  
  17.  
  18. void FAR reverse(ParamBlk FAR *parm)
  19. {
  20.         int i;
  21.         MHANDLE mh_out;
  22.         char FAR *  in_string;
  23.         char FAR * out_string;
  24.  
  25.  
  26.     // Check to see if we can allocate the memory needed
  27.  
  28.     if ((mh_out = _AllocHand(parm->p[0].val.ev_length+1)) == 0)
  29.         _Error(182);             /* "Insufficient memory." */
  30.  
  31.     /*  Since this routine does not call any functions which cause memory
  32.         reorganization, it is not necessary to _HLock the handles prior to
  33.         dereferencing them (_HandToPtr).                                */
  34.  
  35.     in_string = _HandToPtr(parm->p[0].val.ev_handle);
  36.     out_string = (char FAR *) _HandToPtr(mh_out) + parm->p[0].val.ev_length;
  37.  
  38.     *(out_string--) = '\0';         /* _RetChar() needs null terminated string */
  39.  
  40.     for (i = 0; i < parm->p[0].val.ev_length; i++)
  41.         *(out_string--) = *(in_string++);
  42.  
  43.     _HLock(mh_out);                 /* Lock MHANDLE during callback. */
  44.     _RetChar(out_string+1);
  45.  
  46.     _FreeHand(mh_out);              /* Free MHANDLEs we allocate, but not handles
  47.                                        passed in ParamBlk. */
  48. }
  49.  
  50.  
  51.  
  52. FoxInfo myFoxInfo[] =
  53. {
  54.     {"REVERSE", (FPFI) reverse, 1, "C"},
  55. };
  56.  
  57. FoxTable _FoxTable =
  58. {
  59.     (FoxTable FAR *)0, sizeof(myFoxInfo) / sizeof(FoxInfo), myFoxInfo
  60. };
  61.