Alexander Bokovoy schrieb:

> > Oops. It was still being reported as broken so I tried to
> > remove it and upload a new one.
> No, reports were about midgard-php3-1.4.1-1, not -7.

Partly confirmed, the -2 tarball was broken, -7 unpacks ok.

My midgard.h (located in /usr/lcal/include/midgard) is version

" /* $Id: midgard.h.in,v 1.10 2001/03/06 16:42:31 david Exp $ " 
- see attachment. I hope 21k is not too big for your data
lines ;-)

--
-------------------------------------------------------
Thomas M. ROTHER  - "netzwissen" - 73728 Esslingen
Germany/EU - http://www.netzwissen.de (updated)
Public PGP Key available from http://www.keyserver.net
-------------------------------------------------------
/* $Id: midgard.h.in,v 1.10 2001/03/06 16:42:31 david Exp $
 *
 * midgard-lib: database access for Midgard clients
 *
 * Copyright (C) 1999 Jukka Zitting <[EMAIL PROTECTED]>
 * Copyright (C) 2000 The Midgard Project ry
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this library; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

/*! \file lib/midgard/midgard.h
 */
#ifndef MIDGARD_H
#define MIDGARD_H
#include <stdarg.h>
#include <assert.h>
#include <time.h>

/*! Identifier of the Midgard library API functions */
#define MGD_API extern

#define EXPAT_INCLUDE_EXPAT_H 1
#define EXPAT_INCLUDE_XMLTOK_XMLPARSE_H 0
#define EXPAT_INCLUDE_XML_XMLPARSE_H  0

#if EXPAT_INCLUDE_EXPAT_H       /* yea gods I hate diversification */
#include <expat.h>
#else
#if EXPAT_INCLUDE_XMLTOK_XMLPARSE_H 
#include <xmltok/xmlparse.h>
#else
#if EXPAT_INCLUDE_XML_XMLPARSE_H 
#include <xml/xmlparse.h>
#endif
#endif
#endif

#include <iconv.h>

#define HAVE_MIDGARD_SITEGROUPS 0
#define HAVE_MIDGARD_PAGELINKS 0

#define MIDGARD_REPLIGARD_TAG_LENGTH 64
#define MIDGARD_LOGIN_SG_SEPARATOR "+*!$;"
#define MIDGARD_LOGIN_RESERVED_CHARS MIDGARD_LOGIN_SG_SEPARATOR "="

#if HAVE_MIDGARD_SITEGROUPS
#define MIDGARD_LIB_VERSION_SG "/SG"
#else
#define MIDGARD_LIB_VERSION_SG ""
#endif

#define MIDGARD_LIB_VERSION "1.4.1" MIDGARD_LIB_VERSION_SG

typedef struct midgard midgard;
typedef struct midgard_res midgard_res;
typedef struct midgard_pool midgard_pool;

#define MGD_STRUCT_STD_FIELDS \
  midgard_res *res; int restype; \
  int id, creator, revisor, revision; \
  time_t created, revised;

MGD_API const char *mgd_version();
MGD_API void mgd_set_log_debug_func(void (*)(int flags, const char *, ...));
MGD_API void mgd_init();
MGD_API void mgd_done();

/* Database connection */
MGD_API midgard *mgd_setup();
MGD_API midgard *mgd_connect(const char *database,
                            const char *username, const char *password);
MGD_API void mgd_close(midgard * mgd);
MGD_API void mgd_clear(midgard * mgd);
MGD_API int mgd_errno(midgard * mgd);
MGD_API const char *mgd_error(midgard * mgd);

#define MGD_AUTH_ANONYMOUS        0
#define MGD_AUTH_NOT_CONNECTED   -1
#define MGD_AUTH_INVALID_NAME    -2
#define MGD_AUTH_REAUTH          -3
#define MGD_AUTH_SG_NOTFOUND     -4
#define MGD_AUTH_DUPLICATE       -5
#define MGD_AUTH_NOTFOUND        -6
#define MGD_AUTH_INVALID_PWD     -7
MGD_API int mgd_auth(midgard * mgd, const char *username, const char *password);

