Back to index

im-sdk  12.3.91
Functions
Jword.c File Reference
#include "PYIM.h"

Go to the source code of this file.

Functions

VOID GetAsciiFromJword (JWORD *pwJwordArray, CHAR *szAsciiArray, JINT nLen)
JINT JwordValidLen (JWORD *pwJwordArray, JINT nMaxLen)
JINT JwordHanziLen (JWORD *pwJwordArray, JINT nMaxLen)
JINT JwordStrStrReplace (JWORD *pwDst, JWORD *pwSrc1, JWORD *pwSrc2, JINT nLenSrc2)
JWORDStrToJword (CHAR *szStr)
VOID JwordInfo (JWORD *pwJwordArray, JINT nMaxLen)
VOID Jword2Uchar (JWORD *pwJword, UCHAR *szUch, JINT nMaxLen)
UCHARRecovDyz2244 (UCHAR *szDyz2244)
JINT JwordNCmp (JWORD *pwSrc1, JWORD *pwSrc2, JINT nNum)
VOID JwordNCpy (JWORD *pwDst, JWORD *pwSrc, JINT nLen)
JINT IsGbkkkHz (JWORD wHz)

Function Documentation

VOID GetAsciiFromJword ( JWORD pwJwordArray,
CHAR szAsciiArray,
JINT  nLen 
)

Definition at line 249 of file Jword.c.

{
       JINT   i, j;
       
       i = j = 0;
       for (i = 0; i < nLen; i++)
       {
              if ( *(pwJwordArray + i) < 0x0080)
              {
                     *(szAsciiArray + j) = (CHAR)(*(pwJwordArray + i));
                     j++;
              }
       }
       
       for ( ; j < nLen; j++)
              *(szAsciiArray + j) = '\0';
}
JINT IsGbkkkHz ( JWORD  wHz)

Definition at line 339 of file Jword.c.

{
       JINT    nRet;
       JINT    nHi, nLow;
    
       nHi  = (wHz & 0xFF00) >> 8;
       nLow = wHz & 0x00FF;
    
       nRet = TRUE;
       if ((wHz >= 0x2001) && (wHz <= 0x2244))
              nRet = FALSE;
       else if ((nHi >= 0xB0) && (nHi <= 0xF7) && (nLow >= 0xA1) && (nLow <= 0xFE))
              nRet = FALSE;
              
       return nRet;
}

Here is the caller graph for this function:

VOID Jword2Uchar ( JWORD pwJword,
UCHAR szUch,
JINT  nMaxLen 
)

Definition at line 275 of file Jword.c.

{
       JINT     i, j;
       
       j = 0;
       for(i = 0; i < nMaxLen; i++)
       {
              if(pwJword[i] >= 0x0100)           /* OR 0x8140: First char defined in GBK */
              {
                     szUch[j++] = (UCHAR)((pwJword[i] & 0xFF00) >> 8);
                     szUch[j++] = (UCHAR)(pwJword[i] & 0x00FF);
              }
              else
                     szUch[j++] = (UCHAR)(pwJword[i] & 0x00FF);
       }
}

Here is the caller graph for this function:

JINT JwordHanziLen ( JWORD pwJwordArray,
JINT  nMaxLen 
)

Definition at line 228 of file Jword.c.

{
       JINT   i, nValidLen;
       
       i = 0;
       nValidLen = 0;
       while ((i < nMaxLen) && (pwJwordArray[i] != 0))
       {
              i++;
              if (pwJwordArray[i] != 0x0009)
                     nValidLen++;
       }
              
       return nValidLen;
}

Here is the caller graph for this function:

VOID JwordInfo ( JWORD pwJwordArray,
JINT  nMaxLen 
)

Definition at line 89 of file Jword.c.

{
       JINT    i, j, nLen;
       JWORD   wTmp;
       UCHAR   szStr[1024];
       
       nLen = JwordValidLen(pwJwordArray, nMaxLen);

       memset(szStr, '\0', 1024);

       i = j = 0;
       for (i = 0; i < nLen; i++)
       {
              wTmp = *(pwJwordArray + i);
              if ( (wTmp & 0xFF00) > 0)
              {
                     *(szStr + j) = (UCHAR)(( wTmp & 0xFF00) >> 8);
                     j++;
                     
                     *(szStr + j) = (UCHAR)(wTmp & 0x00FF);
                     j++;
              }
              else if ((wTmp < 0x0080) && (wTmp != 0x0009))
              {
                     *(szStr + j)  = (UCHAR)(wTmp & 0x00FF);
                     j++;
              }
       }
       
       fprintf (stderr, "%d  %s\n", j, szStr);
/*     fprintf (stderr, "%d  %s\n", j, RecovDyz2244(szStr));   */
}

Here is the call graph for this function:

JINT JwordNCmp ( JWORD pwSrc1,
JWORD pwSrc2,
JINT  nNum 
)

Definition at line 303 of file Jword.c.

{
       JINT    i;
       JINT    nRet;

       nRet = 0;
       for(i = 0; (i < nNum) && (nRet == 0); i++)
       {
              if(pwSrc1[i] > pwSrc2[i])
              {
                     nRet = 1;
                     break;
              }
              else if(pwSrc1[i] < pwSrc2[i])
              {
                     nRet = -1;
                     break;
              }
       }

       return nRet;
}
VOID JwordNCpy ( JWORD pwDst,
JWORD pwSrc,
JINT  nLen 
)

Definition at line 327 of file Jword.c.

{
       JINT    i;
       
       for (i = 0; i < nLen; i++)
              pwDst[i] = pwSrc[i];
}

