From a6bac0886c3ae5842c1f2175ac107c03b75753b6 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Sun, 9 Aug 2020 13:25:30 -0400 Subject: [PATCH] rAlertString / rErrorString - custom rIcon check --- GNUmakefile | 7 ++++--- alert.c | 18 ++++++++++++++++++ rlint.c | 6 ++++++ rlint.h | 3 +++ 4 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 alert.c diff --git a/GNUmakefile b/GNUmakefile index 4b655d9..9065018 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,16 +1,17 @@ -OBJ = o/rlint.a o/menu.a o/control.a o/bundle.a +OBJ = o/rlint.a o/menu.a o/control.a o/bundle.a o/alert.a rlint : $(OBJ) - $(RM) o/menu.root o/control.root o/bundle.root - iix link o/rlint o/menu o/control o/bundle keep=$@ + $(RM) o/menu.root o/control.root o/bundle.root o/alert.root + iix link o/rlint o/menu o/control o/bundle o/alert keep=$@ o/rlint.a : rlint.c rlint.h o/menu.a : menu.c rlint.h o/control.a : control.c rlint.h o/bundle.a : bundle.c rlint.h +o/alert.a : alert.c rlint.h o : mkdir $@ diff --git a/alert.c b/alert.c new file mode 100644 index 0000000..bfe3542 --- /dev/null +++ b/alert.c @@ -0,0 +1,18 @@ +#include "rlint.h" + +void check_rAlertString(Handle h) { + /* if there's a custom icon, assume it's a resource ref */ + + unsigned char *ptr = *(unsigned char **)h; + unsigned x; + unsigned offset = 0; + + x = ptr[offset++]; + if (x == '0') offset += 8; /* skip past custom size rect */ + x = ptr[offset++]; + if (x == '1') { + /* custom icon */ + unsigned long ref = *(unsigned long *)(ptr + offset); + if (ref) check(rIcon, ref); + } +} diff --git a/rlint.c b/rlint.c index b06bb15..446a2ec 100644 --- a/rlint.c +++ b/rlint.c @@ -209,6 +209,10 @@ void check(ResType type, ResID id) { case rWindParam1: callback = check_rWindParam1; break; case rStringList: callback = check_rStringList; break; case rBundle: callback = check_rBundle; break; + case rAlertString: + case rErrorString: + callback = check_rAlertString; + break; default: callback = 0; } @@ -292,6 +296,8 @@ void one_file(const char *name) { case rWindParam1: case rStringList: case rBundle: + case rAlertString: + case rErrorString: break; default: continue; diff --git a/rlint.h b/rlint.h index 4f7a5d6..d849632 100644 --- a/rlint.h +++ b/rlint.h @@ -12,6 +12,9 @@ void check_rStringList(Handle h); void check_rBundle(Handle h); +void check_rAlertString(Handle h); + + void error(const char *msg); void check(ResType type, ResID id);