/* Language parser utilites */
MGD_API int mgd_select_parser(midgard * mgd, const char *parser);
MGD_API const char *mgd_get_parser_name(midgard * mgd);
/* Encoding of mail messages */
MGD_API const char *mgd_get_encoding(midgard * mgd);
/* Is mail should be sent as quoted printable text? */
MGD_API int mgd_mail_need_qp(midgard * mgd);

/* User information */
MGD_API int mgd_user(midgard * mgd);
MGD_API int mgd_isauser(midgard * mgd);
MGD_API int mgd_isadmin(midgard * mgd);
#if HAVE_MIDGARD_SITEGROUPS
MGD_API int mgd_isroot(midgard * mgd);
MGD_API void mgd_force_root(midgard * mgd); /* use with extreme care */
#endif
MGD_API int mgd_isuser(midgard * mgd, int user);
MGD_API int mgd_ismember(midgard * mgd, int group);
MGD_API int *mgd_groups(midgard * mgd);
MGD_API void mgd_force_admin(midgard * mgd); /* use with extreme care */

#if HAVE_MIDGARD_SITEGROUPS
/* Sitegroup information */
MGD_API void mgd_set_sitegroup(midgard * mgd, int sitegroup);
MGD_API int mgd_sitegroup(midgard * mgd);
#endif

/* Data retrieval */
MGD_API midgard_res *mgd_query(midgard * mgd, const char *query, ...);
MGD_API midgard_res *mgd_vquery(midgard * mgd, const char *query, va_list args);
MGD_API midgard_res *mgd_ungrouped_select(midgard * mgd,
                                         const char *fields, const char *from,
                                         const char *where, const char *sort,
                                         ...);
MGD_API midgard_res *mgd_ungrouped_vselect(midgard * mgd, const char *fields,
                                          const char *from, const char *where,
                                          const char *sort, va_list args);
#if HAVE_MIDGARD_SITEGROUPS
MGD_API midgard_res *mgd_sitegroup_select(midgard * mgd,
                                         const char *fields, const char *from,
                                         const char *where, const char *sort,
                                         ...);
MGD_API midgard_res *mgd_sitegroup_vselect(midgard * mgd, const char *fields,
                                          const char *from, const char *where,
                                          const char *sort, va_list args);
MGD_API midgard_res *mgd_sitegroup_record(midgard * mgd, const char *fields,
                                         const char *table, int id);
#else
#define mgd_sitegroup_select mgd_ungrouped_select
#define mgd_sitegroup_vselect mgd_ungrouped_vselect
#define mgd_sitegroup_record mgd_ungrouped_record
#endif
MGD_API midgard_res *mgd_ungrouped_record(midgard * mgd,
                                         const char *fields, const char *table,
                                         int id);
MGD_API midgard_res *mgd_record_by_name(midgard * mgd, const char *fields,
                                       const char *table, const char *idfield,
                                       int id, const char *name);
MGD_API midgard_res *mgd_record_by_name2(midgard * mgd, const char *fields,
                                        const char *table,
                                        const char *firstfield,
                                        const char *first,
                                        const char *secondfield,
                                        const char *second);
MGD_API midgard_res *mgd_record_by_name_only(midgard * mgd, const char *fields,
                                            const char *table,
                                            const char *name);
MGD_API int mgd_idfield(midgard * mgd, const char *field, const char *table,
                       int id);

/* Only use mgd_exists_id on single-table queries that are not the
   sitegroup table */
MGD_API int mgd_exists_id(midgard * mgd, const char *from, const char *where, ...);
/* make sure you do your own sitegroup verifications, mgd_exists_bool
   doesn't */
MGD_API int mgd_exists_bool(midgard * mgd, const char *from, const char *where, ...);
MGD_API int mgd_global_exists(midgard * mgd, const char *where, ...);

MGD_API int mgd_fetch(midgard_res * res);
MGD_API void mgd_release(midgard_res * res);

