Skip to content
A command-line editor and web browser.
C Perl C++ eC JavaScript CMake Other
Find file

README

edbrowse, a line oriented editor browser.
Written and maintained by Chris Brannon and Karl Dahlke.
See our home page edbrowse.org for current releases and contact information.

See COPYING for licensing agreements.

------------------------------------------------------------

Disclaimer: this software is provided as-is,
with no guarantee that it will perform as expected.
It might trash your precious files.
It might send bad data across the Internet,
causing you to buy a $37,000 elephant instead of
$37 worth of printer supplies.
It may delete all the rows in your mysql customer table.
Use this program at your own risk.

------------------------------------------------------------

Netscape and Explorer are graphical browsers.
Lynx and Links are screen browsers.
This is a command line browser, the only one of its kind.
The user's guide can be found in doc/usersguide.html (in this package).
Of course this reasoning is a bit circular.
You need to use a browser to read the documentation,
which describes how to use the browser.
Well you can always do this:

cd doc ; lynx -dump usersguide.html >usersguide.txt

This produces the documentation in text form,
which you can read using your favorite editor.
Of course we hope edbrowse will eventually become your
favorite editor, whence you can browse the documentation directly.
The doc directory also includes a sample config file.

------------------------------------------------------------

Ok, I'm going to assume you've read the documentation.
No need to repeat all that here.
You're here because you want to compile and/or package the program,
or modify the source in some way.  Great!

cmake can be used to build and install edbrowse in Windows, linux, or Mac OS X.
visual C studio is assumed on Windows.
cd build
cmake .. [options]
make
Or, on linux, you can use the traditional makefiles.
cd src
make

On Mac OS X, you'll need to install tidy-html5.  It's not in macports
yet.  Tell cmake about its location like this:
export TIDY_ROOT=/path/to/tidy-html5
cd build
cmake ..
make
Be careful here.  Apple distributes an ancient version of tidy-html.
You're going to have to take steps to insure that they do not collide.
Perhaps your best bet is to get edbrowse from MacPorts.

As you may know, edbrowse was originally a perl script.
As such, it was only natural to use perl regular expressions for
the search/substitute functions in the editor.
Once you've experienced the power of perl regexp, you'll never
go back to ed.  So I use the perl compatible regular expression
library, /lib/libpcre.so.0, available on most Linux systems.
If you don't have this file, check your installation disks.
the pcre and pcre-devel packages might be there, just not installed.
You need version 8.10 or higher.

Note that my files include <pcre.h>.
Some distributions put it in /usr/include/pcre/pcre.h,
so you'll have to adjust the source, the -I path, or make a link.

You also need libcurl and libcurl-devel,
which is included in almost every Linux distro.
This is used for ftp, http, and https.
Check for /usr/include/curl/curl.h
Edbrowse requires version 7.29.0 or later.  If you compiled with a version
prior to 7.29.0, the program will inform you that you need to upgrade.
If you have to compile curl from source, be sure to specify
--ENABLE-VERSION-SYMBOLS (or some such) at the configure script.

Edbrowse now uses the tidy-html5 HTML parser.  So there are a couple
of things to install for this prerequisite.
The tidy-html5 compilation process uses cmake.  Please either use your
package manager to get cmake (for instance, apt-get install cmake),
or follow the instructions at http://www.cmake.org/download/

Once you have cmake, download the latest tidy-html5 code from:
https://github.com/htacg/tidy-html5/archive/master.zip
Unzip and cd to build/cmake
cmake ../..
make install
Now the latest tidy-html5 library will be available to edbrowse.
Edbrowse requires tidy-html5 version 5.1.25 or greater,
and might not work properly, or even compile with an earlier version.
Note that the latest tagged version is 5.1.25, but 5.1.26 and later
have some fixes for known issues that have been reported upstream.

Finally, you need the Spider Monkey javascript engine from Mozilla.org
ftp://ftp.mozilla.org/pub/mozilla.org/js/
Edbrowse 3.5.1 and higher requires Mozilla js version 2.4.
If this is not available in your distribution, download into /usr/local,
expand, cd js/src, ./configure, make, and make install.
https://ftp.mozilla.org/pub/mozilla.org/js/mozjs-24.2.0.tar.bz2
Lots of warning messages in the build, don't worry about those.
This creates /usr/local/lib/libmozjs-24.so, and with /usr/local/lib
already in my /etc/ld.so.conf, I thought I'd be fine,
but I had to run ldconfig again anyways, not sure why.
Back in your edbrowse/src directory,
you may need to set some flags on the command line
if you had to install Mozilla js as above.
The following works for me.

