00001
00002
00003
00004 #include "jsoc_main.h"
00005
00006
00007 char *module_name = "drms_dropkeys";
00008
00009 typedef enum
00010 {
00011 kDkErr_Success = 0,
00012 kDkErr_FileIO,
00013 kDkErr_NoMemory,
00014 kDkErr_CantModSeries,
00015 kDkErr_CmdParams,
00016 kDkErr_DropKeys
00017 } DkError_t;
00018
00019 #define kSeries "series"
00020 #define kKeys "keys"
00021
00022 ModuleArgs_t module_args[] =
00023 {
00024 {ARG_STRING, kSeries, NULL, "Series to delete keywords from."},
00025 {ARG_STRINGS, kKeys, NULL, "The names of the keywords to delete."},
00026 {ARG_END}
00027 };
00028
00029
00030 int DoIt(void)
00031 {
00032 DkError_t rv = kDkErr_Success;
00033 int drmsstat = DRMS_SUCCESS;
00034 const char *series = NULL;
00035 char **keys = NULL;
00036 int nkeys = -1;
00037
00038 series = cmdparams_get_str(&cmdparams, kSeries, &drmsstat);
00039 if (drmsstat == DRMS_SUCCESS)
00040 {
00041 nkeys = cmdparams_get_strarr(&cmdparams, kKeys, &keys, &drmsstat);
00042 if (drmsstat != DRMS_SUCCESS)
00043 {
00044 rv = kDkErr_CmdParams;
00045 }
00046 }
00047 else
00048 {
00049 rv = kDkErr_CmdParams;
00050 }
00051
00052 if (rv == kDkErr_Success)
00053 {
00054 int ret = drms_dropkeys_fromseries(drms_env, series, keys, nkeys);
00055
00056 if (ret == DRMS_ERROR_CANTMODPUBSERIES)
00057 {
00058 fprintf(stderr, "Unable to modify replicated series.\n");
00059 rv = kDkErr_CantModSeries;
00060 }
00061 else if (ret != DRMS_SUCCESS)
00062 {
00063 rv = kDkErr_DropKeys;
00064 }
00065 }
00066
00067 return rv;
00068 }