src/siri/admin/client.c
/*
 * Called when groups.dat is received.
 */
Called when groups.dat is received.
Called when groups . dat is received .
static void CLIENT_on_file_groups(
        siri_admin_client_t * adm_client,
        sirinet_pkg_t * pkg)
{
    FILE * fp;
    char fn[strlen(adm_client->dbpath) + 11]; 
    sprintf(fn, "%sgroups.dat", adm_client->dbpath);
    fp = fopen(fn, "w");
    if (fp == NULL)
    {
        CLIENT_err(adm_client, "cannot write or create file: %s", fn);
    }
    else
    {
        int rc = fwrite(pkg->data, pkg->len, 1, fp);
        if (fclose(fp) || rc != 1)
        {
            CLIENT_err(adm_client, "cannot write data to file: %s", fn);
        }
        else
        {
            adm_client->request = CLIENT_REQUEST_FILE_SERVERS;
            sirinet_pkg_t * package =
                    sirinet_pkg_new(0, 0, CPROTO_REQ_FILE_SERVERS, NULL);
            if (package == NULL)
            {
                CLIENT_err(adm_client, "memory allocation error");
            }
            else
            {
                CLIENT_send_pkg(adm_client, package);
            }
        }
    }
}
static void CLIENT_on_file_groups ( siri_admin_client_t * adm_client , sirinet_pkg_t * pkg ) { FILE * fp ; char fn [ strlen ( adm_client -> dbpath ) + 11 ] ; sprintf ( fn , " " , adm_client -> dbpath ) ; fp = fopen ( fn , " " ) ; if ( fp == NULL ) { CLIENT_err ( adm_client , " " , fn ) ; } else { int rc = fwrite ( pkg -> data , pkg -> len , 1 , fp ) ; if ( fclose ( fp ) || rc != 1 ) { CLIENT_err ( adm_client , " " , fn ) ; } else { adm_client -> request = CLIENT_REQUEST_FILE_SERVERS ; sirinet_pkg_t * package = sirinet_pkg_new ( 0 , 0 , CPROTO_REQ_FILE_SERVERS , NULL ) ; if ( package == NULL ) { CLIENT_err ( adm_client , " " ) ; } else { CLIENT_send_pkg ( adm_client , package ) ; } } } }
Called when groups.dat is received.
Called when groups . dat is received .
// 11 = strlen("groups.dat") + 1