Back to index

webcit  8.12-dfsg
Classes | Typedefs | Functions
netconf.c File Reference
#include "webcit.h"

Go to the source code of this file.

Classes

struct  _nodeconf

Typedefs

typedef struct _nodeconf NodeConf

Functions

void display_netconf (void)
void DeleteNodeConf (void *vNode)
NodeConfNewNode (StrBuf *SerializedNode)
NodeConfHttpGetNewNode (void)
void SerializeNode (NodeConf *Node, StrBuf *Buf)
HashList * load_netconf (StrBuf *Target, WCTemplputParams *TP)
void save_net_conf (HashList *Nodelist)
void edit_node (void)
void display_edit_node (void)
void display_confirm_delete_node (void)
void delete_node (void)
void tmplput_NodeName (StrBuf *Target, WCTemplputParams *TP)
void tmplput_Secret (StrBuf *Target, WCTemplputParams *TP)
void tmplput_Host (StrBuf *Target, WCTemplputParams *TP)
void tmplput_Port (StrBuf *Target, WCTemplputParams *TP)
void InitModule_NETCONF (void)

Class Documentation

struct _nodeconf

Definition at line 9 of file netconf.c.

Class Members
int DeleteMe
StrBuf * Host
StrBuf * NodeName
StrBuf * Port
StrBuf * Secret

Typedef Documentation

typedef struct _nodeconf NodeConf

Function Documentation

void delete_node ( void  )

Definition at line 230 of file netconf.c.

{
       HashList *NodeConfig;
       const StrBuf *Index;
       NodeConf *Node;
       void *vNode;

       Index = sbstr("index");
       if (Index == NULL) {
              AppendImportantMessage(_("Invalid Parameter"), -1);
              url_do_template();
              return;
       }

       NodeConfig = load_netconf(NULL, &NoCtx);
       if (!GetHash(NodeConfig, ChrPtr(Index), StrLength(Index), &vNode) || 
           (vNode == NULL)) {
              AppendImportantMessage(_("Invalid Parameter"), -1);
              url_do_template();
              DeleteHash(&NodeConfig);
              return;
       }
       Node = (NodeConf *) vNode;
       Node->DeleteMe = 1;
              save_net_conf(NodeConfig);
       DeleteHash(&NodeConfig);
       
       url_do_template();

}

Here is the call graph for this function:

Here is the caller graph for this function:

void DeleteNodeConf ( void *  vNode)

Definition at line 17 of file netconf.c.

{
       NodeConf *Node = (NodeConf*) vNode;
       FreeStrBuf(&Node->NodeName);
       FreeStrBuf(&Node->Secret);
       FreeStrBuf(&Node->Host);
       FreeStrBuf(&Node->Port);
       free(Node);
}

Here is the caller graph for this function:

void display_confirm_delete_node ( void  )

Definition at line 221 of file netconf.c.

