+/**
+ * Free a port configuration structure.
+ *
+ * @param[in] config Pointer to a configuration structure. Must not be NULL.
+ *
+ * @since 0.1.0
+ */
+void sp_free_config(struct sp_port_config *config);
+
+/**
+ * Get the current configuration of the specified serial port.
+ *
+ * The user should allocate a configuration structure using sp_new_config()
+ * and pass this as the config parameter. The configuration structure will
+ * be updated with the port configuration.
+ *
+ * Any parameters that are configured with settings not recognised or
+ * supported by libserialport, will be set to special values that are
+ * ignored by sp_set_config().
+ *
+ * @param[in] port Pointer to a port structure. Must not be NULL.
+ * @param[out] config Pointer to a configuration structure that will hold
+ * the result. Upon errors the contents of the config
+ * struct will not be changed. Must not be NULL.
+ *
+ * @return SP_OK upon success, a negative error code otherwise.
+ *
+ * @since 0.1.0
+ */
+enum sp_return sp_get_config(struct sp_port *port, struct sp_port_config *config);
+
+/**
+ * Set the configuration for the specified serial port.
+ *
+ * For each parameter in the configuration, there is a special value (usually
+ * -1, but see the documentation for each field). These values will be ignored
+ * and the corresponding setting left unchanged on the port.
+ *
+ * Upon errors, the configuration of the serial port is unknown since
+ * partial/incomplete config updates may have happened.
+ *
+ * @param[in] port Pointer to a port structure. Must not be NULL.
+ * @param[in] config Pointer to a configuration structure. Must not be NULL.
+ *
+ * @return SP_OK upon success, a negative error code otherwise.
+ *
+ * @since 0.1.0
+ */
+enum sp_return sp_set_config(struct sp_port *port, const struct sp_port_config *config);
+
+/**
+ * Set the baud rate for the specified serial port.
+ *
+ * @param[in] port Pointer to a port structure. Must not be NULL.
+ * @param[in] baudrate Baud rate in bits per second.
+ *
+ * @return SP_OK upon success, a negative error code otherwise.
+ *
+ * @since 0.1.0
+ */
+enum sp_return sp_set_baudrate(struct sp_port *port, int baudrate);
+
+/**
+ * Get the baud rate from a port configuration.
+ *
+ * The user should allocate a variable of type int and
+ * pass a pointer to this to receive the result.
+ *
+ * @param[in] config Pointer to a configuration structure. Must not be NULL.
+ * @param[out] baudrate_ptr Pointer to a variable to store the result. Must not be NULL.
+ *
+ * @return SP_OK upon success, a negative error code otherwise.
+ *
+ * @since 0.1.0
+ */
+enum sp_return sp_get_config_baudrate(const struct sp_port_config *config, int *baudrate_ptr);
+
+/**
+ * Set the baud rate in a port configuration.
+ *
+ * @param[in] config Pointer to a configuration structure. Must not be NULL.
+ * @param[in] baudrate Baud rate in bits per second, or -1 to retain the current setting.
+ *
+ * @return SP_OK upon success, a negative error code otherwise.
+ *
+ * @since 0.1.0
+ */
+enum sp_return sp_set_config_baudrate(struct sp_port_config *config, int baudrate);
+
+/**
+ * Set the data bits for the specified serial port.
+ *
+ * @param[in] port Pointer to a port structure. Must not be NULL.
+ * @param[in] bits Number of data bits.
+ *
+ * @return SP_OK upon success, a negative error code otherwise.
+ *
+ * @since 0.1.0
+ */
+enum sp_return sp_set_bits(struct sp_port *port, int bits);
+
+/**
+ * Get the data bits from a port configuration.
+ *
+ * The user should allocate a variable of type int and
+ * pass a pointer to this to receive the result.
+ *
+ * @param[in] config Pointer to a configuration structure. Must not be NULL.
+ * @param[out] bits_ptr Pointer to a variable to store the result. Must not be NULL.
+ *
+ * @return SP_OK upon success, a negative error code otherwise.
+ *
+ * @since 0.1.0
+ */
+enum sp_return sp_get_config_bits(const struct sp_port_config *config, int *bits_ptr);
+
+/**
+ * Set the data bits in a port configuration.
+ *
+ * @param[in] config Pointer to a configuration structure. Must not be NULL.
+ * @param[in] bits Number of data bits, or -1 to retain the current setting.
+ *
+ * @return SP_OK upon success, a negative error code otherwise.
+ *
+ * @since 0.1.0
+ */
+enum sp_return sp_set_config_bits(struct sp_port_config *config, int bits);
+
+/**
+ * Set the parity setting for the specified serial port.
+ *
+ * @param[in] port Pointer to a port structure. Must not be NULL.
+ * @param[in] parity Parity setting.
+ *
+ * @return SP_OK upon success, a negative error code otherwise.
+ *
+ * @since 0.1.0
+ */
+enum sp_return sp_set_parity(struct sp_port *port, enum sp_parity parity);
+
+/**
+ * Get the parity setting from a port configuration.
+ *
+ * The user should allocate a variable of type enum sp_parity and
+ * pass a pointer to this to receive the result.
+ *
+ * @param[in] config Pointer to a configuration structure. Must not be NULL.
+ * @param[out] parity_ptr Pointer to a variable to store the result. Must not be NULL.
+ *
+ * @return SP_OK upon success, a negative error code otherwise.
+ *
+ * @since 0.1.0
+ */
+enum sp_return sp_get_config_parity(const struct sp_port_config *config, enum sp_parity *parity_ptr);
+
+/**
+ * Set the parity setting in a port configuration.
+ *
+ * @param[in] config Pointer to a configuration structure. Must not be NULL.
+ * @param[in] parity Parity setting, or -1 to retain the current setting.
+ *
+ * @return SP_OK upon success, a negative error code otherwise.
+ *
+ * @since 0.1.0
+ */
+enum sp_return sp_set_config_parity(struct sp_port_config *config, enum sp_parity parity);
+
+/**
+ * Set the stop bits for the specified serial port.
+ *
+ * @param[in] port Pointer to a port structure. Must not be NULL.
+ * @param[in] stopbits Number of stop bits.
+ *
+ * @return SP_OK upon success, a negative error code otherwise.
+ *
+ * @since 0.1.0
+ */
+enum sp_return sp_set_stopbits(struct sp_port *port, int stopbits);
+
+/**
+ * Get the stop bits from a port configuration.
+ *
+ * The user should allocate a variable of type int and
+ * pass a pointer to this to receive the result.
+ *
+ * @param[in] config Pointer to a configuration structure. Must not be NULL.
+ * @param[out] stopbits_ptr Pointer to a variable to store the result. Must not be NULL.
+ *
+ * @return SP_OK upon success, a negative error code otherwise.
+ *
+ * @since 0.1.0
+ */
+enum sp_return sp_get_config_stopbits(const struct sp_port_config *config, int *stopbits_ptr);
+
+/**
+ * Set the stop bits in a port configuration.
+ *
+ * @param[in] config Pointer to a configuration structure. Must not be NULL.
+ * @param[in] stopbits Number of stop bits, or -1 to retain the current setting.
+ *
+ * @return SP_OK upon success, a negative error code otherwise.
+ *
+ * @since 0.1.0
+ */
+enum sp_return sp_set_config_stopbits(struct sp_port_config *config, int stopbits);
+
+/**
+ * Set the RTS pin behaviour for the specified serial port.
+ *
+ * @param[in] port Pointer to a port structure. Must not be NULL.
+ * @param[in] rts RTS pin mode.
+ *
+ * @return SP_OK upon success, a negative error code otherwise.
+ *
+ * @since 0.1.0
+ */
+enum sp_return sp_set_rts(struct sp_port *port, enum sp_rts rts);
+
+/**
+ * Get the RTS pin behaviour from a port configuration.
+ *
+ * The user should allocate a variable of type enum sp_rts and
+ * pass a pointer to this to receive the result.
+ *
+ * @param[in] config Pointer to a configuration structure. Must not be NULL.
+ * @param[out] rts_ptr Pointer to a variable to store the result. Must not be NULL.
+ *
+ * @return SP_OK upon success, a negative error code otherwise.
+ *
+ * @since 0.1.0
+ */
+enum sp_return sp_get_config_rts(const struct sp_port_config *config, enum sp_rts *rts_ptr);
+
+/**
+ * Set the RTS pin behaviour in a port configuration.
+ *
+ * @param[in] config Pointer to a configuration structure. Must not be NULL.
+ * @param[in] rts RTS pin mode, or -1 to retain the current setting.
+ *
+ * @return SP_OK upon success, a negative error code otherwise.
+ *
+ * @since 0.1.0
+ */
+enum sp_return sp_set_config_rts(struct sp_port_config *config, enum sp_rts rts);
+
+/**
+ * Set the CTS pin behaviour for the specified serial port.
+ *
+ * @param[in] port Pointer to a port structure. Must not be NULL.
+ * @param[in] cts CTS pin mode.
+ *
+ * @return SP_OK upon success, a negative error code otherwise.
+ *
+ * @since 0.1.0
+ */
+enum sp_return sp_set_cts(struct sp_port *port, enum sp_cts cts);
+
+/**
+ * Get the CTS pin behaviour from a port configuration.
+ *
+ * The user should allocate a variable of type enum sp_cts and
+ * pass a pointer to this to receive the result.
+ *
+ * @param[in] config Pointer to a configuration structure. Must not be NULL.
+ * @param[out] cts_ptr Pointer to a variable to store the result. Must not be NULL.
+ *
+ * @return SP_OK upon success, a negative error code otherwise.
+ *
+ * @since 0.1.0
+ */
+enum sp_return sp_get_config_cts(const struct sp_port_config *config, enum sp_cts *cts_ptr);
+
+/**
+ * Set the CTS pin behaviour in a port configuration.
+ *
+ * @param[in] config Pointer to a configuration structure. Must not be NULL.
+ * @param[in] cts CTS pin mode, or -1 to retain the current setting.
+ *
+ * @return SP_OK upon success, a negative error code otherwise.
+ *
+ * @since 0.1.0
+ */
+enum sp_return sp_set_config_cts(struct sp_port_config *config, enum sp_cts cts);
+
+/**
+ * Set the DTR pin behaviour for the specified serial port.
+ *
+ * @param[in] port Pointer to a port structure. Must not be NULL.
+ * @param[in] dtr DTR pin mode.
+ *
+ * @return SP_OK upon success, a negative error code otherwise.
+ *
+ * @since 0.1.0
+ */
+enum sp_return sp_set_dtr(struct sp_port *port, enum sp_dtr dtr);
+
+/**
+ * Get the DTR pin behaviour from a port configuration.
+ *
+ * The user should allocate a variable of type enum sp_dtr and
+ * pass a pointer to this to receive the result.
+ *
+ * @param[in] config Pointer to a configuration structure. Must not be NULL.
+ * @param[out] dtr_ptr Pointer to a variable to store the result. Must not be NULL.
+ *
+ * @return SP_OK upon success, a negative error code otherwise.
+ *
+ * @since 0.1.0
+ */
+enum sp_return sp_get_config_dtr(const struct sp_port_config *config, enum sp_dtr *dtr_ptr);
+
+/**
+ * Set the DTR pin behaviour in a port configuration.
+ *
+ * @param[in] config Pointer to a configuration structure. Must not be NULL.
+ * @param[in] dtr DTR pin mode, or -1 to retain the current setting.
+ *
+ * @return SP_OK upon success, a negative error code otherwise.
+ *
+ * @since 0.1.0
+ */
+enum sp_return sp_set_config_dtr(struct sp_port_config *config, enum sp_dtr dtr);
+
+/**
+ * Set the DSR pin behaviour for the specified serial port.
+ *
+ * @param[in] port Pointer to a port structure. Must not be NULL.
+ * @param[in] dsr DSR pin mode.
+ *
+ * @return SP_OK upon success, a negative error code otherwise.
+ *
+ * @since 0.1.0
+ */