void CGroupsInfo::printGroupInfo(FILE *file) const { size_t i = GetAt(0)->numMatrices() ? 0 : 1; const size_t iMax = GetSize(); if (i == iMax) return; // Nothing was constructed #define SHIFT " " char buffer[256], line[256]; size_t len = SPRINTF(buffer, "\n" SHIFT " |Aut(D)| Nd: Ns: Ndt: Nst:\n"); outString(buffer, file); strcpy_s(line, countof(line), SHIFT); const size_t l_Shift = strlen(SHIFT); memset(line + l_Shift, '_', len); len += l_Shift; strcpy_s(line + len, countof(line) - len, "\n"); outString(line, file); COrderInfo total(0, 0); for (; i < iMax; i++) { const COrderInfo *pInfo = GetAt(i); total.addMatrix(pInfo); len = SPRINTF(buffer, SHIFT"%10zd", pInfo->groupOrder()); pInfo->outNumbInfo(buffer, countof(buffer) - len, len); outString(buffer, file); } outString(line, file); len = SPRINTF(buffer, " Total:"); total.outNumbInfo(buffer, countof(buffer) - len, len); outString(buffer, file); }
void CEnumInfo<T>::outEnumInfo(FILE **pOutFile, bool removeReportFile, const CGroupsInfo *pGroupInfo) { setRunTime(); FILE *outFile = pOutFile ? *pOutFile : NULL; if (!outFile) return; if (!pGroupInfo) pGroupInfo = this; pGroupInfo->printGroupInfo(outFile); const ulonglong nConstrMatr = constrCanonical(); char buff[256]; SPRINTF(buff, "\n%10llu matri%s" CONSTRUCTED_IN " ", nConstrMatr, nConstrMatr == 1 ? "x" : "ces"); const size_t len = strlen(buff); convertTime(runTime(), buff + len, countof(buff) - len, false); outString(buff, outFile); const ulonglong nMatr = numbSimpleDesign(); if (nConstrMatr > 0) { SPRINTF(buff, "%10llu matri%s ha%s no replicated blocks\n", nMatr, nMatr == 1 ? "x" : "ces", nMatr == 1 ? "s" : "ve"); outString(buff, outFile); } SPRINTF(buff, "%10llu matri%s fully constructed\n", constrTotal(), constrTotal() == 1 ? "x was" : "ces were"); outString(buff, outFile); outEnumInformation(pOutFile); if (removeReportFile) // Remove temporary file with the intermediate results remove(reportFileName()); }
uint receiveVar(char* p_c) { // Receive the data by stepping the machine until it outputs // something do { // While there's no data, run the timeout counter RECEIVE_ERROR re; uint32_t u32_count = 0; while (!isCharReady()) { if (u32_count < RECEIVE_TIMEOUT) u32_count++; doHeartbeat(); } // Step the machine *p_c = inChar(); if (u32_count >= RECEIVE_TIMEOUT) notifyOfTimeout(); re = stepReceiveMachine(*p_c); if (re != ERR_NONE) { outString("Data receive error: "); outString(getReceiveErrorString()); outChar('\n'); } } while (!isReceiveMachineChar() && !isReceiveMachineData()); // Note that p_c already contains the received character, since it's // always the last thing received from inChar(). return getReceiveMachineIndex(); }
static void redefMsg(any x, any y) { outFile *oSave = OutFile; void (*putSave)(int) = Env.put; OutFile = OutFiles[STDERR_FILENO], Env.put = putStdout; outString("# "); print(x); if (y) space(), print(y); outString(" redefined\n"); Env.put = putSave, OutFile = oSave; }
void CMMF_TSU_DEVSOUND_TestInterface1DeMux::DoSendSlaveAsyncCommandResultL(const RMmfIpcMessage& aMessage) { TMMFDevSoundCIMessageData data; // decode message iUtility->GetAsyncMessageDataL(aMessage, data); if (data.iCommand != EMMFDevSoundCITestAsyncResult) { User::Leave(KErrNotSupported); } // check descriptor HBufC8* tempBuf = HBufC8::NewL(iUtility->InputDesLength(aMessage)); CleanupStack::PushL(tempBuf); TPtr8 tempDes(tempBuf->Des()); iUtility->ReadFromInputDesL(aMessage, &tempDes); if (tempDes != KDevSoundCITestIn) { User::Leave(KErrCorrupt); } // write to the output buffer TPtrC8 outString(KDevSoundCITestOut); iUtility->WriteToOutputDesL(aMessage, outString); // complete the message iUtility->CompleteMessage(aMessage, KErrNone); CleanupStack::PopAndDestroy(); // tempBuf }
void onDrawContent(SkCanvas* canvas) override { SkPaint paint; SkSafeUnref(paint.setTypeface(SkTypeface::CreateFromFile("/skimages/samplefont.ttf"))); paint.setAntiAlias(true); paint.setFilterQuality(kMedium_SkFilterQuality); SkString outString("fps: "); fTimer.end(); // TODO: generalize this timing code in utils fTimes[fCurrentTime] = (float)(fTimer.fWall); fCurrentTime = (fCurrentTime + 1) & 0x1f; float meanTime = 0.0f; for (int i = 0; i < 32; ++i) { meanTime += fTimes[i]; } meanTime /= 32.f; SkScalar fps = 1000.f / meanTime; outString.appendScalar(fps); outString.append(" ms: "); outString.appendScalar(meanTime); SkString modeString("Text scale: "); modeString.appendU32(fSizeScale); modeString.append("x"); fTimer.start(); canvas->save(); #if SK_SUPPORT_GPU SkBaseDevice* device = canvas->getDevice_just_for_deprecated_compatibility_testing(); GrContext* grContext = canvas->getGrContext(); if (grContext) { GrTexture* tex = grContext->getFontAtlasTexture(GrMaskFormat::kA8_GrMaskFormat); reinterpret_cast<SkGpuDevice*>(device)->drawTexture(tex, SkRect::MakeXYWH(512, 10, 512, 512), paint); } #endif canvas->translate(180, 180); canvas->rotate(fRotation); canvas->scale(fScale, fScale); canvas->translate(-180, -180); const char* text = "Hamburgefons"; size_t length = strlen(text); SkScalar y = SkIntToScalar(0); for (int i = 12; i <= 26; i++) { paint.setTextSize(SkIntToScalar(i*fSizeScale)); y += paint.getFontSpacing(); DrawTheText(canvas, text, length, SkIntToScalar(110), y, paint); } canvas->restore(); paint.setTextSize(16); // canvas->drawText(outString.c_str(), outString.size(), 512.f, 540.f, paint); canvas->drawText(modeString.c_str(), modeString.size(), 768.f, 540.f, paint); }
int main(void) { int16_t i16_c; if (_POR) { i16_b = 0; _POR = 0; } configBasic(HELLO_MSG); outString("Hello world!\n"); ++i16_a; ++i16_b; ++i16_c; printf("a = %d, b = %d, c = %d\n", i16_a, i16_b, i16_c); while (1) { // Do nothing. // After powering the chip on: // // - What is the value of a at this line? Either a number or x if // unknown. // - What is the value of b at this line? Either a number or x if // unknown. // // After pressing the MCLR button once: // // - What is the value of a at this line? Either a number or x if // unknown. // - What is the value of b at this line? Either a number or x if // unknown. } }
void CRowSolution<T>::printRow(FILE *file, PERMUT_ELEMENT_TYPE *pPerm, const T *pSol) const { char buffer[512], *pBuf = buffer; for (size_t j = 0; j < numSolutions(); j++) { size_t idx = pPerm? *(pPerm + j) : j; if (pSol) idx = *(pSol + idx * solutionSize()); pBuf += sprintf_s(pBuf, sizeof(buffer) - (pBuf - buffer), "%2zd", idx % 100); if (pBuf >= buffer + sizeof(buffer) - 2) outString(pBuf = buffer, file); } sprintf_s(pBuf, sizeof(buffer) - (pBuf - buffer), "\n"); outString(buffer, file); }
int main() { str = "Kitty on your lap\n"; printf(str); outString(); return 0; }
void Log::SetLogFileLevel(char *Level) { int32 NewLevel = atoi((char*) Level); if (NewLevel < 0) NewLevel = 0; m_logFileLevel = NewLevel; outString("LogFileLevel is %u", m_logFileLevel); }
void Log::SetDBLogLevel(char *Level) { int32 NewLevel = atoi((char*) Level); if (NewLevel < 0) NewLevel = 0; m_dbLogLevel = NewLevel; outString("DBLogLevel is %u", m_dbLogLevel); }
void CRowSolution<T>::printSolutions(FILE *file, bool markNextUsed) const { if (!solutionSize() || !numSolutions()) return; MUTEX_LOCK(out_mutex); char buffer[2048]; if (numSolutions() >= sizeof(buffer) / 2) { if (markNextUsed) { SPRINTF(buffer, "Using solution # %zd out of %zd\n", solutionIndex(), numSolutions()); outString(buffer, file); } } else { if (markNextUsed) { const size_t len2 = sizeof(buffer) << 1; const size_t len = solutionIndex() * 2; const size_t nLoops = len / len2; size_t idx = 0; for (size_t j = 0; j < nLoops; j++) { idx = setSolutionFlags(buffer, sizeof(buffer), idx); buffer[sizeof(buffer)-1] = '\0'; outString(buffer, file); } const size_t lastLen = 2 * (numSolutions() - idx); setSolutionFlags(buffer, lastLen, idx); buffer[len % len2 + 1] = '*'; strcpy_s(buffer + lastLen, sizeof(buffer)-lastLen, "\n"); outString(buffer, file); } printRow(file); PERMUT_ELEMENT_TYPE *pPerm = solutionPerm() ? solutionPerm()->GetData() : NULL; if (pPerm) printRow(file, pPerm); const VECTOR_ELEMENT_TYPE *pSolution = firstSolution(); for (unsigned int i = 0; i < solutionSize(); i++) printRow(file, pPerm, pSolution + i); } MUTEX_UNLOCK(out_mutex); }
void ACGI::cgiEncodeAndOutputURL(const char *pccSource, int iLength) { char *pcOut = g_aCrypto.convertoEncodeURL(pccSource, iLength); if (pcOut) outString(pcOut); delete []pcOut; }
void ACGI::cgiStartFORM(const char *pccAction, const char *pccMethod) { outStringN("<FORM ACTION=\""); if (pccAction) outString(pccAction); else cgiGetScriptName(0x1); outStringN("\" METHOD="); if (pccMethod) outStringQ(pccMethod); else outStringQ("POST"); outStringCRN(">"); }
static void traceIndent(int i, any x, char *s) { if (i > 64) i = 64; while (--i >= 0) Env.put(' '); if (isSym(x)) print(x); else print(car(x)), space(), print(cdr(x)), space(), print(val(This)); outString(s); }
void CEnumInfo<T>::outEnumAdditionalInfo(FILE **pOutFile) const { FILE *outFile = pOutFile ? *pOutFile : NULL; if (!outFile) return; char buff[256]; SPRINTF(buff, "%10llu matri%s fully constructed\n", constrTotal(), constrTotal() == 1 ? "x was" : "ces were"); outString(buff, outFile); outEnumInformation(pOutFile); }
int main(void) { if (_WDTO) { _WDTO = 0; _SWDTEN = 0; outString("A"); } else { _SWDTEN = 1; SLEEP(); } while (1) { } }
QString commentifyDocString( const QString & docString, int indentLevel = 0 ) { QString indentString; for( int i=0; i<indentLevel; i++ ) indentString += "\t"; QString outString(indentString +"/**\n"); // Unix \n, windows \n\r, mac \r QStringList lines = docString.split( QRegExp( "[\n\r]\r?" ) ); QString commentStart("/*"), commentEnd("*/"); foreach( QString line, lines ) { line = line.replace( commentStart, "" ); line = line.replace( commentEnd, "" ); outString += indentString + " * " + line + "\n"; }
int main(void) { //configure pins. Only need SDO, SCLK since POT is output only CONFIG_RG8_AS_DIG_OUTPUT(); //use RF3 for SDO CONFIG_RG6_AS_DIG_OUTPUT(); //use RF6 for SCLK CONFIG_RG7_AS_DIG_OUTPUT(); //use RF7 for SDI CONFIG_RF0_AS_DIG_OUTPUT(); //chip select for VDIP1_A CONFIG_RB9_AS_DIG_OUTPUT(); //chip select for VDIP1_B configBasic(HELLO_MSG); outString("Hello world \n"); configHeartbeat(); //heartbeat LED //config SPI for VDIP1 VDIP_Init(); VDIP_WriteFile("BARBIE.TXT", "THREE IS THE MAGICAL NUMBER. YOUR HUBBY LOVES YOU!"); VDIP_WriteFile("ABCDEF1.TXT", "This is a test."); VDIP_WriteFile("ABCDEF2.TXT", "This is a test."); VDIP_WriteFile("ABCDEF3.TXT", "This is a test."); VDIP_WriteFile("ABCDEF4.TXT", "This is a test."); VDIP_WriteFile("ABCDEF5.TXT", "This is a test."); VDIP_WriteFile("ABCDEF.TXT", "This is a test-1."); VDIP_WriteFile("ABCDEF.TXT", "This is a test-2."); VDIP_WriteFile("ABCDEF.TXT", "This is a test-3."); VDIP_WriteFile("ABCDEF.TXT", "This is a test-4."); // VDIP_ListDir(); while(1){} return 0; }
int main(void) { int16_t i16_c; configBasic(HELLO_MSG); outString("Hello world!\n"); ++i16_a; ++i16_b; ++i16_c; printf("a = %d, b = %d, c = %d\n", i16_a, i16_b, i16_c); while (1) { // Do nothing. // After powering the chip on: // // 46. What is the value of a at this line? Either a number or x if // unknown. // #. What is the value of b at this line? Either a number or x if // unknown. // #. What is the value of c at this line? Either a number or x if // unknown. } }
void CEnumInfo<T>::outEnumInformation(FILE **pOutFile, bool printMTlevel) const { FILE *outFile = pOutFile ? *pOutFile : NULL; if (!outFile) return; char buff[256]; SPRINTF(buff, "\nUsing %zd-bit program, Assembly flag: %d\n", sizeof(size_t) << 3, USE_ASM); auto outLen = outString(buff, outFile); const auto nThreads = designInfo()->threadNumb; if (USE_THREADS >= 1) { if (printMTlevel) SPRINTF(buff, "%10zd threads launched on level %d (%swaiting to finish mode)\n", nThreads, multiThreadLevel(), WAIT_THREADS ? "" : "not "); else SPRINTF(buff, "%10zd threads launched on difefrent levels (%swaiting to finish mode)\n", nThreads, WAIT_THREADS ? "" : "not "); } else SPRINTF(buff, " Single thread mode\n"); outLen += outString(buff, outFile); if (nThreads >= 1 && CANON_ON_GPU) { SPRINTF(buff, " Canonicity was tested on GPU by %zd checkers (%d for each thread) (\n", NUM_GPU_WORKERS * nThreads, NUM_GPU_WORKERS); outLen += outString(buff, outFile); } SPRINTF(buff, " Canonicity of partial constructed matrix was %sused\n", USE_CANON_GROUP ? "" : "not "); outLen += outString(buff, outFile); SPRINTF(buff, " Strong canonicity was %sused\n", USE_STRONG_CANONICITY ? "" : "not "); outLen += outString(buff, outFile); SPRINTF(buff, " Super strong canonicity was %sused\n\n", USE_STRONG_CANONICITY_A ? "" : "not "); outLen += outString(buff, outFile); FCLOSE(outFile); *pOutFile = NULL; designInfo()->rewindLen = outLen; }
//------------------------------------------------------------------------- // void Log::outMessage(const char* fmt, ...) { RETURN_IS_FAIL(m_pFileMessage); CACHE_VA_LIST(data, fmt); outString(m_pFileMessage, data, strlen(data)); }
int ACGI::cgiOutputBinary(const char *pccMIMEType, const char *pccMIMESubType, const char *pccFilePath) { if (m_posOut && pccMIMEType && pccMIMESubType && pccFilePath) { #ifdef _MSC_VER ifstream ifBinary(pccFilePath, ios::in|ios::binary); #elif defined(__BORLANDC__) ifstream ifBinary(pccFilePath, ios::in|ios::bin); #else //a_UNIX and others don't need the processing ifstream ifBinary(pccFilePath, ios::in); #endif #if defined(__BORLANDC__) || defined(__unix) if ((ifBinary.rdbuf())->is_open()) #else if (ifBinary.is_open()) #endif { //a_Get the length of the file ifBinary.seekg(0x0, ios::end); int iBytesRead = ifBinary.tellg(); //a_MIME output mimeOut(pccMIMEType, pccMIMESubType, iBytesRead); //a_Rewind the file ifBinary.seekg(0x0, ios::beg); //a_Set stream to binary #if defined(_MSC_VER) *this << ios::binary; #elif defined(__BORLANDC__) m_posOut.setf(ios::binary); #else //Probably UNIX and we do not care, everything is binary! #endif //Output the file char sBuffer[READ_BUFFER_SIZE]; while (!ifBinary.eof()) { ifBinary.read(sBuffer, READ_BUFFER_SIZE); iBytesRead = ifBinary.gcount(); if (iBytesRead > 0x0) m_posOut->write(sBuffer, iBytesRead); } ifBinary.close(); m_posOut->flush(); } else { #ifdef _DEBUG_DUMP_ mimeOut("text", "plain"); outStringN("Filename: "); outString(pccFilePath); outStringN(" connot be opened!"); #endif return 0x0; } } else { //a_You have to specify the MIME type/subtype for the binary output //a_and/or a non-NULL file path //a_and/or output stream variable is NULL assert(0x0); return 0x0; } return 0x1; }
void ceefit_call_spec FILEWRITER::Close() { if(Output != null) { STRING outString(StringWriter.ToString()); DYNARRAY<unicode_char_t> convertSrcBuffer; DYNARRAY<char> outBuf; int srcLen = outString.Length(); wchar_t* srcWchar = outString.GetBuffer(); convertSrcBuffer.Reserve(srcLen); int i = -1; while(++i < srcLen) { convertSrcBuffer[i] = srcWchar[i]; } outBuf.Reserve((srcLen*6) + 6); void* privateData; if(ExpectedEncoding->init) { ExpectedEncoding->init(&privateData); } unicode_char_t* src = &convertSrcBuffer[0]; char* dest = &outBuf[0]; fit_size_t incharsLeft = convertSrcBuffer.GetSize(); fit_size_t outbytesLeft = outBuf.GetSize(); fit_size_t maxbytesLeft = outbytesLeft; memset(dest, 0, outbytesLeft); // clear the dest buffer if(ExpectedEncoding->reset) { ExpectedEncoding->reset(privateData, (char**) &dest, &outbytesLeft); } enum unicode_write_result writeResult; writeResult = ExpectedEncoding->write(privateData, &src, &incharsLeft, &dest, &outbytesLeft); if(ExpectedEncoding->destroy) { ExpectedEncoding->destroy(&privateData); } if(writeResult != unicode_write_ok) { STRING reason; reason = STRING("Failed to write output file ") + OutFilepath.GetBuffer() + " using " + ExpectedEncoding->names[0] + " encoding."; // must have hit a bad character, die monster die! throw new IOEXCEPTION(reason); } fwrite(&outBuf[0], maxbytesLeft - outbytesLeft, 1, Output); fclose(Output); Output = null; } }
//------------------------------------------------------------------------- // void Log::outError(const char* fmt, ...) { RETURN_IS_FAIL(m_pFileError); CACHE_VA_LIST(data, fmt); outString(m_pFileError, data, strlen(data)); }
void Log::SetDebugLogMask(DebugLogFilters filter) { m_DebugLogMask = filter; outString( "debug log mask is %u", m_DebugLogMask ); }
// ************************* // interrupts.c - Interrupts // ************************* // Interrupts pause (or interrupt) the foreground code, execute, then return to the foreground code when finished. There are two components: // // 1. Providing an interrupt service routine (ISR). ISRs must be: // // - Declared as ``void _ISR special_name(void)``. // - They **MUST** clear the interrupt they are servicing to prevent an infinite loop. // - Contain no delays or long-running code (``while`` or ``for`` loops, ``outString``, etc.), since forground code will be delayed. // // 2. Have appropriate setup code in ``main`` which: // // - Clears the interrupt flag: ``_xxIF = 0;`` // - Selects a priority (between 1 and 7; 0 doesn't interrupt ``main``; 7 is the highest priority): ``_xxIP = n;`` // - Enables the interrupt: ``_xxIE = 1;`` // - Performs any other interrupt-specific setup (configure an input pin, select which pins to use for change notification interrupts, connect an INTx pin to a physical pin on the PIC, configure a timer, etc.) // // Change notification // =================== // Example 1 // --------- // Assume a pushbutton is connected between RB13 and ground. void _ISR _CNInterrupt(void) { --_CNIP; _CNIF = 0; outString("A"); }
// // 75. What is the voltage on RB13 when the pushbutton is pressed? 3.3, 0, X, or Z? // #. What is the voltage on RB13 when the pushbutton is released? Assume no pullup is present. 3.3, 0, X, or Z? // #. What is the voltage on RB13 when the pushbutton is released? Assume a pullup is present. 3.3, 0, X, or Z? // #. What is output on the first pushbutton press? X (nothing), A... (lots of As), otherwise A, AA, AAA, etc. // #. What is _CNIP after the first pushbutton press? // #. What is _CNIP after a release? // #. What is _CNIP after another press? // #. What is _CNIP after another release? // // Example 2 // --------- // Assume a pushbutton is connected between RB13 and ground. void _ISR _CNInterrupt(void) { _CNIE = 0; _CNIF = 0; outString("A"); }
void Log::outOpCode(uint32 op, const char * name, bool smsg) { if (!(_DebugLogMask & LOG_FILTER_OPCODES)) return; outString("%s: %s 0x%.4X (%u)", smsg ? "S->C" : "C->S", name, op, op); }
//------------------------------------------------------------------------- // void Log::outWarning(const char* fmt, ...) { RETURN_IS_FAIL(m_pFileWarning); CACHE_VA_LIST(data, fmt); outString(m_pFileWarning, data, strlen(data)); }