int main(int argc,char **argv){ FILE *fin; if((fin = fopen("zenkana.sjis","r")) == NULL){ printf("File open Error.\n"); exit(255); } char *inputstring = new char[1024]; fscanf(fin,"%s",inputstring); strcat(inputstring,"\n"); Checker *ip = new FastChecker(); printf("%d",ip->ChkCoding((unsigned char*)inputstring)); delete ip; fclose(fin); return(0); }
static PyObject* CallChecker(PyObject *self, PyObject *args) { unsigned char *str; int type; int len; Codes ret; PyObject *pret; Checker *op; if(!PyArg_ParseTuple(args, "is#", &type, &str, &len)){ return NULL; } op = CheckerTable[type](); ret = op->ChkCoding(str, len); pret = Py_BuildValue("i", ret); delete op; return pret; };
PyObject * kconv_mod_ChkCoding(PyObject *self,PyObject *args,PyObject *keywds){ //デフォルト値の読み込み。一度だけ行なう if(_DEFAULT_INPUT_CODING == _UNKNOWN) _load_defaults(); int cm = _UNDEFINED; unsigned char *input_string; unsigned int string_length; static char *kwlist[] = {"str", "checkmode", NULL}; if(!PyArg_ParseTupleAndKeywords(args,keywds,"s#|i",kwlist, &input_string,&string_length,&cm)) return NULL; //デフォルトの値設定 if(cm == _UNDEFINED)//入力コード判別ルーチン選択 cm = _DEFAULT_CHECK_MODE; Checker *pchecker = CheckerTable[cm](); Codes ret = pchecker->ChkCoding(input_string,string_length); delete pchecker; return(Py_BuildValue("i",ret)); }