From c2610f2dd077d6dbde10d754493a977f3c3fa61c Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Fri, 16 Apr 2021 20:41:46 -0400 Subject: [PATCH] Fill out basic API functions. --- Makefile | 9 +- pdfio-array.c | 169 ++++++++++++++++++++++++++++ pdfio-dict.c | 194 ++++++++++++++++++++++++++++++++ pdfio-file.c | 97 ++++++++++++++++ pdfio-write.c => pdfio-object.c | 4 +- pdfio-page.c | 23 ++++ pdfio-stream.c | 61 ++++++++++ pdfio-read.c => pdfio-value.c | 2 +- pdfio.h | 18 +++ 9 files changed, 573 insertions(+), 4 deletions(-) create mode 100644 pdfio-array.c create mode 100644 pdfio-dict.c create mode 100644 pdfio-file.c rename pdfio-write.c => pdfio-object.c (84%) create mode 100644 pdfio-page.c create mode 100644 pdfio-stream.c rename pdfio-read.c => pdfio-value.c (85%) diff --git a/Makefile b/Makefile index 3ddcfe5..5675ced 100644 --- a/Makefile +++ b/Makefile @@ -37,9 +37,14 @@ prefix = /usr/local # Files LIBOBJS = \ + pdfio-array.o \ pdfio-common.o \ - pdfio-read.o \ - pdfio-write.o + pdfio-dict.o \ + pdfio-file.o \ + pdfio-object.o \ + pdfio-page.o \ + pdfio-stream.o \ + pdfio-value.o OBJS = \ $(LIBOBJS) \ testpdfio.o diff --git a/pdfio-array.c b/pdfio-array.c new file mode 100644 index 0000000..b54b1cb --- /dev/null +++ b/pdfio-array.c @@ -0,0 +1,169 @@ +// +// PDF array functions for pdfio. +// +// Copyright © 2021 by Michael R Sweet. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// + +// +// Include necessary headers... +// + +#include "pdfio-private.h" + + +// +// '()' - . +// + +bool pdfioArrayAppendArray(pdfio_array_t *a, pdfio_array_t *value) +{ +} + + +// +// '()' - . +// + +bool pdfioArrayAppendBoolean(pdfio_array_t *a, boolean value) +{ +} + + +// +// '()' - . +// + +bool pdfioArrayAppendDict(pdfio_array_t *a, pdfio_dict_t *value) +{ +} + + +// +// '()' - . +// + +bool pdfioArrayAppendName(pdfio_array_t *a, const char *value) +{ +} + + +// +// '()' - . +// + +bool pdfioArrayAppendNumber(pdfio_array_t *a, float value) +{ +} + + +// +// '()' - . +// + +bool pdfioArrayAppendObject(pdfio_array_t *a, pdfio_obj_t *value) +{ +} + + +// +// '()' - . +// + +bool pdfioArrayAppendString(pdfio_array_t *a, const char *value) +{ +} + + +// +// '()' - . +// + +pdfio_array_t *pdfioArrayCreate(pdfio_file_t *file) +{ +} + + +// +// '()' - . +// + +pdfio_array_t *pdfioArrayGetArray(pdfio_array_t *a, int n) +{ +} + + +// +// '()' - . +// + +bool pdfioArrayGetBoolean(pdfio_array_t *a, int n) +{ +} + + +// +// '()' - . +// + +pdfio_dict_t *pdfioArrayGetDict(pdfio_array_t *a, int n) +{ +} + + +// +// '()' - . +// + +const char *pdfioArrayGetName(pdfio_array_t *a, int n) +{ +} + + +// +// '()' - . +// + +float pdfioArrayGetNumber(pdfio_array_t *a, int n) +{ +} + + +// +// '()' - . +// + +pdfio_obj_t *pdfioArrayGetObject(pdfio_array_t *a, int n) +{ +} + + +// +// '()' - . +// + +int pdfioArrayGetSize(pdfio_array_t *a) +{ +} + + +// +// '()' - . +// + +const char *pdfioArrayGetString(pdfio_array_t *a, int n) +{ +} + + +// +// '()' - . +// + +pdfio_valtype_t pdfioArrayGetType(pdfio_array_t *a, int n) +{ +} + + diff --git a/pdfio-dict.c b/pdfio-dict.c new file mode 100644 index 0000000..b4d1de0 --- /dev/null +++ b/pdfio-dict.c @@ -0,0 +1,194 @@ +// +// PDF dictionary functions for pdfio. +// +// Copyright © 2021 by Michael R Sweet. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// + +// +// Include necessary headers... +// + +#include "pdfio-private.h" + + +// +// '()' - . +// + +pdfio_dict_t *pdfioDictCreate(pdfio_file_t *file) +{ +} + + +// +// '()' - . +// + +pdfio_array_t *pdfioDictGetArray(pdfio_dict_t *dict, const char *name) +{ +} + + +// +// '()' - . +// + +bool pdfioDictGetBoolean(pdfio_dict_t *dict, const char *name) +{ +} + + +// +// '()' - . +// + +pdfio_dict_t *pdfioDictGetDict(pdfio_dict_t *dict, const char *name) +{ +} + + +// +// '()' - . +// + +const char *pdfioDictGetName(pdfio_dict_t *dict, const char *name) +{ +} + + +// +// '()' - . +// + +float pdfioDictGetNumber(pdfio_dict_t *dict, const char *name) +{ +} + + +// +// '()' - . +// + +pdfio_obj_t *pdfioDictGetObject(pdfio_dict_t *dict, const char *name) +{ +} + + +// +// '()' - . +// + +pdfio_rect_t *pdfioDictGetRect(pdfio_dict_t *dict, const char *name, pdfio_rect_t *rect) +{ +} + + +// +// '()' - . +// + +const char *pdfioDictGetString(pdfio_dict_t *dict, const char *name) +{ +} + + +// +// '()' - . +// + +pdfio_valtype_t pdfioDictGetType(pdfio_dict_t *dict, const char *name) +{ +} + + +// +// '()' - . +// + +bool pdfioDictSetArray(pdfio_dict_t *dict, const char *name, pdfio_array_t *value) +{ +} + + +// +// '()' - . +// + +bool pdfioDictSetBoolean(pdfio_dict_t *dict, const char *name, bool value) +{ +} + + +// +// '()' - . +// + +bool pdfioDictSetDict(pdfio_dict_t *dict, const char *name, pdfio_dict_t *value) +{ +} + + +// +// '()' - . +// + +bool pdfioDictSetName(pdfio_dict_t *dict, const char *name, const char *value) +{ +} + + +// +// '()' - . +// + +bool pdfioDictSetNull(pdfio_dict_t *dict, const char *name) +{ +} + + +// +// '()' - . +// + +bool pdfioDictSetNumber(pdfio_dict_t *dict, const char *name, float value) +{ +} + + +// +// '()' - . +// + +bool pdfioDictSetObject(pdfio_dict_t *dict, const char *name, pdfio_obj_t *value) +{ +} + + +// +// '()' - . +// + +bool pdfioDictSetRect(pdfio_dict_t *dict, const char *name, pdfio_rect_t *value) +{ +} + + +// +// '()' - . +// + +bool pdfioDictSetString(pdfio_dict_t *dict, const char *name, const char *value) +{ +} + + +// +// '()' - . +// + +bool pdfioDictSetStringf(pdfio_dict_t *dict, const char *name, const char *format, ...) +{ +} diff --git a/pdfio-file.c b/pdfio-file.c new file mode 100644 index 0000000..1cb7d6b --- /dev/null +++ b/pdfio-file.c @@ -0,0 +1,97 @@ +// +// PDF file functions for pdfio. +// +// Copyright © 2021 by Michael R Sweet. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// + +// +// Include necessary headers... +// + +#include "pdfio-private.h" + + +// +// '()' - . +// + +bool pdfioFileClose(pdfio_file_t *pdf) +{ +} + + +// +// '()' - . +// + +pdfio_obj_t *pdfioFileCreateObject(pdfio_file_t *file, pdfio_dict_t *dict) +{ +} + + +// +// '()' - . +// + +pdfio_obj_t *pdfioFileCreatePage(pdfio_t *pdf, pdfio_dict_t *dict) +{ +} + + +// +// '()' - . +// + +const char *pdfioFileGetName(pdfio_file_t *pdf) +{ +} + + +// +// '()' - . +// + +int pdfioFileGetNumObjects(pdfio_file_t *pdf) +{ +} + + +// +// '()' - . +// + +int pdfioFileGetNumPages(pdfio_file_t *pdf) +{ +} + + +// +// '()' - . +// + +pdfio_obj_t *pdfioFileGetObject(pdfio_file_t *pdf, int number) +{ +} + + +// +// '()' - . +// + +pdfio_obj_t *pdfioFileGetPage(pdfio_file_t *pdf, int number) +{ +} + + +// +// '()' - . +// + +pdfio_file_t *pdfioFileOpen(const char *filename, const char *mode, pdfio_error_cb_t error_cb, void *error_data) +{ +} + + diff --git a/pdfio-write.c b/pdfio-object.c similarity index 84% rename from pdfio-write.c rename to pdfio-object.c index dbd3850..e634347 100644 --- a/pdfio-write.c +++ b/pdfio-object.c @@ -1,5 +1,5 @@ // -// PDF writing functions for pdfio. +// PDF object functions for pdfio. // // Copyright © 2021 by Michael R Sweet. // @@ -12,3 +12,5 @@ // #include "pdfio-private.h" + + diff --git a/pdfio-page.c b/pdfio-page.c new file mode 100644 index 0000000..c9b0b99 --- /dev/null +++ b/pdfio-page.c @@ -0,0 +1,23 @@ +// +// PDF page functions for pdfio. +// +// Copyright © 2021 by Michael R Sweet. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// + +// +// Include necessary headers... +// + +#include "pdfio-private.h" + + +// +// '()' - . +// + +pdfio_obj_t *pdfioPageCopy(pdfio_t *pdf, pdfio_obj_t *src) +{ +} diff --git a/pdfio-stream.c b/pdfio-stream.c new file mode 100644 index 0000000..0b8823c --- /dev/null +++ b/pdfio-stream.c @@ -0,0 +1,61 @@ +// +// PDF stream functions for pdfio. +// +// Copyright © 2021 by Michael R Sweet. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// + +// +// Include necessary headers... +// + +#include "pdfio-private.h" + + +// +// '()' - . +// + +bool pdfioStreamClose(pdfio_stream_t *st) +{ +} + + +// +// '()' - . +// + +bool pdfioStreamPrintf(pdfio_stream_t *st, const char *format, ...) +{ +} + + +// +// '()' - . +// + +bool pdfioStreamPuts(pdfio_stream_t *st, const char *s) +{ +} + + +// +// '()' - . +// + +ssize_t pdfioStreamRead(pdfio_stream_t *st, void *buffer, size_t bytes) +{ +} + + +// +// '()' - . +// + +bool pdfioStreamWrite(pdfio_stream_t *st, const void *buffer, size_t bytes) +{ +} + + diff --git a/pdfio-read.c b/pdfio-value.c similarity index 85% rename from pdfio-read.c rename to pdfio-value.c index d9f19f7..fb61888 100644 --- a/pdfio-read.c +++ b/pdfio-value.c @@ -1,5 +1,5 @@ // -// PDF reading functions for pdfio. +// PDF value functions for pdfio. // // Copyright © 2021 by Michael R Sweet. // diff --git a/pdfio.h b/pdfio.h index b19c752..d9c3260 100644 --- a/pdfio.h +++ b/pdfio.h @@ -88,6 +88,24 @@ typedef struct _pdfio_value_s pdf_value_t; // Functions... // +extern bool pdfioArrayAppendArray(pdfio_array_t *a, pdfio_array_t *value) PDFIO_PUBLIC; +extern bool pdfioArrayAppendBoolean(pdfio_array_t *a, boolean value) PDFIO_PUBLIC; +extern bool pdfioArrayAppendDict(pdfio_array_t *a, pdfio_dict_t *value) PDFIO_PUBLIC; +extern bool pdfioArrayAppendName(pdfio_array_t *a, const char *value) PDFIO_PUBLIC; +extern bool pdfioArrayAppendNumber(pdfio_array_t *a, float value) PDFIO_PUBLIC; +extern bool pdfioArrayAppendObject(pdfio_array_t *a, pdfio_obj_t *value) PDFIO_PUBLIC; +extern bool pdfioArrayAppendString(pdfio_array_t *a, const char *value) PDFIO_PUBLIC; +extern pdfio_array_t *pdfioArrayCreate(pdfio_file_t *file) PDFIO_PUBLIC; +extern pdfio_array_t *pdfioArrayGetArray(pdfio_array_t *a, int n) PDFIO_PUBLIC; +extern bool pdfioArrayGetBoolean(pdfio_array_t *a, int n) PDFIO_PUBLIC; +extern pdfio_dict_t *pdfioArrayGetDict(pdfio_array_t *a, int n) PDFIO_PUBLIC; +extern const char *pdfioArrayGetName(pdfio_array_t *a, int n) PDFIO_PUBLIC; +extern float pdfioArrayGetNumber(pdfio_array_t *a, int n) PDFIO_PUBLIC; +extern pdfio_obj_t *pdfioArrayGetObject(pdfio_array_t *a, int n) PDFIO_PUBLIC; +extern int pdfioArrayGetSize(pdfio_array_t *a) PDFIO_PUBLIC; +extern const char *pdfioArrayGetString(pdfio_array_t *a, int n) PDFIO_PUBLIC; +extern pdfio_valtype_t pdfioArrayGetType(pdfio_array_t *a, int n) PDFIO_PUBLIC; + extern pdfio_dict_t *pdfioDictCreate(pdfio_file_t *file) PDFIO_PUBLIC; extern pdfio_array_t *pdfioDictGetArray(pdfio_dict_t *dict, const char *name) PDFIO_PUBLIC; extern bool pdfioDictGetBoolean(pdfio_dict_t *dict, const char *name) PDFIO_PUBLIC;