MGD_API int mgd_rows(midgard_res * res);
MGD_API int mgd_cols(midgard_res * res);

MGD_API const char *mgd_colname(midgard_res * res, int col);
MGD_API const char *mgd_colvalue(midgard_res * res, int col);
MGD_API const char *mgd_column(midgard_res * res, const char *name);

MGD_API int mgd_sql2id(midgard_res * res, int col);
MGD_API int mgd_sql2int(midgard_res * res, int col);
MGD_API const char *mgd_sql2str(midgard_res * res, int col);
MGD_API time_t mgd_sql2date(midgard_res * res, int col);
MGD_API time_t mgd_sql2time(midgard_res * res, int col);
MGD_API time_t mgd_sql2datetime(midgard_res * res, int col);

/* Data modification */
MGD_API int mgd_exec(midgard * mgd, const char *command, ...);
MGD_API int mgd_vexec(midgard * mgd, const char *command, va_list args);
MGD_API int mgd_create(midgard * mgd, const char *table,
                      const char *fields, const char *values, ...);
MGD_API int mgd_vcreate(midgard * mgd, const char *table,
                       const char *fields, const char *values, va_list args);
MGD_API int mgd_update(midgard * mgd, const char *table, int id,
                      const char *fields, ...);
MGD_API int mgd_vupdate(midgard * mgd, const char *table, int id,
                       const char *fields, va_list args);
MGD_API int mgd_delete(midgard * mgd, const char *table, int id);

/* repligard functions */
MGD_API int mgd_create_repligard(midgard * mgd, const char *table,
                                const char *fields, const char *values, ...);
MGD_API int mgd_vcreate_repligard(midgard * mgd, const char *table,
                                 const char *fields, const char *values,
                                 va_list args);
MGD_API int mgd_update_repligard(midgard * mgd, const char *table, int id,
                                const char *fields, ...);
MGD_API int mgd_vupdate_repligard(midgard * mgd, const char *table, int id,
                                 const char *fields, va_list args);
MGD_API int mgd_delete_repligard(midgard * mgd, const char *table, int id);

/* utility functions */
MGD_API midgard_pool *mgd_alloc_pool();
MGD_API void mgd_clear_pool(midgard_pool * pool);
MGD_API void mgd_free_pool(midgard_pool * pool);
MGD_API void mgd_free_from_pool(midgard_pool * pool, void *ptr);
MGD_API midgard_pool *mgd_pool(midgard * mgd);
MGD_API midgard_pool *mgd_res_pool(midgard_res * res);
MGD_API void mgd_set_blobdir(midgard *mgd, char *blobdir);
MGD_API const char* mgd_get_blobdir(midgard *mgd);

MGD_API void *mgd_alloc(midgard_pool * pool, int len);
MGD_API char *mgd_stralloc(midgard_pool * pool, int len);

MGD_API char *mgd_strdup(midgard_pool * pool, const char *str);
MGD_API char *mgd_strndup(midgard_pool * pool, const char *str, int len);
MGD_API char *mgd_strcat(midgard_pool * pool, int n, ...);
MGD_API char *mgd_strjoin(midgard_pool * pool, const char *delim, int n, ...);
MGD_API char *mgd_format(midgard * mgd, midgard_pool * pool, const char *fmt,
                        ...);
MGD_API char *mgd_vformat(midgard * mgd, midgard_pool * pool, const char *fmt,
                         va_list args);

