Sophie

Sophie

distrib > Mandriva > 2010.2 > i586 > by-pkgid > 5048a98a2a434ae6a0e486f45de0d373 > files > 13

huskybse-1.0.0-7mdv2010.0.noarch.rpm

* Echoarea : RU.HUSKY (Husky-project (hpt htick fidoconfig))
* From : Dmitry Sergienko, 2:464/910.1 (14 Oct 02 16:26)

* Translated to english by Stas Degteff 2:5080/102

*        Note to All: If found errors, fix its please.


The fidoconf library usage.
First step: see fidoconf.h in detail.
After this write 1st test program:
---------------------
#include <stdio.h>
#include <fidoconf/fidoconf.h>

int main()
{
    s_fidoconfig *config;    /* Declare pointer to fidoconfig stricture */

    config=readConfig(NULL); /* read config, parse and store it into structure */
                 /*   ^^^^  Instead <b>NULL</b> may use alternate config file name */

    printf("Name: %s\n", config->name); /* Use values from config structure */

    disposeConfig(config);  /* Free memory */

    return 0;
}

The smapi library need at link program phase (such is the case now, unfortunately)
---------------------

The smapi library usage example.

---------------------
#include <stdio.h>
#include <smapi/compiler.h>
#include <smapi/msgapi.h>

int main()
{
    struct _minf m;     /* Declare structure for MSGAPI info */
    HAREA area;         /* Declare area structure (echoarea, netmailarea 
                           or localarea - its is unimportant) */
    HMSG msg;           /* Declare structure for message store */
    XMSG xmsg;          /* Another structure for message store */
    char *text = NULL;
    dword  textLen = 0;


 /* Some code for config reading skipped, see first example (below) */


    m.req_version = 2;  /* Set smapi version number */

              /* vvvvvv  config readed before this line or use alternate value/code */
    m.def_zone = config->addr[0].zone;
    if (MsgOpenApi(&m)!= 0) {     /* Open MSGAPI handler call (initialise MSGAPI) */
        printf("MsgOpenApi Error.\n");
        exit(1);
    }
    /* Open area handler call (initialise area, read some info from disk file) */
    area = MsgOpenArea((byte *) areaName, MSGAREA_NORMAL, areaType);

    /* Find and open last message in area, lock file */
    msg = MsgOpenMsg(area, MOPEN_RW, MsgGetHighMsg(oldArea));

    /* Read message */
    MsgReadMsg(msg, &xmsg, 0, textLen, (byte*)text, 0, NULL);

    /* Change message text */
    nfree(text);
    text = strdup("Hello world!\r");
    textLen = strlen(text)+1;

    /* Write changed message into messagebase (disk file) */
    MsgWriteMsg(msg, 0, &xmsg, (byte*)text, textLen, textLen, 0, NULL);

    /* Close message: deinit handler call (flush fuffers, unlock file, release memory) */
    MsgCloseMsg(msg);

    /* Close area: deinit handler call (close file, release memory) */
    MsgCloseArea(area);

    /* Close MSGAPI: deinit handler call (release memory) */
    MsgCloseApi();

    return 0;
}