Packages
smppex
2.2.1
3.3.0
3.2.4
3.2.3
3.2.2
3.2.1
3.2.0
retired
3.1.0
retired
3.0.6
3.0.5
3.0.4
3.0.3
3.0.2
3.0.1
3.0.0
2.4.0
2.3.3
2.3.2
2.3.1
2.3.0
2.2.9
2.2.8
2.2.7
2.2.6
2.2.5
2.2.4
2.2.3
2.2.2
2.2.1
2.2.0
2.1.0
2.0.1
2.0.0
1.0.1
0.3.2
0.3.1
0.3.0
0.2.1
0.2.0
0.1.12
0.1.11
0.1.10
0.1.9
0.1.8
0.1.7
0.1.6
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1
SMPP 3.4 protocol and framework implemented in Elixir
Current section
Files
Jump to
Current section
Files
lib/smppex/protocol/unpack/helpers.ex
defmodule SMPPEX.Protocol.Unpack.Helpers do
@moduledoc false
@spec hex?(binary) :: boolean
def hex?(<< char, rest :: binary >>) when (char >= 48) and (char <= 57), do: hex?(rest)
def hex?(<< char, rest :: binary >>) when (char >= 65) and (char <= 70), do: hex?(rest)
def hex?(<< char, rest :: binary >>) when (char >= 97) and (char <= 102), do: hex?(rest)
def hex?(<<>>), do: true
def hex?(_), do: false
@spec dec?(binary) :: boolean
def dec?(<< char, rest :: binary >>) when (char >= 48) and (char <= 57), do: dec?(rest)
def dec?(<<>>), do: true
def dec?(_), do: false
@spec take_until(binary, integer, integer) :: :not_found | {binary, binary}
def take_until(bin, char, take_max) do
_take_until(bin, char, take_max, 0)
end
@spec _take_until(binary, integer, integer, integer) :: :not_found | {binary, binary}
defp _take_until(_bin, _char, take_max, current) when current >= take_max, do: :not_found
defp _take_until(bin, _char, _take_max, current) when byte_size(bin) <= current, do: :not_found
defp _take_until(bin, char, take_max, current) do
case bin do
<< prefix :: binary-size(current), ^char, rest :: binary >> -> {prefix, rest}
_ -> _take_until(bin, char, take_max, current + 1)
end
end
end