Code: Show/Hide #include <stdlib.h> #include <stdio.h> #include <string.h> #include "util.h" #include "region.h" int main(int argc, char *argv[]) { if (argc == 5) { rect_t r; char out[10]; r.x = atoi(argv[1]); r.y = atoi(argv[2]); r.w = atoi(argv[3]); r.h = atoi(argv[4]); encode_rectangle(out, r); printf("x:%i y:%i w:%i h:%i\n", r.x, r.y, r.w, r.h); printf("%s\n", out); exit(0); } else { printf("usage: %s <x> <y> <w> <h>\n", argv[0]); exit(1); } } |
Code: Show/Hide #include <stdlib.h> #include <stdio.h> #include <string.h> #include "util.h" #include "region.h" int main(int argc, char *argv[]) { if (argc == 2) { if (strlen(argv[1]) != 9) { rect_t r; r = decode_rectangle(argv[1]); printf("x:%i y:%i w:%i h:%i\n", r.x, r.y, r.w, r.h); exit(0); } else { printf("Error: bad length.\n"); exit(1); } } else { printf("usage: %s <chars>\n", argv[0]); exit(1); } } |