⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pkgcreate.ch

📁 图片显示,电脑光于望技术湖连望键往,网络
💻 CH
📖 第 1 页 / 共 2 页
字号:
removeFuncProto("chfcreate/SAX2.h", "xmlSAX2NamespaceDecl", 0);removeFuncProto("chfcreate/globals.h", "__xmlMalloc", 0);removeFuncProto("chfcreate/globals.h", "__xmlMallocAtomic", 0);removeFuncProto("chfcreate/globals.h", "__xmlRealloc", 0);removeFuncProto("chfcreate/globals.h", "__xmlFree", 0);removeFuncProto("chfcreate/globals.h", "__xmlMemStrdup", 0);removeFuncProto("chfcreate/xmlsave.h", "xmlSaveToFd", 0);removeFuncProto("chfcreate/xmlsave.h", "xmlSaveToFilename", 0);removeFuncProto("chfcreate/xmlsave.h", "xmlSaveToBuffer", 0);removeFuncProto("chfcreate/xmlsave.h", "xmlSaveToIO", 0);removeFuncProto("chfcreate/xmlsave.h", "xmlSaveDoc", 0);removeFuncProto("chfcreate/xmlsave.h", "xmlSaveTree", 0);removeFuncProto("chfcreate/xmlsave.h", "xmlSaveFlush", 0);removeFuncProto("chfcreate/xmlsave.h", "xmlSaveClose", 0);removeFuncProto("chfcreate/xmlwriter.h", "xmlTextWriterEndDTDElement", 0);removeFuncProto("chfcreate/xmlwriter.h", "xmlTextWriterEndDTDAttlist", 0);removeFuncProto("chfcreate/xmlwriter.h", "xmlTextWriterEndDTDEntity", 0);removeFuncProto("chfcreate/xmlwriter.h",                 "xmlTextWriterWriteDTDExternalEntityContents", 0);echo Generating xml_chdl.c in c/ directory and xxx.chf in $pkgname/lib ...cd chfcreatelist = `ls *.h`;cd ..foreach(token; list){   c2chf  chfcreate/$token -h _Chxml2_handle -i c libxml/parser.h -i c libxml/$token -o c c -o chf $pkgname/lib}echo Patching special .chf files ...cp -f chfhandmade/*.chf $pkgname/libchmod 644 $pkgname/lib/*.chfcorrectRetval();echo Modifying headerfile libxml/globals.h to work under Ch ...sed 's/XMLPUBVAR xmlMallocFunc xmlMalloc;/void* xmlMalloc(size_t size);/g' $pkgname/include/libxml/globals.h > _tmp_chlibxml2.hmv _tmp_chlibxml2.h $pkgname/include/libxml/globals.hsed 's/XMLPUBVAR xmlMallocFunc xmlMallocAtomic;/void* xmlMallocAtomic(size_t size);/g' $pkgname/include/libxml/globals.h > _tmp_chlibxml2.hmv _tmp_chlibxml2.h $pkgname/include/libxml/globals.hsed 's/XMLPUBVAR xmlReallocFunc xmlRealloc;/void* xmlRealloc(void *ptr, size_t size);/g' $pkgname/include/libxml/globals.h > _tmp_chlibxml2.hmv _tmp_chlibxml2.h $pkgname/include/libxml/globals.hsed 's/XMLPUBVAR xmlFreeFunc xmlFree;/void xmlFree(void *ptr);/g' $pkgname/include/libxml/globals.h > _tmp_chlibxml2.hmv _tmp_chlibxml2.h $pkgname/include/libxml/globals.hsed 's/XMLPUBVAR xmlStrdupFunc xmlMemStrdup;/char* xmlMemStrdup(char *str);/g' $pkgname/include/libxml/globals.h > _tmp_chlibxml2.hmv _tmp_chlibxml2.h $pkgname/include/libxml/globals.hecho Building the dynamically loaded library ...cd c$makecmd clean $debug$makecmd $debugFile// go back to original directorycd $cwdecho Adding .DLL path and testing .dl file ...#pragma package <chiconv>;#pragma package <chzlib>;#pragma exec _path=stradd(_path, "chlibxml2/bin;");if (dlopen("c/libxml2.dl", RTLD_LAZY) == NULL) {    printf("Error: test of loading libxml2.dl: %s\n", dlerror());    printf("Make sure you have chiconv installed\n");    exit(-1);}mv -f c/libxml2.dl $cwd/$pkgname/dlecho package $pkgname created successfully!/******************************************************************* * * This function will add the required preprocessing directives * * needed by Ch to a header file. * * headerfile:   header file to be changed * * macro:        token to be recoganized for insertion of chdlheader * * chdlheader:   preprocessing directives to be inserted * *******************************************************************/int addChdlHeader(char *headerfile, char *macro, char *chdlheader){   char *stop_ptr;   string_t tempfile, token;   string_t result;   FILE *stream;                               tempfile = ``cat $headerfile``;   token = strstr( tempfile, macro);   stop_ptr = strstr(token, "\n");   strncpy(result, tempfile, strlen(tempfile)-strlen(stop_ptr));   result=stradd(result, chdlheader);   result=stradd(result, stop_ptr);   if(!(stream = fopen("_tmpfile", "w")))   {      perror("_tmpfile");      return -1;   }   fprintf(stream, "%s", result);   fclose(stream);   mv -f _tmpfile $(headerfile)   return 0;}/************************************************************************* * (C) Copyright 2005 SoftIntegration, Inc. * This function is in public domain, use as it is without any warranty. **************************************************************************  * This function removes function prototypes such as *     int func1(int i); * from a header file that has already been filtered through processhfile(). * * Argumnets: *    filename: name of the file to process *    funcname: function name to look for *    keepNum: if 0, remove all occurances of this prototype. *             if >0 , keep the keepNum desired funcname that is found. * Example: *    removeFuncProto("chfcreate/test.h", "func1", 2); * This will remove all instances except for the 2nd instance of the function,  * func1(), prototype that is found in the file chfcreate/test.h. ***************************************************************/#define LINESIZE 1024int removeFuncProto(char *filename, char *funcname, int keepNum){   char line[LINESIZE], *ptr;   string_t filenameout;   FILE *stream1, *stream2;   int num = 0;   /* Check to see if the funcname provided is NULL */   if (funcname == NULL)   {      printf("Error: %s: Null funcname recieved.\n", __func__);      return -1;   }   /* Check for access to the file */   if(!(stream1 = fopen(filename, "r")))   {      printf("Error: %s: Unable to open '%s' for reading.\n", __func__, filename);      return -1;   }   filenameout = tmpnam(NULL);   /* Check for access to the file */   if(!(stream2 = fopen(filenameout, "w")))   {      printf("Error: %s: Unable to open '%s' for writing.\n", __func__, filenameout);      return -1;   }    fgets(line, LINESIZE , stream1);    while(!feof(stream1)) {        if(ptr = strstr(line, funcname)) {           if(*(ptr-1) == ' ' || *(ptr-1) == '\t' || /* find ' ' in "int' 'funcname();" */              *(ptr-1) == '*')     /* find * in "int *funcname();" */           {              ptr += strlen(funcname);              while(*ptr == ' ' || *ptr== '\t')    /* skip ' ' or '\t' in "int funcname' '();" or "int funcname'\t'();" */              {                 ptr++;              }              if(*ptr == '(') {          /* Find '(' in "int funcname();" */                 num++;                 if(num != keepNum) {                   while(!strchr(line, ';'))      /* till find ';' in "int funcname();" */                   {                     fgets(line, LINESIZE , stream1);                   }                   fgets(line, LINESIZE , stream1);                   continue;                 }              }           }        }        fputs(line, stream2);        fgets(line, LINESIZE , stream1);    }    fclose(stream1);    fclose(stream2);   /* Move the temperary file to the original file. */    mv -f $filenameout $filename    return 0;}/* * correct_retval.ch * process all chf files which return type are a point to somthing, * return typename likes"xxxxxPtr" * substitute the "return -1" as "return NULL" * this function will automatically search all files in the "lib" directory * if the file contain the "Ptr retval", it will do the replacement. *  * created by ZQ, April 8, 2004 * rewritten by SSN, May 24, 2005*/int correctRetval(){  string_t token, files, files2;  cd $pkgname/lib  files = `grep -l "Ptr retval" *`;  files2 = `grep -l "xmlExternalEntityLoader retval" *`;  cd ../../  mkdir junk  foreach(token;files)  {        sed -f xml2.sed $pkgname/lib/$token > junk/$token  }  chmod 644 junk/*  mv -f junk/* $pkgname/lib/  foreach(token;files2)  {        sed -f xml2.sed $pkgname/lib/$token > junk/$token  }  chmod 644 junk/*  mv -f junk/* $pkgname/lib/  rm -rf junk  return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -