X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fnetconf.c;h=83c391429c95aa0d7a4b10fed5706fa6facda289;hb=5d38a76f8f06640e3a3f097d584ac52336110f7c;hp=cdd265a412da3f5e96c2a9b7a722f4928fa4eccc;hpb=d0b06f827c2116810054db11c603d59d9ca7f88d;p=citadel.git diff --git a/webcit/netconf.c b/webcit/netconf.c index cdd265a41..83c391429 100644 --- a/webcit/netconf.c +++ b/webcit/netconf.c @@ -1,16 +1,8 @@ -/* - * $Id$ - */ -/** - * \defgroup NetShareConf Functions which handle network and sharing configuration. - * - * \ingroup CitadelConfig - */ -/*@{*/ #include "webcit.h" void display_netconf(void); +CtxType CTX_NODECONF = CTX_NONE; /*----------------------------------------------------------------------*/ /* Business Logic */ /*----------------------------------------------------------------------*/ @@ -87,7 +79,6 @@ HashList *load_netconf(StrBuf *Target, WCTemplputParams *TP) HashList *Hash; char nnn[64]; char buf[SIZ]; - long len; int nUsed; NodeConf *Node; @@ -97,14 +88,13 @@ HashList *load_netconf(StrBuf *Target, WCTemplputParams *TP) Hash = NewHash(1, NULL); Buf = NewStrBuf(); - while ((len = StrBuf_ServGetln(Buf), - strcmp(ChrPtr(Buf), "000"))) { + while (StrBuf_ServGetln(Buf), strcmp(ChrPtr(Buf), "000")) { Node = NewNode(Buf); - if (Node == NULL) - continue; - nUsed = GetCount(Hash); - nUsed = snprintf(nnn, sizeof(nnn), "%d", nUsed+1); - Put(Hash, nnn, nUsed, Node, DeleteNodeConf); + if (Node != NULL) { + nUsed = GetCount(Hash); + nUsed = snprintf(nnn, sizeof(nnn), "%d", nUsed+1); + Put(Hash, nnn, nUsed, Node, DeleteNodeConf); + } } FreeStrBuf(&Buf); return Hash; @@ -152,8 +142,8 @@ void save_net_conf(HashList *Nodelist) -/** - * \brief edit a network node +/* + * edit a network node */ void edit_node(void) { HashList *NodeConfig; @@ -164,7 +154,7 @@ void edit_node(void) { Index = sbstr("index"); NewNode = HttpGetNewNode(); if ((NewNode == NULL) || (Index == NULL)) { - sprintf(WC->ImportantMessage, _("Invalid Parameter")); + AppendImportantMessage(_("Invalid Parameter"), -1); url_do_template(); return; } @@ -178,8 +168,8 @@ void edit_node(void) { } -/** - * \brief modify an existing node +/* + * modify an existing node */ void display_edit_node(void) { @@ -191,7 +181,7 @@ void display_edit_node(void) Index = sbstr("index"); if (Index == NULL) { - sprintf(WC->ImportantMessage, _("Invalid Parameter")); + AppendImportantMessage(_("Invalid Parameter"), -1); url_do_template(); return; } @@ -199,36 +189,35 @@ void display_edit_node(void) NodeConfig = load_netconf(NULL, &NoCtx); if (!GetHash(NodeConfig, ChrPtr(Index), StrLength(Index), &vNode) || (vNode == NULL)) { - sprintf(WC->ImportantMessage, _("Invalid Parameter")); + AppendImportantMessage(_("Invalid Parameter"), -1); url_do_template(); DeleteHash(&NodeConfig); return; } - - memset(&SubTP, 0, sizeof(WCTemplputParams)); - SVPutBuf("ITERATE:KEY", Index, 1); - SubTP.Filter.ContextType = CTX_NODECONF; - SubTP.Context = vNode; - begin_burst(); - Tmpl = sbstr("template"); - output_headers(1, 0, 0, 0, 1, 0); - DoTemplate(SKEY(Tmpl), NULL, &SubTP); - end_burst(); + StackContext(NULL, &SubTP, vNode, CTX_NODECONF, 0, NULL); + { + begin_burst(); + Tmpl = sbstr("template"); + output_headers(1, 0, 0, 0, 1, 0); + DoTemplate(SKEY(Tmpl), NULL, &SubTP); + end_burst(); + } + UnStackContext(&SubTP); DeleteHash(&NodeConfig); } -/** - * \brief display all configured nodes +/* + * display all configured nodes */ void display_netconf(void) { wDumpContent(1); } -/** - * \brief display the dialog to verify the deletion +/* + * display the dialog to verify the deletion */ void display_confirm_delete_node(void) { @@ -236,8 +225,8 @@ void display_confirm_delete_node(void) } -/** - * \brief actually delete the node +/* + * actually delete the node */ void delete_node(void) { @@ -248,7 +237,7 @@ void delete_node(void) Index = sbstr("index"); if (Index == NULL) { - sprintf(WC->ImportantMessage, _("Invalid Parameter")); + AppendImportantMessage(_("Invalid Parameter"), -1); url_do_template(); return; } @@ -256,7 +245,7 @@ void delete_node(void) NodeConfig = load_netconf(NULL, &NoCtx); if (!GetHash(NodeConfig, ChrPtr(Index), StrLength(Index), &vNode) || (vNode == NULL)) { - sprintf(WC->ImportantMessage, _("Invalid Parameter")); + AppendImportantMessage(_("Invalid Parameter"), -1); url_do_template(); DeleteHash(&NodeConfig); return; @@ -273,25 +262,25 @@ void delete_node(void) void tmplput_NodeName(StrBuf *Target, WCTemplputParams *TP) { - NodeConf *Node = (NodeConf*) CTX; + NodeConf *Node = (NodeConf*) CTX(CTX_NODECONF); StrBufAppendTemplate(Target, TP, Node->NodeName, 0); } void tmplput_Secret(StrBuf *Target, WCTemplputParams *TP) { - NodeConf *Node = (NodeConf*) CTX; + NodeConf *Node = (NodeConf*) CTX(CTX_NODECONF); StrBufAppendTemplate(Target, TP, Node->Secret, 0); } void tmplput_Host(StrBuf *Target, WCTemplputParams *TP) { - NodeConf *Node= (NodeConf*) CTX; + NodeConf *Node= (NodeConf*) CTX(CTX_NODECONF); StrBufAppendTemplate(Target, TP, Node->Host, 0); } void tmplput_Port(StrBuf *Target, WCTemplputParams *TP) { - NodeConf *Node= (NodeConf*) CTX; + NodeConf *Node= (NodeConf*) CTX(CTX_NODECONF); StrBufAppendTemplate(Target, TP, Node->Port, 0); } @@ -299,6 +288,7 @@ void InitModule_NETCONF (void) { + RegisterCTX(CTX_NODECONF); WebcitAddUrlHandler(HKEY("display_edit_node"), "", 0, display_edit_node, 0); WebcitAddUrlHandler(HKEY("aide_ignetconf_edit_node"), "", 0, edit_node, 0); @@ -314,4 +304,3 @@ InitModule_NETCONF RegisterIterator("NODECONFIG", 0, NULL, load_netconf, NULL, DeleteHash, CTX_NODECONF, CTX_NONE, IT_NOFLAG); } -/*@}*/