Ref: 11640048
Title: Documentation for CONFIG.SYS Editor
Date: 10/2/89

Copyright 3Com Corporation, 1991.  All rights reserved.

This article tells how to use CSED, a Config.Sys EDitor used during the
installation of some 3+ services.  The program CSED.EXE can be found on
3+ service installation diskettes.

Note:  3Com supports the use of CSED.EXE only with 3+ services installation
and tuning processes.  3Com does not support the use of CSED.EXE on other
files.  Use the program at your own risk.


CSED is a command line editor for the file CONFIG.SYS, which MS-DOS uses to
load drivers.  CSED is somewhat like a stream editor and can be given a series
of commands all in a batch file to be processed in sequence.  It assumes that
the CONFIG.SYS file exists in the root directory of the current drive
\CONFIG.SYS.

All commands are entered on the DOS command line as arguments to CSED.
Special flags tell CSED what to do.  Errors are flagged by setting the
ERRORLEVEL environment variable to values determined by the specific error.

There is no limit to the size of the file being edited.  CSED writes to a
temporary file during its operations.

The list of valid flags is as follows:

    -a  (/a):          insert a line AFTER another line
    -b  (/b):          insert a line BEFORE another line
    -d  (/d):          DELETE line(s)
    -e  (/e):          check for the EXISTence of a pattern in the file
    -f  (/f):          change the default FILE to modify
    -i  (/i):          INSERT a line
    -r  (/r):          REPLACE line(s)
    -S  (/s):          SET the parameters on line(s)


The ERRORLEVELs set is as follows:

    0:                 No error
    1:                 Syntax Error
    2:                 Line not found (only applicable for '-el and '-s')
    3:                 Disk Error


CSED Commands

Most of the commands accept wildcards (the usual '*' and '?').  To find all
lines with a string "string", then you must specify "*string*". The
specification "string" will only find lines which contain the characters
S-T-R-I-N-G and nothing else.  Similarly, "string*" will find all lines
beginning with STRING, and "*string" will find all lines ending with STRING.

The program is not case-sensitive.  In other words, "String" will match
"STRING", "string", and "StRiNg".


------------------------------------
AFTER:           A> csed /a <pattern> <string>

The AFTER command is used to find the first line in the file
that matches the given pattern.  (Wildcards '*' and '?' are accepted.)
Then, a new line is inserted just after this line, with <string> as its
contents.  If no line matches the pattern, the program returns
with ERRORLEVEL set to "Line Not Found".  Quotes are only
necessary around <pattern> if the pattern has spaces in it.  Quotes
are optional for <string>.

Example:         A> csed /a "tdrive.sys" "Insert after tdrive.sys"


-------------------------------------
BEFORE:          A> csed /b <pattern> <string>

Same as AFTER, except the line is inserted BEFORE the pattern
matching line.

Example:         A> csed /b "tdrive.sys" "Goes before tdrive.sys"


------------------------------------
DELETE:          A> csed /d <pattern>

The DELETE command will look at all the lines in the CONFIG.SYS
file and delete those that have any part matching the given
pattern.  Wildcards '*' and '?' are accepted.  Quotes may be used, but
are not needed.

Examples:        A> csed /d "dev*=tdrive*"
                 A> csed /d ???ice=t???ve.sys

                          will both delete the line

                 device=tdrive.sys


-----------------------------------------------
EXISTence Check:     A> csed /e <pattern>

The EXIST command will look at all the lines in the CONFIG.SYS
file and simply check to see if the given pattern <pattern> exists
anywhere.  Wildcards '*' and '?' are accepted.  Quotes may be used, but
are not needed.  The ERRORLEVEL will be 0 if the pattern is found, else
it will be 2.

Examples:        A> csed /e "dev*=tdrive.sys"
                 A> csed /e ???ice=t??ve.sys

                          will both return ERRORLEVEL=O if the line
                 device=tdrive.sys
                          exists in the file, else it will return 2.


-----------------------------------------------
FILE:             A> csed /f <filename> /[abdeirs] ....

Use the FILE switch to override the default file selected (which
is \CONFIG.SYS). If this switch is used, it must be the FIRST
switch in the command line.  No quotes should be used around the
filename.

Example:          A> csed /f C:\AUTOEXEC.BAT /i :error_label

This example will open the AUTOEXEC.BAT file and put the label
":error_label" as the last line in the file.


------------------------------------
INSERT:           A> csed /i <string>

The INSERT command will create a new line and place <string> into
it, thus making a new line into the CONFIG.SYS file.  Quotes may
be used, but are not needed.

Examples:         A> csed /i "device=tdrive.sys"
                  A> csed /i device = tdrive.sys


-------------------------------------
REPLACE:          A> csed /r <pattern> <string>

Use this to find a line or lines to delete (if they exist) and
then to replace it with another line given in string.  The same
pattern matching in <pattern> applies as in DELETE.  Quotes are
needed if <pattern> contains spaces (or else only the first word
is used as the pattern match).  Quotes are optional for <string>.

Examples:         A> csed /r "de*tdrive.sys" device=pro3.sys 0 3
                  A> csed /r device=* device=pro3.sys 0 0

The first case will delete the line

                  device=tdrive.sys

and add the line

                  device=pro3.sys 0 3

The second case will replace all the devices (if there is no space
between the word "device" and the "=") and put a new one in:

                  device=pro3.sys 0 0


--------------------------------------------
SET:              A> csed /s <half-pattern> <parms>

SET is a specific command used to find all lines matching the
<half-pattern> and changing the remainder of the line to <parms>.
A <half-pattern> is the same as a full pattern except no '*'s are
allowed.

Examples:       A> csed /s pr?3.sys 0 1 -b

might change the line
                pro3.sys 2 4 6
to
                pro3.sys 0 1 -b

