Skip to content

Commit

Permalink
Refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
interkosmos committed Feb 24, 2024
1 parent 9ab2833 commit 5e14f42
Show file tree
Hide file tree
Showing 25 changed files with 1,857 additions and 1,069 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,14 @@ $ doas pkg install databases/sqlite3 devel/git devel/pcre2 devel/pkgconf ftp/cur
Instead of `math/gnuplot`, you may want to install `math/gnuplot-lite` which
does not depend on X11 (but lacks raster graphic terminals).

In order to generate the man pages and the User’s Guide, install Pygments and
AsciiDoctor:
Optionally, install Pygments and AsciiDoctor to generate the man pages and the
User’s Guide:

```
$ doas pkg install devel/rubygem-pygments.rb textproc/rubygem-asciidoctor
```

The Git repository has to be cloned recursively. Otherwise, your will need to
The Git repository has to be cloned recursively. Otherwise, you will need to
download the sub-modules manually by executing `fetchvendor.sh`. Then, run the
Makefile:

Expand Down
3 changes: 3 additions & 0 deletions adoc/dmfeed.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ The feed id has to be a 36 characters long UUID with hyphens. News aggregators
use the id to identify the feed. Therefore, the id should not be reused among
different feeds. Run _dmuuid(1)_ to generate a valid UUID4.

The time stamp of the feed in the updated element is set to the date and time of
the last log message.

== OPTIONS

*--author*, *-A* _name_::
Expand Down
8 changes: 4 additions & 4 deletions app/dmbeat.f90
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ program dmbeat
character(len=*), parameter :: APP_NAME = 'dmbeat'
integer, parameter :: APP_MAJOR = 0
integer, parameter :: APP_MINOR = 9
integer, parameter :: APP_PATCH = 1
integer, parameter :: APP_PATCH = 2

logical, parameter :: APP_RPC_DEFLATE = .true. !! Compress RPC data.

integer, parameter :: HOST_LEN = 80
integer, parameter :: USERNAME_LEN = 32
integer, parameter :: PASSWORD_LEN = 32
integer, parameter :: HOST_LEN = 256 !! Max. length of host name.
integer, parameter :: USERNAME_LEN = 256 !! Max. length of user name.
integer, parameter :: PASSWORD_LEN = 256 !! Max. length of password.

type :: app_type
!! Application settings.
Expand Down
15 changes: 9 additions & 6 deletions app/dmdb.f90
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ program dmdb
call run(app, db, mqueue, sem)
end block init_block

if (dm_is_error(rc)) call halt(1)
call halt(0)
call halt(rc)
contains
integer function read_args(app) result(rc)
!! Reads command-line arguments and settings from configuration file.
Expand Down Expand Up @@ -180,10 +179,14 @@ integer function read_config(app) result(rc)
call dm_config_close(config)
end function read_config

subroutine halt(stat)
subroutine halt(error)
!! Cleans up and stops program.
integer, intent(in) :: stat
integer :: rc
integer, intent(in), optional :: error !! DMPACK error code.

integer :: rc, stat

stat = 0
if (present(error)) stat = min(1, error)

rc = dm_db_close(db)
rc = dm_mqueue_close(mqueue)
Expand Down Expand Up @@ -287,7 +290,7 @@ subroutine signal_handler(signum) bind(c)
select case (signum)
case default
call dm_log(LOG_INFO, 'exit on signal ' // dm_itoa(signum))
call halt(0)
call halt(E_NONE)
end select
end subroutine signal_handler
end program dmdb
13 changes: 7 additions & 6 deletions app/dmfeed.f90
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ program dmfeed
character(len=*), parameter :: APP_NAME = 'dmfeed'
integer, parameter :: APP_MAJOR = 0
integer, parameter :: APP_MINOR = 9
integer, parameter :: APP_PATCH = 0
integer, parameter :: APP_PATCH = 1

integer, parameter :: APP_MAX_NENTRIES = 500 !! Maximum number of feed entries.

Expand All @@ -21,7 +21,7 @@ program dmfeed
character(len=FILE_PATH_LEN) :: config = ' ' !! Path to config file.
character(len=FILE_PATH_LEN) :: database = ' ' !! Path to log database.
character(len=FILE_PATH_LEN) :: output = ' ' !! Output path of Atom file (stdout if empty).
character(len=NODE_ID_LEN) :: node = ' ' !! Node id.
character(len=NODE_ID_LEN) :: node = ' ' !! Optional node id.
integer :: minlevel = LOG_DEBUG !! Minimum log level
integer :: maxlevel = LOG_CRITICAL !! Maximum log level.
integer :: nentries = 50 !! Max. number of entries in feed.
Expand Down Expand Up @@ -165,10 +165,10 @@ integer function read_config(app) result(rc)
call dm_config_close(config)
end function read_config

subroutine create_feed(app, stat)
subroutine create_feed(app, error)
!! Creates Atom XML feed from logs in database.
type(app_type), intent(inout) :: app !! App type.
integer, intent(out), optional :: stat !! Status.
type(app_type), intent(inout) :: app !! App type.
integer, intent(out), optional :: error !! Error code.

character(len=:), allocatable :: xml
integer :: rc
Expand Down Expand Up @@ -211,6 +211,7 @@ subroutine create_feed(app, stat)
end if

! Create Atom XML string.
app%atom%updated = logs(1)%timestamp
call dm_atom_from_logs(app%atom, logs, xml)

! Write to file.
Expand All @@ -225,7 +226,7 @@ subroutine create_feed(app, stat)
rc = E_NONE
end block feed_block

if (present(stat)) stat = rc
if (present(error)) error = rc
rc = dm_db_close(db)
end subroutine create_feed
end program dmfeed
Loading

0 comments on commit 5e14f42

Please sign in to comment.