-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Writer implemented as in requirements
- Loading branch information
Dariusz
authored and
Dariusz
committed
Jan 9, 2025
1 parent
8bae9f4
commit 43d7fe7
Showing
4 changed files
with
71 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
writer: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.7.0, with debug_info, not stripped |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
CC = gcc | ||
CFLAGS = -g | ||
RM = rm -f | ||
|
||
default: writer | ||
|
||
writer: writer.c | ||
$(CROSS_COMPILE)$(CC) $(CFLAGS) -o writer writer.c | ||
|
||
clean veryclean: | ||
$(RM) writer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include <stdio.h> | ||
#include <syslog.h> | ||
|
||
|
||
int main(int argc, char **argv) | ||
{ | ||
char* str_content; | ||
char* f_name; | ||
FILE *fp = NULL; | ||
|
||
openlog(NULL, 0, LOG_USER); | ||
|
||
if (argc < 2) | ||
{ | ||
syslog(LOG_ERR, "Wrong number of arguments %d", argc ); | ||
return 1; | ||
} | ||
else | ||
{ | ||
str_content = argv[2]; | ||
f_name = argv[1]; | ||
|
||
if((str_content == NULL) || (f_name == NULL)) | ||
{ | ||
syslog(LOG_ERR, "Wrong argument"); | ||
return 1; | ||
} | ||
else | ||
{ | ||
syslog(LOG_DEBUG, "Writing %s to %s", str_content, f_name ); | ||
|
||
fp = fopen(f_name ,"w"); | ||
|
||
if ( fp != NULL) | ||
{ | ||
if (0 > fprintf(fp, "%s", str_content)) | ||
{ | ||
syslog(LOG_DEBUG, "Writing to file failed" ); | ||
return 1; | ||
} | ||
fclose(fp); | ||
return 0; | ||
} | ||
else | ||
{ | ||
return 1; | ||
} | ||
|
||
} | ||
} | ||
|
||
|
||
|
||
|
||
printf("writer done\n"); | ||
} |