summaryrefslogtreecommitdiffstats
path: root/src/logicalfile/file.c
diff options
context:
space:
mode:
authorJan Synacek <jsynacek@redhat.com>2013-02-08 13:16:31 +0100
committerJan Synacek <jsynacek@redhat.com>2013-02-11 13:10:40 +0100
commit7f40ebbf575d93a9d0bc540c484969ec614f308b (patch)
tree3a698f3560c626c5e9ca6aa060dc1c4b3e836b0a /src/logicalfile/file.c
parent80a4e2961a65f9922e000d27ce642a4789588648 (diff)
downloadopenlmi-providers-7f40ebbf575d93a9d0bc540c484969ec614f308b.tar.gz
openlmi-providers-7f40ebbf575d93a9d0bc540c484969ec614f308b.tar.xz
openlmi-providers-7f40ebbf575d93a9d0bc540c484969ec614f308b.zip
New provider: LogicalFile
Diffstat (limited to 'src/logicalfile/file.c')
-rw-r--r--src/logicalfile/file.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/logicalfile/file.c b/src/logicalfile/file.c
new file mode 100644
index 0000000..a9a13a6
--- /dev/null
+++ b/src/logicalfile/file.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2012 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: Jan Synacek <jsynacek@redhat.com>
+ */
+#include "file.h"
+
+static const char *LOGICALFILE_REQUIRED_NAMES[] = {
+ "CSCreationClassName",
+ "CSName",
+ "CreationClassName",
+ "FSCreationClassName",
+ "FSName",
+ "Name",
+ NULL
+};
+
+static const char *UNIXFILE_REQUIRED_NAMES[] = {
+ "CSCreationClassName",
+ "CSName",
+ "LFCreationClassName",
+ "FSCreationClassName",
+ "FSName",
+ "LFName",
+ NULL
+};
+
+CMPIStatus lmi_check_required(
+ const CMPIBroker *b,
+ const CMPIObjectPath *o,
+ const enum RequiredNames rn)
+{
+ const char **names;
+
+ switch (rn) {
+ case LOGICALFILE:
+ names = LOGICALFILE_REQUIRED_NAMES;
+ break;
+ case UNIXFILE:
+ names = UNIXFILE_REQUIRED_NAMES;
+ break;
+ default:
+ /* not possible! */
+ assert(0);
+ break;
+ }
+
+ for (int i = 0; names[i]; i++) {
+ if (CMIsNullValue(CMGetKey(o, names[i], NULL))) {
+ char errmsg[BUFLEN];
+ snprintf(errmsg, BUFLEN, "No '%s' specified", names[i]);
+ CMReturnWithChars(b, CMPI_RC_ERR_FAILED, errmsg);
+ }
+ }
+ CMReturn(CMPI_RC_OK);
+}
+
+void _dump_objectpath(const CMPIObjectPath *o)
+{
+ printf("OP: %s\n", CMGetCharsPtr(o->ft->toString(o, NULL), NULL));
+}
+/* vi: set et: */