コード例 #1
0
ファイル: t_gssexts.c プロジェクト: Brainiarc7/pbis
static OM_uint32
displayCanonName(OM_uint32 *minor, gss_name_t name, char *tag)
{
    gss_name_t canon;
    OM_uint32 major, tmp_minor;
    gss_buffer_desc buf;

    major = gss_canonicalize_name(minor, name,
                                  (gss_OID)gss_mech_krb5, &canon);
    if (GSS_ERROR(major)) {
        displayStatus("gss_canonicalize_name", major, *minor);
        return major;
    }

    major = gss_display_name(minor, canon, &buf, NULL);
    if (GSS_ERROR(major)) {
        displayStatus("gss_display_name", major, *minor);
        gss_release_name(&tmp_minor, &canon);
        return major;
    }

    printf("%s:\t%s\n", tag, (char *)buf.value);

    gss_release_buffer(&tmp_minor, &buf);
    gss_release_name(&tmp_minor, &canon);

    return GSS_S_COMPLETE;
}
コード例 #2
0
ファイル: t_saslname.c プロジェクト: Brainiarc7/pbis
static
OM_uint32 dumpMechAttrs(OM_uint32 *minor, gss_OID mech)
{
    OM_uint32 major, tmpMinor;
    gss_OID_set mech_attrs = GSS_C_NO_OID_SET;
    gss_OID_set known_attrs = GSS_C_NO_OID_SET;
    size_t i;

    major = gss_inquire_attrs_for_mech(minor, mech, &mech_attrs, &known_attrs);
    if (GSS_ERROR(major)) {
        displayStatus("gss_inquire_attrs_for_mech", major, *minor);
        return major;
    }

    printf("Mech attrs:  ");

    for (i = 0; i < mech_attrs->count; i++) {
        gss_buffer_desc name = GSS_C_EMPTY_BUFFER;
        gss_buffer_desc short_desc = GSS_C_EMPTY_BUFFER;
        gss_buffer_desc long_desc = GSS_C_EMPTY_BUFFER;

        major = gss_display_mech_attr(minor, &mech_attrs->elements[i],
                                      &name, &short_desc, &long_desc);
        if (GSS_ERROR(major)) {
            displayStatus("gss_display_mech_attr", major, *minor);
            continue;
        }
        printf("%.*s ", (int)name.length, (char *)name.value);
        gss_release_buffer(minor, &name);
        gss_release_buffer(minor, &short_desc);
        gss_release_buffer(minor, &long_desc);
    }
    printf("\n");

    printf("Known attrs: ");

    for (i = 0; i < known_attrs->count; i++) {
        gss_buffer_desc name = GSS_C_EMPTY_BUFFER;
        gss_buffer_desc short_desc = GSS_C_EMPTY_BUFFER;
        gss_buffer_desc long_desc = GSS_C_EMPTY_BUFFER;

        major = gss_display_mech_attr(minor, &known_attrs->elements[i],
                                      &name, &short_desc, &long_desc);
        if (GSS_ERROR(major)) {
            displayStatus("gss_display_mech_attr", major, *minor);
            continue;
        }
        printf("%.*s ", (int)name.length, (char *)name.value);
        gss_release_buffer(minor, &name);
        gss_release_buffer(minor, &short_desc);
        gss_release_buffer(minor, &long_desc);
    }
    printf("\n");

    gss_release_oid_set(&tmpMinor, &mech_attrs);
    gss_release_oid_set(&tmpMinor, &known_attrs);

    return GSS_S_COMPLETE;
}
コード例 #3
0
ファイル: t_gssexts.c プロジェクト: Brainiarc7/pbis
static OM_uint32
testPrf(OM_uint32 *minor, gss_ctx_id_t initiatorContext,
        gss_ctx_id_t acceptorContext, int flags)
{
    gss_buffer_desc constant;
    OM_uint32 major, tmp_minor;
    unsigned int i;
    gss_buffer_desc initiatorPrf;
    gss_buffer_desc acceptorPrf;

    constant.value = "gss prf test";
    constant.length = strlen((char *)constant.value);

    initiatorPrf.value = NULL;
    acceptorPrf.value = NULL;

    major = gss_pseudo_random(minor, initiatorContext, flags,
                              &constant, 19, &initiatorPrf);
    if (GSS_ERROR(major)) {
        displayStatus("gss_pseudo_random", major, *minor);
        return major;
    }

    printf("%s\n", flags == GSS_C_PRF_KEY_FULL ?
        "PRF_KEY_FULL" : "PRF_KEY_PARTIAL");

    printf("Initiator PRF: ");
    for (i = 0; i < initiatorPrf.length; i++) {
        printf("%02x ", ((char *)initiatorPrf.value)[i] & 0xFF);
    }
    printf("\n");

    major = gss_pseudo_random(minor, acceptorContext, flags,
                              &constant, 19, &acceptorPrf);
    if (GSS_ERROR(major)) {
        displayStatus("gss_pseudo_random", major, *minor);
        gss_release_buffer(&tmp_minor, &initiatorPrf);
        return major;
    }

    printf("Acceptor  PRF: ");
    for (i = 0; i < acceptorPrf.length; i++) {
        printf("%02x ", ((char *)acceptorPrf.value)[i] & 0xFF);
    }
    printf("\n");

    if (acceptorPrf.length != initiatorPrf.length ||
        memcmp(acceptorPrf.value, initiatorPrf.value, initiatorPrf.length)) {
        fprintf(stderr, "Initiator and acceptor PRF output does not match\n");
        major = GSS_S_FAILURE;
    }

    gss_release_buffer(&tmp_minor, &initiatorPrf);
    gss_release_buffer(&tmp_minor, &acceptorPrf);

    return major;
}
コード例 #4
0
void ContestantApp::onContestStateChange ( int r, CONTEST_STATUS s )
{
    if( !loggedIn )
        return;

    status = s;

    if( round != r )
    {
        round = r;
        ad.clear();
        qCount = 0;
        stopQuestion();
    }

    if( round == 3 || round == 4 )
        m_welcome_dlg->start_btn->setEnabled( false );
    if( round == 4 )
    {
        m_finalsChoice_w->setWindowTitle("Tie-Breaker Round");
        m_finalsIdent_w->setWindowTitle("Tie-Breaker Round");
    }

    if( status == CONTEST_RUNNING )
    {
        displayStatus();
        if( round == 1 || round == 2 )
            m_network->getContestTime();
    }
    else if( status == CONTEST_STOPPED )
        stopContest();
    else if( status == CONTEST_PAUSED )
		pauseContest();
	m_network->qDataRequest( r );
}
コード例 #5
0
ファイル: main.cpp プロジェクト: KDE/simon-tools
int main(int argc, char *argv[])
{
    QCoreApplication::addLibraryPath("app/native/plugins");
    QApplication app(argc, argv);

    SimondConnector connector;
    QMLSimoneView view;

    QObject::connect(&view, SIGNAL(connectToServer()), &connector, SLOT(connectToServer()));
    QObject::connect(&view, SIGNAL(disconnectFromServer()), &connector, SLOT(disconnectFromServer()));
    QObject::connect(&view, SIGNAL(startRecording()), &connector, SLOT(startRecording()));
    QObject::connect(&view, SIGNAL(commitRecording()), &connector, SLOT(commitRecording()));
    QObject::connect(&view, SIGNAL(configurationChanged()), &connector, SLOT(configurationChanged()));

    QObject::connect(&connector, SIGNAL(connectionState(ConnectionState)), &view, SLOT(displayConnectionState(ConnectionState)));
    QObject::connect(&connector, SIGNAL(status(QString)), &view, SLOT(displayStatus(QString)));
    QObject::connect(&connector, SIGNAL(error(QString)), &view, SLOT(displayError(QString)));
    QObject::connect(&connector, SIGNAL(listening()), &view, SLOT(displayListening()));
    QObject::connect(&connector, SIGNAL(recognizing()), &view, SLOT(displayRecognizing()));
    QObject::connect(&connector, SIGNAL(microphoneLevel(int,int,int)), &view, SLOT(displayMicrophoneLevel(int,int,int)));
    QObject::connect(&connector, SIGNAL(recognized(RecognitionResultList)), &view, SLOT(recognized(RecognitionResultList)));

    view.show();
    connector.init();

    return app.exec();
}
コード例 #6
0
//====================================
int runStep(int dir)
//====================================
{
  //char stemp[SIZE_ROW];
  int temp;

  g_dir = dir;

  if(dir == S_FORWARD)currentStep++;
  if(dir == S_BACKWARD)currentStep--;
  if(currentStep > g_steps || currentStep < 1)
    {
      currentStep = checkRange(HEAL,"step",currentStep);
      return(S_STOP); 
    }
  currentLoop = stepLoop[currentStep];
  winLog();
  winSer();
  //strcpy(stemp,status[currentStep]);
  displayStatus();
  unoInfo();

  // Realtime animation
  temp = stepDelay[currentStep];
  if(temp > 0)microDelay(temp);

  return(0);
}    
コード例 #7
0
ファイル: samplertest.cpp プロジェクト: 87maxi/oom
SamplerConnectionTest::SamplerConnectionTest(QString host, int p, QWidget* parent) :QWidget(parent)
{
	hostname = host;
	port = p;
	_connected = false;
	socket = new QTcpSocket(this);
	connect(socket, SIGNAL(ready()), this, SLOT(displayStatus()));
	connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayError(QAbstractSocket::SocketError)));
}
コード例 #8
0
MergeCategoriesWorkingPage::MergeCategoriesWorkingPage(QWidget* parent) : QWizardPage(parent),
mergeCategories(new MergeCategories(this))
{
  ui.setupUi ( this );

  connect ( mergeCategories, SIGNAL (status(QString)), this, SLOT (displayStatus(QString)) );
  connect ( mergeCategories, SIGNAL (done()), this, SLOT (finished()) );
  connect ( mergeCategories, SIGNAL (progress(int,int)), this, SLOT (displayProgress(int,int)) );

  setTitle ( i18n ( "Merging..." ) );
}
コード例 #9
0
ファイル: RTGPUTestBench.cpp プロジェクト: robotage/RTGPULib
RTGPUTestBench::RTGPUTestBench(QWidget *parent)
	: QMainWindow(parent)
{
	ui.setupUi(this);

	m_thread = new RTGPUTestThread();
	m_thread->resumeThread();

	layoutWindow();

	connect(this, SIGNAL(startTest(RTGPU_SETTINGS *)), m_thread, SLOT(startTest(RTGPU_SETTINGS *)));
	connect(m_thread, SIGNAL(displayImage(QImage, int)), this, SLOT(displayImage(QImage, int)));
	connect(m_thread, SIGNAL(displayStatus(QString)), this, SLOT(displayStatus(QString)));

	connect(m_runOnce, SIGNAL(clicked()), this, SLOT(onRunOnce()));
	connect(m_runCont, SIGNAL(clicked()), this, SLOT(onRunCont()));
	connect(m_stopTest, SIGNAL(clicked()), this, SLOT(onStopTest()));
	connect(this, SIGNAL(stopTest()), m_thread, SLOT(stopTest()));
	
	connect(m_testSelect, SIGNAL(currentIndexChanged(int)), this, SLOT(onTestChanged(int)));
}
コード例 #10
0
/**
 * \brief Constructor - creates the GUI
 * \author Peter Grasch
 * @param parent
 * Parent of the widget
 */
