static void
round_str (FILE *fout, const char *s, int prec, int emin, int emax,
	   bool ibm_ld)
{
  mpfr_t f;
  mpfr_set_default_prec (prec);
  mpfr_set_emin (emin);
  mpfr_set_emax (emax);
  mpfr_init (f);
  int r = string_to_fp (f, s, MPFR_RNDD);
  if (ibm_ld)
    {
      assert (prec == 106 && emin == -1073 && emax == 1024);
      /* The maximum value in IBM long double has discontiguous
	 mantissa bits.  */
      mpfr_t max_value;
      mpfr_init2 (max_value, 107);
      mpfr_set_str (max_value, "0x1.fffffffffffff7ffffffffffffcp+1023", 0,
		    MPFR_RNDN);
      if (mpfr_cmpabs (f, max_value) > 0)
	r = 1;
      mpfr_clear (max_value);
    }
  mpfr_fprintf (fout, "\t%s,\n", r ? "false" : "true");
  print_fp (fout, f, ",\n");
  string_to_fp (f, s, MPFR_RNDN);
  print_fp (fout, f, ",\n");
  string_to_fp (f, s, MPFR_RNDZ);
  print_fp (fout, f, ",\n");
  string_to_fp (f, s, MPFR_RNDU);
  print_fp (fout, f, "");
  mpfr_clear (f);
}
void display_proposal_info(proposal_info_type *info) {
    
    print_nl();
    print_nl();
    
    print_str("*************************************************\n");
    print_str("Title: ");
    print_str(info->title);
    print_nl();
    
    print_str("Start Date: ");
    
    if (info->start_date.month !=0)  {
		print_date(info->start_date);
    }

    print_nl();
    print_str("End Date: ");
    
    if (info->end_date.month !=0)  {
		print_date(info->end_date);
    }
    
    print_nl();
    
    print_str("Fee/Profit: ");
    print_fp(info->fee);
    print_nl();
    print_str("*************************************************\n");
    
}
Exemple #3
0
Fichier : search.c Projet : vab/cks
int  retrieve_key_info(PGconn *conn, char *fingerprint)
{
	PGresult *result0 = NULL;
	PGresult *result1 = NULL;

	unsigned int nts = 0;

	char query0[200];
	char query1[155];
	unsigned char buff[650];


	snprintf(query0,199,"select fp, key_id, algorithm, size, c_time, e_time, revoked from \
                           cks_key_info_table where fp='%s'", fingerprint);
	snprintf(query1,150,"select  DISTINCT(uid) from cks_uid_table where fp='%s'", fingerprint);

	result0 = PQexec(conn, query0);
	if((PQresultStatus(result0) != PGRES_TUPLES_OK) && (PQresultStatus(result0) != PGRES_COMMAND_OK))
	{
		fprintf(stderr,_("search.c:  Command didn't return tuples properly.\n"));
		fprintf(stderr,_("search.c:  Failing Query: %s\n"),query0);
		PQclear(result0);
		db_exit_nicely(conn);
	}
	if(PQntuples(result0) == 0)
	{
		printf(_("Error:  No Records Found.\n"));
		printf("<br></br>\n");
		printf(_("A Database error Occured.\n"));
		printf(_("Child records appear to be missing.\n"));
		printf(_("Logging Internal Data Corruption...\n"));
		printf(_("Please try another key, or try the same key on another server.\n"));
	}
	else
	{
		result1 = PQexec(conn, query1);
		if((PQresultStatus(result1) != PGRES_TUPLES_OK) && (PQresultStatus(result1) != PGRES_COMMAND_OK))
		{
			fprintf(stderr, _("search.c:  Command didn't return tuples properly.\n"));
			fprintf(stderr, _("search.c:  Failing Query: %s\n"),query1);
			PQclear(result1);
			db_exit_nicely(conn);
		}
		nts = PQntuples(result1);
		if(nts == 0)
		{
			printf(_("No Records Found.\n"));
		}
		else
		{
			int i = 0;
			int revoked = 0;
			unsigned char algo[4];
			unsigned char algo_id = 0x00;
			long expiration_time = 0;
			long creation_time = 0;
			unsigned char creation_time_str[27];
			long current_time = 0;

			current_time = time(NULL);
			memset(creation_time_str,0x00,27);

			algo_id = atoi(PQgetvalue(result0,0,2));
			set_pk_algo_type(algo_id,algo);

			creation_time = 0;
			expiration_time = 0;
			revoked = 0;

			creation_time = atol(PQgetvalue(result0,0,4));
			expiration_time = atol(PQgetvalue(result0,0,5));
			revoked = atoi(PQgetvalue(result0,0,6));

			printf("<pre>\n");
			if(revoked == 1)
			{
				printf(_("<h3><font color=\"RED\">* KEY REVOKED *</font></h3>\n"));
			}
			if( (expiration_time != 0) && (current_time >= expiration_time) )
			{
				printf(_("<h3><font color=\"RED\">* KEY EXPIRED *</font></h3>\n"));
			}
			printf(_("Key ID           Algorithm/Size     Creation Time"));
			if(expiration_time != 0)
			{
				printf(_("                   Expiration Time"));
			}
			printf("\n");
			printf("0x%s       %s/%s           ", PQgetvalue(result0,0,1),algo,PQgetvalue(result0,0,3));

			if(expiration_time != 0)
			{
				creation_time_str[0] = '\0';
				snprintf(creation_time_str,26,"%s",ctime(&(creation_time)));
				creation_time_str[26] = '\0';
				printf("%s        %s",creation_time_str, ctime(&(expiration_time)));
			}
			else
			{
				printf("%s", ctime(&(creation_time)));
			}

			printf("\n");
			printf(_("<li>Fingerprint: <a href=\"search.cgi?stype=fp&fp="));
			printf("%s\">",fingerprint);
			print_fp(fingerprint);
			printf("</a></li>\n");
			printf("<ul>\n");

			for(i=0;i<nts;i++)
			{
				printf(_("\n<li>User ID: "));
				strncpy(buff,PQgetvalue(result1,i,0),649);
				print_sig_data(buff);
				printf("</li>\n");
				buff[0]='\0';
			}
			printf("</ul>\n");
			printf("</pre>\n");
			printf("<hr size=\"1\" width=\"100%%\">\n");
			fflush(0);
		}
	}

	PQclear(result0);
	PQclear(result1);
	printf("\n");


	return 0;
}