本文整理汇总了C++中EXIT函数的典型用法代码示例。如果您正苦于以下问题:C++ EXIT函数的具体用法?C++ EXIT怎么用?C++ EXIT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了EXIT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: kmdf1394_AsyncWrite
//.........这里部分代码省略.........
ENTER("kmdf1394_AsyncWrite");
ioTarget = deviceExtension->StackIoTarget;
pIrb = ExAllocatePoolWithTag(NonPagedPool, sizeof(IRB), POOLTAG_KMDF_VDEV);
if (!pIrb)
{
TRACE(TL_ERROR, ("Failed to allocate pIrb!\n"));
return STATUS_INSUFFICIENT_RESOURCES;
}
RtlZeroMemory (pIrb, sizeof (IRB));
pIrb->FunctionNumber = REQUEST_ASYNC_WRITE;
pIrb->Flags = 0;
pIrb->u.AsyncWrite.DestinationAddress = AsyncWrite->DestinationAddress;
pIrb->u.AsyncWrite.nNumberOfBytesToWrite = AsyncWrite->nNumberOfBytesToWrite;
pIrb->u.AsyncWrite.nBlockSize = AsyncWrite->nBlockSize;
pIrb->u.AsyncWrite.fulFlags = AsyncWrite->fulFlags;
if (AsyncWrite->bGetGeneration)
{
TRACE(
TL_TRACE,
("Retrieved Generation Count = 0x%x\n",
pIrb->u.AsyncRead.ulGeneration));
pIrb->u.AsyncRead.ulGeneration = deviceExtension->GenerationCount;
}
else
{
pIrb->u.AsyncRead.ulGeneration = AsyncWrite->ulGeneration;
}
pMdl = IoAllocateMdl (
AsyncWrite->Data,
AsyncWrite->nNumberOfBytesToWrite,
FALSE,
FALSE,
NULL);
if(NULL == pMdl)
{
TRACE(TL_ERROR, ("Failed to allocate mdl!\n"));
ExFreePoolWithTag (pIrb, POOLTAG_KMDF_VDEV);
return STATUS_INSUFFICIENT_RESOURCES;
}
MmBuildMdlForNonPagedPool (pMdl);
pIrb->u.AsyncWrite.Mdl = pMdl;
//
// We need to create a WDF Memory object for the IRB to nestle in
// for an async request.
//
ntStatus = WdfMemoryCreatePreallocated (
WDF_NO_OBJECT_ATTRIBUTES,
pIrb,
sizeof (IRB),
&Memory);
if (!NT_SUCCESS (ntStatus))
{
TRACE (
TL_ERROR,
("Failed WdfMemoryCreate %d\n",
ntStatus));
IoFreeMdl (pIrb->u.AsyncWrite.Mdl);
ExFreePoolWithTag (pIrb, POOLTAG_KMDF_VDEV);
return ntStatus;
}
WdfRequestSetCompletionRoutine (
Request,
kmdf1394_AsyncWriteCompletion,
Memory);
ntStatus = kmdf1394_SubmitIrpAsync (ioTarget, Request, Memory);
if (!NT_SUCCESS(ntStatus))
{
if (ntStatus != STATUS_INVALID_GENERATION)
{
TRACE(TL_ERROR, ("SubmitIrpSync failed = 0x%x\n", ntStatus));
}
else
{
TRACE (TL_ERROR, ("Invalid Generation count\n"));
}
IoFreeMdl (pIrb->u.AsyncWrite.Mdl);
ExFreePoolWithTag (pIrb, POOLTAG_KMDF_VDEV);
WdfObjectDelete (Memory);
}
EXIT("kmdf1394_AsyncWrite", ntStatus);
return ntStatus;
} // kmdf1394_AsyncWrite
示例2: sys__msg_post
/*!
* Send message to queue or signal to thread
*/
int sys__msg_post ( int dest_type, void *dest, msg_t *msg, uint flags )
{
thread_t *thr;
kthread_t *kthr, *new_kthr;
kthrmsg_qs *thrmsg;
kgmsg_q *kgmsgq;
kmsg_q *kmsgq;
msg_q *msgq;
kmsg_t *kmsg;
msg_t *cmsg;
ASSERT_ERRNO_AND_EXIT ( dest && msg, E_INVALID_HANDLE );
if ( dest_type == MSG_THREAD || dest_type == MSG_SIGNAL )
{
thr = dest;
kthr = k_get_kthread ( thr );
ASSERT_ERRNO_AND_EXIT ( kthr, E_DONT_EXIST );
thrmsg = k_get_thrmsg ( kthr );
kmsgq = &thrmsg->msgq;
}
else if ( dest_type == MSG_QUEUE )
{
msgq = dest;
kgmsgq = msgq->handle;
ASSERT_ERRNO_AND_EXIT ( kgmsgq && kgmsgq->id == msgq->id,
E_INVALID_HANDLE );
kmsgq = &kgmsgq->mq;
}
else {
EXIT ( E_INVALID_TYPE );
}
if ( dest_type == MSG_THREAD || dest_type == MSG_QUEUE )
{
/* send message to queue */
if ( kmsgq->min_prio <= msg->type ) /* msg has required prio. */
{
kmsg = kmalloc ( sizeof (kmsg_t) + msg->size );
ASSERT_ERRNO_AND_EXIT ( kmsg, E_NO_MEMORY );
kmsg->msg.type = msg->type;
kmsg->msg.size = msg->size;
memcpy ( kmsg->msg.data, msg->data, msg->size );
list_append ( &kmsgq->msgs, kmsg, &kmsg->list );
/* is thread waiting for message? */
if ( k_release_thread ( &kmsgq->thrq ) )
k_schedule_threads ();
EXIT ( SUCCESS );
}
else { /* ignore message */
EXIT ( E_IGNORED );
}
}
/* must be MSG_SIGNAL */
if ( thrmsg->sig_prio <= msg->type )
{
/* create thread that will service this signal */
cmsg = k_create_thread_private_storage ( kthr,
sizeof (msg_t) + msg->size );
cmsg->type = msg->type;
cmsg->size = msg->size;
memcpy ( cmsg->data, msg->data, msg->size );
new_kthr = k_create_thread (
thrmsg->signal_handler, cmsg, pi.exit,
k_get_thread_prio ( kthr ) + 1, NULL, 0, 1
);
ASSERT_ERRNO_AND_EXIT ( new_kthr, k_get_errno() );
k_set_thread_private_storage ( new_kthr, cmsg );
SET_ERRNO ( SUCCESS );
k_schedule_threads ();
RETURN ( SUCCESS );
}
else { /* ignore signal */
EXIT ( E_IGNORED );
}
}
示例3: execute
/*
* Execute the shell command tree pointed to by t.
*/
static void
execute(struct tnode *t, int *pin, int *pout)
{
struct tnode *t1;
enum tnflags f;
pid_t cpid;
int i, pfd[2];
const char **gav;
const char *cmd, *p;
if (t == NULL)
return;
switch (t->ntype) {
case TLIST:
f = t->nflags & (FFIN | FPIN | FINTR);
if ((t1 = t->nleft) != NULL)
t1->nflags |= f;
execute(t1, NULL, NULL);
if ((t1 = t->nright) != NULL)
t1->nflags |= f;
execute(t1, NULL, NULL);
return;
case TPIPE:
if (pipe(pfd) == -1) {
err(SH_ERR, FMT1S, ERR_PIPE);
if (pin != NULL) {
(void)close(pin[0]);
(void)close(pin[1]);
}
return;
}
f = t->nflags;
if ((t1 = t->nleft) != NULL)
t1->nflags |= FPOUT | (f & (FFIN|FPIN|FINTR|FPRS));
execute(t1, pin, pfd);
if ((t1 = t->nright) != NULL)
t1->nflags |= FPIN | (f & (FAND|FPOUT|FINTR|FPRS));
execute(t1, pfd, pout);
(void)close(pfd[0]);
(void)close(pfd[1]);
return;
case TCOMMAND:
if (t->nav == NULL || t->nav[0] == NULL) {
/* should never (but can) be true */
err(SH_ERR, FMT1S, "execute: Invalid command");
return;
}
cmd = t->nav[0];
if (EQUAL(cmd, ":")) {
status = SH_TRUE;
return;
}
if (EQUAL(cmd, "chdir")) {
ascan(t->nav[1], &trim);
if (t->nav[1] == NULL)
err(SH_ERR, FMT2S, cmd, ERR_ARGCOUNT);
else if (chdir(t->nav[1]) == -1)
err(SH_ERR, FMT2S, cmd, ERR_BADDIR);
else
status = SH_TRUE;
return;
}
if (EQUAL(cmd, "exit")) {
if (prompt == NULL) {
(void)lseek(FD0, (off_t)0, SEEK_END);
EXIT(status);
}
return;
}
if (EQUAL(cmd, "login") || EQUAL(cmd, "newgrp")) {
if (prompt != NULL) {
p = (*cmd == 'l') ? PATH_LOGIN : PATH_NEWGRP;
vscan(t->nav, &trim);
(void)sasignal(SIGINT, SIG_DFL);
(void)sasignal(SIGQUIT, SIG_DFL);
(void)pexec(p, (char *const *)t->nav);
(void)sasignal(SIGINT, SIG_IGN);
(void)sasignal(SIGQUIT, SIG_IGN);
}
err(SH_ERR, FMT2S, cmd, ERR_EXEC);
return;
}
if (EQUAL(cmd, "shift")) {
if (dolc > 1) {
dolv = &dolv[1];
dolc--;
status = SH_TRUE;
return;
}
err(SH_ERR, FMT2S, cmd, ERR_NOARGS);
return;
}
if (EQUAL(cmd, "wait")) {
pwait(-1);
return;
//.........这里部分代码省略.........
示例4: main
int main(int argc, char **argv)
{
BN_GENCB *cb;
DSA *dsa = NULL;
int counter, ret = 0, i, j;
unsigned char buf[256];
unsigned long h;
unsigned char sig[256];
unsigned int siglen;
if (bio_err == NULL)
bio_err = BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT);
CRYPTO_set_mem_debug(1);
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
RAND_seed(rnd_seed, sizeof rnd_seed);
BIO_printf(bio_err, "test generation of DSA parameters\n");
cb = BN_GENCB_new();
if (!cb)
goto end;
BN_GENCB_set(cb, dsa_cb, bio_err);
if (((dsa = DSA_new()) == NULL) || !DSA_generate_parameters_ex(dsa, 512,
seed, 20,
&counter,
&h, cb))
goto end;
BIO_printf(bio_err, "seed\n");
for (i = 0; i < 20; i += 4) {
BIO_printf(bio_err, "%02X%02X%02X%02X ",
seed[i], seed[i + 1], seed[i + 2], seed[i + 3]);
}
BIO_printf(bio_err, "\ncounter=%d h=%ld\n", counter, h);
DSA_print(bio_err, dsa, 0);
if (counter != 105) {
BIO_printf(bio_err, "counter should be 105\n");
goto end;
}
if (h != 2) {
BIO_printf(bio_err, "h should be 2\n");
goto end;
}
i = BN_bn2bin(dsa->q, buf);
j = sizeof(out_q);
if ((i != j) || (memcmp(buf, out_q, i) != 0)) {
BIO_printf(bio_err, "q value is wrong\n");
goto end;
}
i = BN_bn2bin(dsa->p, buf);
j = sizeof(out_p);
if ((i != j) || (memcmp(buf, out_p, i) != 0)) {
BIO_printf(bio_err, "p value is wrong\n");
goto end;
}
i = BN_bn2bin(dsa->g, buf);
j = sizeof(out_g);
if ((i != j) || (memcmp(buf, out_g, i) != 0)) {
BIO_printf(bio_err, "g value is wrong\n");
goto end;
}
dsa->flags |= DSA_FLAG_NO_EXP_CONSTTIME;
DSA_generate_key(dsa);
DSA_sign(0, str1, 20, sig, &siglen, dsa);
if (DSA_verify(0, str1, 20, sig, siglen, dsa) == 1)
ret = 1;
dsa->flags &= ~DSA_FLAG_NO_EXP_CONSTTIME;
DSA_generate_key(dsa);
DSA_sign(0, str1, 20, sig, &siglen, dsa);
if (DSA_verify(0, str1, 20, sig, siglen, dsa) == 1)
ret = 1;
end:
if (!ret)
ERR_print_errors(bio_err);
DSA_free(dsa);
BN_GENCB_free(cb);
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
if (CRYPTO_mem_leaks(bio_err) <= 0)
ret = 0;
#endif
BIO_free(bio_err);
bio_err = NULL;
EXIT(!ret);
}
示例5: main
int main(int argc,char **argv)
{
size_t preload_read;
const char *preload_buffer;
int yyparse_result;
tree_init();
#ifdef WITH_CGI
cgi_check_request();
if (cgi_status < 0) {
cgi_write_error_bad_req();
return 0;
}
#endif
params_set_defaults();
#ifdef WITH_CGI
if (!cgi_status)
process_parameters(argc, argv);
preload_buffer = charset_init_preload(param_inputf, &preload_read);
if (cgi_status > 0)
cgi_process_parameters(&preload_buffer, &preload_read);
charset_auto_detect(preload_read);
charset_preload_to_input(param_charset_in, preload_read);
if (cgi_status == CGI_ST_MULTIPART)
charset_cgi_boundary(boundary, boundary_len);
#else
/* process command line arguments */
process_parameters(argc, argv);
charset_init_preload(param_inputf, &preload_read);
charset_auto_detect(preload_read);
charset_preload_to_input(param_charset_in, preload_read);
#endif
/* intialize the converter */
saxStartDocument();
if (param_inputf != stdin)
parser_set_input(param_inputf);
/* parse the input file and convert it */
yyparse_result = yyparse();
if (yyparse_result) {
EXIT("Unrecoverable parse error");
}
charset_close();
saxEndDocument();
#ifdef WITH_CGI
if (!cgi_status) {
/* write the output */
if (writeOutput())
EXIT("Bad state in writeOutput()");
/* close de output file */
if (param_outputf != stdout)
fclose(param_outputf);
} else {
cgi_write_output();
}
#else
/* write the output */
if (writeOutput())
EXIT("Bad state in writeOutput()");
/* close de output file */
if (param_outputf != stdout)
fclose(param_outputf);
#endif
/* show final messages */
write_end_messages();
freeMemory();
return 0;
}
示例6: update_ms2_user_outputs
//.........这里部分代码省略.........
UO_FROMECU_MULT_COL,&multiplier,
UO_FROMECU_ADD_COL,&adder,-1);
/*
if (temp_dep)
{
printf("THIS WIDGET IS TEMP DEPENDENT\n");
printf("raw_lower %s, raw_upper %s in treemodel\n",lower,upper);
if (multiplier)
printf("multiplier %f\n",*multiplier);
if (adder)
printf("adder %f\n",*adder);
printf("size %i, precision %i, temp_dep %i\n",(gint)size,precision,(gint)temp_dep);
}
*/
tmpbuf = (gchar *)OBJ_GET(widget,"range_label");
if (tmpbuf)
tmpwidget = lookup_widget_f(tmpbuf);
if (GTK_IS_LABEL(tmpwidget))
{
if (temp_dep)
{
OBJ_SET(tmpwidget,"widget_temp",DATA_GET(global_data,"mtx_temp_units"));
OBJ_SET(tmpwidget,"c_label",tempc_range);
OBJ_SET(tmpwidget,"f_label",tempf_range);
OBJ_SET(tmpwidget,"k_label",tempk_range);
bind_to_lists_f(tmpwidget,"temperature");
gtk_label_set_text(GTK_LABEL(tmpwidget),tempf_range);
convert_temps_f(tmpwidget,DATA_GET(global_data,"mtx_temp_units"));
}
else
{
remove_from_lists_f("temperature",tmpwidget);
OBJ_SET(tmpwidget,"widget_temp",NULL);
OBJ_SET(tmpwidget,"temp_dep",NULL);
/*OBJ_SET(tmpwidget,"c_label",NULL);
OBJ_SET(tmpwidget,"f_label",NULL);
OBJ_SET(tmpwidget,"k_label",NULL);
*/
gtk_label_set_text(GTK_LABEL(tmpwidget),range);
}
}
tmpbuf = (gchar *)OBJ_GET(widget,"thresh_widget");
if (tmpbuf)
tmpwidget = lookup_widget_f(tmpbuf);
if (GTK_IS_WIDGET(tmpwidget))
{
if (temp_dep)
{
OBJ_SET(tmpwidget,"widget_temp",DATA_GET(global_data,"mtx_temp_units"));
OBJ_SET(tmpwidget,"temp_dep",GINT_TO_POINTER(temp_dep));
bind_to_lists_f(tmpwidget,"temperature");
}
else
{
OBJ_SET(tmpwidget,"widget_temp",NULL);
OBJ_SET(tmpwidget,"temp_dep",NULL);
remove_from_lists_f("temperature",tmpwidget);
}
OBJ_SET(tmpwidget,"size",GINT_TO_POINTER(size));
OBJ_SET(tmpwidget,"precision",GINT_TO_POINTER(precision));
OBJ_SET(tmpwidget,"raw_lower",lower);
OBJ_SET(tmpwidget,"raw_upper",upper);
if (multiplier)
OBJ_SET(tmpwidget,"fromecu_mult",multiplier);
else
OBJ_SET(tmpwidget,"fromecu_mult",NULL);
if (adder)
OBJ_SET(tmpwidget,"fromecu_add",adder);
else
OBJ_SET(tmpwidget,"fromecu_add",NULL);
//convert_temps_f(tmpwidget,DATA_GET(global_data,"mtx_temp_units"));
update_widget_f(tmpwidget,NULL);
}
tmpbuf = (gchar *)OBJ_GET(widget,"hyst_widget");
if (tmpbuf)
tmpwidget = lookup_widget_f(tmpbuf);
if (GTK_IS_WIDGET(tmpwidget))
{
OBJ_SET(tmpwidget,"size",GINT_TO_POINTER(size));
OBJ_SET(tmpwidget,"precision",GINT_TO_POINTER(precision));
OBJ_SET(tmpwidget,"raw_lower",lower);
OBJ_SET(tmpwidget,"raw_upper",upper);
if (multiplier)
OBJ_SET(tmpwidget,"fromecu_mult",multiplier);
else
OBJ_SET(tmpwidget,"fromecu_mult",NULL);
if (adder)
OBJ_SET(tmpwidget,"fromecu_add",adder);
else
OBJ_SET(tmpwidget,"fromecu_add",NULL);
update_widget_f(tmpwidget,NULL);
}
g_free(range);
}
valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter);
i++;
}
EXIT();
return;
}
示例7: open_input_image
/*-------------------------------------------------------------------*/
static IFD
open_input_image (char *ifname, U16 *devt, U32 *vcyls,
U32 *itrkl, BYTE **itrkb, BYTE *volser)
{
int rc; /* Return code */
H30CKD_TRKHDR h30trkhdr; /* Input track header */
IFD ifd; /* Input file descriptor */
int len; /* Length of input */
U16 code; /* Device type code */
U16 dt; /* Device type */
U32 cyls; /* Device size (pri+alt cyls)*/
U32 alts; /* Number of alternate cyls */
BYTE *itrkbuf; /* -> Input track buffer */
U32 itrklen; /* Input track length */
BYTE *pbuf; /* Current byte in input buf */
BYTE klen; /* Key length */
U16 dlen; /* Data length */
BYTE *kptr; /* -> Key in input buffer */
BYTE *dptr; /* -> Data in input buffer */
U32 cyl; /* Cylinder number */
U32 head; /* Head number */
BYTE rec; /* Record number */
char pathname[MAX_PATH]; /* file path in host format */
hostpath(pathname, (char *)ifname, sizeof(pathname));
/* Open the HDR-30 CKD image file */
#if defined(HAVE_LIBZ)
if (strcmp(ifname, "-") == 0)
ifd = gzdopen (STDIN_FILENO, "rb");
else
ifd = gzopen (pathname, "rb");
if (ifd == NULL)
{
fprintf (stderr, MSG(HHC02412, "E", "gzopen()", strerror(errno)));
EXIT(3);
}
#else /*!defined(HAVE_LIBZ)*/
if (strcmp(ifname, "-") == 0)
ifd = STDIN_FILENO;
else
{
ifd = HOPEN (pathname, O_RDONLY | O_BINARY);
if (ifd < 0)
{
fprintf (stderr, MSG(HHC02412, "E", "open()", strerror(errno)));
EXIT(3);
}
}
#endif /*!defined(HAVE_LIBZ)*/
/* Read the first track header */
read_input_data (ifd, ifname, (BYTE*)&h30trkhdr,
H30CKD_TRKHDR_SIZE, 0);
#if !defined(HAVE_LIBZ)
/* Reject input if compressed and we lack gzip support */
if (memcmp(h30trkhdr.devcode, gz_magic_id, sizeof(gz_magic_id)) == 0)
{
fprintf (stderr, MSG(HHC02413, "E"));
EXIT(3);
}
#endif /*!defined(HAVE_LIBZ)*/
/* Reject input if it is already in CKD or CCKD format */
if (memcmp((BYTE*)&h30trkhdr, ckd_ident, sizeof(ckd_ident)) == 0)
{
fprintf (stderr, MSG(HHC02414, "I"));
EXIT(3);
}
/* Extract the device type code from the track header */
FETCH_HW (code, h30trkhdr.devcode);
/* Determine the input device type and size from the device code */
switch (code) {
case 0x01: dt=0x3330; cyls=411; alts=7; break; /* 3330 */
case 0x02: dt=0x3330; cyls=815; alts=7; break; /* 3330-11 */
case 0x03: dt=0x3340; cyls=351; alts=1; break; /* 3340-35 */
case 0x04: dt=0x3340; cyls=701; alts=1; break; /* 3340-70 */
case 0x05: dt=0x3350; cyls=562; alts=7; break; /* 3350 */
case 0x06: dt=0x3375; cyls=962; alts=3; break; /* 3375 */
case 0x08: dt=0x3380; cyls=888; alts=3; break; /* 3380-A,D,J*/
case 0x09: dt=0x3380; cyls=1774; alts=4; break; /* 3380-E */
case 0x0A: dt=0x3380; cyls=2660; alts=5; break; /* 3380-K */
case 0x0B: dt=0x3390; cyls=1117; alts=4; break; /* 3390-1 */
case 0x0C: dt=0x3390; cyls=2230; alts=4; break; /* 3390-2 */
case 0x0D: dt=0x3390; cyls=3343; alts=4; break; /* 3390-3 */
case 0x12: dt=0x2314; cyls=203; alts=3; break; /* 2314 */
case 0x13: dt=0x3390; cyls=10038; alts=21; break; /* 3390-9 */
case 0x14: dt=0x9345; cyls=1454; alts=14; break; /* 9345-1 */
case 0x15: dt=0x9345; cyls=2170; alts=14; break; /* 9345-2 */
default:
fprintf (stderr, MSG(HHC02415, "E", code));
EXIT(3);
} /* end switch(code) */
//.........这里部分代码省略.........
示例8: convert_ckd_file
/*-------------------------------------------------------------------*/
static void
convert_ckd_file (IFD ifd, char *ifname, int itrklen, BYTE *itrkbuf,
int repl, int quiet,
char *ofname, int fseqn, U16 devtype, U32 heads,
U32 trksize, BYTE *obuf, U32 start, U32 end,
U32 volcyls, BYTE *volser)
{
int rc; /* Return code */
int ofd; /* Output file descriptor */
CKDDASD_DEVHDR devhdr; /* Output device header */
CKDDASD_TRKHDR *trkhdr; /* -> Output track header */
CKDDASD_RECHDR *rechdr; /* -> Output record header */
U32 cyl; /* Cylinder number */
U32 head; /* Head number */
int fileseq; /* CKD header sequence number*/
int highcyl; /* CKD header high cyl number*/
BYTE *opos; /* -> Byte in output buffer */
BYTE klen; /* Key length */
U16 dlen; /* Data length */
BYTE rec; /* Record number */
BYTE *iptr; /* -> Byte in input buffer */
BYTE *kptr; /* -> Key in input buffer */
BYTE *dptr; /* -> Data in input buffer */
int ilen; /* Bytes left in input buffer*/
H30CKD_TRKHDR *ith; /* -> Input track header */
U32 ihc, ihh; /* Input trk header cyl,head */
U32 offset; /* Current input file offset */
char pathname[MAX_PATH]; /* file path in host format */
UNREFERENCED(volser);
/* Set file sequence number to zero if this is the only file */
if (fseqn == 1 && end + 1 == volcyls)
fileseq = 0;
else
fileseq = fseqn;
/* Set high cylinder number to zero if this is the last file */
if (end + 1 == volcyls)
highcyl = 0;
else
highcyl = end;
/* Create the AWSCKD image file */
hostpath(pathname, (char *)ofname, sizeof(pathname));
ofd = HOPEN (pathname,
O_WRONLY | O_CREAT | O_BINARY | (repl ? 0 : O_EXCL),
S_IRUSR | S_IWUSR | S_IRGRP);
if (ofd < 0)
{
fprintf (stderr, MSG(HHC02412, "E", "open()", strerror(errno)));
EXIT(8);
}
/* Create the device header */
memset(&devhdr, 0, CKDDASD_DEVHDR_SIZE);
memcpy(devhdr.devid, "CKD_P370", 8);
devhdr.heads[3] = (heads >> 24) & 0xFF;
devhdr.heads[2] = (heads >> 16) & 0xFF;
devhdr.heads[1] = (heads >> 8) & 0xFF;
devhdr.heads[0] = heads & 0xFF;
devhdr.trksize[3] = (trksize >> 24) & 0xFF;
devhdr.trksize[2] = (trksize >> 16) & 0xFF;
devhdr.trksize[1] = (trksize >> 8) & 0xFF;
devhdr.trksize[0] = trksize & 0xFF;
devhdr.devtype = devtype & 0xFF;
devhdr.fileseq = fileseq;
devhdr.highcyl[1] = (highcyl >> 8) & 0xFF;
devhdr.highcyl[0] = highcyl & 0xFF;
/* Write the device header */
rc = write (ofd, &devhdr, CKDDASD_DEVHDR_SIZE);
if (rc < CKDDASD_DEVHDR_SIZE)
{
fprintf (stderr, MSG(HHC02412, "E", "write()", errno ? strerror(errno) : "incomplete"));
EXIT(1);
}
/* Write each cylinder */
for (cyl = start; cyl <= end; cyl++)
{
/* Display progress message every 10 cylinders */
if ((cyl % 10) == 0)
{
#ifdef EXTERNALGUI
if (extgui)
fprintf (stderr, "CYL=%u\n", cyl);
else
#endif /*EXTERNALGUI*/
if (quiet == 0)
fprintf (stderr, "Writing cylinder %u\r", cyl);
}
for (head = 0; head < heads; head++)
{
/* Calculate the current offset in the file */
offset = ((cyl*heads)+head)*itrklen;
//.........这里部分代码省略.........
示例9: main
//.........这里部分代码省略.........
int lfs = 0; /* 1 = Build large file */
char *strtok_str = NULL;
/* Set program name */
if ( argc > 0 )
{
if ( strlen(argv[0]) == 0 )
{
pgmname = strdup( UTILITY_NAME );
}
else
{
char path[MAX_PATH];
#if defined( _MSVC_ )
GetModuleFileName( NULL, path, MAX_PATH );
#else
strncpy( path, argv[0], sizeof( path ) );
#endif
pgmname = strdup(basename(path));
#if !defined( _MSVC_ )
strncpy( path, argv[0], sizeof(path) );
#endif
}
}
else
{
pgmname = strdup( UTILITY_NAME );
}
pgm = strtok_r( strdup(pgmname), ".", &strtok_str);
INITIALIZE_UTILITY( pgm );
/* Display the program identification message */
MSGBUF( msgbuf, MSG_C( HHC02499, "I", pgm, "DASD CKD image conversion" ) );
display_version (stderr, msgbuf+10, FALSE);
/* Process the options in the argument list */
for (; argc > 1; argc--, argv++)
{
if (strcmp(argv[1], "-") == 0) break;
if (argv[1][0] != '-') break;
if (strcmp(argv[1], "-r") == 0)
repl = 1;
else if (strcmp(argv[1], "-q") == 0)
quiet = 1;
else
if (sizeof(off_t) > 4 && strcmp(argv[1], "-lfs") == 0)
lfs = 1;
else
argexit(5, pgm);
}
if (argc != 3)
argexit(5, pgm);
/* The first argument is the input file name */
if (argv[1] == NULL || strlen(argv[1]) == 0
|| strlen(argv[1]) > sizeof(ifname)-1)
argexit(1, pgm);
strcpy (ifname, argv[1]);
/* The second argument is the output file name */
if (argv[2] == NULL || strlen(argv[2]) == 0
|| strlen(argv[2]) > sizeof(ofname)-1)
argexit(2, pgm);
strcpy (ofname, argv[2]);
/* Read the first track of the input file, and determine
the device type and size from the track header */
ifd = open_input_image (ifname, &devtype, &volcyls,
&itrklen, &itrkbuf, volser);
/* Use the device type to determine track characteristics */
switch (devtype) {
case 0x2314: heads = 20; maxdlen = 7294; break;
case 0x3330: heads = 19; maxdlen = 13030; break;
case 0x3340: heads = 12; maxdlen = 8368; break;
case 0x3350: heads = 30; maxdlen = 19069; break;
case 0x3375: heads = 12; maxdlen = 35616; break;
case 0x3380: heads = 15; maxdlen = 47476; break;
case 0x3390: heads = 15; maxdlen = 56664; break;
case 0x9345: heads = 15; maxdlen = 46456; break;
default:
fprintf (stderr, MSG(HHC02416, "E", devtype));
EXIT(3);
} /* end switch(devtype) */
/* Create the device */
convert_ckd (lfs, ifd, ifname, itrklen, itrkbuf, repl, quiet,
ofname, devtype, heads, maxdlen, volcyls, volser);
/* Release the input buffer and close the input file */
free (itrkbuf);
IFCLOS (ifd);
/* Display completion message */
fprintf (stderr, MSG(HHC02423, "I"));
return 0;
} /* end function main */
示例10: OnCmdStart
void OnCmdStart(CCommandParser* pParser)
{
if(!s_vtClients.empty())
{
::LogClientStartFail(SE_ILLEGAL_STATE, ::HP_GetSocketErrorDesc(SE_ILLEGAL_STATE));
return;
}
s_stat.Reset();
for(DWORD i = 0; i < g_app_arg.conn_count; i++)
{
CSSLClientPtr pSocket(&s_listener);
if(!pSocket->SetupSSLContext(g_c_iVerifyMode, g_c_lpszPemCertFile, g_c_lpszPemKeyFile, g_c_lpszKeyPasswod, g_c_lpszCAPemCertFileOrPath))
{
int iErrCode = ::SYS_GetLastError();
::LogClientStartFail(iErrCode, _T("initialize SSL env fail"));
ClearHPSocketPtrSet(s_vtClients);
EXIT(EX_CONFIG, iErrCode);
}
pSocket->SetKeepAliveTime(g_app_arg.keep_alive ? TCP_KEEPALIVE_TIME : 0);
if(pSocket->Start(g_app_arg.remote_addr, g_app_arg.port, g_app_arg.async))
s_vtClients.push_back(pSocket.Detach());
else
{
::LogClientStartFail(pSocket->GetLastError(), pSocket->GetLastErrorDesc());
ClearHPSocketPtrSet(s_vtClients);
return;
}
}
::LogClientStart(g_app_arg.remote_addr, g_app_arg.port);
DWORD dwSendDelay = 3;
CString strMsg;
strMsg.Format(_T("*** willing to send data after %d seconds ***"), dwSendDelay);
::LogMsg(strMsg);
::WaitFor(dwSendDelay * 500);
while(true)
{
int iConnected = s_stat.GetConnected();
if(iConnected < 0)
{
ClearHPSocketPtrSet(s_vtClients);
::LogClientStartFail(ERROR_CONNREFUSED, ::HP_GetSocketErrorDesc(SE_CONNECT_SERVER));
return;
}
else if(iConnected == (int)g_app_arg.conn_count)
break;
::WaitFor(3);
}
::WaitFor(dwSendDelay * 500);
s_sendBuffer.Malloc(g_app_arg.data_length, true);
::LogMsg(_T("*** Go Now ! ***"));
s_stat.StartTest();
BOOL bTerminated = FALSE;
for(DWORD i = 0; i < g_app_arg.test_times; i++)
{
for(DWORD j = 0; j < g_app_arg.conn_count; j++)
{
ITcpClient* pSocket = s_vtClients[j];
if(!pSocket->Send(s_sendBuffer, (int)s_sendBuffer.Size()))
{
::LogClientSendFail(i + 1, j + 1, ::SYS_GetLastError(), ::HP_GetSocketErrorDesc(SE_DATA_SEND));
bTerminated = TRUE;
break;
}
}
if(bTerminated)
break;
if(g_app_arg.test_interval > 0 && i + 1 < g_app_arg.test_times)
::WaitFor(g_app_arg.test_interval);
}
if(bTerminated)
ClearHPSocketPtrSet(s_vtClients);
s_sendBuffer.Free();
}
示例11: main
int main(int argc,char **argv)
{
const char *szTestFile;
FILE *f;
if(argc != 2)
{
fprintf(stderr,"%s <test file>\n",argv[0]);
EXIT(1);
}
CRYPTO_malloc_debug_init();
CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
szTestFile=argv[1];
f=fopen(szTestFile,"r");
if(!f)
{
perror(szTestFile);
EXIT(2);
}
/* Load up the software EVP_CIPHER and EVP_MD definitions */
OpenSSL_add_all_ciphers();
OpenSSL_add_all_digests();
#ifndef OPENSSL_NO_ENGINE
/* Load all compiled-in ENGINEs */
ENGINE_load_builtin_engines();
#endif
#if 0
OPENSSL_config();
#endif
#ifndef OPENSSL_NO_ENGINE
/* Register all available ENGINE implementations of ciphers and digests.
* This could perhaps be changed to "ENGINE_register_all_complete()"? */
ENGINE_register_all_ciphers();
ENGINE_register_all_digests();
/* If we add command-line options, this statement should be switchable.
* It'll prevent ENGINEs being ENGINE_init()ialised for cipher/digest use if
* they weren't already initialised. */
/* ENGINE_set_cipher_flags(ENGINE_CIPHER_FLAG_NOINIT); */
#endif
for( ; ; )
{
char line[4096];
char *p;
char *cipher;
unsigned char *iv,*key,*plaintext,*ciphertext;
int encdec;
int kn,in,pn,cn;
if(!fgets((char *)line,sizeof line,f))
break;
if(line[0] == '#' || line[0] == '\n')
continue;
p=line;
cipher=sstrsep(&p,":");
key=ustrsep(&p,":");
iv=ustrsep(&p,":");
plaintext=ustrsep(&p,":");
ciphertext=ustrsep(&p,":");
if (p[-1] == '\n') {
p[-1] = '\0';
encdec = -1;
} else {
encdec = atoi(sstrsep(&p,"\n"));
}
kn=convert(key);
in=convert(iv);
pn=convert(plaintext);
cn=convert(ciphertext);
if(!test_cipher(cipher,key,kn,iv,in,plaintext,pn,ciphertext,cn,encdec)
&& !test_digest(cipher,plaintext,pn,ciphertext,cn))
{
#ifdef OPENSSL_NO_AES
if (strstr(cipher, "AES") == cipher)
{
fprintf(stdout, "Cipher disabled, skipping %s\n", cipher);
continue;
}
#endif
#ifdef OPENSSL_NO_DES
if (strstr(cipher, "DES") == cipher)
{
fprintf(stdout, "Cipher disabled, skipping %s\n", cipher);
continue;
}
#endif
#ifdef OPENSSL_NO_RC4
if (strstr(cipher, "RC4") == cipher)
{
fprintf(stdout, "Cipher disabled, skipping %s\n", cipher);
continue;
}
#endif
//.........这里部分代码省略.........
示例12: test1_exit
static int test1_exit(int ec)
{
EXIT(ec);
return(0); /* To keep some compilers quiet */
}
示例13: mc_sync
// Upon return no more I/O is possible. The stream is closed.
//
// If ne_close indicates a recoverable error, then the object is
// logged to the "degraded object log".
int mc_sync(DAL_Context* ctx) {
ENTRY();
ObjectStream* os = MC_OS(ctx);
ne_handle handle = MC_HANDLE(ctx);
MC_Config* config = MC_CONFIG(ctx);
MC_Context* mc_context = MC_CONTEXT(ctx);
if(! (os->flags & OSF_OPEN)) {
LOG(LOG_ERR, "%s isn't open\n", os->url);
errno = EINVAL;
return -1;
}
// the result of close for a handle opened for reading is an
// indicator of whether the data is degraded and, if so, which
// block is corrupt or missing.
int error_pattern = ne_close(handle);
if(error_pattern > 0) {
// Keeping the log message as well as writing to the degraded
// object file for debugging purposes.
LOG(LOG_INFO, "WARNING: Object %s degraded. Error pattern: 0x%x."
" (N: %d, E: %d, Start: %d).\n",
mc_context->path_template, error_pattern,
config->n, config->e, mc_context->start_block);
// we shouldn't need more then 512 bytes to hold the extra data
// needed for rebuild
char buf[MC_MAX_LOG_LEN];
snprintf(buf, MC_MAX_LOG_LEN,
MC_DEGRADED_LOG_FORMAT, mc_context->path_template,
config->n, config->e,
mc_context->start_block, error_pattern,
MC_FH(ctx)->info.pre.repo->name,
mc_context->pod, mc_context->cap);
WAIT(&config->lock);
// If the degraded log file has not already been opened, open it now.
if(config->degraded_log_fd == -1) {
config->degraded_log_fd =
open_degraded_object_log(config->degraded_log_path);
if(config->degraded_log_fd < 0) {
LOG(LOG_ERR, "failed to open degraded log file\n");
}
else {
// If we successfully opened it, then free the resources
// used to store the path.
free(config->degraded_log_path);
config->degraded_log_path = NULL;
}
}
if(write(config->degraded_log_fd, buf, strlen(buf))
!= strlen(buf)) {
LOG(LOG_ERR, "Failed to write to degraded object log\n");
// theoretically the data is still safe, so we can just log
// and ignore the failure.
}
POST(&config->lock);
}
else if(error_pattern < 0) {
// close the stream, a failed sync renders the ne_handle
// invalid calling mc_close should prevent marfs from ever
// trying to use it again.
mc_close(ctx);
os->flags |= OSF_ERRORS;
LOG(LOG_ERR, "ne_close failed on %s", mc_context->path_template);
return -1;
}
EXIT();
return 0;
}
示例14: convert_ckd
/*-------------------------------------------------------------------*/
static void
convert_ckd (int lfs, IFD ifd, char *ifname, int itrklen,
BYTE *itrkbuf, int repl, int quiet,
char *ofname, U16 devtype, U32 heads,
U32 maxdlen, U32 volcyls, BYTE *volser)
{
int i; /* Array subscript */
char *s; /* String pointer */
int fileseq; /* File sequence number */
char sfname[260]; /* Suffixed name of this file*/
char *suffix; /* -> Suffix character */
U32 endcyl; /* Last cylinder of this file*/
U32 cyl; /* Cylinder number */
U32 cylsize; /* Cylinder size in bytes */
BYTE *obuf; /* -> Output track buffer */
U32 mincyls; /* Minimum cylinder count */
U32 maxcyls; /* Maximum cylinder count */
U32 maxcpif; /* Maximum number of cylinders
in each CKD image file */
int rec0len = 8; /* Length of R0 data */
U32 trksize; /* AWSCKD image track length */
/* Compute the AWSCKD image track length */
trksize = sizeof(CKDDASD_TRKHDR)
+ sizeof(CKDDASD_RECHDR) + rec0len
+ sizeof(CKDDASD_RECHDR) + maxdlen
+ sizeof(eighthexFF);
trksize = ROUND_UP(trksize,512);
/* Compute minimum and maximum number of cylinders */
cylsize = trksize * heads;
mincyls = 1;
if (!lfs)
{
maxcpif = 0x80000000 / cylsize;
maxcyls = maxcpif * CKD_MAXFILES;
}
else
maxcpif = maxcyls = volcyls;
if (maxcyls > 65536) maxcyls = 65536;
/* Check for valid number of cylinders */
if (volcyls < mincyls || volcyls > maxcyls)
{
fprintf (stderr, MSG(HHC02421, "E",
volcyls, mincyls, maxcyls));
EXIT(4);
}
/* Obtain track data buffer */
obuf = malloc(trksize);
if (obuf == NULL)
{
char buf[40];
MSGBUF( buf, "malloc(%u)", trksize);
fprintf (stderr, MSG(HHC02412, "E", buf, strerror(errno)));
EXIT(6);
}
/* Display progress message */
fprintf (stderr, MSG(HHC02422, "I",
devtype, volser, volcyls, heads, trksize));
#ifdef EXTERNALGUI
if (extgui)
fprintf (stderr, "CYLS=%u\n", volcyls);
#endif /*EXTERNALGUI*/
/* Copy the unsuffixed AWSCKD image file name */
strcpy (sfname, ofname);
suffix = NULL;
/* Create the suffixed file name if volume will exceed 2GB */
if (volcyls > maxcpif)
{
/* Look for last slash marking end of directory name */
s = strrchr (ofname, '/');
if (s == NULL) s = ofname;
/* Insert suffix before first dot in file name, or
append suffix to file name if there is no dot */
s = strchr (s, '.');
if (s != NULL)
{
i = s - ofname;
strcpy (sfname + i, "_1");
strcat (sfname, ofname + i);
suffix = sfname + i + 1;
}
else
{
strcat (sfname, "_1");
suffix = sfname + strlen(sfname) - 1;
}
}
/* Create the AWSCKD image files */
for (cyl = 0, fileseq = 1; cyl < volcyls;
//.........这里部分代码省略.........
示例15: process_parameters
static void process_parameters(int argc, char **argv)
{
int i, fich, tmpnum;
/* process command line arguments */
for (i=1, fich=0; i<argc; i++) {
if (!strcmp(argv[i], "-e")) {
param_strict = 0;
} else if (!strcmp(argv[i], "-t") && ((i+1) < argc)) {
param_doctype = dtd_get_dtd_index(argv[++i]);
} else if (!strcmp(argv[i], "-o") && ((i+1) < argc)) {
/* open the output file */
param_outputf = fopen(argv[++i], "wb");
if (!param_outputf) {
perror("fopen");
EXIT("Could not open the output file for writing");
}
} else if (!strcmp(argv[i], "-l") && ((i+1) < argc)) {
tmpnum= atoi(argv[++i]);
if (tmpnum >= 40)
param_chars_per_line = tmpnum;
} else if (!strcmp(argv[i], "-b") && ((i+1) < argc)) {
tmpnum= atoi(argv[++i]);
if (tmpnum >= 0 && tmpnum <= 16)
param_tab_len = tmpnum;
} else if (!strcmp(argv[i], "--preserve-space-comments")) {
param_pre_comments = 1;
} else if (!strcmp(argv[i], "--no-protect-cdata")) {
param_protect_cdata = 0;
} else if (!strcmp(argv[i], "--compact-block-elements")) {
param_compact_block_elms = 1;
} else if (!strcmp(argv[i], "--compact-empty-elem-tags")) {
param_compact_empty_elm_tags = 1;
} else if (!strcmp(argv[i], "--empty-elm-tags-always")) {
param_empty_tags = 1;
} else if (!strcmp(argv[i], "--dos-eol")) {
param_crlf_eol = 1;
} else if (!fich && argv[i][0]!='-') {
fich = 1;
param_inputf = fopen(argv[i], "r");
if (!param_inputf) {
perror("fopen");
EXIT("Could not open the input file for reading");
}
} else if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h")) {
help();
exit(0);
} else if (!strcmp(argv[i], "--version") || !strcmp(argv[i], "-v")) {
print_version();
exit(0);
} else if (!strcmp(argv[i], "-L")) {
print_doctype_keys();
exit(0);
} else if (!strcmp(argv[i], "--ics") && ((i+1) < argc)) {
param_charset_in = charset_lookup_alias(argv[++i]);
if (!param_charset_in) {
EPRINTF1("Trying to set input character set: %s\n", argv[i]);
EXIT("Unsupported character set");
}
} else if (!strcmp(argv[i], "--ocs") && ((i+1) < argc)) {
param_charset_out = charset_lookup_alias(argv[++i]);
if (!param_charset_out) {
EPRINTF1("Trying to set output character set: %s\n", argv[i]);
EXIT("Unsupported character set");
}
} else if (!strcmp(argv[i], "--lcs")) {
charset_dump_aliases(stdout);
exit(0);
} else if (!strcmp(argv[i], "--generate-snippet")) {
param_generate_snippet = 1;
} else {
help();
exit(1);
}
}
}