Exemplo n.º 1
0
/* Constructs newt screens showing server certificate credentials.
 * Returns 1 if user says ok, 2 if not.
 */
static int
show_cert (X509 *cert)
{
	X509_NAME	*name;
	newtGrid	grid, serverGrid, issuerGrid, certGrid;
	newtComponent	form;

	grid = newtCreateGrid(1,2);
	certGrid = newtCreateGrid(2,2);

	/* Subject */
	name = X509_get_subject_name(cert);

	serverGrid = show_names(name);

	newtGridSetField(certGrid, 0,0, NEWT_GRID_COMPONENT,
		newtLabel(-1,-1, _("Installation Server:")),
		2, 0, 0, 0,  NEWT_ANCHOR_LEFT | NEWT_ANCHOR_TOP, 0);

	/* Issuer (CA) */
	name = X509_get_issuer_name(cert);

	issuerGrid = show_names(name);

	newtGridSetField(certGrid, 1,0, NEWT_GRID_COMPONENT,
		newtLabel(-1,-1, _("Certified by:")),
		2, 0, 0, 0,  NEWT_ANCHOR_LEFT | NEWT_ANCHOR_TOP, 0);

	newtGridSetField(certGrid, 0, 1, NEWT_GRID_SUBGRID, serverGrid,
		0, 0, 2, 0, NEWT_ANCHOR_LEFT | NEWT_ANCHOR_TOP, 0);
	newtGridSetField(certGrid, 1, 1, NEWT_GRID_SUBGRID, issuerGrid,
		0, 0, 0, 0, NEWT_ANCHOR_RIGHT | NEWT_ANCHOR_TOP, 0);

	newtGridSetField(grid, 0, 0, NEWT_GRID_SUBGRID, certGrid,
		0, 0, 0, 1, NEWT_ANCHOR_LEFT,
		NEWT_GRID_FLAG_GROWX);

	newtGridWrappedWindow(grid, _("Authenticate Installation Server"));
	form = newtForm(NULL, NULL, 0);
	newtGridAddComponentsToForm(grid, form, 1);

	newtDrawForm(form);
	newtRefresh();

	sleep(10);

	newtPopWindow();

	return 1;
}
Exemplo n.º 2
0
int main (void)
{
	names condidate;
	get_names (&condidate);
	printf ("Let's welcome ");
	show_names (&condidate);
	printf (" to this program!\n");
	return 0;
}
Exemplo n.º 3
0
Arquivo: w2.c Projeto: royye62/mydemo
int main(void)
{
	char **pnames;
	int m, n;

	printf("pls input m & n: ");
	scanf("%d%d", &m, &n);

	pnames = alloc_names(m, 6);
	rand_names(pnames, m, 6);
	show_names(pnames, m);

	printf("------> 退出顺序为: <------\n");
	int out = 0, count = 0, i;
	while (out < m)
	{
		for (i = 0; i < m; i++)	
		{
			if (NULL != pnames[i])	
				count++;

			if (count == n)
			{
				printf("%2d: %s\n", i + 1, pnames[i]);	
				free(pnames[i]);
				pnames[i] = NULL;

				out++;
				count = 0;
			}
		}
	}

	free(pnames);

	return 0;
}
Exemplo n.º 4
0
static bool select_font( bool is_prn )
{
int button, cx, cy, cw, ch, mousey, slidey, dum;
int index, i, double_click;
long pos;
static int top = 0;                 /* first name set to the top */

   wind_update(BEG_UPDATE);

   set_slider_size();                     /* set slider size and position, like a GEM window */
   set_slider_pos(top);

   ((TEDINFO *)chooser[CHACTION].ob_spec)->te_ptext = " Choose GDOS font ";
   ((TEDINFO *)chooser[CHTITLE].ob_spec)->te_ptext = is_prn? " Printer font list: ": " Screen font list: ";
   ((TEDINFO *)chooser[GEMFNAME].ob_spec)->te_ptext = gem_file_name;
   ((TEDINFO *)chooser[GEMFNAME].ob_spec)->te_txtlen = sizeof(gem_file_name);
   form_center(chooser, &cx, &cy, &cw, &ch);
   form_dial(FMD_START, 0, 0, 0, 0, cx, cy, cw, ch);
   objc_draw(chooser, ROOT, MAX_DEPTH, cx, cy, cw, ch);

   /*
   ** the chooser can show up to MAX_NAMES names. If there are fewer than this,
   ** the empty slots are disabled by clearing the TOUCHEXIT flags
   */
   for( i=0; i<MAX_NAMES; i++ ) {
      if( i<nr_names ) {
	 chooser[NAME1+i].ob_flags |= TOUCHEXIT;
      }
      else {
	 chooser[NAME1+i].ob_flags &= ~TOUCHEXIT;
      } /* if */
   } /* for */
   show_names( top );    /* display the font names */

   /** the main loop **/
   
   do {
      button =form_do( chooser, GEMFNAME );
      dprintf(( "\033Hbutton is %x\n", button)); dgetchar();
      if(button&0x8000) {     /* double click */
	 double_click = TRUE;
	 button &= 0x7fff;
      }
      else double_click = FALSE;
      if(button ==DNARR) {
	 if((top+MAX_NAMES)<nr_names) {
	    top++;   /* next name in the list */
	    show_names( top );
	    set_slider_pos(top);
	    objc_draw(chooser, SLIDEBAR, MAX_DEPTH, cx, cy, cw, ch);
	 }
      }
      else if(button ==UPARR) {
	 if(top>0) {
	    top--;
	    show_names( top );
	    set_slider_pos(top);
	    objc_draw(chooser, SLIDEBAR, MAX_DEPTH, cx, cy, cw, ch);
	 }
      }
      else if(button ==SLIDEBAR && nr_names>MAX_NAMES) { /* handle clicks on the slidebar */
	 graf_mkstate(&dum, &mousey, &dum, &dum);     /* where is the mouse - above or below the slider? */
	 objc_offset(chooser, SLIDER, &dum, &slidey);
	 if(mousey<slidey) {                       /* mouse is above the slider */
	    top-=MAX_NAMES;                        /* move up one page of names */
	    if(top<0) top =0;
	 }
	 else {
	    top+=MAX_NAMES;
	    if(top>(nr_names-MAX_NAMES)) top =nr_names-MAX_NAMES;
	 } /* if */
	 show_names( top );
	 set_slider_pos(top);
	 objc_draw(chooser, SLIDEBAR, MAX_DEPTH, cx, cy, cw, ch);
      }
      else if(button ==SLIDER && nr_names>MAX_NAMES) {      /* handle the slider */
	 pos =graf_slidebox(chooser, SLIDEBAR, SLIDER, 1);   /* the position the user wants */
	 chooser[SLIDER].ob_y =pos*(long)(chooser[SLIDEBAR].ob_height-chooser[SLIDER].ob_height)/1000;
	 top =pos*(nr_names-MAX_NAMES)/1000;
	 if(top<0) top =0;
	 if(top>(nr_names-MAX_NAMES)) top =nr_names-MAX_NAMES;
	 show_names( top );
	 objc_draw(chooser, SLIDEBAR, MAX_DEPTH, cx, cy, cw, ch);
      }
      else if(button>=NAME1 && button<=NAME8) {
	 /*** the user has clicked on a font name ***/
	 index = top+button-NAME1;
         dprintf(( "\033Hindex is %d\n", index)); dgetchar();
	 if( iSelected == index ) {    /* the name is already selected */
	    assert( iSelected >=0 );
	    assert( iSelected < nr_names );
	    iSelected = NO_INDEX;      /* deselect it */
	    highlight(button);         /* remove the highlight from the name */
	 }
	 else {
	    /* is the currently selected font name displayed in the box? */
	    if( iSelected!=NO_INDEX
	     && (iSelected+NAME1-top)>=NAME1
	     && (iSelected+NAME1-top)<=NAME8 ) {
	       highlight( iSelected+NAME1-top );        /* remove highlight */
	    } /* if */
	    iSelected = index;    /* set the index for the new selection */
	    highlight(button);         /* and highlight it */
	 } /* if */
	 if(double_click) button =CHOOSEOK;   /* if double clicked on a name, exit immediately */
      } /* if */
      assert( iSelected == NO_INDEX || iSelected >=0 );
      assert( iSelected == NO_INDEX || iSelected < nr_names );
   } while(button!=CHOOSEOK && button!=CHOOSECA);


   /** returned from form, process user actions **/

   dprintf(( "\033HiSelected is %d\n", iSelected)); dgetchar();
   dprintf(( "selected name is %s\n", name_table[iSelected].name ));
   dprintf(( "gem file name is %s\n", 
		     ((TEDINFO *)chooser[GEMFNAME].ob_spec)->te_ptext ));
   dprintf(( "%s format%s\n", 
      chooser[MOT].ob_state&SELECTED ? "motorola" : "intel",
      chooser[WIDONLY].ob_state&SELECTED ? ", width tables only" : "" ));
   dgetchar();

   assert( (chooser[MOT].ob_state & SELECTED) != (chooser[INTEL].ob_state&SELECTED) );
   fMot = (chooser[MOT].ob_state & SELECTED) != 0;
   fWidOnly = (chooser[WIDONLY].ob_state & SELECTED) != 0; 
   chooser[button].ob_state &= ~SELECTED;
   form_dial( FMD_FINISH, 0, 0, 0, 0, cx, cy, cw, ch );
   wind_update( END_UPDATE );
   return button==CHOOSEOK;
} /* select_font() */