aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2020-08-27 20:22:03 +0000
committerrodri <rgl@antares-labs.eu>2020-08-27 20:22:03 +0000
commit47259f1ae68868735c7306eac93266e6ed4bc429 (patch)
treec6ebb6332a31b57233d822fac21762cb8a5808b5
parent9b6ef159316a449e61aed75ac6a5eaaeb72e8038 (diff)
downloadipcalc-47259f1ae68868735c7306eac93266e6ed4bc429.tar.gz
ipcalc-47259f1ae68868735c7306eac93266e6ed4bc429.tar.bz2
ipcalc-47259f1ae68868735c7306eac93266e6ed4bc429.zip
use the proper types. input parsing cleanup.
-rw-r--r--main.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/main.c b/main.c
index b3d3d4e..953ef45 100644
--- a/main.c
+++ b/main.c
@@ -15,7 +15,7 @@ struct IPNet
};
void
-printip(uint addr)
+printip(u32int addr)
{
uchar ip4[4];
@@ -60,7 +60,7 @@ void
main(int argc, char *argv[])
{
IPNet net;
- uint addr, mask;
+ u32int addr, mask;
char *a, *m;
ARGBEGIN{
@@ -70,15 +70,15 @@ main(int argc, char *argv[])
usage();
a = argv[0];
- addr = strtoul(a, &a, 10) << 24; a++;
- addr |= strtoul(a, &a, 10) << 16; a++;
- addr |= strtoul(a, &a, 10) << 8; a++;
- addr |= strtoul(a, &a, 10);
+ addr = strtoul(a, &a, 10) << 24;
+ addr |= strtoul(++a, &a, 10) << 16;
+ addr |= strtoul(++a, &a, 10) << 8;
+ addr |= strtoul(++a, &a, 10);
m = argv[1];
- mask = strtoul(m, &m, 10) << 24; m++;
- mask |= strtoul(m, &m, 10) << 16; m++;
- mask |= strtoul(m, &m, 10) << 8; m++;
- mask |= strtoul(m, &m, 10);
+ mask = strtoul(m, &m, 10) << 24;
+ mask |= strtoul(++m, &m, 10) << 16;
+ mask |= strtoul(++m, &m, 10) << 8;
+ mask |= strtoul(++m, &m, 10);
net.addr = addr&mask;
net.mask = mask;