本文整理汇总了C++中THROW函数的典型用法代码示例。如果您正苦于以下问题:C++ THROW函数的具体用法?C++ THROW怎么用?C++ THROW使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了THROW函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupUpscalingConditions
inline void setupUpscalingConditions(const GridInterface& g,
int bct,
int pddir,
double pdrop,
double bdy_sat,
bool twodim_hack,
BCs& bcs)
{
// Caution: This enum is copied from Upscaler.hpp.
enum BoundaryConditionType { Fixed = 0, Linear = 1, Periodic = 2, PeriodicSingleDirection = 3, Noflow = 4 };
if (bct < 0 || bct > 2) {
THROW("Illegal boundary condition type (0-2 are legal): " << bct); // Later on, we may allow 3 and 4.
}
BoundaryConditionType bctype = static_cast<BoundaryConditionType>(bct);
ASSERT(pddir >=0 && pddir <= 2);
// Flow conditions.
switch (bctype) {
case Fixed:
{
// ASSERT(!g.uniqueBoundaryIds());
bcs.clear();
bcs.resize(7);
bcs.flowCond(2*pddir + 1) = FlowBC(FlowBC::Dirichlet, pdrop);
bcs.flowCond(2*pddir + 2) = FlowBC(FlowBC::Dirichlet, 0.0);
bcs.satCond(2*pddir + 1) = SatBC(SatBC::Dirichlet, bdy_sat); // The only possible inflow location.
for (int i = 0; i < 7; ++i) {
bcs.setCanonicalBoundaryId(i, i);
}
break;
}
case Linear:
{
// ASSERT(g.uniqueBoundaryIds());
createLinear(bcs, g, pdrop, pddir, bdy_sat, twodim_hack);
break;
}
case Periodic:
{
// ASSERT(g.uniqueBoundaryIds());
FlowBC fb(FlowBC::Periodic, 0.0);
boost::array<FlowBC, 6> fcond = {{ fb, fb, fb, fb, fb, fb }};
fcond[2*pddir] = FlowBC(FlowBC::Periodic, pdrop);
fcond[2*pddir + 1] = FlowBC(FlowBC::Periodic, -pdrop);
SatBC sb(SatBC::Periodic, 0.0);
boost::array<SatBC, 6> scond = {{ sb, sb, sb, sb, sb, sb }};
if (twodim_hack) {
// fcond[2] = FlowBC(FlowBC::Neumann, 0.0);
// fcond[3] = FlowBC(FlowBC::Neumann, 0.0);
fcond[4] = FlowBC(FlowBC::Neumann, 0.0);
fcond[5] = FlowBC(FlowBC::Neumann, 0.0);
// scond[2] = SatBC(SatBC::Dirichlet, 1.0);
// scond[3] = SatBC(SatBC::Dirichlet, 1.0);
scond[4] = SatBC(SatBC::Dirichlet, 1.0);
scond[5] = SatBC(SatBC::Dirichlet, 1.0);
}
createPeriodic(bcs, g, fcond, scond);
break;
}
default:
THROW("Error in switch statement, should never be here.");
}
// Default transport boundary conditions are used.
}
示例2: ep2_curve_set_twist
void ep2_curve_set_twist(int type) {
char str[2 * FP_BYTES + 1];
ctx_t *ctx = core_get();
ep2_t g;
fp2_t a;
fp2_t b;
bn_t r;
ep2_null(g);
fp2_null(a);
fp2_null(b);
bn_null(r);
ctx->ep2_is_twist = 0;
if (type == EP_MTYPE || type == EP_DTYPE) {
ctx->ep2_is_twist = type;
} else {
return;
}
TRY {
ep2_new(g);
fp2_new(a);
fp2_new(b);
bn_new(r);
switch (ep_param_get()) {
#if FP_PRIME == 158
case BN_P158:
ASSIGN(BN_P158);
break;
#elif FP_PRIME == 254
case BN_P254:
ASSIGN(BN_P254);
break;
#elif FP_PRIME == 256
case BN_P256:
ASSIGN(BN_P256);
break;
#elif FP_PRIME == 382
case BN_P382:
ASSIGN(BN_P382);
break;
#elif FP_PRIME == 455
case B12_P455:
ASSIGN(B12_P455);
break;
#elif FP_PRIME == 638
case BN_P638:
ASSIGN(BN_P638);
break;
case B12_P638:
ASSIGN(B12_P638);
break;
#endif
default:
(void)str;
THROW(ERR_NO_VALID);
break;
}
fp2_zero(g->z);
fp_set_dig(g->z[0], 1);
g->norm = 1;
ep2_copy(&(ctx->ep2_g), g);
fp_copy(ctx->ep2_a[0], a[0]);
fp_copy(ctx->ep2_a[1], a[1]);
fp_copy(ctx->ep2_b[0], b[0]);
fp_copy(ctx->ep2_b[1], b[1]);
bn_copy(&(ctx->ep2_r), r);
bn_set_dig(&(ctx->ep2_h), 1);
/* I don't have a better place for this. */
fp_prime_calc();
#if defined(EP_PRECO)
ep2_mul_pre((ep2_t *)ep2_curve_get_tab(), &(ctx->ep2_g));
#endif
}
CATCH_ANY {
THROW(ERR_CAUGHT);
}
FINALLY {
ep2_free(g);
fp2_free(a);
fp2_free(b);
bn_free(r);
}
}
示例3: THROW
void LoneFallibleBase::throwErr() const
{
THROW (LoneFallibleBase::UsedInInvalidStateErr());
}
示例4: DEFINE_QUERY
void ParseRuleMgr::initRule ()
{
DEFINE_QUERY (qry);
for (int i=1; i<=MAX_TLV_FLAGS; i++)
m_pParseRule[i] = 0;
qry.setSQL (" Select nvl(Max(parse_rule_group_id),0) "
" From B_PROCESS_PARSE_COMBINE Where process_id = :ProcID "
);
qry.setParameter ("ProcID", m_iProcessID);
qry.open ();
qry.next ();
int iGroupID = qry.field(0).asInteger();
qry.close();
//检查是否有默认解析规则组0
if (iGroupID == 0) {
qry.setSQL (" select count(*) from B_PARSE_RULE_GROUP "
" where parse_rule_group_id = 0" );
qry.open ();
qry.next ();
if (!qry.field(0).asInteger()) {
Log::log (0, "当前进程(%d)未定义解析规则组,也未找到默认(即ID=0的)解析规则组",m_iProcessID);
Log::log (0, "相关配置表有:B_PARSE_RULE_GROUP,B_PROCESS_PARSE_COMBINE,B_PARSE_RULE");
THROW (100100003);
}
qry.close ();
}
qry.setSQL (" Select tlv_tag_id, begin_pos, DATA_LEN, "
" parse_func_id, attr_id, bit_position "
" From b_parse_rule "
" Where parse_rule_group_id = :GrpID "
" Order By tlv_tag_id, begin_pos "
);
qry.setParameter ("GrpID",iGroupID);
qry.open ();
while (qry.next ())
{
ParseRule **ppRule;
int iTag = qry.field ("tlv_tag_id").asInteger();
int iBeginPos = qry.field ("begin_pos").asInteger();
int iDataLen = qry.field ("DATA_LEN").asInteger();
int iFuncID = qry.field ("parse_func_id").asInteger();
int iAttrID = qry.field ("attr_id").asInteger();
int iBitPos = qry.field ("bit_position").asInteger();
//# 当bit位有效时, 转换函数强行使用3, 数据长度强行置为1个字节
if (iBitPos>=1 && iBitPos<=8) {
iFuncID = 3;
iDataLen = 1;
}
if (iTag<1 || iTag>MAX_TLV_FLAGS) {
Log::log (0,"上载解析规则异常, 系统定义TAG位范围(1--%d) \n"
"当前参数配置的TAG标识为: %d ",
MAX_TLV_FLAGS, iTag
);
THROW (100100004);
}
for (ppRule=&(m_pParseRule[iTag]); *ppRule; ppRule=&((*ppRule)->m_pNext));
*ppRule = new ParseRule;
(*ppRule)->m_iTag = iTag;
(*ppRule)->m_iBeginPos = iBeginPos;
(*ppRule)->m_iDataLen = iDataLen;
(*ppRule)->m_iFuncID = iFuncID;
(*ppRule)->m_iAttrID = iAttrID;
(*ppRule)->m_iBitPosition = iBitPos;
(*ppRule)->m_pNext = 0;
}
qry.close ();
}
示例5: LOCK_FOR_SCOPE
void SettingsManager::installMt()
{
LOCK_FOR_SCOPE(*this);
CppUtils::String path_s = CppUtils::getStartupDir();
for(auto it = sesttings_m.mtSettingsMap_m.begin(); it != sesttings_m.mtSettingsMap_m.end(); it++) {
MTSettings const & settings_i = it->second;
//for(int i = 0; i < mtinstances; i++) {
// autonistall
if (settings_i.getStartUpSettings().autoInstall_m) {
CppUtils::String const& path_mt = it->second.getStartUpSettings().mtPath;
// ------------------
CppUtils::String mq4LibName = path_s + NAME_MT4_MQL_COMPILED;
CppUtils::String mq4LibName_dest = path_mt + PATH_MT4_MQL + NAME_MT4_MQL_COMPILED;
if (!CppUtils::fileExists(mq4LibName))
THROW(CppUtils::OperationFailed, "exc_FileNotExist", "ctx_installMt", mq4LibName );
LOG(MSG_DEBUG, SETTINGS_MAN, "Copying file: " << mq4LibName << " to: " << mq4LibName_dest);
if (!CppUtils::copyFile(mq4LibName, mq4LibName_dest, true ))
THROW(CppUtils::OperationFailed, "exc_CannotCopyFile", "ctx_installMt", CppUtils::getOSError());
// -------------------
CppUtils::String mq4LibNameSrc = path_s + NAME_MT4_MQL_SOURCE;
CppUtils::String mq4LibNameSrc_dest = path_mt + PATH_MT4_MQL + NAME_MT4_MQL_SOURCE;
if (!CppUtils::fileExists(mq4LibNameSrc))
THROW(CppUtils::OperationFailed, "exc_FileNotExist", "ctx_installMt", mq4LibNameSrc );
LOG(MSG_DEBUG, SETTINGS_MAN, "Copying file: " << mq4LibNameSrc << " to: " << mq4LibNameSrc_dest);
if (!CppUtils::copyFile(mq4LibNameSrc, mq4LibNameSrc_dest, true ))
THROW(CppUtils::OperationFailed, "exc_CannotCopyFile", "ctx_installMt", CppUtils::getOSError());
// -------------------
// create and save ini file
CppUtils::String mq4InitConf_dest = path_mt + CppUtils::pathDelimiter() +PATH_MT4_CONF + NAME_MT4_MQL_INIT_CONFIG;
CppUtils::String inifile_cont;
if (it->second.getStartUpSettings().fstruct_m.rows_m.size() <= 0) {
inifile_cont = MtCommonHelpers::createMTIniContent();
} else {
auto const& row_first = it->second.getStartUpSettings().fstruct_m.rows_m[0];
inifile_cont = MtCommonHelpers::createMTIniContent(row_first.user_m.c_str(), row_first.pass_m.c_str(), row_first.srv_m.c_str());
}
if(!CppUtils::saveContentInFile2(mq4InitConf_dest, inifile_cont ))
THROW(CppUtils::OperationFailed, "exc_CannotSaveFile", "ctx_installMt", mq4InitConf_dest << " - " << CppUtils::getOSError());
LOG(MSG_DEBUG, SETTINGS_MAN, "Saved MT ini file: " << mq4InitConf_dest );
// check dll
// ------------
CppUtils::String fullMt4ProxyDllName = path_s + SOURCE_NAME_MT4_PROXY_DLL_BASE;
// destination file must be always
CppUtils::String fullMt4ProxyDllName_dest = path_mt + CppUtils::pathDelimiter() + TARGET_NAME_MT4_PROXY_DLL_BASE;
if (!CppUtils::fileExists(fullMt4ProxyDllName))
THROW(CppUtils::OperationFailed, "exc_FileNotExist", "ctx_installMt", fullMt4ProxyDllName );
LOG(MSG_DEBUG, SETTINGS_MAN, "Copying file: " << fullMt4ProxyDllName << " to: " << fullMt4ProxyDllName_dest);
if (!CppUtils::copyFile(fullMt4ProxyDllName, fullMt4ProxyDllName_dest, true ))
THROW(CppUtils::OperationFailed, "exc_CannotCopyFile", "ctx_installMt", CppUtils::getOSError());
// ------------------
// set file
CppUtils::String setFile_dest = path_mt + PATH_MT4_PRESETS + NAME_MT4_MQL_INIT_PARAMS;
CppUtils::String setFile_dest_content = MtCommonHelpers::createMtParameterContent(
settingsFile_m.c_str(),
CHILD_MT_LOG_LEVEL,
settings_i.getStartUpSettings().tmpResultPath_m.c_str()
);
if(!CppUtils::saveContentInFile2(setFile_dest, setFile_dest_content ))
THROW(CppUtils::OperationFailed, "exc_CannotSaveFile", "ctx_autoInstLibToMt", setFile_dest << " - " << CppUtils::getOSError());
LOG(MSG_DEBUG, SETTINGS_MAN, "Saved MT set file: " << setFile_dest );
} // END LOOP
};
//.........这里部分代码省略.........
示例6: showDebug
//.........这里部分代码省略.........
goto error_readBitmap;
}
// load group descriptors
desc = new CExt2GroupDesc[m_info.dwGroupsCount+m_info.dwDescPerBlock];
showDebug(1, "dwGroupsCount = %lu, m_info.dwDescPerBlock = %lu\n",m_info.dwGroupsCount, m_info.dwDescPerBlock);
if (!desc)
{
showDebug(1, "CExt2Part::readBitmap(): Error 003\n");
goto error_readBitmap;
}
// for each descriptor BLOCK (not group descriptor!)
showDebug(1, "readData m_info.dwBlockSize = %lu\n", m_info.dwBlockSize);
for (cPtr=(char*)desc, i=0; i < m_info.dwDescBlocks; i++,cPtr+=m_info.dwBlockSize)
{
nRes = readData(cPtr, ((QWORD)m_info.dwBlockSize) * ((QWORD)(m_info.dwFirstBlock+1+i)), m_info.dwBlockSize);
if (nRes == -1)
{
showDebug(1, "CExt2Part::readBitmap(): Error 004\n");
goto error_readBitmap;
}
}
dwUsed=0;
dwFree=0;
showDebug(1, "m_info.dwBlocksPerGroup = %lu\n", m_info.dwBlocksPerGroup);
for (i = 0; i < m_info.dwGroupsCount; i++)
{
if (Le32ToCpu(desc[i].bg_block_bitmap))
{
// -- read the bitmap block
errno = 0;
nRes = readData(cTempBitmap+(i*(m_info.dwBlocksPerGroup/8)), ((QWORD)m_info.dwBlockSize) *
((QWORD)Le32ToCpu(desc[i].bg_block_bitmap)), (m_info.dwBlocksPerGroup/8));
if (nRes == -1)
{
showDebug(1, "CExt2Part::readBitmap(): Error 005\n");
showDebug(1, "CExt2Part::readBitmap(): err=%d=%d\n", errno, strerror(errno));
goto error_readBitmap;
}
}
else
{
memset(cTempBitmap+(i*(m_info.dwBlocksPerGroup/8)), 0, (m_info.dwBlocksPerGroup/8));
}
}
// convert bitmap to little endian
DWORD *dwPtr;
DWORD dwLen;
dwLen = sizeof(cTempBitmap) / sizeof(DWORD);
dwPtr = (DWORD *)cTempBitmap;
for (i=0; i < dwLen; i++, dwPtr++)
*dwPtr = CpuToLe32(*dwPtr);
// bitmap is full of 0 at init, then we just have to
// write 1 for used blocks
// the boot block of 1024 bytes = used
for (i=0; i < dwBootBlocks; i++)
m_bitmap.setBit(i, true);
dwUsed=0; dwFree=0;
for (i=dwBootBlocks, dwExt2DataBlock=0; dwExt2DataBlock < ( m_info.dwTotalBlocksCount- m_info.dwFirstBlock); dwExt2DataBlock++)
{
dwBit = dwExt2DataBlock % 8;
dwByte = (dwExt2DataBlock - dwBit) / 8;
group = (dwExt2DataBlock/m_info.dwBlocksPerGroup);
if ((cTempBitmap[dwByte] & (1 << dwBit)) != 0)
{
for (j=0; j < m_info.dwLogicalBlocksPerExt2Block; j++, i++)
m_bitmap.setBit(i, true);
showDebug(3, "m_bitmap.setBit(%1u, true), g = %i\n", (i/4), group);
dwUsed++;
}
else
{
for (j=0; j < m_info.dwLogicalBlocksPerExt2Block; j++, i++)
m_bitmap.setBit(i, false);
showDebug(3, "m_bitmap.setBit(%1u, false), g = %i\n", (i/4), group);
dwFree++;
}
}
showDebug(1,"used=%lu\nfree=%lu\ntotal=%lu\n",dwUsed,dwFree,dwUsed+dwFree);
calculateSpaceFromBitmap();
//success_readBitmap:
delete []cTempBitmap;
showDebug(1, "end success\n");
RETURN; // auccess
error_readBitmap:
delete []cTempBitmap;
showDebug(1, "end error\n");
g_interface->msgBoxError(i18n("There was an error while reading the bitmap"));
THROW(ERR_READ_BITMAP);
}
示例7: S_absorb_slices
static void
S_absorb_slices(SortExternal *self, SortExternalIVARS *ivars,
Obj **endpost) {
uint32_t num_runs = VA_Get_Size(ivars->runs);
Obj ***slice_starts = ivars->slice_starts;
uint32_t *slice_sizes = ivars->slice_sizes;
Class *klass = SortEx_Get_Class(self);
CFISH_Sort_Compare_t compare
= (CFISH_Sort_Compare_t)METHOD_PTR(klass, LUCY_SortEx_Compare);
if (ivars->buf_max != 0) { THROW(ERR, "Can't refill unless empty"); }
// Move all the elements in range into the main buffer as slices.
for (uint32_t i = 0; i < num_runs; i++) {
SortExternal *const run = (SortExternal*)VA_Fetch(ivars->runs, i);
SortExternalIVARS *const run_ivars = SortEx_IVARS(run);
uint32_t slice_size = S_find_slice_size(run, run_ivars, endpost);
if (slice_size) {
// Move slice content from run buffer to main buffer.
if (ivars->buf_max + slice_size > ivars->buf_cap) {
size_t cap = Memory_oversize(ivars->buf_max + slice_size,
sizeof(Obj*));
SortEx_Grow_Buffer(self, cap);
}
memcpy(ivars->buffer + ivars->buf_max,
run_ivars->buffer + run_ivars->buf_tick,
slice_size * sizeof(Obj*));
run_ivars->buf_tick += slice_size;
ivars->buf_max += slice_size;
// Track number of slices and slice sizes.
slice_sizes[ivars->num_slices++] = slice_size;
}
}
// Transform slice starts from ticks to pointers.
uint32_t total = 0;
for (uint32_t i = 0; i < ivars->num_slices; i++) {
slice_starts[i] = ivars->buffer + total;
total += slice_sizes[i];
}
// The main buffer now consists of several slices. Sort the main buffer,
// but exploit the fact that each slice is already sorted.
if (ivars->scratch_cap < ivars->buf_cap) {
ivars->scratch_cap = ivars->buf_cap;
ivars->scratch = (Obj**)REALLOCATE(
ivars->scratch, ivars->scratch_cap * sizeof(Obj*));
}
// Exploit previous sorting, rather than sort buffer naively.
// Leave the first slice intact if the number of slices is odd. */
while (ivars->num_slices > 1) {
uint32_t i = 0;
uint32_t j = 0;
while (i < ivars->num_slices) {
if (ivars->num_slices - i >= 2) {
// Merge two consecutive slices.
const uint32_t merged_size = slice_sizes[i] + slice_sizes[i + 1];
Sort_merge(slice_starts[i], slice_sizes[i],
slice_starts[i + 1], slice_sizes[i + 1], ivars->scratch,
sizeof(Obj*), compare, self);
slice_sizes[j] = merged_size;
slice_starts[j] = slice_starts[i];
memcpy(slice_starts[j], ivars->scratch, merged_size * sizeof(Obj*));
i += 2;
j += 1;
}
else if (ivars->num_slices - i >= 1) {
// Move single slice pointer.
slice_sizes[j] = slice_sizes[i];
slice_starts[j] = slice_starts[i];
i += 1;
j += 1;
}
}
ivars->num_slices = j;
}
ivars->num_slices = 0;
}
示例8: ncuriparse
/* Do a simple uri parse: return 0 if fail, 1 otherwise*/
int
ncuriparse(const char* uri0, NCURI** durip)
{
NCURI* duri = NULL;
char* uri = NULL;
char* p;
struct NC_ProtocolInfo* proto;
int i,nprotos;
/* accumulate parse points*/
char* protocol = NULL;
char* host = NULL;
char* port = NULL;
char* constraint = NULL;
char* user = NULL;
char* pwd = NULL;
char* file = NULL;
char* prefixparams = NULL;
char* suffixparams = NULL;
if(uri0 == NULL || strlen(uri0) == 0)
{THROW(1); goto fail;}
duri = (NCURI*)calloc(1,sizeof(NCURI));
if(duri == NULL)
{THROW(2); goto fail;}
/* save original uri */
duri->uri = nulldup(uri0);
/* make local copy of uri */
uri = (char*)malloc(strlen(uri0)+1+PADDING); /* +1 for trailing null,
+PADDING for shifting */
if(uri == NULL)
{THROW(3); goto fail;}
/* strings will be broken into pieces with intermixed '\0; characters;
first char is guaranteed to be '\0' */
duri->strings = uri;
uri++;
/* dup the incoming url */
strcpy(uri,uri0);
/* Walk the uri and do the following:
1. remove all whitespace
2. remove all '\\' (Temp hack to remove escape characters
inserted by Windows or MinGW)
*/
for(p=uri;*p;p++) {
if(*p == '\\' || *p < ' ')
nclshift1(p); /* compress out */
}
p = uri;
/* break up the uri string into big chunks: prefixparams, protocol,
host section, and the file section (i.e. remainder)
*/
/* collect any prefix bracketed parameters */
if(*p == LBRACKET) {
prefixparams = p+1;
/* find end of the clientparams; convert LB,RB to '&' */
for(;*p;p++) {
if(p[0] == RBRACKET && p[1] == LBRACKET) {
p[0] = '&';
nclshift1(p+1);
} else if(p[0] == RBRACKET && p[1] != LBRACKET)
break;
}
if(*p == 0)
{THROW(4); goto fail; /* malformed client params*/}
terminate(p); /* nul term the prefixparams (overwrites
the final RBRACKET) */
p++; /* move past the final RBRACKET */
}
/* Tag the protocol */
protocol = p;
p = strchr(p,':');
if(!p)
{THROW(5); goto fail;}
terminate(p); /*overwrite colon*/
p++; /* skip the colon */
/* verify that the uri starts with an acceptable protocol*/
nprotos = (sizeof(legalprotocols)/sizeof(struct NC_ProtocolInfo));
proto = NULL;
for(i=0;i<nprotos;i++) {
if(strcmp(protocol,legalprotocols[i].name)==0) {
proto = &legalprotocols[i];
break;
}
}
if(proto == NULL)
{THROW(6); goto fail; /* illegal protocol*/}
//.........这里部分代码省略.........
示例9: debug
void
Interpreter::loadModuleRecursive (const string &moduleName)
{
debug ("Interpreter::loadModuleRecursive "
"(moduleName = " << moduleName << ")");
if (moduleIsLoadedInternal (moduleName))
{
debug ("\talready loaded");
return;
}
//
// Using the module search path, locate the file that contains the
// source code for the module. Open the file.
//
string fileName = findModule (moduleName);
ifstream file (fileName.c_str());
if (!file)
{
THROW_ERRNO ("Cannot load CTL module \"" << moduleName << "\". "
"Opening file \"" << fileName << "\" for reading "
"failed (%T).");
}
debug ("\tloading from file \"" << fileName << "\"");
Module *module = 0;
LContext *lcontext = 0;
try
{
//
// Create a Module, an Lcontext and a Parser
//
module = newModule (moduleName, fileName);
_data->moduleSet.addModule (module);
lcontext = newLContext (file, module, _data->symtab);
Parser parser (*lcontext, *this);
//
// Parse the source code and generate executable code
// for the module
//
debug ("\tparsing input");
SyntaxNodePtr syntaxTree = parser.parseInput ();
if (syntaxTree && lcontext->numErrors() == 0)
{
debug ("\tgenerating code");
syntaxTree->generateCode (*lcontext);
}
if (lcontext->numErrors() > 0)
{
lcontext->printDeclaredErrors();
THROW (LoadModuleExc,
"Failed to load CTL module \"" << moduleName << "\".");
}
//
// Run the module's initialization code
//
debug ("\trunning module initialization code");
module->runInitCode();
//
// Cleanup: the LContext and the module's local symbols
// are no longer needed, but we keep the global symbols.
//
debug ("\tcleanup");
delete lcontext;
_data->symtab.deleteAllLocalSymbols (module);
}
catch (...)
{
//
// Something went wrong while loading the module, clean up
//
delete lcontext;
_data->symtab.deleteAllSymbols (module);
_data->moduleSet.removeModule (moduleName);
throw;
}
}
示例10: fb_mul_karat_imp
/**
* Multiplies two binary field elements using recursive Karatsuba
* multiplication.
*
* @param[out] c - the result.
* @param[in] a - the first binary field element.
* @param[in] b - the second binary field element.
* @param[in] size - the number of digits to multiply.
* @param[in] level - the number of Karatsuba steps to apply.
*/
static void fb_mul_karat_imp(dv_t c, const fb_t a, const fb_t b, int size,
int level) {
int i, h, h1;
dv_t a1, b1, ab;
dig_t *a0b0, *a1b1;
dv_null(a1);
dv_null(b1);
dv_null(ab);
/* Compute half the digits of a or b. */
h = size >> 1;
h1 = size - h;
TRY {
/* Allocate the temp variables. */
dv_new(a1);
dv_new(b1);
dv_new(ab);
a0b0 = ab;
a1b1 = ab + 2 * h;
/* a0b0 = a0 * b0 and a1b1 = a1 * b1 */
if (level <= 1) {
#if FB_MUL == BASIC
fb_mul_basic_imp(a0b0, a, b, h);
fb_mul_basic_imp(a1b1, a + h, b + h, h1);
#elif FB_MUL == LCOMB
fb_mul_lcomb_imp(a0b0, a, b, h);
fb_mul_lcomb_imp(a1b1, a + h, b + h, h1);
#elif FB_MUL == RCOMB
fb_mul_rcomb_imp(a0b0, a, b, h);
fb_mul_rcomb_imp(a1b1, a + h, b + h, h1);
#elif FB_MUL == INTEG || FB_MUL == LODAH
fb_muld_low(a0b0, a, b, h);
fb_muld_low(a1b1, a + h, b + h, h1);
#endif
} else {
fb_mul_karat_imp(a0b0, a, b, h, level - 1);
fb_mul_karat_imp(a1b1, a + h, b + h, h1, level - 1);
}
for (i = 0; i < 2 * size; i++) {
c[i] = ab[i];
}
/* c = c - (a0*b0 << h digits) */
fb_addd_low(c + h, c + h, a0b0, 2 * h);
/* c = c - (a1*b1 << h digits) */
fb_addd_low(c + h, c + h, a1b1, 2 * h1);
/* a1 = (a1 + a0) */
fb_addd_low(a1, a, a + h, h);
/* b1 = (b1 + b0) */
fb_addd_low(b1, b, b + h, h);
if (h1 > h) {
a1[h1 - 1] = a[h + h1 - 1];
b1[h1 - 1] = b[h + h1 - 1];
}
if (level <= 1) {
/* a1b1 = (a1 + a0)*(b1 + b0) */
#if FB_MUL == BASIC
fb_mul_basic_imp(a1b1, a1, b1, h1);
#elif FB_MUL == LCOMB
fb_mul_lcomb_imp(a1b1, a1, b1, h1);
#elif FB_MUL == RCOMB
fb_mul_rcomb_imp(a1b1, a1, b1, h1);
#elif FB_MUL == INTEG || FB_MUL == LODAH
fb_muld_low(a1b1, a1, b1, h1);
#endif
} else {
fb_mul_karat_imp(a1b1, a1, b1, h1, level - 1);
}
/* c = c + [(a1 + a0)*(b1 + b0) << digits] */
fb_addd_low(c + h, c + h, a1b1, 2 * h1);
}
CATCH_ANY {
THROW(ERR_CAUGHT);
}
FINALLY {
dv_free(a1);
dv_free(b1);
dv_free(ab);
}
}
示例11: flom_handle_init
int flom_handle_init(flom_handle_t *handle)
{
enum Exception { G_TRY_MALLOC_ERROR1
, G_TRY_MALLOC_ERROR2
, CONFIG_INIT_ERROR
, NONE } excp;
int ret_cod = FLOM_RC_INTERNAL_ERROR;
/* check flom library is initialized */
if (FLOM_RC_OK != (ret_cod = flom_init_check()))
return ret_cod;
FLOM_TRACE(("flom_handle_init\n"));
TRY {
/* memory reset */
memset(handle, 0, sizeof(flom_handle_t));
/* allocate memory for connection data structure */
if (NULL == (handle->conn_data = g_try_malloc0(
sizeof(struct flom_conn_data_s))))
THROW(G_TRY_MALLOC_ERROR1);
/* allocate memory for configuration data structure */
if (NULL == (handle->config = g_try_malloc0(
sizeof(flom_config_t))))
THROW(G_TRY_MALLOC_ERROR2);
/* initialize config object */
if (FLOM_RC_OK != (ret_cod = flom_config_clone(handle->config)))
THROW(CONFIG_INIT_ERROR);
/* clients can not fork a new flom daemon: this restriction is
* necessary to avoid the side effects related to daemonization that
* can affect a general purpose environment... This is a CLIENT!!! */
flom_config_set_lifespan(handle->config, 0);
/* state reset */
handle->state = FLOM_HANDLE_STATE_INIT;
THROW(NONE);
} CATCH {
switch (excp) {
case G_TRY_MALLOC_ERROR1:
case G_TRY_MALLOC_ERROR2:
ret_cod = FLOM_RC_G_TRY_MALLOC_ERROR;
break;
case CONFIG_INIT_ERROR:
break;
case NONE:
ret_cod = FLOM_RC_OK;
break;
default:
ret_cod = FLOM_RC_INTERNAL_ERROR;
} /* switch (excp) */
} /* TRY-CATCH */
/* clean memory if an error occurred */
if (NONE != excp) {
if (NULL != handle->config) {
flom_config_free(handle->config);
g_free(handle->config);
handle->config = NULL;
} /* if (NULL != handle->config) */
if (NULL != handle->conn_data) {
g_free(handle->conn_data);
handle->conn_data = NULL;
} /* if (NULL != handle->conn_data) */
} /* if (NONE != excp) */
FLOM_TRACE(("flom_handle_init/excp=%d/"
"ret_cod=%d/errno=%d\n", excp, ret_cod, errno));
return ret_cod;
}
示例12: flom_handle_unlock
int flom_handle_unlock(flom_handle_t *handle)
{
enum Exception { NULL_OBJECT
, API_INVALID_SEQUENCE
, OBJ_CORRUPTED
, CLIENT_UNLOCK_ERROR
, CLIENT_DISCONNECT_ERROR
, NONE } excp;
int ret_cod = FLOM_RC_INTERNAL_ERROR;
/* check flom library is initialized */
if (FLOM_RC_OK != (ret_cod = flom_init_check()))
return ret_cod;
FLOM_TRACE(("flom_handle_unlock\n"));
TRY {
struct flom_conn_data_s *cd = NULL;
/* check handle is not NULL */
if (NULL == handle)
THROW(NULL_OBJECT);
/* cast and retrieve conn_data fron the proxy object */
cd = (struct flom_conn_data_s *)handle->conn_data;
/* check handle state */
if (FLOM_HANDLE_STATE_LOCKED != handle->state &&
FLOM_HANDLE_STATE_CONNECTED != handle->state) {
FLOM_TRACE(("flom_handle_unlock: handle->state=%d\n",
handle->state));
THROW(API_INVALID_SEQUENCE);
}
/* check the connection data pointer is not NULL (we can't be sure
it's a valid pointer) */
if (NULL == handle->conn_data)
THROW(OBJ_CORRUPTED);
if (FLOM_HANDLE_STATE_LOCKED == handle->state) {
/* lock release */
if (FLOM_RC_OK != (ret_cod = flom_client_unlock(
handle->config, cd)))
THROW(CLIENT_UNLOCK_ERROR);
/* state update */
handle->state = FLOM_HANDLE_STATE_CONNECTED;
} else {
FLOM_TRACE(("flom_handle_unlock: resource already unlocked (%d), "
"skipping...\n", handle->state));
}
/* gracefully disconnect from daemon */
if (FLOM_RC_OK != (ret_cod = flom_client_disconnect(cd)))
THROW(CLIENT_DISCONNECT_ERROR);
/* state update */
handle->state = FLOM_HANDLE_STATE_DISCONNECTED;
THROW(NONE);
} CATCH {
switch (excp) {
case NULL_OBJECT:
ret_cod = FLOM_RC_NULL_OBJECT;
break;
case API_INVALID_SEQUENCE:
ret_cod = FLOM_RC_API_INVALID_SEQUENCE;
break;
case OBJ_CORRUPTED:
ret_cod = FLOM_RC_OBJ_CORRUPTED;
break;
case CLIENT_UNLOCK_ERROR:
case CLIENT_DISCONNECT_ERROR:
break;
case NONE:
ret_cod = FLOM_RC_OK;
break;
default:
ret_cod = FLOM_RC_INTERNAL_ERROR;
} /* switch (excp) */
} /* TRY-CATCH */
FLOM_TRACE(("flom_handle_unlock/excp=%d/"
"ret_cod=%d/errno=%d\n", excp, ret_cod, errno));
return ret_cod;
}
示例13: operator
bool operator()(T const& val) const
{
THROW(CppUtils::OperationFailed, "exc_NotImplemented", "ctx_Comparator", "" );
}
示例14: memset
void SmsPluginTransport::msgInfoToSubmitData(const MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SUBMIT_DATA_S *pData, SMS_CODING_SCHEME_T *pCharType, int addrIndex)
{
// Destination Address
pData->destAddress.ton = SMS_TON_UNKNOWN;
pData->destAddress.npi = SMS_NPI_ISDN;
memset(pData->destAddress.address, 0x00, MAX_ADDRESS_LEN+1);
memcpy(pData->destAddress.address, pMsgInfo->addressList[addrIndex].addressVal, MAX_ADDRESS_LEN);
MSG_DEBUG("ton [%d]", pData->destAddress.ton);
MSG_DEBUG("npi [%d]", pData->destAddress.npi);
MSG_DEBUG("address [%s]", pData->destAddress.address);
int decodeLen = 0, bufSize = (MAX_GSM_7BIT_DATA_LEN*MAX_SEGMENT_NUM) + 1; // SMS_CHARSET_7BIT
unsigned char decodeData[bufSize];
memset(decodeData, 0x00, sizeof(decodeData));
msg_encode_type_t encodeType = MSG_ENCODE_GSM7BIT;
SMS_LANGUAGE_ID_T langId = SMS_LANG_ID_RESERVED;
// User Data
if (pMsgInfo->bTextSms == true)
{
if (*pCharType == SMS_CHARSET_7BIT)
{
decodeLen = SmsPluginTextConvert::instance()->convertUTF8ToGSM7bit(decodeData, bufSize, (unsigned char*)pMsgInfo->msgText, pMsgInfo->dataSize, &langId);
}
else if (*pCharType == SMS_CHARSET_8BIT)
{
memcpy(decodeData, pMsgInfo->msgText, pMsgInfo->dataSize);
decodeLen = pMsgInfo->dataSize;
}
else if (*pCharType == SMS_CHARSET_UCS2)
{
decodeLen = SmsPluginTextConvert::instance()->convertUTF8ToUCS2(decodeData, bufSize, (unsigned char*)pMsgInfo->msgText, pMsgInfo->dataSize);
}
else if (*pCharType == SMS_CHARSET_AUTO)
{
decodeLen = SmsPluginTextConvert::instance()->convertUTF8ToAuto(decodeData, bufSize, (unsigned char*)pMsgInfo->msgText, pMsgInfo->dataSize, &encodeType);
*pCharType = encodeType;
}
}
else
{
int fileSize = 0;
char* pFileData = NULL;
AutoPtr<char> FileBuf(&pFileData);
// Read Message Data from File
if (MsgOpenAndReadFile(pMsgInfo->msgData, &pFileData, &fileSize) == false)
THROW(MsgException::FILE_ERROR, "MsgOpenAndReadFile error");
MSG_DEBUG("file size : [%d] file data : [%s]", fileSize, pFileData);
if (*pCharType == SMS_CHARSET_7BIT)
{
decodeLen = SmsPluginTextConvert::instance()->convertUTF8ToGSM7bit(decodeData, bufSize, (unsigned char*)pFileData, fileSize, &langId);
}
else if (*pCharType == SMS_CHARSET_8BIT)
{
memcpy(decodeData, pFileData, fileSize);
decodeLen = fileSize;
}
else if (*pCharType == SMS_CHARSET_UCS2)
{
decodeLen = SmsPluginTextConvert::instance()->convertUTF8ToUCS2(decodeData, bufSize, (unsigned char*)pFileData, fileSize);
}
else if (*pCharType == SMS_CHARSET_AUTO)
{
decodeLen = SmsPluginTextConvert::instance()->convertUTF8ToAuto(decodeData, bufSize, (unsigned char*)pFileData, fileSize, &encodeType);
*pCharType = encodeType;
}
// Delete File
MsgDeleteFile(pMsgInfo->msgData);
}
MSG_DEBUG("decode length : [%d]", decodeLen);
MSG_DEBUG("character type : [%d]", *pCharType);
MSG_DEBUG("Language Identifier : [%d]", langId);
MSG_DEBUG("reply address : [%s]", pMsgInfo->replyAddress);
int addrLen = 0;
char* encodedAddr = NULL;
AutoPtr<char> addressBuf(&encodedAddr);
if (strlen(pMsgInfo->replyAddress) > 0)
{
SMS_ADDRESS_S replyAddr = {};
replyAddr.ton = SMS_TON_NATIONAL;
replyAddr.npi = SMS_NPI_ISDN;
memset(replyAddr.address, 0x00, MAX_ADDRESS_LEN+1);
memcpy(replyAddr.address, pMsgInfo->replyAddress, MAX_ADDRESS_LEN);
//.........这里部分代码省略.........
示例15: MSG_BEGIN
//.........这里部分代码省略.........
tpdu.data.submit.destAddress.npi = submitData.destAddress.npi;
if (addLen < MAX_ADDRESS_LEN) {
memcpy(tpdu.data.submit.destAddress.address, submitData.destAddress.address, addLen);
tpdu.data.submit.destAddress.address[addLen] = '\0';
} else {
memcpy(tpdu.data.submit.destAddress.address, submitData.destAddress.address, MAX_ADDRESS_LEN);
tpdu.data.submit.destAddress.address[MAX_ADDRESS_LEN] = '\0';
}
for (unsigned int segCnt = 0; segCnt < submitData.segCount; segCnt++)
{
if (submitData.userData[segCnt].headerCnt > 0)
{
tpdu.data.submit.bHeaderInd = true;
}
else
{
tpdu.data.submit.bHeaderInd = false;
}
memset(&(tpdu.data.submit.userData), 0x00, sizeof(SMS_USERDATA_S));
memcpy(&(tpdu.data.submit.userData), &(submitData.userData[segCnt]), sizeof(SMS_USERDATA_S));
// Encode SMS-SUBMIT TPDU
memset(buf, 0x00, sizeof(buf));
bufLen = SmsPluginTpduCodec::encodeTpdu(&tpdu, buf);
// Make Telephony Structure
TelSmsDatapackageInfo_t pkgInfo;
// Set TPDU data
memset((void*)pkgInfo.szData, 0x00, sizeof(pkgInfo.szData));
memcpy((void*)pkgInfo.szData, buf, bufLen);
pkgInfo.szData[bufLen] = 0;
pkgInfo.MsgLength = bufLen;
// Set SMSC data
memset(pkgInfo.Sca, 0x00, sizeof(pkgInfo.Sca));
memcpy((void*)pkgInfo.Sca, smscAddr, smscLen);
pkgInfo.Sca[smscLen] = '\0';
SMS_SENT_INFO_S sentInfo = {};
bool bMoreMsg = FALSE;
memcpy(&(sentInfo.reqInfo), pReqInfo, sizeof(SMS_REQUEST_INFO_S));
if ((segCnt+1) == submitData.segCount && (i+1)==pReqInfo->msgInfo.nAddressCnt)
{
sentInfo.bLast = true;
bMoreMsg = FALSE;
}
else
{
sentInfo.bLast = false;
bMoreMsg = TRUE;
}
SmsPluginEventHandler::instance()->SetSentInfo(&sentInfo);
curStatus = MSG_NETWORK_SENDING;
// Send SMS
int tapiRet = TAPI_API_SUCCESS;
tapiRet = tel_send_sms(pTapiHandle, &pkgInfo, bMoreMsg, TapiEventSentStatus, NULL);
if (tapiRet == TAPI_API_SUCCESS)
{
MSG_DEBUG("######## TelTapiSmsSend Success !!! req Id : [%d] return : [%d] #######", reqId, tapiRet);
}
else
{
SmsPluginEventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_FAIL);
THROW(MsgException::SMS_PLG_ERROR, "######## TelTapiSmsSend Fail !!! req Id : [%d] return : [%d] #######", reqId, tapiRet);
}
msg_network_status_t retStatus = getNetStatus();
if (retStatus == MSG_NETWORK_SEND_SUCCESS)
{
MSG_DEBUG("######## Msg Sent was Successful !!! req Id : [%d] return : [%d] #######", reqId, retStatus);
}
else
{
SmsPluginEventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_FAIL);
THROW(MsgException::SMS_PLG_ERROR, "######## Msg Sent was Failed !!! req Id : [%d] return : [%d] #######", reqId, retStatus);
}
if (tpdu.data.submit.userData.headerCnt > 0) tpdu.data.submit.userData.headerCnt--;
}
}
MSG_END();
}