Skip to content

allthingsgo/edbrowse

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!

A full cmake system is under development.
Meantime, on unix or linux,
just type make, and make install, and hope for the best.

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 HTML parser.  So there are a couple
of things to install for this prerequisite.
The Tidy 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 code from:
https://github.com/htacg/tidy-html5/archive/master.zip
Unzip and cd to build/cmake
cmake ../..
make install
Now the latest Tidy library will be available to edbrowse.

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.
Make edbrowse-odbc, rather than edbrowse.
ODBC has been very stable for a long time.
unixODBC version 2.2.14 seems to satisfy edbrowse-odbc.

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

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

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

Sourcefiles (in the src directory).

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.

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.

stringfile.c:
Helper functions to manage memory, strings, files, directories.
Hides many of the OS specific quirks.

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.

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

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.

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.

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

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

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

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.

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.

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

messages.c:
Strings corresponding to these error messages in various languages.
Also some international print routines to display the correct string
according to your locale.

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

jseng-moz.cpp:
The javascript engine built around the mozilla js library.
Manage all the js objects corresponding to the web page in edbrowse.
This is a stand alone process,
though it may share some sourcefiles with edbrowse, e.g. stringfile.c.
The resulting program is edbrowse-js,
and it must be in the same path 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.

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.

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 startwindow.c,
thus startwindow.c is not a source file.
As you write functions to support DOM,
your first preference is to write them in startwindow.js.
Failing this, write them in C, using the api in ebjs.c.
Failing this, and as a last resort, write them as native code in the js engine.

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.

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

dbops.c:
Database operations; insert update delete.

dbodbc.c:
Connect edbrowse to odbc.

dbinfx.ec:
Connect edbrowse directly to Informix.

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

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",
there is 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, in render.c,
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.

About

A command-line editor and web browser.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 68.1%
  • Perl 18.4%
  • C++ 5.4%
  • eC 3.3%
  • JavaScript 1.9%
  • CMake 1.2%
  • Other 1.7%