Back to index

im-sdk  12.3.91
Functions | Variables
UDCOper.c File Reference
#include <sys/types.h>
#include <sys/stat.h>
#include "PYIM.h"
#include "UDCOper.h"

Go to the source code of this file.

Functions

void DeleteUDCData ()
void GetUDCData ()

Variables

UDCDataudcGB
UDCDataudcGBK
static time_t LastModifyTime = 0

Function Documentation

void DeleteUDCData ( )

Definition at line 51 of file UDCOper.c.

                     {
    UDCData *p, *q;
       
    p = udcGB;
    while(p != NULL) {
       q = p->next;
       free(p);
       p = q;
    }

    p = udcGBK;
    while(p != NULL) {
       q = p->next;
       free(p);
       p = q;
    }
    udcGB = udcGBK = NULL;
}

Here is the caller graph for this function:

void GetUDCData ( )

Definition at line 70 of file UDCOper.c.

                  {
    FILE *fp;
    char buf[256], code[16];
    int state = GB_STATE;
    UDCData *p1, *p2, *q;
    int low, hi, i1, i2;
    struct stat statbuf;

    if(stat(UDC_DATA_PATH, &statbuf) == -1) return;
    if(LastModifyTime == statbuf.st_mtime) return;
    else LastModifyTime = statbuf.st_mtime;

    DeleteUDCData();
    
    p1 = udcGB = NULL; 
    p2 = udcGBK = NULL;
    i1 = i2 = 0;

    fp = fopen(UDC_DATA_PATH, "rb");
    if(fp == NULL) return;

    while(!feof(fp)) {
       fgets(buf, 256, fp);
       if(feof(fp)) break;
/*
printf("%s", buf);
*/

       if(!strncmp(buf, "[zh_CN.EUC]", 11)) {
           state = GB_STATE;
       }
       else if(!strncmp(buf, "[zh_CN.GBK]", 11)) {
           state = GBK_STATE;
       }
       else if(state == GB_STATE) {
           if(strlen(buf) == 0) continue;
           i1 ++;
           q = (UDCData *) malloc(sizeof(UDCData)); 
           q->id = i1;
           q->next = NULL;
           sscanf(buf, "%s %s\n", code, q->pinyin);
           low = code[1] & 0xff;
           hi = code[0] & 0xff;
           q->nHzcode = ((hi << 8) & 0xFF00) + low ;
           q->nYjcode = FastMatchYinJieStr(q->pinyin);
/*
printf("0x%x %s %d\n", q->nHzcode, q->pinyin, q->nYjcode);
*/
           if(p1 != NULL) p1->next = q;
           else udcGB = q;
           p1 = q;
       }
       else if(state == GBK_STATE) {
           if(strlen(buf) == 0) continue;
           i2 ++;
           q = (UDCData *) malloc(sizeof(UDCData)); 
           q->id = i2;
           q->next = NULL;
           sscanf(buf, "%s %s\n", code, q->pinyin);
           low = code[1] & 0xff;
           hi = code[0] & 0xff;
           q->nHzcode = ((hi << 8) & 0xFF00) + low ;
           q->nYjcode = FastMatchYinJieStr(q->pinyin);
/*
printf("0x%x %s %d", q->nHzcode, q->pinyin, q->nYjcode);
*/
           if(p2 != NULL) p2->next = q;
           else udcGBK = q;
           p2 = q;
       }
    }
    fclose(fp);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

time_t LastModifyTime = 0 [static]

Definition at line 49 of file UDCOper.c.

Definition at line 48 of file UDCOper.c.

Definition at line 48 of file UDCOper.c.