diff options
| author | Carlos Maiolino <[email protected]> | 2025-07-10 22:55:07 +0200 |
|---|---|---|
| committer | Carlos Maiolino <[email protected]> | 2025-07-10 22:56:55 +0200 |
| commit | d98f46ce647846b0aa30b2e16a30fd4e152a1bf5 (patch) | |
| tree | 267474fcc77cf20b428f6f4c7f768ca09f4cfe0e /C/final-project-z2h/include | |
| parent | 869e68986aa8f69af6e7842260a68d1e5c6f796f (diff) | |
Add new code
Signed-off-by: Carlos Maiolino <[email protected]>
Diffstat (limited to 'C/final-project-z2h/include')
| -rw-r--r-- | C/final-project-z2h/include/common.h | 8 | ||||
| -rw-r--r-- | C/final-project-z2h/include/file.h | 7 | ||||
| -rw-r--r-- | C/final-project-z2h/include/parse.h | 26 |
3 files changed, 41 insertions, 0 deletions
diff --git a/C/final-project-z2h/include/common.h b/C/final-project-z2h/include/common.h new file mode 100644 index 0000000..839cc6f --- /dev/null +++ b/C/final-project-z2h/include/common.h @@ -0,0 +1,8 @@ +#ifndef COMMON_H +#define COMMON_H + +#define STATUS_ERROR -1 +#define STATUS_SUCCESS 0 + + +#endif diff --git a/C/final-project-z2h/include/file.h b/C/final-project-z2h/include/file.h new file mode 100644 index 0000000..73fd2a7 --- /dev/null +++ b/C/final-project-z2h/include/file.h @@ -0,0 +1,7 @@ +#ifndef FILE_H +#define FILE_H + +int create_db_file(char *filename); +int open_db_file(char *filename); + +#endif diff --git a/C/final-project-z2h/include/parse.h b/C/final-project-z2h/include/parse.h new file mode 100644 index 0000000..edcda9b --- /dev/null +++ b/C/final-project-z2h/include/parse.h @@ -0,0 +1,26 @@ +#ifndef PARSE_H +#define PARSE_H + +#define HEADER_MAGIC 0x4c4c4144 + +struct dbheader_t { + unsigned int magic; + unsigned short version; + unsigned short count; + unsigned int filesize; +}; + +struct employee_t { + char name[256]; + char address[256]; + unsigned int hours; +}; + +int create_db_header(int fd, struct dbheader_t **headerOut); +int validate_db_header(int fd, struct dbheader_t **headerOut); +int read_employees(int fd, struct dbheader_t *, struct employee_t **employeesOut); +int output_file(int fd, struct dbheader_t *, struct employee_t *employees); +void list_employees(struct dbheader_t *dbhdr, struct employee_t *employees); +int add_employee(struct dbheader_t *dbhdr, struct employee_t *employees, char *addstring); + +#endif |
