Files
2026-08-07 17:38:18 +09:00

272 lines
9.9 KiB
C

/****************************************************************************
mod_dav_pgsql (DASL) for apache 2.X
CopyRight(C) 2005 SolutionBox Inc. All Rights reserved.
Author : sean kim (sean@solutionbox.co.kr)
$Id: dbms.h,v 1.3 2007/03/19 08:43:12 elenoa Exp $
Redistribution and use in source and binary forms, with or with out
modification, are not permitted in outside of SolutionBox Inc.
****************************************************************************/
#ifndef __DBMS_H__
#define __DBMS_H__
#include <apr_network_io.h>
#include <stdbool.h> /* ADD 2012-03-20 huibong bool type 사용을 위한 Header 추가 */
#include "apr_dbd.h"
#include "mod_dbd.h"
#include "dav_repos.h"
#include "lock.h"
#include "libpq-fe.h"
#define dav_repos_FILE 0
#define dav_repos_COLLECTION 1
#define dav_repos_SHARE 2
#define dav_repos_RECYCLE 4
#define dav_repos_TEXT 1
#define dav_repos_BIN 2
#define DB_RESULT_CLEAR 1
#define DB_RESULT_NCLEAR 2
struct dav_repos_property
{
apr_int64_t m_resource_id;
long m_ns_id;
const char *m_propname;
const char *m_propvalue;
struct dav_repos_property *next;
};
typedef struct dav_repos_property dav_repos_property;
/*
** DBMS data transfer interface
*/
struct dav_repos_resource
{
apr_int64_t m_resource_id;
int m_resource_type;
apr_int64_t m_owner_id;
char *m_uri;
char *m_fake_uri;
const char *m_filename_org;
const char *m_filename_hash;
int m_depth;
apr_int64_t m_creation_date;
const char *m_displayname;
// 2014.07.09 : 사용되지 않는 컬럼 정리(get_content_language,get_etag,supported_lock,lock_discovery)
apr_int64_t m_get_content_length;
const char *m_get_content_type;
apr_int64_t m_get_lastmodified;
int m_source; /* 0:regular; 1:source; 3:protected */
const char *m_host_name;
char m_is_deleted; /* N:not deleted Y: deleted */
apr_hash_t *lpr_hash; /* live property hash */
dav_repos_property *pr; /* for dead property data */
apr_hash_t *pr_hash; /* use for output value */
apr_hash_index_t *pr_hash_index; /* pr_hash_index to get first and next */
apr_hash_t *ns_hash; /* namespace(URI) to ns_id hash */
apr_hash_t *ns_id_hash; /* ns_id to namespace(URI) hash */
struct dav_repos_resource *next; /* for multiful result */
apr_pool_t *p; /* apache pool */
// 2013.09.27 dadamin
// sibling 및 sync_host 기능 제거
//apr_socket_t *sock; /* Elenoa 2006. 09. 18 : file descriptor for sync */
//dav_resource *res;
//server_rec *server;
request_rec *r;
};
typedef struct dav_repos_resource dav_repos_resource;
/* dav_repos_server_conf is in repos.h */
/* typedef dav_repos_server_conf dav_repos_db; */
/* context needed to identify a resource */
struct dav_resource_private
{
apr_pool_t *pool; /* memory storage pool associated with request */
const char *pathname; /* full pathname to resource */
apr_finfo_t finfo; /* filesystem info */
const dav_repos_resource *db_r;
apr_int64_t user_id; /* opendisk user id */
request_rec *rec; /* Save rec */
};
/* define the dav_stream structure for our use */
struct dav_stream
{
apr_pool_t *p;
apr_file_t *f;
const dav_resource *resource;
const char *pathname; /* we may need to remove it at close time */
int test_flag; /* test flag */
int is_write;
apr_off_t data_read; /* Keep size of read */
apr_off_t start_pos;
};
//int dbms_get_result(PGresult *pResult, unsigned int flag);
void db_error_message(ap_dbd_t *db, char *message_str, int errnum);
/*
int dbms_opendb(dav_repos_db * d);
int dbms_checkdb(dav_repos_db * d);
int dbms_closedb(dav_repos_db * d);
*/
int dbms_get_property(dav_repos_resource * r, bool is_uricaseignore );
// CHG 2012.07.13 dadamin
// close 구분 인자 추가
// CHG 2012-03-21 huibong
// 서비스별 URI 대소문자 구분, 무시 여부 처리 관련 인자값 추가
// CHG 2014-06-16 dadamin
// 첫번재 인자의 const 속성 제거(해당 값 중 m_get_content_length 변경 로직 포함)
// flag 인자 추가(write trunc 경우에 대한 사이즈 오류 방지)
// CHG 2015.06.04 dadamin
// end_pos 인자 추가 (요청 처리 후 file end position 추가)
apr_int64_t dbms_set_property(dav_repos_resource *db_r, const dav_resource *resource, bool is_uricaseignore, bool is_close, int flag, apr_off_t end_pos);
// NEW 2010-01-18 huibong
// SBFS client send ModifyTime to dav...
// This data is file attribute.
// So t_dav_resource add file_lastmodified column and save this data...
// SBFS use dbms_update_file_lastmodified function. not use dbms_update_getlastmodified.
// CHG 2012-03-21 huibong
// 서비스별 URI 대소문자 구분, 무시 여부 처리 관련 인자값 추가
int dbms_update_file_lastmodified(const dav_repos_resource *db_r, apr_int64_t mtime, bool is_uricaseignore );
// 2013.08.21 dadamin
// Set hidden property of DAV:(t_dav_resource)
// hidden : 1, not hidden : 0
int dbms_update_hidden(const dav_repos_resource *db_r, int hidden , bool is_uricaseignore);
int dbms_fill_dead_property(dav_repos_resource * db_r);
// CHG 2010-03-29 huibong
// PROPFIND 에 의한 조회시 조회 시작 시간 정보를 인자로 추가함.
// 본 기능은 연합뉴스 요구사항을 반영하기 위해 수정함.
// CHG 2012-03-21 huibong
// 서비스별 URI 대소문자 구분, 무시 여부 처리 관련 인자값 추가
int dbms_get_collection_resource(dav_repos_resource * db_r, int depth, const char * startTime, bool is_uricaseignore );
/* I'll fill all d and r_src and r_des->uri */
// CHG 2012-03-21 huibong
// 서비스별 URI 대소문자 구분, 무시 여부 처리 관련 인자값 추가
int dbms_move_resource(const dav_repos_resource * r_src, const dav_repos_resource * r_des, const dav_resource * resource, bool is_uricaseignore );
/* I'll fill all d and r_src and r_des->uri */
// CHG 2012-03-23 huibong
// 서비스별 URI 대소문자 구분, 무시 여부 처리 관련 인자값 추가
int dbms_copy_resource(const dav_repos_resource * r_src, const dav_repos_resource * r_des, bool is_uricaseignore );
/* I'll fill pr->name and you will fill pr->value */
int dbms_get_dead_property(const dav_repos_resource * r, dav_repos_property * pr);
/* I'll fill pr->name and you will fill pr->value */
int dbms_get_all_dead_property(const dav_repos_resource * r, dav_repos_property ** pr);
int db_insert_property(const dav_repos_resource * r, const dav_repos_property * pr);
/* I'll fill pr->name and pr->value */
int dbms_set_dead_property(const dav_repos_resource * r, const dav_repos_property * pr);
/* I'll fill pr->name */
int dbms_del_dead_property(const dav_repos_resource * r, const dav_repos_property * pr);
/* Pan */
// CHG 2012-03-21 huibong
// 서비스별 URI 대소문자 구분, 무시 여부 처리 관련 인자값 추가
int dbms_remove_resource(const dav_repos_resource * r, bool is_uricaseignore );
/* remove all files if the resource is collection */
// NEW 2010-03-24 webting
// 이 함수는 N중화 모듈 개발 후 야기될수 있는 문제점을 해결하기 위해
// 만들어 졌다.
// 내용 : 이어올리기 기능으로 업로드 할 경우에만 호출이 되도록 되어 있으며,
// 이어올리기를 시작 할 당시에 이전의 컨텐츠의 replicate가 있는 경우
// 해당 복제본은 deleted_yn = 'Y'로 되도록 만들어졌다.
// * 추가 참고사항:
// 또한 똑같은 해쉬명으로 생성이 됨에따라 같은 FHS에 replicate가 되더라도
// 삭제가 되지 않음을 확인했다. csa(삭제) 데몬.
// CHG 2012-03-21 huibong
// 서비스별 URI 대소문자 구분, 무시 여부 처리 관련 인자값 추가
// QUERY_AND_RETRY 매크로의 반환값 처리로 인해... 반환값 void -> int 로 수정 처리
int dbms_remove_replicate(const dav_repos_resource* r, bool is_uricaseignore );
const char *dav_repos_getetag_dbr(const dav_repos_resource * db_r);
int dbms_get_resourcetype(dav_repos_resource * r);
int dbms_search(char *search_command, dav_repos_resource * db_r);
// CHG 2018-02-14 huibong 각 오류별 HTTP reponse code 를 output 인자로 전달.
// CHG 2012-04-19 dadamin :램덤 처리 인자 추가
// CHG 2012-03-20 huibong: 서비스별 URI 대소문자 구분, 무시 여부 처리 관련 인자값 추가
//char *dbms_get_redirect(dav_repos_resource *db_r, bool is_uricaseignore, bool is_random );
char * dbms_get_redirect( dav_repos_resource *db_r, bool is_uricaseignore, bool is_random, int *error_code );
/* NEW 2011-03-23 dadamin
* 각 디렉토리 서비스 용량정보( Total, 현재사용량, Used 용량)를 조회하기 위한 함수(단 t_sms_sp_svc_product의 cal_used_depth 기준)
* tran_id [in] 서비스 Tran ID 정보
* is_uricaseignore URI 에 대한 대소문자 구분 여부, true : 대소문자 무시, false: 대소문자 구분
* total_byte [out] 해당 서비스 Tran ID 의 Total 스토리지 계약 용량 정보
* used_tbyte [out] 해당 uri가 사용하고있는 용량 정보
* return 오류발생시 -1, 해당정보가 존재하지 않는 경우 0 을 반환, 정상 처리된 경우 1 을 반환함.
*/
int dbms_get_service_quotaex( const dav_repos_resource * db_r, const char * tran_id, bool is_uricaseignore, apr_int64_t * total_byte, apr_int64_t * used_byte );
/* Build namespace
*
* Read namespace infor from DB and fill hash
* db_r must have pool
* This hash is for PROPFIND
* */
void dbms_build_ns_id_hash(dav_repos_resource * db_r);
// 2013.08.22 dadamin
// set namespace
void dbms_set_namespace(dav_repos_resource * db_r, dav_repos_property *pr, const char *snamespace);
// set ns_id
void dbms_set_ns_id(dav_repos_resource * db_r, const char *snamespace, dav_repos_property *pr);
const char *dbms_get_ns(dav_repos_resource * db_r, const long ns_id);
long dbms_get_ns_id(dav_repos_resource * db_r, const char *namespace);
/* NULL Lock */
dav_error *dbms_load_locknull_list(request_rec *r, const char *path, apr_text_header * thead, apr_pool_t * pool);
dav_error *dbms_save_locknull_member(request_rec *r, const char *filename, apr_pool_t * pool);
dav_error *dbms_remove_locknull_member(request_rec *r, const char *filename, apr_pool_t * pool);
dav_error *dbms_load_lock_record(request_rec *r, const char *key,
dav_lock_discovery ** direct,
dav_lock_indirect ** indirect,
int *need_save,
apr_pool_t * pool);
dav_error *dbms_save_lock_record(request_rec *r, const char *key,
const dav_lock_discovery * direct,
const dav_lock_indirect * indirect,
apr_pool_t * pool);
dav_error *dbms_remove_lock_record(request_rec *r, const char *key, apr_pool_t * pool);
int dbms_lock_exists(request_rec *r, const char *key, apr_pool_t * pool);
int dbms_modify_resource(const dav_resource * resource);
#endif