/* revstr.cpp example of dll containing a string function */
#include <string.h>
#include <windows.h>
#include "revstr.h"
/* dll initiator function */
int CALLBACK DllMain (HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved)
{
return (TRUE) ; /* all ok, continue */
}
/* The BlockRev() function reverses the order of the bytes in a */
/* global memory block. The bytes are copied temporarily into */
/* the hgMem block, and then copied back into the input block. */
/* Returns TRUE if all OK, FALSE on error. */
BOOL CALLBACK BlockRev (LPSTR lpSource, int nLong)
{
int i ;
LPSTR lpDest, lps, lpd ;
/* allocate temporary buffer, length + 1 for terminal null */
lpDest = (LPSTR)malloc (nLong+1) ;
lpd = lpDest ; /* points to start of dest */
lps = lpSource + nLong - 1 ; /* points to end of source */
for (i = 0 ; i < nLong ; i++) /* reverse copy to dest */
*lpd++ = *lps-- ;
lpd = lpDest ;
lps = lpSource ;
for (i = 0 ; i < nLong ; i++) /* copy back to source */
*lps++ = *lpd++ ;
free (lpDest) ;
return (TRUE) ;
}