/* Repligard utilities */
MGD_API const char *mgd_create_guid(midgard *mgd, const char *table, int id);
MGD_API char* mgd_repligard_guid(midgard* mgd, midgard_pool* pool, const char* table, 
int id);
MGD_API int mgd_repligard_id(midgard* mgd, const char* guid);
MGD_API int mgd_delete_repligard_guid(midgard* mgd, const char* guid);
MGD_API int mgd_delete_repligard(midgard* mgd, const char* table, int id);
MGD_API char* mgd_repligard_changed(midgard* mgd, midgard_pool* pool, const char* 
table, int id);
MGD_API char* mgd_repligard_changed_guid(midgard* mgd, midgard_pool* pool, const char* 
guid);
MGD_API char* mgd_repligard_updated(midgard* mgd, midgard_pool* pool, const char* 
table, int id);
MGD_API char* mgd_repligard_updated_guid(midgard* mgd, midgard_pool* pool, const char* 
guid);
MGD_API char* mgd_repligard_table(midgard* mgd, midgard_pool* pool, const char* guid);
MGD_API char* mgd_repligard_action(midgard* mgd, midgard_pool* pool, const char* guid);

/* Updates Repligard's records for given table: creates if they aren't exist */
MGD_API void mgd_repligard_touch(midgard * mgd, const char *table);

/* Creates a record in the Repligard table. Generates guid based on object ID, 
   class (table name) and current time. GUID is a md5 sum of  'magic string'
*/
#define CREATE_REPLIGARD(mgd, table,id)\
        mgd_create_repligard(mgd, table, "guid,id,changed,action",\
        "$q,$d,NULL,'create'",mgd_create_guid(mgd, table, id), id);

/* Updates a record in the Repligard table. Sets changed time to the current time */
#define UPDATE_REPLIGARD(mgd, table,id)\
        mgd_update_repligard(mgd, table, id, "changed=NULL,action='update'");

/* Updates a record in the Repligard table. Sets changed time to the specified one */
#define UPDATE_REPLIGARD_TIME(mgd, table,id, changed)\
        mgd_update_repligard(mgd, table, id, "changed=$q,action='update'", changed);

/* Marks a record in the Repligard table for deletion */
#define DELETE_REPLIGARD(mgd, table,id)\
        mgd_update_repligard(mgd, table, id, "updated=NULL,action='delete'");

/* Tree management */
/*! one tree node */
struct _tree_node {
        int id;                                         //!< id of the node
        int up;                                         //!< id of its parent
        int level;                                      //!< level in the tree from 
the root (root=0)
        int size;                                       //!< size of subtree including 
this node
        struct _tree_node * child;      //!< first child (none when =NULL)
        struct _tree_node * next;       //!< next sibling (last when =NULL)
};

typedef struct _tree_node tree_node;

/* Returns raw tree information about given table.
   Maximum possible level of branches is returned in maxlevel. 
   Sort specifies sorting and defaults to 'id' if omitted.
   Actual value of sort should be name of one of the fields in record.
*/
tree_node * mgd_tree_build(midgard * mgd, midgard_pool * pool,
                        const char * table, const char * upfield, int root,
                        int maxlevel, const char * sort);
/* Returns array of ids of branches under selected tree with given id 
   but no deeper than maxlevel. If maxlevel == 0 then whole tree will 
   be returned. If id == 0 then all distinct branches will be returned.
*/
MGD_API int *mgd_tree(midgard * mgd, const char * table, const char * upfield,
                        int id, int maxlevel, const char *sort);
MGD_API int mgd_is_in_tree(midgard * mgd, const char *table, const char *upfield,
                                int root, int id);
/*! the prototype of a user defined function (see mgd_walk_table_tree()) */
typedef int (*midgard_userfunc) (midgard * mgd, int id, int level,
                                  void *xparam);

/* Traverses table tree starting from root and calls user-defined function */
MGD_API int mgd_walk_table_tree(midgard * mgd, const char *table,
                                const char * upfield, int root,
                                int maxlevel, int order, void *xparam,
                                midgard_userfunc func, const char * sort);

MGD_API int mgd_copy_object(midgard * mgd, midgard_res * object,
                           const char *table, const char *upfield, int new_up);
MGD_API int mgd_move_object(midgard * mgd, const char *table,
                           const char *upfield, int id, int newup);

/* Copies topic sub-tree with included articles and return ID of copy 
   of root topic
*/
MGD_API int mgd_copy_topic(midgard * mgd, int root);

