|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T c
Length: 2394 (0x95a)
Types: TextFile
Names: »compare.c«
└─⟦3d0c2be1b⟧ Bits:30001254 ISODE-5.0 Tape
└─⟦eba4602b1⟧ »./isode-5.0.tar.Z«
└─⟦d3ac74d73⟧
└─⟦this⟧ »isode-5.0/quipu/dish/compare.c«
#include "quipu/util.h"
#include "quipu/compare.h"
extern DN dn;
extern PS opt;
extern PS rps;
extern LLog *log_dua;
call_compare (argc, argv)
int argc;
char **argv;
{
struct DSError error;
struct ds_compare_result result;
struct ds_compare_arg compare_arg;
int x;
int att_present = 0;
int print = FALSE;
char *str1_type;
char *str1_value;
char *ptr;
if ((argc = service_control (opt, argc, argv, &compare_arg.cma_common)) == -1)
return;
if (argc == 1) {
ps_print (opt,"What do you want to compare ?\n");
Usage (argv[0]);
return;
}
for (x = 1; x < argc; x++) {
if (test_arg (argv[x],"-attribute",1)) {
str1_type = argv[++x];
att_present = 1;
} else if (test_arg (argv[x], "-print",3)) {
print = TRUE;
DLOG (log_dua, LLOG_TRACE, ("We have the default print flag.\n"));
} else if (test_arg (argv[x], "-noprint",3)) {
DLOG (log_dua, LLOG_TRACE, ("We have a -noprint flag.\n"));
print = FALSE;
} else if (move (argv[x]) == OK)
continue;
else {
if (*argv[x] == '-')
ps_printf (opt,"Unknown option %s\n",argv[x]);
else
ps_printf (opt,"Invalid attribute assertion syntax %s\n",argv[x]);
Usage (argv[0]);
return;
}
}
if (att_present == 0) {
ps_printf (opt, "We are missing <attribute_type>=<attribute_value>.\n");
Usage (argv[0]);
return;
}
ptr = str1_type;
while (*ptr != '=') {
ptr++;
}
*ptr++ = '\0';
str1_value = ptr;
DLOG (log_dua, LLOG_TRACE, ("Type is '%s', Value is '%s'.\n", str1_type, str1_value));
if (get_ava (&compare_arg.cma_purported, str1_type, str1_value) != OK) {
Usage (argv[0]);
return;
}
compare_arg.cma_object = dn;
if (rebind () != OK)
return;
if (ds_compare (&compare_arg, &error, &result) != DS_OK) {
/* deal with error */
ps_printf (opt, "Comapre error.\n");
ds_error (opt, &error);
return;
} else {
if (result.cmr_common.cr_aliasdereferenced & print) {
ps_print (rps, "(Alias dereferenced - ");
dn_print (rps, result.cmr_object, READOUT);
dn_free (result.cmr_object);
ps_print (rps, ")\n");
}
if (print) {
if (result.cmr_matched == TRUE)
ps_print (rps, "TRUE\n");
else
ps_print (opt, "FALSE\n");
} else {
if (result.cmr_matched == TRUE)
ps_print (rps, "\1");
else
ps_print (opt, "\0");
}
}
}