diff options
author | B. Watson <yalhcru@gmail.com> | 2019-03-15 17:14:18 -0400 |
---|---|---|
committer | B. Watson <yalhcru@gmail.com> | 2019-03-15 17:14:18 -0400 |
commit | 3be3c332a5e47434d74e99e2ed77e9fb9f4cf60c (patch) | |
tree | d36549357611a80add50e5d8c896acf032e80b88 /src/formatip.c | |
parent | e0e6a9b6ee60c0b7367be4c0caa99534b6d23071 (diff) | |
download | fujichat-3be3c332a5e47434d74e99e2ed77e9fb9f4cf60c.tar.gz |
printf removal
Diffstat (limited to 'src/formatip.c')
-rw-r--r-- | src/formatip.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/formatip.c b/src/formatip.c new file mode 100644 index 0000000..f1a2fd1 --- /dev/null +++ b/src/formatip.c @@ -0,0 +1,34 @@ +#include <stdio.h> +#include "uip.h" + +/* easier to copy/paste this tiny function from uip.c + than it would be to rebuild all of uIP for use in + this program! Also don't want to bloat fujiconf by + linking uip.a, even if it would link without a + recompile. */ +/* +u16_t local_htons(u16_t val) { + return HTONS(val); +} +*/ + +/* this version's half the size */ +static u16_t local_htons(u16_t val) { + __AX__ = val; + asm("sta tmp1"); + asm("txa"); + asm("ldx tmp1"); +} + +static char ipbuf[20]; + +char *format_ip(uip_ipaddr_t *ip) { + u16_t *ipaddr = (u16_t *)ip; + sprintf(ipbuf, "%d.%d.%d.%d", + local_htons(ipaddr[0]) >> 8, + local_htons(ipaddr[0]) & 0xff, + local_htons(ipaddr[1]) >> 8, + local_htons(ipaddr[1]) & 0xff); + + return ipbuf; +} |