ImportTrainingDirectoryWorkingPage::ImportTrainingDirectoryWorkingPage(QWidget* parent) : QWizardPage(parent),
importer(new ImportTrainingData(this)),
completed(false)
{
  ui.setupUi(this);

  setTitle(i18n("Processing folder..."));

  connect(importer, SIGNAL(done()), this, SLOT(setComplete()));
  connect(importer, SIGNAL(progress(int,int)), this, SLOT(displayProgress(int,int)));
  connect(importer, SIGNAL(status(QString)), this, SLOT(displayStatus(QString)));
  connect(importer, SIGNAL(error(QString)), this, SLOT(displayError(QString)));
}
コード例 #11
0
void ContestantApp::pauseQuestion()
{
    m_finalsChoice_dlg->a_choice->setEnabled(false);
    m_finalsChoice_dlg->b_choice->setEnabled(false);
    m_finalsChoice_dlg->c_choice->setEnabled(false);
    m_finalsChoice_dlg->d_choice->setEnabled(false);
    m_finalsChoice_dlg->submit_btn->setEnabled(false);

    m_finalsIdent_dlg->answer_line->setEnabled(false);
    m_finalsIdent_dlg->submit_btn->setEnabled(false);

    displayStatus();
    timer->stop();
}
コード例 #12
0
ファイル: BANDMASTER.C プロジェクト: sq2gxo/bandmaster
void changeBand()
{
	if (bm_cfg.BandOutDelay == 0)
	{
		BandOutVal = BandSelected;
		blockPTTTimed(bm_cfg.BandChngDelay);
	}
	else
	{
		blockPTTTimed(bm_cfg.BandOutDelay);
	}
	applyOutPins();
	updateCurrentEEConfig();
	displayStatus();	
}
コード例 #13
0
void ContestantApp::pauseContest()
{
    timer->stop();

    m_welcome_dlg->start_btn->setEnabled( false );
    m_elims_dlg->prev_btn->setEnabled( false );
    m_elims_dlg->next_btn->setEnabled( false );

    m_semifinals_dlg->prev_btn->setEnabled( false );
    m_semifinals_dlg->next_btn->setEnabled( false );

    m_summary_dlg->submit_btn->setEnabled( false );

    pauseQuestion();
    displayStatus();
}
コード例 #14
0
ファイル: main.cpp プロジェクト: bedahr/recomment
int main(int argc, char *argv[])
{
    QCoreApplication::addLibraryPath("app/native/plugins");
    QApplication app(argc, argv);

    bool voiceControlled = true;
    SimondConnector *connector;
    if (voiceControlled)
        connector = new SimondConnector;
    else
        connector = 0;

    Recomment recomment;
    QMLRecommentView view(&recomment, voiceControlled);

    if (voiceControlled) {
        QObject::connect(&view, SIGNAL(connectToServer()), connector, SLOT(connectToServer()));
        QObject::connect(&view, SIGNAL(disconnectFromServer()), connector, SLOT(disconnectFromServer()));
        QObject::connect(&view, SIGNAL(startRecording()), connector, SLOT(startRecording()));
        QObject::connect(&view, SIGNAL(commitRecording()), connector, SLOT(commitRecording()));
        QObject::connect(&view, SIGNAL(configurationChanged()), connector, SLOT(configurationChanged()));

        QObject::connect(connector, SIGNAL(connectionState(ConnectionState)), &view, SLOT(displayConnectionState(ConnectionState)));
        QObject::connect(connector, SIGNAL(status(QString)), &view, SLOT(displayStatus(QString)));
        QObject::connect(connector, SIGNAL(error(QString)), &view, SLOT(displayError(QString)));
        QObject::connect(connector, SIGNAL(listening()), &view, SLOT(displayListening()));
        QObject::connect(connector, SIGNAL(recognizing()), &view, SLOT(displayRecognizing()));
        QObject::connect(connector, SIGNAL(microphoneLevel(int,int,int)), &view, SLOT(displayMicrophoneLevel(int,int,int)));
        //QObject::connect(connector, SIGNAL(recognized(QString)), &view, SLOT(displayExecutedAction(QString)));
        QObject::connect(connector, SIGNAL(recognized(QString)), &recomment, SLOT(critique(QString)));
    }

    QObject::connect(&recomment, SIGNAL(recommend(const Offer*, QString)), &view, SLOT(displayRecommendation(const Offer*, QString)));
    QObject::connect(&recomment, SIGNAL(noMatchFor(QString)), &view, SLOT(displayNoMatch(QString)));

    view.show();
    if (voiceControlled)
        connector->init();
    if (!recomment.init()) {
        qWarning() << "Failed to initialize Recomment; Aborting";
        return -1;
    }

    int ret = app.exec();
    delete connector;
    return ret;
}
コード例 #15
0
ファイル: Game.cpp プロジェクト: itsuiyamayoshi/cs32
void Game::play()
{
    m_tank.display(m_screen);
    displayStatus();  //  score, rows left, level
    displayPrompt("Press the Enter key to begin playing Imitris!");
    waitForEnter();  // [in UserInterface.h]

    for(;;)
    {
        if ( ! playOneLevel())
            break;
        displayPrompt("Good job!  Press the Enter key to start next level!");
        waitForEnter();
    }
    displayPrompt("Game Over!  Press the Enter key to exit!");
    waitForEnter();
}
コード例 #16
0
ファイル: t_gssexts.c プロジェクト: Brainiarc7/pbis
static OM_uint32
displayOID(OM_uint32 *minor, gss_OID oid, char *tag)
{
    OM_uint32 major, tmp_minor;
    gss_buffer_desc buf;

    major = gss_oid_to_str(minor, oid, &buf);
    if (GSS_ERROR(major)) {
        displayStatus("gss_oid_to_str", major, *minor);
        return major;
    }

    printf("%s:\t%s\n", tag, (char *)buf.value);

    gss_release_buffer(&tmp_minor, &buf);

    return GSS_S_COMPLETE;
}
コード例 #17
0
void ContestantApp::stopContest()
{
    timer->stop();

    m_welcome_dlg->time_lbl->setText("");
    m_elims_w->hide();
    m_semifinals_w->hide();
    m_finalsChoice_w->hide();
    m_finalsIdent_w->hide();
    m_summary_w->hide();
    m_ending_w->hide();

    qCount = 0;
    m_welcome_dlg->start_btn->setEnabled( false );
    m_welcome_w->show();

    displayStatus();
}
コード例 #18
0
void ContestantApp::runQuestion()
{
    m_finalsChoice_dlg->a_choice->setEnabled(true);
    m_finalsChoice_dlg->b_choice->setEnabled(true);
    m_finalsChoice_dlg->c_choice->setEnabled(true);
    m_finalsChoice_dlg->d_choice->setEnabled(true);
    m_finalsChoice_dlg->a_choice->setCheckable(true);
    m_finalsChoice_dlg->b_choice->setCheckable(true);
    m_finalsChoice_dlg->c_choice->setCheckable(true);
    m_finalsChoice_dlg->d_choice->setCheckable(true);
    m_finalsChoice_dlg->submit_btn->setEnabled(true);

    m_finalsIdent_dlg->answer_line->setEnabled(true);
    m_finalsIdent_dlg->submit_btn->setEnabled(true);

    timer->start( 1000 );
    displayStatus();
}
コード例 #19
0
void ContestantApp::runContest()
{
    if( round == 1 || round == 2 )
        m_welcome_dlg->start_btn->setEnabled( true );
    else if( round == 3 || round == 4 )
        m_welcome_dlg->start_btn->setEnabled( false );

    m_elims_dlg->prev_btn->setEnabled( true );
    m_elims_dlg->next_btn->setEnabled( true );

    m_semifinals_dlg->prev_btn->setEnabled( true );
    m_semifinals_dlg->next_btn->setEnabled( true );

    m_summary_dlg->submit_btn->setEnabled( true );

    if( round == 1 || round == 2 )
        timer->start( 1000 );
    displayStatus();
}
コード例 #20
0
//====================================
int goStep(int step)
//====================================
{
  char stemp[SIZE_ROW];


  if(step > g_steps || step < 1)
    {
      step = checkRange(HEAL,"step",step);
      //return(STOP); 
    }
  currentStep = step;
  currentLoop = stepLoop[currentStep];
  winLog();
  winSer();
  //strcpy(stemp,status[currentStep]);
  displayStatus();
  unoInfo();
  return(0);
}    
コード例 #21
0
ファイル: SystemStarter.c プロジェクト: aosm/Startup
/**
 * checkForActivity checks to see if any items have completed since the last invokation.
 * If not, a message is displayed showing what item(s) are being waited on.
 **/
