[615] | 1 | /* $NetBSD: setmode.c,v 1.30 2003/08/07 16:42:56 agc Exp $ */
|
---|
| 2 |
|
---|
[227] | 3 | /*
|
---|
| 4 | * Copyright (c) 1989, 1993, 1994
|
---|
| 5 | * The Regents of the University of California. All rights reserved.
|
---|
| 6 | *
|
---|
| 7 | * This code is derived from software contributed to Berkeley by
|
---|
| 8 | * Dave Borman at Cray Research, Inc.
|
---|
| 9 | *
|
---|
| 10 | * Redistribution and use in source and binary forms, with or without
|
---|
| 11 | * modification, are permitted provided that the following conditions
|
---|
| 12 | * are met:
|
---|
| 13 | * 1. Redistributions of source code must retain the above copyright
|
---|
| 14 | * notice, this list of conditions and the following disclaimer.
|
---|
| 15 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
| 16 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 17 | * documentation and/or other materials provided with the distribution.
|
---|
[615] | 18 | * 3. Neither the name of the University nor the names of its contributors
|
---|
[227] | 19 | * may be used to endorse or promote products derived from this software
|
---|
| 20 | * without specific prior written permission.
|
---|
| 21 | *
|
---|
| 22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
---|
| 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
---|
| 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
---|
| 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
---|
| 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
---|
| 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
---|
| 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
---|
| 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
---|
| 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
---|
| 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
| 32 | * SUCH DAMAGE.
|
---|
| 33 | */
|
---|
| 34 |
|
---|
[1222] | 35 | #if 0
|
---|
[227] | 36 | #if defined(LIBC_SCCS) && !defined(lint)
|
---|
| 37 | static char sccsid[] = "@(#)setmode.c 8.2 (Berkeley) 3/25/94";
|
---|
[615] | 38 | #else
|
---|
| 39 | __RCSID("$NetBSD: setmode.c,v 1.30 2003/08/07 16:42:56 agc Exp $");
|
---|
[1222] | 40 | #endif /* LIBC_SCCS and not lint */
|
---|
[615] | 41 | #endif
|
---|
[227] | 42 |
|
---|
| 43 | #include <sys/types.h>
|
---|
| 44 | #include <sys/stat.h>
|
---|
| 45 |
|
---|
| 46 | #include <ctype.h>
|
---|
[615] | 47 | #include <errno.h>
|
---|
[227] | 48 | #include <stdlib.h>
|
---|
[1221] | 49 | #include "shinstance.h" /* for unistd.h types/defines */
|
---|
[227] | 50 |
|
---|
| 51 | #ifdef SETMODE_DEBUG
|
---|
| 52 | #include <stdio.h>
|
---|
| 53 | #endif
|
---|
| 54 |
|
---|
| 55 | #define SET_LEN 6 /* initial # of bitcmd struct to malloc */
|
---|
| 56 | #define SET_LEN_INCR 4 /* # of bitcmd structs to add as needed */
|
---|
| 57 |
|
---|
| 58 | typedef struct bitcmd {
|
---|
| 59 | char cmd;
|
---|
| 60 | char cmd2;
|
---|
| 61 | mode_t bits;
|
---|
| 62 | } BITCMD;
|
---|
| 63 |
|
---|
| 64 | #define CMD2_CLR 0x01
|
---|
| 65 | #define CMD2_SET 0x02
|
---|
| 66 | #define CMD2_GBITS 0x04
|
---|
| 67 | #define CMD2_OBITS 0x08
|
---|
| 68 | #define CMD2_UBITS 0x10
|
---|
| 69 |
|
---|
[1222] | 70 | static BITCMD *addcmd(BITCMD *, int, int, int, unsigned int);
|
---|
[616] | 71 | static void compress_mode(BITCMD *);
|
---|
[227] | 72 | #ifdef SETMODE_DEBUG
|
---|
[616] | 73 | static void dumpmode(BITCMD *);
|
---|
[227] | 74 | #endif
|
---|
| 75 |
|
---|
[616] | 76 | #ifndef _DIAGASSERT
|
---|
[3477] | 77 | # define _DIAGASSERT kHlpAssert
|
---|
[1221] | 78 | #endif
|
---|
[616] | 79 |
|
---|
| 80 | #ifndef S_ISTXT
|
---|
| 81 | # ifdef S_ISVTX
|
---|
| 82 | # define S_ISTXT S_ISVTX
|
---|
| 83 | # else
|
---|
| 84 | # define S_ISTXT 0
|
---|
| 85 | # endif
|
---|
| 86 | #endif /* !S_ISTXT */
|
---|
| 87 |
|
---|
[227] | 88 | /*
|
---|
| 89 | * Given the old mode and an array of bitcmd structures, apply the operations
|
---|
| 90 | * described in the bitcmd structures to the old mode, and return the new mode.
|
---|
| 91 | * Note that there is no '=' command; a strict assignment is just a '-' (clear
|
---|
| 92 | * bits) followed by a '+' (set bits).
|
---|
| 93 | */
|
---|
| 94 | mode_t
|
---|
[2498] | 95 | kash_getmode(const void *bbox, mode_t omode)
|
---|
[227] | 96 | {
|
---|
| 97 | const BITCMD *set;
|
---|
| 98 | mode_t clrval, newmode, value;
|
---|
| 99 |
|
---|
[615] | 100 | _DIAGASSERT(bbox != NULL);
|
---|
| 101 |
|
---|
[227] | 102 | set = (const BITCMD *)bbox;
|
---|
| 103 | newmode = omode;
|
---|
| 104 | for (value = 0;; set++)
|
---|
| 105 | switch(set->cmd) {
|
---|
| 106 | /*
|
---|
| 107 | * When copying the user, group or other bits around, we "know"
|
---|
| 108 | * where the bits are in the mode so that we can do shifts to
|
---|
| 109 | * copy them around. If we don't use shifts, it gets real
|
---|
| 110 | * grundgy with lots of single bit checks and bit sets.
|
---|
| 111 | */
|
---|
| 112 | case 'u':
|
---|
| 113 | value = (newmode & S_IRWXU) >> 6;
|
---|
| 114 | goto common;
|
---|
| 115 |
|
---|
| 116 | case 'g':
|
---|
| 117 | value = (newmode & S_IRWXG) >> 3;
|
---|
| 118 | goto common;
|
---|
| 119 |
|
---|
| 120 | case 'o':
|
---|
| 121 | value = newmode & S_IRWXO;
|
---|
| 122 | common: if (set->cmd2 & CMD2_CLR) {
|
---|
| 123 | clrval =
|
---|
| 124 | (set->cmd2 & CMD2_SET) ? S_IRWXO : value;
|
---|
| 125 | if (set->cmd2 & CMD2_UBITS)
|
---|
| 126 | newmode &= ~((clrval<<6) & set->bits);
|
---|
| 127 | if (set->cmd2 & CMD2_GBITS)
|
---|
| 128 | newmode &= ~((clrval<<3) & set->bits);
|
---|
| 129 | if (set->cmd2 & CMD2_OBITS)
|
---|
| 130 | newmode &= ~(clrval & set->bits);
|
---|
| 131 | }
|
---|
| 132 | if (set->cmd2 & CMD2_SET) {
|
---|
| 133 | if (set->cmd2 & CMD2_UBITS)
|
---|
| 134 | newmode |= (value<<6) & set->bits;
|
---|
| 135 | if (set->cmd2 & CMD2_GBITS)
|
---|
| 136 | newmode |= (value<<3) & set->bits;
|
---|
| 137 | if (set->cmd2 & CMD2_OBITS)
|
---|
| 138 | newmode |= value & set->bits;
|
---|
| 139 | }
|
---|
| 140 | break;
|
---|
| 141 |
|
---|
| 142 | case '+':
|
---|
| 143 | newmode |= set->bits;
|
---|
| 144 | break;
|
---|
| 145 |
|
---|
| 146 | case '-':
|
---|
| 147 | newmode &= ~set->bits;
|
---|
| 148 | break;
|
---|
| 149 |
|
---|
| 150 | case 'X':
|
---|
| 151 | if (omode & (S_IFDIR|S_IXUSR|S_IXGRP|S_IXOTH))
|
---|
| 152 | newmode |= set->bits;
|
---|
| 153 | break;
|
---|
| 154 |
|
---|
| 155 | case '\0':
|
---|
| 156 | default:
|
---|
| 157 | #ifdef SETMODE_DEBUG
|
---|
| 158 | (void)printf("getmode:%04o -> %04o\n", omode, newmode);
|
---|
| 159 | #endif
|
---|
| 160 | return (newmode);
|
---|
| 161 | }
|
---|
| 162 | }
|
---|
| 163 |
|
---|
[615] | 164 | #define ADDCMD(a, b, c, d) do { \
|
---|
[227] | 165 | if (set >= endset) { \
|
---|
| 166 | BITCMD *newset; \
|
---|
| 167 | setlen += SET_LEN_INCR; \
|
---|
[2290] | 168 | newset = sh_realloc(NULL, saveset, sizeof(BITCMD) * setlen); \
|
---|
[615] | 169 | if (newset == NULL) { \
|
---|
[2290] | 170 | sh_free(NULL, saveset); \
|
---|
[227] | 171 | return (NULL); \
|
---|
| 172 | } \
|
---|
| 173 | set = newset + (set - saveset); \
|
---|
| 174 | saveset = newset; \
|
---|
| 175 | endset = newset + (setlen - 2); \
|
---|
| 176 | } \
|
---|
[615] | 177 | set = addcmd(set, (a), (b), (c), (d)); \
|
---|
| 178 | } while (/*CONSTCOND*/0)
|
---|
[227] | 179 |
|
---|
| 180 | #define STANDARD_BITS (S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO)
|
---|
| 181 |
|
---|
| 182 | void *
|
---|
[2498] | 183 | kash_setmode(shinstance *psh, const char *p)
|
---|
[227] | 184 | {
|
---|
| 185 | int perm, who;
|
---|
| 186 | char op, *ep;
|
---|
| 187 | BITCMD *set, *saveset, *endset;
|
---|
| 188 | mode_t mask;
|
---|
[615] | 189 | int equalopdone = 0; /* pacify gcc */
|
---|
| 190 | int permXbits, setlen;
|
---|
[227] | 191 |
|
---|
| 192 | if (!*p)
|
---|
| 193 | return (NULL);
|
---|
| 194 |
|
---|
| 195 | /*
|
---|
| 196 | * Get a copy of the mask for the permissions that are mask relative.
|
---|
[1222] | 197 | * Flip the bits, we want what's not set.
|
---|
[227] | 198 | */
|
---|
[1222] | 199 | mask = shfile_get_umask(&psh->fdtab);
|
---|
[227] | 200 |
|
---|
| 201 | setlen = SET_LEN + 2;
|
---|
[1221] | 202 |
|
---|
[2290] | 203 | if ((set = sh_malloc(NULL, sizeof(BITCMD) * setlen)) == NULL)
|
---|
[227] | 204 | return (NULL);
|
---|
| 205 | saveset = set;
|
---|
| 206 | endset = set + (setlen - 2);
|
---|
| 207 |
|
---|
| 208 | /*
|
---|
| 209 | * If an absolute number, get it and return; disallow non-octal digits
|
---|
| 210 | * or illegal bits.
|
---|
| 211 | */
|
---|
| 212 | if (isdigit((unsigned char)*p)) {
|
---|
[615] | 213 | perm = (mode_t)strtol(p, &ep, 8);
|
---|
| 214 | if (*ep || perm & ~(STANDARD_BITS|S_ISTXT)) {
|
---|
[2290] | 215 | sh_free(NULL, saveset);
|
---|
[227] | 216 | return (NULL);
|
---|
| 217 | }
|
---|
| 218 | ADDCMD('=', (STANDARD_BITS|S_ISTXT), perm, mask);
|
---|
| 219 | set->cmd = 0;
|
---|
| 220 | return (saveset);
|
---|
| 221 | }
|
---|
| 222 |
|
---|
| 223 | /*
|
---|
| 224 | * Build list of structures to set/clear/copy bits as described by
|
---|
| 225 | * each clause of the symbolic mode.
|
---|
| 226 | */
|
---|
| 227 | for (;;) {
|
---|
| 228 | /* First, find out which bits might be modified. */
|
---|
| 229 | for (who = 0;; ++p) {
|
---|
| 230 | switch (*p) {
|
---|
| 231 | case 'a':
|
---|
| 232 | who |= STANDARD_BITS;
|
---|
| 233 | break;
|
---|
| 234 | case 'u':
|
---|
| 235 | who |= S_ISUID|S_IRWXU;
|
---|
| 236 | break;
|
---|
| 237 | case 'g':
|
---|
| 238 | who |= S_ISGID|S_IRWXG;
|
---|
| 239 | break;
|
---|
| 240 | case 'o':
|
---|
| 241 | who |= S_IRWXO;
|
---|
| 242 | break;
|
---|
| 243 | default:
|
---|
| 244 | goto getop;
|
---|
| 245 | }
|
---|
| 246 | }
|
---|
| 247 |
|
---|
| 248 | getop: if ((op = *p++) != '+' && op != '-' && op != '=') {
|
---|
[2290] | 249 | sh_free(NULL, saveset);
|
---|
[227] | 250 | return (NULL);
|
---|
| 251 | }
|
---|
| 252 | if (op == '=')
|
---|
| 253 | equalopdone = 0;
|
---|
| 254 |
|
---|
| 255 | who &= ~S_ISTXT;
|
---|
| 256 | for (perm = 0, permXbits = 0;; ++p) {
|
---|
| 257 | switch (*p) {
|
---|
| 258 | case 'r':
|
---|
| 259 | perm |= S_IRUSR|S_IRGRP|S_IROTH;
|
---|
| 260 | break;
|
---|
| 261 | case 's':
|
---|
[615] | 262 | /*
|
---|
[1221] | 263 | * If specific bits where requested and
|
---|
| 264 | * only "other" bits ignore set-id.
|
---|
[615] | 265 | */
|
---|
| 266 | if (who == 0 || (who & ~S_IRWXO))
|
---|
[227] | 267 | perm |= S_ISUID|S_ISGID;
|
---|
| 268 | break;
|
---|
| 269 | case 't':
|
---|
[615] | 270 | /*
|
---|
[1221] | 271 | * If specific bits where requested and
|
---|
| 272 | * only "other" bits ignore set-id.
|
---|
[615] | 273 | */
|
---|
| 274 | if (who == 0 || (who & ~S_IRWXO)) {
|
---|
[227] | 275 | who |= S_ISTXT;
|
---|
| 276 | perm |= S_ISTXT;
|
---|
| 277 | }
|
---|
| 278 | break;
|
---|
| 279 | case 'w':
|
---|
| 280 | perm |= S_IWUSR|S_IWGRP|S_IWOTH;
|
---|
| 281 | break;
|
---|
| 282 | case 'X':
|
---|
| 283 | permXbits = S_IXUSR|S_IXGRP|S_IXOTH;
|
---|
| 284 | break;
|
---|
| 285 | case 'x':
|
---|
| 286 | perm |= S_IXUSR|S_IXGRP|S_IXOTH;
|
---|
| 287 | break;
|
---|
| 288 | case 'u':
|
---|
| 289 | case 'g':
|
---|
| 290 | case 'o':
|
---|
| 291 | /*
|
---|
| 292 | * When ever we hit 'u', 'g', or 'o', we have
|
---|
| 293 | * to flush out any partial mode that we have,
|
---|
| 294 | * and then do the copying of the mode bits.
|
---|
| 295 | */
|
---|
| 296 | if (perm) {
|
---|
| 297 | ADDCMD(op, who, perm, mask);
|
---|
| 298 | perm = 0;
|
---|
| 299 | }
|
---|
| 300 | if (op == '=')
|
---|
| 301 | equalopdone = 1;
|
---|
| 302 | if (op == '+' && permXbits) {
|
---|
| 303 | ADDCMD('X', who, permXbits, mask);
|
---|
| 304 | permXbits = 0;
|
---|
| 305 | }
|
---|
| 306 | ADDCMD(*p, who, op, mask);
|
---|
| 307 | break;
|
---|
| 308 |
|
---|
| 309 | default:
|
---|
| 310 | /*
|
---|
| 311 | * Add any permissions that we haven't already
|
---|
| 312 | * done.
|
---|
| 313 | */
|
---|
| 314 | if (perm || (op == '=' && !equalopdone)) {
|
---|
| 315 | if (op == '=')
|
---|
| 316 | equalopdone = 1;
|
---|
| 317 | ADDCMD(op, who, perm, mask);
|
---|
| 318 | perm = 0;
|
---|
| 319 | }
|
---|
| 320 | if (permXbits) {
|
---|
| 321 | ADDCMD('X', who, permXbits, mask);
|
---|
| 322 | permXbits = 0;
|
---|
| 323 | }
|
---|
| 324 | goto apply;
|
---|
| 325 | }
|
---|
| 326 | }
|
---|
| 327 |
|
---|
| 328 | apply: if (!*p)
|
---|
| 329 | break;
|
---|
| 330 | if (*p != ',')
|
---|
| 331 | goto getop;
|
---|
| 332 | ++p;
|
---|
| 333 | }
|
---|
| 334 | set->cmd = 0;
|
---|
| 335 | #ifdef SETMODE_DEBUG
|
---|
| 336 | (void)printf("Before compress_mode()\n");
|
---|
| 337 | dumpmode(saveset);
|
---|
| 338 | #endif
|
---|
| 339 | compress_mode(saveset);
|
---|
| 340 | #ifdef SETMODE_DEBUG
|
---|
| 341 | (void)printf("After compress_mode()\n");
|
---|
| 342 | dumpmode(saveset);
|
---|
| 343 | #endif
|
---|
| 344 | return (saveset);
|
---|
| 345 | }
|
---|
| 346 |
|
---|
| 347 | static BITCMD *
|
---|
| 348 | addcmd(set, op, who, oparg, mask)
|
---|
| 349 | BITCMD *set;
|
---|
| 350 | int oparg, who;
|
---|
| 351 | int op;
|
---|
[1222] | 352 | unsigned int mask;
|
---|
[227] | 353 | {
|
---|
[615] | 354 |
|
---|
| 355 | _DIAGASSERT(set != NULL);
|
---|
| 356 |
|
---|
[227] | 357 | switch (op) {
|
---|
| 358 | case '=':
|
---|
| 359 | set->cmd = '-';
|
---|
| 360 | set->bits = who ? who : STANDARD_BITS;
|
---|
| 361 | set++;
|
---|
| 362 |
|
---|
| 363 | op = '+';
|
---|
| 364 | /* FALLTHROUGH */
|
---|
| 365 | case '+':
|
---|
| 366 | case '-':
|
---|
| 367 | case 'X':
|
---|
| 368 | set->cmd = op;
|
---|
[2312] | 369 | set->bits = (who ? (unsigned int)who : mask) & (unsigned int)oparg;
|
---|
[227] | 370 | break;
|
---|
| 371 |
|
---|
| 372 | case 'u':
|
---|
| 373 | case 'g':
|
---|
| 374 | case 'o':
|
---|
| 375 | set->cmd = op;
|
---|
| 376 | if (who) {
|
---|
| 377 | set->cmd2 = ((who & S_IRUSR) ? CMD2_UBITS : 0) |
|
---|
| 378 | ((who & S_IRGRP) ? CMD2_GBITS : 0) |
|
---|
| 379 | ((who & S_IROTH) ? CMD2_OBITS : 0);
|
---|
| 380 | set->bits = (mode_t)~0;
|
---|
| 381 | } else {
|
---|
| 382 | set->cmd2 = CMD2_UBITS | CMD2_GBITS | CMD2_OBITS;
|
---|
| 383 | set->bits = mask;
|
---|
| 384 | }
|
---|
[1221] | 385 |
|
---|
[227] | 386 | if (oparg == '+')
|
---|
| 387 | set->cmd2 |= CMD2_SET;
|
---|
| 388 | else if (oparg == '-')
|
---|
| 389 | set->cmd2 |= CMD2_CLR;
|
---|
| 390 | else if (oparg == '=')
|
---|
| 391 | set->cmd2 |= CMD2_SET|CMD2_CLR;
|
---|
| 392 | break;
|
---|
| 393 | }
|
---|
| 394 | return (set + 1);
|
---|
| 395 | }
|
---|
| 396 |
|
---|
| 397 | #ifdef SETMODE_DEBUG
|
---|
| 398 | static void
|
---|
| 399 | dumpmode(set)
|
---|
| 400 | BITCMD *set;
|
---|
| 401 | {
|
---|
[615] | 402 |
|
---|
| 403 | _DIAGASSERT(set != NULL);
|
---|
| 404 |
|
---|
[227] | 405 | for (; set->cmd; ++set)
|
---|
| 406 | (void)printf("cmd: '%c' bits %04o%s%s%s%s%s%s\n",
|
---|
| 407 | set->cmd, set->bits, set->cmd2 ? " cmd2:" : "",
|
---|
| 408 | set->cmd2 & CMD2_CLR ? " CLR" : "",
|
---|
| 409 | set->cmd2 & CMD2_SET ? " SET" : "",
|
---|
| 410 | set->cmd2 & CMD2_UBITS ? " UBITS" : "",
|
---|
| 411 | set->cmd2 & CMD2_GBITS ? " GBITS" : "",
|
---|
| 412 | set->cmd2 & CMD2_OBITS ? " OBITS" : "");
|
---|
| 413 | }
|
---|
| 414 | #endif
|
---|
| 415 |
|
---|
| 416 | /*
|
---|
| 417 | * Given an array of bitcmd structures, compress by compacting consecutive
|
---|
| 418 | * '+', '-' and 'X' commands into at most 3 commands, one of each. The 'u',
|
---|
[1221] | 419 | * 'g' and 'o' commands continue to be separate. They could probably be
|
---|
[227] | 420 | * compacted, but it's not worth the effort.
|
---|
| 421 | */
|
---|
| 422 | static void
|
---|
| 423 | compress_mode(set)
|
---|
| 424 | BITCMD *set;
|
---|
| 425 | {
|
---|
| 426 | BITCMD *nset;
|
---|
| 427 | int setbits, clrbits, Xbits, op;
|
---|
| 428 |
|
---|
[615] | 429 | _DIAGASSERT(set != NULL);
|
---|
| 430 |
|
---|
[227] | 431 | for (nset = set;;) {
|
---|
| 432 | /* Copy over any 'u', 'g' and 'o' commands. */
|
---|
| 433 | while ((op = nset->cmd) != '+' && op != '-' && op != 'X') {
|
---|
| 434 | *set++ = *nset++;
|
---|
| 435 | if (!op)
|
---|
| 436 | return;
|
---|
| 437 | }
|
---|
| 438 |
|
---|
| 439 | for (setbits = clrbits = Xbits = 0;; nset++) {
|
---|
| 440 | if ((op = nset->cmd) == '-') {
|
---|
| 441 | clrbits |= nset->bits;
|
---|
| 442 | setbits &= ~nset->bits;
|
---|
| 443 | Xbits &= ~nset->bits;
|
---|
| 444 | } else if (op == '+') {
|
---|
| 445 | setbits |= nset->bits;
|
---|
| 446 | clrbits &= ~nset->bits;
|
---|
| 447 | Xbits &= ~nset->bits;
|
---|
| 448 | } else if (op == 'X')
|
---|
| 449 | Xbits |= nset->bits & ~setbits;
|
---|
| 450 | else
|
---|
| 451 | break;
|
---|
| 452 | }
|
---|
| 453 | if (clrbits) {
|
---|
| 454 | set->cmd = '-';
|
---|
| 455 | set->cmd2 = 0;
|
---|
| 456 | set->bits = clrbits;
|
---|
| 457 | set++;
|
---|
| 458 | }
|
---|
| 459 | if (setbits) {
|
---|
| 460 | set->cmd = '+';
|
---|
| 461 | set->cmd2 = 0;
|
---|
| 462 | set->bits = setbits;
|
---|
| 463 | set++;
|
---|
| 464 | }
|
---|
| 465 | if (Xbits) {
|
---|
| 466 | set->cmd = 'X';
|
---|
| 467 | set->cmd2 = 0;
|
---|
| 468 | set->bits = Xbits;
|
---|
| 469 | set++;
|
---|
| 470 | }
|
---|
| 471 | }
|
---|
| 472 | }
|
---|