From c7524a591d0d0dd26dce83dbce7a695c8ddebee9 Mon Sep 17 00:00:00 2001 From: Ari Johnson Date: Tue, 20 Feb 2007 04:01:45 +0000 Subject: [PATCH] Initial import --- cnet.mush | 204 ++++++++++++++++++ config.minc | 21 ++ convertdb.mush | 27 +++ expire.mush | 5 + functions.mush | 443 +++++++++++++++++++++++++++++++++++++++ info.mush | 148 +++++++++++++ jobcode.mush | 553 +++++++++++++++++++++++++++++++++++++++++++++++++ macros.minc | 31 +++ mainmenu.mush | 315 ++++++++++++++++++++++++++++ paige.minc | 8 + reader.mush | 167 +++++++++++++++ rome.minc | 12 ++ sql.minc | 101 +++++++++ startunit.mush | 27 +++ writer.mush | 428 ++++++++++++++++++++++++++++++++++++++ yv.minc | 12 ++ 16 files changed, 2502 insertions(+) create mode 100644 cnet.mush create mode 100644 config.minc create mode 100644 convertdb.mush create mode 100644 expire.mush create mode 100644 functions.mush create mode 100644 info.mush create mode 100644 jobcode.mush create mode 100644 macros.minc create mode 100644 mainmenu.mush create mode 100644 paige.minc create mode 100644 reader.mush create mode 100644 rome.minc create mode 100644 sql.minc create mode 100644 startunit.mush create mode 100644 writer.mush create mode 100644 yv.minc diff --git a/cnet.mush b/cnet.mush new file mode 100644 index 0000000..0a3f2e8 --- /dev/null +++ b/cnet.mush @@ -0,0 +1,204 @@ +# Author: Nveid [RLB] +# +# CobraNet - CobraMUSH Board System +############ Verison 1.75b #################################### +# To unload this you must be using umpp.pl obtainable +# at ftp://ftp.nveid.com/pub/mush_utilties/umpp.pl +# +# +# To prepare for Install Create the following objects first +# and set the appropriate defines +# +############################################################## +# +# DEFINE | Create Object +# ----------------------------------------------- +# CNET_CODE_OBJ | @create CobraNet +# TOP_LEVEL_BOARD | @create CobraNet Board +# MESSAGE_DATABASE | @create CobraNet MessageDatabase +# JOB_DATABASE | @create CobraNet Job Database +# +############################################################### + + +#define COBRANET_VERSION 1.75b + + +#include "config.minc" +#include "macros.minc" /@@ Macros File @@/ + + +PRE_INPUT + +#pragma umpp FlushOutput void + +#ifdef INSTALL +th set(me,cnet_obj:[create(CobraNet)]) + +th set(me,top_level:[create(CobraNet Board)]) + +th set(me,message_database:[create(Message Database)]) + +#ifdef JOBCODE +th set(me,job_database:[create(Job Database)]) +#endif +/@@ Redo This To Output a 'config.minc' for them @@/ +think/noeval =========================================================================== +think/noeval Set the following defines in your script and re process __FILE__ +think/noeval --------------------------------------------------------------------------- +think/noeval Define | Value +think/noeval --------------------------------------------------------------------------- +think CNET_CODE_OBJ | [v(cnet_obj)] +think TOP_LEVEL_BOARD | [v(top_level)] +#ifndef SQL_CNET +think MESSAGE_DATABASE | [v(message_database)] +#endif /@@ SQL_CNET @@/ +#ifdef JOBCODE +think JOB_DATABASE | [v(job_database)] +#endif +think/noeval =========================================================================== +@dol cnet_obj top_level message_database job_database=@wipe me/## + +#else + +#define USE_ADAMS_UNFORMAT 1 /@@ Toggle Strict Adam Dray's Unformat processing. + @@ Recognize '-' as the seperator of commands + @@/ + + + +# TODO: +# Create a Function wrapper for colorized menu lists to make more readable +# Adjust @break hacks from before @break 0=then do and @assert 0=then do, type crapp existed +# +# Note: The CobraNet code file is work in progress of making it easier for me 'Nveid' to maintain the +# code and work with it. + +# First Clear Object As it exists to clear an left over deleted attributes +- +@wipe CNET_CODE_OBJ + +- +# CobraNet Code + +@DESCRIBE CNET_CODE_OBJ=TOP_LEVEL_BOARD - TopLevel Board%r + MESSAGE_DATABASE - CobraNet Message DB%r + Locks: %r + CANREAD%r + CANWRITE%r + SEEBOARD%R + MODERATOR +- +@VA CNET_CODE_OBJ = TOP_LEVEL_BOARD +- + +&CREDITS CNET_CODE_OBJ=Created by Nveid@Yesterday's Voyage (Email: nveid@nveid.com) for CobraMUSH. + +- +&VERSION CNET_CODE_OBJ= CobraNet Version COBRANET_VERSION. + Current Version Uploaded __DATE__ at __TIME__ with Ultimate MUSH Pre Processor __VERSION__. +- +&INFO TOP_LEVEL_BOARD= CobraNet Version COBRANET_VERSION.%r + Current Version Uploaded __DATE__ at __TIME__ with UMPP __VERSION__ +- + +#include "mainmenu.mush" +#include "writer.mush" +#include "reader.mush" +#include "functions.mush" +#include "jobcode.mush" +#include "info.mush" +- +/@@ Probably setting a #define for this would be better.. @@/ +@lock/use *CobraNet==*CobraNet +- +@set *CobraNet=!no_command +- +&CM_CNETALERT *CobraNet=$cnetalert *: + /@@ First Make Sure the Board Exists on this MUSH @@/ + @assert sql(SELECT COUNT(*) FROM mushes where board = [elements(%0,1,|)] and mush = "[mudname()]"); + /@@ Alert! @@/ + @dol iter(remove(lwho(),%#),if(nor(lt(level(##),2),hasflag(##,rpmode),hasflag(##,builder)),##)) + =@pemit ##=ansi(hy,New message '[elements(%0,3,|)]' posted to '[elements(%0,2,|)]' by [elements(%0,4,|)].); +- + + + +&FILT_READBOARDS CNET_CODE_OBJ=elock(%0/canread,%#) + +- + +&GET_UC_BOARD CNET_CODE_OBJ=extract(get(%0/cnet_info),2,1) + +- + +&GET_UC_J1 CNET_CODE_OBJ=get(JOB_DATABASE/j1_%0) + +- + +&GET_UC_JID CNET_CODE_OBJ=get(%0/cnet_jid) + +- + +&GET_UC_SAVE CNET_CODE_OBJ=extract(get(%0/cnet_info),3,1) + +- + +&GET_UC_STEP CNET_CODE_OBJ=get(%0/cnet_step) + + +- + + + +&PROMPT CNET_CODE_OBJ=%zh%zy + CobraNet + %zn%zr + > + %zn + +- +&SET_UC_BOARD CNET_CODE_OBJ=[set(%0,cnet_info:[replace(get(%0/cnet_info),2,%1)])] +- + +&SET_UC_MID CNET_CODE_OBJ=set(%0,cnet_mid:%1) + +- + +&SET_UC_MODE CNET_CODE_OBJ=[set(%0,cnet_info:[replace(get(%0/cnet_info),1,%1)])] + +- + +&SET_UC_PAGE CNET_CODE_OBJ=set(%0,cnet_page:%1) + +- + +&SET_UC_PD CNET_CODE_OBJ=set(%0,cnet_postdata_%1:%2) + +- + +&SET_UC_SAVE CNET_CODE_OBJ=[set(%0,cnet_info:[replace(get(%0/cnet_info),3,%1)])] + +- + +&SET_UC_STEP CNET_CODE_OBJ=set(%0,cnet_step:%1) + +- + +&SET_UC_UTS CNET_CODE_OBJ=set(%0,uts_[edit(objid(%1),:,~)]:%2) + +- + +@STARTUP CNET_CODE_OBJ=@function cnetpost=CNET_CODE_OBJ,gfun_cnetpost,3,3,noguest ulocal + +- + +# Setup User Config Infor for user in Cnet +# 'Mode CurrentBoard StoredBoard' is format + +&START_UC_INFO CNET_CODE_OBJ=[set(%0,cnet_info:0 %1 TOP_LEVEL_BOARD)] + +#endif /@@ INSTALL @@/ +- + +POST_INPUT diff --git a/config.minc b/config.minc new file mode 100644 index 0000000..7a8ead1 --- /dev/null +++ b/config.minc @@ -0,0 +1,21 @@ +#ifndef __CONFIG_MINC__ +#define __CONFIG_MINC__ + + +# +# CobraNet Object Definitions +# + +#ifdef PAIGE +#include "paige.minc" +#elif defined(YV) +#include "yv.minc" +#else +#include "rome.minc" +#endif +# +#ifndef SQL_CNET +#define POSTS_ALLOWED(BOARD) t(get(BOARD/postsallowed)) +#endif + +#endif /@@ __CONFIG_MINC__ @@/ diff --git a/convertdb.mush b/convertdb.mush new file mode 100644 index 0000000..5834601 --- /dev/null +++ b/convertdb.mush @@ -0,0 +1,27 @@ +#include "config.minc" +#include "macros.minc" + +/@@ Convert Object Message DB to SQL @@/ +/@@ This doesn't take care of creating the boards tables.. must new_board() each of Those, and + set the board_ptr on each board object. + @@/ + +#define GET_MID_OLD_BODY(MESSAGE_ID) rest(rest(rest(rest(get(MESSAGE_DATABASE/msg_MESSAGE_ID),|),|),|),|) + +/@@ Message format in obj db is + DATE|NAME|DBREF|SUBJ|BODY + @@/ + +@dol iter(lattr(MESSAGE_DATABASE/msg_*),after(##,_))= + { + think setq(M,get(MESSAGE_DATABASE/MSG_##)); + think setq(B,iter(get(MESSAGE_DATABASE/BL_##),[get([itext(0)]/board_ptr)])); + @sql call new_post("[elements(%qM,2,|)]", + "[objid(elements(%qM,3,|))]", + "[sqlescape(elements(%qM,4,|))]" + ); + think setq(I,sql(select LAST_INSERT_ID())); + think SET_MID_TIMESTAMP_HARD(%qI, [elements(%qM,1,|)]); + think SET_MID_BODY(%qI, [GET_MID_OLD_BODY(##)]); + think SET_MID_BL(%qI, %qB); + } diff --git a/expire.mush b/expire.mush new file mode 100644 index 0000000..0685bf0 --- /dev/null +++ b/expire.mush @@ -0,0 +1,5 @@ +/@@ Expiry Code to be Ran Daily @@/ +@DAILY CNET_CODE_OBJ=@dol u(f.dlcon,TOP_LEVEL_BOARD)=@tri me/do_expire=## +- +&DO_EXPIRE CNET_CODE_OBJ=@set me=tmp_expire_var:[u(f.expire_check,%0)]; + @dol v(tmp_expire_var)=th u(f.delmsg,##,%0) diff --git a/functions.mush b/functions.mush new file mode 100644 index 0000000..503cb34 --- /dev/null +++ b/functions.mush @@ -0,0 +1,443 @@ +#ifndef __FUNCTIONS_MUSH__ +#define __FUNCTIONS_MUSH__ +- +# +# Function Start of CobraNet +# + +&F.START_KANET CNET_CODE_OBJ= + [if(elock(%0/seeboard,%#), + [pemit(%#,Starting CobraNet)] + [u(start_uc_info,%#,%0)] + [u(set_uc_page,%#,ulocal(f.selectpage,%0,%#))] + [pemit(%#,u(disp_main,%0))] + [program(%#,me,prog_menu)] + [prompt(%#,u(prompt))] + ,pemit(%#,You can't enter that board.))] + +- +# +# Global Function allow posting from a function type interface +# +# %0 - Board List Seperated by | +# %1 - Subject +# %2 - Message +# + +&GFUN_CNETPOST CNET_CODE_OBJ=squish( +#ifndef SQL_CNET + [setq(0,u(f.genmsg))] +#ifdef USE_FREELIST + [if(not(%q1),set(MESSAGE_DATABASE,freelist:[remove(get(MESSAGE_DATABASE/freelist),%q0)]))] +#endif /@@ USE_FREELIST @@/ + [set(MESSAGE_DATABASE, msg_%q0:[secs()]|[name(%@)]|%@|[squish(%1)]|%2)] + [iter([setq(C,0)]%0, + [switch(ulocal(f.findboard,%@,##) ,#-1,, + [if(and(elock(#$/canwrite,%@),POSTS_ALLOWED(#$)), + [setq(C,inc(%qc))] + [ulocal(f.pm2b,%q0,#$)] + [ulocal(f.notifyusersnew,#$,%q0)],#-1 + )] + )] + ,|)] + [if(%qC,1,0[ulocal(f.delmsg,%q0)])] + [ulocal(f.lmsg_check)]) +#else /@@ SQL_CNET @@/ + + +/@@ uses the mysql5 function we had.. forgot what was in it.. so new code might break + [sql(call new_post('[sqlescape(%n)]','%:', '[sqlescape({%1})]'))] + @@/ + [sql(INSERT INTO messages (Author,who,subject,readers, posted,FromMUSH) + VALUES ('[sqlescape(%n)]','%:','[sqlescape({%1})]', '%:', '1', '[sqlescape([mudname()])]') + )] + [setq(l,sql(select LAST_INSERT_ID()))]/@@ Remember what we just inserted @@/ + /@@ Set Mesage Body @@/ + [SET_MID_BODY(%qL,%2)] + [SET_UC_MID(%@,%qL)] + /@@ Now Loop Through %0 And Add to Boards @@/ + [iter(%0,switch(ulocal(f,findboard,%@,##) + ,#-1,/@@ Can't Do it @@/, + /@@ OtherWise Yes @@/ + ulocal(f.pm2b,GET_UC_MID(%@),##) + ) + ,| + )] + +#endif /@@ SQL_CNET @@/ + + +- +/@@ %0 - First Letter + %1 - Rest of Word + + e.g. ext + do it colorful, :) + @@/ + +&F.CMDLABEL CNET_CODE_OBJ= + %zn%zr%zh<%zh%zy + %0 + %zr> + %zn%zy + %1 + %zn +- +&F.LOADSAVEBOARD CNET_CODE_OBJ= + [u(set_uc_board,%0,setr(0,u(get_uc_save,%0)))] + [u(set_uc_page,%0,ulocal(f.selectpage,%q0,%0))] + [pemit(%#,ulocal(disp_main,%q0))] + [program(%#,me,prog_menu)] + [prompt(%#,u(prompt))] + +- + +&F.MAXPAGES CNET_CODE_OBJ=[if(mod(setr(0,words( +#ifndef SQL_CNET + get(%0/msg_list) +#else + MSG_LIST([get(%0/board_ptr)]) +#endif + )),10),inc(div(%q0,10)),div(%q0,10))] + +- + +&F.MSGDATE CNET_CODE_OBJ= +#ifndef SQL_CNET + extract(get(MESSAGE_DATABASE/msg_%0),1,1,|) +#else + GET_MID_DATE(%0) +#endif + +- + +&F.MSGOWNER CNET_CODE_OBJ= +#ifndef SQL_CNET + extract(get(MESSAGE_DATABASE/msg_%0),3,1,|) +#else + GET_MID_AUTHOR_OBJID(%0) + /@@ FIXME: We were doing a first(,:)... not sure why.. if problems persist look at this @@/ +#endif +- +&F.NEWTO CNET_CODE_OBJ=[squish([setq(0,0)][iter(get(%0/msg_list),if(and(gt(val(ulocal(f.msgdate,itext(0))),val(GET_UC_UTS(%0,%#))),not(strmatch(u(f.msgowner,itext(0)),%#))),[setq(0,inc(%q0))]))]%q0)] + +- + +# +# Total Up total Unread messages in a board and all subboards +# %0 - Top Level Boared to STart Checking from + +&F.NEWTO_TOT CNET_CODE_OBJ= + [squish( + [setq(0,0)] + [iter(filter(filt_readboards,%0 [u(f.dlcon,%0)]), +#ifdef SQL_CNET + [setq(p,get(##/board_ptr))] +#endif + [if(not(match(get(##/ignore),%#)), +#ifndef SQL_CNET + [iter( + get(##/msg_list), + if(and(gt(val(ulocal(f.msgdate,itext(0))),val(GET_UC_UTS(##,%#))) + ,not(strmatch(u(f.msgowner,itext(0)),%#)) + ),[setq(0,inc(%q0))] + ) + )] +#else + [setq(0,add(val(%q0),[UNREAD_COUNT(%qP,%:)]))] +#endif + )] + )] + %q0 + )] + +- +/@@ %0 - board + %1 - message id + + %qM - Messsage get() ** Not SQL + %qS - Message Subject ** SQL Only + %qL - MUSH Board Lookup Dbref + @@/ +&F.NOTIFYUSERSNEW CNET_CODE_OBJ= +#ifndef SQL_CNET + [setq(M,get(MESSAGE_DATABASE/msg_%1))] +#else + [setq(S,GET_MID_SUBJECT(%1))] +#endif + [iter(iter(remove(lwho(),%#),if(nor(lt(level(##),2),hasflag(##,rpmode),hasflag(##,builder)),##)), + [if(cand( + setr(L,u(f.findboard,##,[setr(N,ulocal(f.boardname,%0))])) + ,elock(%qL/canread,##) + ,not(match(get(%qL/ignore),##)) + ) +#ifndef SQL_CNET + ,[pemit(##,ansi(hy,New message '[squish(extract(%qM,4,1,|))]' posted to '%qN' by [name(%#)].))] +#else + ,[pemit(##,ansi(hy,New message '%qS' posted to '%qN' by [name(%#)].))] +#endif + )] + )] + /@@ Alert our litle cnet bot! @@/ + [pemit(num(*CobraNet),ALERTCNET5331-[get(%0/board_ptr)]|%qN|%qS|[name(%#)])] +- + + +# +# Grab Specified Page +# +/@@ + @@/ + +&F.PAGE CNET_CODE_OBJ=extract(%0,[if(eq(%1,1),1,inc(mul(dec(%1),%2)) )],%2) +- +&F.PAGESTART CNET_CODE_OBJ=[if(eq(%0,1),0,mul(dec(%0),%1))] + +- +# +# Post Message To Board +# %0 - Message ID +# %1 - Board Dbref + +&F.PM2B CNET_CODE_OBJ= +#ifndef SQL_CNET + [set(%1,msg_list:%0 [get(%1/msg_list)])] + [set(MESSAGE_DATABASE,bl_%0:%1 [get(MESSAGE_DATABASE/bl_%0)])] +#else /@@ SQL_CNET @@/ + [SET_MID_BL(%0, [setunion(GET_MID_BL(%0),get(%1/board_ptr))])] +#endif /@@ SQL_CNET @@/ + +- + +&F.QUICKJUMP CNET_CODE_OBJ= + [if(setr(0,u(f.findboard,%#,%0)), + [u(set_uc_board,%#,%q0)] + [u(set_uc_page,%#,ulocal(f.selectpage,%q0,%#))] + )] + [pemit(%#,u(disp_main,u(get_uc_board,%#)))] + +- + +# Quit Player completely out of cnet, no matter where they're at. + +&F.QUIT CNET_CODE_OBJ=[quitprog(%0)][wipe(%0/cnet_*)][pemit(%#,Quitting CobraNet.)] + +- +# +# Save Board in StoreBoard spot on UC Info of player +# + +&F.SAVECURRENTBOARD CNET_CODE_OBJ=u(set_uc_save,%0,u(get_uc_board,%0)) + +- +/@@ %0 - Board @@/ +&F.SELECTPAGE CNET_CODE_OBJ= +#ifndef SQL_CNET + [setq(W,val(GET_UC_UTS(%0,%1)))] + [setq(L,get(%0/msg_list))] + [null([setq(P,words(%qL))][iter( + revwords(%qL) + ,if(gte(val(ulocal(f.msgdate,##)),%qW),[setq(P,#@)][break()]))])] + [add(if(eq(mod(%qP,10),0),1,1),val(div(%qP,10)))] +#else + /@@ First Unread Message Id @@/ + [setq(F,first(sql(select id from messages where UNREAD_WHERE_CLAUSE([get(%0/board_ptr)], %:))))] + /@@ Grab Whole Message List @@/ + [setq(m,MSG_LIST([get(%0/board_ptr)]))] + [if(%qf, + /@@ Grab Whole Message List @@/ + [setq(m,MSG_LIST([get(%0/board_ptr)]))] + /@@ Get the where its at in the list @@/ + [setq(p,match(%qM,%qf))] + /@@ Then Isolate Where that is in the Message List @@/ + [add(if(eq(mod(%qP,10),0),1,1),val(div(%qP,10)))] + , + /@@ There is no unread message. So grab the last page possible @@/ + [if(mod(setr(0,words(%qM)),10), + inc(div(%q0,10)), + div(%q0,10) + )] + )] + +#endif + +- + +&F.SIDELIST CNET_CODE_OBJ=iter(%0,##[if(mod(#@,2),:,%b)],,) + +- + +&F.STAMPUSER CNET_CODE_OBJ=if(gt([setr(0,val( +#ifndef SQL_CNET + extract(get(MESSAGE_DATABASE/msg_[get(%#/cnet_mid)]),1,1,|) +#else + GET_MID_DATE([get(%#/cnet_mid)]) +#endif + ))] + ,val([get(ulocal(get_uc_board,%#)/uts_[edit(objid(%#),:,~)])]) + ),ulocal(set_uc_uts,ulocal(get_uc_board,%#),%#,%q0)) + +- +# Board Number 2 dbref + +&F.BN2DBREF CNET_CODE_OBJ= + [squish( + [setq(0,0)] + [iter(lcon(%0),if(cand(elock(##/seeboard,%#),hasattr(##,isboard),not(hastype(##,player))),[setq(0,inc(%q0))][if(eq(%1,%q0),##)]))] + )] + +- +# Fetch Board Name + +&F.BOARDNAME CNET_CODE_OBJ= + [squish( + [iter(revwords(loctree(%0)), + [if(cand(hasattr(##,isboard),not(strmatch(##,TOP_LEVEL_BOARD))), + [squish(before(name(##),Board))].)],,)][before(name(%0),Board)])] + +- + +&F.BOARDSELECTMODE CNET_CODE_OBJ= + [u(set_uc_mode,%#,1)] + [program(%#,me,prog_bsel)] + [pemit(%#,u(disp_main,ulocal(get_uc_board,%#)))] + [prompt(%#,u(prompt))] +- +/@@ + %0 - Message ID + %1 - Board To Delete From + @@/ +&F.DELMSG CNET_CODE_OBJ= +#ifndef SQL_CNET + [if(%1,[set(%1,msg_list:[remove(get(%1/msg_list),%0)])] + [set(MESSAGE_DATABASE,bl_%0:[remove(get(MESSAGE_DATABASE/bl_%0),%1)])] + )] + [if(not(get(MESSAGE_DATABASE/bl_%0)), + [wipe(MESSAGE_DATABASE/bl_%0)] + [wipe(MESSAGE_DATABASE/msg_%0)] +#ifdef FREELIST + [set(MESSAGE_DATABASE,freelist:%0 [get(MESSAGE_DATABASE/freelist)])] +#endif + )] + [u(f.lmsg_check)] +#else /@@ SQL_CNET @@/ + /@@ First Remove The Board From Its Board List @@/ + /@@ If there was only one thing on the board list, remove the entry from the message table @@/ + [setq(B,GET_MID_BL(%0))] + [if(gt(words(%qb),1), + /@@ Just Remove %1 from it @@/ + SET_MID_BL(%0,[remove(%qB,[get(%1/BOARD_PTR)])]) + , + /@@ Delete It @@/ + [sql(delete from messages where id=%0)] + )] +#endif /@@ SQL_CNET @@/ +- + +&F.DLCON CNET_CODE_OBJ=iter(lcon(%0),[if(elock(##/seeboard,%#),## [iter(lcon(##),if(elock(itext(0)/seeboard,%#),[itext(0)] [if(lcon(itext(0)),u(f.dlcon2,itext(0)))]))])]) + +- + +&F.DLCON2 CNET_CODE_OBJ=u(f.dlcon,%0) + +- + +&F.EXPIRE_CHECK CNET_CODE_OBJ=[if( + setr(E,get(%0/Inf_Expire)), + [iter( +#ifndef SQL_CNET + get(%0/msg_list), +#else + MSG_LIST([get(%0/board_ptr)]), +#endif + [if(lt(elements(get(MESSAGE_DATABASE/msg_##),1,|),sub(secs(),mul(86400,%qE))),##)])] + )] + +- + +&F.FINDBOARD CNET_CODE_OBJ=[if(match(get(TOP_LEVEL_BOARD/alias),%1), + setq(0,TOP_LEVEL_BOARD), + [setq(0,TOP_LEVEL_BOARD)] + [iter(%1,switch(u(F.findcontents,%q0,##,%0) + ,#-1,[setq(0,#-1)] + [break()] + ,setq(0,#$) + ) + ,., + )] + )]%q0 + +- + +&F.FINDCONTENTS CNET_CODE_OBJ=[setq(1,squish(iter(lcon(%0),if(elock(##/seeboard,%2),setunion(iter(get(##/alias),[itext(0)]:##, ,|),[squish(before(name(##),Board))]:##,|)), ,|),|))][switch(match(%q1,%1:#?*,|),0,#-1,elements(elements(%q1,#$,|),2,:))] + +- +&F.FINISHPOST CNET_CODE_OBJ= +#ifdef SQL_CNET + /@@ Simply Flip Message to Posted Status @@/ + /@@ Name - ObjId - Subject @@/ + /@@ replace old lost mysql5 function + [sql(call new_post('[sqlescape(%n)]','%:', '[sqlescape(edit(get(%#/cnet_postdata_2),|,))]'))] + @@/ + [sql(INSERT INTO messages (readers,posted,Author,who,subject,FromMUSH) + VALUES ('%:', '1', '[sqlescape(%n)]','%:','[sqlescape(edit(get(%#/cnet_postdata_2),|,))]', + '[sqlescape([mudname()])]') + )] + + [setq(l,sql(select LAST_INSERT_ID()))]/@@ Remember what we just inserted @@/ + /@@ Set Mesage Body @@/ + [SET_MID_BODY(%qL,[edit(get(%#/cnet_postdata_3),|,)])] + [SET_UC_MID(%#,%qL)] +#else /@@ SQL_CNET @@/ + [setq(0,u(f.genmsg))] +# We no longer use the freelist +#ifdef USE_FREELIST + [if(not(%q1),set(MESSAGE_DATABASE,freelist:[remove(get(MESSAGE_DATABASE/freelist),%q0)]))] +#endif /@@ USE_FREELIST @@/ + [SET_UC_MID(%#,%q0)] + [set(MESSAGE_DATABASE, msg_%q0: +/@@ PostDate | Name of Player | Dbref of Player | Subj | Message @@/ + [secs()]|%n|%#|[edit(get(%#/cnet_postdata_2),|,)]|[edit(get(%#/cnet_postdata_3),|,)] + )] + [ulocal(f.lmsg_check)] +#endif /@@ SQL_CNET @@/ +- + +&F.FORMATPERCENT CNET_CODE_OBJ=[switch(%0,>99,%zh%zg,>80,%zg,>50,%zh%zy,>35,%zy,>15,%zh%zr,%zr)]%0%zn%zh%%%zn + +- +#ifndef SQL_CNET +&F.GENMSG CNET_CODE_OBJ= +# We No longer use freelist +#ifdef USE_FREELIST + if(get(MESSAGE_DATABASE/freelist),first(get(MESSAGE_DATABASE/freelist)),setr(1, +#endif /@@ USE_FREELIST @@/ + baseconv(inc(baseconv(get(MESSAGE_DATABASE/lmsg),32,10)),10,32) +#ifdef USE_FREELIST + )) +#endif /@@ USE_FREELIST @@/ + + +- +#endif /@@ SQL_CNET @@/ +&F.ISMODERATOR CNET_CODE_OBJ=or(controls(%1,%0),switch(lock(%0/moderator),*UNLOCKED*,0,elock(%0/moderator,%1))) + +#ifndef SQL_CNET +- +&F.LMSG_CHECK CNET_CODE_OBJ= + [set(MESSAGE_DATABASE,lmsg: + [baseconv( + last(sort(iter(lattr( + MESSAGE_DATABASE/MSG_*),baseconv(after(##,MSG_),32,10)),n)) + ,10,32)] + )] +# No longer using freelist, we should never run out.. Hopefully, :) +#ifdef USE_FREELIST + [iter(setr(0,get(MESSAGE_DATABASE/freelist)), + [if(gte(baseconv(##,32,10),baseconv(get(MESSAGE_DATABASE/lmsg),32,10)),setq(0,remove(%q0,##)))])][set(MESSAGE_DATABASE,freelist:%q0)] +#endif /@@ USE_FREELIST @@/ + +#endif /@@ SQL_CNET @@/ +- + +#endif /@@ __FUNCTIONS__MUSH__ @@/ diff --git a/info.mush b/info.mush new file mode 100644 index 0000000..24ade78 --- /dev/null +++ b/info.mush @@ -0,0 +1,148 @@ +#ifndef _INFO_MUSH_ +#define _INFO_MUSH_ +- + +&F.ISCNETADMIN CNET_CODE_OBJ = gt(level(%0),27) + +- + +&PROG_INFO CNET_CODE_OBJ= + @switch %0=T,{@break [if(POSTS_ALLOWED(setr(1,u(get_uc_board,%#))),0,[pemit(%#,This not a postable board.)]1)]; + @pe %#=Ignore Status Toggled + [if(match(setr(0,get(%q1/ignore)),%#),Off[set(%q1,ignore:[remove(%q0,%#)])],On[set(%q1,ignore:[setunion(%q0,%#)])])].; + @pe %#=ulocal(disp_info,ulocal(get_uc_board,%#))} + ,U,{@program %#=prog_menu; + @pemit %#=ulocal(disp_main,ulocal(get_uc_board,%#)); + @prompt %#=[u(prompt)] + } + ,C,{ /@@ Create new SubBoard @@/ + @assert u(f.ISCNETADMIN,%#) + =@pemit %#=Permission denied; + @program %#=PROG_CREATEBOARD-1; + @prompt %#=Board Name:; + } + ,DB,{/@@ Delete Board @@/ + @pemit %#=Still haven't gotten there.; + } + ,VP,{/@@ View List of Board Ptrs @@/ + @pemit %#=u(disp_boardptrs); + } + ,AP,{/@@ Assign Board Ptr @@/ + @assert u(f.ISCNETADMIN,%#)=@pemit %#=Permission denied.; + @program %#=PROG_ASSIGNPTR; + @prompt %#=What Board Ptr Shall I Assign?; + } + ,Q,th u(f.quit,%#) + ,@pe %#=ulocal(disp_info,ulocal(get_uc_board,%#)) +- +&PROG_ASSIGNPTR CNET_CODE_OBJ + = @assert match(sql(SELECT id FROM boards),%0) + ={ + @pemit %#=Invalid Board Ptr.; + @program %#=PROG_INFO; + @pemit %#=ulocal(disp_info,ulocal(get_uc_board,%#)); + }; + &board_ptr ulocal(get_uc_board,%#) = %0; + /@@ Check And See If this board is registered to be on this MUSH or not.. @@/ + th if( + sql(select COUNT(board) from mushes WHERE board = %0 and mush = "[mudname()]") + ,/@@ It is.. Do nothing @@/ + ,/@@ Otherwise.. insert it @@/ + sql(INSERT INTO mushes (mush, board) VALUES ("[sqlescape(mudname())]", %0)) + ); + + @pemit %#=Assigned Board Ptr; + @program %#=PROG_INFO; + @pemit %#=ulocal(disp_info,ulocal(get_uc_board,%#)); +- +&PROG_CREATEBOARD-1 CNET_CODE_OBJ + = + @break gt(strlen(%0),32) + = @pemit %# = Too long.. Try shorter.; + think setq(Z,create(%0)); + think setq(A,1); + @tel %qZ=ulocal(get_uc_board,%#); + @program %#=PROG_CREATEBOARD-2; + @prompt %#=Assign a custom Pointer(QZ is %qZ, Qa is %qA)? (y/n) +- +&PROG_CREATEBOARD-2 CNET_CODE_OBJ + = + @pemit %#=QZ is %qZ. QA is %qA; + @break strmatch(%0,Y) + = { + @program %# = PROG_CREATEBOARD-3; + @prompt %# = Assign what pointer? + }; + @sql INSERT INTO boards (name) VALUES ('[sqlescape([name(%qZ)])]'); + @fo me=&board_ptr %qZ = [sql(select LAST_INSERT_ID())]; + @sql INSERT INTO mushes (mush, board) VALUES("[mudname()]", LAST_INSERT_ID()); + &isboard %qZ = 1; + @pemit %#=Assigned Board Ptr(%qZ)... Returning to Info screen.; + @program %#=prog_info; + @pemit %#=u(disp_info,ulocal(get_uc_board,%#)); +- +&PROG_CREATEBOARD-3 CNET_CODE_OBJ + = + @select %0=VP,{ + @pemit %#=u(disp_boardptrs); + @prompt %#=Assign what pointer now? + @break 1; + } + ,A,{ + @program %#=prog_createboard-4; + @prompt %#=Assign a custom Poitner (y/n); + @break 1; + }; + @assert match(sql(SELECT id FROM boards),%0) + ={ + @pemit %#=Invalid Board Ptr. Type VP to see a list of pointers, or A for abort.; + }; + &board_ptr %qZ = %0; + &isboard %qZ = 1; + th if( + sql(select COUNT(board) from mushes WHERE board = %0 and mush = "[mudname()]") + ,/@@ It is.. Do nothing @@/ + ,/@@ Otherwise.. insert it @@/ + sql(INSERT INTO mushes (mush, board) VALUES ("[sqlescape(mudname())]", %0)) + ); + @pemit %#=Assigned Board Ptr... Returning to Info screen.; + @program %#=prog_info; + @pemit %#=u(disp_info,ulocal(get_uc_board,%#)); +- +&DISP_INFO CNET_CODE_OBJ= + %zh%zb[center(%zc[u(f.boardname,%0)] Info[if(cansee(%#,%0),%zh%zy(%zn%zc%0[flags(%0)]%zh%zy))]%zb,79,-)]%zn%r + Owner: [name(owner(%0))][if(cansee(%#,owner(%0)),\([owner(%0)][flags(owner(%0))]\))]%r + [if(cansee(%#,%0), + Board Ptr: [get(%0/board_ptr)]%r + )] + [if(get(%0/alias),Board Aliases: [get(%0/alias)]%r)] + [if(hasattrp(%0,INFO), + [objeval(%0,eval(%0,info))] + %r + )] + [switch(get(%0/inf_expire), + /@@ If there is Nothing do nothing @@/ + ,, + /@@ Default @@/ + Messages on this board expire after #$ days.%r + )] + [if(match(get(%0/ignore),%#),Currently ignoring new message notifications on this board.%r)] + [center( + [if(POSTS_ALLOWED(%0),[u(f.CmdLabel,T,oggle Ignore)]%b)] + [u(f.CmdLabel,U,p)] [u(f.CmdLabel,Q,uit)] + ,79)] + %r%zh%zb[repeat(-,79)]%zn + +- +#ifdef SQL_CNET +&DISP_BOARDPTRS CNET_CODE_OBJ + = + %zh%zb[center(%zc[u(f.boardname,%0)] Info[if(cansee(%#,%0),%zh%zy(%zn%zc%0[flags(%0)]%zh%zy))]%zb,79,-)]%zn%r + [ansi(hw,[ljust(id,5)][ljust(Board Name,30)][ljust(PA,5)][ljust(PUB,5)])]%r + [iter(sql(SELECT * from boards,~,|), + [ljust(elements(##,1,|),5)][ljust(elements(##,2,|),30)][ljust(elements(##,3,|),5)][ljust(elements(##,4,|),5)] + ,~,%r)] + %r%zh%zb[repeat(-,79)]%zn +#endif + +#endif /@@ _INFO_MUSH_ @@/ diff --git a/jobcode.mush b/jobcode.mush new file mode 100644 index 0000000..6542beb --- /dev/null +++ b/jobcode.mush @@ -0,0 +1,553 @@ +#ifndef __JOBCODE_MUSH__ +#define __JOBCODE_MUSH__ +#include "config.minc" +#include "macros.minc" + +/@@ Locks on Boards for Jobs: + ------------------------------------------------------ + CanJStatus - Who can use set job status menu + CanVWork - Who can view Work History + @@/ + +#define USE_ADAMS_UNFORMAT /@@ Incase We are being called directly @@/ + +/@@ The Job code thats been in work for a long long time, not sure when its going to be completed *sigh* @@/ + +#ifdef JOBCODE +- + +/@@ I hate the display ones.. they're so hard to make look right in the file @@/ +&DISP_JOB CNET_CODE_OBJ= + %r%zh%zb[center(%zc[elements(get(JOB_DATABASE/j1_%0),1,|)]%zh%zb,79,-)]%zn%r + Initiator: [u(f.padstr,[name(elements(elements(get(JOB_DATABASE/j3_%0),1,|),3,:))],23)] + [center(~~~,10)][rjust(Priority:,15)] [elements(get(JOB_DATABASE/j1_%0),2,|)]%r + Initiate Date: [u(f.padstr, + [timefmt($d$b$y,[elements(elements(get(JOB_DATABASE/j3_%0),1,|),2,:)])] + ,19)] + [center(~~~,10)] + [rjust(Status:,15)] [u(f.jstat,%0)]%r + Due Date: [u(f.padstr,[ulocal(f.duedate,elements(get(JOB_DATABASE/j1_%0),3,|))],24)] + [center(~~~,10)][rjust(Handler:,15)] [ulocal(f.jobhandler,%0)]%r + [u(f.jstime,%0)]%zh%zw%zuDescription%zn%zh:%zn%r + [elements(get(JOB_DATABASE/j1_%0),4,|)]%r + [if(get(JOB_DATABASE/j2_%0),%zh%zuComments%zn%zh:%zn%r + [iter(get(JOB_DATABASE/j2_%0),%t\[ [name(elements(##,2,:))] on [timefmt($d$b$y $H:$M:$S,[elements(##,1,:)])]%b\]%r + [rest(rest(##,:),:)],|,%r)])]%zn%r + [ansi(hb,repeat(-,79))]%r + [center([if(elock(u(get_uc_board,%#)/CanVWork,%#), + [u(f.CmdLabel,W,ork history)]%b + )] + [if(elock(u(get_uc_board,%#)/CanJStatus,%#), + [u(f.CmdLabel,S,tatus Menu)]%b + )] + /@@ TODO: Add Check for if they can add a comment or not to show this or not @@/ + [u(f.CmdLabel,C,omment)] + [u(f.CmdLabel,U,p)] + [u(f.CmdLabel,Q,uit)] + ,79)] + %r%zh%zb[repeat(-,79)]%zn + +- +&DISP_PREVJOB CNET_CODE_OBJ= + %r%zh%zb[center(%zc[GET_UC_PD(%#,2)]%zh%zb,79,-)]%zn%r + Initiator: [u(f.padstr,[name(%#)],23)] + [center(~~~,10)][rjust(Priority:,15)] Normal%r + Initiate Date: [u(f.padstr, + [timefmt($d$b$y,secs())] + ,19)] + [center(~~~,10)] + [rjust(Status:,15)] NEW%r + Due Date: [u(f.padstr,[ulocal(f.duedate,get(%#/cnet_duedate))],24)] + [center(~~~,10)]%r + %zh%zw%zuDescription%zn%zh:%zn%r + [if(%0, + /@@ Check If its a Call from Cex, if so. Show Lines @@/ + [setq(w,words(GET_UC_PD(%#,3),%r))] + [iter([GET_UC_PD(%#,3)],[if(cor(nor(%1,%2), + cand(gte(#@,%0),lte(#@,%2)) + ), + [rjust(#@,3,0)]: ## + /@@ Don't give newline on last last @@/ + [if(neq(#@,%qw),%r)] + )] + ,%r,)] + ,[GET_UC_PD(%#,3)] + )]%r + %zh%zb[repeat(-,79)]%zn +- + +&DISP_JOBHISTORY CNET_CODE_OBJ= + %zh%zb[repeat(-,79)]%zn%r + [center(%zh%zcWork History %zh%zb-%zh%zc [elements(get(JOB_DATABASE/j1_%0),1,|)]%zb,79)]%zn%r + [ansi(hb,repeat(-,79))]%r + %zn%zh%zc[ljust(Handler,16)]%zb|%zh%zc [ljust(Status,14)]%zb|%zh%zc [ljust(Date,19)]%zb|%zh%zc Details%zn%r + %zh%zb[repeat(-,79)]%zn%r + [iter(setr(H,get(JOB_DATABASE/j3_%0)), + %zc[ljust(left(name(elements(##,3,:)),16),16)][ansi(hb,|)]%zc + [ljust(left( + switch(elements(##,1,:) + ,C,Created + ,P,Pending + ,IW,In Progress + ,OW,On Hold + ,D,Deferred + ,JC,Completed + ,#$ + ) + ,14) + ,14)] + [ansi(hb,|)]%zc [ljust(left(timefmt($d$b$y $H:$M:$S,elements(##,2,:)),19),19)][ansi(hb,|)]%zc + [squish( + switch(elements(##,1,:) + ,D,Claimed + ,OW,[u(f.formatpercent,elements(##,4,:))]%zc complete%zn + ,C,Unclaimed for [timestring(sub([if(eq(words(%qH,|),#@),secs(),elements(elements(%qH,inc(#@),|),2,:))], + elements(##,2,:) + ))] + ,IW,In work for [timestring(sub([if(eq(words(%qH,|),#@),secs(),elements(elements(%qH,inc(#@),|),2,:))], + elements(##,2,:)))] + ) + )] + ,|,%r)] + %zh%zb%r[repeat(-,79)]%zn + +- +&DISP_JSTATUSMENU CNET_CODE_OBJ= + %zh%zb[center(%zh%zcJob Status Menu%zh%zb,79,-)]%zn%r + Job: [ljust([elements(u(get_uc_j1,%0),1,|)],40)]Job Status: [u(f.jstat,%0)]([elements(last(%q0,|),1,:)])%r + [table( + /@@ | Is the seperator for the table @@/ + [ansi(hy,Code)] %zr~%zh%zy Description%zn| + [ansi(hy,Code)] %zr~%zh%zy Description%zn| + %b%b + IW ~ Set the Job In Work| + %b%b + P + %b%b~ Set the Job in Pending Status| + %b%b + OW ~ Take Job out of Work| + %b%b + D %b~ Set Job in Deferred Status| + %b%b + JC ~ Completed Job + ,38,79,|)]%r + [center(ansi(y,Type job code to set Job Status.),79)]%r + [ansi(hb,repeat(-,79))]%r + [center([u(f.CmdLabel,U,p)] [u(f.CmdLabel,Q,uit)],79)]%r + %zh%zb[repeat(-,79)]%zn +- +/@@ + Convert mm/dd/yyyy date format to conventional + e.g. Sat Dec 17 00:00:00 2005 + + %0 - Month + %1 - day + %2 - Year + @@/ +&F.CONVDUEDATE CNET_CODE_OBJ= + convtime( + /@@ Decode Month @@/ + [switch(%0,1,Jan + ,2,Feb + ,3,Mar + ,4,Apr + ,5,May + ,6,Jun + ,7,Jul + ,8,Aug + ,9,Sep + ,10,Oct + ,11,Nov + ,12,Dec + )] + /@@ Day Number @@/ + %1 + /@@ Time, put it at the beginning of the day @@/ + 00:00:00 + /@@ Year @@/ + %2 + ) +- +/@@ delete job from boards + + %0 - Job Id + %1 - Boards To delete Job From + @@/ +&F.DELJOB CNET_CODE_OBJ= + [if(%1,[set(%1,job_list:[remove(get(%1/job_list),%0)])] + [set(JOB_DATABASE,bl_%0:[remove(get(JOB_DATABASE/bl_%0),%1)])] + )] + [if(not(get(JOB_DATABASE/bl_%0)), + [wipe(JOB_DATABASE/bl_%0)] + [wipe(JOB_DATABASE/j?_%0)] + )] + [u(f.ljob_check)] + +- +&F.DUEDATE CNET_CODE_OBJ= + switch(%0 + ,,None Set, + [switch(sub(%0,secs()),<0,[setq(C,r)],<616251,[setq(c,y)])] + [timefmt([ansi(%qC,$m)]%zh%zy/%zn[ansi(%qC,$d)]%zh%zy/%zn[ansi(%qC,$y)],%0)] + ) + +- +&F.PADSTR CNET_CODE_OBJ=[switch(%2,center,center(mid({%0},0,%1),%1,%3),right,rjust(mid({%0},0,%1),%1,%3),ljust(mid({%0},0,%1),%1,%3))] + +- +&F.GENJOB CNET_CODE_OBJ=baseconv(inc(baseconv(get(JOB_DATABASE/ljob),32,10)),10,32) + +- + +&F.JOBHANDLER CNET_CODE_OBJ=switch(words(setr(0,get(JOB_DATABASE/j3_%0)),|),1,UnAssigned,[name([elements([elements(%q0,#$,|)],3,:)])]) +- +/@@ Return Last Known Job Percent @@/ +&F.LASTJPERC CNET_CODE_OBJ=[val(squish(iter(revwords(get(JOB_DATABASE/J3_%0),|), + [switch(elements(##,4,:) + ,,/@@ Nothing @@/ + ,/@@ Return and break @@/ + #$[break()] + )] + ,|)))] + +- +/@@ %0 - Job Id + @@/ + +&F.JSTAT CNET_CODE_OBJ= + [if(eq(words(get(JOB_DATABASE/j3_%0),|),1), + NEW, + [switch([elements(setr(0,last(get(JOB_DATABASE/j3_%0),|)),1,:)] + ,IW,ansi(g,In Progress) /@@ Soemone has it In Work @@/ + ,OW,[ansi(y,On Hold)] [u(f.formatpercent,elements(%q0,4,:))] + ,JC,ansi(hg,Job Completed) + ,P,[ansi(r,Pending)] /@@ Waiting to be claimed @@/ + ,C,[ansi(hy,Created)] + ,D,[ansi(hr,Deferred)] /@@ Job Deferred for some reason or another@@/ + ,#$ + )] + )] +- + +&F.JSTIME CNET_CODE_OBJ= + [if(words(setr(0,get(JOB_DATABASE/j3_%0)),|), + [switch(elements(last(%q0,|),1,:) + ,IW,In Work For: [timestring(sub(secs(),elements(last(%q0,|),2,:)))]%r + ,OW,Last Worked Date: [timefmt($d$b$y,elements(last(%q0,|),2,:))]%r + )] + )] + +- + +&F.LJOB_CHECK CNET_CODE_OBJ= + [set(JOB_DATABASE,ljob:[baseconv(last(sort(iter(lattr(JOB_DATABASE/J1_*),baseconv(after(##,J1_),32,10)),n)),10,32)])] +- +/@@ + ** Update Job Status ** + %0 - Job Id + %1 - Dbref of Player + %2 Job Status + %3 - Optional Percent + Job Stats in format of |STAT:TIMESTAMP:OWNER:PERC| + @@/ + +&F.UPDATE_JSTATUS CNET_CODE_OBJ =[set(JOB_DATABASE, + J3_%0: + [squish( + [get(JOB_DATABASE/J3_%0)]| + %2:[secs()]:%1:%3 + ,| + )] + )] + +- + +&PROG_JSTAT CNET_CODE_OBJ= + + @switch %0= + Q,th u(f.quit,%#) + ,D,{/@@ Delete @@/ + think u(f.deljob,ulocal(get_uc_jid,%#),ulocal(get_uc_board,%#)); + @program %#=prog_menu; + @pemit %#=ulocal(disp_main,ulocal(get_uc_board,%#)); + @prompt %#=u(prompt); + } + ,U,{ /@@ Up @@/ + @program %#=prog_menu; + @pemit %#=ulocal(disp_main,ulocal(get_uc_board,%#)); + @prompt %#=[u(prompt)] + } + ,W,{ /@@ Work History @@/ + @pemit %#=u(disp_jobhistory,u(get_uc_jid,%#)) + } + ,S,{ /@@ Set a Job Status @@/ + @program %#=prog_jstatusmenu; + @pemit %#=ulocal(disp_jstatusmenu,ulocal(get_uc_jid,%#)); + @prompt %#=[u(prompt)] + } + ,C,{ /@@ Post a Comment - Job Must be In Work to use this @@/ + @assert strmatch(first(last(get(JOB_DATABASE/j3_[ulocal(get_uc_jid,%#)]),|),:),IW) + ={ + @pemit %#=Job must be in work before you can add a comment.; + @prompt %#=[u(prompt)]; + }; + @program %#=prog_job_comment; + @pemit %#=Type Job Comment, may be no longer than 79 characters.; + @prompt %#; + }, + /@@ default: @@/ + @pemit %#=%zrInvalid Job Menu Command.%zn + +- + +&PROG_JSTATUSMENU CNET_CODE_OBJ= + @select %0 = + IW,{/@@ Put In Work @@/ + think [ulocal(f.UPDATE_JSTATUS,ulocal(get_uc_jid,%#),%#,IW)]; + @pemit %#=Job placed in work.; + } + ,JC,{ /@@ Job Complete @@/ + think [ulocal(f.UPDATE_JSTATUS,ulocal(get_uc_jid,%#),%#,JC)]; + /@@ TODO: Further shit on JCs.. Like mandatory comment or something @@/ + @pemit %#=Job completed.; + } + ,OW,{ + @program %#=prog_ow-1; + @prompt %#=Enter Percent Complete: + } + ,P,{ /@@ Set Pending Status @@/ + think [ulocal(f.UPDATE_JSTATUS,ulocal(get_uc_jid,%#),%#,P)]; + @pemit %#=Job set in pending status.; + } + ,C,{ /@@ Claim an unclaimed job @@/ + @pemit %#=TODO; + } + ,D,{ /@@ Put Job in Deferred Status @@/ + @pemit %#=TODO; + } + ,U,{ + @program %#=prog_jstat; + @pemit %#=u(disp_job,u(get_uc_jid,%#)); + @prompt %#=u(prompt); + } + ,Q, /@@ Quit CobraNet @@/ + th u(f.quit,%#) + +- +/@@ %qJ - Job Id + %qm - Min Requird Job Percent + @@/ + +&PROG_OW-1 CNET_CODE_OBJ= + think [setq(J,ulocal(get_uc_jid,%#))]; + @assert isnum(%0)={ + @pemit %#=Must be in number form without the percent sign.; + @prompt %#=Enter Percent Complete: + }; + @assert cand(gte(%0,setr(m,u(f.lastjperc,%qJ))),lt(%0,100)) + ={ + @pemit %#=Number must between %qM-99.; + @prompt %#=Enter Percent Complete: + }; + think [ulocal(f.UPDATE_JSTATUS,%qJ,%#,OW,%0)]; + @program %#=prog_ow-2; + @prompt %#=Would you like to add a Comment? (Y/N); + + +- + +&PROG_OW-2 CNET_CODE_OBJ= + @switch %0= + Y,{ + /@@ Pass them Through the comment Program @@/ + @program %#=prog_job_comment; + @pemit %#=Type Job Comment, may not be no longer than 79 characters.; + @prompt %#; + } + ,N,{ /@@ Now Return them 'PROG_JSTAT' and display 'DISP_JOB' @@/ + @program %#=PROG_JSTAT; + @pemit %#=u(disp_job,u(get_uc_jid,%#)); + @prompt %#=[u(prompt)]; + } + ,@prompt %#=Invalid Answer. Would you like to add a comment? (Y/N); + +- +/@@ Insert Comment And move 'em back to PROG_JSTAT + truncate to 79 characters + %0 - Comment String + %q0 - Job Id + + Note: J2_* Is the comment section in the job database + @@/ + +&PROG_JOB_COMMENT CNET_CODE_OBJ = + @set JOB_DATABASE= + J2_[setr(0,u(get_uc_jid,%#))]:[squish([get(JOB_DATABASE/J2_%q0)]| + [secs()]:%#: + /@@ Make sure there is no |s in the string and truncate @@/ + [setr(S, + [left(edit(%0,|,),79)] + )] + ,|)]; + @pemit %#=Added comment: %qS; + /@@ Now throw them make to the job view @@/ + @program %#=PROG_JSTAT; + @pemit %#=u(disp_job,u(get_uc_jid,%#)); + @prompt %#=[u(prompt)]; +- +&PROG_CREATEJOB-1 CNET_CODE_OBJ= + @set %#=CNET_POSTDATA_1:1;/@@ This isn't really used much until after the message @@/ + @set %#=CNET_POSTDATA_2:%0; + @set %#=CNET_POSTDATA_6:1; + @program %#=prog_createjob-2; + @prompt %#=Enter Due Date: + +- +&PROG_CREATEJOB-2 CNET_CODE_OBJ= +/@@ Check That its a valid Due Date format given is mm/dd/yy @@/ + @break strmatch(%0,None)={ + @set %#=CNET_DUEDATE:None; + @pemit %#=%zcType description of job line by line. Type '%zy%zh.%zn%zc' on a line by itself to finish.%zn; + @program %#=prog_createjob-3; + @prompt %#; + } + @assert [regmatch(%0,(\\d+)/(\\d+)/(\\d+),0 m d y)]={ + @pemit %#=Invalid due date format. Must be in mm/dd/yyyy; + @prompt %#=Enter Due Date: + }; + @assert [gt(setr(t,u(F.ConvDueDate,%qm,%qD,%qy)), + secs() + )]={ + @pemit %#=Due Date Must be in the future; + @prompt %#=Enter Due Date: + }; + @set %#=CNET_DUEDATE:%qT; + @pemit %#=%zcType description of job line by line. Type '%zy%zh.%zn%zc' on a line by itself to finish.%zn; + @program %#=prog_createjob-3; + @prompt %#; +- +&PROG_CREATEJOB-3 CNET_CODE_OBJ= + @break [strmatch(%0,:*)]=th u(Cmd_Cex,after(%0,:)); + think [switch(%0, +/@@ If Its a Period end the posting nonsense @@/ + ., + [program(%#,me,prog_createjob-4)] + [if(gt(words(GET_UC_PD(%#,3),%r),10), + [SET_UC_PD(%#,1,2)] + [pemit(%#,Message is too long\, the server can either truncate it for you or you can edit it yourself.)] + [prompt(%#,Truncate? \(Y/N\))] + , + [SET_UC_PD(%#,1,3)] + [pemit(%#,%zcWould you like to post this job?%zn [u(f.CmdLabel,Y,es)] + [u(f.CmdLabel,N,o)] + [u(f.CmdLabel,P,roof Read)] + [u(f.CmdLabel,E,dit)] + )] + [prompt(%#,u(prompt))] + )] + ,/@@ Default @@/ + /@@ Add to Post @@/ + [set(%#,cnet_postdata_3: + [if(setr(0,GET_UC_PD(%#,3)), + [if(GET_UC_PD(%#,5), + [insert(%q0,GET_UC_PD(%#,5),%0,%r)] + /@@ Then Advance the Line Number @@/ + [set(%#,cnet_postdata_5:[inc(GET_UC_PD(%#,5))])] + ,%q0%r%0 + )] + ,%0 + )] + )] + /@@ Message Writer > Prompt @@/ + [prompt(%#)] + )] +- +&PROG_CREATEJOB-4 CNET_CODE_OBJ= + @break eq(GET_UC_PD(%#,1),2)= + { + think switch(%0 + ,Y,/@@ Grab first 10 lines, toss the rest @@/ + [set(%#,cnet_postdata_3:[extract(GET_UC_PD(%#,3),1,10,%r)])] + [SET_UC_PD(%#,1,3)] + ,N,/@@ Return to Edit Mode @@/ + [SET_UC_PD(%#,1,1)] + [program(%#,%!,PROG_CREATEJOB-3)] + [pemit(%#,Returning to Edit Mode.)] + [prompt(%#)] + , + [prompt(%#,Invalid Answer. Enter a Yes or a No. \(Y/N\)?)] + ) + }; + @switch %0=Y, + { + /@@ We should be done with everyone.. So Lets make this into a real job. @@/ + @set JOB_DATABASE=J1_[setr(J,u(f.genjob))]: + [GET_UC_PD(%#,2)]|/@@ Title @@/ + Normal| + [get(%#/CNET_DUEDATE)]|/@@ Due Date @@/ + [GET_UC_PD(%#,3)];/@@ Job Description @@/ + think [u(f.ljob_check)];/@@ Update Ljob @@/ + @set JOB_DATABASE=J3_%qJ:C:[secs()]:%#:; + @set setr(b,ulocal(get_uc_board,%#))=JOB_LIST:[get(%qb/JOB_LIST)] %qJ; + /@@ Now Wipe Cnet Post Data Off of Them @@/ + @wipe %#/Cnet_PostData_*; + @wipe %#/cnet_DueDate; + @pemit %#=u(disp_main,ulocal(get_uc_board,%#)); + @program %#=prog_menu; + @prompt %#=u(prompt); + }, + N,{/@@ Toss the Job and return them to the main board @@/ + @wipe %#/cnet_postdata_*; + @pemit %#=%zrJob Aborted.%zn; + @pemit %#=u(disp_main,ulocal(get_uc_board,%#)); + @program %#=prog_menu; + @prompt %#=u(prompt); + }, + P,{/@@ Proof Read Job @@/ + @pemit %#=u(disp_prevjob); /@@ Prev Job By Cnet_postData sets @@/ + @pemit %#=%zcWould you like to post this job?%zn [u(f.CmdLabel,Y,es)] + [u(f.CmdLabel,N,o)] + [u(f.CmdLabel,P,roof Read)] + [u(f.CmdLabel,E,dit)]; + @prompt %#=u(prompt); + }, + E,{/@@ Return to edit mode, edit job @@/ + think [SET_UC_PD(%#,1,1)]; + @program %#=prog_createjob-3; + @pemit %#=Returning to Edit Mode.; + @prompt %#; + } + ,{/@@ Default, Invalid Command @@/ + @pemit %#=Invalid CobraNet Command.; + @pemit %#=%zcWould you like to post this job?%zn [u(f.CmdLabel,Y,es)] + [u(f.CmdLabel,N,o)] + [u(f.CmdLabel,P,roof Read)] + [u(f.CmdLabel,E,dit)]; + @prompt %#=u(prompt); + } + + +- + +&MI_JOBS CNET_CODE_OBJ= + %r + [ansi(hu, + [ljust(#,5)][ljust(Title,21)][ljust(Initiator,14)][ljust(Handler,14)][ljust(Due Date,11)][ljust(Status,14)])]%r + [iter(get(%0/job_list), + /@@ Job # - Job Title @@/ + [ljust(J#@,5)][ljust([elements(get(JOB_DATABASE/j1_##),1,|)],21)] + /@@ Initiator @@/ + [ljust([name(elements(first(get(JOB_DATABASE/j3_##),|),3,:))],14)] + /@@ Handler @@/ + [ljust([u(f.JobHandler,##)],14)] + /@@ Due Date @@/ + [ljust([u(f.duedate,elements(get(JOB_DATABASE/j1_##),3,|))],11)] + /@@ Status @@/ + [u(f.jstat,##)] + ,,%r)] + %r + +- +#endif /@@ JOBCODE @@/ + +#endif /@@ __JOBCODE_MUSH__ @@/ diff --git a/macros.minc b/macros.minc new file mode 100644 index 0000000..329619c --- /dev/null +++ b/macros.minc @@ -0,0 +1,31 @@ +#ifndef __MACROS_MINC__ +#define __MACROS_MINC__ +/@@ Macros File @@/ + +#define GET_UC_MID(PLAYER) get(PLAYER/cnet_mid) +#define GET_UC_MODE(PLAYER) extract(get(PLAYER/cnet_info),1,1) +#define GET_UC_PAGE(PLAYER) get(PLAYER/cnet_page) + +#define GET_UC_PD(PLAYER,PDATANUM) get(PLAYER/cnet_postdata_PDATANUM) +#define SET_UC_PD(PLAYER,PDATANUM,DATA) set(PLAYER,cnet_postdata_PDATANUM:DATA) +#define GET_MID_BODY(MESSAGE_ID) rest(rest(rest(rest(get(MESSAGE_DATABASE/msg_MESSAGE_ID),|),|),|),|) +#define GET_UC_UTS(BOARD,PLAYER) get(BOARD/uts_[edit([objid(PLAYER)],:,~)]) + +#define SET_UC_MID(PLAYER, MESSAGE_ID) set(PLAYER, cnet_mid:MESSAGE_ID) + + +#define PRE_INPUT @set me=!quiet +#define POST_INPUT @set me=!quiet + +/@@ CNET_POST_DATA - Info + _1 -> Step In Posting + _2 -> Subject + _3 -> Message + _4 -> Board Posting To + _5 -> If located in another spot in the editing. It will be filled in here + _6 -> If This is set, we are doing a Job Post + @@/ + +#include "sql.minc" + +#endif /@@ __MACROS_MINC__ @@/ diff --git a/mainmenu.mush b/mainmenu.mush new file mode 100644 index 0000000..72ba3c4 --- /dev/null +++ b/mainmenu.mush @@ -0,0 +1,315 @@ +- +# +# This seems to spawn the most function invocation.. +# Suspected the newto messages is it, must find a way to reduce. +# + +&DISP_MAIN CNET_CODE_OBJ= + [setq(0,ulocal(f.sidelist,iter(lcon(%0),if(cand(elock(##/seeboard,%#),hasattr(##,isboard)),##))))] + %zh%zb + [center(%zc[u(f.boardname,%0)]%zh%zb,79,-)]%zn +# Show Description of board + [if(hasattrp(%0,describe),%r[objeval(ulocal(get_uc_board,%#),eval(%0,describe))]%r +# Only Give this line if subboards exists and they can see 'em + %zb[repeat(-,79)]%zn%r,if(%q0,%r))] +# Show Sub Boards + [iter(%q0, + [ljust(%zb%zh[ljust([dec(mul(#@,2))]%zn%zb.,4)]%zn%zc[squish(before(name(setr(1,before(##,:))),Board))]%zb + [if(cand(eq(GET_UC_MODE(%#),0),setr(2,ulocal(f.newto_tot,%q1))),\(%q2 new messages\))]%zn, + 44)] + [if(after(##,:),[ljust(%zh%zb[mul(#@,2)]%zn%zb.,4)]%zc[squish(before(name(setr(1,after(##,:))),Board))]%zb[if(cand(eq(GET_UC_MODE(%#),0),setr(2,ulocal(f.newto_tot,%q1))),\(%q2 new messages\))])] + %zn + ,,%r)] +# Show Messages If in UC_MODE 0 + [switch(GET_UC_MODE(%#) + /@@ Main Menu @@/ + ,0,u(mi_main,%0) + /@@ Board Toggling in Interactive Mode @@/ + ,1,ulocal(mi_mp,%0))] + %r%zh%zb[repeat(-,79)]%zn + +- + +&DISP_MSGLIST CNET_CODE_OBJ= + [ljust( + %zh%zyPage [GET_UC_PAGE(%0)]/[if(mod(setr(4,words( +#ifndef SQL_CNET + setr(m,get([setr(0,ulocal(get_uc_board,%0))]/msg_list)) +#else + setr(m,MSG_LIST([setr(p,get(ulocal(get_uc_board,%0)/board_ptr))])) +#endif + )),10), + inc(div(%q4,10)), + div(%q4,10) + )] + ,15 + )]%zn + [if(lt([GET_UC_PAGE(%#)],ulocal(f.maxpages,ulocal(get_uc_board,%#))), + %zr<%zh%zyN%zn%zr>%zn%zyext + )] + [if(gt(GET_UC_PAGE(%#),1), + %b%zr<%zh%zyL%zn%zr>%zyast + )]%zn%r +#ifndef SQL_CNET + [iter(ulocal(f.page, + revwords(%qM),GET_UC_PAGE(%0),10), + [ansi( + if(and( + gt(val(ulocal(f.msgdate,##)),val(GET_UC_UTS(%q0,%#))), + not(strmatch(ulocal(f.msgowner,##),%#)) + ) + ,hw + ,c + ), + [ljust(M[add(mul(10,dec(GET_UC_PAGE(%0))),#@)].,5)] + [ljust(left(extract(setr(1,get(MESSAGE_DATABASE/msg_##)),2,1,|),15),15)] - [ljust(left(if(setr(3,extract(%q1,4,1,|)) + ,%q3,(No Subject)),45),45 + )]- [timefmt($d$b$y,extract(%q1,1,1,|))])] + ,,%r)]%r%zh%zb +#else /@@ SQL_CNET @@/ + [iter( + {[sql({ + select id, DATE_FORMAT(date, '\%d\%b\%y'), Author, subject from messages + where boards regexp "(^%qP$|^(.*) %qP$|^%qP (.*)$)" and posted=1 + ORDER BY date LIMIT [u(f.pagestart,GET_UC_PAGE(%0),10)],10 + },|,~)]}, + [ansi( + if(not(GET_READ_STATUS([first({##},~)],%:)) + ,hw + ,c + ), + [ljust(M[add(mul(10,dec(GET_UC_PAGE(%0))),#@)].,5)] + [ljust(left(elements({##},3,~),15),15)] - [ljust(left(if(setr(3,rest(rest(rest({##},~),~),~)) + ,{%q3},(No Subject)),45),45 + )]- [elements({##},2,~)])] + ,|,%r)]%r%zh%zb + +#endif /@@ SQL_CNET @@/ + [repeat(-,79)]%zn%r + +- + +&CMD_SEL CNET_CODE_OBJ=[if(setr(0,[ulocal(f.bn2dbref,ulocal(get_uc_board,%0),%1)]), + [u(set_uc_board,%0,%q0)] + [u(set_uc_page,%#,ulocal(f.selectpage,%q0,%#))] + )] + [pemit(%0,ulocal(disp_main,ulocal(get_uc_board,%0)))] + [prompt(%#,u(prompt))] +- + +&PROG_MENU CNET_CODE_OBJ= + @break strmatch(%0,Q)=think u(f.quit,%#); + @select %0= +# Goto Next Page of Messages + N, + { + th [if(lte( + setr(0,[inc(GET_UC_PAGE(%#))]), + /@@ <= @@/ + ulocal(f.maxpages,ulocal(get_uc_board,%#)) + ) + ,[set(%#,cnet_page:%q0)] + )] + [pemit(%#,ulocal(disp_main,ulocal(get_uc_board,%#)))] + [prompt(%#,u(prompt))] + } +# Goto Last Page of Messages + ,L, + th [if(gt(setr(0,GET_UC_PAGE(%#)),1),set(%#,cnet_page:[dec(%q0)]))] + [pemit(%#,ulocal(disp_main,ulocal(get_uc_board,%#)))] + [prompt(%#,u(prompt))] +# Jump Prompt loader + ,J, + { + @pemit %#=[u(disp_jump)]; + @program %#=prog_jump; + @prompt %#=[u(prompt)] + } +# one line jump shortcut.. e.g. jdev.cobramush +# If Jobcode is enabled will also check to see if its a valid job your trying to view. + ,J*, + { +#ifdef JOBCODE +/@@ %q0 -> Job # @@/ + @break + [if( + cand(get(ulocal(get_uc_board,%#)/isjboard),isnum(setr(0,after(capstr(%0),J)))), + /@@ This is a possible Job Request View @@/ + [if( + cor( + not(elock(u(get_uc_board,%#)/canread,%#)) + ,gt(%q0,words(get(ulocal(get_uc_board,%#)/job_list))) + ,lt(%q0,1),not(isnum(%q0)) + ) + ,1 + [pemit(%#,Invalid Selection.)] + [prompt(%#,u(prompt))] + ,0 + )] + , +#else /@@ JOBCODE @@/ + think +#endif /@@ JOBCODE @@/ + [u(f.quickjump,after(ucstr(%0),J))] +#ifdef JOBCODE + 1 + )]; + @prog %#=prog_jstat; + th [set(%#,cnet_jid:[elements(get(ulocal(get_uc_board,%#)/job_list),%q0)])] + [pemit(%#,ulocal(disp_job,u(get_uc_jid,%#)))]; + @prompt %#=[u(prompt)] +#endif /@@ JOBCODE @@/ + } +#ifdef JOBCODE + ,CJ,{ + /@@ Create Job @@/ + @program %#=Prog_CreateJob-1; + @prompt %#=Job Title: + } +#endif /@@ JOBCODE @@/ +# Board Info + ,I, + { + @pemit %#=ulocal(disp_info,ulocal(get_uc_board,%#)); + @program %#=prog_info; + @prompt %#=[u(prompt)] + } +# Go Up in the Menu + ,U*, + th ulocal(cmd_up,%#) +#ifdef SQL_CNET + ,T,{ + /@@ Tag All Messages Read On this board for the user @@/ + think setq(P,get(u(get_uc_board,%#)/board_ptr)); + @sql update messages set date=date, readers=CONCAT(messages.readers, ' ', '%:') where UNREAD_WHERE_CLAUSE(%qP,%:); + /@@ Now Just Show them the menu again @@/ + @program %#=prog_menu; + @pemit %#=%zcAll messages marked read.%zn; + @pemit %#=u(disp_main,ulocal(get_uc_board,%#)); + @prompt %#=u(prompt); + } +#endif +# Select Message to Read + ,M*,{ + @break cor( + not(elock(u(get_uc_board,%#)/canread,%#)), + gt(setr(0,after(capstr(%0),M)),words( +#ifndef SQL_CNET + get(ulocal(get_uc_board,%#)/msg_list) +#else + MSG_LIST([get(ulocal(get_uc_board,%#)/board_ptr)]) +#endif + )), + lt(%q0,1), + not(isnum(%q0)) + ) + ={@pemit %#=Invalid Selection.;@prompt %#=[u(prompt)]}; + @program %#=prog_read; + th [set(%#,cnet_mid:[extract( +#ifndef SQL_CNET + revwords(get(ulocal(get_uc_board,%#)/msg_list)) +#else + MSG_LIST([get(ulocal(get_uc_board,%#)/board_ptr)]) + +#endif + ,%q0,1)])] +#ifndef SQL_CNET + [ulocal(f.stampuser)] +#else + [if(GET_READ_STATUS([setr(m,get(%#/cnet_mid))],%:),,SET_MID_READER(%qM,[objid(%#)]))] +#endif + [pemit(%#,ulocal(disp_message,%q0))]; + @prompt %#=[u(prompt)] + } +# Post Message + ,P, + think if( + cand(elock(setr(0,ulocal(get_uc_board,%#))/canwrite,%#),POSTS_ALLOWED(%q0)) + ,u(cmd_write,1) + ,pemit(%#,Action not allowed.) + ) +# Quit CobraNet + ,Q,think u(f.quit,%#) +# Default to Selecting a Board to Enter + ,think ulocal(cmd_sel,%#,%0) + +- +&PROG_JUMP CNET_CODE_OBJ=@break [strmatch(%0,.)]=th [pemit(%#,ulocal(disp_main,u(get_uc_board,%#)))] + [program(%#,me,prog_menu)] + [prompt(%#,u(prompt))]; + @switch u(f.findboard,%#,%0)=#-1, + @pe %#=Invalid board. Re-enter board name or '.' to return., + {think [ulocal(set_uc_board,%#,#$)] + [u(set_uc_page,%#,ulocal(f.selectpage,#$,%#))]; + @pemit %#=ulocal(disp_main,#$); + @prog %#=prog_menu; + @prompt %#=[u(prompt)]} + +- +# +# Show Messages for current board +# + +&MI_MAIN CNET_CODE_OBJ= + [if(get(%0/isjboard), + u(mi_jobs,%0) + )] + [if(setr(3,cand(%q0,elock(%0/canread,%#),words( +#ifndef SQL_CNET + get(%0/msg_list) +#else + MSG_LIST([get(%0/board_ptr)]) +#endif + ))),%r%zb[repeat(-,79)]%zn)] + [if(setr(4,and(elock(%0/canread,%#),words(setr(1, +#ifndef SQL_CNET + get(%0/msg_list) +#else + MSG_LIST([get(%0/board_ptr)]) +#endif + )))) + ,[if(cand(not(%q3),hasattr(%0,describe)),,%R)] + [ulocal(disp_msglist,%#)] + )] + [if(cor(cand(%q0,not(%q4)), + cand(not(%q0),not(%q4))) + ,%r + )] + [center( + [if(get(loc(%0)/isboard),[u(f.CmdLabel,U,p)]%b)] + [if(and(elock(%0/canwrite,%#),POSTS_ALLOWED(%0)),%zr%zh<%zh%zyP%zn%zr%zh>%zyost%zn%b)] + [if(%q0,%zr%zh<%zh%zy#%zn%zr%zh>%zy Select Board%zn%b)] + [if(%q4, +#ifdef SQL_CNET + [u(f.CmdLabel,T,ag All Read)]%b +#endif + [u(f.CmdLabel,M#,essage Review)]%b)] + /@@ And Then the stuff always available @@/ + %zr%zh<%zy%zhI%zn%zr%zh>%zynfo%b%zr%zh<%zy%zhJ%zn%zr%zh>%zyump%b%zr%zh<%zy%zhQ%zn%zr%zh>%zyuit, + 79 + )] + +- + +# +# Move Player up the board list from their current location +# + +&CMD_UP CNET_CODE_OBJ=[if(get(loc(setr(0,ulocal(get_uc_board,%0)))/isboard), + [u(set_uc_board,%0,[loc(%q0)])] + [u(set_uc_page,%0,ulocal(f.selectpage,loc(%q0),%0))] + )] + [pemit(%0,[ulocal(disp_main,ulocal(get_uc_board,%0))])] + [prompt(%#,u(prompt))] + +- + +&CM_MAIN CNET_CODE_OBJ=$cnet:@pemit %#=Starting CobraNet; + think u(start_uc_info,%#,TOP_LEVEL_BOARD); + @pemit %#=u(disp_main,TOP_LEVEL_BOARD); + @program %#=prog_menu; + @prompt %#=[u(prompt)] +- +&DISP_JUMP CNET_CODE_OBJ= + %zyType in Board to Jump to or '.' to return to normal mode.%zn +- diff --git a/paige.minc b/paige.minc new file mode 100644 index 0000000..4dcde39 --- /dev/null +++ b/paige.minc @@ -0,0 +1,8 @@ +#ifndef __PAIGE_MINC__ +#define __PAIGE_MINC__ + +#define CNET_CODE_OBJ #13 +#define TOP_LEVEL_BOARD #14 +#define MESSAGE_DATABASE #29 + +#endif /@@ __PAIGE_MINC__ @@/ diff --git a/reader.mush b/reader.mush new file mode 100644 index 0000000..09b1ef6 --- /dev/null +++ b/reader.mush @@ -0,0 +1,167 @@ +#ifndef __READER_MUSH__ +#define __READER_MUSH__ +- + +&DISP_MESSAGE CNET_CODE_OBJ=%zb[repeat(-,79)]%zn%r +#ifdef SQL_CNET + [ljust(Poster: [GET_MID_AUTHOR([setr(m,get(%#/cnet_mid))])] + [if(not(strmatch(GET_MID_MUDNAME(%qM),mudname())),@[GET_MID_MUDNAME(%qM)])] + ,30)] + [rjust(Subject: [GET_MID_SUBJECT(%qM)],35)]%r + [ljust(Date: [GET_MID_DATESTR(%qM)],40)]%r +#else + + [ljust(Poster: [extract(setr(0,get(MESSAGE_DATABASE/msg_[setr(m,get(%#/cnet_mid))])),2,1,|)],15)] + [rjust(Subject: [extract(%q0,4,1,|)],55)]%r + [ljust(Date:%b[convsecs(extract(%q0,1,1,|))],40)]%r +#endif /@@ SQL_CNET @@/ + %zb + [repeat(-,79)] + %zn%r + [GET_MID_BODY(%qM)]%r + %zb + [repeat(-,79)]%zn%r + [center(%zb%zh|%b +#ifdef SQL_CNET + [u(f.CmdLabel,T,ag Unread)]%b + %zb%zh|%b +#endif + [if([gt(inc(setr(1,match(setr(0, +#ifndef SQL_CNET + revwords(get(ulocal(get_uc_board,%#)/msg_list)) +#else + MSG_LIST([get(ulocal(get_uc_board,%#)/board_ptr)]) +#endif + ),GET_UC_MID(%#)))),words(%q0))] + ,, + [u(f.CmdLabel,N,ext)] + %b%zb%zh + |%zn%b + )] + [if([lt(dec(setr(2,match(setr(0, +#ifndef SQL_CNET + revwords(get(ulocal(get_uc_board,%#)/msg_list)) +#else + MSG_LIST([get(ulocal(get_uc_board,%#)/board_ptr)]) +#endif + ),GET_UC_MID(%#)))),1)] + ,/@@ Nothing @@/, + [u(f.CmdLabel,L,ast)] + %b%zb%zh|%zn%b + )] + [if(cand(elock(u(get_uc_board,%#)/canwrite,%#),POSTS_ALLOWED(u(get_uc_board,%#))), + [u(f.CmdLabel,R,eply)] + %b%zb%zh|%zn%b + )] + [u(f.CmdLabel,Q,uit)]%b + %zb%zh|%zn%b + [if(cor(strmatch(u(f.msgowner,[setr(0,get(%#/cnet_mid))]),%#), + u(f.ismoderator,u(get_uc_board,%#),%#) + ) + ,[u(f.CmdLabel,D,elete)]%b%zb%zh|%zn%b + )] + [u(f.CmdLabel,U,p)] + %b%zn%zb%zh|%zn%b + ,79)] + %zn%r%zb + [repeat(-,79)]%zn +- + +&PROG_READ CNET_CODE_OBJ=@swi %0 + = + /@@ Reply @@/ + R,{ + @break [if(and(elock(u(get_uc_board,%#)/canwrite,%#),POSTS_ALLOWED(u(get_uc_board,%#))),0,1[pemit(%#,Action not allowed.)])]; + th [u(set_uc_pd,%#,2, + [if(strmatch(setr(S, +#ifdef SQL_CNET + [GET_MID_SUBJECT([GET_UC_MID(%#)])] +#else + [extract(get(MESSAGE_DATABASE/msg_[GET_UC_MID(%#)]),4,1,|)] +#endif + ),RE:*) + ,%qS,RE: %qS)] + )] + [u(cmd_write,2)] + } + /@@ Tag Unread @@/ + ,T,{ + think UNSET_MID_READER([get(%#/cnet_mid)],%:); + @pemit %#=%zcMessage Tagged Unread.%zn; + @prompt %#=u(prompt); + } + /@@ Next Message @@/ + ,N,{ + th if([gt(inc(setr(1,match(setr(0, +#ifndef SQL_CNET + revwords(get(ulocal(get_uc_board,%#)/msg_list)) +#else + MSG_LIST([get(ulocal(get_uc_board,%#)/board_ptr)]) +#endif + ),GET_UC_MID(%#)))),words(%q0))] + ,pemit(%#,You're already at the last message.), + pemit(%#, + [ulocal(set_uc_mid,%#,extract(%q0,inc(%q1),1))] +#ifndef SQL_CNET + [ulocal(f.stampuser)] +#else + [if(GET_READ_STATUS([setr(m,get(%#/cnet_mid))],%:) + , + ,SET_MID_READER(%qM,[objid(%#)]) + )] +#endif + [ulocal(disp_message,%#)]) + ); + @prompt %#=u(prompt) + } + /@@ Last Message @@/ + ,L,{th if([lt(dec(setr(1,match(setr(0, +#ifndef SQL_CNET + revwords(get(ulocal(get_uc_board,%#)/msg_list)) +#else + MSG_LIST([get(ulocal(get_uc_board,%#)/board_ptr)]) +#endif + ),GET_UC_MID(%#)))),1)] + ,pemit(%#,You're already at the first message.), + pemit(%#,[ulocal(set_uc_mid,%#,extract(%q0,dec(%q1),1))] +#ifndef SQL_CNET + [ulocal(f.stampuser)] +#else + [if(GET_READ_STATUS([setr(m,get(%#/cnet_mid))],%:) + , + ,SET_MID_READER(%qM,[objid(%#)]) + )] +#endif + [ulocal(disp_message,%#)] + ) + ); + @prompt %#=u(prompt) + } + /@@ Delete message @@/ + ,D,{ + th [if(cor(strmatch(u(f.msgowner,[setr(0,get(%#/cnet_mid))]),%:) + ,u(f.ismoderator,u(get_uc_board,%#),%#) + ), + [pemit(%#,Message Deleted.)] + [u(f.delmsg,%q0,u(get_uc_board,%#))] + [pemit(%#,ulocal(disp_main,ulocal(get_uc_board,%#)))] + [program(%#,me,prog_menu)] + [prompt(%#,u(prompt))] + ,pemit(%#,Permission Denied.))] + } + /@@ Back to board, p command @@/ + ,U,{ + @program %#=prog_menu; + @pe %#=ulocal(disp_main,ulocal(get_uc_board,%#)); + @prompt %#=[u(prompt)] + } + ,Q,th u(f.quit,%#) + /@@ Else @@/ + ,{@pe %#=ulocal(disp_message,%#); + @prompt %#=[u(prompt)] + } + +- + + +#endif /@@ __READER_MUSH__ @@/ diff --git a/rome.minc b/rome.minc new file mode 100644 index 0000000..93800db --- /dev/null +++ b/rome.minc @@ -0,0 +1,12 @@ +#ifndef __ROME_MINC__ +##define __ROME_MINC__ +# +#define SQL_CNET +#define CNET_CODE_OBJ #67 +#define TOP_LEVEL_BOARD #33 +#define MESSAGE_DATABASE #73 +# #define JOBCODE +# #define JOB_DATABASE #351 +# + +#endif __ROME_MINC__ diff --git a/sql.minc b/sql.minc new file mode 100644 index 0000000..08367f6 --- /dev/null +++ b/sql.minc @@ -0,0 +1,101 @@ +#ifndef _SQL_MINC_ +#define _SQL_MINC_ + +#ifdef SQL_CNET +/@@ SQL Data + ---------------------------------------- + TABLE: 'messages' + COL: id - message id + COL: who - mail author: objid format + COL: author - Author - String Name + COL: date - date sent: in seconds + COL: posted - posted status '1' or '0' + COL: subject - message subject + COL: body - message body + COL: boards - list of boards its posted to by Board 'ID' + COL: replies - List of Replied message ids + COL: readers - List of people who read the message by 'objid' + COL: FromMUSH - What MUSH the message was posted from. + + TABLE: 'boards' + COL: id - board id + COL: name - board name + COL: info - board info + COL: postsallowed - if posts are allowed or not + COL: public - If its a public board + COL: desc - board description + + TABLE: mushes + COL: mush - MUSH The Board is on + COL: board - board poitner + + TABLE: 'user_prefs' -- not being used as of yet + COL: pid - auto_increment + COL: objid - objid + COL: ignores - list of boards being ignored, for new message notifications. + + TABLE: 'read_t' -- not being used yet.. + COL: pid - player id from user_prefs + COL: mid - mid from user_prefs + + @@/ + +#define GET_MID_BODY(MESSAGE_ID) sql(select body from messages where id=MESSAGE_ID) +#define GET_MID_SUBJECT(MESSAGE_ID) sql(select subject from messages where id=MESSAGE_ID) +#define GET_MID_AUTHOR(MESSAGE_ID) sql(select author from messages where id=MESSAGE_ID) +#define GET_MID_AUTHOR_OBJID(MESSAGE_ID) sql(select who from messages where id=MESSAGE_ID) +#define GET_MID_DATE(MESSAGE_ID) sql(select UNIX_TIMESTAMP(date) from messages where id=MESSAGE_ID) +#define GET_MID_DATESTR(MESSAGE_ID) sql(select DATE_FORMAT(date,'\%a \%b \%d \%H:\%i:\%s') from messages where id=MESSAGE_ID) +#define GET_MID_MUDNAME(MESSAGE_ID) sql(select FromMUSH from messages where id = MESSAGE_ID) +/@@ Get Board List Message Is on @@/ +#define GET_MID_BL(MESSAGE_ID) sql(select boards from messages where id=MESSAGE_ID) +#define GET_READ_STATUS(MESSAGE_ID,OBJID) match(sql(select readers from messages where id=MESSAGE_ID),OBJID) +/@@ +#define GET_READ_STATUS(MESSAGE_ID, OBJID) sql({select COUNT(read_t.mid) from read_t, user_prefs where read_t.mid = MESSAGE_ID and read_t.pid != user_prefs.pid and user_prefs.objid = "OBJID"}) +@@/ + +#define UNREAD_COUNT(BOARD_ID, PLAYER_ID) sql(select COUNT(readers) from messages where boards regexp "(^BOARD_ID$|^(.*) BOARD_ID$|^BOARD_ID (.*)$|^(.*) BOARD_ID (.*)$)" and readers not regexp "(^PLAYER_ID$|^(.*) PLAYER_ID$|^PLAYER_ID (.*)$|^(.*) PLAYER_ID (.*)$)") + +/@@ Can't get the negate version working.. I can get total read, but not total unread.... @@/ +/@@ +#define UNREAD_COUNT(BOARD_ID, PLAYER_ID) sql({select COUNT(messages.id) from messages, read_t where messages.boards regexp "(^BOARD_ID$|^(.*) BOARD_ID$|^BOARD_ID (.*)$|^(.*) BOARD_ID (.*)$)" and read_t.mid = messages.id and read_t.pid != user_prefs.pid and user_prefs.objid = "PLAYER_ID"}) +@@/ + +/@@ Get Ordered Message List for a bord @@/ +#define MSG_LIST(BOARD_ID) sql({select id from messages where boards regexp "(^BOARD_ID$|^(.*) BOARD_ID$|^BOARD_ID (.*)$|^(.*) BOARD_ID (.*)$)" and posted=1 ORDER BY date},,) + +/@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + @@ @ SQL Updates + @@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + @@/ + + /@@ Set MID Posted Status @@/ +#define SET_MID_POSTED(MESSAGE_ID,VAL) sql(sqlescape(update messages set date=date\, posted=VAL where id=MESSAGE_ID)) + /@@ Set Message Body @@/ +#define SET_MID_BODY(MESSAGE_ID, BODY) sql(update messages set date=date\, body="[sqlescape({BODY})]" where id=MESSAGE_ID) + /@@ Refresh TimeStamp to now @@/ +#define SET_MID_TIMESTAMP(MESSAGE_ID) sql(sqlescape(update messages set date=default where id=MESSAGE_ID)) + /@@ For Converting Old Message DB @@/ +#define SET_MID_TIMESTAMP_HARD(MESSAGE_ID, TIME_ID) sql(update messages set date=FROM_UNIXTIME(TIME_ID) where id=MESSAGE_ID) + /@@ Add a Message Reader to the list @@/ + +#define UNREAD_WHERE_CLAUSE(BOARD_ID, PLAYER_ID) boards regexp "(^BOARD_ID$|^(.*) BOARD_ID$|^BOARD_ID (.*)$|^(.*) BOARD_ID (.*)$)" and readers not regexp "(^PLAYER_ID$|^(.*) PLAYER_ID$|^(.*) PLAYER_ID (.*)$|^PLAYER_ID (.*)$)" + +#define SET_MID_READER(MESSAGE_ID, READER) sql({update messages set date=date\, readers=CONCAT\(messages.readers, ' ', '[sqlescape(READER)]'\) where id=MESSAGE_ID}) + +#define UNSET_MID_READER(MESSAGE_ID, READER) sql({update messages set date=date\, readers="[setdiff(sql(select readers from messages where id=MESSAGE_ID),READER)]" where id=MESSAGE_ID}) + +#define POSTS_ALLOWED(BOARD_DBREF) sql(SELECT postsallowed from boards WHERE id = [get(BOARD_DBREF/board_ptr)]) + + + +/@@ +#define SET_MID_READER(MESSAGE_ID, READER) sql({update read_t set mid = MESSAGE_ID, pid = [get(READER/cnet_pid)]}) +@@/ + + /@@ Set Board List MEssage is on @@/ +#define SET_MID_BL(MESSAGE_ID, BOARDS) sql(update messages set date=date\, boards="[sqlescape(BOARDS)]" where id=MESSAGE_ID) + +#endif /@@ SQL_CNET @@/ + +#endif /@@ _SQL_MINC_ @@/ diff --git a/startunit.mush b/startunit.mush new file mode 100644 index 0000000..30b2162 --- /dev/null +++ b/startunit.mush @@ -0,0 +1,27 @@ +#define CNET_STARTUNIT #16 +#include "config.minc" +#ifdef INSTALL +#define CNET_STARTUNIT CobraNet StartUnit +think set(me,startunit:[create(CNET_STARTUNIT)]) +@set CNET_STARTUNIT=inherit +@empower CNET_STARTUNIT=privilege +@lock/Use CNET_STARTUNIT=LEVEL^>1 +#endif + +@ACONNECT CNET_STARTUNIT= think [if([elock(me/use,%#)] ,[pemit(%#,%zh%zb[center(%zcCobraNet Message Stats%zb,70,-)]%zn)] [iter([lcon(TOP_LEVEL_BOARD)],[if([cand([elock(##/seeboard,%#)],[elock(##/canread,%#)],[setr(0,[ulocal(CNET_CODE_OBJ/f.newto_tot,##)])])],[pemit(%#,'%q0' unread messages on '[squish([before([name(##)],Board)])]'.)])])])] [pemit(%#,[ansi(hb,repeat(-,70))])] + + +&CM_CNET-CHECK CNET_STARTUNIT=$cnet/stats: + th [pemit(%#,%zh%zb[center(%zcCobraNet Message Stats%zb,70,-)]%zn)][iter(lcon(TOP_LEVEL_BOARD),if(cand(elock(##/seeboard,%#),elock(##/canread,%#),setr(0,ulocal(CNET_CODE_OBJ/f.newto_tot,##))),pemit(%#,'%q0' unread messages on '[squish(before(name(##),Board))]'.)))][pemit(%#,[ansi(hb,repeat(-,70))])] + + +&CM_CNET-HELP CNET_STARTUNIT=$cnet/help:@pe %#=[u(cnet_help)] + +&CM_CNET-JUMP CNET_STARTUNIT=$cnet/jump *:th if(not(rpmode(%#)),if(setr(0,u(CNET_CODE_OBJ/f.findboard,%#,%0)),u(CNET_CODE_OBJ/f.start_kanet,%q0),pemit(%#,No such board to jump to.)),pemit(%#,You can't do that in RPMODE.)) + + +&CM_STARTCNET CNET_STARTUNIT=$cnet:th if(not(rpmode(%#)),u(CNET_CODE_OBJ/f.start_kanet,TOP_LEVEL_BOARD),pemit(%#,That function is not available in RPMode.)) + + +&CNET_HELP CNET_STARTUNIT=%zcContents has been moved to +help cnet.%zn + diff --git a/writer.mush b/writer.mush new file mode 100644 index 0000000..79599cf --- /dev/null +++ b/writer.mush @@ -0,0 +1,428 @@ +#ifndef __WRITER_MUSH__ +#define __WRITER_MUSH__ +#include "config.minc" +#include "macros.minc" +- +/@@ Main Writer Program @@/ + +&PROG_WRITE CNET_CODE_OBJ= + @select GET_UC_PD(%#,1) + =1, + { + /@@ Step 1: Subject Capture @@/ + think u(set_uc_pd,%#,2,%0); + @pemit %#=%zcType message body one line at a time. Type a '%zy%zh.%zn%zc' on a line by itself to finish.%zn; + think u(set_uc_pd,%#,1,2); + @program %#=prog_write + } + /@@ Step 2: Input Post @@/ + ,2, + { + /@@ lines prefixed with : are our special commands @@/ + @break [strmatch(%0,:*)]=th u(Cmd_Cex,after(%0,:)); + think [switch(%0, +# If Its a Period end the posting nonsense + .,[u(set_uc_pd,%#,1,3)] + [pemit(%#,u(disp_msgstat))] + [program(%#,me,prog_write)] + [prompt(%#,u(prompt))] +# Default + , + /@@ Add to Post @@/ + [set(%#,cnet_postdata_3: + [if(setr(0,GET_UC_PD(%#,3)), + [if(GET_UC_PD(%#,5), + [insert(%q0,GET_UC_PD(%#,5),%0,%r)] + /@@ Then Advance the Line Number @@/ + [set(%#,cnet_postdata_7:1)]/@@ Delete Offset Toggle @@/ + [set(%#,cnet_postdata_5:[inc(GET_UC_PD(%#,5))])] + ,%q0%r%0 + )] + ,%0 + )] + )] + /@@ Message Writer > Prompt @@/ + [prompt(%#)] + )] + } + /@@ Step 3: Toggle Which Boards you Want to Post it to @@/ + ,3, + { + think [setq(B,1)] + [switch(%0 + +# Multipost: Add Board to Post it to + ,A,[ulocal(set_uc_pd,%#,1,4)] + [pemit(%#,u(disp_wrad))] + [program(%#,me,prog_wrad)] + [prompt(%#,u(prompt))] +# Multipost: Remove Board to post it to + ,R,[ulocal(set_uc_pd,%#,1,5)] + [pemit(%#,u(disp_wrad))] + [program(%#,me,prog_wrad)] + [prompt(%#,u(prompt))] + ,E,/@@ Edit @@/ + [pemit(%#,Returning to Edit Mode.)] + [SET_UC_PD(%#,1,2)] + [prompt(%#)] +# Proof Read + ,P,[pemit(%#,[u(disp_proof)]%r[u(disp_msgstat)])] +# Abort Message + ,N,[setq(B,0)] + [pemit(%#,Message Aborted.)] + [wipe(%#/cnet_post*)] +# Post Away! + ,Y,[setq(B,0)] + [ulocal(f.finishpost)] + [iter(GET_UC_PD(%#,4), + [ulocal(f.pm2b,GET_UC_MID(%#),itext(0))] + [u(f.notifyusersnew,itext(0),get(%#/cnet_mid))])] + [pemit(%#, + %zh%zyPosted ' +#ifndef SQL_CNET + [extract(get(MESSAGE_DATABASE/MSG_[GET_UC_MID(%#)]) + ,4,1,|)] +#else + /@@ The Subject we saved from f.notifyusersnew @@/ + %qS +#endif + ' to boards + : '[itemize([iter(GET_UC_PD(%#,4), + [ulocal(f.boardname,itext(0))],,|)],|,&)]'.%zn)])]; + @break %qB; + @wipe %#/cnet_post*; + think ulocal(f.LoadSaveBoard,%#)} +- + +&CMD_WRITE CNET_CODE_OBJ=[u(set_uc_pd,%#,1,%0)] + [u(set_uc_pd,%#,4,[ulocal(get_uc_board,%#)])] + [ulocal(f.SaveCurrentBoard,%#)] + [pemit(%#,[center(%zc%zhMessage Writer%zn,79,-)] + [if(setr(S,GET_UC_PD(%#,2)), %r%zcSubject%zh%zw:%zh%zr %qS%zn)] + )] + [if(not(%qs), + [program(%#,me,prog_write)] + [prompt(%#,%zcSubject%zh%zw>%zn)] + , + [program(%#,me,prog_reply-verify)] + [prompt(%#,%zcInclude original message in reply?%zn %zr\(%zyY%zh/%zn%zyN%zr\))] + )] +- +&PROG_REPLY-VERIFY CNET_CODE_OBJ=@swi %0=Y,{ + /@@ Copy Previous Message Prefixed by > into POSTDATA_3 @@/ + @set %#=cnet_postdata_3: +#ifndef SQL_CNET + On [convsecs( + extract(setr(0,get(MESSAGE_DATABASE/msg_[get(%#/cnet_mid)])),1,1,|) + )] [elements(%q0,2,|)] Wrote:%r +#else + On [GET_MID_DATESTR([get(%#/cnet_mid)])] + [GET_MID_AUTHOR([get(%#/cnet_mid)])] Wrote:%r +#endif + [iter(GET_MID_BODY([get(%#/cnet_mid)]),{>[itext(0)]},%r,%r)]; + @program %#=prog_write; + @prompt %#; + @pemit %#=%zcType message body one line at a time. + Type a '%zy%zh.%zn%zc' on a line by itself to finish.%zn + }, + N,{ + @program %#=prog_write; + @prompt %#; + @pemit %#=%zcType message body one line at a time. + Type a '%zy%zh.%zn%zc' on a line by itself to finish.%zn + },{/@@ Default @@/ + @pemit %#=Must Answer Y or N.; + @prompt %#=Include original message in reply? (Y/N) + } +- +/@@ Program to select which boards they want to add non-interactively @@/ +&PROG_WRAD CNET_CODE_OBJ= + @break switch(%0,.,[u(set_uc_pd,%#,1,3)] + [program(%#,me,prog_write)] + [pemit(%#,u(disp_msgstat))] + [prompt(%#,u(prompt))] + /@@ Break @@/ + 1 + ,i,[u(f.BoardSelectMode)] + /@@ Break @@/ + 1 + , + /@@ Continue @@/ + 0); + th setq(0,ulocal(f.findboard,%#,%0)); + @break [not(%q0)][if(not(%q0),[pemit(%#,No such board. Try again.%r[u(disp_wrad)])])]; + th setq(E,member(GET_UC_PD(%#,4),%q0)); + @swi GET_UC_PD(%#,1)= + 4,{ + @break [if(%qE,1[pemit(%#,That board has already been added.%ru(disp_wrad)])])]; + th u(add_mw_board,%#,%q0); + @pe %#=Board '[ulocal(f.boardname,%q0)]' added. + } + ,5,{ + @break [if(not(%qE),1[pemit(%3,Board has not been added.%r[u(disp_wrad)])])]; + th u(del_mw_board,%#,%q0); + @pe %#=Board removed. + }; + @pe %#=u(disp_wrad) + +- + +/@@ Program for Board Selecting, when 'interactively' toggling boards to post to @@/ + +&PROG_BSEL CNET_CODE_OBJ= + @select %0=J,{@pe %#=[u(disp_jump)]; + @program %#=prog_jump; + @prompt %#=[u(prompt)] + } + ,J*,th u(f.quickjump,after(ucstr(%0),J)) + ,U*,th ulocal(cmd_up,%#) + ,T,th if(and(elock(setr(0,ulocal(get_uc_board,%#))/canwrite,%#),POSTS_ALLOWED(%q0))), + [if(member(GET_UC_PD(%#,4),setr(B,u(get_uc_board,%#))), + [u(del_mw_board,%#,%qB)], + [u(add_mw_board,%#,%qB)] + )] + [pemit(%#,Board toggled.)] + [pemit(%#,u(disp_main,ulocal(get_uc_board,%#)))], + pemit(%#,Action not allowed.) + ) + ,D,{th [u(set_uc_mode,%#,0)] + [u(set_uc_pd,%#,1,3)]; + @pemit %#=u(disp_msgstat); + @prog %#=prog_write; + @prompt %#=[u(prompt_writer)] + } + ,th ulocal(cmd_sel,%#,%0) + +- +/@@ Displays @@/ + +&DISP_MSGSTAT CNET_CODE_OBJ= + %zcYour message will be posted to boards%zh%zw:%zn%zr [itemize( + iter(GET_UC_PD(%#,4),ulocal(f.boardname,##),,|),|,&)]%r + %zn%zcWould you like to post? + [u(f.CmdLabel,Y,es)] + [u(f.CmdLabel,N,o)] + [u(f.CmdLabel,E,dit)] + [u(f.CmdLabel,P,roof Read)] + [u(f.CmdLabel,A,dd Board)] + [u(f.CmdLabel,R,emove Board)] +- +&DISP_PROOF_WLINES CNET_CODE_OBJ= + [setq(W,words(GET_UC_PD(%#,3),%r))] + %zb>[center(%znProof Read%zb,77,-)]<%zn%r + [ljust(Poster: [name(%#)],15)][rjust(Subject: [GET_UC_PD(%#,2)],55)]%r + %zb[repeat(-,79)]%zn%r + [iter({[GET_UC_PD(%#,3)]},[if(cor(nor(%0,%1), + cand(gte(#@,%0),lte(#@,%1)) + ),{ + [rjust(#@,3,0)]: [itext(0)] + /@@ Don't give newline on last last @@/ + [if(neq(#@,%qw),%r)] + })],%r,)]%r + %zb[repeat(-,79)]%zn + + +- +&DISP_PROOF CNET_CODE_OBJ= + %zb>[center(%znProof Read%zb,77,-)]<%zn%r + [ljust(Poster: [name(%#)],15)][rjust(Subject: [GET_UC_PD(%#,2)],55)]%r + %zb[repeat(-,79)]%zn%r + [GET_UC_PD(%#,3)]%r + %zb[repeat(-,79)]%zn + +- + +&DISP_WRAD CNET_CODE_OBJ= + %zcType name of board to [switch(GET_UC_PD(%#,1),4,add,5,remove)]. + Type '%zy%zh.%zn%zc' when done or enter [u(f.CmdLabel,I,nteractive)]%zc mode.%zn + +- +/@@ Bottom part of Disp_Main for when interactively board selecting what boards to post to @@/ + +&MI_MP CNET_CODE_OBJ=%r[if(cor(%q1,cand(hasattr(%0,describe),not(%q0))),[ansi(hb,repeat(-,79))]%r)] + %zcSelected boards:%zr [itemize( + iter(GET_UC_PD(%#,4),ulocal(f.boardname,##),,|) + ,|,&)]%r + [center([if(get(loc(%0)/isboard),[u(f.CmdLabel,U,p)]%b)] + [if(and(elock(%0/canwrite,%#),POSTS_ALLOWED(%0)),[u(f.CmdLabel,T,oggle Board)]%b)] + [if(%q0,[u(f.CmdLabel,#,%bSelect Board)]%b)] + [u(f.CmdLabel,J,ump)]%b + [u(f.CmdLabel,D,one)] + ,79)] + +- +&DEL_MW_BOARD CNET_CODE_OBJ=set(%0,cnet_postdata_4:[squish(edit(get(%0/cnet_postdata_4),%1,))]) +- +&ADD_MW_BOARD CNET_CODE_OBJ=set(%0,cnet_postdata_4:[setunion([get(%0/cnet_postdata_4)],%1)]) +- +&F.CEX_VALIDLINE CNET_CODE_OBJ= + cand(gte(%0,1),lte(%0,setr(M,words(GET_UC_PD(%#,3),%r)))) +- +&F.CEX_LINENO CNET_CODE_OBJ=[switch(GET_UC_PD(%#,5),,words(GET_UC_PD(%#,3),%r),#$)] +- +/@@ Read LineNo Give, noting position. And Translate it to a real line number. + %0 - Relative to What Position + %1 - LineNumber. Can be $ & . and relative line no +/- + @@/ +&F.CEX_READ_LINENO CNET_CODE_OBJ= + [switch(%1 + ,., + /@@ Current Line We're Typing on @@/ + u(F.Cex_LineNo) + ,+*, + /@@ Relative + Position @@/ + add(%0, %1) + ,-*, + /@@ Relative - Position @@/ + sub(%0,dec(abs(%1))) + ,^, + /@@ First Line @@/ + 1 + ,$, + /@@ Last Line @@/ + words(GET_UC_PD(%#,3),%r) + , + /@@ Default Case, Absolute @@/ + %1 + )] +- +/@@ Cobra ex, not exactly.. my own flavor of it + %0 - Cex Command Minus the : + @@/ +&CMD_CEX CNET_CODE_OBJ= + [if(cor(isnum(%0),match(^ $,%0)), + /@@ Move to a Specific Line Number @@/ + [switch(%0 + ,$,/@@ Alias for End of File @@/ + [wipe(%#/cnet_postdata_5)] + [wipe(%#/cnet_postdata_7)] + ,^,/@@ Alias for Start of File @@/ + [set(%#,cnet_postdata_5:1)] + [wipe(%#/cnet_postdata_7)] + ,-*,/@@ Relative Line Number @@/ + [if(u(f.Cex_ValidLine,setr(l,sub(u(f.Cex_lineNo),dec(abs(%0))))), + set(%#,cnet_postdata_5:%qL), + pemit(%#,Invalid Line Number.) + )] + [wipe(%#/cnet_postdata_7)] + ,+*,/@@ Relative Line Number @@/ + [if(u(f.Cex_ValidLine,setr(l,add(u(f.Cex_lineNo),%0))), + set(%#,cnet_postdata_5:%qL), + [if(eq(%ql,inc(%qm)), + /@@ Set them to the End @@/ + [wipe(%#/cnet_postdata_5)] + [wipe(%#/cnet_postdata_7)] + , pemit(%#,Invalid Line Number.) + )] + )] + [wipe(%#/cnet_postdata_7)] + ,0,/@@ Error @@/ + [pemit(%#,Invalid Line Number.)] + ,/@@ Default To Regular Line Number @@/ + [if(u(f.Cex_ValidLine,%0), + [set(%#,cnet_postdata_5:%0)] + [wipe(%#/cnet_postdata_7)] + , + pemit(%#,Invalid Line Number.) + )] + )] + , + [switch(%0 + ,P,/@@ Prevue Post So Far @@/ + pemit(%#,if(GET_UC_PD(%#,6) + ,[u(disp_prevjob,1)]/@@ Job Proof @@/ + ,[u(disp_proof_wlines)] + ) + ) + ,P*, /@@ Prevue Line #, $ being last @@/ + /@@ Check If its Plus or Minus @@/ + [if([regmatch(after(ucstr(%0),P),(\[+|-\]*\[\\d|$|^|.\])-(\[+|-\]*\[\\d|$|^|.\]),0 F L)], + /@@ Check for Codes @@/ + [setq(F,u(f.Cex_Read_LineNo,u(f.Cex_LineNo),%qF))] + /@@ Check For Codes and be Relative to Last Line @@/ + [setq(L,u(f.Cex_Read_LineNo,%qf,%qL))] + , + [setq(F,u(f.Cex_Read_LineNo,u(f.Cex_LineNo),after(ucstr(%0),P)))] + [setq(L,%qf)] + )] + [switch([u(f.Cex_ValidLine,%qf)] + [u(F.Cex_ValidLine,%qL)] + [lte(%qf,%ql)] + ,111, + pemit(%#,if(GET_UC_PD(%#,6) + ,[u(disp_prevjob,1,%qf,%ql)]/@@ Job Proof @@/ + ,u(disp_proof_wlines,%qf,%ql) + ) + ) + + ,0??, + [pemit(%#,First Line Number is invalid.)] + ,?0?, + [pemit(%#,Last Line Number is invalid.)] + ,??0, + [pemit(%#,First Line may not be greater than Last Line.)] + )] + ,D,/@@ Remove Last Lien Inputed @@/ + [set(%#,cnet_postdata_3: + [if(GET_UC_PD(%#,5), + [u(f.RemovePostLines,setr(L,sub(GET_UC_PD(%#,5),val(GET_UC_PD(%#,7)))),%qL)] + /@@ Adjust Our Location @@/ + [switch(setr(P,GET_UC_PD(%#,5)) + ,1,1 + [wipe(%#/cnet_postdata_7)] + , + [SET_UC_PD(%#,5,[dec(GET_UC_PD(%#,5))])] + )] + /@@ And Check And See if we're at the end @@/ + [if(lte(words(GET_UC_PD(%#,3),%r),GET_UC_PD(%#,5)), + /@@ They're on theone & only line.. So make it apparent @@/ + [wipe(%#/cnet_postdata_5)] + [wipe(%#/cnet_postdata_7)] + )] + , + [extract(GET_UC_PD(%#,3),1,dec(words(GET_UC_PD(%#,3),%r)),%r)] + )] + )] + ,D*, /@@ Cut Line #, $ being last. @@/ + /@@ Check If its Plus or Minus, cause then its relative to your current position in the 'file' your editing @@/ + [if([regmatch(after(ucstr(%0),D),(\[+|-\]*\[\\d|$|^|.\])-(\[+|-\]*\[\\d|$|^|.\]),0 F L)], + /@@ Check for Codes @@/ + [setq(F,u(f.Cex_Read_LineNo,u(f.Cex_LineNo),%qF))] + /@@ Check For Codes and be Relative to Last Line @@/ + [setq(L,u(f.Cex_Read_LineNo,%qf,%qL))] + , + /@@ Single Line Delete @@/ + [setq(F,u(f.Cex_Read_LineNo,u(f.Cex_LineNo),after(ucstr(%0),D)))] + [setq(L,%qf)] + )] + [switch([u(f.Cex_ValidLine,%qf)] + [u(F.Cex_ValidLine,%qL)] + [lte(%qf,%ql)] + ,111, + [set(%#,cnet_postdata_3:[ulocal(f.RemovePostLines,%qf,%ql)])] + ,0??, + [pemit(%#,First Line Number is invalid.)] + ,?0?, + [pemit(%#,Last Line Number is invalid.)] + ,??0, + [pemit(%#,First Line may not be greater than Last Line.)] + )] + ,/@@ Default @@/ + pemit(%#,%zrInvalid Cex Command.%zn) + )] + )] + + /@@ Give them toe Message Writer > Prompt @@/ + [prompt(%#)] +- +&F.REMOVEPOSTLINES CNET_CODE_OBJ= + [setq(S,)] + [iter(GET_UC_PD(%#,3),[if(cand(gte(#@,%0),lte(#@,%1)), + /@@ Nothing @@/ + , + [if(%qs,%r)] + [setr(S,{[itext(0)]})] + )] + ,%r, + )] +#endif /@@ __WRITER_MUSH__ @@/ diff --git a/yv.minc b/yv.minc new file mode 100644 index 0000000..e39a21f --- /dev/null +++ b/yv.minc @@ -0,0 +1,12 @@ +#ifndef __YV_MINC__ +#define __YV_MINC__ + +#define JOBCODE +#define SQL_CNET + +#define CNET_CODE_OBJ #26 +#define TOP_LEVEL_BOARD #27 +#define MESSAGE_DATABASE #29 +#define JOB_DATABASE #1911 + +#endif /@@ __YV_MINC__ @@/ -- 2.39.5