static void checkForActivity(CFRunLoopTimerRef aTimer, void* anInfo)
{
    static CFIndex aLastStatusDictionaryCount = -1;
    static CFStringRef aWaitingForString = NULL;
    
    StartupContext aStartupContext = (StartupContext)anInfo;

    if (aStartupContext && aStartupContext->aStatusDict)
      {
        CFIndex aCount = CFDictionaryGetCount(aStartupContext->aStatusDict);

        if (!aWaitingForString)
          {
            aWaitingForString = LocalizedString(aStartupContext->aResourcesBundlePath, kWaitingForKey);
          }
      
        if (aLastStatusDictionaryCount == aCount)
          {
            CFArrayRef aRunningList = StartupItemListGetRunning(aStartupContext->aWaitingList);
            if (aRunningList && CFArrayGetCount(aRunningList) > 0)
              {
                CFMutableDictionaryRef anItem = (CFMutableDictionaryRef)CFArrayGetValueAtIndex(aRunningList, 0);
                CFStringRef anItemDescription = StartupItemGetDescription(anItem);
                CFStringRef aString = aWaitingForString && anItemDescription ? 
                                        CFStringCreateWithFormat(NULL, NULL, aWaitingForString, anItemDescription) : NULL;
                
                if (aString)
                  {
                    displayStatus(aStartupContext->aDisplayContext, aString);
                    CFRelease(aString);
                  }
                if (anItemDescription) CFRelease(anItemDescription);
              }
            if (aRunningList) CFRelease(aRunningList);
          }
        aLastStatusDictionaryCount = aCount;
      }
}
コード例 #22
0
ファイル: IPC.c プロジェクト: aosm/Startup
/**
 * Displays a message on the console.
 * aConsoleMessage will be localized according to the dictionary in the specified item.
 * Running tems may be specified by their current process id.  Items may also be specified
 * by one of the service names they provide.
 **/
static void consoleMessage (StartupContext aStartupContext, CFDictionaryRef anIPCMessage)
{
    if (aStartupContext && anIPCMessage)
      {
        CFStringRef aConsoleMessage = CFDictionaryGetValue(anIPCMessage, kIPCConsoleMessageKey);

        if (aConsoleMessage && CFGetTypeID(aConsoleMessage) == CFStringGetTypeID())
          {
            CFStringRef     aLocalizedMessage = NULL;
            CFDictionaryRef anItem            = itemFromIPCMessage(aStartupContext, anIPCMessage);
            
            if (anItem)
              {
                aLocalizedMessage = StartupItemCreateLocalizedString(anItem, aConsoleMessage);
              }

            if (!aLocalizedMessage) aLocalizedMessage = CFRetain(aConsoleMessage);

            displayStatus(aStartupContext->aDisplayContext, aLocalizedMessage);
        
            CFRelease(aLocalizedMessage);
          }
      }
}
コード例 #23
0
task main()
{
    initializeRobot();

    while(nNxtButtonPressed != nxtOrange)
    {
        displayStatus();
    }

    waitTillNoButton();
    eraseDisplay();
    resetEncoders();

    while(nNxtButtonPressed != nxtOrange)
    {
        while(nxtGrey != nNxtButtonPressed)
        {
            displayString(4,"PICK UP AND PRESS GREY BTN");
        }
        while((nMotorEncoder[rightFront] < 1800)||(nMotorEncoder[rightBack] < 1800)||(nMotorEncoder[leftBack] < 1800)||(nMotorEncoder[leftFront]< 1800))
        {
            eraseDisplay();
            setMotors(70,70,70,70);
        }
        stopMotors();

        displayString(1, "should be 1800");
        displayString(3, "rightback encoder: %d", nMotorEncoder[rightFront]);
        displayString(2, "rightfront encoder: %d", nMotorEncoder[rightBack]);
        displayString(4, "leftfront encoder: %d", nMotorEncoder[leftFront]);
        displayString(5, "leftback encoder: %d", nMotorEncoder[leftBack]);
    }

    waitTillNoButton();

}
コード例 #24
0
ファイル: IPC.c プロジェクト: aosm/Startup
/**
 * Loads the SystemStarter display bundle at the specified path.
 * A no-op if SystemStarter is not starting in graphical mode.
 **/
