Example #1
0
int main(int argc, char **argv)
{
  int g,rep;

  setup_io();

  // Set GPIO pins 7-11 to output
  for (g=7; g<=11; g++)
  {
    set_out(g);
  }

  for (rep=0; rep<10; rep++)
  {
     for (g=7; g<=11; g++)
     {
       switch_gpio(1, g);
       sleep(1);
     }
     for (g=7; g<=11; g++)
     {
       switch_gpio(0, g);
       sleep(1);
     }
  }

  return 0;

} // main
Example #2
0
	inline void set_buffers(zstream_handle stream,
	                        const char * in_first, std::size_t in_size,
	                        char * out_first, std::size_t out_size)
	{
		set_in(stream, in_first, in_size);
		set_out(stream, out_first, out_size);
	}
Example #3
0
	inline void set_buffers(zstream_handle stream,
	                        const char * in_first, const char * in_last,
	                        char * out_first, char * out_last)
	{
		set_in(stream, in_first, in_last);
		set_out(stream, out_first, out_last);
	}
Example #4
0
Item *led(List *expression)
{
    uint8_t led = eval_as_string(second(expression))[0] == 'R' ? 0 : 1;
    Item *value = third(expression);
    led_mode(led, value ? LEDMANUAL : LEDSTATE_OFF);
    set_out(leds[led], eval_as_uint8(value));
    return 0;
}
Example #5
0
bool TestFuzzer::Init() {
    BEGIN_HELPER;
    Reset();

    out_ = open_memstream(&outbuf_, &outbuflen_);
    ASSERT_NONNULL(out_);

    err_ = open_memstream(&errbuf_, &errbuflen_);
    ASSERT_NONNULL(err_);

    // Configure base object
    set_root(fixture_.path());
    set_out(out_);
    set_err(err_);

    END_HELPER;
}
Example #6
0
Vector3iSet GraspSet::intersection(const Vector3iSet& set1, const Vector3iSet& set2) const
{
  if (set2.size() < set1.size())
  {
    return intersection(set2, set1);
  }

  Vector3iSet set_out(set1.size());

  for (Vector3iSet::const_iterator it = set1.begin(); it != set1.end(); it++)
  {
    if (set2.find(*it) != set2.end())
    {
      set_out.insert(*it);
    }
  }

  return set_out;
}
Example #7
0
void exec_stream_t::start( std::string const & program, std::string const & arguments )
{
    if( !close() ) {
        throw exec_stream_t::error_t( "exec_stream_t::start: previous child process has not yet terminated" );
    }

    pipe_t in;
    pipe_t out;
    pipe_t err;
    set_stdhandle_t set_in( STD_INPUT_HANDLE, in.r() );
    set_stdhandle_t set_out( STD_OUTPUT_HANDLE, out.w() );
    set_stdhandle_t set_err( STD_ERROR_HANDLE, err.w() );
    HANDLE cp=GetCurrentProcess();
    if( !DuplicateHandle( cp, in.w(), cp, &m_impl->m_in_pipe, 0, FALSE, DUPLICATE_SAME_ACCESS ) ) {
        throw os_error_t( "exec_stream_t::start: unable to duplicate in handle" );
    }
    in.close_w();
    if( !DuplicateHandle( cp, out.r(), cp, &m_impl->m_out_pipe, 0, FALSE, DUPLICATE_SAME_ACCESS ) ) {
        throw os_error_t( "exec_stream_t::start: unable to duplicate out handle" );
    }
    out.close_r();
    if( !DuplicateHandle( cp, err.r(), cp, &m_impl->m_err_pipe, 0, FALSE, DUPLICATE_SAME_ACCESS ) ) {
        throw os_error_t( "exec_stream_t::start: unable to duplicate err handle" );
    }
    err.close_r();

    std::string command;
    command.reserve( program.size()+arguments.size()+3 );
    if( program.find_first_of( " \t" )!=std::string::npos ) {
        command+='"';
        command+=program;
        command+='"';
    }else
        command=program;
    if( arguments.size()!=0 ) {
        command+=' ';
        command+=arguments;
    }
    STARTUPINFOA si;
    ZeroMemory( &si, sizeof( si ) );
    si.cb=sizeof( si );
    PROCESS_INFORMATION pi;
    ZeroMemory( &pi, sizeof( pi ) );
    if( !CreateProcessA( 0, const_cast< char * >( command.c_str() ), 0, 0, TRUE, 0, 0, 0, &si, &pi ) ) {
        throw os_error_t( "exec_stream_t::start: CreateProcess failed.\n command line was: "+command );
    }

    m_impl->m_child_process=pi.hProcess;
    
    m_impl->m_in_buffer.clear();
    m_impl->m_out_buffer.clear();
    m_impl->m_err_buffer.clear();

    m_impl->m_in.clear();
    m_impl->m_out.clear();
    m_impl->m_err.clear();

    m_impl->m_out_thread.set_read_buffer_size( STREAM_BUFFER_SIZE );
    m_impl->m_out_thread.start_reader_thread( m_impl->m_out_pipe );

    m_impl->m_err_thread.set_read_buffer_size( STREAM_BUFFER_SIZE );
    m_impl->m_err_thread.start_reader_thread( m_impl->m_err_pipe );

    m_impl->m_in_thread.start_writer_thread( m_impl->m_in_pipe );
}
Example #8
0
/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
*/
static void yy_reduce(
  yyParser *yypParser,         /* The parser */
  int yyruleno                 /* Number of the rule by which to reduce */
){
  int yygoto;                     /* The next state */
  int yyact;                      /* The next action */
  YYMINORTYPE yygotominor;        /* The LHS of the rule reduced */
  yyStackEntry *yymsp;            /* The top of the parser's stack */
  int yysize;                     /* Amount to pop the stack */
  ParseARG_FETCH;
  yymsp = &yypParser->yystack[yypParser->yyidx];
#ifndef NDEBUG
  if( yyTraceFILE && yyruleno>=0 
        && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
    fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
      yyRuleName[yyruleno]);
  }
