Example #1
0
PROTO void client_quit(void)
{
        if ( client->connected == 1 )
        {
                closegroup();
                disconnect_server(client);
        }
}
Example #2
0
PROTO int group(const char *group, char nogroupecho)
{
        char b[MAX_SERVERRSP];
        ACTIVE *newgroup;
        SERVER *svr;
        CLEARBUF

        if ( nullstr(group) )
        {
                swriteclient(client,"500 You must select a group\r\n");
                return 1;
        }
  
        /* only change group if it has changed */
        if ( client->group == NULL || strcmp(client->group->newsgroup, group) != 0 ) 
        {
                /* check for read permission */
                if ( ! match_expression((unsigned char *)group
                                        , (unsigned char *)getwildmat(client->user->readpat)
                                        , 0) ) 
                {
                        if ( ! nogroupecho )
                                swriteclient(client, MSG_NOSUCHGROUP);
                        return 1;
                }

                /* find and load our new group */
                if ( (newgroup = getgroup(group)) == NULL ) 
                {
                        if ( ! nogroupecho )
                                swriteclient(client, MSG_NOSUCHGROUP);
                        return 1;
                }

                if ( (svr=getserver(newgroup->server)) == NULL )
                        return swriteclient(client, "500 Cant find server for group\r\n");

                /* disconnect first if we have to change server */
                if ( client->groupserver != NULL &&
                        client->connected == 1 &&
                        strcmp(svr->Groups, client->groupserver->Groups) != 0 )
                {
                        disconnect_server(client);
                }

                /* close group and reconnect */
                closegroup();
                client->group = newgroup;

                switch ( connect_groupserver(client, svr->Name) )
                {
                        case CONNECT_ERR:
                                return swriteclient(client, "500 Error selecting server\r\n");

                        case CONNECT_DOWN:
                                sleep(cfg.DownDelay);
                                return writeclient(client, MSG_SERVER_DOWN);

                        default:
                                break;
                }

                /* reset by connect_groupserver (via disconnect_server FIXME) */
                client->group = newgroup;

                client->groups++;
        }

        if ( ! writeserver(client, "GROUP %s\r\n", group) ) return -1;
        if ( ! readserver(client, b, MAX_SERVERRSP-1) ) return -1;

        syslog(LOG_NOTICE, "%s: group %s", client->hostname, group);

        if ( ! nogroupecho ) return swriteclient(client,b);
        return 0;
}
Example #3
0
/**
  * Write one run log.
  * @param name The log name
  * @param times The pointer to the time array
  * @param data The pointer to the data
  * @param type The type of the data
  * @param size The size of the data
  * @param units The units of the data
  */
void SaveISISNexus::write_runlog(const char *name, void *times, void *data,
                                 int type, int size, const std::string &units) {
  write_logOpen(name, times, data, type, size, units);
  closegroup();
}