case MACHINE:
if ( (stat = do_mr_query("get_machine", 1, &name1,
StoreInfo, (char *)&elem)) != 0) {
- com_err(program_name, stat, " in get_machine.");
+ if (stat == MR_NO_MATCH) {
+ char buf[128];
+ sprintf(buf, "Machine '%s' is not in the database.", name1);
+ Put_message(buf);
+ } else
+ com_err(program_name, stat, " in get_machine.");
return(NULL);
}
break;
int type;
Bool name;
{
- char temp_buf[BUFSIZ], *newname;
+ char temp_buf[BUFSIZ], *newname, *oldnewname;
switch (type) {
case MACHINE:
switch (type) {
case MACHINE:
newname = Strsave(info[M_NAME]);
- GetValueFromUser("The new name for this machine? ", &newname);
+ if (GetValueFromUser("The new name for this machine? ", &newname) ==
+ SUB_ERROR)
+ return(NULL);
+ oldnewname = Strsave(newname);
newname = canonicalize_hostname(newname);
+ if (strcasecmp(newname, oldnewname)) {
+ sprintf(temp_buf, "Warning: '%s' canonicalized to '%s'\n",
+ oldnewname, newname);
+ Put_message(temp_buf);
+ }
+ free(oldnewname);
break;
case CLUSTER:
newname = Strsave(info[C_NAME]);
- GetValueFromUser("The new name for this cluster? ",
- &newname);
+ if (GetValueFromUser("The new name for this cluster? ",
+ &newname) == SUB_ERROR)
+ return(NULL);
break;
default:
Put_message("Unknown type in AskMCDInfo, programmer botch");
switch(type) {
case MACHINE:
- GetTypeFromUser("Machine's Type", "mac_type", &info[M_TYPE]);
+ if (GetTypeFromUser("Machine's Type", "mac_type", &info[M_TYPE]) ==
+ SUB_ERROR)
+ return(NULL);
FreeAndClear(&info[M_MODTIME], TRUE);
FreeAndClear(&info[M_MODBY], TRUE);
FreeAndClear(&info[M_MODWITH], TRUE);
break;
case CLUSTER:
- GetValueFromUser("Cluster's Description:", &info[C_DESCRIPT]);
- GetValueFromUser("Cluster's Location:", &info[C_LOCATION]);
+ if (GetValueFromUser("Cluster's Description:", &info[C_DESCRIPT]) ==
+ SUB_ERROR)
+ return(NULL);
+ if (GetValueFromUser("Cluster's Location:", &info[C_LOCATION]) ==
+ SUB_ERROR)
+ return(NULL);
FreeAndClear(&info[C_MODTIME], TRUE);
FreeAndClear(&info[C_MODBY], TRUE);
FreeAndClear(&info[C_MODWITH], TRUE);
break;
case DATA:
- GetValueFromUser("Label defining this data?", &info[CD_LABEL]);
- GetValueFromUser("The data itself ? ", &info[CD_DATA]);
+ if (GetValueFromUser("Label defining this data?", &info[CD_LABEL]) ==
+ SUB_ERROR)
+ return(NULL);
+ if (GetValueFromUser("The data itself ? ", &info[CD_DATA]) == SUB_ERROR)
+ return(NULL);
break;
}
int argc;
char **argv;
{
- char **args, *info[MAX_ARGS_SIZE], *name;
+ char **args, *info[MAX_ARGS_SIZE], *name, buf[256];
int stat;
if (!ValidName(argv[1])) /* Checks for wildcards. */
name = canonicalize_hostname(strsave(argv[1]));
if ( (stat = do_mr_query("get_machine", 1, &name, NullFunc, NULL)) == 0) {
- Put_message("This machine already exists.");
+ sprintf(buf, "The machine '%s' already exists.", name);
+ Put_message(buf);
free(name);
return(DM_NORMAL);
}
else if (stat != MR_NO_MATCH) {
- com_err(program_name, stat, " in AddMachine.");
+ com_err(program_name, stat,
+ " while checking machine '%s' in AddMachine.", name);
free(name);
return(DM_NORMAL);
}
- args = AskMCDInfo(SetMachineDefaults(info, name), MACHINE, FALSE);
+ if ((args = AskMCDInfo(SetMachineDefaults(info, name), MACHINE, FALSE)) ==
+ NULL) {
+ Put_message("Aborted.");
+ return(DM_NORMAL);
+ }
/*
* Actually create the new Machine.
{
register int stat;
char ** args = AskMCDInfo(info, MACHINE, TRUE);
+ if (args == NULL) {
+ Put_message("Aborted.");
+ return;
+ }
if ( (stat = do_mr_query("update_machine", CountArgs(args),
args, Scream, NULL)) != 0)
com_err(program_name, stat, " in UpdateMachine.");
struct qelem * melem, *mtop, *celem, *ctop;
machine = canonicalize_hostname(strsave(argv[1]));
+ if (strcasecmp(machine, argv[1])) {
+ sprintf(temp_buf, "Warning: '%s' canonicalized to '%s'.",
+ argv[1], machine);
+ Put_message(temp_buf);
+ }
cluster = argv[2];
celem = ctop = GetMCInfo(CLUSTER, cluster, (char *) NULL);
register int stat;
args[MAP_MACHINE] = canonicalize_hostname(strsave(argv[1]));
+ if (strcasecmp(args[MAP_MACHINE], argv[1])) {
+ sprintf(temp_buf, "Warning: '%s' canonicalized to '%s'.",
+ argv[1], args[MAP_MACHINE]);
+ Put_message(temp_buf);
+ }
args[MAP_CLUSTER] = argv[2];
args[MAP_END] = NULL;
com_err(program_name, stat, " in AddCluster.");
return(DM_NORMAL);
}
- args = AskMCDInfo(SetClusterDefaults(info, name), CLUSTER, FALSE);
+ if ((args = AskMCDInfo(SetClusterDefaults(info, name), CLUSTER, FALSE)) ==
+ NULL) {
+ Put_message("Aborted.");
+ FreeInfo(info);
+ return(DM_NORMAL);
+ }
+
/*
* Actually create the new Cluster.
*/
{
register int stat;
char ** args = AskMCDInfo(info, CLUSTER, TRUE);
+ if (args == NULL) {
+ Put_message("Aborted.");
+ return;
+ }
if ( (stat = do_mr_query("update_cluster", CountArgs(args),
args, Scream, NULL)) != 0)
com_err(program_name, stat, " in UpdateCluster.");
char *tmpname;
tmpname = canonicalize_hostname(strsave(argv[1]));
+ if (strcasecmp(tmpname, argv[1])) {
+ sprintf(temp_buf, "Warning: '%s' canonicalized to '%s'.",
+ argv[1], tmpname);
+ Put_message(temp_buf);
+ }
top = elem = GetMCInfo(MAP, tmpname, argv[2]);
Put_message(""); /* blank line on screen */