#endif /* NDEBUG */

  /* Silence complaints from purify about yygotominor being uninitialized
  ** in some cases when it is copied into the stack after the following
  ** switch.  yygotominor is uninitialized when a rule reduces that does
  ** not set the value of its left-hand side nonterminal.  Leaving the
  ** value of the nonterminal uninitialized is utterly harmless as long
  ** as the value is never used.  So really the only thing this code
  ** accomplishes is to quieten purify.  
  **
  ** 2007-01-16:  The wireshark project (www.wireshark.org) reports that
  ** without this code, their parser segfaults.  I'm not sure what there
  ** parser is doing to make this happen.  This is the second bug report
  ** from wireshark this week.  Clearly they are stressing Lemon in ways
  ** that it has not been previously stressed...  (SQLite ticket #2172)
  */
  /*memset(&yygotominor, 0, sizeof(yygotominor));*/
  yygotominor = yyzerominor;


  switch( yyruleno ){
  /* Beginning here are the reduction cases.  A typical example
  ** follows:
  **   case 0:
  **  #line <lineno> <grammarfile>
  **     { ... }           // User supplied code
  **  #line <lineno> <thisfile>
  **     break;
  */
      case 4: /* decl ::= REPORT TO STR */
#line 22 "cfg.y"
{set_report(ps,yymsp[0].minor.yy0);}
#line 739 "cfg.c"
        break;
      case 5: /* decl ::= LISTEN ON STR */
#line 23 "cfg.y"
{set_listen(ps,yymsp[0].minor.yy0);}
#line 744 "cfg.c"
        break;
      case 6: /* job ::= JOB LCURLY sbody RCURLY */
#line 24 "cfg.y"
{push_job(ps);}
#line 749 "cfg.c"
        break;
      case 9: /* kv ::= NAME STR */
#line 27 "cfg.y"
{set_name(ps,yymsp[0].minor.yy0);}
#line 754 "cfg.c"
        break;
      case 11: /* kv ::= DIR path */
#line 29 "cfg.y"
{set_dir(ps,yymsp[0].minor.yy0);}
#line 759 "cfg.c"
        break;
      case 12: /* kv ::= OUT path */
#line 30 "cfg.y"
{set_out(ps,yymsp[0].minor.yy0);}
#line 764 "cfg.c"
        break;
      case 13: /* kv ::= IN path */
#line 31 "cfg.y"
{set_in(ps,yymsp[0].minor.yy0);}
#line 769 "cfg.c"
        break;
      case 14: /* kv ::= ERR path */
#line 32 "cfg.y"
{set_err(ps,yymsp[0].minor.yy0);}
#line 774 "cfg.c"
        break;
      case 15: /* kv ::= USER STR */
#line 33 "cfg.y"
{set_user(ps,yymsp[0].minor.yy0);}
#line 779 "cfg.c"
        break;
      case 16: /* kv ::= ORDER STR */
#line 34 "cfg.y"
{set_ord(ps,yymsp[0].minor.yy0);}
#line 784 "cfg.c"
        break;
      case 17: /* kv ::= ENV STR */
#line 35 "cfg.y"
{set_env(ps,yymsp[0].minor.yy0);}
#line 789 "cfg.c"
        break;
      case 18: /* kv ::= ULIMIT STR STR */
      case 34: /* pairs ::= pairs STR STR */ yytestcase(yyruleno==34);
#line 36 "cfg.y"
{set_ulimit(ps,yymsp[-1].minor.yy0,yymsp[0].minor.yy0);}
#line 795 "cfg.c"
        break;
      case 20: /* kv ::= DISABLED */
#line 38 "cfg.y"
{set_dis(ps);  }
#line 800 "cfg.c"
        break;
      case 21: /* kv ::= WAIT */
#line 39 "cfg.y"
{set_wait(ps); }
#line 805 "cfg.c"
        break;
      case 22: /* kv ::= ONCE */
#line 40 "cfg.y"
{set_once(ps); }
#line 810 "cfg.c"
        break;
      case 23: /* kv ::= BOUNCE EVERY STR */
#line 41 "cfg.y"
{set_bounce(ps,yymsp[0].minor.yy0);}
#line 815 "cfg.c"
        break;
      case 25: /* cmd ::= path */
#line 43 "cfg.y"
{set_cmd(ps,yymsp[0].minor.yy0);}
#line 820 "cfg.c"
        break;
      case 26: /* cmd ::= path args */
#line 44 "cfg.y"
{set_cmd(ps,yymsp[-1].minor.yy0);}
#line 825 "cfg.c"
        break;
      case 27: /* path ::= STR */
      case 30: /* arg ::= STR */ yytestcase(yyruleno==30);
#line 45 "cfg.y"
{yygotominor.yy0=yymsp[0].minor.yy0;}
#line 831 "cfg.c"
        break;
      case 28: /* args ::= args arg */
      case 29: /* args ::= arg */ yytestcase(yyruleno==29);
#line 46 "cfg.y"
{utarray_push_back(&ps->job->cmdv,&yymsp[0].minor.yy0);}
#line 837 "cfg.c"
        break;
      case 31: /* arg ::= QUOTEDSTR */
#line 49 "cfg.y"
{yygotominor.yy0=unquote(yymsp[0].minor.yy0);}
#line 842 "cfg.c"
        break;
      case 32: /* paths ::= paths path */
      case 33: /* paths ::= path */ yytestcase(yyruleno==33);
#line 50 "cfg.y"
{utarray_push_back(&ps->job->depv,&yymsp[0].minor.yy0);}
#line 848 "cfg.c"
        break;
      default:
      /* (0) file ::= decls */ yytestcase(yyruleno==0);
      /* (1) decls ::= decls job */ yytestcase(yyruleno==1);
      /* (2) decls ::= decls decl */ yytestcase(yyruleno==2);
      /* (3) decls ::= */ yytestcase(yyruleno==3);
      /* (7) sbody ::= sbody kv */ yytestcase(yyruleno==7);
      /* (8) sbody ::= kv */ yytestcase(yyruleno==8);
      /* (10) kv ::= CMD cmd */ yytestcase(yyruleno==10);
      /* (19) kv ::= ULIMIT LCURLY pairs RCURLY */ yytestcase(yyruleno==19);
      /* (24) kv ::= DEPENDS LCURLY paths RCURLY */ yytestcase(yyruleno==24);
      /* (35) pairs ::= */ yytestcase(yyruleno==35);
        break;
  };
  yygoto = yyRuleInfo[yyruleno].lhs;
  yysize = yyRuleInfo[yyruleno].nrhs;
  yypParser->yyidx -= yysize;
  yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
  if( yyact < YYNSTATE ){
#ifdef NDEBUG
    /* If we are not debugging and the reduce action popped at least
    ** one element off the stack, then we can push the new element back
    ** onto the stack here, and skip the stack overflow test in yy_shift().
    ** That gives a significant speed improvement. */
    if( yysize ){
      yypParser->yyidx++;
      yymsp -= yysize-1;
      yymsp->stateno = (YYACTIONTYPE)yyact;
      yymsp->major = (YYCODETYPE)yygoto;
      yymsp->minor = yygotominor;
    }else
#endif
    {
      yy_shift(yypParser,yyact,yygoto,&yygotominor);
    }
  }else{
    assert( yyact == YYNSTATE + YYNRULE + 1 );
    yy_accept(yypParser);
  }
}