I have a simple utility expecting three command-line arguments:
./myutil -k 123 45
argv[1] is a text flag of some sort: memcmp() against allowed flags; works!
argv[2] and argv[3] need to sit in unsigned 32-bit integers and are required to be >= 1.
For now I'm using:
strstr() to look for "-" ...and assuming absence of "-" means +ve number-as-string.
atoi() to get assumed +ve number into unsigned thisuint, thatuint
Then checking thisuint >= 1, thatuint >=1
It works for the test cases I've tried, but it seems mmmmmm clumsy.
Is there a better way?
As stated, this is a "simple utility": 1000 lines of validation code is the wrong choice.
Chris
./myutil -k 123 45
argv[1] is a text flag of some sort: memcmp() against allowed flags; works!
argv[2] and argv[3] need to sit in unsigned 32-bit integers and are required to be >= 1.
For now I'm using:
strstr() to look for "-" ...and assuming absence of "-" means +ve number-as-string.
atoi() to get assumed +ve number into unsigned thisuint, thatuint
Then checking thisuint >= 1, thatuint >=1
It works for the test cases I've tried, but it seems mmmmmm clumsy.
Is there a better way?
As stated, this is a "simple utility": 1000 lines of validation code is the wrong choice.
Chris
Comment