Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
biboumi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
88
Issues
88
List
Boards
Labels
Service Desk
Milestones
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
louiz’
biboumi
Commits
b60cbda4
Commit
b60cbda4
authored
Nov 12, 2013
by
louiz’
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Read the served hostname from the config file
parent
2be4811d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
6 deletions
+22
-6
src/main.cpp
src/main.cpp
+22
-6
No files found.
src/main.cpp
View file @
b60cbda4
...
...
@@ -5,26 +5,42 @@
#include <iostream>
#include <memory>
/**
* Provide an helpful message to help the user write a minimal working
* configuration file.
*/
int
config_help
(
const
std
::
string
&
missing_option
)
{
if
(
!
missing_option
.
empty
())
std
::
cerr
<<
"Error: empty value for option "
<<
missing_option
<<
"."
<<
std
::
endl
;
std
::
cerr
<<
"Please provide a configuration file filled like this:
\n\n
"
"hostname=irc.example.com
\n
password=S3CR3T"
<<
std
::
endl
;
return
1
;
}
int
main
(
int
ac
,
char
**
av
)
{
if
(
ac
>
1
)
Config
::
filename
=
av
[
1
];
Config
::
file_must_exist
=
true
;
std
::
cerr
<<
"Using configuration file: "
<<
Config
::
filename
<<
std
::
endl
;
std
::
string
password
;
try
{
// The file must exist
password
=
Config
::
get
(
"password"
,
""
);
}
catch
(
const
std
::
ios
::
failure
&
e
)
{
return
1
;
return
config_help
(
""
)
;
}
const
std
::
string
hostname
=
Config
::
get
(
"hostname"
,
""
);
if
(
password
.
empty
())
{
std
::
cerr
<<
"No password provided."
<<
std
::
endl
;
return
1
;
}
return
config_help
(
"hostname"
);
if
(
hostname
.
empty
())
return
config_help
(
"password"
);
std
::
shared_ptr
<
XmppComponent
>
xmpp_component
=
std
::
make_shared
<
XmppComponent
>
(
"irc.abricot"
,
password
);
std
::
make_shared
<
XmppComponent
>
(
hostname
,
password
);
Poller
p
;
p
.
add_socket_handler
(
xmpp_component
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment