Beispiel #1
0
int main( int argc, const char * argv[] )
/*********************************/
{
    int     contok;
    int     retcode;

    TRMemOpen();

    contok = ScanParams( argc, argv );

    if (CmdLineParms.PrintHelp) {
        PrintUsageMessage( argv[0] );
    }

    if (contok) {
        retcode = DumpFile();
    } else {
        retcode = 1;
    }

    FreeParams();

    switch (retcode) {
    case 1:         /* reading parameters */
        break;
    case 2:         /* reading input file */
        puts( "Error reading input file" );
        break;
    }

    TRMemClose();

    return( retcode );
}
Beispiel #2
0
// чтение зон из ini файла
// зоны записываются в массив контуров и в массив прямоугольников.
void LoadZones(int w, int h)
{
	TVAInitParams params;


	if (!LoadInitParams("init.xml", &params))
	{
		printf("Cannot load params.\n");
		return;
	}
	memcpy(&g_camera, &params.Camera, sizeof(TVACamera));
	g_contours_count = 0;
	g_rects_count = 0;
	// преобразуем параметры в структуры g_rects и g_contours 
	for (int i = 0; i < params.NumZones; i++)
	{
		if (params.Zones[i].IsRect && g_rects_count < C_MAX_OBJECTS)
		{
			g_rects[g_rects_count].x = int(w*params.Zones[i].Rect.LeftTop.X / 100.);
			g_rects[g_rects_count].y = int(h*params.Zones[i].Rect.LeftTop.Y / 100.);
			g_rects[g_rects_count].width = int(w*(params.Zones[i].Rect.RightBottom.X - params.Zones[i].Rect.LeftTop.X) / 100.);
			g_rects[g_rects_count].height = int(h*(params.Zones[i].Rect.RightBottom.Y - params.Zones[i].Rect.LeftTop.Y) / 100.);
			g_rects_count++;
		}
		else if (!params.Zones[i].IsRect && g_contours_count < C_MAX_OBJECTS)
		{
			g_contours[g_contours_count].NumPoints = params.Zones[i].NumPoints > C_MAX_POINTS ? C_MAX_POINTS:params.Zones[i].NumPoints;
			memcpy(g_contours[g_contours_count].Points, params.Zones[i].Points, g_contours[g_contours_count].NumPoints*sizeof(TVAPoint));
			g_contours_count++;
		}
	}
	FreeParams(&params);
	MakeMaskImage(g_mask);
}
Beispiel #3
0
void FCGX_Free(FCGX_Request * request, int close)
{
	if (request == NULL)
		return;

	FCGX_FreeStream(&request->in);
	FCGX_FreeStream(&request->out);
	FCGX_FreeStream(&request->err);
	FreeParams(&request->paramsPtr);

	if (close) {
		OS_IpcClose(request->ipcFd);
		request->ipcFd = -1;
	}
}
 const tCommand& operator = (const tCommand& v)
 {
     int i;
     FreeParams();
     cmdId = v.cmdId;
     for (i = 0; i < v.params.GetCount(); ++i)
     {
         tParameter *pParam = new tParameter(*v.params[i]);
         params.Add(pParam);
     }
     step = v.step;
     line = v.line;
     lineDot = v.lineDot;
     return *this;
 }
Beispiel #5
0
/*
 *----------------------------------------------------------------------
 *
 * ProcessManagementRecord --
 *
 *      Reads and responds to a management record.  The only type of
 *      management record this library understands is FCGI_GET_VALUES.
 *      The only variables that this library's FCGI_GET_VALUES
 *      understands are FCGI_MAX_CONNS, FCGI_MAX_REQS, and FCGI_MPXS_CONNS.
 *      Ignore other FCGI_GET_VALUES variables; respond to other
 *      management records with a FCGI_UNKNOWN_TYPE record.
 *
 *----------------------------------------------------------------------
 */
static int ProcessManagementRecord(int type, FCGX_Stream * stream)
{
	FCGX_Stream_Data *data = (FCGX_Stream_Data *) stream->data;
	ParamsPtr paramsPtr = NewParams(3);
	char **pPtr;
	char response[64];	/* 64 = 8 + 3*(1+1+14+1)* + padding */
	char *responseP = &response[FCGI_HEADER_LEN];
	char *name, value = '\0';
	int len, paddedLen;
	if (type == FCGI_GET_VALUES) {
		ReadParams(paramsPtr, stream);
		if ((FCGX_GetError(stream) != 0) || (data->contentLen != 0)) {
			FreeParams(&paramsPtr);
			return FCGX_PROTOCOL_ERROR;
		}
		for (pPtr = paramsPtr->vec; pPtr < paramsPtr->cur; pPtr++) {
			name = *pPtr;
			*(strchr(name, '=')) = '\0';
			if (strcmp(name, FCGI_MAX_CONNS) == 0) {
				value = '1';
			} else if (strcmp(name, FCGI_MAX_REQS) == 0) {
				value = '1';
			} else if (strcmp(name, FCGI_MPXS_CONNS) == 0) {
				value = '0';
			} else {
				name = NULL;
			}
			if (name != NULL) {
#include <fmt.h>
				len = strlen(name);
				responseP[0] = (char)len;
				responseP[1] = (char)1;
				fmt_str(responseP + 2, name);
				responseP[2 + len] = value;
				responseP[3 + len] = '\0';
//                sprintf(responseP, "%c%c%s%c", len, 1, name, value);
				responseP += len + 3;
			}
		}
		len = responseP - &response[FCGI_HEADER_LEN];
		paddedLen = AlignInt8(len);
		*((FCGI_Header *) response)
			= MakeHeader(FCGI_GET_VALUES_RESULT,
			FCGI_NULL_REQUEST_ID, len, paddedLen - len);
		FreeParams(&paramsPtr);
	} else {
		paddedLen = len = sizeof(FCGI_UnknownTypeBody);
		((FCGI_UnknownTypeRecord *) response)->header
			= MakeHeader(FCGI_UNKNOWN_TYPE, FCGI_NULL_REQUEST_ID,
			len, 0);
		((FCGI_UnknownTypeRecord *) response)->body
			= MakeUnknownTypeBody(type);
	}
	if (write_it_all(data->reqDataPtr->ipcFd, response,
			FCGI_HEADER_LEN + paddedLen) < 0) {
		SetError(stream, OS_Errno);
		return -1;
	}

	return MGMT_RECORD;
}
 ~tCommand()
 {
     FreeParams();
 }