Skip to content

Commit

Permalink
Reformatted.
Browse files Browse the repository at this point in the history
  • Loading branch information
interkosmos committed Oct 16, 2024
1 parent 48ffe3b commit e857aa2
Show file tree
Hide file tree
Showing 16 changed files with 145 additions and 282 deletions.
27 changes: 9 additions & 18 deletions src/dm_arg.f90
Original file line number Diff line number Diff line change
Expand Up @@ -326,24 +326,15 @@ integer function dm_arg_read(args, app, major, minor, patch, version) result(rc)

case (E_ARG_TYPE)
select case (args(i)%type)
case (ARG_TYPE_INTEGER)
call dm_error_out(rc, 'argument --' // trim(args(i)%name) // ' is not an integer')
case (ARG_TYPE_REAL)
call dm_error_out(rc, 'argument --' // trim(args(i)%name) // ' is not a number')
case (ARG_TYPE_CHAR)
call dm_error_out(rc, 'argument --' // trim(args(i)%name) // ' is not a single character')
case (ARG_TYPE_ID)
call dm_error_out(rc, 'argument --' // trim(args(i)%name) // ' is not a valid id')
case (ARG_TYPE_UUID)
call dm_error_out(rc, 'argument --' // trim(args(i)%name) // ' is not a valid UUID')
case (ARG_TYPE_TIME)
call dm_error_out(rc, 'argument --' // trim(args(i)%name) // ' is not in ISO 8601 format')
case (ARG_TYPE_LEVEL)
call dm_error_out(rc, 'argument --' // trim(args(i)%name) // ' is not a valid log level')
case (ARG_TYPE_FILE)
call dm_error_out(rc, 'file ' // trim(args(i)%value) // ' not found')
case (ARG_TYPE_DATABASE)
call dm_error_out(rc, 'database ' // trim(args(i)%value) // ' not found')
case (ARG_TYPE_INTEGER); call dm_error_out(rc, 'argument --' // trim(args(i)%name) // ' is not an integer')
case (ARG_TYPE_REAL); call dm_error_out(rc, 'argument --' // trim(args(i)%name) // ' is not a number')
case (ARG_TYPE_CHAR); call dm_error_out(rc, 'argument --' // trim(args(i)%name) // ' is not a single character')
case (ARG_TYPE_ID); call dm_error_out(rc, 'argument --' // trim(args(i)%name) // ' is not a valid id')
case (ARG_TYPE_UUID); call dm_error_out(rc, 'argument --' // trim(args(i)%name) // ' is not a valid UUID')
case (ARG_TYPE_TIME); call dm_error_out(rc, 'argument --' // trim(args(i)%name) // ' is not in ISO 8601 format')
case (ARG_TYPE_LEVEL); call dm_error_out(rc, 'argument --' // trim(args(i)%name) // ' is not a valid log level')
case (ARG_TYPE_FILE); call dm_error_out(rc, 'file ' // trim(args(i)%value) // ' not found')
case (ARG_TYPE_DATABASE); call dm_error_out(rc, 'database ' // trim(args(i)%value) // ' not found')
end select

exit validate_loop
Expand Down
2 changes: 1 addition & 1 deletion src/dm_error.f90
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ pure function dm_error_message(error) result(message)
case (E_ZLIB); message = 'zlib error'
case (E_ZSTD); message = 'zstd error'
case (E_XMPP); message = 'XMPP error'
! Default.
! Unknown.
case default; message = 'unknown error'
end select
end function dm_error_message
Expand Down
24 changes: 8 additions & 16 deletions src/dm_file.f90
Original file line number Diff line number Diff line change
Expand Up @@ -119,22 +119,14 @@ integer function dm_file_status(path, status) result(rc)
file_type = int(iand(status%mode, int(S_IFMT, kind=i8)))

select case (file_type)
case (S_IFBLK)
status%type = FILE_TYPE_BLOCK
case (S_IFCHR)
status%type = FILE_TYPE_CHAR
case (S_IFDIR)
status%type = FILE_TYPE_DIR
case (S_IFIFO)
status%type = FILE_TYPE_FIFO
case (S_IFLNK)
status%type = FILE_TYPE_LINK
case (S_IFREG)
status%type = FILE_TYPE_FILE
case (S_IFSOCK)
status%type = FILE_TYPE_SOCKET
case default
status%type = FILE_TYPE_NONE
case (S_IFBLK); status%type = FILE_TYPE_BLOCK
case (S_IFCHR); status%type = FILE_TYPE_CHAR
case (S_IFDIR); status%type = FILE_TYPE_DIR
case (S_IFIFO); status%type = FILE_TYPE_FIFO
case (S_IFLNK); status%type = FILE_TYPE_LINK
case (S_IFREG); status%type = FILE_TYPE_FILE
case (S_IFSOCK); status%type = FILE_TYPE_SOCKET
case default; status%type = FILE_TYPE_NONE
end select

status%a_time = fs%st_atim%tv_sec ! Last access time.
Expand Down
2 changes: 1 addition & 1 deletion src/dm_geocom_error.f90
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ pure function dm_geocom_error_message(grc) result(message)
case (GRC_FTR_NOTENOUGHSPACE); message = 'not enough space on device to proceed uploading'
case (GRC_FTR_INVALIDINPUT); message = 'rename of file failed'
case (GRC_FTR_MISSINGSETUP); message = 'invalid parameter as input'
! Default
! unknown
case default; message = 'unknown GeoCOM code (' // dm_itoa(grc) // ')'
end select
end function dm_geocom_error_message
Expand Down
26 changes: 9 additions & 17 deletions src/dm_hdf5.f90
Original file line number Diff line number Diff line change
Expand Up @@ -246,16 +246,11 @@ logical function dm_hdf5_has_filter(filter, error) result(available)
hdf5_block: block
rc = E_INVALID
select case (filter)
case (HDF5_FILTER_DEFLATE)
f = H5Z_FILTER_DEFLATE_F
case (HDF5_FILTER_SHUFFLE)
f = H5Z_FILTER_SHUFFLE_F
case (HDF5_FILTER_FLETCHER32)
f = H5Z_FILTER_FLETCHER32_F
case (HDF5_FILTER_SZIP)
f = H5Z_FILTER_SZIP_F
case default
exit hdf5_block
case (HDF5_FILTER_DEFLATE); f = H5Z_FILTER_DEFLATE_F
case (HDF5_FILTER_SHUFFLE); f = H5Z_FILTER_SHUFFLE_F
case (HDF5_FILTER_FLETCHER32); f = H5Z_FILTER_FLETCHER32_F
case (HDF5_FILTER_SZIP); f = H5Z_FILTER_SZIP_F
case default; exit hdf5_block
end select

rc = E_HDF5
Expand Down Expand Up @@ -923,14 +918,11 @@ integer function hdf5_open_file(file, path, mode, create) result(rc)
mode_ = HDF5_RDWR
if (present(mode)) mode_ = mode

rc = E_INVALID
select case (mode_)
case (HDF5_RDONLY)
flags = H5F_ACC_RDONLY_F
case (HDF5_RDWR)
flags = H5F_ACC_RDWR_F
case default
rc = E_INVALID
return
case (HDF5_RDONLY); flags = H5F_ACC_RDONLY_F
case (HDF5_RDWR); flags = H5F_ACC_RDWR_F
case default; return
end select

rc = E_NOT_FOUND
Expand Down
73 changes: 24 additions & 49 deletions src/dm_http.f90
Original file line number Diff line number Diff line change
Expand Up @@ -41,57 +41,32 @@ pure function dm_http_status_string(http_status) result(str)

select case (http_status)
! 20X
case (HTTP_OK)
str = 'OK'
case (HTTP_CREATED)
str = 'Created'
case (HTTP_ACCEPTED)
str = 'Accepted'
case (HTTP_NO_CONTENT)
str = 'No Content'
case (HTTP_RESET_CONTENT)
str = 'Reset Content'

case (HTTP_OK); str = 'OK'
case (HTTP_CREATED); str = 'Created'
case (HTTP_ACCEPTED); str = 'Accepted'
case (HTTP_NO_CONTENT); str = 'No Content'
case (HTTP_RESET_CONTENT); str = 'Reset Content'
! 4XX
case (HTTP_BAD_REQUEST)
str = 'Bad Request'
case (HTTP_UNAUTHORIZED)
str = 'Unauthorized'
case (HTTP_PAYMENT_REQUIRED)
str = 'Payment Required'
case (HTTP_FORBIDDEN)
str = 'Forbidden'
case (HTTP_NOT_FOUND)
str = 'Not Found'
case (HTTP_METHOD_NOT_ALLOWED)
str = 'Method Not Allowed'
case (HTTP_NOT_ACCEPTABLE)
str = 'Not Acceptable'
case (HTTP_PROXY_AUTHENTICATION_REQUIRED)
str = 'Proxy Authentication Required'
case (HTTP_REQUEST_TIMEOUT)
str = 'Request Timeout'
case (HTTP_CONFLICT)
str = 'Conflict'
case (HTTP_GONE)
str = 'Gone'
case (HTTP_LENGTH_REQUIRED)
str = 'Length Required'
case (HTTP_UNSUPPORTED_MEDIA_TYPE)
str = 'Unsupported Media Type'

case (HTTP_BAD_REQUEST); str = 'Bad Request'
case (HTTP_UNAUTHORIZED); str = 'Unauthorized'
case (HTTP_PAYMENT_REQUIRED); str = 'Payment Required'
case (HTTP_FORBIDDEN); str = 'Forbidden'
case (HTTP_NOT_FOUND); str = 'Not Found'
case (HTTP_METHOD_NOT_ALLOWED); str = 'Method Not Allowed'
case (HTTP_NOT_ACCEPTABLE); str = 'Not Acceptable'
case (HTTP_PROXY_AUTHENTICATION_REQUIRED); str = 'Proxy Authentication Required'
case (HTTP_REQUEST_TIMEOUT); str = 'Request Timeout'
case (HTTP_CONFLICT); str = 'Conflict'
case (HTTP_GONE); str = 'Gone'
case (HTTP_LENGTH_REQUIRED); str = 'Length Required'
case (HTTP_UNSUPPORTED_MEDIA_TYPE); str = 'Unsupported Media Type'
! 50X
case (HTTP_INTERNAL_SERVER_ERROR)
str = 'Internal Server Error'
case (HTTP_NOT_IMPLEMENTED)
str = 'Not Implemented'
case (HTTP_BAD_GATEWAY)
str = 'Bad Gateway'
case (HTTP_SERVICE_UNAVAILABLE)
str = 'Service Unavailable'

case default
str = ''
case (HTTP_INTERNAL_SERVER_ERROR); str = 'Internal Server Error'
case (HTTP_NOT_IMPLEMENTED); str = 'Not Implemented'
case (HTTP_BAD_GATEWAY); str = 'Bad Gateway'
case (HTTP_SERVICE_UNAVAILABLE); str = 'Service Unavailable'
! NIY
case default; str = ''
end select
end function dm_http_status_string
end module dm_http
2 changes: 1 addition & 1 deletion src/dm_log.f90
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pure elemental logical function dm_log_is_valid(log) result(valid)

valid = .false.

if (.not. dm_log_level_is_valid(log%level)) return
if (.not. dm_log_level_is_valid(log%level)) return
if (.not. dm_error_is_valid(log%error)) return
if (log%id == UUID_DEFAULT) return
if (.not. dm_uuid4_is_valid(log%id)) return
Expand Down
39 changes: 13 additions & 26 deletions src/dm_lua.f90
Original file line number Diff line number Diff line change
Expand Up @@ -196,22 +196,14 @@ integer function dm_lua_error(lua_error) result(rc)
integer, intent(in) :: lua_error !! Lua error code.

select case (lua_error)
case (LUA_OK)
rc = E_NONE
case (LUA_YIELD)
rc = E_LUA_YIELD
case (LUA_ERRRUN)
rc = E_LUA_RUNTIME
case (LUA_ERRSYNTAX)
rc = E_LUA_SYNTAX
case (LUA_ERRMEM)
rc = E_LUA_MEM
case (LUA_ERRERR)
rc = E_LUA_ERROR
case (LUA_ERRFILE)
rc = E_LUA_FILE
case default
rc = E_LUA
case (LUA_OK); rc = E_NONE
case (LUA_YIELD); rc = E_LUA_YIELD
case (LUA_ERRRUN); rc = E_LUA_RUNTIME
case (LUA_ERRSYNTAX); rc = E_LUA_SYNTAX
case (LUA_ERRMEM); rc = E_LUA_MEM
case (LUA_ERRERR); rc = E_LUA_ERROR
case (LUA_ERRFILE); rc = E_LUA_FILE
case default; rc = E_LUA
end select
end function dm_lua_error

Expand Down Expand Up @@ -548,16 +540,11 @@ subroutine dm_lua_dump_stack(lua, unit)
write (unit_, '(tr1, i0, tr1, a, tr1)', advance='no') i, lua_typename(lua%ctx, type)

select case (type)
case (LUA_TNIL)
write (unit_, '("nil")')
case (LUA_TBOOLEAN)
write (unit_, '(l1)') lua_toboolean(lua%ctx, i)
case (LUA_TNUMBER)
write (unit_, '(f0.1)') lua_tonumber(lua%ctx, i)
case (LUA_TSTRING)
write (unit_, '(a)') lua_tostring(lua%ctx, i)
case default
write (unit_, *)
case (LUA_TNIL); write (unit_, '("nil")')
case (LUA_TBOOLEAN); write (unit_, '(l1)') lua_toboolean(lua%ctx, i)
case (LUA_TNUMBER); write (unit_, '(f0.1)') lua_tonumber(lua%ctx, i)
case (LUA_TSTRING); write (unit_, '(a)') lua_tostring(lua%ctx, i)
case default; write (unit_, *)
end select
end do
end subroutine dm_lua_dump_stack
Expand Down
9 changes: 3 additions & 6 deletions src/dm_mqueue.f90
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,9 @@ integer function mqueue_open_raw(mqueue, name, max_msg, msg_size, access, mode,

if (present(access)) then
select case (access)
case (MQUEUE_RDONLY)
flag = O_RDONLY
case (MQUEUE_WRONLY)
flag = O_WRONLY
case (MQUEUE_RDWR)
flag = O_RDWR
case (MQUEUE_RDONLY); flag = O_RDONLY
case (MQUEUE_WRONLY); flag = O_WRONLY
case (MQUEUE_RDWR); flag = O_RDWR
end select
end if

Expand Down
21 changes: 7 additions & 14 deletions src/dm_path.f90
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,13 @@ function dm_path_parsed(path) result(parsed)
end if

select case (a)
case ('D')
parsed = parsed // date(7:8)
case ('M')
parsed = parsed // date(5:6)
case ('Y')
parsed = parsed // date(3:4)
case ('h')
parsed = parsed // time(1:2)
case ('m')
parsed = parsed // time(3:4)
case ('s')
parsed = parsed // time(5:6)
case default
parsed = parsed // '%' // a
case ('D'); parsed = parsed // date(7:8)
case ('M'); parsed = parsed // date(5:6)
case ('Y'); parsed = parsed // date(3:4)
case ('h'); parsed = parsed // time(1:2)
case ('m'); parsed = parsed // time(3:4)
case ('s'); parsed = parsed // time(5:6)
case default; parsed = parsed // '%' // a
end select

flag = .false.
Expand Down
9 changes: 3 additions & 6 deletions src/dm_pipe.f90
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,9 @@ integer function dm_pipe_open(pipe, command, access) result(rc)

rc = E_INVALID
select case (access)
case (PIPE_RDONLY)
a = 'r' // c_null_char
case (PIPE_WRONLY)
a = 'w' // c_null_char
case default
return
case (PIPE_RDONLY); a = 'r' // c_null_char
case (PIPE_WRONLY); a = 'w' // c_null_char
case default; return
end select

rc = E_SYSTEM
Expand Down
8 changes: 3 additions & 5 deletions src/dm_response.f90
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,17 @@ pure elemental logical function dm_response_is_valid(response) result(valid)
type(response_type), intent(in) :: response !! Response type.

valid = .false.
if (.not. dm_id_is_valid(response%name)) return
if (.not. dm_id_is_valid(response%name)) return
if (.not. dm_response_type_is_valid(response%type)) return
if (.not. dm_error_is_valid(response%error)) return
if (.not. dm_error_is_valid(response%error)) return
valid = .true.
end function dm_response_is_valid

pure elemental logical function dm_response_type_is_valid(type) result(valid)
!! Returns `.true.` if the given response value type is valid.
integer, intent(in) :: type !! Response value type.

valid = .false.
if (type < RESPONSE_TYPE_REAL64 .or. type > RESPONSE_TYPE_LAST) return
valid = .true.
valid = (type >= RESPONSE_TYPE_REAL64 .and. type <= RESPONSE_TYPE_LAST)
end function dm_response_type_is_valid

pure function dm_response_type_to_name(type) result(str)
Expand Down
Loading

0 comments on commit e857aa2

Please sign in to comment.