Annotation of Net2/ddb/db_write_cmd.c, revision 1.1.1.2

1.1       root        1: /* 
                      2:  * Mach Operating System
                      3:  * Copyright (c) 1991,1990 Carnegie Mellon University
                      4:  * All Rights Reserved.
                      5:  * 
                      6:  * Permission to use, copy, modify and distribute this software and its
                      7:  * documentation is hereby granted, provided that both the copyright
                      8:  * notice and this permission notice appear in all copies of the
                      9:  * software, derivative works or modified versions, and any portions
                     10:  * thereof, and that both notices appear in supporting documentation.
                     11:  * 
                     12:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS 
                     13:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
                     14:  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
                     15:  * 
                     16:  * Carnegie Mellon requests users of this software to return to
                     17:  * 
                     18:  *  Software Distribution Coordinator  or  [email protected]
                     19:  *  School of Computer Science
                     20:  *  Carnegie Mellon University
                     21:  *  Pittsburgh PA 15213-3890
                     22:  * 
                     23:  * any improvements or extensions that they make and grant Carnegie the
                     24:  * rights to redistribute these changes.
                     25:  */
                     26: /*
                     27:  * HISTORY
                     28:  * $Log: db_write_cmd.c,v $
1.1.1.2 ! root       29:  * Revision 1.1.1.1  1993/03/21 09:46:27  cgd
        !            30:  * initial import of 386bsd-0.1 sources
        !            31:  *
1.1       root       32:  * Revision 1.1  1992/03/25  21:45:42  pace
                     33:  * Initial revision
                     34:  *
                     35:  * Revision 2.4  91/02/05  17:07:35  mrt
                     36:  *     Changed to new Mach copyright
                     37:  *     [91/01/31  16:20:19  mrt]
                     38:  * 
                     39:  * Revision 2.3  90/10/25  14:44:26  rwd
                     40:  *     Changed db_write_cmd to print unsigned.
                     41:  *     [90/10/19            rpd]
                     42:  * 
                     43:  * Revision 2.2  90/08/27  21:53:54  dbg
                     44:  *     Set db_prev and db_next instead of explicitly advancing dot.
                     45:  *     [90/08/22            dbg]
                     46:  *     Reflected changes in db_printsym()'s calling seq.
                     47:  *     [90/08/20            af]
                     48:  *     Warn user if nothing was written.
                     49:  *     [90/08/07            dbg]
                     50:  *     Created.
                     51:  *     [90/07/25            dbg]
                     52:  * 
                     53:  */
                     54: /*
                     55:  *     Author: David B. Golub,  Carnegie Mellon University
                     56:  *     Date:   7/90
                     57:  */
                     58: 
                     59: #include "param.h"
                     60: #include "proc.h"
                     61: #include <machine/db_machdep.h>
                     62: 
                     63: #include <ddb/db_lex.h>
                     64: #include <ddb/db_access.h>
                     65: #include <ddb/db_command.h>
                     66: #include <ddb/db_sym.h>
                     67: 
                     68: /*
                     69:  * Write to file.
                     70:  */
                     71: /*ARGSUSED*/
                     72: void
                     73: db_write_cmd(address, have_addr, count, modif)
                     74:        db_expr_t       address;
                     75:        boolean_t       have_addr;
                     76:        db_expr_t       count;
                     77:        char *          modif;
                     78: {
                     79:        register
                     80:        db_addr_t       addr;
                     81:        register
                     82:        db_expr_t       old_value;
                     83:        db_expr_t       new_value;
                     84:        register int    size;
                     85:        boolean_t       wrote_one = FALSE;
                     86: 
                     87:        addr = (db_addr_t) address;
                     88: 
                     89:        switch (modif[0]) {
                     90:            case 'b':
                     91:                size = 1;
                     92:                break;
                     93:            case 'h':
                     94:                size = 2;
                     95:                break;
                     96:            case 'l':
                     97:            case '\0':
                     98:                size = 4;
                     99:                break;
                    100:            default:
                    101:                db_error("Unknown size\n");
                    102:                return;
                    103:        }
                    104: 
                    105:        while (db_expression(&new_value)) {
                    106:            old_value = db_get_value(addr, size, FALSE);
                    107:            db_printsym(addr, DB_STGY_ANY);
                    108:            db_printf("\t\t%#8n\t=\t%#8n\n", old_value, new_value);
                    109:            db_put_value(addr, size, new_value);
                    110:            addr += size;
                    111: 
                    112:            wrote_one = TRUE;
                    113:        }
                    114: 
                    115:        if (!wrote_one)
                    116:            db_error("Nothing written.\n");
                    117: 
                    118:        db_next = addr;
                    119:        db_prev = addr - size;
                    120: 
                    121:        db_skip_to_eol();
                    122: }
                    123: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.