{
       wDumpContent(1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void display_edit_node ( void  )

Definition at line 173 of file netconf.c.

{
       WCTemplputParams SubTP;
       HashList *NodeConfig;
       const StrBuf *Index;
       void *vNode;
       const StrBuf *Tmpl;

       Index = sbstr("index");
       if (Index == NULL) {
              AppendImportantMessage(_("Invalid Parameter"), -1);
              url_do_template();
              return;
       }

       NodeConfig = load_netconf(NULL, &NoCtx);
       if (!GetHash(NodeConfig, ChrPtr(Index), StrLength(Index), &vNode) || 
           (vNode == NULL)) {
              AppendImportantMessage(_("Invalid Parameter"), -1);
              url_do_template();
              DeleteHash(&NodeConfig);
              return;
       }
       
       memset(&SubTP, 0, sizeof(WCTemplputParams));
       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();                                                                               
       DeleteHash(&NodeConfig);
       
}

Here is the call graph for this function:

Here is the caller graph for this function:

void display_netconf ( void  )

Definition at line 213 of file netconf.c.

{
       wDumpContent(1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void edit_node ( void  )

Definition at line 147 of file netconf.c.

                     {
       HashList *NodeConfig;
       const StrBuf *Index;
       NodeConf *NewNode;

       if (havebstr("ok_button")) {
              Index = sbstr("index");
               NewNode = HttpGetNewNode();
              if ((NewNode == NULL) || (Index == NULL)) {
                     AppendImportantMessage(_("Invalid Parameter"), -1);
                     url_do_template();
                     return;
              }
                     
              NodeConfig = load_netconf(NULL, &NoCtx);
              Put(NodeConfig, ChrPtr(Index), StrLength(Index), NewNode, DeleteNodeConf);
              save_net_conf(NodeConfig);
              DeleteHash(&NodeConfig);
       }
       url_do_template();
}

Here is the call graph for this function:

Here is the caller graph for this function:

NodeConf* HttpGetNewNode ( void  )

Definition at line 46 of file netconf.c.

{
       NodeConf *Node;

       if (!havebstr("node") || 
           !havebstr("secret")||
           !havebstr("host")||
           !havebstr("port"))
              return NULL;

       Node = (NodeConf *) malloc(sizeof(NodeConf));
       Node->DeleteMe = 0;
       Node->NodeName = NewStrBufDup(sbstr("node"));
       Node->Secret = NewStrBufDup(sbstr("secret"));
       Node->Host = NewStrBufDup(sbstr("host"));
       Node->Port = NewStrBufDup(sbstr("port"));
       return Node;
}

Here is the caller graph for this function:

void InitModule_NETCONF ( void  )

Definition at line 288 of file netconf.c.

{
       WebcitAddUrlHandler(HKEY("display_edit_node"), "", 0, display_edit_node, 0);

       WebcitAddUrlHandler(HKEY("aide_ignetconf_edit_node"), "", 0, edit_node, 0);
       WebcitAddUrlHandler(HKEY("display_netconf"), "", 0, display_netconf, 0);
       WebcitAddUrlHandler(HKEY("display_confirm_delete_node"), "", 0, display_confirm_delete_node, 0);
       WebcitAddUrlHandler(HKEY("delete_node"), "", 0, delete_node, 0);

                                                                                          
        RegisterNamespace("CFG:IGNET:NODE", 0, 1, tmplput_NodeName, NULL, CTX_NODECONF);
        RegisterNamespace("CFG:IGNET:SECRET", 0, 1, tmplput_Secret, NULL, CTX_NODECONF);
        RegisterNamespace("CFG:IGNET:HOST", 0, 1, tmplput_Host, NULL, CTX_NODECONF);
        RegisterNamespace("CFG:IGNET:PORT", 0, 1, tmplput_Port, NULL, CTX_NODECONF);

       RegisterIterator("NODECONFIG", 0, NULL, load_netconf, NULL, DeleteHash, CTX_NODECONF, CTX_NONE, IT_NOFLAG);
}

Here is the call graph for this function:

Here is the caller graph for this function:

HashList* load_netconf ( StrBuf *  Target,
WCTemplputParams TP 
)

Definition at line 75 of file netconf.c.

{
       StrBuf *Buf;
       HashList *Hash;
       char nnn[64];
       char buf[SIZ];
       int nUsed;
       NodeConf *Node;

       serv_puts("CONF getsys|application/x-citadel-ignet-config");
       serv_getln(buf, sizeof buf);
       if (buf[0] == '1') {
              Hash = NewHash(1, NULL);

              Buf = NewStrBuf();
              while (StrBuf_ServGetln(Buf), strcmp(ChrPtr(Buf), "000")) {
                     Node = NewNode(Buf);
                     if (Node != NULL) {
                            nUsed = GetCount(Hash);
                            nUsed = snprintf(nnn, sizeof(nnn), "%d", nUsed+1);
                            Put(Hash, nnn, nUsed, Node, DeleteNodeConf); 
                     }
              }
              FreeStrBuf(&Buf);
              return Hash;
       }
       return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NodeConf* NewNode ( StrBuf *  SerializedNode)

we need at least 4 pipes and some other text so its invalid.

Definition at line 27 of file netconf.c.

{
       NodeConf *Node;

       if (StrLength(SerializedNode) < 8) 
              return NULL; 
       Node = (NodeConf *) malloc(sizeof(NodeConf));
       Node->DeleteMe = 0;
       Node->NodeName=NewStrBuf();
       StrBufExtract_token(Node->NodeName, SerializedNode, 0, '|');
       Node->Secret=NewStrBuf();
       StrBufExtract_token(Node->Secret, SerializedNode, 1, '|');
       Node->Host=NewStrBuf();
       StrBufExtract_token(Node->Host, SerializedNode, 2, '|');
       Node->Port=NewStrBuf();
       StrBufExtract_token(Node->Port, SerializedNode, 3, '|');
       return Node;
}

Here is the caller graph for this function:

void save_net_conf ( HashList *  Nodelist)

Definition at line 106 of file netconf.c.

{
       char buf[SIZ];
       StrBuf *Buf;
       HashPos *where;
       void *vNode;
       NodeConf *Node;
       const char *Key;
       long KeyLen;

       serv_puts("CONF putsys|application/x-citadel-ignet-config");
       serv_getln(buf, sizeof buf);
       if (buf[0] == '4') {
              if ((Nodelist != NULL) && (GetCount(Nodelist) > 0)) {
                     where = GetNewHashPos(Nodelist, 0);
                     Buf = NewStrBuf();
                     while (GetNextHashPos(Nodelist, where, &KeyLen, &Key, &vNode)) {
                            Node = (NodeConf*) vNode;
                            if (Node->DeleteMe==0) { 
                                   SerializeNode(Node, Buf);
                                   serv_putbuf(Buf);
                            }
                     }
                     FreeStrBuf(&Buf);
                     DeleteHashPos(&where);
              }
              serv_puts("000");
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void SerializeNode ( NodeConf Node,
StrBuf *  Buf 
)

Definition at line 65 of file netconf.c.

{
       StrBufPrintf(Buf, "%s|%s|%s|%s", 
                   ChrPtr(Node->NodeName),
                   ChrPtr(Node->Secret),
                   ChrPtr(Node->Host),
                   ChrPtr(Node->Port));
}

Here is the caller graph for this function:

void tmplput_Host ( StrBuf *  Target,
WCTemplputParams TP 
)

Definition at line 274 of file netconf.c.

{
       NodeConf *Node= (NodeConf*) CTX;
       StrBufAppendTemplate(Target, TP, Node->Host, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tmplput_NodeName ( StrBuf *  Target,
WCTemplputParams TP 
)

Definition at line 262 of file netconf.c.

{
       NodeConf *Node = (NodeConf*) CTX;  
       StrBufAppendTemplate(Target, TP, Node->NodeName, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tmplput_Port ( StrBuf *  Target,
WCTemplputParams TP 
)

Definition at line 280 of file netconf.c.

{
       NodeConf *Node= (NodeConf*) CTX;
       StrBufAppendTemplate(Target, TP, Node->Port, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tmplput_Secret ( StrBuf *  Target,
WCTemplputParams TP 
)

Definition at line 268 of file netconf.c.

{
       NodeConf *Node = (NodeConf*) CTX;
       StrBufAppendTemplate(Target, TP, Node->Secret, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function: