您好,欢迎访问三七文档
当前位置:首页 > 电子/通信 > 综合/其它 > 数据通信源代码(牧云水务信息大数据存储与分析系统)
牧云水务信息大数据存储与分析系统V1.01/*linenoise.c--guerrillalineeditinglibraryagainsttheideathata**Copyright(c)2010,SalvatoreSanfilippoantirezatgmaildotcom*Copyright(c)2010,PieterNoordhuispcnoordhuisatgmaildotcom**Allrightsreserved.**Redistributionanduseinsourceandbinaryforms,withorwithout*modification,arepermittedprovidedthatthefollowingconditionsaremet:***Redistributionsofsourcecodemustretaintheabovecopyrightnotice,*thislistofconditionsandthefollowingdisclaimer.**Redistributionsinbinaryformmustreproducetheabovecopyright*notice,thislistofconditionsandthefollowingdisclaimerinthe*documentationand/orothermaterialsprovidedwiththedistribution.**NeitherthenameofRedisnorthenamesofitscontributorsmaybeused*toendorseorpromoteproductsderivedfromthissoftwarewithout*specificpriorwrittenpermission.**THISSOFTWAREISPROVIDEDBYTHECOPYRIGHTHOLDERSANDCONTRIBUTORSASIS*ANDANYEXPRESSORIMPLIEDWARRANTIES,INCLUDING,BUTNOTLIMITEDTO,THE*IMPLIEDWARRANTIESOFMERCHANTABILITYANDFITNESSFORAPARTICULARPURPOSE*AREDISCLAIMED.INNOEVENTSHALLTHECOPYRIGHTOWNERORCONTRIBUTORSBE*LIABLEFORANYDIRECT,INDIRECT,INCIDENTAL,SPECIAL,EXEMPLARY,OR*CONSEQUENTIALDAMAGES(INCLUDING,BUTNOTLIMITEDTO,PROCUREMENTOF*SUBSTITUTEGOODSORSERVICES;LOSSOFUSE,DATA,ORPROFITS;ORBUSINESS*INTERRUPTION)HOWEVERCAUSEDANDONANYTHEORYOFLIABILITY,WHETHERIN*CONTRACT,STRICTLIABILITY,ORTORT(INCLUDINGNEGLIGENCEOROTHERWISE)*ARISINGINANYWAYOUTOFTHEUSEOFTHISSOFTWARE,EVENIFADVISEDOFTHE*POSSIBILITYOFSUCHDAMAGE.**lineeditinglibneedstobe20,000linesofCcode.**Youcanfindthelatestsourcecodeat:****Doesanumberofcrazyassumptionsthathappentobetruein99.9999%of*the2010UNIXcomputersaround.**References:*-*-**Todolist:*-Switchtogets()if$TERMissomethingwecan'tsupport.*-FilterbogusCtrl+charcombinations.*-Win32support**Bloat:牧云水务信息大数据存储与分析系统V1.02*-Completion?*-HistorysearchlikeCtrl+rinreadline?**Listofescapesequencesusedbythisprogram,wedoeverythingjust*withthreesequences.Inordertobesocheapwemayhavesome*flickeringeffectwithsomeslowterminal,butthelessersequences*themorecompatible.**CHA(CursorHorizontalAbsolute)*Sequence:ESC[nG*Effect:movescursortocolumnn(1based)**EL(EraseLine)*Sequence:ESC[nK*Effect:ifnis0ormissing,clearfromcursortoendofline*Effect:ifnis1,clearfrombeginningoflinetocursor*Effect:ifnis2,clearentireline**CUF(CursorForward)*Sequence:ESC[nC*Effect:movescursorforwardofnchars**Thefollowingareusedtoclearthescreen:ESC[HESC[2J*Thisisactuallycomposedoftwosequences:**cursorhome*Sequence:ESC[H*Effect:movesthecursortoupperleftcorner**ED2(Clearentirescreen)*Sequence:ESC[2J*Effect:clearthewholescreen**/#ifdef_WIN32#includeconio.h#includewindows.h#includeio.h#definesnprintf_snprintf//Microsoftheadersuseunderscoresinsomenames#definestrcasecmp_stricmp#definestrdup_strdup#defineisatty_isatty#definewrite_write#defineSTDIN_FILENO0#else/*_WIN32*/#includesignal.h牧云水务信息大数据存储与分析系统V1.03#includetermios.h#includeunistd.h#includestdlib.h#includestring.h#includesys/types.h#includesys/ioctl.h#includecctype#includewctype.h#endif/*_WIN32*/#includestdio.h#includeerrno.h#includefcntl.h#includelinenoise.h#includelinenoise_utf8.h#includemk_wcwidth.h#includestring#includevector#includeboost/smart_ptr/scoped_array.hppusingstd::string;usingstd::vector;usingboost::scoped_array;usinglinenoise_utf8::UChar8;usinglinenoise_utf8::UChar32;usinglinenoise_utf8::copyString8to32;usinglinenoise_utf8::copyString32;usinglinenoise_utf8::copyString32to8;usinglinenoise_utf8::strlen32;usinglinenoise_utf8::strncmp32;usinglinenoise_utf8::write32;usinglinenoise_utf8::Utf8String;usinglinenoise_utf8::Utf32String;structlinenoiseCompletions{vectorUtf32StringcompletionStrings;};#defineLINENOISE_DEFAULT_HISTORY_MAX_LEN100#defineLINENOISE_MAX_LINE4096//makecontrol-charactersmorereadable#definectrlChar(upperCaseASCII)(upperCaseASCII-0x40)/***RecomputewidthsofallcharactersinaUChar32buffer*@paramtextinputbufferofUnicodecharacters牧云水务信息大数据存储与分析系统V1.04*@paramwidthsoutputbufferofcharacterwidths*@paramcharCountnumberofcharactersinbuffer*/staticvoidrecomputeCharacterWidths(constUChar32*text,char*widths,intcharCount){for(inti=0;icharCount;++i){widths[i]=mk_wcwidth(text[i]);}}/***Calculateanewscreenpositiongivenastartingposition,screenwidthandcharactercount*@paramxinitialxposition(zero-based)*@paramyinitialyposition(zero-based)*@paramscreenColumnsscreencolumncount*@paramcharCountcharacterpositionstoadvance*@paramxOutreturnedxposition(zero-based)*@paramyOutreturnedyposition(zero-based)*/staticvoidcalculateScreenPosition(intx,inty,intscreenColumns,intcharCount,int&xOut,int&yOut){xOut=x;yOut=y;intcharsRemaining=charCount;while(charsRemaining0){intcharsThisRow=(x+charsRemainingscreenColumns)?charsRemaining:screenColumns-x;xOut=x+charsThisRow;yOut=y;charsRemaining-=charsThisRow;x=0;++y;}if(xOut==screenColumns){//wehavetospecial-caselinewrapxOut=0;++yOut;}}/***Calculateacolumnwidthusingmk_wcswidth()*@parambu
本文标题:数据通信源代码(牧云水务信息大数据存储与分析系统)
链接地址:https://www.777doc.com/doc-316665 .html