コード例 #1
0
/* this is where the thread get to do all its work */
void *
xsldbgThreadMain(void *)
{
 // int defaultArgc = 2;
 // char *defaultArgv[2];
 // int i;

  if (getThreadStatus() != XSLDBG_MSG_THREAD_INIT){
    fprintf(stderr, "xsldbg thread is not ready to be started. Or one is already running.\n");
    return NULL; /* we can't start more than one thread of xsldbg */
  }

//  defaultArgv[0] = xmlMemStrdup("xsldbg");
//  defaultArgv[1] = xmlMemStrdup("--shell");
  /*
  defaultArgv[2] = xmlMemStrdup("xsldoc.xsl");
  defaultArgv[3] = xmlMemStrdup("xsldoc.xml");
  */
/*  for (i = 0; i < defaultArgc; i++){
    if (defaultArgv[i] == NULL){
      fprintf(stderr, "Start thread failed. Unable to create xsldbg arguments\n");
      return NULL;
    }
  }
*/
    xsldbgSetThreadCleanupFunc(xsldbgThreadCleanupQt);
    setThreadStatus(XSLDBG_MSG_THREAD_RUN);
    setInputStatus(XSLDBG_MSG_AWAITING_INPUT);
    fprintf(stderr, "Starting thread\n");

    /* call the "main of xsldbg" found in debugXSL.c */
//    xsldbgMain(defaultArgc, defaultArgv);
    xsldbgMain(0,0);
    fprintf(stderr, "Stopping thread\n");
/*
  for (i = 0; i < defaultArgc; i++){
    xmlFree(defaultArgv[i]);
  }
*/

    setThreadStatus(XSLDBG_MSG_THREAD_DEAD);
    setInputStatus(XSLDBG_MSG_PROCESSING_INPUT);
    notifyXsldbgApp(XSLDBG_MSG_THREAD_DEAD, NULL);
    return NULL;
}
コード例 #2
0
void CLSValueSetpointEditor::updateInputStatus()
{
	setInputStatus( getInputStatus() );
}
コード例 #3
0
/**
 * qtXslDbgShellReadline:
 * @prompt:  the prompt value
 *
 * Read a string
 *
 * Returns a copy of the text inputed or NULL if EOF in stdin found.
 *    The caller is expected to free the returned string.
 */
xmlChar *
qtXslDbgShellReadline(xmlChar * prompt)
{

  const char *inputReadBuff;

  static char last_read[DEBUG_BUFFER_SIZE] = { '\0' };

  if (getThreadStatus() != XSLDBG_MSG_THREAD_RUN)
    {
#ifdef HAVE_READLINE
      xmlChar *line_read;

      /* Get a line from the user. */
      line_read = (xmlChar *) readline((char *) prompt);

      /* If the line has any text in it, save it on the history. */
      if (line_read && *line_read) {
        add_history((char *) line_read);
        strncpy((char*)last_read, (char*)line_read, DEBUG_BUFFER_SIZE - 1);
      } else {
        /* if only <Enter>is pressed then try last saved command line */
        line_read = (xmlChar *) xmlMemStrdup(last_read);
      }
      return (line_read);
#else
      char line_read[DEBUG_BUFFER_SIZE];

      if (prompt != NULL)
        xsltGenericError(xsltGenericErrorContext, "%s", prompt);
      if (!fgets(line_read, DEBUG_BUFFER_SIZE - 1, stdin))
        return (NULL);
      line_read[DEBUG_BUFFER_SIZE - 1] = 0;
      /* if only <Enter>is pressed then try last saved command line */
      if ((strlen(line_read) == 0) || (line_read[0] == '\n')) {
        strcpy(line_read, last_read);
      } else {
        strcpy(last_read, line_read);
      }
      return (xmlChar *) xmlMemStrdup(line_read);
#endif

    }
  else{

    setInputStatus(XSLDBG_MSG_AWAITING_INPUT);
    notifyXsldbgApp(XSLDBG_MSG_AWAITING_INPUT, NULL);

    while (getInputReady() == 0){
      usleep(10000);
      /* have we been told to die */
      if (getThreadStatus() ==  XSLDBG_MSG_THREAD_STOP){
	fprintf(stderr, "About to stop thread\n");
	xslDebugStatus = DEBUG_QUIT;
	return NULL;
      }
    }

    setInputStatus(XSLDBG_MSG_READ_INPUT);
    inputReadBuff =  getFakeInput();
    if(inputReadBuff){
      notifyXsldbgApp(XSLDBG_MSG_READ_INPUT, inputReadBuff);
      return (xmlChar*)xmlMemStrdup(inputReadBuff);
    }else{
      return NULL;
    }
  }
}