Squashed 'third_party/rawrtc/rawrtc-common/' content from commit aff7a3a3b

Change-Id: I2cb019410e8d0e1e0bf814577b0ef83aeb32c7fd
git-subtree-dir: third_party/rawrtc/rawrtc-common
git-subtree-split: aff7a3a3b9bbf49f7d2fc8b123edd301825b3e1c
diff --git a/include/rawrtcc/code.h b/include/rawrtcc/code.h
new file mode 100644
index 0000000..08051e7
--- /dev/null
+++ b/include/rawrtcc/code.h
@@ -0,0 +1,64 @@
+#pragma once
+
+/// Return codes.
+///
+/// To make it easy to test for errors, the *success* return code's
+/// value will always be `0`. Therefore, you can test for errors
+/// in the following way:
+///
+///     enum rawrtc_code const error = rawrtc_some_function();
+///     if (error) {
+///        // Handle the error...
+///     }
+///
+/// **Important**: Add translations for new return codes in
+/// `utils/utils.c`!
+enum rawrtc_code {
+    /// An unknown (or non-translatable) error occurred.
+    RAWRTC_CODE_UNKNOWN_ERROR = -2,
+    /// The necessary functionality has not been implemented.
+    RAWRTC_CODE_NOT_IMPLEMENTED = -1,
+    /// Success! Nothing went wrong - you're fine to proceed.
+    RAWRTC_CODE_SUCCESS = 0,
+    /// Initialisation failed.
+    RAWRTC_CODE_INITIALISE_FAIL,
+    /// Invalid argument.
+    RAWRTC_CODE_INVALID_ARGUMENT,
+    /// Memory could not be allocated.
+    RAWRTC_CODE_NO_MEMORY,
+    /// Invalid state.
+    RAWRTC_CODE_INVALID_STATE,
+    /// Unsupported protocol.
+    RAWRTC_CODE_UNSUPPORTED_PROTOCOL,
+    /// Unsupported algorithm.
+    RAWRTC_CODE_UNSUPPORTED_ALGORITHM,
+    /// No value has been set.
+    /// @note This is often used for functions that change the value of
+    ///       a variable declared outside of the function to indicate
+    ///       that no change occurred.
+    RAWRTC_CODE_NO_VALUE,
+    /// Socket could not be found.
+    RAWRTC_CODE_NO_SOCKET,
+    /// Invalid certificate.
+    RAWRTC_CODE_INVALID_CERTIFICATE,
+    /// Invalid fingerprint.
+    RAWRTC_CODE_INVALID_FINGERPRINT,
+    /// Insufficient space.
+    RAWRTC_CODE_INSUFFICIENT_SPACE,
+    /// Target is still being used.
+    RAWRTC_CODE_STILL_IN_USE,
+    /// Invalid message.
+    RAWRTC_CODE_INVALID_MESSAGE,
+    /// Message is too long.
+    RAWRTC_CODE_MESSAGE_TOO_LONG,
+    /// Try again later.
+    /// @note This is semantically equivalent to `EAGAIN` and
+    ///       `EWOULDBLOCK`.
+    RAWRTC_CODE_TRY_AGAIN_LATER,
+    /// Stopped iterating (early).
+    RAWRTC_CODE_STOP_ITERATION,
+    /// Operation not permitted.
+    RAWRTC_CODE_NOT_PERMITTED,
+    /// An external function returned an error.
+    RAWRTC_CODE_EXTERNAL_ERROR,
+};