Here is the caller graph for this function:

JINT JwordStrStrReplace ( JWORD pwDst,
JWORD pwSrc1,
JWORD pwSrc2,
JINT  nLenSrc2 
)

Definition at line 135 of file Jword.c.

{
       JINT   i, j, k, nLenDst, nLenSrc1, nFoundFlag, nFirstAddr;
       
       nFoundFlag = 0;
       nLenDst    = JwordValidLen(pwDst, 256);
       nLenSrc1   = JwordValidLen(pwSrc1, 80);
       
       /*
       **  Find the startup offset in PwDst.
       **  THE FOLLOWING CODE TO BE TESTED TO REPLACE ABOVE CODE!! MXL 97-12-06
       */
       i = j = k = 0;
       for(i = 0; (i < nLenDst) && (j < nLenSrc1); i++)
       {
              if (pwDst[i] == pwSrc1[j])
                     j++;
              else
                     j = 0;
       }

       if (j == nLenSrc1)
       {
#ifdef _DEBUG
              /* If there is a SPACE char in the end of found pwSrc1 in pwDst. */
              if ( pwDst[i] == (JWORD)' ')
              {
                     fprintf (stderr, "JwordStrStrReplace():  THERE IS A SPACE!\n");
                     nLenSrc1 += 1;
              }
#endif

              /* 
              **  NOTES: Don't change the sequence of the following exchange and 
              **  the FOR sentence sequence 
              */
              nFirstAddr = i - j;
              if (nLenSrc1 >= nLenSrc2)
              {
                     for (i = nFirstAddr; i < (nFirstAddr + nLenSrc2); i++)
                            pwDst[i]  = pwSrc2[i - nFirstAddr];
                     for (i = (nFirstAddr + nLenSrc2); i < (nLenDst - (nLenSrc1 - nLenSrc2)); i++)
                            pwDst[i]  = pwDst[i + (nLenSrc1 - nLenSrc2)];
                     for (i = (nLenDst - (nLenSrc1 - nLenSrc2)); i < 256; i++)
                            pwDst[i]  = 0x0000;
              }
              else if (nLenSrc1 < nLenSrc2)
              {
                     for (i = (nLenDst + (nLenSrc2 - nLenSrc1)); i < 256; i++)
                            pwDst[i]  = 0x0000;
                     for (i = (nFirstAddr + nLenSrc2); i < (nLenDst + nLenSrc2 - nLenSrc1); i++)
                            pwDst[i]  = pwDst[i - (nLenSrc2 - nLenSrc1)];
                     for (i = nFirstAddr; i < (nFirstAddr + nLenSrc2); i++)
                            pwDst[i]  = pwSrc2[i - nFirstAddr];
              }
              return TRUE;
       }
       else
       {
#ifdef _DEBUG
              fprintf(stderr, "Cannot find string to be replaced in pwdst. JwordStrStrReplace().\n");
#endif
              return FALSE;
       }
}

Here is the call graph for this function:

JINT JwordValidLen ( JWORD pwJwordArray,
JINT  nMaxLen 
)

Definition at line 206 of file Jword.c.

{
       JINT   i, nValidLen;
       
       i = 0;
       nValidLen = 0;
       while ((i < nMaxLen) && (*(pwJwordArray + i) != 0))
       {
              i++;
              nValidLen++;
       }
              
       return nValidLen;
}

Here is the caller graph for this function:

UCHAR* RecovDyz2244 ( UCHAR szDyz2244)

Definition at line 1972 of file PyBasic.c.

{
       JINT    i, j, nLen, nHlfLen;
       JINT    nDyzCode, nNormCode;
       static  UCHAR*  szNorm = NULL; 
   
       nLen = strlen((CHAR*)szDyz2244);
       nHlfLen = nLen / 2;

       if(szNorm != NULL)
              free(szNorm);

       szNorm = (UCHAR*)malloc(nLen + MALIGN);
       if (szNorm == NULL)
       {
              fprintf(stderr, "Failed to alloc Memory in function RecovDyz2244()\n");
              return (szNorm);
       }
       memset(szNorm, '\0', (nLen + MALIGN));
       
       j = 0;
       for (i = 0; i < nHlfLen; i++)
       {
              nDyzCode = szDyz2244[(2 * i) + 1] + ((JINT)szDyz2244[2 * i] << 8);
              if ((nDyzCode >= 0x2001) && (nDyzCode <= 0x2244))
              {
                     nNormCode         = DYZLIST[nDyzCode - 0x2001];
                     szNorm[2 * i]     = (UCHAR)((nNormCode & 0xFF00) >> 8);
                     szNorm[2 * i + 1] = (UCHAR)(nNormCode & 0x00FF);
              }
              else
              {
                     szNorm[2 * i]      = szDyz2244[2 * i];
                     szNorm[2 * i + 1]  = szDyz2244[2 * i + 1];
              }
       }
       
       return (szNorm);
}
JWORD* StrToJword ( CHAR szStr)

Definition at line 63 of file Jword.c.

{
       JINT    i, nLen;
static  JWORD*  pwRet = NULL;      
       
       nLen = strlen(szStr);
       
       free(pwRet);
       pwRet = (JWORD*)malloc((nLen + MALIGN) * sizeof(JWORD));
       if(pwRet == NULL)
       {
              fprintf (stderr, "Failed to alloc Memory in StrToJword().\n");
              return NULL;
       }
       memset(pwRet, '\0', (nLen + MALIGN) * sizeof(JWORD));

       for (i = 0; i < nLen; i++)
              pwRet[i]  = (JWORD)szStr[i];
       
       return pwRet;
}