/* Deletes topic sub-tree with included articles */
MGD_API int mgd_delete_topic(midgard * mgd, int root);

/* Copies page sub-tree with included pageelements and return ID of copy 
   of page
*/
MGD_API int mgd_copy_page(midgard * mgd, int root);

/* Copy article/pageelement/element to specified topic/page/style
   If newtopic/newpage/newstyle is equal to 0, a copy will be created
   in old container.
*/
MGD_API int mgd_copy_article(midgard * mgd, int id, int newtopic);
MGD_API int mgd_copy_page_element(midgard * mgd, int id, int newpage);
MGD_API int mgd_copy_element(midgard * mgd, int id, int newstyle);
MGD_API int mgd_copy_snippet(midgard * mgd, int id, int newsnippetdir);

/* Deletes page sub-tree with included page elements */
MGD_API int mgd_delete_page(midgard * mgd, int root);

/* Copies style sub-tree with included elements and return ID of copy 
   of style
*/
MGD_API int mgd_copy_style(midgard * mgd, int root);

/* Deletes style sub-tree with included elements */
MGD_API int mgd_delete_style(midgard * mgd, int root);

/* Copies snippetdir sub-tree with included snippets and return ID of copy 
   of snippetdir
*/
MGD_API int mgd_copy_snippetdir(midgard * mgd, int root);

/* Deletes snippetdir sub-tree with included snippets */
MGD_API int mgd_delete_snippetdir(midgard * mgd, int root);

#define MIDGARD_PATH_ELEMENT_NOTEXISTS          0
#define MIDGARD_PATH_ELEMENT_EXISTS             1
#define MIDGARD_PATH_OBJECT_NOTEXISTS           2
#define MIDGARD_PATH_OBJECT_EXISTS              3
typedef int (*midgard_pathfunc) (midgard * mgd, const char *table,
                                 const char *name, int up, int id, int flag);

/* Parses a path and returns IDs of requested object and its uplink in 'id' and 'up'. 
Returns 0 on success */
MGD_API int mgd_parse_path(midgard * mgd, const char *path, const char *uptable,
                          const char *table, const char *upfield,
                          const char *namefield, int *id, int *up);
/* The same but hook is called whenever path element is queried. 'flag' will be set to 
one of predefined state */
/* (id is undefined in such case) but parsing will continue if hook returns !0 */
MGD_API int mgd_parse_path_with_hook(midgard * mgd, const char *path,
                                    const char *uptable, const char *table,
                                    const char *upfield, const char *namefield,
                                    int *id, int *up, midgard_pathfunc hook);
/* Several predefined macroses to parse common cases: */
/* 1. Parse standard 'id'-'up'-'name' tables */
#define MGD_PARSE_COMMON_PATH(mgd, path, uptable, table, id, up)\
    mgd_parse_path(mgd, path, uptable, table, "up", "name", id, up)
/* 2. Parse articles by 'name' field */
#define MGD_PARSE_ARTICLE_PATH(mgd, path, id, up)\
    mgd_parse_path(mgd, path, "topic", "article", "topic", "name", id, up)
/* 3. Parse articles by 'title' field */
#define MGD_PARSE_ARTICLE_PATH_BY_TITLE(mgd, path, id, up)\
    mgd_parse_path(mgd, path, "topic", "article", "topic", "title", id, up)
/* 4. Parse topics only */
#define MGD_PARSE_TOPIC_PATH(mgd, path, up)\
    mgd_parse_path(mgd, path, "topic", NULL, NULL, NULL, NULL, up)

/* functions exported from tree.c */