static void loadDisplayBundle (StartupContext aStartupContext, CFDictionaryRef anIPCMessage)
{
    if (!gVerboseFlag && anIPCMessage && aStartupContext)
      {
        CFStringRef aBundlePath = CFDictionaryGetValue(anIPCMessage, kIPCDisplayBundlePathKey);        
        if (aBundlePath && CFGetTypeID(aBundlePath) == CFStringGetTypeID())
          {
            extern void LoadDisplayPlugIn(CFStringRef);

            if (aStartupContext->aDisplayContext)
                freeDisplayContext(aStartupContext->aDisplayContext);
            LoadDisplayPlugIn(aBundlePath);
            aStartupContext->aDisplayContext = initDisplayContext();
            
              {
                CFStringRef aLocalizedString = LocalizedString(aStartupContext->aResourcesBundlePath, kWelcomeToMacintoshKey);
                if (aLocalizedString)
                  {
                    displayStatus(aStartupContext->aDisplayContext, aLocalizedString);
                    displayProgress(aStartupContext->aDisplayContext, ((float)CFDictionaryGetCount(aStartupContext->aStatusDict)/((float)aStartupContext->aServicesCount + 1.0)));
                    CFRelease(aLocalizedString);
                  }
              }
            
            if (gSafeBootFlag)
              {
                CFStringRef aLocalizedString = LocalizedString(aStartupContext->aResourcesBundlePath, kSafeBootKey);
                if (aLocalizedString)
                  {
                    (void) displaySafeBootMsg(aStartupContext->aDisplayContext, aLocalizedString);
                    CFRelease(aLocalizedString);
                  }
              }
          }
      }
}
コード例 #25
0
void display() {
/*
	This function is used to display the content on to the screen...
	This is not important for the participant... He can skip it
*/
	int gridDup[6][7],moveDup=move,endGameFlagDup,rowNum;
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();

	drawGrid(grid);
	if(animate) {
		drawPiece(result,displacement,move);
		if(stopAnimate(grid,result,displacement)) {
			animate=0;
			if(!errorFlag) {
				rowNum=updateGrid(move,grid,result);			//	update the grid implying the move has been made
				drawGrid(grid);
				if(checkWinOrLose(grid,result,rowNum)) {		//	check for win condition
					win=move;					//	win will contain which bot has won
					endGameFlag=1;
				}
				else if(checkDraw(grid)) {				//	check for draw condition
					win=0;						//	win=0 implies draw
					endGameFlag=1;
				}
				move*=-1;						//	toggle between plaper 1 and player 2
			}
		}
	}
	if(errorFlag)									//	If error occurs
		text(displayStr,-1.5,-1.8,font3);
	if(endGameFlag) {								//	If game ends
		if(win>0)				//	player 1 wins
			strcpy(displayStr,"Bot 1 wins!!!");
		else if(win<0)				//	player 2 wins
			strcpy(displayStr,"Bot 2 wins!!!");
		else					//	draw
			strcpy(displayStr,"Game drawn!!!");
		text(displayStr,-1.5,-1.8,font3);
		printf("\n\n\t%s\n\n\t\tgrid content : \n\n",displayStr);
		displayStatus(grid);
	}
	glFlush();
	glutSwapBuffers();
	if(animate)
		displacement+=0.005;
	if(!endGameFlag && !errorFlag && !animate) {
		copyGrid(grid,gridDup);
		moveDup=move;
		endGameFlagDup=endGameFlag;
		if(move>0)
			result=bot1(grid,move);
		else
			result=bot2(grid,move);
		if(!(equalGrid(grid,gridDup) && move==moveDup && endGameFlagDup==endGameFlag)) {	//	grid() and move variables should not be changed
			sprintf(displayStr,"Bot %d error : Grid or move is modified!!!",move);
			errorFlag=1;
		}
		checkForErrors(result,move,grid);			//	errors like result should be within the 0 to 6 range, etc...
		animate=1;
		displacement=0;
	}
}
コード例 #26
0
ファイル: SystemStarter.c プロジェクト: aosm/Startup
int system_starter (Action anAction, CFStringRef aService)
{
    CFRunLoopSourceRef	anIPCSource = NULL;
	NSSearchPathDomainMask	aMask;
    CFRunLoopTimerRef    anActivityTimer = NULL;

    StartupContext   aStartupContext = (StartupContext) malloc(sizeof(struct StartupContextStorage));
    if (! aStartupContext)
      {
        error(CFSTR("Not enough memory to allocate startup context.\n"));
        return(1);
      }

    /**
     * Init the display context.  Starts with the default text display.
     * A graphical display may be requested later via IPC.
     **/
    aStartupContext->aDisplayContext = initDisplayContext();

	aStartupContext->aResourcesBundlePath = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s/%@.%s/"),
                                                    kBundleDirectory,
                                                    kResourcesBundleName,
                                                    kBundleExtension);

      {
        CFStringRef aLocalizedString = LocalizedString(aStartupContext->aResourcesBundlePath, kWelcomeToMacintoshKey);
        if (aLocalizedString)
          {
            displayStatus(aStartupContext->aDisplayContext, aLocalizedString);
            CFRelease(aLocalizedString);
          }
      }
      
    if (gSafeBootFlag)
      {
        CFStringRef aLocalizedString = LocalizedString(aStartupContext->aResourcesBundlePath, kSafeBootKey);
        if (aLocalizedString)
          {
            (void) displaySafeBootMsg(aStartupContext->aDisplayContext, aLocalizedString);
            CFRelease(aLocalizedString);
          }
      }

   if (gDebugFlag && gNoRunFlag) sleep(1);

    /**
     * Create the IPC port
     **/
    anIPCSource = CreateIPCRunLoopSource(kSystemStarterMessagePort, aStartupContext);
    if (anIPCSource)
      {
        CFRunLoopAddSource(CFRunLoopGetCurrent(), anIPCSource, kCFRunLoopCommonModes);
        CFRelease(anIPCSource);
      }
    else
      {
        error(CFSTR("Could not create IPC port (%@)."), kSystemStarterMessagePort);
        return(1);
      }

    /**
     * Get a list of Startup Items which are in /Local and /System.
     * We can't search /Network yet because the network isn't up.
     **/
        aMask = NSSystemDomainMask;
        if (!gSafeBootFlag)
          {
            aMask |= NSLocalDomainMask;
          }
        else
          {
            if (gDebugFlag)
              {
                debug(CFSTR("Safe Boot mode active\n")); fflush(stdout);
              }
          }

        aStartupContext->aWaitingList = StartupItemListCreateWithMask(aMask);
        aStartupContext->aFailedList = NULL;
        aStartupContext->aStatusDict  = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks,
                                                                                 &kCFTypeDictionaryValueCallBacks);
        aStartupContext->aServicesCount = 0;
        aStartupContext->aRunningCount = 0;
        aStartupContext->aQuitOnNotification = gQuitOnNotification && aStartupContext->aDisplayContext;

        if (aService)
          {
            CFMutableArrayRef aDependentsList = StartupItemListCreateDependentsList(aStartupContext->aWaitingList, aService, anAction);

            if (aDependentsList)
              {
                CFRelease(aStartupContext->aWaitingList);
                aStartupContext->aWaitingList = aDependentsList;
              }
            else 
              {
                error(CFSTR("Unknown service: %@\n"), aService);
                return(1);
              } 
	  }

        aStartupContext->aServicesCount = StartupItemListCountServices(aStartupContext->aWaitingList);

    /**
     * Create the activity timer.
     **/
    anActivityTimer = createActivityTimer(aStartupContext);
        
    /**
     * Do the run loop
     **/
        while (1)
          {
        CFMutableDictionaryRef anItem = StartupItemListGetNext(aStartupContext->aWaitingList, aStartupContext->aStatusDict, anAction);

        if (anItem)
          {
            int err = StartupItemRun(aStartupContext->aStatusDict, anItem, anAction);
            if (!err)
              {
                ++aStartupContext->aRunningCount;
                MonitorStartupItem(aStartupContext, anItem); 
              }
            else
              {
                /* add item to failed list */
                AddItemToFailedList(aStartupContext, anItem);

                /* Remove the item from the waiting list. */
                RemoveItemFromWaitingList(aStartupContext, anItem);
              }
          }
        else
          {
            /* If no item was selected to run, and if no items are running, startup is done. */
            if (aStartupContext->aRunningCount == 0)
              {
                if (gDebugFlag) debug(CFSTR("none left\n"));                      
                break;
              }

            /* Perform periodic checks for activity. */
            if (anActivityTimer)
              {
                CFRunLoopAddTimer(CFRunLoopGetCurrent(), anActivityTimer, kCFRunLoopCommonModes);
              }
            
            /* Process incoming IPC messages and item terminations */
            CFRunLoopRun();
            
            /* Don't perform activity checks while we are doing work. */
            if (anActivityTimer)
              {
                CFRunLoopRemoveTimer(CFRunLoopGetCurrent(), anActivityTimer, kCFRunLoopCommonModes);
              }
          }
      }

    /**
     * Good-bye.
     **/
    displayErrorMessages(aStartupContext);

    /*  Display final message and wait if necessary  */
    {
      CFStringRef aLocalizedString = NULL;
      if (aStartupContext->aQuitOnNotification)
        {
          aLocalizedString = LocalizedString(aStartupContext->aResourcesBundlePath, kLoginWindowKey);
        }
      else
        {
          aLocalizedString = LocalizedString(aStartupContext->aResourcesBundlePath, kStartupCompleteKey);
        }

      if (aLocalizedString)
        {
          displayStatus(aStartupContext->aDisplayContext, aLocalizedString);
          CFRelease(aLocalizedString);
        }
    }

    /* sit and wait for a message from ConsoleMessage to quit */
    if (aStartupContext->aQuitOnNotification)
      {
        CFRunLoopRun();
      }

    /*  clean up  */
    if (anActivityTimer              ) CFRelease(anActivityTimer);
    if (aStartupContext->aStatusDict ) CFRelease(aStartupContext->aStatusDict);
    if (aStartupContext->aWaitingList) CFRelease(aStartupContext->aWaitingList);
    if (aStartupContext->aFailedList)  CFRelease(aStartupContext->aFailedList);
    if (aStartupContext->aResourcesBundlePath) CFRelease(aStartupContext->aResourcesBundlePath);
    
    if (aStartupContext->aDisplayContext) freeDisplayContext(aStartupContext->aDisplayContext);
    free(aStartupContext);
    return(0);
}
コード例 #27
0
ファイル: main.c プロジェクト: chamboard/Ju
int main (int argc,char *argv[ ]) {
	
	bus_struct chantilly_stack;
	uint8_t myTXBuffer[1024]={0}; 					 
	uint8_t exit_loop=0;
	uint8_t c=0;
	uint32_t errors=0;
									
	sequencer seq={"Seq\0",0x0F,0x150,0x04,0x141,30,0x144,10,0x1CC,1,0x1CF};	// The sructure storing specific settings to sequencer Seq.
	//  seq.mask=0x0F;									
	//  seq.maskAddr=0x150;															
	//  seq.cursor=0x04;									
	//  seq.cursorAddr=0x141;							
	//  seq.astepIncTime=30;							
	//  seq.astepIncTimeAddr=0x144;					
	//  seq.presetCount=10;							
	//  seq.presetCountAddr=0x1CC;					
	//  seq.presetStep=1;																	
	//  seq.presetStepAddr=0x1CF;	
						
	sequencer seq1={"Seq1\0",0xF0,0x151,0x07,0x1C1,30,0x1C2,10,0x1CD,1,0x1D0};	// The sructure storing specific settings to sequencer Seq1.
	//  seq1.mask=0xF0;									
	//  seq1.maskAddr=0x151;							
	//  seq1.cursor=0x07;								
	//  seq1.cursorAddr=0x1C1;						
	//  seq1.astepIncTime=30;							
	//  seq1.astepIncTimeAddr=0x1C2;				
	//  seq1.presetCount=10;							
	//  seq1.presetCountAddr=0x1CD;					
	//  seq1.presetStep=1;								 									
	//  seq1.presetStepAddr=0x1D0;						
	
	sequencers seqs={0,0x1D2,1,0x146};				                          	// The structure storing common settings to the three sequencers.
	//	seqs.stepcountRestart=0;						  
	//	seqs.stepcountRestartAddr=0x1D2;				 
	//  seqs.wrap=1;									
	//	seqs.wrapAddr=0x146;											

	
	/************************************************************************************************************************************************************************************************************************************************
	*											SETS UP CHANTILLY																										                                                                            *
	************************************************************************************************************************************************************************************************************************************************/
	
	
	if(CHAN_setup("APP100",1)!=0) { printf("Error opening chantilly , error or processID { }\n"); CHAN_close();return 0;}	// stops here if can't open immediate core access mode.
	
	
	/************************************************************************************************************************************************************************************************************************************************
	*											CHECKS CHANTILLY STACK 				                                                                                                                                                                *
	************************************************************************************************************************************************************************************************************************************************/
	
	
	CHAN_checkBUS(&chantilly_stack,1,1);			// Checks what's on the addr1 of the chantilly stack bus.
	CHAN_checkBUS(&chantilly_stack,2,1);			// Checks what's on the addr2 of the chantilly stack bus.
	
	
	/************************************************************************************************************************************************************************************************************************************************
	*											SETS UP UPDATE PERIOD OF SEQUENCED OUTPUTS MODE 				                                                                                                                                    *
	************************************************************************************************************************************************************************************************************************************************/
	
	
	errors+=CHAN_addr4(IO24_NUM,0x52);             	// Sets current address to 0x52*4=0x148 into IO24 (CHAN_addr4() can only access multiple of 4 offsets,
													// 													must do empty reading or writing to increase current address). 
	errors+=CHAN_setByte(IO24_NUM,0x08);           	// Writes 0x08 at current address 0x148 into the IO24 (current address increases automatically).
	errors+=CHAN_setByte(IO24_NUM,0xCF);			// Writes 0xCF at current address 0x149 into the IO24.  
													// Two previous values at addresses 0x148 and 0x149 are used to set  SEQ_USER_VAL=0xCF08 => 0xFFFF-SEQ_USER_VAL=0x30F7=12535. 
	errors+=CHAN_setByte(IO24_NUM,0x01);			// Writes 0x01 at current address 0x14A into IO24.
													// Previous value is used to set SEQ_USER_PRESCA=1 => PRESCAseq=1/4 (0,1,2,..,7 respectively corresponding to 1/2,1/4,1/8,..,1/256). 
	// Sequencer mode is now set with update period, Tseq, such as Tseq=(0xFFFF-SEQ_USER_VAL)*100ns/PRESCAseq=12535*100ns*4=5.014ms.
	// That means, inputs are read every Tseq=5.014ms and sequenced outputs are updated every (SEQ_ASTEP_INC_TIME+1)*Tseq=(SEQ_ASTEP_INC_TIME+1)*5.014ms. 

	
	/************************************************************************************************************************************************************************************************************************************************
	*											SETS UP SEQUENCED OUTPUTS MODE				                                                                                                                                                        *
	************************************************************************************************************************************************************************************************************************************************/
	
	
	/** SETS UP SEQUENCED OUTPUTS */			
	
	errors+=CHAN_addr4(IO24_NUM,0x40);				// Sets current address at 0x40*4=0x100 into IO24.
	errors+=CHAN_setByte(IO24_NUM,0x00);			// Writes 0 at current address 0x100 into IO24. Used to set OUTPUT_A=0. 
	errors+=CHAN_setByte(IO24_NUM,0);				// Writes 0 at current address 0x101 into IO24. Used to set OUTPUT_B=0. 
	errors+=CHAN_addr4(IO24_NUM,0x54);				// Sets current address at 0x54*4=0x150 into IO24.
	errors+=CHAN_setByte(IO24_NUM,seq.mask);		// Writes seq.mask(=0x0F) at current address 0x150 into IO24. Used to set SEQ_MASK=0x0F
	errors+=CHAN_setByte(IO24_NUM,seq1.mask);		// Writes seq1.mask(=0xF0) at current address 0x151 into IO24. used to set SEQ1_MASK=0xF0
	// Since mode of sequencer is 1, Seq and Seq1 play on OutputA such as OutputA=data[SEQ_CURSOR]&SEQ_MASK|data[SEQ1_CURSOR]&SEQ1_MASK|OUTPUT_A with data[X]:value stored at address X and 0x04≤X≤0xFF.
	//								 Seq plays on OutputB such as OutputB=data[SEQ_CURSOR+128]|OUTPUT_B.
	// With above settings Seq1 plays on OutputA bit7, bit6, bit5 and bit4 Seq plays on OutputA bit3, bit2, bit1 and bit0, and on all bits of OutputB. 
	
	
	/** WRITES SEQUENCES VALUES */
	
	myTXBuffer[00]=0x11;							// Seq and Seq1 sequence on OutputA			
	myTXBuffer[01]=0x22;							// (1st sequence of the couple)	
	myTXBuffer[02]=0x44;							//  							
	myTXBuffer[03]=0x88;							//						
	errors+=CHAN_addr(IO24_NUM,0x04);				// Sets current address at 0x04 into IO24.
	errors+=CHAN_setBytes(IO24_NUM,4,myTXBuffer);	// Writes sequence (via myTXBuffer) at current address 0x04 into IO24.
	// Using mode 1 implies that first sequence of the couple is the sequence of Seq and Seq1 on OutputA. This sequence must be stored between included addresses 0x04 and 0x7F in RAM.
	
	myTXBuffer[00]=0x10;							// Seq sequence on OutputB			
	myTXBuffer[01]=0x20;							// (2nd sequence of the couple)	
	myTXBuffer[02]=0x40;							//  							
	myTXBuffer[03]=0x80;							//								
	errors+=CHAN_addr(IO24_NUM,0x84);				// Sets current address at 0x84 into IO24.
	errors+=CHAN_setBytes(IO24_NUM,4,myTXBuffer);	// Writes sequence (via myTXBuffer) at current address 0x04 into IO24.
	// Using mode 1 implies that second sequence of the couple is the sequence of Seq on OutputB. This sequence must be stored between included addresses 0x84 and 0xFF in RAM.
	
	
	/** SETS UP SEQUENCER Seq SETTINGS */
													// Presets via myTXBuffer :
	myTXBuffer[0]=0; 		  						// SEQ_STEP is useless in stepcount mode and replaced by SEQ_PRESET_STEP.
	myTXBuffer[1]=seq.cursor;						// SEQ_CURSOR=0x04 : 	 current RAM address of Seq sequence (permanently overwritten but as Seq increase must be initialized such as SEQ_CURSOR≤SEQ_END).
	myTXBuffer[2]=0x04;								// SEQ_START=0x04 : 	 RAM address where (common) Seq sequence begins.
	myTXBuffer[3]=0x07;   							// SEQ_END=0x08 : 		 RAM address where (common) Seq sequence ends. In mode 0, 0x04≤SEQ_START≤SEQ_END≤0x7F.
	myTXBuffer[4]=seq.astepIncTime;					// SEQ_ASTEP_INC_TIME :  used to change delay Ts between steps of Seq sequence such as Ts=(SEQ_ASTEP_INC_TIME+1)*Tseq=31*0.005014=155.434 ms. => fs=6.43Hz. 
	myTXBuffer[5]=0;								/*********************************************non implementé ??????******************************/
	myTXBuffer[6]=1;								// SEQ_WRAP=1 : 		 plays sequences infinitely by setting SEQ_CURSOR=SEQ_START if SEQ_STEP=1 or SEQ_CURSOR=SEQ_END if SEQ_STEP=2 when Seq sequence ends.
	myTXBuffer[7]=1;								// SEQ_MODE=1 : 		 the two sequencers Seq and Seq1 are independent and play a common sequence asynchronously. Seq and Seq1 settings are required.
	errors+=CHAN_addr4(IO24_NUM,0x50);				// Sets current address at 0x50*4=0x140 into IO24.
	errors+=CHAN_setBytes(IO24_NUM,8,myTXBuffer);	// Writes sequencer Seq settings (stored in myTXBuffer) at current address.
	errors+=CHAN_addr(IO24_NUM,seq.presetCountAddr);// Sets current address at 0x1CC into IO24.
	errors+=CHAN_setByte(IO24_NUM,seq.presetCount);	// Sets SEQ_PRESET_COUNT=10 : sequencer Seq executes 10 steps.
	errors+=CHAN_addr(IO24_NUM,seq.presetStepAddr);	// Sets current address at 0x1CF into IO24.
	errors+=CHAN_setByte(IO24_NUM,seq.presetStep);	// SEQ_PRESET_STEP=seq.presetStep=1 : sequencer Seq increases.
	errors+=CHAN_addr(IO24_NUM,seqs.stepcountRestartAddr);	// Sets current address at 0x1D2 into IO24.
	errors+=CHAN_setByte(IO24_NUM,seqs.stepcountRestart);	// SEQS_STEPCOUNT_RESTART=1 : sets SEQ_CURSOR=SEQ1_CURSOR=SEQ_START when executing the IO24 command named STEPCOUNT_SEQUENCER_RUN.
	// To edit SEQ_MODE and SEQ_WRAP, sequencer mode must be restarted by executing IO24 command 0x07 named STEPCOUNT_SEQUENCER_RUN. 
	// All others sequencer settings can be edited when stepcount sequenced outputs mode is running but it is not advisable.
	
	
	/** SETS UP SEQUENCER Seq1 SETTINGS */
	
	myTXBuffer[0]=0;
	myTXBuffer[1]=seq1.cursor;
	myTXBuffer[2]=seq1.astepIncTime;
	errors+=CHAN_addr4(IO24_NUM,0x70);						// Sets current address at 0x70*4=0x1C0 into IO24.
	errors+=CHAN_setBytes(IO24_NUM,3,myTXBuffer);			// Writes sequencer Seq1 settings (stored in myTXBuffer) at current address.
	errors+=CHAN_addr(IO24_NUM,seq1.presetCountAddr);		// Sets current address at 0x1CD into IO24.
	errors+=CHAN_setByte(IO24_NUM,seq1.presetCount);		// Sets SEQ1_PRESET_COUNT=10 : sequencer Seq1 executes 10 steps.
	errors+=CHAN_addr(IO24_NUM,seq1.presetStepAddr);		// Sets current address at 0x1D0 into IO24.
	errors+=CHAN_setByte(IO24_NUM,seq1.presetStep);			// Sets SEQ1_PRESET_STEP=1 : sequencer Seq1 increases.
	// To edit SEQ1_PRESET_STEP sequencer mode must be restarted by executing IO24 command 0x07 named STEPCOUNT_SEQUENCER_RUN.
	// All others sequencer Seq1 settings can be edited when stepcount sequenced outputs mode is running but it is not advisable.
			
	
	/************************************************************************************************************************************************************************************************************************************************
	*											STARTS SEQUENCED OUTPUTS MODE																																										*
	************************************************************************************************************************************************************************************************************************************************/											
	
	
	errors+=CHAN_command(IO24_NUM,0x07);			// Executes IO24 command 0x07 named STEPCOUNT_SEQUENCER_RUN : Starts (immediate inputs and) stepcount sequenced outputs mode.
	
	
	/************************************************************************************************************************************************************************************************************************************************
	*											LOOPS :			             	                                                                                                                                                                    *
	************************************************************************************************************************************************************************************************************************************************/


	printf("\nIO24 stepcount sequenced outputs mode 1 is started : \n");
	printf("Sequencers Seq and Seq1 are running with respective steps delays Ts and Ts1 set such as ");
	printf("Ts=Tseq*(SEQ_ASTEP_INC_TIME+1) and Ts1=Tseq*(SEQ1_ASTEP_INC_TIME+1) ");
	printf("with SEQ_ASTEP_INC_TIME=SEQ1_ASTEP_INC_TIME=30 and Tseq=5ms ");
	printf("then Ts=Ts1=31*5ms=155ms\n\n");
	displayMainMenu();
	
	
	while (!exit_loop) {														// Entering loop
		getch_start();															//
		c=getch_try();															//
		getch_stop();															//  Gets the last character typed without stopping program (see FUNCTIONS above).
		if (c) {                                                    			//  
			if (c=='q') {														//
				printf("\n");													//
				exit_loop=1;													//   If 'q' is typed exits loop.
			}																	//
			else if (c=='w') invertWrap(&seqs,&errors);							//	 Else if 'w' is typed inverts wrap of the three sequencers (even if Seq2 is unused). . 
			else if (c=='p') pauseResumeSteps(&seq,&seq1,&errors);				//	 Else if 'p' is typed pauses/resumes the two sequencers Seq and Seq1. 
			else if (c=='a') add10Steps(&seq,&seq1,&errors);					//	 Else if 'a' is typed adds 10 steps to the two sequencers Seq and Seq1. 
			else if (c=='?') displayStatus(&seq,&seq1,&errors);					//   Else if '?' is typed displays status.
			else if (c=='0') exit_loop=displaySeqMenu(c,&seq,&errors); 			// 	 Else if '0' is typed displays Seq menu.														
			else if (c=='2') exit_loop=displaySeqMenu(c,&seq1,&errors);			//   Else if '1' is typed displays Seq1 menu.	
		}
	}
	
	
	/************************************************************************************************************************************************************************************************************************************************
	*											EXITS PROGRAM				                                                                                                                                                                        *
	************************************************************************************************************************************************************************************************************************************************/
	
	
	/** STOPS IO24 */
	
	errors+=CHAN_command(IO24_NUM,6);           	// Executes IO24 command 0x06 named STOP : Stops IO24 running mode (optionnal, if not executed IO24 will go on maintening mode
													//																				actually running after having closed chantilly and program).  
	
	/** CLOSES CHANTILLY	*/
	
	errors+=CHAN_close();							// Closes immediate core access mode.
	
	
	/** DEBUG */
	
	printf("\naccess errors : %d\n\n",errors);		// Displays access errors (optionnal for debug).
	fflush(stdout);
	
	return 0;
	
}
コード例 #28
0
ファイル: t_saslname.c プロジェクト: Brainiarc7/pbis
int main(int argc, char *argv[])
{
    gss_OID_set mechs;
    OM_uint32 major, minor;
    size_t i;

    major = gss_indicate_mechs(&minor, &mechs);
    if (GSS_ERROR(major)) {
        displayStatus("gss_indicate_mechs", major, minor);
        return major;
    }

    for (i = 0; i < mechs->count; i++) {
        gss_buffer_desc oidstr = GSS_C_EMPTY_BUFFER;
        gss_buffer_desc sasl_mech_name = GSS_C_EMPTY_BUFFER;
        gss_buffer_desc mech_name = GSS_C_EMPTY_BUFFER;
        gss_buffer_desc mech_description = GSS_C_EMPTY_BUFFER;
        gss_OID oid = GSS_C_NO_OID;

        major = gss_oid_to_str(&minor, &mechs->elements[i], &oidstr);
        if (GSS_ERROR(major))
            continue;

        major = gss_inquire_saslname_for_mech(&minor, &mechs->elements[i],
                                              &sasl_mech_name, &mech_name,
                                              &mech_description);
        if (GSS_ERROR(major)) {
            gss_release_buffer(&minor, &oidstr);
            continue;
        }

        printf("-------------------------------------------------------------"
               "-----------------\n");
        printf("OID        : %.*s\n", (int)oidstr.length,
               (char *)oidstr.value);
        printf("SASL mech  : %.*s\n", (int)sasl_mech_name.length,
               (char *)sasl_mech_name.value);
        printf("Mech name  : %.*s\n", (int)mech_name.length,
               (char *)mech_name.value);
        printf("Mech desc  : %.*s\n", (int)mech_description.length,
               (char *)mech_description.value);
        dumpMechAttrs(&minor, &mechs->elements[i]);
        printf("-------------------------------------------------------------"
               "-----------------\n");

        if (GSS_ERROR(gss_inquire_mech_for_saslname(&minor, &sasl_mech_name,
                                                    &oid))) {
            displayStatus("gss_inquire_mech_for_saslname", major, minor);
        } else if (oid == GSS_C_NO_OID ||
            (oid->length != mechs->elements[i].length &&
             memcmp(oid->elements, mechs->elements[i].elements,
                    oid->length) != 0)) {
            gss_release_buffer(&minor, &oidstr);
            (void) gss_oid_to_str(&minor, oid, &oidstr);
            fprintf(stderr, "Got different OID %.*s for mechanism %.*s\n",
                    (int)oidstr.length, (char *)oidstr.value,
                    (int)sasl_mech_name.length, (char *)sasl_mech_name.value);
        }
        gss_release_buffer(&minor, &oidstr);
        gss_release_buffer(&minor, &sasl_mech_name);
        gss_release_buffer(&minor, &mech_name);
        gss_release_buffer(&minor, &mech_description);
    }

    gss_release_oid_set(&minor, &mechs);

    return GSS_ERROR(major) ? 1 : 0;
}
コード例 #29
0
ファイル: BANDMASTER.C プロジェクト: sq2gxo/bandmaster
int main (void)
{
	// Initialize
	//---------------------------------------
	// 1) set band data inputs
	initPORTS();
	// 2) confgure ADC for ICOM band data
	initADC(); 
	// 3) Read EEPROM data
	readEEConfig();
	// 4) set output
	applyOutPins();
	// 5) Enable 10ms timer
	initTIMER();
	// 6) Enable serial port communication
	initSERIAL();
   	// 7) Initialize LCD module
   	LCDInit(LS_NONE);
	// 8) display welcome message
	showSplashScreen();
	// 9) show status on screen
	displayStatus();
	// 10) set LEDs
	if (BandDecode_Mode == BAND_MODE_AUTO)
	{
		enableAutoLED();
		disableManLED();
	}
	else
	{
		enableManLED();
		disableAutoLED();
	}
	disableLinkLED();


	// Main loop
	//---------------------------------------
	while(1)
	{
		// Get auto band
		//---------------------------------------
		if (BandDecode_Mode == BAND_MODE_AUTO)
		{
			checkAutoBand();
			// check if changed and refresh screen...
			if (current_auto_band != BAND_INVALID)
			{			
				if (BandSelected != current_auto_band)
				{
					if (IS_TX)
					{
						displayMsg(m1_band_change_when_tx_warn, m2_when_tx, 2);
					}
					BandSelected = current_auto_band;

					changeBand();
				}
				disableManLEDBlink();
			}
			else
			{
				enableManLEDBlink();
			}
		}
	
		// Selecting antennas
		//---------------------------------------
		int8_t ant_chng = -1;
		if (sw_state[ANT1_SW_ID] == SW_PRESS)
		{
			sw_state[ANT1_SW_ID] = SW_OPEN;
			ant_chng = 0;
		}
		else if (sw_state[ANT2_SW_ID] == SW_PRESS)
		{
			sw_state[ANT2_SW_ID] = SW_OPEN;
			ant_chng = 1;
		}
		else if (sw_state[ANT3_SW_ID] == SW_PRESS)
		{
			sw_state[ANT3_SW_ID] = SW_OPEN;
			ant_chng = 2;
		}
		if (ant_chng != -1)
		{
			uint8_t new_ant_id = bm_cfg.AntAvailBandCfg[BandSelected][ant_chng];
			if (new_ant_id != NO_ANTENNA && bm_cfg.AntSelBandCfg[BandSelected] != new_ant_id)
			{
				if (IS_TX)
				{
					displayMsg(m1_ant_change_press_when_tx, m2_when_tx, 2);
				}
				else
				{
					bm_cfg.AntSelBandCfg[BandSelected] = new_ant_id;
					applyOutPins();
					updateCurrentEEConfig();
					displayStatus();
				}
			}
		}	
		
		// Selecting band change mode
		//---------------------------------------
		if (sw_state[MODE_SW_ID] == SW_PRESS)
		{
			sw_state[MODE_SW_ID] = SW_OPEN;
			if (BandDecode_Mode == BAND_MODE_AUTO)
			{
				BandDecode_Mode = BAND_MODE_MAN;
				disableManLEDBlink();
				enableManLED();
				disableAutoLED();
				displayMsg(m1_man_mode, m_empty, 2);
			}
			else
			{
				BandDecode_Mode = BAND_MODE_AUTO;
				enableAutoLED();
				disableManLED();
				displayMsg(m1_auto_mode, m_empty, 2);
			}
			updateCurrentEEConfig();
		}

		// Selecting band manual
		//---------------------------------------
		else if (sw_state[UP_SW_ID] == SW_PRESS)
		{
			sw_state[UP_SW_ID] = SW_OPEN;
			if (BandDecode_Mode == BAND_MODE_MAN)
			{
				if (IS_TX)
				{
					displayMsg(m1_band_change_press_when_tx, m2_when_tx, 2);
				}
				else
				{
					if (BandSelected < BAND_MAX)
					{
						BandSelected++;
					}
					else
					{
						BandSelected = 0;
					}
					
					changeBand();
				}
			}
			else
			{
				displayMsg(m1_band_change_press_when_auto, m2_band_change_press_when_auto, 3);
			}
		}

		else if (sw_state[DWN_SW_ID] == SW_PRESS)
		{
			sw_state[DWN_SW_ID] = SW_OPEN;

			if (BandDecode_Mode == BAND_MODE_MAN)
			{
				if (IS_TX)
				{
					displayMsg(m1_band_change_press_when_tx, m2_when_tx, 2);
				}
				else
				{
					if (BandSelected > 0)
					{
						BandSelected--;
					}
					else
					{
						BandSelected = BAND_MAX;
					}
					
					changeBand();
				}
			}
			else
			{
				displayMsg(m1_band_change_press_when_auto, m2_band_change_press_when_auto, 2);
			}
		}

		// Change profile
		//---------------------------------------
		/*
		else if (sw_state[MODE_SW_ID] == SW_HOLD)
		{
			sw_state[MODE_SW_ID] = SW_OPEN;
		
			if (IS_TX)
			{
				displayMsg(m1_profile_change_press_when_tx, m2_when_tx, 2);
			}
			else
			{
				if (profile_Id >= MAX_PROFILES - 1)
				{
					profile_Id = 0;
				}
				else
				{
					profile_Id++;
				}
				char msg[24];
				snprintf(msg, 24, m1_profile, bm_cfg.ProfileName);
				displayMsg(msg, m2_activated, 2);
				readEEConfigProfile(profile_Id);
				//blockPTTTimed();
				applyOutPins();
				updateCurrentEEConfig();
				//displayStatus();
			}
		}
		*/

		// Refresh display if needed after displaying error message
		//---------------------------------------
		if (refresh_disp_needed == 1)
		{
			refresh_disp_needed = 0;
			displayStatus();
		}

		// Refresh output/display if needed after loosing peer link
		//---------------------------------------
		if (refresh_ptt_needed == 1)
		{
			refresh_ptt_needed = 0;
			applyPttStatus();
			displayStatus();
		}

		if (refresh_bandout_needed == 1)
		{
			refresh_bandout_needed = 0;
			applyOutPins();
		}

		// Check and process serial port messages
		//---------------------------------------
		processSerialMsg();

	}
	// Main loop end


}
コード例 #30
0
ファイル: stm32f10x_it.c プロジェクト: thaigiang/VMS
//===========================================
void EXTI1_IRQHandler(void)
{
	if(EXTI_GetFlagStatus(EXTI_Line1) == SET)
	{
		u8 i = 0,j = 0;
		static u8 sec_count = 0;
		static u16 bat_count = 0;
		static u8 current_sec = 0;
		
		sec_count ++;
		if(networkStatus != NETWORK_LOST)
		{
			connTimeout ++;
			if(connTimeout == CONNECTION_TIMEOUT)
			{
				networkStatus = NETWORK_LOST;
				event = EVENT_NETWORK_LOST;
				sysStatus |= SYSTEM_ERR_NETWORK;
				displayStatus(sysStatus);
				sendResponse(CMD_REQUEST_RECONNECT,CMD_REQUEST_RECONNECT);
				connTimeout = 0;
			}
		}
		else //network lost
		{
			if(!fEthernetHardReseted)
				{
					u32 i = 0;
					
					GPIO_InitTypeDef GPIO_InitStructure;
					GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
					GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
					GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
					GPIO_Init(GPIOB, &GPIO_InitStructure);
					GPIO_WriteBit(ETHERNET_RESET_PORT, ETHERNET_RESET_PIN,Bit_SET); 
					
					for(i=0;i<10000;i++) __NOP;
					
					GPIO_WriteBit(ETHERNET_RESET_PORT, ETHERNET_RESET_PIN,Bit_RESET);
					fEthernetHardReseted = true;
				}
		}
		

		// Check if SDC error in running time
		if(sysStatus & SYSTEM_ERR_SDC)
		{
			// Try to reinit SDC
			initSDC();
			// If SDC still not avaiable then reset system
			if(sysStatus & SYSTEM_ERR_SDC)
			{
				if(!fSdcErr)
					NVIC_SystemReset();
			}
			else
			{
				fSdcErr = false;
				displayStatus(sysStatus);
			}	
		}
		
		
		if(sec_count == 60)
		{
			sec_count = 0;
			bat_count ++;
			if(bat_count == 5)
			{
				u16 adc_value = 0;
				u32 battery_volt = 0;
				u32 power_volt = 0;
				
				adc_value = ADC_GetConversionValue(ADC1);
				battery_volt = ((adc_value*33*62/4096)/15);
				if(battery_volt < BATTERY_VOLT_EMPTY)
				{
					GPIO_WriteBit(CHARGE_PORT,CHARGE_PIN,Bit_RESET);
				}
				else if(battery_volt >= BATTERY_VOLT_FULL)
				{
					GPIO_WriteBit(CHARGE_PORT,CHARGE_PIN,Bit_SET);
				}
				adc_value = ADC_GetConversionValue(ADC2);
				power_volt = ((adc_value*33*62/4096)/15);
				if(power_volt < BATTERY_VOLT_FULL)
				{
					//sendWarning(WARNING_OUT_OF_POWER);
//					fWarning = true;
//					warning = WARNING_OUT_OF_POWER;
				}
				bat_count = 0;
			}
			rtS = DS1307_GetTime();
			for(i = 0;i<page->header.itemCount;i++)
			{
				PLAYLIST_ITEM* playlist = (PLAYLIST_ITEM*)page->popup[i].Info.data;
				
				if((playlist[0].header.dataType == PLAYLIST_CLOCK)||(playlist[0].header.dataType == PLAYLIST_TEMP))
					page->popup[i].Info.header.isUpdate = false;
			}
			
			sysTemp = Read_Temperature();
			if(sysTemp > wnConfig.maxTemp)
			{
				//sendWarning(WARNING_TOO_HOT);
				//fWarning = true;
				//warning = WARNING_TOO_HOT;
			}			
		}
		for(i = 0;i<page->header.itemCount;i++)
		{
			if(page->popup[i].Info.header.dataType == POPUP_PLAYLIST)
			{
				PLAYLIST_ITEM* playlist = (PLAYLIST_ITEM*)page->popup[i].Info.data;
				
				if((page->popup[i].Info.header.isUpdate)&&(page->popup[i].Info.header.countDown))
				{
					page->popup[i].Info.header.countDown --;
					if(!page->popup[i].Info.header.countDown)
						page->popup[i].Info.header.isUpdate = false;
				}
				for(j = 0;j<page->popup[i].Info.header.itemCount;j++)
				{
					if((playlist[j].TTL_count < 0xFFFF)&&(playlist[j].TTL_count>0))
						playlist[j].TTL_count --;					
				}
			}
		}
		EXTI_ClearFlag(EXTI_Line1);
	}
}