DesignFlowStep_Status HDLFunctionDeclFix::Exec()
{
   bool changed_tree = false;
   const tree_managerRef TM = AppM->get_tree_manager();
   const auto hdl_writer_type = static_cast<HDLWriter_Language>(parameters->getOption<unsigned int>(OPT_writer_language));
   const auto hdl_writer = language_writer::create_writer(hdl_writer_type, GetPointer<HLS_manager>(AppM)->get_HLS_target()->get_technology_manager(), parameters);
   const auto hdl_reserved_names = hdl_writer->GetHDLReservedNames();
   std::remove_const<decltype(hdl_reserved_names)>::type found_names;
   if(hdl_writer_type == HDLWriter_Language::VHDL)
   {
      for(const auto hdl_reserved_name : hdl_reserved_names)
      {
         found_names.insert(boost::to_upper_copy<std::string>(hdl_reserved_name));
      }
   }
   else
   {
      found_names = hdl_reserved_names;
   }

   for(const auto function : TM->GetAllFunctions())
   {
      auto fd = GetPointer<function_decl>(TM->get_tree_node_const(function));
      if(not fd->name)
         continue;
      auto in = GetPointer<identifier_node>(GET_NODE(fd->name));
      const auto identifier = hdl_writer_type == HDLWriter_Language::VHDL ? boost::to_upper_copy<std::string>(in->strg) : in->strg;
      if(found_names.find(identifier) != found_names.end())
      {
         std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
         unsigned int var_decl_name_nid_test;
         unsigned var_decl_unique_id=0;
         do
         {
            IR_schema[TOK(TOK_STRG)] = in->strg + STR(var_decl_unique_id++);
            var_decl_name_nid_test = TM->find(identifier_node_K, IR_schema);
         } while(var_decl_name_nid_test);
         found_names.insert(in->strg + STR(var_decl_unique_id - 1));
         unsigned int var_decl_name_nid = TM->new_tree_node_id();
         TM->create_tree_node(var_decl_name_nid, identifier_node_K, IR_schema);
         IR_schema.clear();
         tree_nodeRef tr_new_id = TM->GetTreeReindex(var_decl_name_nid);
         fd->name = tr_new_id;
      }
      else
      {
         found_names.insert(identifier);
      }
   }
   return changed_tree ? DesignFlowStep_Status::SUCCESS : DesignFlowStep_Status::UNCHANGED;

}
示例#2
0
bool CPrsBDF::Parse( const char *pcFont )
{
#define TOK(T) TPairTokenNameID( #T, PBDF_TOKEN_##T )
	static const TPairTokenNameID m_aoToken_[] = 
	{
		TOK( STARTFONT ),
		TOK( COMMENT ),
		TOK( CONTENTVERSION ),
		TOK( FONT ),
		TOK( SIZE ),
		TOK( FONTBOUNDINGBOX ),
		TOK( METRICSSET ),
		TOK( SWIDTH ),
		TOK( DWIDTH ),
		TOK( SWIDTH1 ),
		TOK( DWIDTH1 ),
		TOK( VVECTOR ),
		TOK( STARTPROPERTIES ),
		TOK( ENDPROPERTIES ),
		TOK( CHARS ),
		TOK( STARTCHAR ),
		TOK( ENCODING ),
		TOK( BBX ),
		TOK( BITMAP ),
		TOK( ENDCHAR ),
		TOK( ENDFONT )
	};
	static const unsigned int uiTokenNum = sizeof( m_aoToken_ ) / sizeof( TPairTokenNameID );
	CStr oStrFontFile( pcFont );
	const int iFontSize = oStrFontFile.GetSize();
	int iPropertiesStartPos = -1;
	CGlyph oGylphNew;
	CGlyph *poGlyph = &m_oGlyphDefault;
	bool bIsReadingChar = false;
	
	Reset();
	
	PBDF_LOG( "parse: start\n" );
	
	int iPos = 0;
	while( iPos < iFontSize )
	{
		int iEndOfLine = oStrFontFile.Find( iPos, PBDF_NEWLINE );
		if( iEndOfLine < 0 )
			iEndOfLine = iFontSize;
		
		CStr oStrLine = oStrFontFile.GetSub( iPos, iEndOfLine - iPos );
		RemoveLeadingSpace( oStrLine );
		
		//PBDF_LOG( "line: %s", oStrLine.GetData() );
		//PBDF_LOG( "line_size: %s", oStrLine.GetSize() );
		
		unsigned int uiTokenNext = PBDF_TOKEN_NONE;
		
		for( unsigned int t=0; t<uiTokenNum; ++t )
		{
			CStr oStrToken = m_aoToken_[t].GetFirst() ;
			const unsigned int uiTokenSize = oStrToken.GetSize();
			
			//PBDF_LOG( "token: %s", oStrToken.GetData() );
			
			int iPosToken = oStrLine.Find( 0, oStrToken );
			if( iPosToken != 0 ) 
				continue;
			
			// Danach müssen Leerzeichen oder das Ende folgen!
			const unsigned int uiPosNext = iPosToken + uiTokenSize;
			if( uiPosNext < oStrLine.GetSize() )
			{
				const char cNext = oStrLine[ uiPosNext ];
				if( !( cNext == ' ' || cNext == '\t' ) )
					continue;
			}
			
			if( iPosToken >= 0 )
			{
				oStrLine.Del( 0, uiTokenSize );
				RemoveLeadingSpace( oStrLine );
				uiTokenNext = m_aoToken_[t].GetSecond();
				PBDF_LOG( "token: %s\n", oStrToken.GetData() );
				break;
			}
		}
		
		if( uiTokenNext != PBDF_TOKEN_NONE )
		{
			switch( uiTokenNext )
			{
			case PBDF_TOKEN_STARTFONT:
				ReadValue( oStrLine, &m_dVersion );
				PBDF_LOG( "version: %g\n", m_dVersion );
			break;
			case PBDF_TOKEN_COMMENT:
			break;
			case PBDF_TOKEN_CONTENTVERSION: // optional
				ReadValue( oStrLine, &m_iContentVersion );
				PBDF_LOG( "content_version: %d\n", m_iContentVersion );
			break;
			case PBDF_TOKEN_FONT:
				ReadValue( oStrLine, &m_oStrFont );
				PBDF_LOG( "font: %s\n", m_oStrFont.GetData() );
			break;
			case PBDF_TOKEN_SIZE:
				ReadValue( oStrLine, &m_iPointSize );
				PBDF_LOG( "point_size: %d\n", m_iPointSize );
				RemoveNextWord( oStrLine );
				ReadValue( oStrLine, &m_iResX );
				PBDF_LOG( "res_x: %d\n", m_iResX );
				RemoveNextWord( oStrLine );
				ReadValue( oStrLine, &m_iResY );
				PBDF_LOG( "res_y: %d\n", m_iResY );
			break;
			case PBDF_TOKEN_FONTBOUNDINGBOX:
				ReadValue( oStrLine, &m_iBBX );
				PBDF_LOG( "bounding_box_x: %d\n", m_iBBX );
				RemoveNextWord( oStrLine );
				ReadValue( oStrLine, &m_iBBY );
				PBDF_LOG( "bounding_box_y: %d\n", m_iBBY );
				RemoveNextWord( oStrLine );
				ReadValue( oStrLine, &m_iOffX );
				PBDF_LOG( "offset_y: %d\n", m_iOffX );
				RemoveNextWord( oStrLine );
				ReadValue( oStrLine, &m_iOffY );
				PBDF_LOG( "offset_x: %d\n", m_iOffY );
				RemoveNextWord( oStrLine );
			break;
			case PBDF_TOKEN_METRICSSET: // optional
				ReadValue( oStrLine, &m_iMetricsSet );
				PBDF_LOG( "metrics_set: %d\n", m_iMetricsSet );
			break;
			case PBDF_TOKEN_SWIDTH:
				ReadValue( oStrLine, &poGlyph->m_dSX );
				PBDF_LOG( "sx: %g\n", poGlyph->m_dSX );
				RemoveNextWord( oStrLine );
				ReadValue( oStrLine, &poGlyph->m_dSY );
				PBDF_LOG( "sy: %g\n", poGlyph->m_dSY );
			break;
			case PBDF_TOKEN_DWIDTH:
				ReadValue( oStrLine, &poGlyph->m_iDX );
				PBDF_LOG( "dx: %d\n", poGlyph->m_iDX );
				RemoveNextWord( oStrLine );
				ReadValue( oStrLine, &poGlyph->m_iDY );
				PBDF_LOG( "dy: %d\n", poGlyph->m_iDY );
			break;
			case PBDF_TOKEN_SWIDTH1:
				ReadValue( oStrLine, &poGlyph->m_dSX1 );
				PBDF_LOG( "sx1: %g\n", poGlyph->m_dSX1 );
				RemoveNextWord( oStrLine );
				ReadValue( oStrLine, &poGlyph->m_dSY1 );
				PBDF_LOG( "sy1: %g\n", poGlyph->m_dSY1 );
			break;
			case PBDF_TOKEN_DWIDTH1:
				ReadValue( oStrLine, &poGlyph->m_iDX1 );
				PBDF_LOG( "dx1: %d\n", poGlyph->m_iDX1 );
				RemoveNextWord( oStrLine );
				ReadValue( oStrLine, &poGlyph->m_iDY1 );
				PBDF_LOG( "dy1: %d\n", poGlyph->m_iDY1 );
			break;
			case PBDF_TOKEN_VVECTOR: // optional
				ReadValue( oStrLine, &poGlyph->m_dVVX );
				PBDF_LOG( "vvx: %g\n", poGlyph->m_dVVX );
				RemoveNextWord( oStrLine );
				ReadValue( oStrLine, &poGlyph->m_dVVY );
				PBDF_LOG( "vvy: %g\n", poGlyph->m_dVVY );
			break;
			case PBDF_TOKEN_STARTPROPERTIES: // optional
				ReadValue( oStrLine, &m_iProperties );
				PBDF_LOG( "properties: %d\n", m_iProperties );
				iPropertiesStartPos = iEndOfLine + 1;
			break;
			case PBDF_TOKEN_ENDPROPERTIES: // optional
				if( iPropertiesStartPos < 0 )
					break;
				m_oStrProperties = oStrFontFile.GetSub( 
					iPropertiesStartPos, iPos - iPropertiesStartPos );
				PBDF_LOG( "properties:\n%s\n", m_oStrProperties.GetData() );
			break;
			case PBDF_TOKEN_CHARS:
				ReadValue( oStrLine, &m_iChars );
				PBDF_LOG( "chars: %d\n", m_iChars );
				
				poGlyph = &oGylphNew;
			break;
			case PBDF_TOKEN_STARTCHAR:
				if( bIsReadingChar )
				{
					PBDF_ERROR( "glyph %s\n", oStrLine.GetData() );
					return false;
				}
				bIsReadingChar = true;
				
				oGylphNew = m_oGlyphDefault;
				ReadValue( oStrLine, &poGlyph->m_oStrName );
				PBDF_LOG( "char_name: %s\n", poGlyph->m_oStrName.GetData() );
				PBDF_LOG( "char_num: %d\n", m_oArrGlyph.GetSize() );
			break;
			case PBDF_TOKEN_ENCODING:
				ReadValue( oStrLine, &poGlyph->m_iEncoding0  );
				PBDF_LOG( "encoding0: %d\n", poGlyph->m_iEncoding0 );
				RemoveNextWord( oStrLine );
				if( !oStrLine.GetSize() )
					break;
				ReadValue( oStrLine, &poGlyph->m_iEncoding1 );
				PBDF_LOG( "encoding1: %d\n", poGlyph->m_iEncoding1 );
			break;
			case PBDF_TOKEN_BBX:
				ReadValue( oStrLine, &poGlyph->m_iBBX );
				PBDF_LOG( "bbx: %d\n", poGlyph->m_iBBX );
				RemoveNextWord( oStrLine );
				ReadValue( oStrLine, &poGlyph->m_iBBY );
				PBDF_LOG( "bby: %d\n", poGlyph->m_iBBY );
				RemoveNextWord( oStrLine );
				ReadValue( oStrLine, &poGlyph->m_iBBOffX );
				PBDF_LOG( "bb_off_x: %d\n", poGlyph->m_iBBOffX );
				RemoveNextWord( oStrLine );
				ReadValue( oStrLine, &poGlyph->m_iBBOffY );
				PBDF_LOG( "bb_off_y: %d\n", poGlyph->m_iBBOffY );
			break;
			case PBDF_TOKEN_BITMAP:
			{
				CArray<unsigned char> oArrBitmap;
				const int iHeight = poGlyph->m_iBBY;
				
				// Da hier sowieso kein Token folgt, kann ohne weiteres
				// auch über das Zeilenende hinaus gearbeitet werden.
				int iPosBegin = iEndOfLine + 1;
				int l = 0;
				
				poGlyph->m_oArrBitmap.Clear();
				
				while( l < iHeight )
				{
					const int iEOL = oStrFontFile.Find( iPosBegin, PBDF_NEWLINE ); 
					if( iEOL < 0 )
						break;
					CStr oCodeLine = oStrFontFile.GetSub( iPosBegin, iEOL - iPosBegin );
					ReadValue( oCodeLine, &oArrBitmap );
					poGlyph->m_oArrBitmap.Append( oArrBitmap );
					iPosBegin = iEOL + 1;
					++l;
				}		
			}
			break;
			case PBDF_TOKEN_ENDCHAR:
				m_oArrGlyph.Append( oGylphNew );
				bIsReadingChar = false;
			break;
			case PBDF_TOKEN_ENDFONT:
				PBDF_LOG( "glyph_count: %d\n", m_oArrGlyph.GetSize() );
				if( m_oArrGlyph.GetSize() != (unsigned int)m_iChars )
				{
					PBDF_ERROR( "glyph_cout: %d != %d", m_oArrGlyph.GetSize(), m_iChars );
					return false;
				}
			break;
			};
		}
		iPos = iEndOfLine + 1; // falls "\r\n"??
	}
	
	PBDF_LOG( "parse: end\n" );
	return true;
}
示例#3
0
文件: error.C 项目: seyko2/cfront-3
int error(int t, loc* lc, const char* s, const ea& a0, const ea& a1, const ea& a2, const ea& a3)
/*
	"int" not "void" because of "pch" in lex.c

	legal error types are:

	not counted in error count:

		'w'		warning
		'd'		debug
		'D'		debug -- no prefix
		'C'		text -- line no. and no newline
		'c'		text -- no line no. and no newline

	counted in error count:

		's'		"not implemented" message
		'l'		"compiler limit exceeded" message
    		0		error 
    		'e'		error -- no newline
    		'i'		internal error (causes abort)
		't'		error while printing error message
*/
{
	if (suppress_error && t!='i' && t!='d') return 0;

	if (in_error++)
		if (t == 't')
			t = 'i';
		else if (4 < in_error) {
			fprintf(stderr,"\nOops!, error while handling error\n");
			ext(13);
		}

	FILE * of = out_file;
	out_file = stderr;

	if (!scan_started || t=='t')
		putch('\n');
	else if (lc != &dummy_loc) {
		if(t != 'D' && t != 'c') lc->put(out_file);
	} else {
		if(t != 'D' && t != 'c') print_loc();
	}

	int user_error = 0;

	switch (t) {
        case 'C':
        case 'c':
		break;
    	case 'e':
		user_error = 1;
		// no break
    	case 0:
		putstring("error: ");
		user_error += 1;
		break;
        case 'd':
		putstring("DEBUG: ");
        case 'D':
		break;
        case 'w':
//		no_of_warnings++;
		putstring("warning: ");
		break;
        case 'l':
		putstring("compiler limit exceeded: ");
		break;
        case 's':
		putstring("sorry, not implemented: ");
		user_error = 1;
		break;
        case 'i':
		if (error_count++) {
			fprintf(out_file,"sorry, cannot recover from earlier errors\n");
			out_file = of; // restore for fflush()
#ifdef TEST_SUITE
			ext(INTERNAL2);
#else
			ext(INTERNAL);
#endif
		}
		else
			fprintf(out_file,"internal %s error: ",prog_name);
        }

	ea argv[4];
	ea* a = argv;
	argv[0] = a0;
	argv[1] = a1;
	argv[2] = a2;
	argv[3] = a3;

	int c;

	while (c = *s++) {
		if ('A'<=c && c<='Z')
			putstring(abbrev_tbl[c-'A']);
		else if (c == '%') {
			switch (c = *s++) {
			case 'k':	// TOK assumed passed as an int
			{	int x = TOK(a->i);
				if (0 < x && x<=MAXTOK && keys[x])
					fprintf(out_file," %s",keys[x]);
				else
					fprintf(out_file," token(%d)",x);
				break;
			}
			case 't':	// Ptype 
			{	Ptype tt = Ptype(a->p);
				if (tt == 0) break;

				putch(' ');
			
				int nt = ntok;
				emode = 1;
				tt->dcl_print(0);
				emode = 0;
				ntok = nt;
				break;
			}
			case 'n':	// Pname
			{	Pname nn = Pname(a->p);
				if (nn && nn->string) {
					// suppress generated class names:
					if (nn->string[0]=='_'
					&& nn->string[1]=='_'
					&& nn->string[2]=='C') break;
					emode = 1;
					putch(' ');
					nn->print();
					emode = 0;
				}
				else
					putstring(" ?");
				break;
			}
			case 'p':	// pointer
			{	char* f = sizeof(char*)==sizeof(int)?" %d":" %ld";
				fprintf(out_file,f,a->p);
				break;
			}
			case 'a':	// fully qualified function 
			{	Pname nn = Pname(a->p);
				if (nn->tp->base!=FCT && nn->tp->base!=OVERLOAD)
					error('i',"%n not function",nn);
				if (nn && nn->string) {
					// suppress generated class names:
					if (nn->string[0]=='_'
					&& nn->string[1]=='_'
					&& nn->string[2]=='C') break;
					emode = 1;
					putch(' ');
					nn->print(1);
					emode = 0;
				}
				else
					putstring(" ?");
				break;
			}
			case 'c':	// char assumed passed as an int
				putch((int)a->i);
				break;

			case 'd':	// int
				fprintf(out_file," %d",a->i);
				break;

			case 'o':	// int
				fprintf(out_file," 0%o",a->i);
				break;

			case 's':	// char*
				{
				char *s = ((char *)a->p);
				if ( s ) putst((char*)a->p);
				break;
				}
			}
			a++;
		}
		else
			putch(c);
	}

/*
	switch (t) {
	case 'd':
	case 't':
	case 'w':
		putch('\n');
		break;
	default:
*/
		if (t != 'c' && t != 'e' && t != 'C')
			print_context();
/*
	}
*/

	if (user_error) 
		basic_inst::head->print_error_loc(user_error==2);

	out_file = of; // restore before ext() for fflush()
	if (!scan_started && t!='d' && t!='w') ext(4);

        // now we may want to carry on 
	switch (t) {
	case 't':
		if (--in_error) {
			fflush(stderr);
			//fflush(out_file);
			return 0;
		}
	case 'i': 
		ext(INTERNAL);
	case 0:
	case 'e':
	case 'l':
	case 's':
#ifdef TEST_SUITE
		if (t == 's')
			ext(SORRY);
#endif
		if (MAXERR<++error_count) {
			fprintf(stderr,"Sorry, too many errors\n");
			ext(7);
		}
	}

	in_error = 0;
	fflush(stderr);
	//fflush(out_file);
	return 0;
}
示例#4
0
Request *requestNew(char *buff) {
    Request *request = malloc(sizeof(Request));

    char *segment, *bs;

    request->method      = UNKNOWN_METHOD;
    request->path        = NULL;
    request->uri         = NULL;
    request->queryString = NULL;
    request->postBody    = NULL;
    request->headers     = NULL;
    request->cookies     = NULL;
    request->account     = NULL;

    // METHOD
    TOK(buff, " \t");

    if      (strcmp(segment, "OPTIONS") == 0) request->method = OPTIONS;
    else if (strcmp(segment, "GET")     == 0) request->method = GET;
    else if (strcmp(segment, "HEAD")    == 0) request->method = HEAD;
    else if (strcmp(segment, "POST")    == 0) request->method = POST;
    else if (strcmp(segment, "PUT")     == 0) request->method = PUT;
    else if (strcmp(segment, "DELETE")  == 0) request->method = DELETE;
    else if (strcmp(segment, "TRACE")   == 0) request->method = TRACE;
    else if (strcmp(segment, "CONNECT") == 0) request->method = CONNECT;
    else goto fail;

    // PATH
    TOK(NULL, " \t");

    request->path = bsNew(segment);
    request->uri  = bsNew(segment);

    if (strchr(request->path, '#') != NULL)
        goto fail;

    // VERSION
    TOK(NULL, "\n");

    if (strncmp(segment, "HTTP/1.0", 8) != 0 &&
        strncmp(segment, "HTTP/1.1", 8) != 0)
        goto fail;

    // HEADERS
    request->headers = parseHeaders(segment);

    // BODY
    bs = kvFindList(request->headers, "Content-Type");

    if (bs != NULL && strncmp(bs, "application/x-www-form-urlencoded", 33) == 0) {
        segment = strtok(NULL, "\0");

        if (segment == NULL)
            goto fail;

        request->postBody = parseQS(segment);
    }

    // QUERYSTRING
    segment = strchr(request->path, '?');

    if (segment != NULL) {
        request->uri = bsNewLen(request->path, segment - request->path);
        request->queryString = parseQS(segment + 1);

        if (request->queryString == NULL)
            goto fail;
    }

    // COOKIES
    segment = kvFindList(request->headers, "Cookie");

    if (segment != NULL) {
        request->cookies = parseCookies(segment);

        if (request->cookies == NULL)
            goto fail;
    }

    return request;

fail:
    requestDel(request);

    return NULL;
}
示例#5
0
enum http_rc_e
action_forward (struct req_args_s *args)
{
	const char *id = OPT("id");
	const char *action = TOK("ACTION");

	if (!id)
		return _reply_format_error (args, BADREQ("Missing SRVID"));
	if (!action)
		return _reply_format_error (args, BADREQ("Missing action"));

	GError *err = NULL;
	if (!g_ascii_strcasecmp (action, "flush")) {
		err = sqlx_remote_execute_FLUSH (id);
		if (!err)
			return _reply_success_json (args, NULL);
		return _reply_common_error (args, err);
	}
	if (!g_ascii_strcasecmp (action, "reload")) {
		err = sqlx_remote_execute_RELOAD (id);
		if (!err)
			return _reply_success_json (args, NULL);
		return _reply_common_error (args, err);
	}
	if (!g_ascii_strcasecmp (action, "kill")) {
		GByteArray *encoded = message_marshall_gba_and_clean (
				metautils_message_create_named("REQ_KILL"));
		err = gridd_client_exec (id, 1.0, encoded);
		if (err)
			return _reply_common_error (args, err);
		return _reply_success_json (args, NULL);
	}
	if (!g_ascii_strcasecmp (action, "ping")) {
		args->rp->no_access();
		GByteArray *encoded = message_marshall_gba_and_clean (
				metautils_message_create_named("REQ_PING"));
		err = gridd_client_exec (id, 1.0, encoded);
		if (err)
			return _reply_common_error (args, err);
		return _reply_success_json (args, NULL);
	}
	if (!g_ascii_strcasecmp (action, "lean-glib")) {
		MESSAGE req = metautils_message_create_named("REQ_LEAN");
		metautils_message_add_field_str(req, "LIBC", "1");
		metautils_message_add_field_str(req, "THREADS", "1");
		GByteArray *encoded = message_marshall_gba_and_clean (req);
		err = gridd_client_exec (id, 1.0, encoded);
		if (err)
			return _reply_common_error (args, err);
		return _reply_success_json (args, NULL);
	}

	if (!g_ascii_strcasecmp (action, "lean-sqlx")) {
		GByteArray *encoded = message_marshall_gba_and_clean (
				metautils_message_create_named(NAME_MSGNAME_SQLX_LEANIFY));
		err = gridd_client_exec (id, 1.0, encoded);
		if (err)
			return _reply_common_error (args, err);
		return _reply_success_json (args, NULL);
	}

	if (!g_ascii_strcasecmp (action, "version")) {
		args->rp->no_access();
		MESSAGE req = metautils_message_create_named("REQ_VERSION");
		GByteArray *encoded = message_marshall_gba_and_clean (req);
		gchar *packed = NULL;
		err = gridd_client_exec_and_concat_string (id, 1.0, encoded, &packed);
		if (err) {
			g_free0 (packed);
			return _reply_common_error (args, err);
		}

		/* TODO(jfs): quite duplicated from _reply_json() but the original
		   was not suitable. */
		args->rp->set_status (200, "OK");
		args->rp->set_body_bytes (g_bytes_new_take((guint8*)packed, strlen(packed)));
		args->rp->finalize ();
		return HTTPRC_DONE;
	}

	if (!g_ascii_strcasecmp (action, "handlers")) {
		args->rp->no_access();
		MESSAGE req = metautils_message_create_named("REQ_HANDLERS");
		GByteArray *encoded = message_marshall_gba_and_clean (req);
		gchar *packed = NULL;
		err = gridd_client_exec_and_concat_string (id, 1.0, encoded, &packed);
		if (err) {
			g_free0 (packed);
			return _reply_common_error (args, err);
		}

		/* TODO(jfs): quite duplicated from _reply_json() but the original
		   was not suitable. */
		args->rp->set_status (200, "OK");
		args->rp->set_body_bytes (g_bytes_new_take((guint8*)packed, strlen(packed)));
		args->rp->finalize ();
		return HTTPRC_DONE;
	}

	return _reply_common_error (args, BADREQ("unexpected action"));
}
示例#6
0
enum http_rc_e
action_cache_set_ttl_low (struct req_args_s *args)
{
	hc_resolver_set_ttl_services (resolver, atoi (TOK ("COUNT")));
	return _reply_success_json (args, NULL);
}
示例#7
0
enum http_rc_e
action_cache_set_max_high (struct req_args_s *args)
{
	hc_resolver_set_max_csm0 (resolver, atoi (TOK ("COUNT")));
	return _reply_success_json (args, NULL);
}