[Debootloaders-devel] r68 - trunk/rsrce
Aurélien GÉRÔME
ag-guest at costa.debian.org
Tue Jul 11 01:24:38 UTC 2006
Author: ag-guest
Date: 2006-07-11 01:24:38 +0000 (Tue, 11 Jul 2006)
New Revision: 68
Modified:
trunk/rsrce/resource.c
Log:
Patch from Piotr Krysiuk to allow changing the resource attributes
using symbolic representation.
Modified: trunk/rsrce/resource.c
===================================================================
--- trunk/rsrce/resource.c 2006-07-11 01:23:49 UTC (rev 67)
+++ trunk/rsrce/resource.c 2006-07-11 01:24:38 UTC (rev 68)
@@ -137,8 +137,30 @@
const char * const res_attrch = "7spLPlw0";
void res_chattr(struct resource *r, const char *spec)
{
- /* FIXME: please a bit more usable */
- r->attr = atoi(spec);
+ int v, op, mask;
+ char *pos;
+
+ v = 0;
+ op = 0xff;
+ while(*spec) {
+ pos = strchr(res_attrch, *spec);
+ if(pos) {
+ mask = 0x80 >> (pos - res_attrch);
+ v &= ~mask;
+ v |= op & mask;
+ r->attr = v;
+ } else if(*spec == '+') {
+ v = r->attr;
+ op = 0xff;
+ } else if(*spec == '-') {
+ v = r->attr;
+ op = 0;
+ } else {
+ r->attr = v;
+ fprintf(stderr, "Unknown attribute '%c'\n", *spec);
+ }
+ spec++;
+ }
}
void res_delete(struct resource *r)
More information about the Debootloaders-devel
mailing list