int mgd_delete_all_attachments(midgard * mgd, int id, const char * table);
int mgd_delete_article(midgard * mgd, int root);
int mgd_delete_topic(midgard * mgd, int root);
int mgd_delete_page(midgard * mgd, int root);
int mgd_delete_snippetdir(midgard * mgd, int root);
int mgd_delete_event(midgard * mgd, int root);
int mgd_delete_style(midgard * mgd, int root);
int mgd_has_dependants(midgard * mgd, int id, char * table);
int mgd_copy_article(midgard * mgd, int root, int newtopic);
int mgd_copy_page_element(midgard * mgd, int id, int newpage);
int mgd_copy_element(midgard * mgd, int id, int newstyle);
int mgd_copy_snippet(midgard * mgd, int id, int newsnippetdir);
int mgd_copy_topic(midgard * mgd, int root);
int mgd_copy_event(midgard * mgd, int root);
int mgd_copy_page(midgard * mgd, int root);
int mgd_copy_style(midgard * mgd, int root);
int mgd_copy_snippetdir(midgard * mgd, int root);
int mgd_copy_object(midgard * mgd, midgard_res * object, const char *table,
                    const char *upfield, int new_up);
int mgd_copy_object_article(midgard * mgd, midgard_res * object,
                    int new_topic, int new_up);
typedef int (*mgd_ft_signal_handler) (int ft_sig, void *client_data);
typedef int (*mgd_ft_element_handler) (char *name, char *value,
                                       void *client_data);
typedef int (*mgd_ft_file_handler) (char *file, void *client_data);
typedef void (*mgd_ft_syntaxerror_handler) (int line, void *client_data);

enum
{
        MGD_FT_SIGNAL_AUTH, MGD_FT_SIGNAL_STOP,
        MGD_FT_SIGNAL_SKIP_HOST_STYLE, MGD_FT_SIGNAL_PAGE_IN_STYLE,
        MGD_FT_SIGNAL_ACCESS_DENIED
};

enum
{
        MGD_FT_ERR_NONE, MGD_FT_ERR_NWF, MGD_FT_ERR_ACCESS,
        MGD_FT_ERR_PATH, MGD_FT_ERR_ABORT
};

int midgard_traverse_filetemplate(
   char *startfile, char *templatefile,
   mgd_ft_signal_handler signal_handler,
   mgd_ft_element_handler element_handler,
   mgd_ft_file_handler file_handler,
   mgd_ft_syntaxerror_handler syntaxerror_handler,
   void *client_data);

  /* Converts string using given iconv descriptor and returns result allocated by 
malloc */
  char *midgard_iconv (iconv_t cd, const char *s, int len, int *reslen);

  /* Helper function for using in XML_SetUnknownEncodingHandler() */
  /* If encondingHandleData != NULL then midgard_unknown_xml_encoding will additionally
     return iconv descriptor for UTF-8 -> detected encoding conversion. It's up to
     client's code to free this descriptor with iconv_close().
   */
  int midgard_unknown_xml_encoding (/* (iconv_t *) */ void * encodingHandleData,
                                      const XML_Char * name,
                                      XML_Encoding * info);

/* access.c */
MGD_API int mgd_istopicreader(midgard *mgd, int topic);
MGD_API int mgd_isarticlereader(midgard *mgd, int article);
MGD_API int mgd_istopicowner(midgard *mgd, int topic);
MGD_API int mgd_issnippetdirowner(midgard *mgd, int snippetdir);
MGD_API int mgd_isgroupowner(midgard *mgd, int gid);
MGD_API int mgd_isgroupreader(midgard *mgd, int gid);
MGD_API int mgd_isuserowner(midgard *mgd, int uid);
#if HAVE_MIDGARD_PAGELINKS
MGD_API int mgd_ispagelinkowner(midgard *mgd, int pagelink);
#endif
MGD_API int mgd_isarticleowner(midgard *mgd, int article);
MGD_API int mgd_isarticlelocker(midgard *mgd, int article);
MGD_API int mgd_iseventowner(midgard *mgd, int event);
MGD_API int mgd_ishostowner(midgard *mgd, int host);
MGD_API int mgd_ispageowner(midgard *mgd, int page);
MGD_API int mgd_isstyleowner(midgard *mgd, int style);
MGD_API int mgd_global_is_owner(midgard *mgd, int table, int id);

MGD_API int mgd_lookup_table_id(const char *table);

#endif /* MIDGARD_H */



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to