Skip to content

Commit

Permalink
Add support for OpenStep plist format
Browse files Browse the repository at this point in the history
  • Loading branch information
nikias committed Jan 8, 2023
1 parent 3f9360e commit 60d2919
Show file tree
Hide file tree
Showing 18 changed files with 1,322 additions and 45 deletions.
8 changes: 6 additions & 2 deletions docs/plistutil.1
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@ filename, plistutil will read from stdin.
Output FILE to convert to. If this argument is omitted or - is passed as
filename, plistutil will write to stdout.
.TP
.B \-f, \-\-format [bin|xml|json]
.B \-f, \-\-format [bin|xml|json|openstep]
Force output format, regardless of input type. This is useful if the input
format is not known, but the output format should always be in a specific
format (like xml or json).

If omitted, XML plist data will be converted to binary and vice-versa. To
convert to/from JSON the output format needs to specified.
convert to/from JSON or OpenStep the output format needs to specified.
.TP
.B \-c, \-\-compact
JSON and OpenStep only: Print output in compact form. By default, the output
will be pretty-printed.
.TP
.B \-h, \-\-help
Prints usage information.
Expand Down
24 changes: 24 additions & 0 deletions include/plist/plist.h
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,20 @@ extern "C"
*/
plist_err_t plist_to_json(plist_t plist, char **plist_json, uint32_t* length, int prettify);

/**
* Export the #plist_t structure to OpenStep format.
*
* @param plist the root node to export
* @param plist_openstep a pointer to a char* buffer. This function allocates the memory,
* caller is responsible for freeing it.
* @param length a pointer to an uint32_t variable. Represents the length of the allocated buffer.
* @param prettify pretty print the output if != 0
* @return PLIST_ERR_SUCCESS on success or a #plist_err_t on failure
* @note Use plist_mem_free() to free the allocated memory.
*/
plist_err_t plist_to_openstep(plist_t plist, char **plist_openstep, uint32_t* length, int prettify);


/**
* Import the #plist_t structure from XML format.
*
Expand Down Expand Up @@ -727,6 +741,16 @@ extern "C"
*/
plist_err_t plist_from_json(const char *json, uint32_t length, plist_t * plist);

/**
* Import the #plist_t structure from OpenStep plist format.
*
* @param openstep a pointer to the OpenStep plist buffer.
* @param length length of the buffer to read.
* @param plist a pointer to the imported plist.
* @return PLIST_ERR_SUCCESS on success or a #plist_err_t on failure
*/
plist_err_t plist_from_openstep(const char *openstep, uint32_t length, plist_t * plist);

/**
* Import the #plist_t structure from memory data.
* This method will look at the first bytes of plist_data
Expand Down
1 change: 1 addition & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ libplist_2_0_la_SOURCES = \
bplist.c \
jsmn.c jsmn.h \
jplist.c \
oplist.c \
plist.c plist.h

libplist___2_0_la_LIBADD = libplist-2.0.la
Expand Down
Loading

0 comments on commit 60d2919

Please sign in to comment.