コード例 #1
0
ファイル: generic_agent.c プロジェクト: nishesj/core
static JsonElement *ReadJsonFile(const char *filename)
{
    struct stat sb;
    if (stat(filename, &sb) == -1)
    {
        Log(LOG_LEVEL_DEBUG, "Could not open JSON file %s", filename);
        return NULL;
    }

    JsonElement *doc = NULL;
    JsonParseError err = JsonParseFile(filename, 4096, &doc);

    if (err != JSON_PARSE_OK
        || NULL == doc)
    {
        Log(LOG_LEVEL_DEBUG, "Could not parse JSON file %s", filename);
    }

    return doc;
}
コード例 #2
0
ファイル: loading.c プロジェクト: lra/core
/**
 * @brief Reads the release_id file from inputs and return a JsonElement.
 */
static JsonElement *ReadReleaseIdFileFromInputs()
{
    char filename[CF_MAXVARSIZE];

    GetReleaseIdFile(GetInputDir(), filename, sizeof(filename));

    struct stat sb;
    if (stat(filename, &sb) == -1)
    {
        return NULL;
    }

    JsonElement *validated_doc = NULL;
    JsonParseError err = JsonParseFile(filename, 4096, &validated_doc);
    if (err != JSON_PARSE_OK)
    {
        Log(LOG_LEVEL_WARNING, "Could not read release ID: '%s' did not contain valid JSON data. "
            "(JsonParseFile: '%s')", filename, JsonParseErrorToString(err));
    }

    return validated_doc;
}