#pragma module BBS_HTLB "BBS_HTLB-1-X" /* **++ ** FACILITY: ** BBS/Forum system on DEC RDB ** ** MODULE DESCRIPTION: ** ** This module contains a set of routines to interoperate with VMS Text Library to retrive ** HTML templates. ** ** AUTHORS: ** ** Ruslan R. Laishev ** ** CREATION DATE: 13-APR-2005 ** ** DESIGN ISSUES: ** ** ** MODIFICATION HISTORY: ** **-- */ #include #include #include #include #include #include #include #include #include #include #define __NEW_STARLET 1 #include "bbsdef.h" #include "bbs_msg.h" #define INIT_SDESC(dsc, len, ptr) {(dsc).dsc$b_dtype = DSC$K_DTYPE_T;\ (dsc).dsc$b_class = DSC$K_CLASS_S; (dsc).dsc$w_length = (short) (len);\ (dsc).dsc$a_pointer = (ptr);} #define INIT_DDESC(dsc) {(dsc).dsc$b_dtype = DSC$K_DTYPE_T;\ (dsc).dsc$b_class = DSC$K_CLASS_D;(dsc).dsc$w_length = 0;\ (dsc).dsc$a_pointer = 0;} /* ** Names/File specifications of the HTML Text/Help Libraries */ $DESCRIPTOR(htlb_fns, "BBS$HTLB"); $DESCRIPTOR(hhlb_fns, "BBS$HHLB"); unsigned htlb_idx = 0,hhlb_idx = 0; /* Library indexes */ #define ASCIC(a) ((unsigned char)sizeof(a)-1),a HTML_FMT tpl_table [] = { {FMT$K_UAT_START, ASCIC("UAT-START")}, {FMT$K_UAT_ROW, ASCIC("UAT-ROW")}, {FMT$K_UAT_END, ASCIC("UAT-END")}, {FMT$K_UPT_START, ASCIC("UPT-START")}, {FMT$K_UPT_ROW, ASCIC("UPT-ROW")}, {FMT$K_UPT_END, ASCIC("UPT-END")}, {FMT$K_CAT_START, ASCIC("CAT-START")}, {FMT$K_CAT_ROW, ASCIC("CAT-ROW")}, {FMT$K_CAT_END, ASCIC("CAT-END")}, {FMT$K_SUBCAT_START, ASCIC("SUBCAT-START")}, {FMT$K_SUBCAT_ROW, ASCIC("SUBCAT-ROW")}, {FMT$K_SUBCAT_END, ASCIC("SUBCAT-END")}, {0,0,0}}; /* **++ ** FUNCTIONAL DESCRIPTION: ** ** Open the BBS's HTML Templates VMS Text Library and BBS's VMS Help Library. ** ** FORMAL PARAMETERS: ** ** None. ** ** RETURN VALUE: ** ** VMS Condition code ** **-- */ int bbs_hxlb_init (void) { int status,txtrfa[2]; struct dsc$descriptor key,*fmt,outbufdes; /* if ( 1 & (status = lbr$ini_control(&hhlb_idx,&LBR$C_READ,&LBR$C_TYP_TXT,NULL)) ) if ( 1 & (status = lbr$open(&hhlb_idx,&hhlb_fns,0,0,0,0,0)) ) status = lbr$set_locate(&hhlb_idx); */ if ( 1 & (status = lbr$ini_control(&htlb_idx,&LBR$C_READ,&LBR$C_TYP_TXT,NULL)) ) if ( 1 & (status = lbr$open(&htlb_idx,&htlb_fns,0,0,0,0,0)) ) status = lbr$set_locate(&htlb_idx); if ( !(1 & status) ) lib$signal(status); /* ** Run over HTML Format string table and load format ** string into memory */ for(int i = 0;tpl_table[i].fmt$w_len && tpl_table[i].fmt$t_name;i++) { /* ** Lookup key */ INIT_SDESC(key,tpl_table[i].fmt$w_len,tpl_table[i].fmt$t_name); if ( !(1 & (status = lbr$lookup_key(&htlb_idx,&key,&txtrfa))) ) { // lib$signal(BBS_NOTPL,3,&key,&htlb_fns,status); continue; } /* ** Reading records of the module with name tpl_table[i].key */ INIT_SDESC(outbufdes,0,NULL); fmt = (struct dsc$descriptor *) &tpl_table[i].fmt$l_fmt; INIT_DDESC(*fmt); while ( 1 & (status = lbr$get_record(&htlb_idx,NULL,&outbufdes)) ) if ( !(1 & (status = str$concat(fmt,fmt,&outbufdes))) ) break; if ( status != RMS$_EOF ) return status; } return SS$_NORMAL; return status; } #if 0 int main (void) { int status; if ( !(1 & (status = bbs_hxlb_init())) ) lib$signal(status); } #endif