summaryrefslogtreecommitdiffstats
path: root/src/globals.c
diff options
context:
space:
mode:
authorRadek Novacek <rnovacek@redhat.com>2013-04-08 11:09:53 +0200
committerRadek Novacek <rnovacek@redhat.com>2013-04-17 12:31:25 +0200
commitc14bd833b7b1b3b1283d116a87b6f293377f129b (patch)
tree09e297a582294bfe137ef4e2fc0927bbdd33784c /src/globals.c
parent1b8ac75de453d41f5cc78695cb7f5cec476cf674 (diff)
downloadopenlmi-providers-c14bd833b7b1b3b1283d116a87b6f293377f129b.tar.gz
openlmi-providers-c14bd833b7b1b3b1283d116a87b6f293377f129b.tar.xz
openlmi-providers-c14bd833b7b1b3b1283d116a87b6f293377f129b.zip
Support for using libopenlmicommon by external providers
* add FindOpenLMI.cmake module * add pkgconfig for OpenLMI * add openlmi.c/h with exported functions * add symlink with major version to openlmicommon library Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=948948
Diffstat (limited to 'src/globals.c')
-rw-r--r--src/globals.c98
1 files changed, 0 insertions, 98 deletions
diff --git a/src/globals.c b/src/globals.c
deleted file mode 100644
index 7e58817..0000000
--- a/src/globals.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2012-2013 Red Hat, Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Radek Novacek <rnovacek@redhat.com>
- */
-
-#include "globals.h"
-
-#include <stdlib.h>
-#include <stdarg.h>
-#include <unistd.h>
-#include <sys/utsname.h>
-#include <string.h>
-#include <netdb.h>
-#include <stdio.h>
-
-static char *_fqdn = NULL;
-static int _log_level = DEBUG;
-
-char *getFQDN(void)
-{
- struct utsname uts;
- if ((uname(&uts) > 0) && (uts.nodename != NULL)) {
- return strdup(uts.nodename);
- }
- char hostname[256];
- hostname[255] = '\0';
- if (gethostname(hostname, 255) == -1) {
- // FIXME: what to do, if we can't use gethostname?
- return NULL;
- }
-
- struct addrinfo hints;
- struct addrinfo *info = NULL, *p;
- memset(&hints, 0, sizeof hints);
- hints.ai_family = AF_UNSPEC; // either IPV4 or IPV6
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_flags = AI_CANONNAME;
-
- if (getaddrinfo(hostname, "http", &hints, &info) == 0) {
- for (p = info; p != NULL; p = p->ai_next) {
- if (p->ai_canonname && strstr(p->ai_canonname, "localhost") == NULL) {
- char *dn = strdup(p->ai_canonname);
- freeaddrinfo(info);
- return dn;
- }
- }
- }
- if (info != NULL) {
- freeaddrinfo(info);
- }
- return strdup(hostname);
-}
-
-const char *get_system_name()
-{
- if (_fqdn == NULL) {
- _fqdn = getFQDN();
- }
- return _fqdn;
-}
-
-const char *get_system_creation_class_name()
-{
- return "Linux_ComputerSystem";
-}
-
-void _debug(int level, const char *file, int line, const char *format, ...)
-{
- if (level > _log_level) {
- return;
- }
- FILE *trace_file = stderr;
- const char *lvl[] = { "NONE", "ERROR", "WARNING", "DEBUG" };
- // TODO: use logger from sfcbd and pegasus
- fprintf(trace_file, "[%s] %s:%d\t", lvl[level], file, line);
-
- va_list args;
- va_start(args, format);
- vfprintf(stderr, format, args);
- va_end(args);
-
- fprintf(stderr, "\n");
-}