Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
relibc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Peter Limkilde Svendsen
relibc
Commits
d0261ebb
Verified
Commit
d0261ebb
authored
6 years ago
by
Jeremy Soller
Browse files
Options
Downloads
Patches
Plain Diff
Move db to crate root
parent
09340bd0
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/db.rs
+56
-0
56 additions, 0 deletions
src/db.rs
src/header/netdb/db.rs
+0
-31
0 additions, 31 deletions
src/header/netdb/db.rs
src/header/netdb/mod.rs
+4
-9
4 additions, 9 deletions
src/header/netdb/mod.rs
src/lib.rs
+1
-0
1 addition, 0 deletions
src/lib.rs
with
61 additions
and
40 deletions
src/db.rs
0 → 100644
+
56
−
0
View file @
d0261ebb
use
alloc
::
string
::
String
;
use
alloc
::
vec
::
Vec
;
use
c_str
::
CStr
;
use
fs
::
File
;
use
header
::
fcntl
;
use
io
::{
self
,
BufRead
,
BufReader
};
pub
enum
Separator
{
Character
(
char
),
Whitespace
,
}
pub
struct
Db
<
R
:
BufRead
>
{
reader
:
R
,
separator
:
Separator
,
}
impl
<
R
:
BufRead
>
Db
<
R
>
{
pub
fn
new
(
reader
:
R
,
separator
:
Separator
)
->
Self
{
Db
{
reader
,
separator
}
}
pub
fn
read
(
&
mut
self
)
->
io
::
Result
<
Option
<
Vec
<
String
>>>
{
let
mut
line
=
String
::
new
();
if
self
.reader
.read_line
(
&
mut
line
)
?
==
0
{
return
Ok
(
None
);
}
let
vec
=
if
let
Some
(
not_comment
)
=
line
.trim
()
.split
(
'#'
)
.next
()
{
match
self
.separator
{
Separator
::
Character
(
c
)
=>
not_comment
.split
(
c
)
.map
(
String
::
from
)
.collect
(),
Separator
::
Whitespace
=>
not_comment
.split_whitespace
()
.map
(
String
::
from
)
.collect
(),
}
}
else
{
Vec
::
new
()
};
Ok
(
Some
(
vec
))
}
}
pub
type
FileDb
=
Db
<
BufReader
<
File
>>
;
impl
FileDb
{
pub
fn
open
(
path
:
&
CStr
,
separator
:
Separator
)
->
io
::
Result
<
Self
>
{
let
file
=
File
::
open
(
path
,
fcntl
::
O_RDONLY
|
fcntl
::
O_CLOEXEC
)
?
;
Ok
(
Db
::
new
(
BufReader
::
new
(
file
),
separator
))
}
}
This diff is collapsed.
Click to expand it.
src/header/netdb/db.rs
deleted
100644 → 0
+
0
−
31
View file @
09340bd0
use
alloc
::
string
::{
String
,
ToString
};
use
alloc
::
vec
::
Vec
;
use
c_str
::
CStr
;
use
fs
::
File
;
use
header
::
fcntl
;
use
io
::{
self
,
BufRead
,
BufReader
};
pub
struct
Db
(
BufReader
<
File
>
);
impl
Db
{
pub
fn
new
(
path
:
&
CStr
)
->
io
::
Result
<
Self
>
{
File
::
open
(
path
,
fcntl
::
O_RDONLY
)
.map
(
BufReader
::
new
)
.map
(
Db
)
}
pub
fn
read
(
&
mut
self
)
->
io
::
Result
<
Vec
<
String
>>
{
let
mut
parts
=
Vec
::
new
();
let
mut
line
=
String
::
new
();
self
.0
.read_line
(
&
mut
line
)
?
;
if
let
Some
(
not_comment
)
=
line
.split
(
'#'
)
.next
()
{
for
part
in
not_comment
.split_whitespace
()
{
parts
.push
(
part
.to_string
());
}
}
Ok
(
parts
)
}
}
This diff is collapsed.
Click to expand it.
src/header/netdb/mod.rs
+
4
−
9
View file @
d0261ebb
...
@@ -10,12 +10,6 @@ use alloc::str::SplitWhitespace;
...
@@ -10,12 +10,6 @@ use alloc::str::SplitWhitespace;
use
alloc
::
vec
::
Vec
;
use
alloc
::
vec
::
Vec
;
use
c_str
::{
CStr
,
CString
};
use
c_str
::{
CStr
,
CString
};
use
platform
;
use
platform
::
rlb
::{
Line
,
RawLineBuffer
};
use
platform
::
types
::
*
;
use
platform
::{
Pal
,
Sys
};
use
header
::
arpa_inet
::{
htons
,
inet_aton
};
use
header
::
arpa_inet
::{
htons
,
inet_aton
};
use
header
::
errno
::
*
;
use
header
::
errno
::
*
;
use
header
::
fcntl
::
O_RDONLY
;
use
header
::
fcntl
::
O_RDONLY
;
...
@@ -25,6 +19,10 @@ use header::strings::strcasecmp;
...
@@ -25,6 +19,10 @@ use header::strings::strcasecmp;
use
header
::
sys_socket
::
constants
::
AF_INET
;
use
header
::
sys_socket
::
constants
::
AF_INET
;
use
header
::
sys_socket
::{
sockaddr
,
socklen_t
};
use
header
::
sys_socket
::{
sockaddr
,
socklen_t
};
use
header
::
unistd
::
SEEK_SET
;
use
header
::
unistd
::
SEEK_SET
;
use
platform
;
use
platform
::
rlb
::{
Line
,
RawLineBuffer
};
use
platform
::
types
::
*
;
use
platform
::{
Pal
,
Sys
};
#[cfg(target_os
=
"linux"
)]
#[cfg(target_os
=
"linux"
)]
#[path
=
"linux.rs"
]
#[path
=
"linux.rs"
]
...
@@ -34,9 +32,6 @@ pub mod sys;
...
@@ -34,9 +32,6 @@ pub mod sys;
#[path
=
"redox.rs"
]
#[path
=
"redox.rs"
]
pub
mod
sys
;
pub
mod
sys
;
//TODO: use self::db::Db;
pub
mod
db
;
use
self
::
lookup
::{
lookup_addr
,
lookup_host
};
use
self
::
lookup
::{
lookup_addr
,
lookup_host
};
pub
mod
lookup
;
pub
mod
lookup
;
...
...
This diff is collapsed.
Click to expand it.
src/lib.rs
+
1
−
0
View file @
d0261ebb
...
@@ -45,6 +45,7 @@ extern crate spin;
...
@@ -45,6 +45,7 @@ extern crate spin;
mod
macros
;
mod
macros
;
pub
mod
c_str
;
pub
mod
c_str
;
pub
mod
cxa
;
pub
mod
cxa
;
pub
mod
db
;
pub
mod
fs
;
pub
mod
fs
;
pub
mod
header
;
pub
mod
header
;
pub
mod
io
;
pub
mod
io
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment