Resource Index

Quick Links

Infsect is an INF/INI file manipulation utility for the command line. It has a number of advantages over some other INI editors, such as the ability to use the program itself to prompt for input when executed in a batch script.

While derived from a Bash script in the original incarnation of Hierma, it is a total rewrite in the C language, easily making it around 20x faster. Its original goal was to be a part of a new, DOS-based Hierma, but that has not made any progress since this program was first written.

Version 0.3

This is a bugfix release, making the program more usable on Unix/Linux as well as in DOS/Win32. It also raises some arbitrary limits that the previous version of Infsect suffered from, particularly the file name length.

Note that if you use Infsect on a CRLF file in a Unix environment, CRLFs will be converted to LFs by this program, so remember to use unix2dos to convert them back to the native line break format used by DOS and Windows if you intend to use your INFs there.

Floppy disk Download Infsect 0.3 (MS-DOS, 13.4 KB)

Floppy disk Download Infsect 0.3 (Win32, 36 KB)

Floppy disk Download source code (4.1 KB)

View change log

Version 0.2

Once again, Infsect is completely rewritten, this time with a modest DOS-first approach. The fundamental problem with the last version was that it was trying to do too much all at once right from the start, all for a larger thing that never took off. After being tested in both MS-DOS and Win32, Infsect 0.2 should be better suited as a standalone utility for certain routines. It promises less functionality than the last version, but hey, at least it works now.

Knowing that not very many people are going to end up using this as I previously imagined, I ditched the GPL for it and released every bit of it into the public domain, so it can be used and modified without any restrictions.

System Recommendations and Running

The supplied MS-DOS executable is compiled to run on anything as low as the Intel 8088 CPU, found in IBM XTs. It is recommended that you use MS-DOS 3.30 or later, and have 256KB of RAM or more. The Win32 executable requires Windows 95, Windows NT, or later, and is absolutely necessary for 64-bit versions of Windows.

Infsect should be highly portable to other operating systems as it only requires standard C libraries. To compile this program for something like Linux, all you need to do is run a command like this (assuming you have GCC installed):

gcc main.c -o ~/opt/bin/infsect

The -o switch followed by a path generates an executable named infsect located at opt/bin in your home directory. Make sure infsect.h is present in the same directory as main.c.

How to Use

If you type infsect -h (or no switches at all), this message is displayed:

INFSECT Version 0.3 compiled Mon Aug 30 02:40:19 2021
Released to the public domain

 infsect [file] -s [section] [-g | -i | -d] [field | field=value]
 infsect [file] -k [section]

General switches:
	[file]		Name of file
	-s		Section name
	-g		Read or write field value (trail with =value to write)
	-d		Delete a field
	-i		Interactive prompt to input value

Alternate switches:
	-k		Delete a section

Program information:
	-h		Display this usage reference
	-v		Display program version

Use of this program requires at least some understanding of the structure of INF files or anything else this covers. As for how this program is used, it would be best to look at some examples...

We'll use this sample file to experiment with the tool:

Signature	= "$CHICAGO$"
SetupClass	= BASE

FamilyValues	= NO	; Comment
;Ignore		= YES
DoNotIgnore	= huh?, UNACCEPTABLE

Value		= Value1

Value		= Value2
Which		= C:\WINDOWS


Retrieve a value

Here, I want to retrieve the value stored in the field Value at [Section]. To do this, I type:

infsect test.inf -s section -g value

and this is returned to standard output:


Note that Infsect is not case sensitive when it comes to specifying the names of sections or fields, respecting the case insensitive nature of Windows. As such, you can type a section name in all lowercase letters even if it uses title casing.

If you were to try to retrive the value from the field Ignore in [SectionOther], it would not be picked up because the field is cancelled out by a semicolon comment marker. [1]

If a field contains a value surrounded by quote marks, the quote marks are returned alongside the value.

infsect test.inf -s section -g quote

Assign a new value

To put a new value in a field, the same -g switch is used, but this time the field name is immediately followed by an equals symbol (=). This tells the program you intend to overwrite an existing field with a new value, or create a new field.

To create a new field NewVal storing the value Purplefish, you would type:

infsect test.inf -s section -g NewVal=Purplefish

If you check the file now, [Section] will look something like this:

NewVal = Purplefish
Value		= Value1

To overwrite the value in Value with BrandNew, type:

infsect test.inf -s section -g value=BrandNew

and the section will look like this:

NewVal = Purplefish
value = BrandNew

Note that while it knows to overwrite Value in title casing even when typing value in lowercase, Infsect also changes the casing of the field name to what the user specifies. Also keep in mind that there must be NO whitespace surrounding the equals sign.

To enter a value with spaces surrounded by quote marks, you type:

infsect test.inf -s section -g Value="\"Brand New\""

\" is an escape character for a literal quote mark. The two escape quotes should be sandwiched inside the outermost standalone quote marks, which are used to actually tell the program you're writing a single argument. You can also write the command like this if desired:

infsect test.inf -s section -g "Value=\"Brand New\""

You can also create a new section by adding a field to it, like this:

infsect test.inf -s newsect -g twest -v ok

Prompt user to assign new value

Instead of dealing with extra programs like PUTINENV, you can tell Infsect to prompt the user for a value to assign when you call the program from a batch script. You can type something like this:

infsect test.inf -s section -i Value

When run this way, the user is given the above message and must type a new value themselves before proceeding.

Value: egg

If the user inputs egg, that becomes the new value of Value. If no value is entered, the existing one remains unaffected. If you want to use a default value when the user enters nothing, you'd type something like this:

infsect test.inf -s section -i Value=salad

This ensures that the value salad will be entered if the user doesn't input anything.

Delete a field

To delete a field outright, replace -g with -d followed by the field name, like this:

infsect test.inf -s section -d Value

What's Next?

Obviously, Infsect has to get back up to par with what it was earlier. The "start small" approach worked very well and may be enough for most people, but just in case, I might want to add more things to it like the ability to manipulate subvalues within values later on when I get the time.

Now that Infsect is in a decent position, it'll also allow me to bring about a really cool guide in the future which will need this program. Beyond that, it's not much, but it's a small victory in the way of getting myself into the kind of programming I want to do.


1 Currently, Infsect does not actually skip comments. This will be addressed in a future release.