chromium/third_party/grpc/src/third_party/upb/upb/json_decode.c

/*
 * Copyright (c) 2009-2021, Google LLC
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of Google LLC nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "upb/json_decode.h"

#include <errno.h>
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <math.h>
#include <setjmp.h>
#include <stdlib.h>
#include <string.h>

#include "upb/encode.h"
#include "upb/reflection.h"

/* Special header, must be included last. */
#include "upb/port_def.inc"

jsondec;

enum {};

/* Forward declarations of mutually-recursive functions. */
static void jsondec_wellknown(jsondec* d, upb_Message* msg,
                              const upb_MessageDef* m);
static upb_MessageValue jsondec_value(jsondec* d, const upb_FieldDef* f);
static void jsondec_wellknownvalue(jsondec* d, upb_Message* msg,
                                   const upb_MessageDef* m);
static void jsondec_object(jsondec* d, upb_Message* msg,
                           const upb_MessageDef* m);

static bool jsondec_streql(upb_StringView str, const char* lit) {}

static bool jsondec_isnullvalue(const upb_FieldDef* f) {}

static bool jsondec_isvalue(const upb_FieldDef* f) {}

UPB_NORETURN static void jsondec_err(jsondec* d, const char* msg) {}

UPB_PRINTF(2, 3)
UPB_NORETURN static void jsondec_errf(jsondec* d, const char* fmt, ...) {}

static void jsondec_skipws(jsondec* d) {}

static bool jsondec_tryparsech(jsondec* d, char ch) {}

static void jsondec_parselit(jsondec* d, const char* lit) {}

static void jsondec_wsch(jsondec* d, char ch) {}

static void jsondec_true(jsondec* d) {}
static void jsondec_false(jsondec* d) {}
static void jsondec_null(jsondec* d) {}

static void jsondec_entrysep(jsondec* d) {}

static int jsondec_rawpeek(jsondec* d) {}

/* JSON object/array **********************************************************/

/* These are used like so:
 *
 * jsondec_objstart(d);
 * while (jsondec_objnext(d)) {
 *   ...
 * }
 * jsondec_objend(d) */

static int jsondec_peek(jsondec* d) {}

static void jsondec_push(jsondec* d) {}

static bool jsondec_seqnext(jsondec* d, char end_ch) {}

static void jsondec_arrstart(jsondec* d) {}

static void jsondec_arrend(jsondec* d) {}

static bool jsondec_arrnext(jsondec* d) {}

static void jsondec_objstart(jsondec* d) {}

static void jsondec_objend(jsondec* d) {}

static bool jsondec_objnext(jsondec* d) {}

/* JSON number ****************************************************************/

static bool jsondec_tryskipdigits(jsondec* d) {}

static void jsondec_skipdigits(jsondec* d) {}

static double jsondec_number(jsondec* d) {}

/* JSON string ****************************************************************/

static char jsondec_escape(jsondec* d) {}

static uint32_t jsondec_codepoint(jsondec* d) {}

/* Parses a \uXXXX unicode escape (possibly a surrogate pair). */
static size_t jsondec_unicode(jsondec* d, char* out) {}

static void jsondec_resize(jsondec* d, char** buf, char** end, char** buf_end) {}

static upb_StringView jsondec_string(jsondec* d) {}

static void jsondec_skipval(jsondec* d) {}

/* Base64 decoding for bytes fields. ******************************************/

static unsigned int jsondec_base64_tablelookup(const char ch) {}

static char* jsondec_partialbase64(jsondec* d, const char* ptr, const char* end,
                                   char* out) {}

static size_t jsondec_base64(jsondec* d, upb_StringView str) {}

/* Low-level integer parsing **************************************************/

/* We use these hand-written routines instead of strto[u]l() because the "long
 * long" variants aren't in c89. Also our version allows setting a ptr limit. */

static const char* jsondec_buftouint64(jsondec* d, const char* ptr,
                                       const char* end, uint64_t* val) {}

