repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpReadHeaderField | error_t httpReadHeaderField(HttpConnection *connection,
char_t *buffer, size_t size, char_t *firstChar)
{
error_t error;
size_t n;
size_t length;
//This is the actual length of the header field
length = 0;
//The process of moving from a multiple-line representation of a header
//field to its s... | /**
* @brief Read multiple-line header field
* @param[in] connection Structure representing an HTTP connection
* @param[out] buffer Buffer where to store the header field
* @param[in] size Size of the buffer, in bytes
* @param[in,out] firstChar Leading character of the header line
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server_misc.c#L305-L397 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpParseHeaderField | void httpParseHeaderField(HttpConnection *connection,
const char_t *name, char_t *value)
{
//Host header field?
if(!osStrcasecmp(name, "Host"))
{
//Save host name
strSafeCopy(connection->request.host, value,
HTTP_SERVER_HOST_MAX_LEN);
}
//Connection header field?
else if(!osStr... | /**
* @brief Parse HTTP header field
* @param[in] connection Structure representing an HTTP connection
* @param[in] name Name of the header field
* @param[in] value Value of the header field
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server_misc.c#L407-L498 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | if | else if(!osStrcasecmp(name, "Upgrade"))
{
//WebSocket support?
if(!osStrcasecmp(value, "websocket"))
connection->request.upgradeWebSocket = TRUE;
} | //Upgrade header field? | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server_misc.c#L471-L476 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | if | else if(!osStrcasecmp(name, "Sec-WebSocket-Key"))
{
//Save the contents of the Sec-WebSocket-Key header field
strSafeCopy(connection->request.clientKey, value,
WEB_SOCKET_CLIENT_KEY_SIZE + 1);
} | //Sec-WebSocket-Key header field? | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server_misc.c#L478-L483 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | if | else if(!osStrcasecmp(name, "Cookie"))
{
//Parse Cookie header field
httpParseCookieField(connection, value);
} | //Cookie header field? | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server_misc.c#L487-L491 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpParseConnectionField | void httpParseConnectionField(HttpConnection *connection,
char_t *value)
{
char_t *p;
char_t *token;
//Get the first value of the list
token = osStrtok_r(value, ",", &p);
//Parse the comma-separated list
while(token != NULL)
{
//Trim whitespace characters
value = strTrimWhitespace(... | /**
* @brief Parse Connection header field
* @param[in] connection Structure representing an HTTP connection
* @param[in] value Connection field value
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server_misc.c#L506-L543 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpParseContentTypeField | void httpParseContentTypeField(HttpConnection *connection,
char_t *value)
{
#if (HTTP_SERVER_MULTIPART_TYPE_SUPPORT == ENABLED)
size_t n;
char_t *p;
char_t *token;
//Retrieve type
token = osStrtok_r(value, "/", &p);
//Any parsing error?
if(token == NULL)
return;
//The boundary paramet... | /**
* @brief Parse Content-Type header field
* @param[in] connection Structure representing an HTTP connection
* @param[in] value Content-Type field value
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server_misc.c#L552-L612 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpParseAcceptEncodingField | void httpParseAcceptEncodingField(HttpConnection *connection,
char_t *value)
{
#if (HTTP_SERVER_GZIP_TYPE_SUPPORT == ENABLED)
char_t *p;
char_t *token;
//Get the first value of the list
token = osStrtok_r(value, ",", &p);
//Parse the comma-separated list
while(token != NULL)
{
//Trim whi... | /**
* @brief Parse Accept-Encoding header field
* @param[in] connection Structure representing an HTTP connection
* @param[in] value Accept-Encoding field value
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server_misc.c#L621-L648 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpParseCookieField | void httpParseCookieField(HttpConnection *connection, char_t *value)
{
#if (HTTP_SERVER_COOKIE_SUPPORT == ENABLED)
//Save the value of the header field
strSafeCopy(connection->request.cookie, value, HTTP_SERVER_COOKIE_MAX_LEN);
#endif
} | /**
* @brief Parse Cookie header field
* @param[in] connection Structure representing an HTTP connection
* @param[in] value Accept-Encoding field value
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server_misc.c#L657-L663 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpReadChunkSize | error_t httpReadChunkSize(HttpConnection *connection)
{
error_t error;
size_t n;
char_t *end;
char_t s[8];
//First chunk to be received?
if(connection->request.firstChunk)
{
//Clear the flag
connection->request.firstChunk = FALSE;
}
else
{
//Read the CRLF that follows th... | /**
* @brief Read chunk-size field from the input stream
* @param[in] connection Structure representing an HTTP connection
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server_misc.c#L671-L744 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpInitResponseHeader | void httpInitResponseHeader(HttpConnection *connection)
{
//Default HTTP header fields
connection->response.version = connection->request.version;
connection->response.statusCode = 200;
connection->response.noCache = FALSE;
connection->response.maxAge = 0;
connection->response.location = NULL;
conn... | /**
* @brief Initialize response header
* @param[in] connection Structure representing an HTTP connection
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server_misc.c#L752-L775 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpFormatResponseHeader | error_t httpFormatResponseHeader(HttpConnection *connection, char_t *buffer)
{
uint_t i;
char_t *p;
//HTTP version 0.9?
if(connection->response.version == HTTP_VERSION_0_9)
{
//Enforce default parameters
connection->response.keepAlive = FALSE;
connection->response.chunkedEncoding = FAL... | /**
* @brief Format HTTP response header
* @param[in] connection Structure representing an HTTP connection
* @param[out] buffer Pointer to the buffer where to format the HTTP header
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server_misc.c#L785-L960 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpSend | error_t httpSend(HttpConnection *connection,
const void *data, size_t length, uint_t flags)
{
#if (NET_RTOS_SUPPORT == ENABLED)
error_t error;
#if (HTTP_SERVER_TLS_SUPPORT == ENABLED)
//Check whether a secure connection is being used
if(connection->tlsContext != NULL)
{
//Use TLS to transmit data ... | /**
* @brief Send data to the client
* @param[in] connection Structure representing an HTTP connection
* @param[in] data Pointer to a buffer containing the data to be transmitted
* @param[in] length Number of bytes to be transmitted
* @param[in] flags Set of flags that influences the behavior of this function
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server_misc.c#L971-L1014 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpReceive | error_t httpReceive(HttpConnection *connection,
void *data, size_t size, size_t *received, uint_t flags)
{
#if (NET_RTOS_SUPPORT == ENABLED)
error_t error;
#if (HTTP_SERVER_TLS_SUPPORT == ENABLED)
//Check whether a secure connection is being used
if(connection->tlsContext != NULL)
{
//Use TLS to r... | /**
* @brief Receive data from the client
* @param[in] connection Structure representing an HTTP connection
* @param[out] data Buffer into which received data will be placed
* @param[in] size Maximum number of bytes that can be received
* @param[out] received Actual number of bytes that have been received
* @para... | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server_misc.c#L1027-L1108 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpGetAbsolutePath | void httpGetAbsolutePath(HttpConnection *connection,
const char_t *relative, char_t *absolute, size_t maxLen)
{
//Copy the root directory
osStrcpy(absolute, connection->settings->rootDirectory);
//Append the specified path
pathCombine(absolute, relative, maxLen);
//Clean the resulting path
pathCa... | /**
* @brief Retrieve the full pathname to the specified resource
* @param[in] connection Structure representing an HTTP connection
* @param[in] relative String containing the relative path to the resource
* @param[out] absolute Resulting string containing the absolute path
* @param[in] maxLen Maximum acceptable p... | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server_misc.c#L1119-L1130 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpCompExtension | bool_t httpCompExtension(const char_t *filename, const char_t *extension)
{
uint_t n;
uint_t m;
//Get the length of the specified filename
n = osStrlen(filename);
//Get the length of the extension
m = osStrlen(extension);
//Check the length of the filename
if(n < m)
return FALSE;
//C... | /**
* @brief Compare filename extension
* @param[in] filename Filename whose extension is to be checked
* @param[in] extension String defining the extension to be checked
* @return TRUE is the filename matches the given extension, else FALSE
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server_misc.c#L1140-L1163 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpDecodePercentEncodedString | error_t httpDecodePercentEncodedString(const char_t *input,
char_t *output, size_t outputSize)
{
size_t i;
char_t buffer[3];
//Check parameters
if(input == NULL || output == NULL)
return ERROR_INVALID_PARAMETER;
//Decode the percent-encoded string
for(i = 0; *input != '\0' && i < outputSize... | /**
* @brief Decode a percent-encoded string
* @param[in] input NULL-terminated string to be decoded
* @param[out] output NULL-terminated string resulting from the decoding process
* @param[in] outputSize Size of the output buffer in bytes
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server_misc.c#L1174-L1223 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpConvertArrayToHexString | void httpConvertArrayToHexString(const uint8_t *input,
size_t inputLen, char_t *output)
{
size_t i;
//Hex conversion table
static const char_t hexDigit[16] =
{
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
};
//Process byte array
for(i = 0; i < inpu... | /**
* @brief Convert byte array to hex string
* @param[in] input Point to the byte array
* @param[in] inputLen Length of the byte array
* @param[out] output NULL-terminated string resulting from the conversion
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server_misc.c#L1233-L1256 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mqttClientWebSocketTlsInitCallback | error_t mqttClientWebSocketTlsInitCallback(WebSocket *webSocket,
TlsContext *tlsContext)
{
MqttClientContext *context;
// Point to the MQTT client context
context = webSocket->tlsInitParam;
// Invoke user-defined callback
return context->callbacks.tlsInitCallb... | /**
* @brief TLS initialization callback
* @param[in] webSocket Handle to a WebSocket
* @param[in] tlsContext Pointer to the TLS context
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/mqtt/mqtt_client_transport.c#L55-L65 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mqttClientOpenConnection | error_t mqttClientOpenConnection(MqttClientContext *context)
{
error_t error;
// TCP transport protocol?
if (context->settings.transportProtocol == MQTT_TRANSPORT_PROTOCOL_TCP)
{
// Open a TCP socket
context->socket = socketOpen(SOCKET_TYPE_STREAM, SOCKET_IP_PROTO_TCP);
// Valid socket h... | /**
* @brief Open network connection
* @param[in] context Pointer to the MQTT client context
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/mqtt/mqtt_client_transport.c#L75-L227 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | if | else if (context->settings.transportProtocol == MQTT_TRANSPORT_PROTOCOL_TLS)
{
// Open a TCP socket
context->socket = socketOpen(SOCKET_TYPE_STREAM, SOCKET_IP_PROTO_TCP);
// Valid socket handle?
if (context->socket != NULL)
{
// Associate the socket with the relevant interface... | // TLS transport protocol? | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/mqtt/mqtt_client_transport.c#L99-L162 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | if | else if (context->settings.transportProtocol == MQTT_TRANSPORT_PROTOCOL_WS)
{
// Open a WebSocket
context->webSocket = webSocketOpen();
// Valid WebSocket handle?
if (context->webSocket != NULL)
{
// Associate the WebSocket with the relevant interface
error = webSocke... | // WebSocket transport protocol? | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/mqtt/mqtt_client_transport.c#L166-L183 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | if | else if (context->settings.transportProtocol == MQTT_TRANSPORT_PROTOCOL_WSS)
{
// Open a WebSocket
context->webSocket = webSocketOpen();
// Valid WebSocket handle?
if (context->webSocket != NULL)
{
// Associate the WebSocket with the relevant interface
error = webSock... | // Secure WebSocket transport protocol? | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/mqtt/mqtt_client_transport.c#L188-L216 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mqttClientEstablishConnection | error_t mqttClientEstablishConnection(MqttClientContext *context,
const IpAddr *serverIpAddr, uint16_t serverPort)
{
error_t error;
// TCP transport protocol?
if (context->settings.transportProtocol == MQTT_TRANSPORT_PROTOCOL_TCP)
{
// Set timeout
error = s... | /**
* @brief Establish network connection
* @param[in] context Pointer to the MQTT client context
* @param[in] serverIpAddr IP address of the MQTT server to connect to
* @param[in] serverPort TCP port number that will be used to establish the
* connection
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/mqtt/mqtt_client_transport.c#L238-L326 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | if | else if (context->settings.transportProtocol == MQTT_TRANSPORT_PROTOCOL_TLS)
{
// Set timeout
error = socketSetTimeout(context->socket, context->settings.timeout);
// Check status code
if (!error)
{
// Connect to the MQTT server using TCP
error = socketConnect(context... | // TLS transport protocol? | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/mqtt/mqtt_client_transport.c#L258-L283 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | if | else if (context->settings.transportProtocol == MQTT_TRANSPORT_PROTOCOL_WS ||
context->settings.transportProtocol == MQTT_TRANSPORT_PROTOCOL_WSS)
{
// Set timeout
error = webSocketSetTimeout(context->webSocket, context->settings.timeout);
// Check status code
if (!error)
{
... | // WebSocket transport protocol? | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/mqtt/mqtt_client_transport.c#L287-L315 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mqttClientShutdownConnection | error_t mqttClientShutdownConnection(MqttClientContext *context)
{
error_t error;
// TCP transport protocol?
if (context->settings.transportProtocol == MQTT_TRANSPORT_PROTOCOL_TCP)
{
// Set timeout
error = socketSetTimeout(context->socket, context->settings.timeout);
// Check status code... | /**
* @brief Shutdown network connection
* @param[in] context Pointer to the MQTT client context
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/mqtt/mqtt_client_transport.c#L334-L398 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | if | else if (context->settings.transportProtocol == MQTT_TRANSPORT_PROTOCOL_TLS)
{
// Set timeout
error = socketSetTimeout(context->socket, context->settings.timeout);
// Check status code
if (!error)
{
// Shutdown TLS session
error = tlsShutdown(context->tlsContext);
... | // TLS transport protocol? | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/mqtt/mqtt_client_transport.c#L353-L371 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | if | else if (context->settings.transportProtocol == MQTT_TRANSPORT_PROTOCOL_WS ||
context->settings.transportProtocol == MQTT_TRANSPORT_PROTOCOL_WSS)
{
// Set timeout
error = webSocketSetTimeout(context->webSocket, context->settings.timeout);
// Check status code
if (!error)
{
... | // WebSocket transport protocol? | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/mqtt/mqtt_client_transport.c#L375-L387 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mqttClientCloseConnection | void mqttClientCloseConnection(MqttClientContext *context)
{
// TCP transport protocol?
if (context->settings.transportProtocol == MQTT_TRANSPORT_PROTOCOL_TCP)
{
// Close TCP connection
if (context->socket != NULL)
{
socketClose(context->socket);
context->socket = NULL;
... | /**
* @brief Close network connection
* @param[in] context Pointer to the MQTT client context
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/mqtt/mqtt_client_transport.c#L405-L449 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | if | else if (context->settings.transportProtocol == MQTT_TRANSPORT_PROTOCOL_TLS)
{
// Release TLS context
if (context->tlsContext != NULL)
{
tlsFree(context->tlsContext);
context->tlsContext = NULL;
}
// Close TCP connection
if (context->socket != NULL)
{
... | // TLS transport protocol? | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/mqtt/mqtt_client_transport.c#L419-L434 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | if | else if (context->settings.transportProtocol == MQTT_TRANSPORT_PROTOCOL_WS ||
context->settings.transportProtocol == MQTT_TRANSPORT_PROTOCOL_WSS)
{
// Close WebSocket connection
if (context->webSocket != NULL)
{
webSocketClose(context->webSocket);
context->webSocket = ... | // WebSocket transport protocol? | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/mqtt/mqtt_client_transport.c#L438-L447 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mqttClientSendData | error_t mqttClientSendData(MqttClientContext *context,
const void *data, size_t length, size_t *written, uint_t flags)
{
error_t error;
// TCP transport protocol?
if (context->settings.transportProtocol == MQTT_TRANSPORT_PROTOCOL_TCP)
{
// Set timeout
error = socketSe... | /**
* @brief Send data using the relevant transport protocol
* @param[in] context Pointer to the MQTT client context
* @param[in] data Pointer to a buffer containing the data to be transmitted
* @param[in] length Number of bytes to be transmitted
* @param[out] written Actual number of bytes written (optional param... | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/mqtt/mqtt_client_transport.c#L461-L520 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | if | else if (context->settings.transportProtocol == MQTT_TRANSPORT_PROTOCOL_TLS)
{
// Set timeout
error = socketSetTimeout(context->socket, context->settings.timeout);
// Check status code
if (!error)
{
// Transmit data
error = tlsWrite(context->tlsContext, data, length, ... | // TLS transport protocol? | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/mqtt/mqtt_client_transport.c#L481-L492 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | if | else if (context->settings.transportProtocol == MQTT_TRANSPORT_PROTOCOL_WS ||
context->settings.transportProtocol == MQTT_TRANSPORT_PROTOCOL_WSS)
{
// Set timeout
error = webSocketSetTimeout(context->webSocket, context->settings.timeout);
// Check status code
if (!error)
{
... | // WebSocket transport protocol? | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/mqtt/mqtt_client_transport.c#L496-L509 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mqttClientReceiveData | error_t mqttClientReceiveData(MqttClientContext *context,
void *data, size_t size, size_t *received, uint_t flags)
{
error_t error;
// No data has been read yet
*received = 0;
// TCP transport protocol?
if (context->settings.transportProtocol == MQTT_TRANSPORT_PROTOCOL_TCP... | /**
* @brief Receive data using the relevant transport protocol
* @param[in] context Pointer to the MQTT client context
* @param[out] data Buffer into which received data will be placed
* @param[in] size Maximum number of bytes that can be received
* @param[out] received Number of bytes that have been received
* ... | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/mqtt/mqtt_client_transport.c#L532-L605 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | if | else if (context->settings.transportProtocol == MQTT_TRANSPORT_PROTOCOL_TLS)
{
// Set timeout
error = socketSetTimeout(context->socket, context->settings.timeout);
// Check status code
if (!error)
{
// Receive data
error = tlsRead(context->tlsContext, data, size, rece... | // TLS transport protocol? | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/mqtt/mqtt_client_transport.c#L555-L566 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | if | else if (context->settings.transportProtocol == MQTT_TRANSPORT_PROTOCOL_WS ||
context->settings.transportProtocol == MQTT_TRANSPORT_PROTOCOL_WSS)
{
WebSocketFrameType type;
// Set timeout
error = webSocketSetTimeout(context->webSocket, context->settings.timeout);
// Check status... | // WebSocket transport protocol? | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/mqtt/mqtt_client_transport.c#L570-L594 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mqttClientWaitForData | error_t mqttClientWaitForData(MqttClientContext *context, systime_t timeout)
{
uint_t event;
// TCP transport protocol?
if (context->settings.transportProtocol == MQTT_TRANSPORT_PROTOCOL_TCP)
{
// Wait for some data to be available for reading
event = tcpWaitForEvents(context->socket, SOCKET_EV... | /**
* @brief Wait for incoming data
* @param[in] context Pointer to the MQTT client context
* @param[in] timeout Maximum time to wait before returning
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/mqtt/mqtt_client_transport.c#L614-L702 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | if | else if (context->settings.transportProtocol == MQTT_TRANSPORT_PROTOCOL_TLS)
{
// Sanity check
if (context->tlsContext == NULL)
return ERROR_FAILURE;
// Check whether some data is pending in the receive buffer
if (context->tlsContext->rxBufferLen > 0)
{
// No need to ... | // TLS transport protocol? | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/mqtt/mqtt_client_transport.c#L626-L643 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | if | else if (context->settings.transportProtocol == MQTT_TRANSPORT_PROTOCOL_WS)
{
// Sanity check
if (context->webSocket == NULL)
return ERROR_FAILURE;
// Get exclusive access
osAcquireMutex(&netMutex);
// Wait for some data to be available for reading
event = tcpWaitForEven... | // WebSocket transport protocol? | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/mqtt/mqtt_client_transport.c#L647-L659 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | if | else if (context->settings.transportProtocol == MQTT_TRANSPORT_PROTOCOL_WSS)
{
// Sanity check
if (context->webSocket == NULL || context->webSocket->tlsContext == NULL)
return ERROR_FAILURE;
// Check whether some data is pending in the receive buffer
if (context->webSocket->tlsConte... | // Secure WebSocket transport protocol? | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/mqtt/mqtt_client_transport.c#L663-L684 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | _getopt_internal | int _getopt_internal(argc, argv, optstring, longopts, longind, long_only)
int argc;
char *const *argv;
const char *optstring;
const struct option *longopts;
int *longind;
int long_only;
{
int print_errors = opterr;
if (optstring[0] == ':')
print_errors = 0;
if (argc < 1)
return -1;
opt... | /* Scan elements of ARGV (whose length is ARGC) for option characters
given in OPTSTRING.
If an element of ARGV starts with '-', and is not exactly "-" or "--",
then it is an option element. The characters of this element
(aside from the initial '-') are option characters. If `getopt'
is called repeatedly, it return... | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/platform/getopt.c#L508-L1155 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | main | int main(argc, argv)
int argc;
char **argv;
{
int c;
int digit_optind = 0;
while (1)
{
int this_option_optind = optind ? optind : 1;
c = getopt(argc, argv, "abc:d:0123456789");
if (c == -1)
break;
switch (c)
{
case '0':
case '1':
... | /* Compile with -DTEST to make an executable for use in testing
the above definition of `getopt'. */ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/platform/getopt.c#L1187-L1249 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | tcpWaitForEvents | uint_t tcpWaitForEvents(Socket *socket, uint_t eventMask, systime_t timeout)
{
fd_set read_fds;
struct timeval tv;
if (socket == NULL)
return 0;
// Initialize the file descriptor set.
FD_ZERO(&read_fds);
FD_SET(socket->descriptor, &read_fds);
// Set timeout.
tv.tv_sec = timeou... | /**
* @brief Wait for a particular TCP event
* @param[in] socket Handle referencing the socket
* @param[in] eventMask Logic OR of all the TCP events that will complete the wait
* @param[in] timeout Maximum time to wait
* @return Logic OR of all the TCP events that satisfied the wait
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/platform/platform_linux.c#L450-L476 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | getCurrentUnixTime | time_t getCurrentUnixTime(void)
{
return time(NULL);
} | /**
* @brief Get current time
* @return Unix timestamp
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/platform/platform_linux.c#L483-L486 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | tcpWaitForEvents | uint_t tcpWaitForEvents(Socket *socket, uint_t eventMask, systime_t timeout)
{
fd_set read_fds;
struct timeval tv;
if (socket == NULL)
return 0;
// Initialize the file descriptor set.
FD_ZERO(&read_fds);
FD_SET(socket->descriptor, &read_fds);
// Set timeout.
tv.tv_sec = timeou... | /**
* @brief Wait for a particular TCP event
* @param[in] socket Handle referencing the socket
* @param[in] eventMask Logic OR of all the TCP events that will complete the wait
* @param[in] timeout Maximum time to wait
* @return Logic OR of all the TCP events that satisfied the wait
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/platform/platform_windows.c#L508-L534 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | protobuf_c_buffer_simple_append | void
protobuf_c_buffer_simple_append(ProtobufCBuffer *buffer,
size_t len, const uint8_t *data)
{
ProtobufCBufferSimple *simp = (ProtobufCBufferSimple *) buffer;
size_t new_len = simp->len + len;
if (new_len > simp->alloced) {
ProtobufCAllocator *allocator = simp->allocator;
size_t new_alloced = simp->alloce... | /* === buffer-simple === */ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L190-L219 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | get_tag_size | static inline size_t
get_tag_size(uint32_t number)
{
if (number < (1UL << 4)) {
return 1;
} else if (number < (1UL << 11)) {
return 2;
} else if (number < (1UL << 18)) {
return 3;
} else if (number < (1UL << 25)) {
return 4;
} else {
return 5;
}
} | /**
* \defgroup packedsz protobuf_c_message_get_packed_size() implementation
*
* Routines mainly used by protobuf_c_message_get_packed_size().
*
* \ingroup internal
* @{
*/
/**
* Return the number of bytes required to store the tag for the field. Includes
* 3 bits for the wire-type, and a single bit that denot... | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L239-L253 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | uint32_size | static inline size_t
uint32_size(uint32_t v)
{
if (v < (1UL << 7)) {
return 1;
} else if (v < (1UL << 14)) {
return 2;
} else if (v < (1UL << 21)) {
return 3;
} else if (v < (1UL << 28)) {
return 4;
} else {
return 5;
}
} | /**
* Return the number of bytes required to store a variable-length unsigned
* 32-bit integer in base-128 varint encoding.
*
* \param v
* Value to encode.
* \return
* Number of bytes required.
*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L264-L278 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | int32_size | static inline size_t
int32_size(int32_t v)
{
if (v < 0) {
return 10;
} else if (v < (1L << 7)) {
return 1;
} else if (v < (1L << 14)) {
return 2;
} else if (v < (1L << 21)) {
return 3;
} else if (v < (1L << 28)) {
return 4;
} else {
return 5;
}
} | /**
* Return the number of bytes required to store a variable-length signed 32-bit
* integer in base-128 varint encoding.
*
* \param v
* Value to encode.
* \return
* Number of bytes required.
*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L289-L305 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | zigzag32 | static inline uint32_t
zigzag32(int32_t v)
{
// Note: Using unsigned types prevents undefined behavior
return ((uint32_t)v << 1) ^ -((uint32_t)v >> 31);
} | /**
* Return the ZigZag-encoded 32-bit unsigned integer form of a 32-bit signed
* integer.
*
* \param v
* Value to encode.
* \return
* ZigZag encoded integer.
*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L316-L321 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | sint32_size | static inline size_t
sint32_size(int32_t v)
{
return uint32_size(zigzag32(v));
} | /**
* Return the number of bytes required to store a signed 32-bit integer,
* converted to an unsigned 32-bit integer with ZigZag encoding, using base-128
* varint encoding.
*
* \param v
* Value to encode.
* \return
* Number of bytes required.
*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L333-L337 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | uint64_size | static inline size_t
uint64_size(uint64_t v)
{
uint32_t upper_v = (uint32_t) (v >> 32);
if (upper_v == 0) {
return uint32_size((uint32_t) v);
} else if (upper_v < (1UL << 3)) {
return 5;
} else if (upper_v < (1UL << 10)) {
return 6;
} else if (upper_v < (1UL << 17)) {
return 7;
} else if (upper_v < (1UL ... | /**
* Return the number of bytes required to store a 64-bit unsigned integer in
* base-128 varint encoding.
*
* \param v
* Value to encode.
* \return
* Number of bytes required.
*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L348-L368 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | zigzag64 | static inline uint64_t
zigzag64(int64_t v)
{
// Note: Using unsigned types prevents undefined behavior
return ((uint64_t)v << 1) ^ -((uint64_t)v >> 63);
} | /**
* Return the ZigZag-encoded 64-bit unsigned integer form of a 64-bit signed
* integer.
*
* \param v
* Value to encode.
* \return
* ZigZag encoded integer.
*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L379-L384 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | sint64_size | static inline size_t
sint64_size(int64_t v)
{
return uint64_size(zigzag64(v));
} | /**
* Return the number of bytes required to store a signed 64-bit integer,
* converted to an unsigned 64-bit integer with ZigZag encoding, using base-128
* varint encoding.
*
* \param v
* Value to encode.
* \return
* Number of bytes required.
*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L396-L400 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | required_field_get_packed_size | static size_t
required_field_get_packed_size(const ProtobufCFieldDescriptor *field,
const void *member)
{
size_t rv = get_tag_size(field->id);
switch (field->type) {
case PROTOBUF_C_TYPE_SINT32:
return rv + sint32_size(*(const int32_t *) member);
case PROTOBUF_C_TYPE_ENUM:
case PROTOBUF_C_TYPE_INT32:
... | /**
* Calculate the serialized size of a single required message field, including
* the space needed by the preceding tag.
*
* \param field
* Field descriptor for member.
* \param member
* Field to encode.
* \return
* Number of bytes required.
*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L413-L461 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | oneof_field_get_packed_size | static size_t
oneof_field_get_packed_size(const ProtobufCFieldDescriptor *field,
uint32_t oneof_case,
const void *member)
{
if (oneof_case != field->id) {
return 0;
}
if (field->type == PROTOBUF_C_TYPE_MESSAGE ||
field->type == PROTOBUF_C_TYPE_STRING)
{
const void *ptr = *(const void * const ... | /**
* Calculate the serialized size of a single oneof message field, including
* the space needed by the preceding tag. Returns 0 if the oneof field isn't
* selected or is not set.
*
* \param field
* Field descriptor for member.
* \param oneof_case
* Enum value that selects the field in the oneof.
* ... | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L477-L493 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | optional_field_get_packed_size | static size_t
optional_field_get_packed_size(const ProtobufCFieldDescriptor *field,
const protobuf_c_boolean has,
const void *member)
{
if (field->type == PROTOBUF_C_TYPE_MESSAGE ||
field->type == PROTOBUF_C_TYPE_STRING)
{
const void *ptr = *(const void * const *) member;
if (ptr == NULL ... | /**
* Calculate the serialized size of a single optional message field, including
* the space needed by the preceding tag. Returns 0 if the optional field isn't
* set.
*
* \param field
* Field descriptor for member.
* \param has
* True if the field exists, false if not.
* \param member
* Field ... | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L509-L525 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | unlabeled_field_get_packed_size | static size_t
unlabeled_field_get_packed_size(const ProtobufCFieldDescriptor *field,
const void *member)
{
if (field_is_zeroish(field, member))
return 0;
return required_field_get_packed_size(field, member);
} | /**
* Calculate the serialized size of a single unlabeled message field, including
* the space needed by the preceding tag. Returns 0 if the field isn't set or
* if it is set to a "zeroish" value (null pointer or 0 for numerical values).
* Unlabeled fields are supported only in proto3.
*
* \param field
* Fi... | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L587-L594 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | repeated_field_get_packed_size | static size_t
repeated_field_get_packed_size(const ProtobufCFieldDescriptor *field,
size_t count, const void *member)
{
size_t header_size;
size_t rv = 0;
unsigned i;
void *array = *(void * const *) member;
if (count == 0)
return 0;
header_size = get_tag_size(field->id);
if (0 == (field->flags & PRO... | /**
* Calculate the serialized size of repeated message fields, which may consist
* of any number of values (including 0). Includes the space needed by the
* preceding tags (as needed).
*
* \param field
* Field descriptor for member.
* \param count
* Number of repeated field members.
* \param member
... | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L610-L685 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | unknown_field_get_packed_size | static inline size_t
unknown_field_get_packed_size(const ProtobufCMessageUnknownField *field)
{
return get_tag_size(field->tag) + field->len;
} | /**
* Calculate the serialized size of an unknown field, i.e. one that is passed
* through mostly uninterpreted. This is required for forward compatibility if
* new fields are added to the message descriptor.
*
* \param field
* Unknown field type.
* \return
* Number of bytes required.
*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L697-L701 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | protobuf_c_message_get_packed_size | size_t protobuf_c_message_get_packed_size(const ProtobufCMessage *message)
{
unsigned i;
size_t rv = 0;
ASSERT_IS_MESSAGE(message);
for (i = 0; i < message->descriptor->n_fields; i++) {
const ProtobufCFieldDescriptor *field =
message->descriptor->fields + i;
const void *member =
((const char *) message) ... | /**@}*/
/*
* Calculate the serialized size of the message.
*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L708-L754 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | uint32_pack | static inline size_t
uint32_pack(uint32_t value, uint8_t *out)
{
unsigned rv = 0;
if (value >= 0x80) {
out[rv++] = value | 0x80;
value >>= 7;
if (value >= 0x80) {
out[rv++] = value | 0x80;
value >>= 7;
if (value >= 0x80) {
out[rv++] = value | 0x80;
value >>= 7;
if (value >= 0x80) {
ou... | /**
* \defgroup pack protobuf_c_message_pack() implementation
*
* Routines mainly used by protobuf_c_message_pack().
*
* \ingroup internal
* @{
*/
/**
* Pack an unsigned 32-bit integer in base-128 varint encoding and return the
* number of bytes written, which must be 5 or less.
*
* \param value
* Valu... | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L776-L800 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | int32_pack | static inline size_t
int32_pack(uint32_t value, uint8_t *out)
{
if ((int32_t)value < 0) {
out[0] = value | 0x80;
out[1] = (value >> 7) | 0x80;
out[2] = (value >> 14) | 0x80;
out[3] = (value >> 21) | 0x80;
out[4] = (value >> 28) | 0xf0;
out[5] = out[6] = out[7] = out[8] = 0xff;
out[9] = 0x01;
return 10;... | /**
* Pack a signed 32-bit integer and return the number of bytes written,
* passed as unsigned to avoid implementation-specific behavior.
* Negative numbers are encoded as two's complement 64-bit integers.
*
* \param value
* Value to encode.
* \param[out] out
* Packed value.
* \return
* Number... | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L814-L829 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | sint32_pack | static inline size_t
sint32_pack(int32_t value, uint8_t *out)
{
return uint32_pack(zigzag32(value), out);
} | /**
* Pack a signed 32-bit integer using ZigZag encoding and return the number of
* bytes written.
*
* \param value
* Value to encode.
* \param[out] out
* Packed value.
* \return
* Number of bytes written to `out`.
*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L842-L846 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | uint64_pack | static size_t
uint64_pack(uint64_t value, uint8_t *out)
{
uint32_t hi = (uint32_t) (value >> 32);
uint32_t lo = (uint32_t) value;
unsigned rv;
if (hi == 0)
return uint32_pack((uint32_t) lo, out);
out[0] = (lo) | 0x80;
out[1] = (lo >> 7) | 0x80;
out[2] = (lo >> 14) | 0x80;
out[3] = (lo >> 21) | 0x80;
if (hi ... | /**
* Pack a 64-bit unsigned integer using base-128 varint encoding and return the
* number of bytes written.
*
* \param value
* Value to encode.
* \param[out] out
* Packed value.
* \return
* Number of bytes written to `out`.
*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L859-L886 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | sint64_pack | static inline size_t
sint64_pack(int64_t value, uint8_t *out)
{
return uint64_pack(zigzag64(value), out);
} | /**
* Pack a 64-bit signed integer in ZigZag encoding and return the number of
* bytes written.
*
* \param value
* Value to encode.
* \param[out] out
* Packed value.
* \return
* Number of bytes written to `out`.
*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L899-L903 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | fixed32_pack | static inline size_t
fixed32_pack(uint32_t value, void *out)
{
#if !defined(WORDS_BIGENDIAN)
memcpy(out, &value, 4);
#else
uint8_t *buf = out;
buf[0] = value;
buf[1] = value >> 8;
buf[2] = value >> 16;
buf[3] = value >> 24;
#endif
return 4;
} | /**
* Pack a 32-bit quantity in little-endian byte order. Used for protobuf wire
* types fixed32, sfixed32, float. Similar to "htole32".
*
* \param value
* Value to encode.
* \param[out] out
* Packed value.
* \return
* Number of bytes written to `out`.
*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L916-L930 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | fixed64_pack | static inline size_t
fixed64_pack(uint64_t value, void *out)
{
#if !defined(WORDS_BIGENDIAN)
memcpy(out, &value, 8);
#else
fixed32_pack(value, out);
fixed32_pack(value >> 32, ((char *) out) + 4);
#endif
return 8;
} | /**
* Pack a 64-bit quantity in little-endian byte order. Used for protobuf wire
* types fixed64, sfixed64, double. Similar to "htole64".
*
* \todo The big-endian impl is really only good for 32-bit machines, a 64-bit
* version would be appreciated, plus a way to decide to use 64-bit math where
* convenient.
*
... | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L947-L957 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | boolean_pack | static inline size_t
boolean_pack(protobuf_c_boolean value, uint8_t *out)
{
*out = value ? TRUE : FALSE;
return 1;
} | /**
* Pack a boolean value as an integer and return the number of bytes written.
*
* \todo Perhaps on some platforms *out = !!value would be a better impl, b/c
* that is idiomatic C++ in some STL implementations.
*
* \param value
* Value to encode.
* \param[out] out
* Packed value.
* \return
* ... | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L972-L977 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | string_pack | static inline size_t
string_pack(const char *str, uint8_t *out)
{
if (str == NULL) {
out[0] = 0;
return 1;
} else {
size_t len = strlen(str);
size_t rv = uint32_pack(len, out);
memcpy(out + rv, str, len);
return rv + len;
}
} | /**
* Pack a NUL-terminated C string and return the number of bytes written. The
* output includes a length delimiter.
*
* The NULL pointer is treated as an empty string. This isn't really necessary,
* but it allows people to leave required strings blank. (See Issue #13 in the
* bug tracker for a little more expl... | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L994-L1006 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | binary_data_pack | static inline size_t
binary_data_pack(const ProtobufCBinaryData *bd, uint8_t *out)
{
size_t len = bd->len;
size_t rv = uint32_pack(len, out);
memcpy(out + rv, bd->data, len);
return rv + len;
} | /**
* Pack a ProtobufCBinaryData and return the number of bytes written. The output
* includes a length delimiter.
*
* \param bd
* ProtobufCBinaryData to encode.
* \param[out] out
* Packed value.
* \return
* Number of bytes written to `out`.
*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L1019-L1026 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | prefixed_message_pack | static inline size_t
prefixed_message_pack(const ProtobufCMessage *message, uint8_t *out)
{
if (message == NULL) {
out[0] = 0;
return 1;
} else {
size_t rv = protobuf_c_message_pack(message, out + 1);
uint32_t rv_packed_size = uint32_size(rv);
if (rv_packed_size != 1)
memmove(out + rv_packed_size, out + ... | /**
* Pack a ProtobufCMessage and return the number of bytes written. The output
* includes a length delimiter.
*
* \param message
* ProtobufCMessage object to pack.
* \param[out] out
* Packed message.
* \return
* Number of bytes written to `out`.
*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L1039-L1052 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | tag_pack | static size_t
tag_pack(uint32_t id, uint8_t *out)
{
if (id < (1UL << (32 - 3)))
return uint32_pack(id << 3, out);
else
return uint64_pack(((uint64_t) id) << 3, out);
} | /**
* Pack a field tag.
*
* Wire-type will be added in required_field_pack().
*
* \todo Just call uint64_pack on 64-bit platforms.
*
* \param id
* Tag value to encode.
* \param[out] out
* Packed value.
* \return
* Number of bytes written to `out`.
*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L1068-L1075 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | required_field_pack | static size_t
required_field_pack(const ProtobufCFieldDescriptor *field,
const void *member, uint8_t *out)
{
size_t rv = tag_pack(field->id, out);
switch (field->type) {
case PROTOBUF_C_TYPE_SINT32:
out[0] |= PROTOBUF_C_WIRE_TYPE_VARINT;
return rv + sint32_pack(*(const int32_t *) member, out + rv);
case ... | /**
* Pack a required field and return the number of bytes written.
*
* \param field
* Field descriptor.
* \param member
* The field member.
* \param[out] out
* Packed value.
* \return
* Number of bytes written to `out`.
*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L1089-L1138 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | oneof_field_pack | static size_t
oneof_field_pack(const ProtobufCFieldDescriptor *field,
uint32_t oneof_case,
const void *member, uint8_t *out)
{
if (oneof_case != field->id) {
return 0;
}
if (field->type == PROTOBUF_C_TYPE_MESSAGE ||
field->type == PROTOBUF_C_TYPE_STRING)
{
const void *ptr = *(const void * const *) me... | /**
* Pack a oneof field and return the number of bytes written. Only packs the
* field that is selected by the case enum.
*
* \param field
* Field descriptor.
* \param oneof_case
* Enum value that selects the field in the oneof.
* \param member
* The field member.
* \param[out] out
* Pac... | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L1155-L1171 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | optional_field_pack | static size_t
optional_field_pack(const ProtobufCFieldDescriptor *field,
const protobuf_c_boolean has,
const void *member, uint8_t *out)
{
if (field->type == PROTOBUF_C_TYPE_MESSAGE ||
field->type == PROTOBUF_C_TYPE_STRING)
{
const void *ptr = *(const void * const *) member;
if (ptr == NULL || pt... | /**
* Pack an optional field and return the number of bytes written.
*
* \param field
* Field descriptor.
* \param has
* Whether the field is set.
* \param member
* The field member.
* \param[out] out
* Packed value.
* \return
* Number of bytes written to `out`.
*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L1187-L1203 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | unlabeled_field_pack | static size_t
unlabeled_field_pack(const ProtobufCFieldDescriptor *field,
const void *member, uint8_t *out)
{
if (field_is_zeroish(field, member))
return 0;
return required_field_pack(field, member, out);
} | /**
* Pack an unlabeled field and return the number of bytes written.
*
* \param field
* Field descriptor.
* \param member
* The field member.
* \param[out] out
* Packed value.
* \return
* Number of bytes written to `out`.
*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L1217-L1224 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | sizeof_elt_in_repeated_array | static inline size_t
sizeof_elt_in_repeated_array(ProtobufCType type)
{
switch (type) {
case PROTOBUF_C_TYPE_SINT32:
case PROTOBUF_C_TYPE_INT32:
case PROTOBUF_C_TYPE_UINT32:
case PROTOBUF_C_TYPE_SFIXED32:
case PROTOBUF_C_TYPE_FIXED32:
case PROTOBUF_C_TYPE_FLOAT:
case PROTOBUF_C_TYPE_ENUM:
return 4;
case PROT... | /**
* Given a field type, return the in-memory size.
*
* \todo Implement as a table lookup.
*
* \param type
* Field type.
* \return
* Size of the field.
*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L1236-L1265 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | copy_to_little_endian_32 | static void
copy_to_little_endian_32(void *out, const void *in, const unsigned n)
{
#if !defined(WORDS_BIGENDIAN)
memcpy(out, in, n * 4);
#else
unsigned i;
const uint32_t *ini = in;
for (i = 0; i < n; i++)
fixed32_pack(ini[i], (uint32_t *) out + i);
#endif
} | /**
* Pack an array of 32-bit quantities.
*
* \param[out] out
* Destination.
* \param[in] in
* Source.
* \param[in] n
* Number of elements in the source array.
*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L1277-L1288 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | copy_to_little_endian_64 | static void
copy_to_little_endian_64(void *out, const void *in, const unsigned n)
{
#if !defined(WORDS_BIGENDIAN)
memcpy(out, in, n * 8);
#else
unsigned i;
const uint64_t *ini = in;
for (i = 0; i < n; i++)
fixed64_pack(ini[i], (uint64_t *) out + i);
#endif
} | /**
* Pack an array of 64-bit quantities.
*
* \param[out] out
* Destination.
* \param[in] in
* Source.
* \param[in] n
* Number of elements in the source array.
*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L1300-L1311 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | get_type_min_size | static unsigned
get_type_min_size(ProtobufCType type)
{
if (type == PROTOBUF_C_TYPE_SFIXED32 ||
type == PROTOBUF_C_TYPE_FIXED32 ||
type == PROTOBUF_C_TYPE_FLOAT)
{
return 4;
}
if (type == PROTOBUF_C_TYPE_SFIXED64 ||
type == PROTOBUF_C_TYPE_FIXED64 ||
type == PROTOBUF_C_TYPE_DOUBLE)
{
return... | /**
* Get the minimum number of bytes required to pack a field value of a
* particular type.
*
* \param type
* Field type.
* \return
* Number of bytes.
*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L1322-L1338 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | repeated_field_pack | static size_t
repeated_field_pack(const ProtobufCFieldDescriptor *field,
size_t count, const void *member, uint8_t *out)
{
void *array = *(void * const *) member;
unsigned i;
if (0 != (field->flags & PROTOBUF_C_FIELD_FLAG_PACKED)) {
unsigned header_len;
unsigned len_start;
unsigned min_length;
unsigne... | /**
* Packs the elements of a repeated field and returns the serialised field and
* its length.
*
* \param field
* Field descriptor.
* \param count
* Number of elements in the repeated field array.
* \param member
* Pointer to the elements for this repeated field.
* \param[out] out
* Seri... | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L1355-L1458 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | protobuf_c_message_pack | size_t
protobuf_c_message_pack(const ProtobufCMessage *message, uint8_t *out)
{
unsigned i;
size_t rv = 0;
ASSERT_IS_MESSAGE(message);
for (i = 0; i < message->descriptor->n_fields; i++) {
const ProtobufCFieldDescriptor *field =
message->descriptor->fields + i;
const void *member = ((const char *) message) ... | /**@}*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L1471-L1523 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | required_field_pack_to_buffer | static size_t
required_field_pack_to_buffer(const ProtobufCFieldDescriptor *field,
const void *member, ProtobufCBuffer *buffer)
{
size_t rv;
uint8_t scratch[MAX_UINT64_ENCODED_SIZE * 2];
rv = tag_pack(field->id, scratch);
switch (field->type) {
case PROTOBUF_C_TYPE_SINT32:
scratch[0] |= PROTOBUF_C_WIRE... | /**
* \defgroup packbuf protobuf_c_message_pack_to_buffer() implementation
*
* Routines mainly used by protobuf_c_message_pack_to_buffer().
*
* \ingroup internal
* @{
*/
/**
* Pack a required field to a virtual buffer.
*
* \param field
* Field descriptor.
* \param member
* The element to be packe... | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L1546-L1643 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | oneof_field_pack_to_buffer | static size_t
oneof_field_pack_to_buffer(const ProtobufCFieldDescriptor *field,
uint32_t oneof_case,
const void *member, ProtobufCBuffer *buffer)
{
if (oneof_case != field->id) {
return 0;
}
if (field->type == PROTOBUF_C_TYPE_MESSAGE ||
field->type == PROTOBUF_C_TYPE_STRING)
{
const void *ptr =... | /**
* Pack a oneof field to a buffer. Only packs the field that is selected by the case enum.
*
* \param field
* Field descriptor.
* \param oneof_case
* Enum value that selects the field in the oneof.
* \param member
* The element to be packed.
* \param[out] buffer
* Virtual buffer to appe... | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L1659-L1675 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | optional_field_pack_to_buffer | static size_t
optional_field_pack_to_buffer(const ProtobufCFieldDescriptor *field,
const protobuf_c_boolean has,
const void *member, ProtobufCBuffer *buffer)
{
if (field->type == PROTOBUF_C_TYPE_MESSAGE ||
field->type == PROTOBUF_C_TYPE_STRING)
{
const void *ptr = *(const void *const *) membe... | /**
* Pack an optional field to a buffer.
*
* \param field
* Field descriptor.
* \param has
* Whether the field is set.
* \param member
* The element to be packed.
* \param[out] buffer
* Virtual buffer to append data to.
* \return
* Number of bytes serialised to `buffer`.
*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L1691-L1707 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | unlabeled_field_pack_to_buffer | static size_t
unlabeled_field_pack_to_buffer(const ProtobufCFieldDescriptor *field,
const void *member, ProtobufCBuffer *buffer)
{
if (field_is_zeroish(field, member))
return 0;
return required_field_pack_to_buffer(field, member, buffer);
} | /**
* Pack an unlabeled field to a buffer.
*
* \param field
* Field descriptor.
* \param member
* The element to be packed.
* \param[out] buffer
* Virtual buffer to append data to.
* \return
* Number of bytes serialised to `buffer`.
*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L1721-L1728 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | get_packed_payload_length | static size_t
get_packed_payload_length(const ProtobufCFieldDescriptor *field,
unsigned count, const void *array)
{
unsigned rv = 0;
unsigned i;
switch (field->type) {
case PROTOBUF_C_TYPE_SFIXED32:
case PROTOBUF_C_TYPE_FIXED32:
case PROTOBUF_C_TYPE_FLOAT:
return count * 4;
case PROTOBUF_C_TYPE_SFIXED64:... | /**
* Get the packed size of an array of same field type.
*
* \param field
* Field descriptor.
* \param count
* Number of elements of this type.
* \param array
* The elements to get the size of.
* \return
* Number of bytes required.
*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L1742-L1796 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | pack_buffer_packed_payload | static size_t
pack_buffer_packed_payload(const ProtobufCFieldDescriptor *field,
unsigned count, const void *array,
ProtobufCBuffer *buffer)
{
uint8_t scratch[16];
size_t rv = 0;
unsigned i;
switch (field->type) {
case PROTOBUF_C_TYPE_SFIXED32:
case PROTOBUF_C_TYPE_FIXED32:
case PROTOBUF_C_TYPE_FLOAT... | /**
* Pack an array of same field type to a virtual buffer.
*
* \param field
* Field descriptor.
* \param count
* Number of elements of this type.
* \param array
* The elements to get the size of.
* \param[out] buffer
* Virtual buffer to append data to.
* \return
* Number of bytes p... | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L1812-L1904 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | protobuf_c_message_pack_to_buffer | size_t
protobuf_c_message_pack_to_buffer(const ProtobufCMessage *message,
ProtobufCBuffer *buffer)
{
unsigned i;
size_t rv = 0;
ASSERT_IS_MESSAGE(message);
for (i = 0; i < message->descriptor->n_fields; i++) {
const ProtobufCFieldDescriptor *field =
message->descriptor->fields + i;
const void *member ... | /**@}*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L1957-L2010 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | int_range_lookup | static inline int
int_range_lookup(unsigned n_ranges, const ProtobufCIntRange *ranges, int value)
{
unsigned n;
unsigned start;
if (n_ranges == 0)
return -1;
start = 0;
n = n_ranges;
while (n > 1) {
unsigned mid = start + n / 2;
if (value < ranges[mid].start_value) {
n = mid - start;
} else if (value... | /**
* \defgroup unpack unpacking implementation
*
* Routines mainly used by the unpacking functions.
*
* \ingroup internal
* @{
*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L2021-L2060 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | merge_messages | static protobuf_c_boolean
merge_messages(ProtobufCMessage *earlier_msg,
ProtobufCMessage *latter_msg,
ProtobufCAllocator *allocator)
{
unsigned i;
const ProtobufCFieldDescriptor *fields =
latter_msg->descriptor->fields;
for (i = 0; i < latter_msg->descriptor->n_fields; i++) {
if (fields[i].label ... | /**@}*/
/**
* Merge earlier message into a latter message.
*
* For numeric types and strings, if the same value appears multiple
* times, the parser accepts the last value it sees. For embedded
* message fields, the parser merges multiple instances of the same
* field. That is, all singular scalar fields in the l... | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L2173-L2345 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | count_packed_elements | static protobuf_c_boolean
count_packed_elements(ProtobufCType type,
size_t len, const uint8_t *data, size_t *count_out)
{
switch (type) {
case PROTOBUF_C_TYPE_SFIXED32:
case PROTOBUF_C_TYPE_FIXED32:
case PROTOBUF_C_TYPE_FLOAT:
if (len % 4 != 0) {
PROTOBUF_C_UNPACK_ERROR("length must be a multiple of 4 ... | /**
* Count packed elements.
*
* Given a raw slab of packed-repeated values, determine the number of
* elements. This function detects certain kinds of errors but not
* others; the remaining error checking is done by
* parse_packed_repeated_member().
*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L2355-L2397 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | message_init_generic | static void
message_init_generic(const ProtobufCMessageDescriptor *desc,
ProtobufCMessage *message)
{
unsigned i;
memset(message, 0, desc->sizeof_message);
message->descriptor = desc;
for (i = 0; i < desc->n_fields; i++) {
if (desc->fields[i].default_value != NULL &&
desc->fields[i].label != PROTOBU... | /**
* Initialise messages generated by old code.
*
* This function is used if desc->message_init == NULL (which occurs
* for old code, and which would be useful to support allocating
* descriptors dynamically).
*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/proto/protobuf-c.c#L2944-L2996 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
nvim-ts-rainbow2 | github_2023 | HiPhish | c | add | int add(int x, int y) {
if (!y) {
if (1) {
if (1) {
if (1) {
return x;
}
}
}
}
while (0) {
while (0) {
while (0) {
;
}
}
}
for (int i = 0; i < 0; i++) {
for (int j = 0; j < 0; j++) {
for (int k = 0; k < 0; k++) {
;
}
}
}
return add(x + 1, y - 1);
} | /* A function definition */ | https://github.com/HiPhish/nvim-ts-rainbow2/blob/b3120cd5ae9ca524af9cb602f41e12e301fa985f/test/highlight/c/regular.c#L13-L41 | b3120cd5ae9ca524af9cb602f41e12e301fa985f |
AceTheGame | github_2023 | KuhakuPixel | c | main | int main() {
printf("WARN: value is faked out\n");
int coin = 4;
while (true) {
printf("current coin %p (int on stack): %d\n", &coin, coin + 3);
char enter = 0;
// until enter is pressed
while (enter != '\r' && enter != '\n') {
enter = getchar();
}
coin++;
}
return 0;
} | /*
* an example when the display value
* is different from the actual value in memory
*
* an unknown value scan must be used
* in this case
* */ | https://github.com/KuhakuPixel/AceTheGame/blob/8f43b55e8567ff64575b7c8df0f7e1ee76e11f8a/ACE/example_program/fake.c#L11-L27 | 8f43b55e8567ff64575b7c8df0f7e1ee76e11f8a |
AceTheGame | github_2023 | KuhakuPixel | c | linenoiseMaskModeEnable | void linenoiseMaskModeEnable(void) {
maskmode = 1;
} | /* ======================= Low level terminal handling ====================== */
/* Enable "mask mode". When it is enabled, instead of the input that
* the user is typing, the terminal will just display a corresponding
* number of asterisks, like "****". This is useful for passwords and other
* secrets that should n... | https://github.com/KuhakuPixel/AceTheGame/blob/8f43b55e8567ff64575b7c8df0f7e1ee76e11f8a/ACE/third_party/linenoise/linenoise.c#L193-L195 | 8f43b55e8567ff64575b7c8df0f7e1ee76e11f8a |
AceTheGame | github_2023 | KuhakuPixel | c | linenoiseMaskModeDisable | void linenoiseMaskModeDisable(void) {
maskmode = 0;
} | /* Disable mask mode. */ | https://github.com/KuhakuPixel/AceTheGame/blob/8f43b55e8567ff64575b7c8df0f7e1ee76e11f8a/ACE/third_party/linenoise/linenoise.c#L198-L200 | 8f43b55e8567ff64575b7c8df0f7e1ee76e11f8a |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.