/* AutoConvert, a Chinese HZ/GB/Big5 encodings auto-converter Copyright (C) 1999 ÓÚ¹ã»Ô Yu Guanghui This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include "hz.h" #define MAX 100 struct c_modules{ int from; int to; char* (*pfun_convert)(); int (*pfun_init)(); int distance; int skip; }; struct stack { char from; char to; int dist; int index; }; struct stack bt_stack[MAX]; int num_modules=0; int find_pos=0; int tos=0; struct c_modules clist[MAX]; void assert_module(int from,int to,char* (*convert)(),int (*init)(),int dist) { if(num_modules0){ tos--; *from=bt_stack[tos].from; *to=bt_stack[tos].to; *dist=bt_stack[tos].dist; *index=bt_stack[tos].index; }else{ printf("Stack underflow.\n"); } } int match(int from,int to,int *index) { register int t; for(t=num_modules-1;t>-1;t--){ if( (clist[t].from == from) && (clist[t].to == to)){ *index=t; return clist[t].distance; } } return 0; } int find(int from,int * anywhere,int *index) { find_pos=0; while(find_pos0){ pop(&from,&to,&dist,&index); ismodule(from,to); } return 0; } int hz_search(int from,int to,int distance) { int dist=0, t=0; hz_init(); ismodule(from,to); while(t 4) return 0; for(i=0;i<=num_modules;i++){ if(strcmp(from,clist[i].from)==0 && strcmp(to,clist[i].to)==0){ pconv->convert=clist[i].pfun_convert; pconv->init=clist[i].pfun_init; return 1; } } for(i=0;i<=num_modules;i++){ if(strcmp(from,clist[i].from)==0){ clist[i].skip=1; pconv->convert=clist[i].pfun_convert; pconv->init=clist[i].pfun_init; if(strcmp(to,clist[i].to)==0){ return 1; }else if(clist[1].skip==0 && strcmp(start,clist[i].to)!=0){ (struct covernter*)pconv->next=malloc(sizeof(struct converter)); if(!search(clist[i].to,to,pconv->next,start,deep)){ free(pconv->next); pconv->next=NULL; }else{ return 1; } } clist[i].skip=0; pconv->convert=NULL; } } return 0; } */