本文整理汇总了C++中Print函数的典型用法代码示例。如果您正苦于以下问题:C++ Print函数的具体用法?C++ Print怎么用?C++ Print使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Print函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Interrupt
/*
*******************************************************************************
* *
* Interrupt() is used to read in a move when the operator types something *
* while a search is in progress (during pondering as one example.) This *
* routine reads in a command (move) and then makes two attempts to use this *
* input: (1) call Option() to see if the command can be executed; (2) try *
* InputMove() to see if this input is a legal move; If so, and we are *
* pondering see if it matches the move we are pondering. *
* *
*******************************************************************************
*/
void Interrupt(int ply) {
int temp, i, left = 0, readstat, result, time_used;
int save_move_number;
TREE *const tree = block[0];
/*
************************************************************
* *
* If trying to find a move to ponder, and the operator *
* types a command, exit a.s.a.p. *
* *
************************************************************
*/
if (puzzling)
abort_search = 1;
/*
************************************************************
* *
* First check to see if this is a command by calling *
* Option(). Option() will return a 0 if it didn't *
* recognize the command; otherwise it returns a 1 if *
* the command was executed, or a 2 if we need to abort *
* the search to execute the command. *
* *
************************************************************
*/
else
do {
readstat = Read(0, buffer);
if (readstat <= 0)
break;
nargs = ReadParse(buffer, args, " ;");
if (nargs == 0) {
Print(128, "ok.\n");
break;
}
if (strcmp(args[0], ".")) {
save_move_number = move_number;
if (!wtm)
move_number--;
if (root_wtm)
Print(128, "Black(%d): %s\n", move_number, buffer);
else
Print(128, "White(%d): %s\n", move_number, buffer);
move_number = save_move_number;
}
/*
************************************************************
* *
* "." command displays status of current search. *
* *
************************************************************
*/
if (!strcmp(args[0], ".")) {
if (xboard) {
end_time = ReadClock();
time_used = (end_time - start_time);
printf("stat01: %d ", time_used);
printf(BMF " ", tree->nodes_searched);
printf("%d ", iteration_depth);
for (i = 0; i < n_root_moves; i++)
if (!(root_moves[i].status & 128))
left++;
printf("%d %d\n", left, n_root_moves);
fflush(stdout);
break;
} else {
end_time = ReadClock();
time_used = (end_time - start_time);
printf("time:%s ", DisplayTime(time_used));
printf("nodes:" BMF "\n", tree->nodes_searched);
DisplayTreeState(block[0], 1, 0, ply);
}
}
/*
************************************************************
* *
* "mn" command is used to set the move number to a *
* specific value... *
* *
************************************************************
*/
else if (!strcmp("mn", args[0])) {
if (nargs == 2) {
move_number = atoi(args[1]);
Print(128, "move number set to %d\n", move_number);
}
}
//.........这里部分代码省略.........
示例2: Show_Message
void ActBalance::Zone_Report (void)
{
int i, zone, num_zone, num_group;
double factor;
Factor_Group *group;
double average [MAX_PURPOSE], maximum [MAX_PURPOSE], minimum [MAX_PURPOSE];
Show_Message ("Zone Factor Summary");
num_zone = 0;
num_group = factor_group.Num_Records ();
for (i=1; i <= num_group; i++) {
average [i] = 0.0;
maximum [i] = 0.0;
minimum [i] = 10000000.0;
}
//---- print the report ----
Header_Number (ZONE_SUM);
if (!Break_Check (max_zone + 7)) {
Print (1);
Zone_Header ();
}
for (zone = 1; zone <= max_zone; zone++) {
Print (1, "%5d ", zone);
num_zone++;
for (i=1; i <= num_group; i++) {
group = (Factor_Group *) factor_group [i];
if (group->current [zone] > 0.0 && group->target [0] > 0.0) {
factor = (group->target [zone] * group->current [0]) / (group->current [zone] * group->target [0]);
} else {
factor = 1.0;
}
Print (0, " %10.5lf", factor);
average [i] += factor;
if (factor > maximum [i]) maximum [i] = factor;
if (factor < minimum [i]) minimum [i] = factor;
}
}
if (num_zone > 0) {
Break_Check (4);
Print (2, "Average");
for (i=1; i <= num_group; i++) {
Print (0, " %10.5lf ", average [i] / num_zone);
}
Print (1, "Maximum");
for (i=1; i <= num_group; i++) {
Print (0, " %10.5lf ", maximum [i]);
}
Print (1, "Minimum");
for (i=1; i <= num_group; i++) {
Print (0, " %10.5lf ", minimum [i]);
}
}
Header_Number (0);
}
示例3: PVExit
static void PVExit (CPURegs* Regs)
{
Print (stderr, 1, "PVExit ($%02X)\n", Regs->AC);
exit (Regs->AC);
}
示例4: stream
XMLError XMLDocument::SaveFile(FILE* fp, bool compact)
{
XMLPrinter stream(fp, compact);
Print(&stream);
return _errorID;
}
示例5: ShowDistribution
static void ShowDistribution(char *args)
{
Print(0, distribution);
Print(0, warranty);
}
示例6: main
void main(){
char *str;
str=Input();
//printf("%c",str);//加了这句就报错!
Print(str);
}
示例7: fsw_efi_dnode_getinfo
EFI_STATUS fsw_efi_dnode_getinfo(IN FSW_FILE_DATA *File,
IN EFI_GUID *InformationType,
IN OUT UINTN *BufferSize,
OUT VOID *Buffer)
{
EFI_STATUS Status;
FSW_VOLUME_DATA *Volume = (FSW_VOLUME_DATA *)File->shand.dnode->vol->host_data;
EFI_FILE_SYSTEM_INFO *FSInfo;
UINTN RequiredSize;
struct fsw_volume_stat vsb;
if (CompareGuid(InformationType, &GUID_NAME(FileInfo))) {
#if DEBUG_LEVEL
Print(L"fsw_efi_dnode_getinfo: FILE_INFO\n");
#endif
Status = fsw_efi_dnode_fill_FileInfo(Volume, File->shand.dnode, BufferSize, Buffer);
} else if (CompareGuid(InformationType, &GUID_NAME(FileSystemInfo)) == 0) {
#if DEBUG_LEVEL
Print(L"fsw_efi_dnode_getinfo: FILE_SYSTEM_INFO\n");
#endif
// check buffer size
RequiredSize = SIZE_OF_EFI_FILE_SYSTEM_INFO + fsw_efi_strsize(&Volume->vol->label);
if (*BufferSize < RequiredSize) {
*BufferSize = RequiredSize;
return EFI_BUFFER_TOO_SMALL;
}
// fill structure
FSInfo = (EFI_FILE_SYSTEM_INFO *)Buffer;
FSInfo->Size = RequiredSize;
FSInfo->ReadOnly = TRUE;
FSInfo->BlockSize = Volume->vol->log_blocksize;
fsw_efi_strcpy(FSInfo->VolumeLabel, &Volume->vol->label);
// get the missing info from the fs driver
ZeroMem(&vsb, sizeof(struct fsw_volume_stat));
Status = fsw_efi_map_status(fsw_volume_stat(Volume->vol, &vsb), Volume);
if (EFI_ERROR(Status))
return Status;
FSInfo->VolumeSize = vsb.total_bytes;
FSInfo->FreeSpace = vsb.free_bytes;
// prepare for return
*BufferSize = RequiredSize;
Status = EFI_SUCCESS;
} else if (CompareGuid(InformationType, &GUID_NAME(FileSystemVolumeLabelInfoId))) {
#if DEBUG_LEVEL
Print(L"fsw_efi_dnode_getinfo: FILE_SYSTEM_VOLUME_LABEL\n");
#endif
// check buffer size
RequiredSize = SIZE_OF_EFI_FILE_SYSTEM_VOLUME_LABEL_INFO + fsw_efi_strsize(&Volume->vol->label);
if (*BufferSize < RequiredSize) {
*BufferSize = RequiredSize;
return EFI_BUFFER_TOO_SMALL;
}
// copy volume label
fsw_efi_strcpy(((EFI_FILE_SYSTEM_VOLUME_LABEL_INFO *)Buffer)->VolumeLabel, &Volume->vol->label);
// prepare for return
*BufferSize = RequiredSize;
Status = EFI_SUCCESS;
} else {
Status = EFI_UNSUPPORTED;
}
return Status;
}
示例8: main
int main(int argc, char *argv[]){
HREinitBegin(argv[0]);
HREaddOptions(options,"Tool for signature minimization\n\nOptions");
char *files[2];
lts_lib_setup();
HREinitStart(&argc,&argv,1,2,files,"<input> [<output>]");
if (task==Undefined){
Abort("Please select the reduction to apply.");
}
lts_t lts=lts_create();
Debug("reading %s",files[0]);
lts_read(files[0],lts);
Print(infoShort,"input has %u states and %u transitions",
lts->states,lts->transitions);
switch(task){
case Strong:{
lowmem_strong_reduce(lts);
break;
}
case Branching:{
bitset_t divergence=NULL;
if (divergence_sensitive){
divergence=bitset_create(256,256);
lts_find_divergent(lts,tau_step,NULL,divergence);
}
lowmem_branching_reduce(lts,divergence);
break;
}
case Weak:{
setbased_weak_reduce(lts);
break;
}
case Lumping:{
lowmem_lumping_reduce(lts);
break;
}
case Copy:{
break;
}
case Silent:{
silent_compression(lts);
break;
}
case Determinize:{
lts_mkdet(lts);
break;
}
case Cycle:{
lts_cycle_elim(lts);
break;
}
case Merge:{
lts_merge_hyperedges(lts);
break;
}
default: Abort("missing case");
}
Print(infoShort,"reduced LTS has %u states and %u transitions",
lts->states,lts->transitions);
if (files[1]){
Debug("writing %s",files[1]);
lts_write(files[1],lts,NULL,segments);
Debug("output written");
} else {
Debug("no output");
}
HREexit(LTSMIN_EXIT_SUCCESS);
}
示例9: Print
void StringHash::Print()
{
Print(stdout);
}
示例10: Integrate
static int Integrate(creal epsrel, creal epsabs,
cint flags, cnumber mineval, cnumber maxeval,
int key1, int key2, int key3, ccount maxpass,
creal maxchisq, creal mindeviation,
real *integral, real *error, real *prob)
{
TYPEDEFREGION;
Region anchor, *region;
Totals totals[NCOMP];
real nneed, weight;
count dim, comp, iter, nregions, pass = 0, err;
number nwant, nmin = INT_MAX;
int fail = -1;
if( VERBOSE > 1 ) {
char s[512];
sprintf(s, "Divonne input parameters:\n"
" ndim " COUNT "\n ncomp " COUNT "\n"
" epsrel " REAL "\n epsabs " REAL "\n"
" flags %d\n mineval " NUMBER "\n maxeval " NUMBER "\n"
" key1 %d\n key2 %d\n key3 %d\n maxpass " COUNT "\n"
" border " REAL "\n maxchisq " REAL "\n mindeviation " REAL "\n"
" ngiven " NUMBER "\n nextra " NUMBER "\n",
ndim_, ncomp_,
epsrel, epsabs,
flags, mineval, maxeval,
key1, key2, key3, maxpass,
border_.lower, maxchisq, mindeviation,
ngiven_, nextra_);
Print(s);
}
anchor.next = NULL;
for( dim = 0; dim < ndim_; ++dim ) {
Bounds *b = &anchor.bounds[dim];
b->lower = 0;
b->upper = 1;
}
RuleIni(&rule7_);
RuleIni(&rule9_);
RuleIni(&rule11_);
RuleIni(&rule13_);
SamplesIni(&samples_[0]);
SamplesIni(&samples_[1]);
SamplesIni(&samples_[2]);
#ifdef MLVERSION
if( setjmp(abort_) ) goto abort;
#endif
/* Step 1: partition the integration region */
if( VERBOSE ) Print("Partitioning phase:");
if( IsSobol(key1) || IsSobol(key2) || IsSobol(key3) )
IniRandom(2*maxeval, flags);
SamplesLookup(&samples_[0], key1,
(number)47, (number)INT_MAX, (number)0);
SamplesAlloc(&samples_[0]);
totals_ = totals;
Zap(totals);
phase_ = 1;
Explore(&anchor, &samples_[0], INIDEPTH, 1);
for( iter = 1; ; ++iter ) {
Totals *maxtot;
for( comp = 0; comp < ncomp_; ++comp ) {
Totals *tot = &totals[comp];
tot->avg = tot->spreadsq = 0;
tot->spread = tot->secondspread = -INFTY;
}
nregions = 0;
for( region = anchor.next; region; region = region->next ) {
++nregions;
for( comp = 0; comp < ncomp_; ++comp ) {
cResult *r = ®ion->result[comp];
Totals *tot = &totals[comp];
tot->avg += r->avg;
tot->spreadsq += Sq(r->spread);
if( r->spread > tot->spread ) {
tot->secondspread = tot->spread;
tot->spread = r->spread;
tot->region = region;
}
else if( r->spread > tot->secondspread )
tot->secondspread = r->spread;
}
}
maxtot = totals;
for( comp = 0; comp < ncomp_; ++comp ) {
Totals *tot = &totals[comp];
integral[comp] = tot->avg;
//.........这里部分代码省略.........
示例11: Sample
static void Sample(This *t, Region *region)
{
csize_t setsize = SetSize;
creal vol = ldexp(1., -region->div);
real *x = t->frame, *f = x + t->rule.n*t->ndim;
Set *first = t->rule.first, *last = t->rule.last, *s;
Bounds *b, *B = region->bounds + t->ndim;
Result *result = RegionResult(region), *res, *Res = result + t->ncomp;
creal *errcoeff = t->rule.errcoeff;
creal ratio = Sq(IndexSet(first,2)->gen[0]/
IndexSet(first,1)->gen[0]);
ccount offset = 2*t->ndim*t->ncomp;
count dim, rul, n, maxdim = 0;
real maxrange = 0;
for( b = region->bounds, dim = 0; b < B; ++b, ++dim ) {
creal range = b->upper - b->lower;
if( range > maxrange ) {
maxrange = range;
maxdim = dim;
}
}
for( s = first; s <= last; NextSet(s) )
if( s->n ) x = ExpandFS(t, region->bounds, s->gen, x);
DoSample(t, t->rule.n, t->frame, f);
for( res = result; res < Res; ++res ) {
real sum[nrules];
creal *f1 = f;
creal base = *f1*2*(1 - ratio);
real maxdiff = 0;
count bisectdim = maxdim;
for( dim = 0; dim < t->ndim; ++dim ) {
creal *fp = f1 + t->ncomp;
creal *fm = fp + t->ncomp;
creal fourthdiff = fabs(base +
ratio*(fp[0] + fm[0]) - (fp[offset] + fm[offset]));
f1 = fm;
if( fourthdiff > maxdiff ) {
maxdiff = fourthdiff;
bisectdim = dim;
}
}
res->bisectdim = bisectdim;
f1 = f++;
Zap(sum);
for( s = first; s <= last; NextSet(s) )
for( n = s->n; n; --n ) {
creal fun = *f1;
f1 += t->ncomp;
for( rul = 0; rul < nrules; ++rul )
sum[rul] += fun*s->weight[rul];
}
/* Search for the null rule, in the linear space spanned by two
successive null rules in our sequence, which gives the greatest
error estimate among all normalized (1-norm) null rules in this
space. */
for( rul = 1; rul < nrules - 1; ++rul ) {
real maxerr = 0;
for( s = first; s <= last; NextSet(s) )
maxerr = Max(maxerr,
fabs(sum[rul + 1] + s->scale[rul]*sum[rul])*s->norm[rul]);
sum[rul] = maxerr;
}
res->avg = vol*sum[0];
res->err = vol*(
(errcoeff[0]*sum[1] <= sum[2] && errcoeff[0]*sum[2] <= sum[3]) ?
errcoeff[1]*sum[1] :
errcoeff[2]*Max(Max(sum[1], sum[2]), sum[3]) );
}
if( VERBOSE > 2 ) {
Vector(char, out, 64*NDIM + 128*NCOMP);
char *oe = out;
count comp;
cchar *msg = "\nRegion (" REALF ") - (" REALF ")";
for( b = region->bounds; b < B; ++b ) {
oe += sprintf(oe, msg, b->lower, b->upper);
msg = "\n (" REALF ") - (" REALF ")";
}
for( res = result, comp = 0; res < Res; ++res )
oe += sprintf(oe, "\n[" COUNT "] "
REAL " +- " REAL, ++comp, res->avg, res->err);
Print(out);
}
示例12: main
int main( int argc, char* argv[] ) {
Stream* stream = NULL;
Dictionary* dictionary;
Dictionary_Entry_Value* tmpVal0;
Dictionary_Entry_Value* tmpVal1;
MPI_Init( &argc, &argv );
BaseFoundation_Init( &argc, &argv );
BaseIO_Init( &argc, &argv );
stream = Journal_Register (Info_Type, "myStream");
dictionary = Dictionary_New();
tmpVal0 = Dictionary_Entry_Value_NewStruct();
tmpVal1 = Dictionary_Entry_Value_NewStruct();
Dictionary_Entry_Value_AddMember( tmpVal1, "name", Dictionary_Entry_Value_FromString( "bill" ) );
Dictionary_Entry_Value_AddMember( tmpVal1, "value", Dictionary_Entry_Value_FromDouble( 1.0f ) );
Dictionary_Entry_Value_AddMember( tmpVal0, "inside", tmpVal1 );
tmpVal1 = Dictionary_Entry_Value_NewList();
Dictionary_Entry_Value_AddElement( tmpVal1, Dictionary_Entry_Value_FromString( "bottom" ) );
Dictionary_Entry_Value_AddElement( tmpVal1, Dictionary_Entry_Value_FromString( "top" ) );
Dictionary_Entry_Value_AddMember( tmpVal0, "list_one", tmpVal1 );
Dictionary_Add( dictionary, "one", tmpVal0 );
tmpVal0 = Dictionary_Entry_Value_NewStruct();
tmpVal1 = Dictionary_Entry_Value_NewStruct();
Dictionary_Entry_Value_AddMember( tmpVal1, "new_name", Dictionary_Entry_Value_FromString( "frank" ) );
Dictionary_Entry_Value_AddMember( tmpVal1, "value", Dictionary_Entry_Value_FromDouble( 2.0f ) );
Dictionary_Entry_Value_AddMember( tmpVal0, "inside", tmpVal1 );
tmpVal1 = Dictionary_Entry_Value_NewList();
Dictionary_Entry_Value_AddElement( tmpVal1, Dictionary_Entry_Value_FromString( "left" ) );
Dictionary_Entry_Value_AddElement( tmpVal1, Dictionary_Entry_Value_FromString( "right" ) );
Dictionary_Entry_Value_AddMember( tmpVal0, "list_one", tmpVal1 );
Dictionary_AddMerge( dictionary, "one", tmpVal0, Dictionary_MergeType_Append );
Print( dictionary, stream );
Stg_Class_Delete( dictionary );
dictionary = Dictionary_New();
tmpVal0 = Dictionary_Entry_Value_NewStruct();
tmpVal1 = Dictionary_Entry_Value_NewStruct();
Dictionary_Entry_Value_AddMember( tmpVal1, "name", Dictionary_Entry_Value_FromString( "bill" ) );
Dictionary_Entry_Value_AddMember( tmpVal1, "value", Dictionary_Entry_Value_FromDouble( 1.0f ) );
Dictionary_Entry_Value_AddMember( tmpVal0, "inside", tmpVal1 );
tmpVal1 = Dictionary_Entry_Value_NewList();
Dictionary_Entry_Value_AddElement( tmpVal1, Dictionary_Entry_Value_FromString( "bottom" ) );
Dictionary_Entry_Value_AddElement( tmpVal1, Dictionary_Entry_Value_FromString( "top" ) );
Dictionary_Entry_Value_AddMember( tmpVal0, "list_one", tmpVal1 );
Dictionary_Add( dictionary, "one", tmpVal0 );
tmpVal0 = Dictionary_Entry_Value_NewStruct();
tmpVal1 = Dictionary_Entry_Value_NewStruct();
Dictionary_Entry_Value_AddMember( tmpVal1, "new_name", Dictionary_Entry_Value_FromString( "frank" ) );
Dictionary_Entry_Value_AddMember( tmpVal1, "value", Dictionary_Entry_Value_FromDouble( 2.0f ) );
Dictionary_Entry_Value_AddMember( tmpVal0, "inside", tmpVal1 );
tmpVal1 = Dictionary_Entry_Value_NewList();
Dictionary_Entry_Value_AddElement( tmpVal1, Dictionary_Entry_Value_FromString( "left" ) );
Dictionary_Entry_Value_AddElement( tmpVal1, Dictionary_Entry_Value_FromString( "right" ) );
Dictionary_Entry_Value_AddMember( tmpVal0, "list_one", tmpVal1 );
Dictionary_AddMerge( dictionary, "one", tmpVal0, Dictionary_MergeType_Merge );
Print( dictionary, stream );
Stg_Class_Delete( dictionary );
dictionary = Dictionary_New();
tmpVal0 = Dictionary_Entry_Value_NewStruct();
tmpVal1 = Dictionary_Entry_Value_NewStruct();
Dictionary_Entry_Value_AddMember( tmpVal1, "name", Dictionary_Entry_Value_FromString( "bill" ) );
Dictionary_Entry_Value_AddMember( tmpVal1, "value", Dictionary_Entry_Value_FromDouble( 1.0f ) );
Dictionary_Entry_Value_AddMember( tmpVal0, "inside", tmpVal1 );
tmpVal1 = Dictionary_Entry_Value_NewList();
Dictionary_Entry_Value_AddElement( tmpVal1, Dictionary_Entry_Value_FromString( "bottom" ) );
Dictionary_Entry_Value_AddElement( tmpVal1, Dictionary_Entry_Value_FromString( "top" ) );
Dictionary_Entry_Value_AddMember( tmpVal0, "list_one", tmpVal1 );
Dictionary_Add( dictionary, "one", tmpVal0 );
tmpVal0 = Dictionary_Entry_Value_NewStruct();
tmpVal1 = Dictionary_Entry_Value_NewStruct();
Dictionary_Entry_Value_AddMember( tmpVal1, "new_name", Dictionary_Entry_Value_FromString( "frank" ) );
Dictionary_Entry_Value_AddMember( tmpVal1, "value", Dictionary_Entry_Value_FromDouble( 2.0f ) );
Dictionary_Entry_Value_AddMember( tmpVal0, "inside", tmpVal1 );
tmpVal1 = Dictionary_Entry_Value_NewList();
Dictionary_Entry_Value_AddElement( tmpVal1, Dictionary_Entry_Value_FromString( "left" ) );
Dictionary_Entry_Value_AddElement( tmpVal1, Dictionary_Entry_Value_FromString( "right" ) );
Dictionary_Entry_Value_AddMember( tmpVal0, "list_one", tmpVal1 );
Dictionary_AddMerge( dictionary, "one", tmpVal0, Dictionary_MergeType_Replace );
Print( dictionary, stream );
Stg_Class_Delete( dictionary );
BaseIO_Finalise();
BaseFoundation_Finalise();
MPI_Finalize();
return EXIT_SUCCESS;
}
示例13: efi_main
EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
EFI_LOADED_IMAGE *loaded_image;
CHAR8 *b;
UINTN size;
BOOLEAN secure = FALSE;
CHAR8 *sections[] = {
(UINT8 *)".cmdline",
(UINT8 *)".linux",
(UINT8 *)".initrd",
(UINT8 *)".splash",
NULL
};
UINTN addrs[ELEMENTSOF(sections)-1] = {};
UINTN offs[ELEMENTSOF(sections)-1] = {};
UINTN szs[ELEMENTSOF(sections)-1] = {};
CHAR8 *cmdline = NULL;
UINTN cmdline_len;
CHAR16 uuid[37];
EFI_STATUS err;
InitializeLib(image, sys_table);
err = uefi_call_wrapper(BS->OpenProtocol, 6, image, &LoadedImageProtocol, (VOID **)&loaded_image,
image, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (EFI_ERROR(err)) {
Print(L"Error getting a LoadedImageProtocol handle: %r ", err);
uefi_call_wrapper(BS->Stall, 1, 3 * 1000 * 1000);
return err;
}
if (efivar_get_raw(&global_guid, L"SecureBoot", &b, &size) == EFI_SUCCESS) {
if (*b > 0)
secure = TRUE;
FreePool(b);
}
err = pe_memory_locate_sections(loaded_image->ImageBase, sections, addrs, offs, szs);
if (EFI_ERROR(err)) {
Print(L"Unable to locate embedded .linux section: %r ", err);
uefi_call_wrapper(BS->Stall, 1, 3 * 1000 * 1000);
return err;
}
if (szs[0] > 0)
cmdline = (CHAR8 *)(loaded_image->ImageBase + addrs[0]);
cmdline_len = szs[0];
/* if we are not in secure boot mode, accept a custom command line and replace the built-in one */
if (!secure && loaded_image->LoadOptionsSize > 0 && *(CHAR16 *)loaded_image->LoadOptions != 0) {
CHAR16 *options;
CHAR8 *line;
UINTN i;
options = (CHAR16 *)loaded_image->LoadOptions;
cmdline_len = (loaded_image->LoadOptionsSize / sizeof(CHAR16)) * sizeof(CHAR8);
line = AllocatePool(cmdline_len);
for (i = 0; i < cmdline_len; i++)
line[i] = options[i];
cmdline = line;
#if ENABLE_TPM
/* Try to log any options to the TPM, especially manually edited options */
err = tpm_log_event(SD_TPM_PCR,
(EFI_PHYSICAL_ADDRESS) loaded_image->LoadOptions,
loaded_image->LoadOptionsSize, loaded_image->LoadOptions);
if (EFI_ERROR(err)) {
Print(L"Unable to add image options measurement: %r", err);
uefi_call_wrapper(BS->Stall, 1, 200 * 1000);
}
#endif
}
/* export the device path this image is started from */
if (disk_get_part_uuid(loaded_image->DeviceHandle, uuid) == EFI_SUCCESS)
efivar_set(L"LoaderDevicePartUUID", uuid, FALSE);
/* if LoaderImageIdentifier is not set, assume the image with this stub was loaded directly from UEFI */
if (efivar_get_raw(&global_guid, L"LoaderImageIdentifier", &b, &size) != EFI_SUCCESS) {
CHAR16 *loaded_image_path = DevicePathToStr(loaded_image->FilePath);
efivar_set(L"LoaderImageIdentifier", loaded_image_path, FALSE);
FreePool(loaded_image_path);
}
/* if LoaderFirmwareInfo is not set, let's set it */
if (efivar_get_raw(&global_guid, L"LoaderFirmwareInfo", &b, &size) != EFI_SUCCESS) {
CHAR16 *loader_firmware_info = PoolPrint(L"%s %d.%02d", ST->FirmwareVendor, ST->FirmwareRevision >> 16, ST->FirmwareRevision & 0xffff);
efivar_set(L"LoaderFirmwareInfo", loader_firmware_info, FALSE);
FreePool(loader_firmware_info);
}
示例14: SetTime
static void SetTime(char *arg)
{
int ttmoves, ttime, tminutes, tseconds, inc = 0;
char *x, *colon;
char *args[3];
args[0] = strtok(arg, " \t");
args[1] = strtok(NULL, " \t");
args[2] = strtok(NULL, " \t");
if(XBoardMode) {
sscanf(args[0], "%d", &ttmoves);
colon = strchr(args[1], ':'); /* check for time in xx:yy format */
if(colon) {
sscanf(args[1], "%d:%d", &tminutes, &tseconds);
ttime = (tminutes * 60) + tseconds;
} else {
sscanf(args[1], "%d", &tminutes);
ttime = tminutes * 60;
}
sscanf(args[2], "%d", &inc);
TwoTimeControls = FALSE;
TMoves = ttmoves;
TTime = ttime;
Increment = inc;
Moves[White] = Moves[Black] = TMoves;
Time[White] = Time[Black] = TTime;
}
else {
x = strtok(args[0], "/+ \t\n\r");
if(x) {
if(!strcmp(x, "sd")) ttmoves = 0;
else if(!strcmp(x, "fixed")) ttmoves = -1;
else sscanf(x, "%d", &ttmoves);
x = strtok(NULL, "/ \t\n\r");
if(x) {
sscanf(x, "%d", &ttime);
for(x++; *x; x++) {
if(*x == '+') {
sscanf(x+1, "%d", &inc);
break;
}
}
if(args[1] != NULL) {
x = strtok(args[1], " /\n\t\r");
TMoves2 = -1;
if(!strcmp(x, "sd")) TMoves2 = 0;
else sscanf(x, "%d", &TMoves2);
x = strtok(NULL, " /\n\t\r");
if(x) {
TTime2 = -1;
sscanf(x, "%d", &TTime2);
if(TMoves2 >= 0 && TTime2 > 0)
TwoTimeControls = TRUE;
}
}
Print(0, "Timecontrol is ");
if(ttmoves >= 0) {
if(ttmoves == 0) Print(0, "all ");
else Print(0, "%d ", ttmoves);
if(inc) {
Print(0, "moves in %d mins + %d secs Increment\n",
ttime, inc);
} else {
Print(0, "moves in %d mins\n", ttime);
}
TMoves = ttmoves;
TTime = ttime*60;
Increment = inc;
Moves[White] = Moves[Black] = TMoves;
Time[White] = Time[Black] = TTime;
}
else {
Print(0, "%d seconds/move fixed time\n", ttime);
TMoves = -1;
TTime = ttime;
}
if(TwoTimeControls) {
Print(0, "Second Timecontrol is ");
if(TMoves2 == 0) Print(0, "all ");
else Print(0, "%d ", TMoves2);
Print(0, "moves in %d mins\n", TTime2);
TTime2 *= 60;
}
}
}
}
}
示例15: userFile
int FixUsersCommand::Execute() {
std::cout << "Runnning FixUsersCommand::Execute" << std::endl;
File userFile(syscfg.datadir, USER_LST);
if (!userFile.Exists()) {
Print(NOK, true, "%s does not exist.", userFile.full_pathname().c_str());
giveUp();
}
WUserManager userMgr;
userMgr.InitializeUserManager(syscfg.datadir, sizeof(userrec), syscfg.maxusers);
Print(OK, true, "Checking USER.LST... found %d user records.", userMgr.GetNumberOfUserRecords());
Print(OK, true, "TBD: Check for trashed user recs.");
if (userMgr.GetNumberOfUserRecords() > syscfg.maxusers) {
Print(OK, true, "Might be too many.");
maybeGiveUp();
} else {
Print(OK, true, "Reasonable number.");
}
std::vector<smalrec> smallrecords;
std::set<std::string> names;
const int num_user_records = userMgr.GetNumberOfUserRecords();
for(int i = 1; i <= num_user_records; i++) {
WUser user;
userMgr.ReadUser(&user, i);
user.FixUp();
userMgr.WriteUser(&user, i);
if (!user.IsUserDeleted() && !user.IsUserInactive()) {
smalrec sr = { 0 };
strcpy((char*) sr.name, user.GetName());
sr.number = static_cast<unsigned short>(i);
std::string namestring((char*) sr.name);
if (names.find(namestring) == names.end()) {
smallrecords.push_back(sr);
names.insert(namestring);
const std::string msg = StringPrintf("Keeping user: %s #%d", sr.name, sr.number);
Print(OK, true, msg.c_str());
}
else {
std::cout << "[skipping duplicate user: " << namestring << " #" << sr.number << "]";
}
}
};
std::sort(smallrecords.begin(), smallrecords.end(), [](const smalrec& a, const smalrec& b) -> bool {
int equal = strcmp((char*)a.name, (char*)b.name);
// Sort by user number if names match.
if (equal == 0) {
return a.number < b.number;
}
// Otherwise sort by name comparison.
return equal < 0;
});
printf("size=%lu %lu\n", smallrecords.size(), sizeof(smalrec) * smallrecords.size());
Print(OK, true, "Checking NAMES.LST");
File nameFile(syscfg.datadir, NAMES_LST);
if (!nameFile.Exists()) {
Print(NOK, true, "%s does not exist, regenerating with %d names", nameFile.full_pathname().c_str(),
smallrecords.size());
nameFile.Close();
nameFile.Open(File::modeCreateFile | File::modeBinary | File::modeWriteOnly);
nameFile.Write(&smallrecords[0], sizeof(smalrec) * smallrecords.size());
nameFile.Close();
} else {
if (nameFile.Open(File::modeReadOnly | File::modeBinary)) {
unsigned long size = nameFile.GetLength();
unsigned short recs = static_cast<unsigned short>(size / sizeof(smalrec));
if (recs != status.users) {
status.users = recs;
Print(NOK, true, "STATUS.DAT contained an incorrect user count.");
} else {
Print(OK, true, "STATUS.DAT matches expected user count of %d users.", status.users);
}
}
nameFile.Close();
}
return 0;
}