示例#1
0
double fixtod(int dp, long xfix)
{
 int ibeg;
 int iend;
 double temp;
 int hold;
 int i;
 temp = xfix;
 if (temp > 999999999)
    temp = 999999999;
 if (temp < -999999999)
    temp = -999999999;
 sprintf(buffer,"%14.1lf",temp);
 if (dp > 9)
    dp = 9;
 if (dp < 0)
    dp = 0;
 buffer[12] = 0;
 ibeg = 12 - dp;
 iend = 13;
 for (i=iend; i>ibeg; i--)
   {
    buffer[i] = buffer[i-1];
   }
 buffer[i] = '.';
 hold = strpos;
 temp = strd(buffer,0,0);
 strpos = hold;
 return temp;
}
	static void
add_password( char* user, FILE* f ,char *passwd)
{
	char pass[100];
	char* pw;
	char* cpw;
	char salt[3];

	if ( ! isatty( fileno( stdin ) ) )
	{
		(void) fgets( pass, sizeof(pass), stdin );
		if ( pass[strlen(pass) - 1] == '\n' )
			pass[strlen(pass) - 1] = '\0';
		pw = pass;
	}
	else
	{
		/* Original Code*//*
				     pw = strd( (char*) getpass( "New password:"******"Re-type new password:"******"They don't match, sorry.\n" );
				     if ( tfd != -1 )
				     unlink( temp_template );
				     exit( 1 );
				     }*/

		pw = strd(passwd);
	}
	(void) srandom( (int) time( (time_t*) 0 ) );
	to64( &salt[0], random(), 2 );
	cpw = crypt( pw, salt );
	printf("%s:%s\n",user,cpw);
	(void) fprintf( f, "%s:%s\n", user, cpw );
}
示例#3
0
long strfix(char strg[], int pos, int len, int dp)
{
 double temp;
 char tstrg[35];
 int i;
 temp = strd(strg,pos,len);
 return dtofix(dp,temp);
}
示例#4
0
float strf(char strg[], int pos, int len)
{
 return (float)strd(strg,pos,len);
}