ips.c
809 Bytes
/*
* Copyright (C) 1996-1998 by the Board of Trustees
* of Leland Stanford Junior University.
*
* This file is part of the SimOS distribution.
* See LICENSE file for terms of the license.
*
*/
/*
* Generate list of SimOS IP addresses, given list of people and
* number of addresses/person.
*
* ips <people-file> <n-per-person> <base-IP>
*
*/
#include <stdio.h>
int main(int argc, char *argv[])
{
FILE *people = fopen(argv[1], "r");
int n = atoi(argv[2]);
char *base = argv[3];
char name[100];
int i, k, a1, a2, a3, a4;
sscanf(base, "%d.%d.%d.%d", &a1, &a2, &a3, &a4);
for (k = 0; ; k += n) {
if (fscanf(people, "%s", name) != 1) return 0;
for (i = 0; i < n; i++)
printf("%d.%d.%d.%d\t%s-%d\n", a1, a2, a3, a4+k+i, name, i);
printf("\n");
}
}