summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-03-15 15:30:22 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-03-15 15:30:22 +0800
commit11795e8a33b288eb61b92c75c498fa2598f42945 (patch)
tree12ea12571ff5d97d41b6dc0f01d403e05ca20208
parentb78e3948144360a41a582d4b56a2c000e7eb44c6 (diff)
downloadpttbbs-11795e8a33b288eb61b92c75c498fa2598f42945.tar
pttbbs-11795e8a33b288eb61b92c75c498fa2598f42945.tar.gz
pttbbs-11795e8a33b288eb61b92c75c498fa2598f42945.tar.bz2
pttbbs-11795e8a33b288eb61b92c75c498fa2598f42945.tar.lz
pttbbs-11795e8a33b288eb61b92c75c498fa2598f42945.tar.xz
pttbbs-11795e8a33b288eb61b92c75c498fa2598f42945.tar.zst
pttbbs-11795e8a33b288eb61b92c75c498fa2598f42945.zip
no longer maintained
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1595 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--pttpi/README4
-rw-r--r--pttpi/cgi/Makefile16
-rw-r--r--pttpi/cgi/pttpi.c249
-rw-r--r--pttpi/cgi/t/.cvsignore1
-rw-r--r--pttpi/cgi/t/article.list.pl16
-rw-r--r--pttpi/cgi/t/article.readfn.pl15
-rw-r--r--pttpi/cgi/t/board.getBid.pl12
-rw-r--r--pttpi/cgi/t/board.getBrdInfo.pl15
-rw-r--r--pttpi/cgi/t/board.getNarticle.pl14
-rw-r--r--pttpi/cgi/t/class.list.pl14
-rw-r--r--pttpi/cgi/t/host.pl.sample2
-rw-r--r--pttpi/doc/spec50
-rw-r--r--pttpi/include/pierr.h9
13 files changed, 0 insertions, 417 deletions
diff --git a/pttpi/README b/pttpi/README
deleted file mode 100644
index 8f60ff6c..00000000
--- a/pttpi/README
+++ /dev/null
@@ -1,4 +0,0 @@
-PTT Programming Interface
-
-這目前還是一個實驗性的東西,
-它還不穩定, 沒有效率, 沒有經過完整測試, 並且 spec 還在編修中.
diff --git a/pttpi/cgi/Makefile b/pttpi/cgi/Makefile
deleted file mode 100644
index 42613de3..00000000
--- a/pttpi/cgi/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-# $Id: Makefile,v 1.1 2003/05/19 01:33:00 in2 Exp $
-
-.include "../../pttbbs.mk"
-
-CFLAGS+= -I../../include `xmlrpc-c-config cgi-server --cflags`
-LDFLAGS+= `xmlrpc-c-config cgi-server --libs`
-
-UTIL_OBJS= \
- ../../util/util_cache.o ../../util/util_record.o ../../util/util_passwd.o
-all: pttpi.cgi
-
-pttpi.cgi: pttpi.c
- $(CC) $(CFLAGS) $(LDFLAGS) -o pttpi.cgi pttpi.c $(UTIL_OBJS)
-
-clean:
- rm -f *.cgi *~
diff --git a/pttpi/cgi/pttpi.c b/pttpi/cgi/pttpi.c
deleted file mode 100644
index 1e452f68..00000000
--- a/pttpi/cgi/pttpi.c
+++ /dev/null
@@ -1,249 +0,0 @@
-/* $Id: pttpi.c,v 1.5 2003/05/19 05:15:36 in2 Exp $ */
-#include "bbs.h"
-#include "pierr.h"
-#include <xmlrpc.h>
-#include <xmlrpc_cgi.h>
-
-extern SHM_t *SHM;
-typedef xmlrpc_int32 int32;
-
-#define errorexit() if( env->fault_occurred ) return NULL
-int check_board_and_permission(int bid)
-{
- return (bid < 0 || bid > MAX_BOARD ||
- !bcache[bid].brdname[0] ||
- (bcache[bid].brdattr & BRD_HIDE) ||
- (bcache[bid].level && !(bcache[bid].brdattr & BRD_POSTMASK) &&
- (bcache[bid].level &
- ~(PERM_BASIC|PERM_CHAT|PERM_PAGE|PERM_POST|PERM_LOGINOK))));
-}
-
-#define check_bp_return(bid) \
- if( check_board_and_permission(bid) ) \
- return xmlrpc_build_value(env, "{s:i}", \
- "errno", PIERR_NOBRD);
-
-#define errorreturn(returncode) \
- return xmlrpc_build_value(env, "{s:i}", \
- "errno", returncode)
-
-xmlrpc_value *
-getBid(xmlrpc_env *env, xmlrpc_value *param_array, void *user_data)
-{
- /* !!! overwrite util_cache.c !!! */
- char *brdname;
- int bid;
-
- xmlrpc_parse_value(env, param_array, "(s)", &brdname);
- errorexit();
-
- bid = getbnum(brdname);
- return xmlrpc_build_value(env, "{s:i,s:s,s:i}",
- "errno", (bid == -1 ? PIERR_NOBRD : PIERR_OK),
- "brdname", brdname,
- "bid", (int32)bid);
-}
-
-xmlrpc_value *
-getBrdInfo(xmlrpc_env *env, xmlrpc_value *param_array, void *user_data)
-{
- int32 bid;
-
- xmlrpc_parse_value(env, param_array, "(i)", &bid);
- errorexit();
- check_bp_return(bid);
-
- return xmlrpc_build_value(env, "{s:i,s:s,s:i,s:6,s:6,s:i}",
- "errno", PIERR_OK,
- "brdname", bcache[bid].brdname,
- "bid", (int32)bid,
- "title", bcache[bid].title, strlen(bcache[bid].title),
- "BM", bcache[bid].BM, strlen(bcache[bid].BM),
- "nuser", bcache[bid].nuser);
-}
-
-char *getpath(int bid, char *fn)
-{
- static char fpath[MAXPATHLEN];
- if( fn == NULL )
- fn = "";
- snprintf(fpath, sizeof(fpath), "boards/%c/%s/%s",
- bcache[bid].brdname[0], bcache[bid].brdname, fn);
- return fpath;
-}
-
-int getfilesize(int bid, char *fn, int *fd)
-{
- struct stat sb;
- if( fd == NULL ){
- if( stat(getpath(bid, fn), &sb) < 0 )
- return -1;
- }
- else {
- if( (*fd = open(getpath(bid, fn), O_RDONLY)) < 0 )
- return -1;
- if( fstat(*fd, &sb) < 0 ){
- close(*fd);
- return -1;
- }
- }
- return sb.st_size;
-}
-
-xmlrpc_value *
-getNarticle(xmlrpc_env *env, xmlrpc_value *param_array, void *user_data)
-{
- int bid, nas;
-
- xmlrpc_parse_value(env, param_array, "(i)", &bid);
- errorexit();
- check_bp_return(bid);
- nas = getfilesize(bid, ".DIR", NULL);
-
- return xmlrpc_build_value(env, "{s:i,s:i}",
- "errno", (nas == -1 ? PIERR_INT : PIERR_OK),
- "narticle", nas / sizeof(fileheader_t));
-}
-
-xmlrpc_value *
-class_list(xmlrpc_env *env, xmlrpc_value *param_array, void *user_data)
-{
- int bid;
- boardheader_t *bptr;
- xmlrpc_value *ret, *t;
-
- xmlrpc_parse_value(env, param_array, "(i)", &bid);
- errorexit();
-
- if( bid != 0 )
- check_bp_return(bid);
-
- if( bid != 0 && !(bcache[bid].brdattr & BRD_GROUPBOARD) )
- errorreturn(PIERR_NOTCLASS);
-
- ret = xmlrpc_build_value(env, "()");
- for( bptr = bcache[bid].firstchild[0] ;
- bptr != (boardheader_t*)~0 ;
- bptr = bptr->next[0] ){
- if( check_board_and_permission(bptr - bcache) )
- continue;
- t = xmlrpc_build_value(env, "{s:i,s:s,s:6,s:i,s:6,s:i,s:b}",
- "bid", (int32)(bptr - bcache),
- "brdname", bptr->brdname,
- "title", bptr->title + 5, strlen(bptr->title) - 5,
- "gid", bptr->gid,
- "BM", bptr->BM, strlen(bptr->BM),
- "nuser", (int32)bptr->nuser,
- "isclass", (xmlrpc_bool)
- (bptr->brdattr & BRD_GROUPBOARD) ? 1 : 0
- );
- xmlrpc_array_append_item(env, ret, t);
- }
- return ret;
-}
-
-xmlrpc_value *
-article_list(xmlrpc_env *env, xmlrpc_value *param_array, void *user_data)
-{
-#define MAXGETARTICLES 20
- xmlrpc_value *ret, *t;
- fileheader_t art[MAXGETARTICLES];
- int32 bid, from, nArticles, fd, nGets, i;
-
- xmlrpc_parse_value(env, param_array, "(ii)", &bid, &from);
- errorexit();
- check_bp_return(bid);
-
- if( (nArticles = getfilesize(bid, ".DIR", &fd)) < 0 )
- errorreturn(PIERR_INT);
- nArticles /= sizeof(fileheader_t);
-
- if( from < 0 )
- from += nArticles;
- if( from < 0 || from > nArticles ){
- close(fd);
- errorreturn(PIERR_NOMORE);
- }
-
- nGets = (((from + MAXGETARTICLES) < nArticles) ?
- MAXGETARTICLES : (nArticles - from));
- if( (nGets = read(fd, art, nGets * sizeof(fileheader_t))) < 0 ){
- close(fd);
- errorreturn(PIERR_INT);
- }
- close(fd);
- nGets /= sizeof(fileheader_t);
-
- ret = xmlrpc_build_value(env, "()");
- for( i = 0 ; i < nGets ; ++i ){
- t = xmlrpc_build_value(env, "{s:i,s:s,s:i,s:s,s:s,s:6}",
- "articleid", (int32)(from + i),
- "filename", art[i].filename,
- "recommend", (int32)art[i].recommend,
- "owner", art[i].owner,
- "date", art[i].date,
- "title", art[i].title, strlen(art[i].title)
- );
- xmlrpc_array_append_item(env, ret, t);
- }
- return ret;
-}
-
-xmlrpc_value *
-_article_readfn(xmlrpc_env *env, int bid, char *fn)
-{
- char *content;
- int fd, size;
- xmlrpc_value *ret;
- if( (size = getfilesize(bid, fn, &fd)) < 0 )
- errorreturn(PIERR_INT);
-
- content = (char *)malloc(sizeof(char) * size);
- read(fd, content, size);
- close(fd);
- ret = xmlrpc_build_value(env, "{s:6}", "content", content, size);
- free(content);
-
- return ret;
-}
-
-xmlrpc_value *
-article_readfn(xmlrpc_env *env, xmlrpc_value *param_array, void *user_data)
-{
- int bid;
- char *fn;
-
- xmlrpc_parse_value(env, param_array, "(is)", &bid, &fn);
- errorexit();
-
- if( fn == NULL || (fn[0] != 'M' && fn[0] != 'G') || fn[1] != '.' )
- errorreturn(PIERR_NOBRD);
- check_bp_return(bid);
-
- return _article_readfn(env, bid, fn);
-}
-
-int main(int argc, char **argv)
-{
- attach_SHM();
- chdir(BBSHOME);
- xmlrpc_cgi_init(XMLRPC_CGI_NO_FLAGS);
- xmlrpc_cgi_add_method_w_doc("board.getBid", &getBid, NULL, "?",
- "get bid from brdname");
- xmlrpc_cgi_add_method_w_doc("board.getBrdInfo", &getBrdInfo, NULL, "?",
- "get board information");
- xmlrpc_cgi_add_method_w_doc("board.getNarticle", &getNarticle, NULL, "?",
- "get # articles in the board");
-
- xmlrpc_cgi_add_method_w_doc("class.list", &class_list, NULL, "?",
- "list (C)lass");
-
- xmlrpc_cgi_add_method_w_doc("article.list", &article_list, NULL, "?",
- "article list");
- xmlrpc_cgi_add_method_w_doc("article.readfn", &article_readfn, NULL, "?",
- "read the article by filename");
-
- xmlrpc_cgi_process_call();
- xmlrpc_cgi_cleanup();
- return 0;
-}
diff --git a/pttpi/cgi/t/.cvsignore b/pttpi/cgi/t/.cvsignore
deleted file mode 100644
index 9f20a79c..00000000
--- a/pttpi/cgi/t/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-host.pl
diff --git a/pttpi/cgi/t/article.list.pl b/pttpi/cgi/t/article.list.pl
deleted file mode 100644
index 27370aa1..00000000
--- a/pttpi/cgi/t/article.list.pl
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/usr/bin/perl
-# $Id: article.list.pl,v 1.1 2003/05/19 02:04:14 in2 Exp $
-use Frontier::Client;
-use Frontier::RPC2;
-use MIME::Base64;
-use Data::Dumper;
-do 'host.pl';
-
-$bid = $ARGV[0] || 0;
-
-$server = Frontier::Client->new(url => $server_url);
-$result = $server->call('article.list',
- $bid, # bid
- 0); # from # article
-
-print Dumper($result);
diff --git a/pttpi/cgi/t/article.readfn.pl b/pttpi/cgi/t/article.readfn.pl
deleted file mode 100644
index e2d0bc27..00000000
--- a/pttpi/cgi/t/article.readfn.pl
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/usr/bin/perl
-# $Id: article.readfn.pl,v 1.1 2003/05/19 02:06:34 in2 Exp $
-use Frontier::Client;
-use Frontier::RPC2;
-use MIME::Base64;
-use Data::Dumper;
-do 'host.pl';
-
-$bid = $ARGV[0] || 0;
-$fn = $ARGV[1] || 'M.1047292518.A.48E';
-
-$server = Frontier::Client->new(url => $server_url);
-$result = $server->call('article.readfn', $bid, $fn);
-
-print decode_base64($result->{content}->value());
diff --git a/pttpi/cgi/t/board.getBid.pl b/pttpi/cgi/t/board.getBid.pl
deleted file mode 100644
index a628da4e..00000000
--- a/pttpi/cgi/t/board.getBid.pl
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/perl
-# $Id: board.getBid.pl,v 1.1 2003/05/19 01:57:22 in2 Exp $
-use Frontier::Client;
-use Data::Dumper;
-do 'host.pl';
-
-$brdname = $ARGV[0] || 'SYSOP';
-$server = Frontier::Client->new(url => $server_url);
-$result = $server->call('board.getBid', $brdname);
-
-print "board.getBid($brdname) from $server_url:\n";
-print Dumper($result);
diff --git a/pttpi/cgi/t/board.getBrdInfo.pl b/pttpi/cgi/t/board.getBrdInfo.pl
deleted file mode 100644
index 7870e386..00000000
--- a/pttpi/cgi/t/board.getBrdInfo.pl
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/usr/bin/perl
-# $Id: board.getBrdInfo.pl,v 1.1 2003/05/19 01:58:27 in2 Exp $
-use Frontier::Client;
-use Frontier::RPC2;
-use MIME::Base64;
-use Data::Dumper;
-do 'host.pl';
-
-$bid = $ARGV[0] || 0;
-
-$server = Frontier::Client->new(url => $server_url);
-$result = $server->call('board.getBrdInfo', $bid);
-
-print Dumper($result);
-print decode_base64($result->{title}->value());
diff --git a/pttpi/cgi/t/board.getNarticle.pl b/pttpi/cgi/t/board.getNarticle.pl
deleted file mode 100644
index a5fb56a1..00000000
--- a/pttpi/cgi/t/board.getNarticle.pl
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/perl
-# $Id: board.getNarticle.pl,v 1.1 2003/05/19 02:01:15 in2 Exp $
-use Frontier::Client;
-use Frontier::RPC2;
-use MIME::Base64;
-use Data::Dumper;
-do 'host.pl';
-
-$bid = $ARGV[0] || 0;
-
-$server = Frontier::Client->new(url => $server_url);
-$result = $server->call('board.getNarticle', $bid);
-
-print Dumper($result);
diff --git a/pttpi/cgi/t/class.list.pl b/pttpi/cgi/t/class.list.pl
deleted file mode 100644
index 9e10932b..00000000
--- a/pttpi/cgi/t/class.list.pl
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/perl
-# $Id: class.list.pl,v 1.1 2003/05/19 02:02:52 in2 Exp $
-use Frontier::Client;
-use Frontier::RPC2;
-use MIME::Base64;
-use Data::Dumper;
-do 'host.pl';
-
-$bid = $ARGV[0] || 0;
-
-$server = Frontier::Client->new(url => $server_url);
-$result = $server->call('class.list', $bid);
-
-print Dumper($result);
diff --git a/pttpi/cgi/t/host.pl.sample b/pttpi/cgi/t/host.pl.sample
deleted file mode 100644
index 72669230..00000000
--- a/pttpi/cgi/t/host.pl.sample
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/usr/bin/perl
-$server_url = 'http://host_to_pttpi/path_to_pttpi/pttpi.cgi'
diff --git a/pttpi/doc/spec b/pttpi/doc/spec
deleted file mode 100644
index e1460030..00000000
--- a/pttpi/doc/spec
+++ /dev/null
@@ -1,50 +0,0 @@
-board.getBid get bid from board name
-input (s)
- (board name)
-output ({s:i, s:s, s:i})
- {errno => errno,
- brdname => boardname,
- bid => boardid} (bid = -1 if error)
-
-
-board.getBrdInfo
-get board information (by bid)
-input (i)
- (bid)
-output ({s:i,s:s,s:i,s:6,s:6,s:i})
- {errno => errno,
- brdname => boardname
- bid => bid,
- title => title (Base64),
- BM => board manager(s) (Base64),
- nuser => #users in this board,
- }
-
-board.getNarticle
-get # articles in the board
-input (i)
- (bid)
-output ({s:i, s:s, s:i})
- {errno => errno,
- narticle => #articles in the board}
-
-article.list
-get article list of bid
-input (ii)
- (bid, from # article)
-output: ({s:i,s:s,s:i,s:s,s:s,s:6}...)
- [{articleid => article id,
- filename => file name,
- recommend => recommend,
- owner => owner's userid,
- date => date (format: mm/dd),
- title => article title (Base64)},
- {...},...]
-
-article.readfn
-read article by bid and filename
-input (is)
- (bid, filename)
-output ({s:6})
- {content => content}
-
diff --git a/pttpi/include/pierr.h b/pttpi/include/pierr.h
deleted file mode 100644
index da462a36..00000000
--- a/pttpi/include/pierr.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef _PIERR_H_
-#define _PIERR_H_
-
-#define PIERR_OK (int32)0 /* no error */
-#define PIERR_INT (int32)1 /* internal error (ex: syscall failure) */
-#define PIERR_NOBRD (int32)2 /* no such board or permission denied */
-#define PIERR_NOMORE (int32)3 /* no more data */
-#define PIERR_NOTCLASS (int32)4 /* this bid is NOT class */
-#endif