ton of annoying string workaround stuff

This commit is contained in:
zongor 2023-09-03 00:33:26 -04:00
parent e56dad405c
commit 959234ca0e
1 changed files with 42 additions and 22 deletions

View File

@ -58,57 +58,77 @@ contains
character, dimension(:), allocatable, intent(in) :: request
integer, intent(in) :: length
character(len=:), allocatable :: command
character(len=32) :: created
integer :: i, s_u_idx, e_u_idx, s_p_idx, e_p_idx, s_a_idx
integer :: i, j, s_idx, e_idx, username_len, password_len
character(len=24) :: username
character(len=24) :: password
character(len=32) :: created
character(len=8) :: appearance
logical :: start = .false.
character(len=:), allocatable :: command
j = 1
get_username: do i = 1, length
if (request(i) .eq. '=') then
s_u_idx = i + 1
s_idx = i + 1
start = .true.
end if
if (request(i) .eq. '&') then
e_u_idx = i - 1
e_idx = i - 1
start = .false.
exit get_username
end if
end do get_username
! username = transfer(request(s_idx:e_idx), username)
get_password: do i = e_u_idx + 2, length
if (start) then
username(j:j) = request(i + 1)
j = j + 1
end if
end do get_username
username_len = j-2
j = 1
get_password: do i = e_idx + 2, length
if (request(i) .eq. '=') then
s_p_idx = i + 1
s_idx = i + 1
start = .true.
end if
if (request(i) .eq. '&') then
e_p_idx = i - 1
e_idx = i - 1
start = .false.
exit get_password
end if
end do get_password
! password = transfer(request(s_idx:e_idx), password)
get_appearance: do i = e_p_idx + 2, length
if (start) then
password(j:j) = request(i + 1)
j = j + 1
end if
end do get_password
password_len = j-2
get_appearance: do i = e_idx + 2, length
if (request(i) .eq. '=') then
s_a_idx = i + 1
s_idx = i + 1
end if
end do get_appearance
! appearance = transfer(request(s_a_idx:length), appearance)
appearance = transfer(request(s_idx:length), appearance)
write (created, *) time()
command = 'sqlite3 ' &
//trim(adjustl(db_path)) &
command = 'sqlite3 '//db_path(:Len_Trim(db_path)) &
//' "INSERT INTO users (username,password' &
//',apperance,x_pos,y_pos,last_login,created) VALUES (''' &
//request(s_u_idx:e_u_idx) &
// username(:username_len) &
//''',''' &
//request(s_p_idx:e_p_idx) &
// password(:password_len) &
//''',''' &
//request(s_a_idx:length) &
// appearance(:Len_Trim(appearance)) &
//''',0,0,0,' &
//created//');"'
//created(:Len_Trim(created))//');"'
write (12, *) command
call execute_command_line(command)
end subroutine add_user
end program main
end program main