Пример #1
0
int
GetFileInfo(struct dllist *dl)
{
	int	error;

	error = CheckElfFile(dl->ldfd);
	if (error == 0) {
		error = GetElfFileInfo(dl);
		if (error != 0) {
			return(-1);
		}
		return (0);
	}

	error = CheckAOutFile(dl->ldfd);
	if (error == 0) {
		error = GetAOutFileInfo(dl);
		if (error != 0) {
			return(-1);
		}
		return (0);
	}

	error = CheckMopFile(dl->ldfd);
	if (error == 0) {
		error = GetMopFileInfo(dl);
		if (error != 0) {
			return(-1);
		}
		return (0);
	}

	/* Unknown file format. */
	return(-1);
}
Пример #2
0
int
main(int argc, char  **argv)
{
	struct dllist dl;
	int     op, i;
	char   *filename;
	struct if_info *ii;
	int	error;

	mopInteractive = 1;

	opterr = 0;
	while ((op = getopt(argc, argv, "av")) != -1) {
		switch (op) {
		case 'a':
			AllFlag++;
			break;
		case 'v':
			VersionFlag++;
			break;
		default:
			Usage();
			/* NOTREACHED */
		}
	}
	
	if (VersionFlag)
		printf("%s: Version %s\n", getprogname(), version);

	if (AllFlag) {
		if (VersionFlag)
			printf("\n");
		iflist = NULL;
		deviceInitAll();
		if (iflist == NULL)
			printf("No interface\n");
		else {
			printf("Interface Address\n");
			for (ii = iflist; ii; ii = ii->next)
				printf("%-9s %x:%x:%x:%x:%x:%x\n",
				    ii->if_name, ii->eaddr[0], ii->eaddr[1],
				    ii->eaddr[2], ii->eaddr[3], ii->eaddr[4],
				    ii->eaddr[5]);
		}
	}
	
	if (VersionFlag || AllFlag)
		i = 1;
	else
		i = 0;

	while (argc > optind) {
		if (i)	printf("\n");
		i++;
		filename = argv[optind++];
		printf("Checking: %s\n", filename);
		dl.ldfd = open(filename, O_RDONLY, 0);
		if (dl.ldfd == -1)
			printf("Unknown file.\n");
		else {
			if ((error = CheckElfFile(dl.ldfd)) == 0) {
				if (GetElfFileInfo(&dl) < 0) {
					printf(
					"Some failure in GetElfFileInfo\n");
				}
			} else if ((error = CheckAOutFile(dl.ldfd)) == 0) {
				if (GetAOutFileInfo(&dl) < 0) {
					printf(
					"Some failure in GetAOutFileInfo\n");
				}
			} else if ((error = CheckMopFile(dl.ldfd)) == 0) {
				if (GetMopFileInfo(&dl) < 0) {
					printf(
					    "Some failure in GetMopFileInfo\n");
				}
			}
		}
		(void) close(dl.ldfd);
	}
	return (0);
}