Esempio n. 1
0
void TransTableS::Add(
  const int tricks,
  const int hand,
  const unsigned short aggrTarget[],
  const unsigned short ourWinRanks[],
  const nodeCardsType& first,
  const bool flag)
{
  BuildSOP(ourWinRanks, aggrTarget, first, suitLengths[tricks],
           tricks, hand, flag);

  if (clearTTflag)
    ResetMemory(TT_RESET_MEMORY_EXHAUSTED);

  return;
}
Esempio n. 2
0
int main(void) {
    // initialize the device
    SYSTEM_Initialize();
    
    //Light show 
    debounce(2);
    PORTAbits.RA3 = 0;    //Led 4 
    debounce(5);
    PORTBbits.RB5 = 0;    //Led 3
    debounce(2);
    PORTBbits.RB7 = 0;    //Led 2
    debounce(1);
    PORTBbits.RB6 = 0;    //Led 1
    debounce(1);
    
    ResetMemory();
    
    while (1) {
        //All mighty while loop
        
        if(TransmitComplete){
            TransmitComplete = 0; 
            SetTo90();
            if(LocalMemory[0]== 0x01){
            MoveServo1_Degrees(LocalMemory[1]); 
            debounce(1);
            MoveServo4_Degrees(LocalMemory[4]);
            debounce(1);
            MoveServo3_Degrees(LocalMemory[3]);
            debounce(1);
            MoveServo2_Degrees(LocalMemory[2]);
            debounce(1);
            MoveServo5_Degrees(LocalMemory[5]);
            ResetMemory();  
            }
            else if(LocalMemory[0]== 0x02){
                
                switch(LocalMemory[1]){
                    case 1: GrabBlock();
                        break;
                    case 2: break;
                    case 3: break;
                    case 4: break;
                    case 5: break;
                            
                    
                }
            }
            
        }
        
        if(PORTAbits.RA0 == 1){        //S1 pressed
            S1++; 
            if(S1==10)
                                     //Overflow Condition~No State 9
                S1 = 1; 
            
            debounce(10);
            StateMaker(S1);         //Set the LEDs 
        }
        
        if(PORTAbits.RA2 == 1){          //S2 pressed 
            
            PORTBbits.RB6 = 1;        //Signifies selection with blinking of light
            debounce(5);
            PORTBbits.RB6 = 0;
            debounce(3); 
            PORTBbits.RB6 = 1;
            debounce(2);
            PORTBbits.RB6 = 0;
            debounce(1); 
            PORTBbits.RB6 = 1;
            
            MakeSelection(S1); 
            
            PORTBbits.RB6 = 1;        //Signifies end of selection with blinking of light
            debounce(5);
            PORTBbits.RB6 = 0;
            debounce(3); 
            PORTBbits.RB6 = 1;
            debounce(2);
            PORTBbits.RB6 = 0;
            debounce(1); 
            PORTBbits.RB6 = 1;
            debounce(1);
            PORTBbits.RB6 = 0; 
          
        }
    }
    return -1;
}
Esempio n. 3
0
int cRssParser::DownloadAndParse(const char *urlP)
{
  CURL *curl_handle;

  // Clear items list and initialize depth
  itemsM.Clear();
  depthS = 0;
  ResetMemory();

  // Init the curl session
  curl_global_init(CURL_GLOBAL_ALL);
  curl_handle = curl_easy_init();

  // Specify URL to get
  curl_easy_setopt(curl_handle, CURLOPT_URL, urlP);

  // Specify HTTP proxy: my.proxy.com:80
  if (RssReaderConfig.IsUseProxy()) {
     curl_easy_setopt(curl_handle, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
     curl_easy_setopt(curl_handle, CURLOPT_PROXY, RssReaderConfig.GetHttpProxy());
     }

  // Send all data to this function
  curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);

  // Set maximum file size to get (bytes)
  curl_easy_setopt(curl_handle, CURLOPT_MAXFILESIZE, 1048576L);

  // No progress meter
  curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1L);

  // No signaling
  curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1L);

  // Follow location
  curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1L);

  // Set timeout to 15 seconds
  curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, 15L);

  // Pass our 'data' struct to the callback function
  curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&dataM);

  // Some servers don't like requests that are made without a user-agent field
  curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, *cString::sprintf("vdr-%s/%s", PLUGIN_NAME_I18N, VERSION));

  // Get it!
  if (curl_easy_perform(curl_handle) != 0) {
     // Cleanup curl stuff
     curl_easy_cleanup(curl_handle);
     ResetMemory();
     error("%s (%s) Couldn't download the stream", __PRETTY_FUNCTION__, urlP);
     return (RSS_DOWNLOAD_ERROR);
     }

  if (dataM.size) {
     // Only for debug dump
     if (RssReaderConfig.IsTraceMode(cRssReaderConfig::eTraceModeDebug15)) {
        int fd;
        char tmpname[NAME_MAX];
        strn0cpy(tmpname, TMPDIR "/vdr-" PLUGIN_NAME_I18N ".XXXXXX", sizeof(tmpname));
        fd = mkstemp(tmpname);
        if (fd >= 0) {
           if (write(fd, dataM.memory, dataM.size) != (ssize_t)dataM.size)
              error("%s (%s) Couldn't write debug dump correctly into '%s'", __PRETTY_FUNCTION__, urlP, tmpname);
           else
              debug15("%s (%s) Wrote debug dump into '%s'", __PRETTY_FUNCTION__, urlP, tmpname);
           close(fd);
           }
        else
           error("%s (%s) Couldn't open file '%s'", __PRETTY_FUNCTION__, urlP, tmpname);
        }

     // Setup expat
     XML_Parser p = XML_ParserCreate(NULL);
     if (!p) {
        // Cleanup curl stuff
        curl_easy_cleanup(curl_handle);
        ResetMemory();
        error("%s (%s) Couldn't allocate memory for parser", __PRETTY_FUNCTION__, urlP);
        return (RSS_UNKNOWN_ERROR);
        }
     XML_SetElementHandler(p, StartHandler, EndHandler);
     XML_SetCharacterDataHandler(p, DataHandler);
     XML_SetUnknownEncodingHandler(p, UnknownEncodingHandler, NULL);

     if (XML_Parse(p, dataM.memory, (int)dataM.size, XML_TRUE) == XML_STATUS_ERROR) {
        // Cleanup curl stuff
        curl_easy_cleanup(curl_handle);
        ResetMemory();
        error("%s (%s) Parse error at line %ld: %s", __PRETTY_FUNCTION__, urlP, XML_GetCurrentLineNumber(p), XML_ErrorString(XML_GetErrorCode(p)));
        return (RSS_PARSING_ERROR);
        }
     }

  // Cleanup curl stuff
  curl_easy_cleanup(curl_handle);
  ResetMemory();

  return (RSS_PARSING_OK);
}
Esempio n. 4
0
cRssParser::~cRssParser()
{
  ResetMemory();
}