make JS_CXXFLAGS=-I/usr/local/include/mozjs-24 JSLIB=-lmozjs-24 edbrowse

If you want database access, you need unixODBC and unixODBC-devel.
Select the odbc option via:
make BUILD_EDBR_ODBC=on in the src directory, or from build,
cmake -DBUILD_EDBR_ODBC:BOOL=ON ..
ODBC has been very stable for a long time.
unixODBC version 2.2.14 seems to satisfy edbrowse with odbc.

------------------------------------------------------------

Edbrowse creates a system wide temp directory if it is not already present.
This is /tmp/.edbrowse in Unix, and $(TEMP)/edbrowse in Windows.
This directory contains a subdirectory per user, mod 700, for added security.
Thus one user cannot spy on the temp files, perhaps sensitive internet data,
of another user.
However, true multiuser security requires a root job at startup,
e.g. in /etc/rc.d/rc.local, to create the directory with the sticky bit.
	mkdir /tmp/.edbrowse
	chmod 1777 /tmp/.edbrowse

------------------------------------------------------------

The code in this project is indented via the script Lindent,
which is in the tools directory, and is taken from the Linux kernel source.
In other words, the indenting style is the same as the Linux kernel.
If you modify some source, you may want to run it through
../tools/Lindent before the commit.

In the interest of portability to Window Studio C, please keep variable
definitions at the top of each function or block.
A variable should not be defined after an executable statement.

------------------------------------------------------------

Debug levels:
0: silent
1: show the sizes of files and web pages as they are read and written
2: show the url as you call up a web page,
and http redirection.
3: javascript execution and errors.
   cookies, http codes, form data, and sql statements logged.
   html syntax errors as per tidy5.
4: show the socket connections, and the http headers in and out
   side effects of running javascript.
5: messages to and from the javascript process, url resolution, tidy html nodes.
6: show javascript to be executed
7: reformatted regular expressions, breakline chunks, read from js.
8: text lines freed, debug garbage collection
9: not used

Casual users should not go beyond db2.
Even developers rarely go beyond db4.

------------------------------------------------------------

Sourcefiles as follows.

src/main.c:
Read and parse the config file.
Entry point.
Command line options.
Invoke mail client if mail options are present.
If run as editor/browser, treat arguments as files or URLs
and read them into buffers.
Read commands from stdin and invoke them via the command
interpreter in buffers.c.

src/buffers.c:
Manage all the text buffers.
Interpret the standard ed commands, move, copy, delete, substitute, etc.
Run the 2 letter commands, such as qt to quit.

src/stringfile.c:
Helper functions to manage memory, strings, files, directories.

src/url.c:
Split a url into its components.
Decide if it's a proxy url.
Resolve relative url into absolute url
based on the location of the current web page.

src/format.c:
Arrange text into lines and paragraphs.
base64 encode and decode for email.

src/http.c:
Send the http request, and read the data from the web server.
Handles https connections as well,
and 301/302 redirection.
Uncompresses html data if necessary.
ftp, sftp, download files, possibly in the background.

src/html.c:
Manage the html tags and the tree of nodes.
Turn js side effects, like document.write or innerHTML,
back into html tags if that makes sense.
Submit/reset forms.
Render the tree of html nodes into a text buffer.
Rerender the tree after js has run, and report any changes to the user.

src/cookies.c:
Send and receive cookies.  Maintain the cookie jar.

src/auth.c:
Remember user and password for web pages that require authentication.
Only the basic method is implemented at this time.

src/sendmail.c:
Send mail (smtp or smtps).  Encode attachments.

src/fetchmail.c:
Fetch mail (pop3 or pop3s or imap).  Decode attachments.
Browse mail files, separate mime components.
Delete emails, move emails to other imap folders, search on an imap server.

src/plugin.c:
Determine the mime type of a file or web page and the corresponding plugin,
if any. Launch the plugin automatically or on command.
A plugin can play the file, like music, or render the file, like pdf.

src/messages.h:
Symbolic constants for the warning/error messages of edbrowse.

