本文整理汇总了C++中ON_ERROR函数的典型用法代码示例。如果您正苦于以下问题:C++ ON_ERROR函数的具体用法?C++ ON_ERROR怎么用?C++ ON_ERROR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ON_ERROR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: c2w
static int c2w( int c_count,
const char* c,
int w_count,
wchar_t* w // array of at least w_count+1 wide characters
)
{
// convert UTF-8 string to UTF-16 string
int rc = 0;
if ( w )
w[0] = 0;
// returns length of converted c[]
if ( w_count > 0 && w && c_count > 0 && c && c[0] ) {
w[0] = 0;
if ( c )
{
unsigned int error_status = 0;
unsigned int error_mask = 0xFFFFFFFF;
ON__UINT32 error_code_point = 0xFFFD;
const char* p1 = 0;
rc = ON_ConvertUTF8ToWideChar(c,c_count,w,w_count,&error_status,error_mask,error_code_point,&p1);
if ( rc > 0 && rc <= w_count )
w[rc] = 0;
else {
w[w_count] = 0;
rc = 0;
}
if ( 0 != error_status )
{
ON_ERROR("Error converting UTF-8 encoded char string to UTF-16 encoded wchar_t string.");
}
}
}
return rc;
}
示例2: ON_GetKnotVectorSpanVector
bool ON_GetKnotVectorSpanVector(
int order, // order (>=2)
int cv_count, // cv count
const double* knot, // knot[] array
double* s // s[] array
)
{
if ( 0 == knot || 0 == s )
{
if ( 0 != order || 0 != cv_count )
{
ON_ERROR("NULL knot[] or s[] passed to ON_KnotVectorSpanCount.");
return false;
}
return true;
}
int i, span_count = 0;
s[span_count++] = knot[order-2];
for ( i = order-1; i < cv_count; i++ ) {
if ( knot[i] > knot[i-1] )
s[span_count++] = knot[i];
}
return (span_count>1) ? true : false;
}
示例3: Header
void ON_wString::Empty()
{
ON_wStringHeader* p = Header();
if ( p != pEmptyStringHeader ) {
if ( p->ref_count > 1 ) {
// string memory is shared
p->ref_count--;
Create();
}
else if ( p->ref_count == 1 ) {
// string memory is not shared - reuse it
if (m_s && p->string_capacity>0)
*m_s = 0;
p->string_length = 0;
}
else {
// should not happen
ON_ERROR("ON_wString::Empty() encountered invalid header - fixed.");
Create();
}
}
else {
// initialized again
Create();
}
}
示例4: ON_ERROR
bool ON_BezierCage::IsSingular( // true if surface side is collapsed to a point
int side // side of parameter space to test
// 0 = south, 1 = east, 2 = north, 3 = west, 4 = bottom, 5 =top
) const
{
ON_ERROR("TODO: fill in ON_BezierCage::IsSingular\n");
return false;
/*
int i,j,k=0;
ON_3dPoint p[2];
double fuzz[2] = {0.0,0.0};
p[0].Zero();
p[1].Zero();
int i0 = 0;
int i1 = 0;
int j0 = 0;
int j1 = 0;
switch ( side ) {
case 0: // south
i0 = 0;
i1 = Order(0);
j0 = 0;
j1 = 1;
break;
case 1: // east
i0 = Order(0)-1;
i1 = Order(0);
j0 = 0;
j1 = Order(1);
break;
case 2: // north
i0 = 0;
i1 = Order(0);
j0 = Order(1)-1;
j1 = Order(1);
break;
case 3: // west
i0 = 0;
i1 = 1;
j0 = 0;
j1 = Order(1);
break;
default:
return false;
break;
}
GetCV(i0,j0,p[k]);
fuzz[k] = p[k].Fuzz();
for ( i = i0; i < i1; i++ ) for ( j = j0; j < j1; j++ ) {
k = (k+1)%2;
GetCV( i, j, p[k] );
fuzz[k] = p[k].Fuzz();
if ( (p[0]-p[1]).MaximumCoordinate() > fuzz[0]+fuzz[1] )
return false;
}
return true;
*/
}
示例5: ON_ERROR
bool ON_BezierCage::IsSingular( // true if surface side is collapsed to a point
int side // side of parameter space to test
// 0 = south, 1 = east, 2 = north, 3 = west, 4 = bottom, 5 =top
) const
{
ON_ERROR("TODO: fill in ON_BezierCage::IsSingular\n");
return false;
}
示例6: daemon_init
static void daemon_init(void)
{
fd = open("./ettercap_demonized.log", O_CREAT|O_TRUNC|O_WRONLY, 0600);
ON_ERROR(fd, -1, "Can't open daemon log file");
/* daemonize ettercap */
daemonize();
}
示例7: ON_ERROR
bool ON_SubDArchiveIdMap::AddComponentPtr(ON_SubDComponentPtr eptr, unsigned int archive_id)
{
if (m_element_count != archive_id)
{
ON_ERROR("Archive id is not valid and ON_SubD::Read will fail.");
return false;
}
ON_SubDComponentPtr* p = (ON_SubDComponentPtr*)m_fsp.AllocateElement();
*p = eptr;
#if defined(ON_DEBUG)
if (0 != archive_id)
{
const ON_SubDComponentPtr* p1 = (const ON_SubDComponentPtr*)m_fsp.Element(archive_id);
unsigned int archive_id1 = 0;
if (p1 == p)
{
switch (p1->ComponentType())
{
case ON_SubDComponentPtr::Type::Vertex:
archive_id1 = p1->Vertex()->ArchiveId();
break;
case ON_SubDComponentPtr::Type::Edge:
archive_id1 = p1->Edge()->ArchiveId();
break;
case ON_SubDComponentPtr::Type::Face:
archive_id1 = p1->Face()->ArchiveId();
break;
default:
ON_ERROR("invalid element type");
break;
}
}
if (archive_id1 != archive_id)
{
// break here and then see what went wrong
ON_SubDIncrementErrorCount();
m_fsp.Element(archive_id);
m_fsp.Element(archive_id);
}
}
#endif
m_element_count++;
return true;
}
示例8: check_malloc
//
// Object creation
//
void* check_malloc(size_t size)
{
void* result = malloc(size);
if(result == NULL)
ON_ERROR(-1);
return result;
}
示例9: ON_UuidToString
char* ON_UuidToString( const ON_UUID& uuid, char* s)
{
// s - [out] The s[] char array must have length >= 37.
// The returned char array will have a 36
// character uuid in s[0..35] and a null in s[36].
// NOTE WELL:
// This code has to work on non-Windows OSs and on both big and
// little endian CPUs. The result must satisfy
// uuid == ON_UuidFromString(ON_UuidToString(uuid,s))
// 31 August 2005 Dale Lear
// Changed upper case to lower case so result is
// identical to the string returned by Windows' ::UuidToString().
//static const char x[16] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
static const char x[16] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
static const int addhyphen[16] = {0,0,0,1, 0,1, 0,1, 0,1, 0, 0, 0, 0, 0, 0};
const unsigned char* b = (const unsigned char*)&uuid;
char* p;
int i;
static const int* rho = ( ON::big_endian == ON::Endian() )
? big_endian_rho
: little_endian_rho;
// 5 December 2002 Dale Lear:
// There is either a bug in Purify (likely) or perhaps a bug in the
// way Microsoft compiles c>>4 when c is an unsigned char. In any
// case, changing c to an unsigned int makes purify happy and should
// work just as well.
//
//unsigned char c;
unsigned int c;
if ( !s )
return 0;
p = s;
for ( i = 0; i < 16; i++ ) {
c = b[rho[i]];
*p++ = x[c>>4]; // purify gripes here if c is an unsigned char - the code runs fine.
*p++ = x[c&0x0F];
if ( addhyphen[i] )
*p++ = '-';
}
*p = 0;
#if defined(ON_DEBUG)
{
ON_UUID u = ON_UuidFromString(s);
if ( ON_UuidCompare(&u,&uuid) ) {
ON_ERROR("ON_UuidToString() bug"); // <- breakpoint here
}
}
#endif
return s;
}
示例10: Style
ON_BOOL32 ON_Light::IsValid( ON_TextLog* text_log ) const
{
int s = Style();
if ( s <= ON::unknown_light_style || s >= ON::light_style_count ) {
ON_ERROR("ON_Light::IsValid(): illegal light style.");
return false;
}
return true;
}
示例11: log_write_packet
void log_write_packet(struct log_fd *fd, struct packet_object *po)
{
struct log_header_packet hp;
int c, zerr;
memset(&hp, 0, sizeof(struct log_header_packet));
/* adjust the timestamp */
memcpy(&hp.tv, &po->ts, sizeof(struct timeval));
hp.tv.tv_sec = htonl(hp.tv.tv_sec);
hp.tv.tv_usec = htonl(hp.tv.tv_usec);
memcpy(&hp.L2_src, &po->L2.src, MEDIA_ADDR_LEN);
memcpy(&hp.L2_dst, &po->L2.dst, MEDIA_ADDR_LEN);
memcpy(&hp.L3_src, &po->L3.src, sizeof(struct ip_addr));
memcpy(&hp.L3_dst, &po->L3.dst, sizeof(struct ip_addr));
hp.L4_flags = po->L4.flags;
hp.L4_proto = po->L4.proto;
hp.L4_src = po->L4.src;
hp.L4_dst = po->L4.dst;
/* the length of the payload */
hp.len = htonl(po->DATA.disp_len);
LOG_LOCK;
if (fd->type == LOG_COMPRESSED) {
c = gzwrite(fd->cfd, &hp, sizeof(hp));
ON_ERROR(c, -1, "%s", gzerror(fd->cfd, &zerr));
c = gzwrite(fd->cfd, po->DATA.disp_data, po->DATA.disp_len);
ON_ERROR(c, -1, "%s", gzerror(fd->cfd, &zerr));
} else {
c = write(fd->fd, &hp, sizeof(hp));
ON_ERROR(c, -1, "Can't write to logfile");
c = write(fd->fd, po->DATA.disp_data, po->DATA.disp_len);
ON_ERROR(c, -1, "Can't write to logfile");
}
LOG_UNLOCK;
}
示例12: ON_SUBD_RETURN_ERROR
bool ON_SubDArchiveIdMap::ConvertArchiveIdToRuntimeVertexPtr(
unsigned int vertex_count,
size_t vertex_capacity,
ON_SubDVertex** vertex
)
{
if ( 0 == vertex_count )
return true;
if ( 0 == vertex_capacity || nullptr == vertex )
return ON_SUBD_RETURN_ERROR(false);
if ( vertex_count > vertex_capacity )
return ON_SUBD_RETURN_ERROR(false);
for (unsigned int i = 0; i < vertex_count; i++)
{
ON__UINT_PTR vptr = (ON__UINT_PTR)(vertex[i]);
vertex[i] = nullptr;
const unsigned int archive_id = ON_SubDArchiveIdMap::ArchiveIdFromComponentPtr(vptr);
// future use // ON__UINT_PTR flags = ON_SUBD_ELEMENT_FLAGS(vptr);
if (0 == archive_id || archive_id < m_archive_id_partition[0] || archive_id >= m_archive_id_partition[1])
{
ON_ERROR("Invalid vertex archive id.");
continue;
}
const ON_SubDComponentPtr* eleptr = ComponentPtrFromArchiveId(archive_id);
if (nullptr == eleptr)
{
ON_ERROR("null element pointer.");
continue;
}
ON_SubDVertex* v = eleptr->Vertex();
if (nullptr == v)
{
ON_ERROR("null vertex pointer.");
continue;
}
if (archive_id != v->ArchiveId())
{
ON_ERROR("archive_id != v->ArchiveId().");
continue;
}
vertex[i] = v;
}
return true;
}
示例13: write_output
int write_output(void)
{
int fd;
struct filter_op *fop;
struct filter_header fh;
size_t ninst, i, data_len;
u_char pad = 0, *data = NULL;
/* conver the tree to an array of filter_op */
ninst = compile_tree(&fop);
if (fop == NULL)
return -E_NOTHANDLED;
if (ninst == 0)
return -E_INVALID;
/* create the file */
fd = open(GBL_OPTIONS->output_file, O_CREAT | O_RDWR | O_TRUNC | O_BINARY, 0644);
ON_ERROR(fd, -1, "Can't create file %s", GBL_OPTIONS->output_file);
/* display the message */
fprintf(stdout, " Writing output to \'%s\' ", GBL_OPTIONS->output_file);
fflush(stdout);
/* compute the header */
fh.magic = htons(EC_FILTER_MAGIC);
strncpy(fh.version, EC_VERSION, sizeof(fh.version));
fh.data = sizeof(fh);
data_len = create_data_segment(&data, &fh, fop, ninst);
/* write the header */
write(fd, &fh, sizeof(struct filter_header));
/* write the data segment */
write(fd, data, data_len);
/* write padding to next 8-byte boundary */
for (i = 0; i < fh.code - (fh.data + data_len); i++)
write(fd, &pad, 1);
/* write the instructions */
for (i = 0; i < ninst; i++) {
print_progress_bar(&fop[i]);
write(fd, &fop[i], sizeof(struct filter_op));
}
close(fd);
fprintf(stdout, " done.\n\n");
fprintf(stdout, " -> Script encoded into %d instructions.\n\n", (int)(i - 1));
return E_SUCCESS;
}
示例14: open_log
void open_log(char *file)
{
int zerr;
GBL_LOGFILE = strdup(file);
GBL_LOG_FD = gzopen(file, "rb");
ON_ERROR(GBL_LOG_FD, NULL, "%s", gzerror(GBL_LOG_FD, &zerr));
}
示例15: ON_ERROR
unsigned int ON_3dmObjectAttributes::ApplyParentalControl(
const ON_3dmObjectAttributes& parents_attributes,
unsigned int control_limits
)
{
ON_ERROR("Do not use deprecated version of ON_3dmObjectAttributes::ApplyParentalControl()");
ON_Layer bogus_layer;
bogus_layer.m_layer_index = -1;
return ApplyParentalControl(parents_attributes,bogus_layer,control_limits);
}