diff --git a/Makefile.in b/Makefile.in index 1f02ce52513a92c3abd77f32ba518b4e5fcdb49f..6372eeb18f2c8713c6470a4617bc084f57f82315 100644 --- a/Makefile.in +++ b/Makefile.in @@ -29,25 +29,21 @@ RM = @RM@ all: - @for DIR in src; do \ - echo "===> $${DIR}"; \ - (cd $${DIR}; make all); \ - echo "<=== $${DIR}"; \ - done + make -C src all + +test: all + make -C tests test install: - (cd src/; make install) + make -C src install deinstall: uninstall uninstall: (cd src/; make deinstall) clean: - @for DIR in src; do \ - echo "===> $${DIR}"; \ - (cd $${DIR}; make clean); \ - echo "<=== $${DIR}"; \ - done + make -C src clean + distclean: clean @for DIR in src tests examples; do \ diff --git a/README.md b/README.md index fc75aea2012758ccdfc80f734a509262af929b7d..e349eb2da9eedc626760061393a6b3dabbfc1bb9 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,7 @@ The following people have helped with suggestions, ideas, code or fixing bugs: * [Alexandre Lucchesi](https://github.com/alexandrelucchesi) * [Anthony Tseng](https://github.com/darkdh) +* [Carpentier Pierre-Francois](https://github.com/kakwa) * Cesar * [Colin](https://github.com/colintd) * [Charles](https://github.com/Charles0429) @@ -147,7 +148,7 @@ The following people have helped with suggestions, ideas, code or fixing bugs: * Maik Beckmann * RQ * [Ryan Gonzalez](https://github.com/kirbyfan64) -* [Seungyoung Kim](https://github.com/wolkykim) +* [Seungyoung "Steve" Kim](https://github.com/wolkykim) - Project Lead * Umesh If we have forgotten or misspelled your name, please let us know. diff --git a/config.guess b/config.guess old mode 100644 new mode 100755 diff --git a/config.sub b/config.sub old mode 100644 new mode 100755 diff --git a/configure b/configure old mode 100644 new mode 100755 diff --git a/include/qlibc/containers/qhasharr.h b/include/qlibc/containers/qhasharr.h index 23f2e089386d5cc6557154de9e5a932e0c54a7e1..4d4c0908864c212b4ae23cc1b3f659bd4414c522 100644 --- a/include/qlibc/containers/qhasharr.h +++ b/include/qlibc/containers/qhasharr.h @@ -35,7 +35,6 @@ #ifndef QHASHARR_H #define QHASHARR_H -#include #include #include #include diff --git a/include/qlibc/containers/qlist.h b/include/qlibc/containers/qlist.h index f96cde1b2fe619291d91e81bea7c86ea8ca7549f..a0a276d9e7af43e875d29865d9779d2dceb09dcc 100644 --- a/include/qlibc/containers/qlist.h +++ b/include/qlibc/containers/qlist.h @@ -44,14 +44,14 @@ extern "C" { #endif -enum { - QLIST_THREADSAFE = (0x01) /*!< make it thread-safe */ -}; - /* types */ typedef struct qlist_s qlist_t; typedef struct qlist_obj_s qlist_obj_t; +enum { + QLIST_THREADSAFE = (0x01) /*!< make it thread-safe */ +}; + /* member functions * * All the member functions can be accessed in both ways: diff --git a/include/qlibc/containers/qlisttbl.h b/include/qlibc/containers/qlisttbl.h index e5ff89064d2d84db7ca1bf0c4cc14637671725df..ece47f6e554de36f8f43d2bdb4501b2a246fa299 100644 --- a/include/qlibc/containers/qlisttbl.h +++ b/include/qlibc/containers/qlisttbl.h @@ -35,7 +35,6 @@ #ifndef QLISTTBL_H #define QLISTTBL_H -#include #include #include #include @@ -49,23 +48,13 @@ typedef struct qlisttbl_s qlisttbl_t; typedef struct qlisttbl_obj_s qlisttbl_obj_t; typedef struct qlisttbl_data_s qlisttbl_data_t; -/* - //이클립스에서 indexing이 안되서 수정 enum { - QLISTTBL_THREADSAFE = (0x01), !< make it thread-safe - QLISTTBL_UNIQUE = (0x01 << 1), !< keys are unique - QLISTTBL_CASEINSENSITIVE = (0x01 << 2), !< keys are case insensitive - QLISTTBL_INSERTTOP = (0x01 << 3), !< insert new key at the top - QLISTTBL_LOOKUPFORWARD = (0x01 << 4), !< find key from the top (default: backward) + QLISTTBL_THREADSAFE = (0x01), /*!< make it thread-safe */ + QLISTTBL_UNIQUE = (0x01 << 1), /*!< keys are unique */ + QLISTTBL_CASEINSENSITIVE = (0x01 << 2), /*!< keys are case insensitive */ + QLISTTBL_INSERTTOP = (0x01 << 3), /*!< insert new key at the top */ + QLISTTBL_LOOKUPFORWARD = (0x01 << 4), /*!< find key from the top (default: backward) */ }; -*/ - -#define QLISTTBL_THREADSAFE (0x01) /*!< make it thread-safe */ -#define QLISTTBL_UNIQUE (0x01 << 1) /*!< keys are unique */ -#define QLISTTBL_CASEINSENSITIVE (0x01 << 2) /*!< keys are case insensitive */ -#define QLISTTBL_INSERTTOP (0x01 << 3) /*!< insert new key at the top */ -#define QLISTTBL_LOOKUPFORWARD (0x01 << 4) /*!< find key from the top (default: backward) */ - /* member functions * @@ -93,7 +82,7 @@ extern bool qlisttbl_removeobj(qlisttbl_t *tbl, const qlisttbl_obj_t *obj); extern bool qlisttbl_getnext(qlisttbl_t *tbl, qlisttbl_obj_t *obj, const char *name, bool newmem); extern size_t qlisttbl_size(qlisttbl_t *tbl); -extern void qlisttbl_sort(qlisttbl_t *tbl, const bool reverse); +extern void qlisttbl_sort(qlisttbl_t *tbl); extern void qlisttbl_clear(qlisttbl_t *tbl); extern bool qlisttbl_save(qlisttbl_t *tbl, const char *filepath, char sepchar, bool encode); extern ssize_t qlisttbl_load(qlisttbl_t *tbl, const char *filepath, char sepchar, bool decode); @@ -130,7 +119,7 @@ struct qlisttbl_s { bool (*getnext) (qlisttbl_t *tbl, qlisttbl_obj_t *obj, const char *name, bool newmem); size_t (*size) (qlisttbl_t *tbl); - void (*sort) (qlisttbl_t *tbl, const bool reverse); + void (*sort) (qlisttbl_t *tbl); void (*clear) (qlisttbl_t *tbl); bool (*save) (qlisttbl_t *tbl, const char *filepath, char sepchar, diff --git a/include/qlibc/containers/qvector.h b/include/qlibc/containers/qvector.h index b9689dfe963be8030c4992e07392da5286f08b87..1fdbb1d349cbf5a29700eabce2efee0aecc22b97 100644 --- a/include/qlibc/containers/qvector.h +++ b/include/qlibc/containers/qvector.h @@ -39,7 +39,6 @@ #ifndef QVECTOR_H #define QVECTOR_H -#include #include #include #include @@ -52,9 +51,6 @@ extern "C" { typedef struct qvector_s qvector_t; typedef struct qvector_obj_s qvector_obj_t; -///////////////// -//이클립스에서 indexing이 안되서 수정 -////////////// /* public functions */ enum { QVECTOR_THREADSAFE = (0x01), /*!< make it thread-safe */ @@ -63,12 +59,6 @@ enum { QVECTOR_RESIZE_EXACT = (0x08) /*!< add up as much as needed*/ }; -//#define QVECTOR_THREADSAFE (0x01), /*!< make it thread-safe */ -//#define QVECTOR_RESIZE_DOUBLE (0x02), /*!< double the size when vector is full*/ -//#define QVECTOR_RESIZE_LINEAR (0x04), /*!< add the size with initial num when vector is full*/ -//#define QVECTOR_RESIZE_EXACT (0x08) /*!< add up as much as needed*/ - - extern qvector_t *qvector(size_t max, size_t objsize, int options); extern bool qvector_addfirst(qvector_t *vector, const void *data); diff --git a/include/qlibc/extensions/qhttpclient.h b/include/qlibc/extensions/qhttpclient.h index ba9f5c705873ce079143a793ea051416a02266ae..3883d02f1dc70bd945d71cf6c52f862d431a3b76 100644 --- a/include/qlibc/extensions/qhttpclient.h +++ b/include/qlibc/extensions/qhttpclient.h @@ -84,12 +84,6 @@ struct qhttpclient_s { size_t *contentslength, qlisttbl_t *reqheaders, qlisttbl_t *resheaders); - char *(*json) (qhttpclient_t *client, - const char *method, const char *uri, - char *data, size_t size, int *rescode, - size_t *contentslength, - qlisttbl_t *reqheaders, qlisttbl_t *resheaders); - bool (*sendrequest) (qhttpclient_t *client, const char *method, const char *uri, qlisttbl_t *reqheaders); int (*readresponse) (qhttpclient_t *client, qlisttbl_t *resheaders, @@ -100,7 +94,7 @@ struct qhttpclient_s { ssize_t (*write) (qhttpclient_t *client, const void *buf, size_t nbytes); off_t (*recvfile) (qhttpclient_t *client, int fd, off_t nbytes); - off_t (*sendfile) (qhttpclient_t *client, int fd, off_t nbytes); + off_t (*sendfile) (qhttpclient_t *client, int fd, off_t nbytes); bool (*close) (qhttpclient_t *client); void (*free) (qhttpclient_t *client); diff --git a/include/qlibc/utilities/qfile.h b/include/qlibc/utilities/qfile.h index fcb8ebd59d88da3d98b9430b9175cc9edfb3643d..d1121b52a49e7cc298c41b49b0953ac00ed26656 100644 --- a/include/qlibc/utilities/qfile.h +++ b/include/qlibc/utilities/qfile.h @@ -35,7 +35,6 @@ #ifndef QFILE_H #define QFILE_H -#include #include #include #include diff --git a/install-sh b/install-sh old mode 100644 new mode 100755 diff --git a/src/Makefile.in b/src/Makefile.in index a42fb5ca823f46b075c536b398d2a5d71ea38443..4e274ed3ec8ec599476ebaf57b15b6dc570f135a 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -122,69 +122,70 @@ qlibcext: ${QLIBCEXT_OBJS} install: ${INSTALL_TARGETS} install-qlibc: qlibc - ${MKDIR_P} ${INST_INCDIR}/qlibc - ${INSTALL_DATA} ${QLIBC_INCDIR}/qlibc.h ${INST_INCDIR}/qlibc/qlibc.h - ${MKDIR_P} ${INST_INCDIR}/qlibc/containers/ - ${INSTALL_DATA} ${QLIBC_INCDIR}/containers/qtreetbl.h ${INST_INCDIR}/qlibc/containers/qtreetbl.h - ${INSTALL_DATA} ${QLIBC_INCDIR}/containers/qhashtbl.h ${INST_INCDIR}/qlibc/containers/qhashtbl.h - ${INSTALL_DATA} ${QLIBC_INCDIR}/containers/qhasharr.h ${INST_INCDIR}/qlibc/containers/qhasharr.h - ${INSTALL_DATA} ${QLIBC_INCDIR}/containers/qlisttbl.h ${INST_INCDIR}/qlibc/containers/qlisttbl.h - ${INSTALL_DATA} ${QLIBC_INCDIR}/containers/qlist.h ${INST_INCDIR}/qlibc/containers/qlist.h - ${INSTALL_DATA} ${QLIBC_INCDIR}/containers/qvector.h ${INST_INCDIR}/qlibc/containers/qvector.h - ${INSTALL_DATA} ${QLIBC_INCDIR}/containers/qqueue.h ${INST_INCDIR}/qlibc/containers/qqueue.h - ${INSTALL_DATA} ${QLIBC_INCDIR}/containers/qstack.h ${INST_INCDIR}/qlibc/containers/qstack.h - ${INSTALL_DATA} ${QLIBC_INCDIR}/containers/qgrow.h ${INST_INCDIR}/qlibc/containers/qgrow.h - ${MKDIR_P} ${INST_INCDIR}/qlibc/utilities/ - ${INSTALL_DATA} ${QLIBC_INCDIR}/utilities/qcount.h ${INST_INCDIR}/qlibc/utilities/qcount.h - ${INSTALL_DATA} ${QLIBC_INCDIR}/utilities/qencode.h ${INST_INCDIR}/qlibc/utilities/qencode.h - ${INSTALL_DATA} ${QLIBC_INCDIR}/utilities/qfile.h ${INST_INCDIR}/qlibc/utilities/qfile.h - ${INSTALL_DATA} ${QLIBC_INCDIR}/utilities/qhash.h ${INST_INCDIR}/qlibc/utilities/qhash.h - ${INSTALL_DATA} ${QLIBC_INCDIR}/utilities/qio.h ${INST_INCDIR}/qlibc/utilities/qio.h - ${INSTALL_DATA} ${QLIBC_INCDIR}/utilities/qsocket.h ${INST_INCDIR}/qlibc/utilities/qsocket.h - ${INSTALL_DATA} ${QLIBC_INCDIR}/utilities/qstring.h ${INST_INCDIR}/qlibc/utilities/qstring.h - ${INSTALL_DATA} ${QLIBC_INCDIR}/utilities/qsystem.h ${INST_INCDIR}/qlibc/utilities/qsystem.h - ${INSTALL_DATA} ${QLIBC_INCDIR}/utilities/qtime.h ${INST_INCDIR}/qlibc/utilities/qtime.h - ${MKDIR_P} ${INST_INCDIR}/qlibc/ipc/ - ${INSTALL_DATA} ${QLIBC_INCDIR}/ipc/qsem.h ${INST_INCDIR}/qlibc/ipc/qsem.h - ${INSTALL_DATA} ${QLIBC_INCDIR}/ipc/qshm.h ${INST_INCDIR}/qlibc/ipc/qshm.h - ${MKDIR_P} ${INST_LIBDIR} - ${INSTALL_DATA} ${QLIBC_LIBDIR}/${QLIBC_LIBNAME} ${INST_LIBDIR}/${QLIBC_LIBNAME} - ${INSTALL_DATA} ${QLIBC_LIBDIR}/${QLIBC_SLIBREALNAME} ${INST_LIBDIR}/${QLIBC_SLIBREALNAME} - ( cd ${INST_LIBDIR}; ${LN_S} -f ${QLIBC_SLIBREALNAME} ${QLIBC_SLIBNAME} ) + ${MKDIR_P} $(DESTDIR)/${INST_INCDIR}/qlibc + ${INSTALL_DATA} ${QLIBC_INCDIR}/qlibc.h $(DESTDIR)/${INST_INCDIR}/qlibc/qlibc.h + ${MKDIR_P} $(DESTDIR)/${INST_INCDIR}/qlibc/containers/ + ${INSTALL_DATA} ${QLIBC_INCDIR}/containers/qtreetbl.h $(DESTDIR)/${INST_INCDIR}/qlibc/containers/qtreetbl.h + ${INSTALL_DATA} ${QLIBC_INCDIR}/containers/qhashtbl.h $(DESTDIR)/${INST_INCDIR}/qlibc/containers/qhashtbl.h + ${INSTALL_DATA} ${QLIBC_INCDIR}/containers/qhasharr.h $(DESTDIR)/${INST_INCDIR}/qlibc/containers/qhasharr.h + ${INSTALL_DATA} ${QLIBC_INCDIR}/containers/qlisttbl.h $(DESTDIR)/${INST_INCDIR}/qlibc/containers/qlisttbl.h + ${INSTALL_DATA} ${QLIBC_INCDIR}/containers/qlist.h $(DESTDIR)/${INST_INCDIR}/qlibc/containers/qlist.h + ${INSTALL_DATA} ${QLIBC_INCDIR}/containers/qvector.h $(DESTDIR)/${INST_INCDIR}/qlibc/containers/qvector.h + ${INSTALL_DATA} ${QLIBC_INCDIR}/containers/qqueue.h $(DESTDIR)/${INST_INCDIR}/qlibc/containers/qqueue.h + ${INSTALL_DATA} ${QLIBC_INCDIR}/containers/qstack.h $(DESTDIR)/${INST_INCDIR}/qlibc/containers/qstack.h + ${INSTALL_DATA} ${QLIBC_INCDIR}/containers/qgrow.h $(DESTDIR)/${INST_INCDIR}/qlibc/containers/qgrow.h + ${MKDIR_P} $(DESTDIR)/${INST_INCDIR}/qlibc/utilities/ + ${INSTALL_DATA} ${QLIBC_INCDIR}/utilities/qcount.h $(DESTDIR)/${INST_INCDIR}/qlibc/utilities/qcount.h + ${INSTALL_DATA} ${QLIBC_INCDIR}/utilities/qencode.h $(DESTDIR)/${INST_INCDIR}/qlibc/utilities/qencode.h + ${INSTALL_DATA} ${QLIBC_INCDIR}/utilities/qfile.h $(DESTDIR)/${INST_INCDIR}/qlibc/utilities/qfile.h + ${INSTALL_DATA} ${QLIBC_INCDIR}/utilities/qhash.h $(DESTDIR)/${INST_INCDIR}/qlibc/utilities/qhash.h + ${INSTALL_DATA} ${QLIBC_INCDIR}/utilities/qio.h $(DESTDIR)/${INST_INCDIR}/qlibc/utilities/qio.h + ${INSTALL_DATA} ${QLIBC_INCDIR}/utilities/qsocket.h $(DESTDIR)/${INST_INCDIR}/qlibc/utilities/qsocket.h + ${INSTALL_DATA} ${QLIBC_INCDIR}/utilities/qstring.h $(DESTDIR)/${INST_INCDIR}/qlibc/utilities/qstring.h + ${INSTALL_DATA} ${QLIBC_INCDIR}/utilities/qsystem.h $(DESTDIR)/${INST_INCDIR}/qlibc/utilities/qsystem.h + ${INSTALL_DATA} ${QLIBC_INCDIR}/utilities/qtime.h $(DESTDIR)/${INST_INCDIR}/qlibc/utilities/qtime.h + ${MKDIR_P} $(DESTDIR)/${INST_INCDIR}/qlibc/ipc/ + ${INSTALL_DATA} ${QLIBC_INCDIR}/ipc/qsem.h $(DESTDIR)/${INST_INCDIR}/qlibc/ipc/qsem.h + ${INSTALL_DATA} ${QLIBC_INCDIR}/ipc/qshm.h $(DESTDIR)/${INST_INCDIR}/qlibc/ipc/qshm.h + ${MKDIR_P} $(DESTDIR)/${INST_LIBDIR} + ${INSTALL_DATA} ${QLIBC_LIBDIR}/${QLIBC_LIBNAME} $(DESTDIR)/${INST_LIBDIR}/${QLIBC_LIBNAME} + ${INSTALL_DATA} ${QLIBC_LIBDIR}/${QLIBC_SLIBREALNAME} $(DESTDIR)/${INST_LIBDIR}/${QLIBC_SLIBREALNAME} + ( cd $(DESTDIR)/${INST_LIBDIR}; ${LN_S} -f ${QLIBC_SLIBREALNAME} ${QLIBC_SLIBNAME} ) uninstall-qlibc: - ${RM} -f ${INST_INCDIR}/qlibc/qlibc.h - ${RM} -rf ${INST_INCDIR}/qlibc/containers - ${RM} -rf ${INST_INCDIR}/qlibc/utilities - ${RM} -rf ${INST_INCDIR}/qlibc/ipc - ${RM} -f ${INST_LIBDIR}/${QLIBC_LIBNAME} - ${RM} -f ${INST_LIBDIR}/${QLIBC_SLIBREALNAME} - ${RM} -f ${INST_LIBDIR}/${QLIBC_SLIBNAME} + ${RM} -f $(DESTDIR)/${INST_INCDIR}/qlibc/qlibc.h + ${RM} -rf $(DESTDIR)/${INST_INCDIR}/qlibc/containers + ${RM} -rf $(DESTDIR)/${INST_INCDIR}/qlibc/utilities + ${RM} -rf $(DESTDIR)/${INST_INCDIR}/qlibc/ipc + ${RM} -f $(DESTDIR)/${INST_LIBDIR}/${QLIBC_LIBNAME} + ${RM} -f $(DESTDIR)/${INST_LIBDIR}/${QLIBC_SLIBREALNAME} + ${RM} -f $(DESTDIR)/${INST_LIBDIR}/${QLIBC_SLIBNAME} install-qlibcext: qlibcext - ${MKDIR_P} ${INST_INCDIR}/qlibc - ${INSTALL_DATA} ${QLIBC_INCDIR}/qlibcext.h ${INST_INCDIR}/qlibc/qlibcext.h - ${MKDIR_P} ${INST_INCDIR}/qlibc/extensions/ - ${INSTALL_DATA} ${QLIBC_INCDIR}/extensions/qconfig.h ${INST_INCDIR}/qlibc/extensions/qconfig.h - ${INSTALL_DATA} ${QLIBC_INCDIR}/extensions/qaconf.h ${INST_INCDIR}/qlibc/extensions/qaconf.h - ${INSTALL_DATA} ${QLIBC_INCDIR}/extensions/qlog.h ${INST_INCDIR}/qlibc/extensions/qlog.h - ${INSTALL_DATA} ${QLIBC_INCDIR}/extensions/qhttpclient.h ${INST_INCDIR}/qlibc/extensions/qhttpclient.h - ${INSTALL_DATA} ${QLIBC_INCDIR}/extensions/qdatabase.h ${INST_INCDIR}/qlibc/extensions/qdatabase.h - ${MKDIR_P} ${INST_LIBDIR} - ${INSTALL_DATA} ${QLIBC_LIBDIR}/${QLIBCEXT_LIBNAME} ${INST_LIBDIR}/${QLIBCEXT_LIBNAME} - ${INSTALL_DATA} ${QLIBC_LIBDIR}/${QLIBCEXT_SLIBREALNAME} ${INST_LIBDIR}/${QLIBCEXT_SLIBREALNAME} - ( cd ${INST_LIBDIR}; ${LN_S} -f ${QLIBCEXT_SLIBREALNAME} ${QLIBCEXT_SLIBNAME} ) + ${MKDIR_P} $(DESTDIR)/${INST_INCDIR}/qlibc + ${INSTALL_DATA} ${QLIBC_INCDIR}/qlibcext.h $(DESTDIR)/${INST_INCDIR}/qlibc/qlibcext.h + ${MKDIR_P} $(DESTDIR)/${INST_INCDIR}/qlibc/extensions/ + ${INSTALL_DATA} ${QLIBC_INCDIR}/extensions/qconfig.h $(DESTDIR)/${INST_INCDIR}/qlibc/extensions/qconfig.h + ${INSTALL_DATA} ${QLIBC_INCDIR}/extensions/qaconf.h $(DESTDIR)/${INST_INCDIR}/qlibc/extensions/qaconf.h + ${INSTALL_DATA} ${QLIBC_INCDIR}/extensions/qlog.h $(DESTDIR)/${INST_INCDIR}/qlibc/extensions/qlog.h + ${INSTALL_DATA} ${QLIBC_INCDIR}/extensions/qhttpclient.h $(DESTDIR)/${INST_INCDIR}/qlibc/extensions/qhttpclient.h + ${INSTALL_DATA} ${QLIBC_INCDIR}/extensions/qdatabase.h $(DESTDIR)/${INST_INCDIR}/qlibc/extensions/qdatabase.h + ${INSTALL_DATA} ${QLIBC_INCDIR}/extensions/qtokenbucket.h $(DESTDIR)/${INST_INCDIR}/qlibc/extensions/qtokenbucket.h + ${MKDIR_P} $(DESTDIR)/${INST_LIBDIR} + ${INSTALL_DATA} ${QLIBC_LIBDIR}/${QLIBCEXT_LIBNAME} $(DESTDIR)/${INST_LIBDIR}/${QLIBCEXT_LIBNAME} + ${INSTALL_DATA} ${QLIBC_LIBDIR}/${QLIBCEXT_SLIBREALNAME} $(DESTDIR)/${INST_LIBDIR}/${QLIBCEXT_SLIBREALNAME} + ( cd $(DESTDIR)/${INST_LIBDIR}; ${LN_S} -f ${QLIBCEXT_SLIBREALNAME} ${QLIBCEXT_SLIBNAME} ) uninstall-qlibcext: - ${RM} -f ${INST_INCDIR}/qlibc/qlibcext.h - ${RM} -rf ${INST_INCDIR}/qlibc/extensions - ${RM} -f ${INST_LIBDIR}/${QLIBCEXT_LIBNAME} - ${RM} -f ${INST_LIBDIR}/${QLIBCEXT_SLIBREALNAME} - ${RM} -f ${INST_LIBDIR}/${QLIBCEXT_SLIBNAME} + ${RM} -f $(DESTDIR)/${INST_INCDIR}/qlibc/qlibcext.h + ${RM} -rf $(DESTDIR)/${INST_INCDIR}/qlibc/extensions + ${RM} -f $(DESTDIR)/${INST_LIBDIR}/${QLIBCEXT_LIBNAME} + ${RM} -f $(DESTDIR)/${INST_LIBDIR}/${QLIBCEXT_SLIBREALNAME} + ${RM} -f $(DESTDIR)/${INST_LIBDIR}/${QLIBCEXT_SLIBNAME} deinstall: uninstall uninstall: uninstall-qlibc uninstall-qlibcext - ${RMDIR} ${INST_INCDIR}/qlibc + ${RMDIR} $(DESTDIR)/${INST_INCDIR}/qlibc clean: ${RM} -f ${QLIBC_OBJS} diff --git a/src/autocompile.sh b/src/autocompile.sh old mode 100644 new mode 100755 diff --git a/src/containers/qlisttbl.c b/src/containers/qlisttbl.c index 7ac30947a2cf5cce660dd79fdb2e3ccac8074f72..a202cac53331673aab0a079ca67e0c32d3707105 100644 --- a/src/containers/qlisttbl.c +++ b/src/containers/qlisttbl.c @@ -823,7 +823,7 @@ size_t qlisttbl_size(qlisttbl_t *tbl) * b = 6 d = 1 a = 2 * @endcode */ -void qlisttbl_sort(qlisttbl_t *tbl, const bool reverse) +void qlisttbl_sort(qlisttbl_t *tbl) { // run bubble sort qlisttbl_lock(tbl); @@ -834,7 +834,7 @@ void qlisttbl_sort(qlisttbl_t *tbl, const bool reverse) n2 = 0; for (i = 0, obj1 = tbl->first; i < (n - 1); i++, obj1 = obj1->next) { obj2 = obj1->next; // this can't be null. - if ((tbl->namecmp(obj1->name, obj2->name) > 0) != reverse) { + if (tbl->namecmp(obj1->name, obj2->name) > 0) { // swapping contents is faster than adjusting links. tmpobj = *obj1; obj1->hash = obj2->hash; diff --git a/src/extensions/qhttpclient.c b/src/extensions/qhttpclient.c index e56ec50f396bdfd71eff7ff5af5bb4db678d31d3..ee67ff101a9bfff009385bf2e45b209a71b7b75d 100644 --- a/src/extensions/qhttpclient.c +++ b/src/extensions/qhttpclient.c @@ -161,10 +161,6 @@ static void *cmd(qhttpclient_t *client, const char *method, const char *uri, void *data, size_t size, int *rescode, size_t *contentslength, qlisttbl_t *reqheaders, qlisttbl_t *resheaders); -static char *json(qhttpclient_t *client, const char *method, const char *uri, - char *data, size_t size, int *rescode, size_t *contentslength, - qlisttbl_t *reqheaders, qlisttbl_t *resheaders); - static bool sendrequest(qhttpclient_t *client, const char *method, const char *uri, qlisttbl_t *reqheaders); static int readresponse(qhttpclient_t *client, qlisttbl_t *resheaders, @@ -173,7 +169,6 @@ static int readresponse(qhttpclient_t *client, qlisttbl_t *resheaders, static ssize_t gets_(qhttpclient_t *client, char *buf, size_t bufsize); static ssize_t read_(qhttpclient_t *client, void *buf, size_t nbytes); static ssize_t write_(qhttpclient_t *client, const void *buf, size_t nbytes); -static off_t recvcontens(qhttpclient_t *client, char *contents, off_t nbytes); static off_t recvfile(qhttpclient_t *client, int fd, off_t nbytes); static off_t sendfile_(qhttpclient_t *client, int fd, off_t nbytes); @@ -293,7 +288,6 @@ qhttpclient_t *qhttpclient(const char *destname, int port) { client->get = get; client->put = put; client->cmd = cmd; - client->json = json; client->sendrequest = sendrequest; client->readresponse = readresponse; @@ -1166,183 +1160,6 @@ static void *cmd(qhttpclient_t *client, const char *method, const char *uri, return content; } -/** - * qhttpclient->json(): Sends a custom request(method) to the remote host - * and reads it's response. - * - * @param client qhttpclient object pointer. - * @param method method name. - * @param uri remote URL for uploading file. - * ("/path" or "http://.../path") - * @param data data to send. (can be NULL) - * @param size data size. - * @param rescode if not NULL, remote response code will be stored. - * (can be NULL) - * @param contentslength if not NULL, the contents length will be stored. - * (can be NULL) - * @param reqheaders qlisttbl_t pointer which contains additional user - * request headers. (can be NULL) - * @param resheaders qlisttbl_t pointer for storing response headers. - * (can be NULL) - * - * @return malloced content data if successful, otherwise returns NULL - * - * @code - * int nResCode; - * size_t nContentsLength; - * void *contents = httpclient->json(httpclient, "POST", "/API/test.json", - * userdata, 123 - * &nRescode, &nContentsLength - * NULL, NULL); - * if(contents == NULL) { - * ...(error occured)... - * } else { - * printf("Response code : %d\n", nResCode); - * printf("Contents length : %zu\n", nContentsLength); - * printf("Contents : %s\n", (char*)contents); // if contents is printable - * free(contents); // de-allocate - * } - * @endcode - * - * @note - * This store server's response into memory so if you expect server responses - * large amount of data, consider to use sendrequest() and readresponse() - * instead of using this. The returning malloced content will be allocated - * +1 byte than actual content size 'contentslength' and will be null - * terminated. - */ -static char *json(qhttpclient_t *client, const char *method, const char *uri, - char *data, size_t size, int *rescode, size_t *contentslength, - qlisttbl_t *reqheaders, qlisttbl_t *resheaders) -{ - - // reset rescode - if (rescode != NULL) - *rescode = 0; - if (contentslength != NULL) - *contentslength = 0; - - // send request - bool freeReqHeaders = false; - if (reqheaders == NULL && data != NULL && size > 0) { - reqheaders = qlisttbl(QLISTTBL_UNIQUE | QLISTTBL_CASEINSENSITIVE); - - reqheaders->putstr(reqheaders, "Content-Type", "application/json"); - reqheaders->putstrf(reqheaders, "Content-Length", "%jd", size); - freeReqHeaders = true; - } - - bool sendret = sendrequest(client, method, uri, reqheaders); - if (freeReqHeaders == true) { - reqheaders->free(reqheaders); - reqheaders = NULL; - } - if (sendret == false) { - _close(client); - return NULL; - } - - // send data - if (data != NULL && size > 0) { - ssize_t written = write_(client, data, size); - if (written != size) { - _close(client); - return NULL; - } - } - - // read response - off_t clength = 0; - off_t recv = 0; - int resno = readresponse(client, resheaders, &clength); - if (rescode != NULL) - *rescode = resno; - if (contentslength != NULL) - *contentslength = clength; - - char *content = NULL; - - if (clength > 0) { - // malloc data - content = malloc(clength + 1); - memset(content, 0, clength+1); - - while (recv < clength) { - unsigned int recvsize; // this time receive size - if (clength - recv < MAX_ATOMIC_DATA_SIZE) { - recvsize = clength - recv; - } else { - recvsize = MAX_ATOMIC_DATA_SIZE; - } - - ssize_t ret = recvcontens(client, content, recvsize); - if (ret <= 0) - break; // Connection closed by peer - recv += ret; - } - - if (recv != clength) { - _close(client); - return false; - } - } else if (clength == -1) { // chunked - bool completed = false; - do { - // read chunk size - char buf[64]; - if (gets_(client, buf, sizeof(buf)) <= 0) - break; - - // parse chunk size - unsigned int recvsize; // this time chunk size - sscanf(buf, "%x", &recvsize); - if (recvsize == 0) { - // end of transfer - completed = true; - } - - // malloc data - if(recv == 0) { - content = malloc(recvsize + 1); - } else { - content = realloc(content, recv + recvsize + 1); - } - - - // save chunk - if (recvsize > 0) { - ssize_t ret = recvcontens(client, content+recv, recvsize); - if (ret != recvsize) - break; - recv += ret; - DEBUG("recv : %zd , ret : %zd\n", recv, ret); - } - - // read tailing CRLF - if (gets_(client, buf, sizeof(buf)) <= 0) - break; - } while (completed == false); - - content[recv] = '\0'; - - if (contentslength != NULL) - *contentslength = recv; - - if (completed == false) { - DEBUG("Broken pipe. %jd/chunked, errno=%d", recv, errno); - _close(client); - return false; - } - } - - // close connection - if (client->keepalive == false || client->connclose == true) { - _close(client); - } - - return content; -} - /** * qhttpclient->sendrequest(): Sends a HTTP request to the remote host. * @@ -1402,10 +1219,8 @@ static bool sendrequest(qhttpclient_t *client, const char *method, return false; // buffer out command - if(uri == NULL) - outBuf->addstrf(outBuf, "%s / %s\r\n", method, HTTP_PROTOCOL_11); - else - outBuf->addstrf(outBuf, "%s %s %s\r\n", method, uri, HTTP_PROTOCOL_11); + outBuf->addstrf(outBuf, "%s %s %s\r\n", method, uri, + HTTP_PROTOCOL_11); // buffer out headers qlisttbl_obj_t obj; @@ -1698,46 +1513,6 @@ static ssize_t write_(qhttpclient_t *client, const void *buf, size_t nbytes) { #endif } -/** - * qhttpclient->recvcontents(): Reads data from a HTTP/HTTPS stream and save - * into a buffer. - * - * @param client qhttpclient object pointer. - * @param contents save buffer pointer - * @param nbytes the number of bytes to read and save. - * - * @return the number of bytes written if successful, otherwise returns -1. - */ -static off_t recvcontens(qhttpclient_t *client, char *contents, off_t nbytes) { - if (nbytes == 0) - return 0; - - unsigned char buf[MAX_ATOMIC_DATA_SIZE]; - - off_t total = 0; // total size sent - while (total < nbytes) { - size_t chunksize; // this time sending size - if (nbytes - total <= sizeof(buf)) - chunksize = nbytes - total; - else - chunksize = sizeof(buf); - - // read - ssize_t rsize = read_(client, buf, chunksize); - if (rsize <= 0) - break; - - // write - strncpy(contents+total, buf, rsize); - - total += rsize; - } - - if (total > 0) - return total; - return -1; -} - /** * qhttpclient->recvfile(): Reads data from a HTTP/HTTPS stream and save * into a file descriptor. @@ -1967,6 +1742,4 @@ static bool _parse_uri(const char *uri, bool *protocol, char *hostname, } #endif /* _DOXYGEN_SKIP */ - - #endif /* DISABLE_QHTTPCLIENT */ diff --git a/src/internal/md5/md5.h b/src/internal/md5/md5.h index a6bda1fe56eae987f4a5b32c8181db276f8ed66a..8e726febf155c837bc55e29de9c3faaa8e474d00 100644 --- a/src/internal/md5/md5.h +++ b/src/internal/md5/md5.h @@ -28,15 +28,16 @@ #define MD5_DIGEST_LENGTH 16 #define MD5_DIGEST_STRING_LENGTH (MD5_DIGEST_LENGTH * 2 + 1) -typedef unsigned int UINT4; - /* MD5 context. */ typedef struct MD5Context { - UINT4 state[4]; /* state (ABCD) */ - UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ + u_int32_t state[4]; /* state (ABCD) */ + u_int32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */ unsigned char buffer[64]; /* input buffer */ } MD5_CTX; +#ifdef __cplusplus +extern "C" { +#endif void MD5Init(MD5_CTX *); void MD5Update(MD5_CTX *, const unsigned char *, unsigned int); void MD5Final(unsigned char[16], MD5_CTX *); @@ -44,5 +45,8 @@ char * MD5End(MD5_CTX *, char *); char * MD5File(const char *, char *); char * MD5FileChunk(const char *, char *, off_t, off_t); char * MD5Data(const unsigned char *, unsigned int, char *); +#ifdef __cplusplus +} +#endif #endif /* Q_MD5_H */ diff --git a/src/internal/md5/md5c.c b/src/internal/md5/md5c.c index 533b0520bc28f659b39a6708053f47dacf129028..040bf5e84328b00a6ab8f69350f6b05f895b6b26 100644 --- a/src/internal/md5/md5c.c +++ b/src/internal/md5/md5c.c @@ -30,7 +30,7 @@ #include #include "md5.h" -static void MD5Transform( UINT4[4], const unsigned char[64]); +static void MD5Transform( u_int32_t[4], const unsigned char[64]); #if (BYTE_ORDER == LITTLE_ENDIAN) #define Encode memcpy @@ -38,26 +38,26 @@ static void MD5Transform( UINT4[4], const unsigned char[64]); #else /* - * Encodes input (UINT4) into output (unsigned char). Assumes len is + * Encodes input (u_int32_t) into output (unsigned char). Assumes len is * a multiple of 4. */ -static void Encode (unsigned char *output, UINT4 *input, unsigned int len) { +static void Encode (unsigned char *output, u_int32_t *input, unsigned int len) { unsigned int i; - UINT4 *op = (UINT4 *)output; + u_int32_t *op = (u_int32_t *)output; for (i = 0; i < len / 4; i++) op[i] = htole32(input[i]); } /* - * Decodes input (unsigned char) into output (UINT4). Assumes len is + * Decodes input (unsigned char) into output (u_int32_t). Assumes len is * a multiple of 4. */ -static void Decode (UINT4 *output, const unsigned char *input, unsigned int len) { +static void Decode (u_int32_t *output, const unsigned char *input, unsigned int len) { unsigned int i; - const UINT4 *ip = (const UINT4 *)input; + const u_int32_t *ip = (const u_int32_t *)input; for (i = 0; i < len / 4; i++) output[i] = le32toh(ip[i]); @@ -83,22 +83,22 @@ static unsigned char PADDING[64] = { 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, * Rotation is separate from addition to prevent recomputation. */ #define FF(a, b, c, d, x, s, ac) { \ - (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \ + (a) += F ((b), (c), (d)) + (x) + (u_int32_t)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define GG(a, b, c, d, x, s, ac) { \ - (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \ + (a) += G ((b), (c), (d)) + (x) + (u_int32_t)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define HH(a, b, c, d, x, s, ac) { \ - (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \ + (a) += H ((b), (c), (d)) + (x) + (u_int32_t)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define II(a, b, c, d, x, s, ac) { \ - (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \ + (a) += I ((b), (c), (d)) + (x) + (u_int32_t)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } @@ -130,10 +130,10 @@ void MD5Update(MD5_CTX *context, const unsigned char *input, idx = (unsigned int) ((context->count[0] >> 3) & 0x3F); /* Update number of bits */ - if ((context->count[0] += ((UINT4) inputLen << 3)) - < ((UINT4) inputLen << 3)) + if ((context->count[0] += ((u_int32_t) inputLen << 3)) + < ((u_int32_t) inputLen << 3)) context->count[1]++; - context->count[1] += ((UINT4) inputLen >> 29); + context->count[1] += ((u_int32_t) inputLen >> 29); partLen = 64 - idx; @@ -192,8 +192,8 @@ void MD5Final(unsigned char digest[16], MD5_CTX *context) { /* MD5 basic transformation. Transforms state based on block. */ -static void MD5Transform(UINT4 state[4], const unsigned char block[64]) { - UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; +static void MD5Transform(u_int32_t state[4], const unsigned char block[64]) { + u_int32_t a = state[0], b = state[1], c = state[2], d = state[3], x[16]; Decode(x, block, 64); diff --git a/src/utilities/qfile.c b/src/utilities/qfile.c index 0c3430c71cc160ea36cfae1f2b2ba25801d16dba..2ae72de4a1b43f74b32df3e9f04090735f7e45f5 100644 --- a/src/utilities/qfile.c +++ b/src/utilities/qfile.c @@ -76,7 +76,7 @@ bool qfile_lock(int fd) { return false; #else struct flock lock; - memset((void *) &lock, 0, sizeof(lock)); + memset((void *) &lock, 0, sizeof(flock)); lock.l_type = F_WRLCK; lock.l_whence = SEEK_SET; lock.l_start = 0; @@ -100,7 +100,7 @@ bool qfile_unlock(int fd) { return false; #else struct flock lock; - memset((void *) &lock, 0, sizeof(lock)); + memset((void *) &lock, 0, sizeof(flock)); lock.l_type = F_UNLCK; lock.l_whence = SEEK_SET; lock.l_start = 0; diff --git a/src/utilities/qstring.c b/src/utilities/qstring.c index 6bd4e640df10fc4b9038eaeaddf0edf78babb72c..8ae1a084b3e101a7d3b3def093ef59e271ca4c9c 100644 --- a/src/utilities/qstring.c +++ b/src/utilities/qstring.c @@ -48,7 +48,7 @@ * * @param str source string * - * @return a pointer of source string if rsuccessful, otherewise returns NULL + * @return a pointer of source string if successful, otherwise returns NULL * * @note This modify source string directly. */ @@ -83,7 +83,7 @@ char *qstrtrim(char *str) { * * @param str source string * - * @return a pointer of source string if rsuccessful, otherewise returns NULL + * @return a pointer of source string if successful, otherwise returns NULL * * @note This modify source string directly. */ @@ -109,7 +109,7 @@ char *qstrtrim_head(char *str) { * * @param str source string * - * @return a pointer of source string if rsuccessful, otherewise returns NULL + * @return a pointer of source string if successful, otherwise returns NULL * * @note This modify source string directly. */ @@ -136,7 +136,7 @@ char *qstrtrim_tail(char *str) { * @param head heading character * @param tail tailing character * - * @return a pointer of source string if successful, otherewise returns NULL + * @return a pointer of source string if successful, otherwise returns NULL * * @note This modify source string directly. * @@ -170,10 +170,10 @@ char *qstrunchar(char *str, char head, char tail) { * @param word target word to be replaced * * @return a pointer of malloced or source string depending on the mode if - * successful, otherewise returns NULL + * successful, otherwise returns NULL * * @note - * The mode argument has two separated character. First character + * The mode argument has two separated characters. First character * is used to decide replacing method and can be 't' or 's'. * The character 't' and 's' stand on [t]oken and [s]tring. * diff --git a/src/utilities/qtime.c b/src/utilities/qtime.c index fb17fd14734973018e56e3b8af5ad76c77bdf2ad..1b45694282a5d1a27a8e38bd2518618c3b194b21 100644 --- a/src/utilities/qtime.c +++ b/src/utilities/qtime.c @@ -31,38 +31,16 @@ */ #define __USE_XOPEN -//#define _XOPEN_SOURCE +#define _XOPEN_SOURCE #define _BSD_SOURCE #include #include #include #include #include -#include #include "qinternal.h" #include "utilities/qtime.h" -#include - -#ifndef HAVE_TIMEGM - -time_t timegm(struct tm *tm) { - time_t temp_ltime; - struct tm *temp_gm; - - if (!tm) { - temp_ltime = 0; - } - else { - temp_ltime = mktime(tm); - } - - temp_gm = gmtime(&temp_ltime); - - return (time_t)(temp_ltime + (temp_ltime - mktime(temp_gm))); -} - -#endif /* HAVE_TIMEGM */ /** * Returns the current time in milliseconds. * diff --git a/tests/launcher.sh b/tests/launcher.sh old mode 100644 new mode 100755