src/messages.c:
International print routines to display the message according to your locale.

lang/msg-*:
Edbrowse status and error messages in various languages.
Each is converted into a const array of messages in src/msg-strings.c,
thus src/msg-strings.c is not a source file.

src/decorate.c:
Decorate the tree with js objects corresponding to the html nodes
if js is enabled.

src/jseng-moz.cpp:
The javascript engine built around the mozilla js library.
Manage all the js objects corresponding to the web page in edbrowse.
Copy or link edbrowse to edbrowse-js;
the latter executable runs the machinery in this file.
It must be in the same bin as edbrowse.
All the js details are hidden in this file.
this is encapsulation, hiding the js library from the rest of edbrowse.
It might be possible, for instance, to build jseng-v8.c, based upon v8 etc.

src/html-tidy.c:
Use tidy5 to parse html and return a tree of nodes.
This is another form of encapsulation.
We could, in the future, write html-foo.c, having the same interface,
if we prefer parser foo instead.

src/startwindow.js:
Javascript that is run at the start of each session.
This creates certain support methods that client js will need.
It is converted into a const string in src/startwindow.c,
thus src/startwindow.c is not a source file.
As you write functions to support DOM,
your first preference is to write them in src/startwindow.js.
Failing this, write them in C, using the api in src/ebjs.c.
Failing this, and as a last resort, write them as native code in the js engine.

lang/ebrc-*:
Default .ebrc config file that is written to your home directory,
if you have no such file.
Different files for different languages.
Each is converted into a const string in src/ebrc.c,
thus src/ebrc.c is not a source file.

src/ebjs.c:
Interface between edbrowse and edbrowse-js.
Sends interprocess messages to js to manipulate the js objects,
and returns the result back to edbrowse.
Think of edbrowse-js as the js server, and edbrowse as the client.

src/jsrt:
This is the javascript regression test for edbrowse.
It exercises some of the javascript DOM interactions.

win32/dirent.c:
Access directories in Windows.

win32/vsprtf.c:
Windows implementation of asprintf().

src/dbops.c:
Database operations; insert update delete.

src/dbodbc.c:
Connect edbrowse to odbc.

src/dbinfx.ec:
Connect edbrowse directly to Informix.
Other connectors could be built, e.g. Oracle,
but it's probably easier just to go through odbc.

------------------------------------------------------------

Error conventions.
Unix commands return 0 for ok and a negative number for a problem.
Some of my functions work this way, but many return
true for success and false for error.
The error message is left in a buffer, which you can see by typing h
in the /bin/ed style.
Sometimes the error is displayed no matter what,
like when you are reading or writing files.
error messages are created according to your locale, i.e. in your language,
if a translation is available.
Some error messages in the database world have not yet been internationalized.
Some are beyond my control, as they come from odbc or its native driver.

------------------------------------------------------------

Multiple Representations.

A web form asks for your name, and you type in Fred Flintstone.
This piece of data is part of your edbrowse buffer.
In this sense it is merely text.
You can make corrections with the substitute command, etc.
Yet it is also carried into the html tags in html.c,
so that it can be sent when you push the submit button.
This is a second copy of the data.
As if that weren't bad enough, I now need a third copy for javascript.
When js accesses form.fullname.value, it needs to find,
and in some cases change, the text that you entered.
These 3 representations are "separate but equal",
using a lot of software to keep them in sync.
Remember that an input field could be an entire text area,
i.e. the text in another editing session.
When you are in that session, composing your thoughts,
am I really going to take every textual change, every substitute,
every delete, every insert, every undo,
and map those changes over to the html tag that goes with this session,
and the js variable that goes with this session?
I don't think so.
When you submit the form, or run any javascript for any reason,
the text is carried into the html tag, under t->value, and into the js object,
to make sure everything is in sync before js runs.
This is accomplished by jSyncup() in html.c.
When js has run to completion, any changes it has made to the fields have
to be mapped back to the editor, where you can see them.
This is done by jSideEffects() in html.c.
In other words, any action that might in any way involve js
must begin with jSyncup() and end with jSideEffects().
Once this is done, the tree of tags is rerendered,
and the new buffer is compared with the old using a very simple diff algorithm.
Edbrowse tells you if any lines have changed.

Line 357 has been updated.

Something went wrong with that request. Please try again.