Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
redes1-trabalho1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eduardo Machado
redes1-trabalho1
Commits
90bfe904
Commit
90bfe904
authored
9 years ago
by
Victor Perszel
Browse files
Options
Downloads
Patches
Plain Diff
continuando ls / data continua com ultimo dado
parent
0f5809cb
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
include/submessages.h
+1
-1
1 addition, 1 deletion
include/submessages.h
src/main.cpp
+2
-1
2 additions, 1 deletion
src/main.cpp
src/messages.cpp
+20
-1
20 additions, 1 deletion
src/messages.cpp
src/submessages.cpp
+3
-0
3 additions, 0 deletions
src/submessages.cpp
with
26 additions
and
3 deletions
include/submessages.h
+
1
−
1
View file @
90bfe904
...
...
@@ -9,7 +9,7 @@ class SubMessage{
private:
unsigned
char
startMessage
;
// Delimitador de início.
int
sizSeqTyp
;
// 6 bits para tamanho, 6 bits para sequencia e 4 bits para o tipo.
unsigned
char
*
data
;
// Área para envio dos dados.
unsigned
char
*
data
=
NULL
;
// Área para envio dos dados.
unsigned
char
parity
;
// 1 Byte para a paridade vertical (detecção de erros).
// Calcula a paridade da mensagem, esse método está como privado para ser
...
...
This diff is collapsed.
Click to expand it.
src/main.cpp
+
2
−
1
View file @
90bfe904
...
...
@@ -88,7 +88,8 @@ int main(int argc, char *argv[]) {
resposta
.
setData
((
unsigned
char
*
)
"4"
,
0
,
0
);
// Manda um Nack
send
(
soquete
,
resposta
.
objToString
(),
68
,
0
);
}
else
{
if
(
mainMessage
.
receiveLS
(
resposta
.
getData
(),
currentPath
)){
cout
<<
"res "
<<
serverReceive
.
getData
()
<<
endl
;
if
(
mainMessage
.
receiveLS
(
serverReceive
.
getData
(),
currentPath
)){
cout
<<
"ERRO: ls remoto."
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/messages.cpp
+
20
−
1
View file @
90bfe904
...
...
@@ -544,27 +544,41 @@ int Message::receiveLS(unsigned char* options, char* currentPath){
ifstream
lsFile
;
unsigned
char
*
lsData
;
int
i
;
cout
<<
"-1-"
<<
endl
;
parameter
=
(
char
*
)
options
;
cout
<<
"-parameter- "
<<
parameter
<<
endl
;
path
=
currentPath
;
cout
<<
"-3-"
<<
endl
;
/* Para dar um ls apenas, é necessário escrever "ls ." */
/* Precisamos pensar em um jeito de concertar isso. */
switch
(
lsParameter
(
parameter
)){
case
1
:
cout
<<
"-case1-"
<<
endl
;
lsAux
=
"ls > "
+
path
+
"/ls.txt"
;
cout
<<
"-case1.1-"
<<
endl
;
system
(
lsAux
.
c_str
());
cout
<<
"-case1.2-"
<<
endl
;
break
;
case
2
:
cout
<<
"-case2-"
<<
endl
;
lsAux
=
"ls -a > "
+
path
+
"/ls.txt"
;
cout
<<
"-case2.1-"
<<
endl
;
system
(
lsAux
.
c_str
());
cout
<<
"-case2.2-"
<<
endl
;
break
;
case
3
:
cout
<<
"-case3-"
<<
endl
;
lsAux
=
"ls -l > "
+
path
+
"/ls.txt"
;
cout
<<
"-case3.1-"
<<
endl
;
system
(
lsAux
.
c_str
());
cout
<<
"-case3.2-"
<<
endl
;
break
;
case
4
:
cout
<<
"-case4-"
<<
endl
;
lsAux
=
"ls -la > "
+
path
+
"/ls.txt"
;
cout
<<
"-case4.1-"
<<
endl
;
system
(
lsAux
.
c_str
());
cout
<<
"-case4.2-"
<<
endl
;
break
;
case
-
1
:
puts
(
"Parâmetro de ls inválido."
);
...
...
@@ -577,11 +591,13 @@ int Message::receiveLS(unsigned char* options, char* currentPath){
fileName
=
path
+
"/ls.txt"
;
lsFile
.
open
(
fileName
.
c_str
(),
ios
::
in
);
lsFile
.
seekg
(
0
);
cout
<<
"+1+"
<<
endl
;
// Leitura do arquivo.
show
+=
path
+
"
\n
"
;
while
(
getline
(
lsFile
,
temp
))
{
show
+=
temp
+
"
\n
"
;
}
cout
<<
"+2+"
<<
endl
;
// Remove arquivo ls.txt
remove
(
fileName
.
c_str
());
...
...
@@ -589,10 +605,13 @@ int Message::receiveLS(unsigned char* options, char* currentPath){
for
(
i
=
0
;
i
<
show
.
size
();
i
++
){
lsData
[
i
]
=
show
[
i
];
}
cout
<<
"+3+"
<<
endl
;
if
(
sendData
(
lsData
)
==
0
){
cout
<<
"+return 0+"
<<
endl
;
return
0
;
}
else
{
cout
<<
"+return -1+"
<<
endl
;
return
-
1
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/submessages.cpp
+
3
−
0
View file @
90bfe904
...
...
@@ -54,6 +54,9 @@ void SubMessage::setData(unsigned char* dataBody, int type, int seq){
int
i
,
tamanho
=
1
;
while
(
dataBody
[
tamanho
-
1
]
!=
'\0'
&&
tamanho
<
64
)
tamanho
++
;
cout
<<
"AQUI"
<<
endl
;
delete
(
data
);
cout
<<
"FERA"
<<
endl
;
data
=
new
unsigned
char
[
tamanho
];
for
(
i
=
0
;
i
<
tamanho
;
i
++
){
...
...
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