Blame libfreerdp/core/errbase.c

Packit 1fb8d4
/**
Packit 1fb8d4
 * FreeRDP: A Remote Desktop Protocol Implementation
Packit 1fb8d4
 * Error Base
Packit 1fb8d4
 *
Packit 1fb8d4
 * Copyright 2015 Armin Novak <armin.novak@thincast.com>
Packit 1fb8d4
 * Copyright 2015 Thincast Technologies GmbH
Packit 1fb8d4
 *
Packit 1fb8d4
 * Licensed under the Apache License, Version 2.0 (the "License");
Packit 1fb8d4
 * you may not use this file except in compliance with the License.
Packit 1fb8d4
 * You may obtain a copy of the License at
Packit 1fb8d4
 *
Packit 1fb8d4
 *     http://www.apache.org/licenses/LICENSE-2.0
Packit 1fb8d4
 *
Packit 1fb8d4
 * Unless required by applicable law or agreed to in writing, software
Packit 1fb8d4
 * distributed under the License is distributed on an "AS IS" BASIS,
Packit 1fb8d4
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit 1fb8d4
 * See the License for the specific language governing permissions and
Packit 1fb8d4
 * limitations under the License.
Packit 1fb8d4
 */
Packit 1fb8d4
Packit 1fb8d4
#ifdef HAVE_CONFIG_H
Packit 1fb8d4
#include "config.h"
Packit 1fb8d4
#endif
Packit 1fb8d4
Packit 1fb8d4
#include <stdio.h>
Packit 1fb8d4
Packit 1fb8d4
#include <freerdp/log.h>
Packit 1fb8d4
Packit 1fb8d4
#include "errinfo.h"
Packit 1fb8d4
Packit 1fb8d4
#define TAG FREERDP_TAG("core")
Packit 1fb8d4
Packit Service 5a9772
#define ERRBASE_DEFINE(_code)                                            \
Packit Service 5a9772
	{                                                                    \
Packit Service 5a9772
		ERRBASE_##_code, "ERRBASE_" #_code, ERRBASE_##_code##_STRING, "" \
Packit Service 5a9772
	}
Packit 1fb8d4
Packit 1fb8d4
/* Protocol-independent codes */
Packit 1fb8d4
Packit 1fb8d4
/* Special codes */
Packit 1fb8d4
#define ERRBASE_SUCCESS_STRING "Success."
Packit 1fb8d4
#define ERRBASE_NONE_STRING ""
Packit 1fb8d4
Packit Service 5a9772
static const ERRINFO ERRBASE_CODES[] = { ERRBASE_DEFINE(SUCCESS),
Packit 1fb8d4
Packit Service 5a9772
	                                     ERRBASE_DEFINE(NONE) };
Packit 1fb8d4
Packit 1fb8d4
const char* freerdp_get_error_base_string(UINT32 code)
Packit 1fb8d4
{
Packit 1fb8d4
	const ERRINFO* errInfo;
Packit 1fb8d4
Packit 1fb8d4
	errInfo = &ERRBASE_CODES[0];
Packit 1fb8d4
Packit 1fb8d4
	while (errInfo->code != ERRBASE_NONE)
Packit 1fb8d4
	{
Packit 1fb8d4
		if (code == errInfo->code)
Packit 1fb8d4
		{
Packit 1fb8d4
			return errInfo->info;
Packit 1fb8d4
		}
Packit 1fb8d4
Packit 1fb8d4
		errInfo++;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	return "ERRBASE_UNKNOWN";
Packit 1fb8d4
}
Packit 1fb8d4
Packit Service 5a9772
const char* freerdp_get_error_base_category(UINT32 code)
Packit Service 5a9772
{
Packit Service 5a9772
	const ERRINFO* errInfo;
Packit Service 5a9772
Packit Service 5a9772
	errInfo = &ERRBASE_CODES[0];
Packit Service 5a9772
Packit Service 5a9772
	while (errInfo->code != ERRBASE_NONE)
Packit Service 5a9772
	{
Packit Service 5a9772
		if (code == errInfo->code)
Packit Service 5a9772
		{
Packit Service 5a9772
			return errInfo->category;
Packit Service 5a9772
		}
Packit Service 5a9772
Packit Service 5a9772
		errInfo++;
Packit Service 5a9772
	}
Packit Service 5a9772
Packit Service 5a9772
	return "ERRBASE_UNKNOWN";
Packit Service 5a9772
}
Packit Service 5a9772
Packit 1fb8d4
const char* freerdp_get_error_base_name(UINT32 code)
Packit 1fb8d4
{
Packit 1fb8d4
	const ERRINFO* errInfo;
Packit 1fb8d4
Packit 1fb8d4
	errInfo = &ERRBASE_CODES[0];
Packit 1fb8d4
Packit 1fb8d4
	while (errInfo->code != ERRBASE_NONE)
Packit 1fb8d4
	{
Packit 1fb8d4
		if (code == errInfo->code)
Packit 1fb8d4
		{
Packit 1fb8d4
			return errInfo->name;
Packit 1fb8d4
		}
Packit 1fb8d4
Packit 1fb8d4
		errInfo++;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	return "ERRBASE_UNKNOWN";
Packit 1fb8d4
}