Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Linux programozás nagyházi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eckl, Máté
Linux programozás nagyházi
Commits
d0caf918
Commit
d0caf918
authored
May 26, 2016
by
dnsadmin
Browse files
Options
Downloads
Patches
Plain Diff
Utasítások általánosítása (
#1
)(
#8
)
parent
263d9123
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/command.h
+37
-0
37 additions, 0 deletions
include/command.h
main.cpp
+16
-6
16 additions, 6 deletions
main.cpp
with
53 additions
and
6 deletions
include/command.h
0 → 100644
+
37
−
0
View file @
d0caf918
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: command.h
* Author: Eckl Máté <ecklm94@gmail.com>
*
* Created on 2016. május 26., 14:50
*/
#ifndef COMMAND_H
#define COMMAND_H
enum
command
{
MONITOR
,
STATISTICS
,
KILL
};
/**
* Returns the readable version of command
* @param c command to convert to string
* @return The string command or "" by default
*/
const
char
*
get_readable_command
(
command
c
)
{
switch
(
c
)
{
case
MONITOR
:
return
"monitor"
;
case
STATISTICS
:
return
"statistics"
;
case
KILL
:
return
"kill"
;
default:
return
""
;
}
}
#endif
/* COMMAND_H */
This diff is collapsed.
Click to expand it.
main.cpp
+
16
−
6
View file @
d0caf918
...
...
@@ -18,6 +18,7 @@
#include
"include/exceptions/db_exception.h"
#include
"include/logger.h"
#include
"include/IPC_US_communicator.h"
#include
"include/command.h"
#define WORKING_DIR "/home/mate/Dokumentumok/Egyetem/Tárgyak/2016 tavasz/Linux programozás/HF/DNS_server"
#define COMM_SOCK_PATH "/var/run/ecklm-dns/"
...
...
@@ -32,6 +33,7 @@ int main(int argc, char *argv[])
{
int
cli_option
;
bool
run_as_daemon
=
false
;
std
::
vector
<
command
>
command_list
;
while
((
cli_option
=
getopt
(
argc
,
argv
,
"dmskvh"
))
!=
-
1
)
{
switch
(
cli_option
)
...
...
@@ -40,13 +42,13 @@ int main(int argc, char *argv[])
run_as_daemon
=
true
;
break
;
case
'm'
:
throw
"Not implemented"
;
command_list
.
push_back
(
MONITOR
)
;
break
;
case
's'
:
throw
"Not implemented"
;
command_list
.
push_back
(
STATISTICS
)
;
break
;
case
'k'
:
throw
"Not implemented"
;
command_list
.
push_back
(
KILL
)
;
break
;
case
'v'
:
verbose
=
true
;
...
...
@@ -107,8 +109,16 @@ int main(int argc, char *argv[])
IPC_US_communicator
comm_link
(
COMM_SOCK_PATH
,
run_as_daemon
);
if
(
!
run_as_daemon
)
{
comm_link
.
send_data
(
"shutdown"
);
if
(
command_list
.
empty
())
{
log_on_demand
(
LOG_ERR
,
"In this mode you must specify at least one command!"
);
exit
(
EXIT_FAILURE
);
}
for
(
command
c
:
command_list
)
{
comm_link
.
send_data
(
get_readable_command
(
c
));
log_on_demand
(
LOG_INFO
,
"Answer received: %s"
,
comm_link
.
recv_data
().
c_str
());
}
exit
(
EXIT_SUCCESS
);
}
...
...
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