pnoltes opened a new issue, #612:
URL: https://github.com/apache/celix/issues/612

   # Netstring lib
   
   A netstring lib in C which can be used to encode/decode 
(serializer/deserialize) properties and/or metadata for remote service data and 
events for the - yet to be implemented - event admin.
   
   # Background
   
   > In [computer 
programming](https://en.wikipedia.org/wiki/Computer_programming), a netstring 
is a formatting method for [byte 
strings](https://en.wikipedia.org/wiki/String_(computer_science)) that uses a 
declarative notation to indicate the size of the 
string.[[1]](https://en.wikipedia.org/wiki/Netstring#cite_note-1)[[2]](https://en.wikipedia.org/wiki/Netstring#cite_note-2)
   
   > Netstrings store the byte length of the data that follows, making it 
easier to unambiguously pass text and byte data between programs that could be 
sensitive to values that could be interpreted as 
[delimiters](https://en.wikipedia.org/wiki/Delimiter) or terminators (such as a 
[null character](https://en.wikipedia.org/wiki/Null_character)).
   
   > The format consists of the string's length written using ASCII digits, 
followed by a colon, the byte data, and a comma. "Length" in this context means 
"number of 8-bit units", so if the string is, for example, encoded using 
[UTF-8](https://en.wikipedia.org/wiki/UTF-8), this may or may not be identical 
to the number of textual characters that are present in the string.
   
   Source: https://en.wikipedia.org/wiki/Netstring
   
   # Implementation hints
   
   Use the  implementation in 
https://github.com/apache/celix/blob/master/bundles/pubsub/pubsub_protocol/pubsub_protocol_lib/src/pubsub_wire_protocol_common.c
 (`pubsubProtocol_addNetstringEntryToBuffer` and 
`pubsubProtocol_parseNetstring`) as a basis for the netstring lib. 
   
   Place the implementation in `libs/netstring` and ensure that the lib name is 
`celix_netstring`. The lib should depend on `Celix::utils` and use the 
`celix_err` implementation to report error message 
(https://github.com/apache/celix/blob/master/libs/utils/include/celix_err.h). 
   
   The `celix_status_t` should be extended with a netstring facility and 
`CELIX_CUSTOMER_ERROR_MAKE` using celix_errno.h 
(https://github.com/apache/celix/blob/rel/celix-2.3.0/libs/utils/include/celix_errno.h)
   
   A possible api could be:
   ```C
   //celix_netstring.h
   
   #define CELIX_FACILITY_NETSTRING   3 //maybe add to celix_errno.h
   
   #define CELIX_NETSTRING_ERROR_TOO_LONG  
CELIX_ERROR_MAKE(CELIX_FACILITY_NETSTRING, 1)
   #define CELIX_NETSTRING_ERROR_NO_COLON  
CELIX_ERROR_MAKE(CELIX_FACILITY_NETSTRING, 2)
   //rest of netstring error codes
   
   celix_status_t celix_netstring_encode(const char* string, FILE* 
netstringOutput);
   
   celix_status_t celix_netstring_decode(FILE* netstringInput, char** 
stringResult);
   
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@celix.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to