1 # ===================================================================== 2 # blogger.getRecentPosts.awk: Blogger API 1.0 and MetaWeblog API. 3 # 4 # Copyright (c) 2007,2008,2009,2010 Carlo Strozzi 5 # 6 # This program is free software; you can redistribute it and/or modify 7 # it under the terms of the GNU General Public License as published by 8 # the Free Software Foundation; version 2 dated June, 1991. 9 # 10 # This program is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with this program; if not, write to the Free Software 17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 # 19 # ===================================================================== 20 21 # ===================================================================== 22 # void _userproc(int mode) 23 # ===================================================================== 24 25 function _userproc(mode, value,a,tmp) { 26 27 if (mode == _O_REQUEST) { # request. 28 29 if (_request("0_0",1) ~ /^blogger\./) { # BloggerAPI 1.0 30 bloggerAuth() 31 split(_request("2_1",1),a,"/") # target language/group 32 } 33 else { MetaWeblog API (default) 34 bloggerAuth("2_1","3_1","1_1") 35 split(_request("1_1",1),a,"/") # target language/group 36 } 37 38 # Handle numeric group specification. 39 if (a[2] == _NULL && (a[1]/=1)) { 40 tmp = ENVIRON["CSA_ROOT"] "/var/nodes/" \ 41 substr(a[1],1,1) "/" substr(a[1],2,1) "/" \ 42 substr(a[1],3,1) "/" a[1] 43 44 getline value < tmp; close(tmp) 45 split(value,a,"/") 46 _rcset("cgi.numeric","on") # tell the caller. 47 } 48 49 if (_LANG[a[1]] != _NULL) _rcset("CSA_LANG",a[1]) 50 51 # group must not be null and it may not contain the 52 # unescaped ``.'' character. 53 54 if (a[2] != _NULL && a[2] !~ /\./) { 55 _rcset("cgi.group",unixify(a[2])) 56 _rcset("cgi.group.literal",a[2]) 57 } 58 59 # Increase the specified count by '1', to let the underlying 60 # shell script account for the table header. 61 if ((value=(_request("5_1")/1))) _rcset("cgi.numposts",++value) 62 63 # The following test is necessary since the address could, 64 # at least in theory, have been set to any string by the 65 # remote user, due to how it is handled to cope with stunnel(8) 66 # and the lack of transproxy support in kernel 2.4.x. 67 68 if (_isipaddr(ENVIRON["REMOTE_ADDR"]) == _TRUE) 69 value = ENVIRON["REMOTE_ADDR"] 70 else value = "0.0.0.0" 71 72 _rcset("REMOTE_ADDR",value) 73 } 74 75 else { # response. 76 77 # generic template conditionals. 78 79 ifsections() 80 } 81 } 82 83 # EOF