-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
M agpl-xml.ads M dom-core-nodes-output.adb A agpl-ustrings.ads A agpl-containers-string_vectors.ads M dom-core-nodes-output.ads A agpl-url.adb A agpl-url.ads A agpl-strings-utf8.adb M agpl-filesystem.adb A agpl-strings-utf8.ads M agpl-filesystem.ads
- Loading branch information
Showing
12 changed files
with
533 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
------------------------------------------------------------------------------ | ||
-- AGPL -- | ||
-- -- | ||
-- Copyright (C) 2003 -- | ||
-- A. Mosteo. -- | ||
-- -- | ||
-- Authors: A. Mosteo. (public@mosteo.com) -- | ||
-- -- | ||
-- If you have any questions in regard to this software, please address -- | ||
-- them to the above email. -- | ||
-- -- | ||
-- This program is free software; you can redistribute it and/or modify -- | ||
-- it under the terms of the GNU General Public License as published by -- | ||
-- the Free Software Foundation; either version 2 of the License, or (at -- | ||
-- your option) any later version. -- | ||
-- -- | ||
-- This program is distributed in the hope that it will be useful, but -- | ||
-- WITHOUT ANY WARRANTY; without even the implied warranty of -- | ||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- | ||
-- General Public License for more details. -- | ||
-- -- | ||
-- You should have received a copy of the GNU General Public License -- | ||
-- along with this library; if not, write to the Free Software Foundation, -- | ||
-- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- | ||
------------------------------------------------------------------------------ | ||
|
||
with Ada.Containers.Indefinite_Vectors; | ||
|
||
package Agpl.Containers.String_Vectors is new | ||
Ada.Containers.Indefinite_Vectors (Positive, String); | ||
|
||
pragma Preelaborate (Agpl.Containers.String_Vectors); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
with Agpl.Types.Ustrings; use Agpl.Types.Ustrings; | ||
|
||
package body Agpl.Strings.Utf8 is | ||
|
||
------------------- | ||
-- Extract_Words -- | ||
------------------- | ||
|
||
function Extract_Words (Str : String) return Containers.String_Vectors.Vector | ||
is | ||
Words : Containers.String_Vectors.Vector; | ||
Str_Idx : Natural := Str'First; | ||
Word : Ustring; | ||
use Asu; | ||
begin | ||
while Str_Idx <= Str'Last loop | ||
declare | ||
Char : Unicode.Unicode_Char; | ||
begin | ||
Unicode.Ces.Utf8.Read (Str, Str_Idx, Char); | ||
|
||
if Unicode.Is_Letter (Char) or else Unicode.Is_Digit (Char) then | ||
declare | ||
Code : String (1 .. 20); | ||
Last : Natural := Code'First; | ||
begin | ||
Unicode.Ces.Utf8.Encode (Char, Code, Last); | ||
Append (Word, Code (Code'First + 1 .. Last)); | ||
end; | ||
end if; | ||
|
||
if Str_Idx > Str'Last or else | ||
not (Unicode.Is_Letter (Char) or else Unicode.Is_Digit (Char)) | ||
then | ||
if Word /= Null_Ustring then | ||
Words.Append (+Word); | ||
Word := Null_Ustring; | ||
end if; | ||
end if; | ||
end; | ||
end loop; | ||
|
||
return Words; | ||
end Extract_Words; | ||
|
||
end Agpl.Strings.Utf8; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
------------------------------------------------------------------------------ | ||
-- ADAGIO - ADALID - AENEA. -- | ||
-- -- | ||
-- Copyright (C) 2003 -- | ||
-- A. Mosteo. -- | ||
-- -- | ||
-- Authors: A. Mosteo. (adagio@mosteo.com) -- | ||
-- -- | ||
-- If you have any questions in regard to this software, please address -- | ||
-- them to the above email. -- | ||
-- -- | ||
-- This program is free software; you can redistribute it and/or modify -- | ||
-- it under the terms of the GNU General Public License as published by -- | ||
-- the Free Software Foundation; either version 2 of the License, or (at -- | ||
-- your option) any later version. -- | ||
-- -- | ||
-- This program is distributed in the hope that it will be useful, but -- | ||
-- WITHOUT ANY WARRANTY; without even the implied warranty of -- | ||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- | ||
-- General Public License for more details. -- | ||
-- -- | ||
-- You should have received a copy of the GNU General Public License -- | ||
-- along with this library; if not, write to the Free Software Foundation, -- | ||
-- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- | ||
-- -- | ||
-- You are not allowed to use any part of this code to develop a program -- | ||
-- whose output would be used to harass or prosecute other users of the -- | ||
-- networks Adagio connects with. All data collected with Adagio or a tool -- | ||
-- containing Adagio code about other network users must remain -- | ||
-- confidential and cannot be made public by any mean, nor be used to -- | ||
-- harass or legally prosecute these users. -- | ||
------------------------------------------------------------------------------ | ||
-- $Id: agpl-strings.ads,v 1.3 2004/02/03 22:52:09 Jano Exp $ | ||
|
||
with Agpl.Containers.String_Vectors; | ||
|
||
with Unicode.Ces.Utf8; | ||
|
||
package Agpl.Strings.Utf8 is | ||
|
||
subtype Utf8_String is Unicode.Ces.Utf8.Utf8_String; | ||
|
||
function Extract_Words (Str : String) return Containers.String_Vectors.Vector; | ||
-- Will split the string using non-letters and non-numbers as delimiters | ||
|
||
end Agpl.Strings.Utf8; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
------------------------------------------------------------------------------ | ||
-- Ada Web Server -- | ||
-- -- | ||
-- Copyright (C) 2000-2004 -- | ||
-- ACT-Europe -- | ||
-- -- | ||
-- This library is free software; you can redistribute it and/or modify -- | ||
-- it under the terms of the GNU General Public License as published by -- | ||
-- the Free Software Foundation; either version 2 of the License, or (at -- | ||
-- your option) any later version. -- | ||
-- -- | ||
-- This library is distributed in the hope that it will be useful, but -- | ||
-- WITHOUT ANY WARRANTY; without even the implied warranty of -- | ||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- | ||
-- General Public License for more details. -- | ||
-- -- | ||
-- You should have received a copy of the GNU General Public License -- | ||
-- along with this library; if not, write to the Free Software Foundation, -- | ||
-- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- | ||
-- -- | ||
-- As a special exception, if other files instantiate generics from this -- | ||
-- unit, or you link this unit with other files to produce an executable, -- | ||
-- this unit does not by itself cause the resulting executable to be -- | ||
-- covered by the GNU General Public License. This exception does not -- | ||
-- however invalidate any other reasons why the executable file might be -- | ||
-- covered by the GNU Public License. -- | ||
------------------------------------------------------------------------------ | ||
|
||
-- $Id: aws-url.adb,v 1.37 2004/11/10 13:53:24 obry Exp $ | ||
|
||
with Agpl.Conversions; | ||
|
||
with Ada.Characters.Handling; | ||
|
||
package body Agpl.URL is | ||
|
||
subtype Escape_Code is String (1 .. 2); | ||
|
||
Not_Escaped : constant Escape_Code := " "; | ||
|
||
function Code (C : in Character) return Escape_Code; | ||
pragma Inline (Code); | ||
-- Returns hexadecimal code for character C | ||
|
||
subtype ASCII_7 is Character range Character'First .. Character'Val (127); | ||
type ASCII_7_Set is array (ASCII_7) of Escape_Code; | ||
|
||
function Build_Hex_Escape return ASCII_7_Set; | ||
-- Returns the table with pre-computed encoding for 7bits characters | ||
|
||
---------------------- | ||
-- Build_Hex_Escape -- | ||
---------------------- | ||
|
||
function Build_Hex_Escape return ASCII_7_Set is | ||
Result : ASCII_7_Set; | ||
begin | ||
for C in Character'Val (0) .. Character'Val (127) loop | ||
if Strings.Maps.Is_In (C, Default_Encoding_Set) then | ||
Result (C) := Code (C); | ||
else | ||
Result (C) := Not_Escaped; | ||
end if; | ||
end loop; | ||
return Result; | ||
end Build_Hex_Escape; | ||
|
||
---------- | ||
-- Code -- | ||
---------- | ||
|
||
function Code (C : in Character) return Escape_Code is | ||
begin | ||
return Conversions.To_Hex (Character'Pos (C)); | ||
end Code; | ||
|
||
Hex_Escape : constant ASCII_7_Set := Build_Hex_Escape; | ||
-- Limit Hex_Escape to 7bits ASCII characters only. Other ISO-8859-1 are | ||
-- handled separately in Encode function. Space character is not processed | ||
-- specifically, contrary to what is done in AWS.URL. | ||
|
||
------------ | ||
-- Decode -- | ||
------------ | ||
|
||
function Decode (Str : in String) return String is | ||
Res : String (1 .. Str'Length); | ||
K : Natural := 0; | ||
I : Positive := Str'First; | ||
begin | ||
if Str = "" then | ||
return ""; | ||
end if; | ||
|
||
loop | ||
K := K + 1; | ||
|
||
if Str (I) = '%' | ||
and then I + 2 <= Str'Last | ||
and then Characters.Handling.Is_Hexadecimal_Digit (Str (I + 1)) | ||
and then Characters.Handling.Is_Hexadecimal_Digit (Str (I + 2)) | ||
then | ||
Res (K) := Conversions.From_Hex (Str (I + 1 .. I + 2)); | ||
I := I + 2; | ||
|
||
elsif Str (I) = '+' then | ||
Res (K) := ' '; | ||
|
||
else | ||
Res (K) := Str (I); | ||
end if; | ||
|
||
I := I + 1; | ||
exit when I > Str'Last; | ||
end loop; | ||
|
||
return Res (1 .. K); | ||
end Decode; | ||
|
||
------------ | ||
-- Encode -- | ||
------------ | ||
|
||
function Encode | ||
(Str : in String; | ||
Encoding_Set : in Strings.Maps.Character_Set := Default_Encoding_Set) | ||
return String | ||
is | ||
C_128 : constant Character := Character'Val (128); | ||
Res : String (1 .. Str'Length * 3); | ||
K : Natural := 0; | ||
begin | ||
for I in Str'Range loop | ||
if Strings.Maps.Is_In (Str (I), Encoding_Set) then | ||
-- This character must be encoded | ||
|
||
K := K + 1; | ||
Res (K) := '%'; | ||
K := K + 1; | ||
|
||
if Str (I) < C_128 then | ||
-- We keep a table for characters lower than 128 for efficiency | ||
Res (K .. K + 1) := Hex_Escape (Str (I)); | ||
else | ||
Res (K .. K + 1) := Code (Str (I)); | ||
end if; | ||
|
||
K := K + 1; | ||
|
||
else | ||
K := K + 1; | ||
Res (K) := Str (I); | ||
end if; | ||
end loop; | ||
|
||
return Res (1 .. K); | ||
end Encode; | ||
|
||
end Agpl.URL; |
Oops, something went wrong.