コード例 #1
0
ファイル: process.c プロジェクト: Bluerise/bitrig-xenocara
/* ARGSUSED */
static int
dump_entry(const char *inputfilename, int lineno, Xauth *auth, char *data)
{
    struct _list_data *ld = (struct _list_data *) data;
    FILE *fp = ld->fp;

    if (ld->numeric) {
	dump_numeric (fp, auth);
    } else {
	const char *dpyname = NULL;

	switch (auth->family) {
	  case FamilyLocal:
	    fwrite (auth->address, sizeof (char), auth->address_length, fp);
	    fprintf (fp, "/unix");
	    break;
	  case FamilyInternet:
#if defined(IPv6) && defined(AF_INET6)
	  case FamilyInternet6:
#endif
	  case FamilyDECnet:
	    dpyname = get_hostname (auth);
	    if (dpyname) {
		fprintf (fp, "%s", dpyname);
		break;
	    }
	    /* else fall through to default */
	  default:
	    fprintf (fp, "#%04x#", auth->family);
	    fprintfhex (fp, auth->address_length, auth->address);
	    putc ('#', fp);
	}
	putc (':', fp);
	fwrite (auth->number, sizeof (char), auth->number_length, fp);
	putc (' ', fp);
	putc (' ', fp);
	fwrite (auth->name, sizeof (char), auth->name_length, fp);
	putc (' ', fp);
	putc (' ', fp);
	if (!strncmp(auth->name, SECURERPC, auth->name_length) ||
	    !strncmp(auth->name, K5AUTH, auth->name_length))
            fwrite (auth->data, sizeof (char), auth->data_length, fp);
	else
	    fprintfhex (fp, auth->data_length, auth->data);
	putc ('\n', fp);
    }
    return 0;
}
コード例 #2
0
ファイル: infocmp.c プロジェクト: BackupTheBerlios/wl530g-svn
static void
compare_predicate(int type, int idx, const char *name)
/* predicate function to use for entry difference reports */
{
    register ENTRY *e1 = &entries[0];
    register ENTRY *e2 = &entries[1];
    char buf1[MAX_STRING], buf2[MAX_STRING];
    int b1, b2;
    int n1, n2;
    char *s1, *s2;

    switch (type) {
    case CMP_BOOLEAN:
	b1 = e1->tterm.Booleans[idx];
	b2 = e2->tterm.Booleans[idx];
	switch (compare) {
	case C_DIFFERENCE:
	    if (!(b1 == ABSENT_BOOLEAN && b2 == ABSENT_BOOLEAN) && b1 != b2)
		(void) printf("\t%s: %s%s%s.\n",
			      name,
			      dump_boolean(b1),
			      bool_sep,
			      dump_boolean(b2));
	    break;

	case C_COMMON:
	    if (b1 == b2 && b1 != ABSENT_BOOLEAN)
		(void) printf("\t%s= %s.\n", name, dump_boolean(b1));
	    break;

	case C_NAND:
	    if (b1 == ABSENT_BOOLEAN && b2 == ABSENT_BOOLEAN)
		(void) printf("\t!%s.\n", name);
	    break;
	}
	break;

    case CMP_NUMBER:
	n1 = e1->tterm.Numbers[idx];
	n2 = e2->tterm.Numbers[idx];
	dump_numeric(n1, buf1);
	dump_numeric(n2, buf2);
	switch (compare) {
	case C_DIFFERENCE:
	    if (!((n1 == ABSENT_NUMERIC && n2 == ABSENT_NUMERIC)) && n1 != n2)
		(void) printf("\t%s: %s, %s.\n", name, buf1, buf2);
	    break;

	case C_COMMON:
	    if (n1 != ABSENT_NUMERIC && n2 != ABSENT_NUMERIC && n1 == n2)
		(void) printf("\t%s= %s.\n", name, buf1);
	    break;

	case C_NAND:
	    if (n1 == ABSENT_NUMERIC && n2 == ABSENT_NUMERIC)
		(void) printf("\t!%s.\n", name);
	    break;
	}
	break;

    case CMP_STRING:
	s1 = e1->tterm.Strings[idx];
	s2 = e2->tterm.Strings[idx];
	switch (compare) {
	case C_DIFFERENCE:
	    if (capcmp(idx, s1, s2)) {
		dump_string(s1, buf1);
		dump_string(s2, buf2);
		if (strcmp(buf1, buf2))
		    (void) printf("\t%s: %s, %s.\n", name, buf1, buf2);
	    }
	    break;

	case C_COMMON:
	    if (s1 && s2 && !capcmp(idx, s1, s2))
		(void) printf("\t%s= '%s'.\n", name, TIC_EXPAND(s1));
	    break;

	case C_NAND:
	    if (!s1 && !s2)
		(void) printf("\t!%s.\n", name);
	    break;
	}
	break;

    case CMP_USE:
	/* unlike the other modes, this compares *all* use entries */
	switch (compare) {
	case C_DIFFERENCE:
	    if (!useeq(e1, e2)) {
		(void) fputs("\tuse: ", stdout);
		print_uses(e1, stdout);
		fputs(", ", stdout);
		print_uses(e2, stdout);
		fputs(".\n", stdout);
	    }
	    break;

	case C_COMMON:
	    if (e1->nuses && e2->nuses && useeq(e1, e2)) {
		(void) fputs("\tuse: ", stdout);
		print_uses(e1, stdout);
		fputs(".\n", stdout);
	    }
	    break;

	case C_NAND:
	    if (!e1->nuses && !e2->nuses)
		(void) printf("\t!use.\n");
	    break;
	}
    }
}