Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Lindsay Knupp
csci315
Commits
b235963b
Commit
b235963b
authored
Dec 02, 2021
by
Lindsay Knupp
Browse files
Pre-lab 10.1 completed
parent
1fbc381b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Labs/Lab10/Makefile
View file @
b235963b
...
...
@@ -22,9 +22,9 @@
# compiler
CC
=
gcc
CFLAGS
=
-g
-Wall
CFLAGS
=
-std
=
gnu99
-g
-Wall
EXE
=
file_stat read_dir
EXE
=
file_stat read_dir
fdump
all
:
$(EXE)
...
...
@@ -40,5 +40,11 @@ read_dir: read_dir.o
read_dir.o
:
read_dir.c
$(CC)
-c
$(CFLAGS)
read_dir.c
hexdump.o
:
hexdump.h hexdump.c
$(CC)
$(CFLAGS)
-c
hexdump.c
-o
hexdump.o
fdump
:
fdump.c hexdump.o
$(CC)
$(CFLAGS)
fdump.c hexdump.o
-o
fdump
clean
:
/bin/rm
-f
*
~
*
.o core
$(EXE)
Labs/Lab10/fdump.c
View file @
b235963b
...
...
@@ -7,10 +7,42 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include "hexdump.h"
#define MAXLEN 20
int
main
(
int
argc
,
char
*
argv
[]){
FILE
*
fp
;
char
filename
[
MAXLEN
];
unsigned
int
offset
;
unsigned
int
size
;
unsigned
char
buffer
[
256
];
if
(
argc
<
4
){
printf
(
"Correct usage: %s [filename] [offset] [size]
\n
"
,
argv
[
0
]);
exit
(
-
1
);
}
else
{
strcpy
(
filename
,
argv
[
1
]);
offset
=
atoi
(
argv
[
2
]);
size
=
atoi
(
argv
[
3
]);
}
fp
=
fopen
(
filename
,
"r+"
);
fseek
(
fp
,
offset
,
SEEK_SET
);
for
(
int
i
=
0
;
i
<
size
;
i
++
){
buffer
[
i
]
=
fgetc
(
fp
);
}
fclose
(
fp
);
hexdump
(
buffer
,
size
+
1
);
return
0
;
}
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