static const char* jsondec_buftoint64(jsondec* d, const char* ptr,
                                      const char* end, int64_t* val) {}

static uint64_t jsondec_strtouint64(jsondec* d, upb_StringView str) {}

static int64_t jsondec_strtoint64(jsondec* d, upb_StringView str) {}

/* Primitive value types ******************************************************/

/* Parse INT32 or INT64 value. */
static upb_MessageValue jsondec_int(jsondec* d, const upb_FieldDef* f) {}

/* Parse UINT32 or UINT64 value. */
static upb_MessageValue jsondec_uint(jsondec* d, const upb_FieldDef* f) {}

/* Parse DOUBLE or FLOAT value. */
static upb_MessageValue jsondec_double(jsondec* d, const upb_FieldDef* f) {}

/* Parse STRING or BYTES value. */
static upb_MessageValue jsondec_strfield(jsondec* d, const upb_FieldDef* f) {}

static upb_MessageValue jsondec_enum(jsondec* d, const upb_FieldDef* f) {}

static upb_MessageValue jsondec_bool(jsondec* d, const upb_FieldDef* f) {}

/* Composite types (array/message/map) ****************************************/

static void jsondec_array(jsondec* d, upb_Message* msg, const upb_FieldDef* f) {}

static void jsondec_map(jsondec* d, upb_Message* msg, const upb_FieldDef* f) {}

static void jsondec_tomsg(jsondec* d, upb_Message* msg,
                          const upb_MessageDef* m) {}

static upb_MessageValue jsondec_msg(jsondec* d, const upb_FieldDef* f) {}

static void jsondec_field(jsondec* d, upb_Message* msg,
                          const upb_MessageDef* m) {}

static void jsondec_object(jsondec* d, upb_Message* msg,
                           const upb_MessageDef* m) {}

static upb_MessageValue jsondec_value(jsondec* d, const upb_FieldDef* f) {}

/* Well-known types ***********************************************************/

static int jsondec_tsdigits(jsondec* d, const char** ptr, size_t digits,
                            const char* after) {}

static int jsondec_nanos(jsondec* d, const char** ptr, const char* end) {}

/* jsondec_epochdays(1970, 1, 1) == 1970-01-01 == 0. */
int jsondec_epochdays(int y, int m, int d) {}

static int64_t jsondec_unixtime(int y, int m, int d, int h, int min, int s) {}

static void jsondec_timestamp(jsondec* d, upb_Message* msg,
                              const upb_MessageDef* m) {}

static void jsondec_duration(jsondec* d, upb_Message* msg,
                             const upb_MessageDef* m) {}

static void jsondec_listvalue(jsondec* d, upb_Message* msg,
                              const upb_MessageDef* m) {}

static void jsondec_struct(jsondec* d, upb_Message* msg,
                           const upb_MessageDef* m) {}

static void jsondec_wellknownvalue(jsondec* d, upb_Message* msg,
                                   const upb_MessageDef* m) {}

static upb_StringView jsondec_mask(jsondec* d, const char* buf,
                                   const char* end) {}

static void jsondec_fieldmask(jsondec* d, upb_Message* msg,
                              const upb_MessageDef* m) {}

static void jsondec_anyfield(jsondec* d, upb_Message* msg,
                             const upb_MessageDef* m) {}

static const upb_MessageDef* jsondec_typeurl(jsondec* d, upb_Message* msg,
                                             const upb_MessageDef* m) {}

static void jsondec_any(jsondec* d, upb_Message* msg, const upb_MessageDef* m) {}

static void jsondec_wrapper(jsondec* d, upb_Message* msg,
                            const upb_MessageDef* m) {}

static void jsondec_wellknown(jsondec* d, upb_Message* msg,
                              const upb_MessageDef* m) {}

bool upb_JsonDecode(const char* buf, size_t size, upb_Message* msg,
                    const upb_MessageDef* m, const upb_DefPool* symtab,
                    int options, upb_Arena* arena, upb_Status* status) {}