예제 #1
0
void CKHttpUtils::onGetFileCompleted(cocos2d::network::HttpClient *sender, cocos2d::network::HttpResponse *response)
{		
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WP8)
	CKNetStruct* sInfo = static_cast<CKNetStruct*>(response->getHttpRequest()->getUserData());
	CCASSERT(sInfo,"sInfo is empty");
	const char* path = sInfo->name.c_str();
	log("getTextName=%s",path);

	CKHttpModel* model = CKHttpModel::create();
	
	std::string res = httpRequestCompleted(sender,response,model);
	writeFileData(path,res.c_str());
	model->setValue("content",Value(res.c_str()));
	model->setValue("path",Value(path));

	sInfo->callback(model);
	sInfo->hideLoadingDialog();
	CC_SAFE_DELETE(sInfo);
#endif
}
예제 #2
0
파일: FileMgr.cpp 프로젝트: xkmld419/crawl
bool FileMgr::addData(char *sData,  int iCnt){
    int iOffset;
    char *pSrc;

    while (iCnt-->0) {
        m_sData[0]='\0';
        iOffset=0;
        for (int i=0;i<m_iFileFieldCnt;i++) {

            switch (m_sFileTransType[i]) {
            case FILEMGR_TRANS_STRING:
            case FILEMGR_TRANS_EVTDATE:
                pSrc= sData+m_iFileFieldOffSet[i];
                while (*pSrc) {
                    m_sData[iOffset++]=*pSrc++ ;
                }
                break;

            case FILEMGR_TRANS_INT:
                sprintf(&m_sData[iOffset],"%d", *(int*)(sData+m_iFileFieldOffSet[i]) );
                while (1) {
                    iOffset++;
                    if (m_sData[iOffset]==NULL)
                        break;
                } 
                break;

            case FILEMGR_TRANS_LONG:
                sprintf( &m_sData[iOffset], "%ld", *(long*)(sData+m_iFileFieldOffSet[i]) );
                while (1) {
                    iOffset++;
                    if (m_sData[iOffset]==NULL)
                        break;
                }
                break;

            case FILEMGR_TRANS_CHAR:
                {
                    int iTempChar=*(int *)(sData+m_iFileFieldOffSet[i]);
                    m_sData[iOffset]= iTempChar & 0x007F;
                    iOffset++;
                    m_sData[iOffset]=NULL;
                }
                break;

            case FILEMGR_TRANS_FLOAT:
                sprintf(&m_sData[iOffset],"%f", *(float*)(sData+m_iFileFieldOffSet[i]) );
                while (1) {
                    iOffset++;
                    if (m_sData[iOffset]==NULL)
                        break;
                }
                break;

            case FILEMGR_TRANS_DOUBLE:
                sprintf(&m_sData[iOffset],"%lf", *(double*)(sData+m_iFileFieldOffSet[i]) );
                while (1) {
                    iOffset++;
                    if (m_sData[iOffset]==NULL)
                        break;
                }
                break;

            default:
                Log::log(0, "未知数据类型,无法转化!");
                break;

            }

            m_sData[iOffset]=m_sDivChar;
            iOffset++;
            m_sData[iOffset]=NULL;

        }//end for

        m_sData[iOffset++]='\n';
        m_sData[iOffset]=NULL;

        if ( !writeFileData(m_sData, iOffset) )
            return false;
        sData += m_iDataStructSize;

    }//end while

    return true;
}
예제 #3
0
파일: main.c 프로젝트: Acidburn0zzz/afdko
int main(int argc, char *argv[])
{
	int allowEdit, allowHintSub, fixStems, debug, badParam;
	char *fontInfoFileName=NULL; /* font info file name, or suffix of environment variable holding the fontfino string. */
	char *fontinfo = NULL; /* the string of fontinfo data */
	int firstFileNameIndex = -1; /* arg index for first bez file name, or  suffix of environment variable holding the bez string. */
	register char *current_arg;
	short total_files = 0; 
	int result, argi;
  
	badParam = fixStems = debug = doAligns = doStems = allstems = FALSE;
	allowEdit = allowHintSub = TRUE;
	fileSuffix = (char*)dfltExt;

	/* read in options */
	argi = 0;
	while (++argi < argc)
		{
	   current_arg = argv[argi];
	   
		if (current_arg[0] == '\0')
			continue;
		else if (current_arg[0] != '-')
			{
			if (firstFileNameIndex == -1)
				firstFileNameIndex = argi;
			total_files++;
			continue;
			}
		else if (firstFileNameIndex != -1)
			{
			fprintf(OUTPUTBUFF, "Error. Illegal command line. \"-\" option found after first file name.\n");
			exit(1);
 			}

		switch (current_arg[1])
			{
			case '\0':
				badParam = TRUE;
				break;
			case 'u':
				printUsage();
				#ifdef EXECUTABLE
				  exit(0);
				#else
					longjmp(aclibmark, 1);
				#endif
				break;
			case 'h':
				printHelp();
				#ifdef EXECUTABLE
				  exit(0);
				#else
					longjmp(aclibmark, 1);
				#endif
				break;
			 case 'e':
				allowEdit = FALSE;
				break;
			 case 'f':
				fontInfoFileName = argv[++argi];
				if  ((fontInfoFileName[0] == '\0') || (fontInfoFileName[0] == '-'))
					{
					fprintf(OUTPUTBUFF, "Error. Illegal command line. \"-f\" option must be followed by a file name.\n");
					exit(1);
					}
				break;
			 case 's':
				fileSuffix = argv[++argi];
				if  ((fileSuffix[0] == '\0') || (fileSuffix[0] == '-'))
					{
					fprintf(OUTPUTBUFF, "Error. Illegal command line. \"-s\" option must be followed by a string, and the string must not begin with '-'.\n");
					exit(1);
					}
				break;
			case 'n':
				allowHintSub = FALSE;
				break;
			case 'q':
				verbose = FALSE;
				break;
			 case 'D':
				debug = TRUE;
				break;
			case 'F':
				fixStems = TRUE;
			  break;
			case 'a':
				allstems = 1;
				break;
				
			case 'r':
				allowEdit = allowHintSub = FALSE;
				fileSuffix = (char *)reportExt;
				switch (current_arg[2])
					{
					case 'a':
						reportRetryCB = reportRetry;
						addCharExtremesCB = charZoneCB;
						addStemExtremesCB = stemZoneCB;
						doAligns = 1;

						addHStemCB = NULL;
						addVStemCB = NULL;
						doStems = 0;
						break;
					case 's':
						reportRetryCB = reportRetry;
						addHStemCB = hstemCB;
						addVStemCB = vstemCB;
						doStems = 1;

						addCharExtremesCB = NULL;
						addStemExtremesCB = NULL;
						doAligns = 0;
						break;
					default:
						fprintf(OUTPUTBUFF, "Error. %s is an invalid parameter.\n", current_arg);
						badParam = TRUE;
						break;
					}
					break;
			case 'v':
				printVersions();
				exit(0);
				break;
			  break;
#if ALLOWCSOUTPUT
			case 'C':
				charstringoutput = TRUE;
				break;
#endif
			default:
				fprintf(OUTPUTBUFF, "Error. %s is an invalid parameter.\n", current_arg);
				badParam = TRUE;
				break;
			}
		}

	if (firstFileNameIndex == -1)
		{
		fprintf(OUTPUTBUFF, "Error. Illegal command line. Must provide bez file name.\n");
		badParam = TRUE;
		}
	if (fontInfoFileName == NULL)
		{
		fprintf(OUTPUTBUFF, "Error. Illegal command line. Must provide font info file name.\n");
		badParam = TRUE;
		}
		
	if (badParam) 
#ifdef EXECUTABLE
		exit(NONFATALERROR);
#else
		longjmp(aclibmark, -1);
#endif

#if ALLOWCSOUTPUT
	if (charstringoutput)
		read_char_widths();
#endif

	AC_SetReportCB(reportCB, verbose);
	fontinfo = getFileData(fontInfoFileName);
	argi = firstFileNameIndex-1;
	while (++argi < argc)
		{
		char *bezdata;
		char *output;
		size_t outputsize = 0;
		bezName = argv[argi];
		bezdata = getFileData(bezName);
		outputsize = 4*strlen(bezdata);
		output = malloc(outputsize); 

		if (doAligns || doStems)
			openReportFile(bezName, fileSuffix);
			
		result = AutoColorString(bezdata, fontinfo, output, (int*)&outputsize, allowEdit, allowHintSub, debug);
		if (result == AC_DestBuffOfloError)
			{
			free(output);
			if (reportFile != NULL)
				closeReportFile();
			if (doAligns || doStems)
				openReportFile(bezName, fileSuffix);
			output = malloc(outputsize); 
			/* printf("NOTE: trying again. Input size %d output size %d.\n", strlen(bezdata), outputsize); */
			AC_SetReportCB(reportCB, FALSE);
			result = AutoColorString(bezdata, fontinfo, output, (int*)&outputsize, allowEdit, allowHintSub, debug);
			AC_SetReportCB(reportCB, verbose);
			}
		if (reportFile != NULL)
			closeReportFile();
		else
			{
			if ((outputsize != 0) && (result == AC_Success))
				writeFileData(bezName, output, fileSuffix);
			}
		free(output);
		main_cleanup( (result == AC_Success) ? OK : FATALERROR);
		}
		

  return 0;
  }