TIP: Click on subject to list as thread! ANSI
echo: muffin
to: All
from: Bo Simonsen
date: 2003-06-22 16:40:16
subject: fconf2maximus

Hello All!

I've made a small program whitch is getting fidoconf information, to make
the msgareas.ctl

Can be compiled by

        g++ fconf2max.c -lfidoconfig -lhusky

=== Cut ===
#include 
#include 
#include 
#include 

void DoMsgAreas(char*, int, int, char*, bool);

int main(int argc, char** argv)
{
    bool local = false;
    int i;
    char* group = "";
    int startecho = 0;
    int startlocal = 0;
    char* filename = "";

    printf("fconf2max - Copyright 2003, Bo Simonsen\n\n");
    for(i=0; i <= argc; i++)
    {
        /* To avoid it crashes under strcmp, because argv[i] is null */
        if(argv[i] != NULL)
        {
            if(!strcmp(argv[i], "-g"))
            {
                group = argv[i+1];
            }
            if(!strcmp(argv[i], "-se"))
            {
                startecho = atoi(argv[i+1]);
            }
            if(!strcmp(argv[i], "-sl"))
            {
                startlocal = atoi(argv[i+1]);
            }
            if(!strcmp(argv[i], "-o"))
            {
                filename = argv[i+1];
            }
            if(!strcmp(argv[1], "-l"))
            {
                local = true;
            }
        }
    }

    /* If all is in, let's go ahead! */

    if(group != "" && startecho != 0 && filename
!= "")
    {
        DoMsgAreas(group, startecho, startlocal, filename, local);

    }

    /* else we are kind to tell the user what do to */

    else
    {
        printf("You didn't fill in the required parameters\n");
        printf("Options:\n -l include local areas\n -g group -- does
only process that group (if all it takes all groups)\n -se num -- Start
area number for echo\n -sl num -- Start area number for local\n -o outfile
-- output msgarea.ctl\n\n");
    }

}

void DoMsgAreas(char* group, int startecho, int startlocal, char* filename,
bool local)
{
    int i;
    int count = 0;

    /* The fidoconfig structure */
    s_fidoconfig *config;

    /* Get it! It's NULL we let fidoconfig find the configfile */
    config=readConfig(NULL);

    FILE* file;

    /* We open the file ... */
    file = fopen(filename, "w");

    if(local && startlocal != 0)
    {
        for(i=0; i localAreaCount; i++)
        {
            /* start to print the msgarea.ctl format */
            fprintf(file, "MsgArea %d\n", startlocal+count);
            fprintf(file, "ACS Transient\n");

            /* if there is a description */
            if(config->localAreas[i].description != NULL)
            {
            fprintf(file, "Desc %s\n",
config->localAreas[i].description); 
            }

            /* else.. hmm.. let's use the areaname as description! */
            else
            {
                fprintf(file, "Desc %s\n",
config->localAreas[i].areaName); 
            }
            fprintf(file, "Style Squish Local Pvt\n");
            fprintf(file, "Path %s\n", config->localAreas[i].fileName);
            fprintf(file, "End MsgArea\n\n");
            count++;
        }
    }

    count = 0;

    /* Run so long as we have echoareas aviable */
    for(i=0; i echoAreaCount; i++)
    {
        /* If a group is entered */
        if(config->echoAreas[i].group != NULL)
        {

            /* if it's the _right_ group! */
            if(!strcmp(config->echoAreas[i].group, group) ||
!strcmp(group, "all"))
            {

                /* start to print the msgarea.ctl format */
                fprintf(file, "MsgArea %d\n", startecho+count);
                fprintf(file, "ACS Transient\n");

                /* if there is a description */
                if(config->echoAreas[i].description != NULL)
                {
                    fprintf(file, "Desc %s\n",
config->echoAreas[i].description);
                }

                /* else.. hmm.. let's use the areaname as description! */
                else
                {
                    fprintf(file, "Desc %s\n",
config->echoAreas[i].areaName); 
                }
                fprintf(file, "Style Squish Realname Echo Pub\n");
                fprintf(file, "Path %s\n",
config->echoAreas[i].fileName);
                if(config->echoAreas[i].useAka != NULL)
                {
                    fprintf(file, "Origin %d:%d/%d.%d %d:%d/%d.%d
%s\n", config->echoAreas[i].useAka->zone,
config->echoAreas[i].useAka->net,
config->echoAreas[i].useAka->node,
config->echoAreas[i].useAka->point,config->echoAreas[i].useAka->zone,
config->echoAreas[i].useAka->net,
config->echoAreas[i].useAka->node,
config->echoAreas[i].useAka->point, config->origin);
                }
                fprintf(file, "End MsgArea\n\n");
                count++;
            }
        }

    }

    /* Free memory */
    disposeConfig(config);

    /* .. and we are kind, so we close the file */
    fclose(file);
    printf("Wrote file %s\n\n", filename);
}
=== Cut ===

Regards,
Bo

--- GoldED+/LNX 1.1.5
* Origin: The Night Express * Roennede DK * telnet geekworld.dk (2:236/100)
SEEN-BY: 633/267 270
@PATH: 236/100 237/9 20/11 106/1 2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.