Example #1
0
DbException::DbException(const DbException &that)
:	__DB_STD(exception)()
,	what_(dupString(that.what_))
,	err_(that.err_)
,	dbenv_(0)
{
}

DbException &DbException::operator = (const DbException &that)
{
	if (this != &that) {
		err_ = that.err_;
		delete [] what_;
		what_ = dupString(that.what_);
	}
	return (*this);
}

void DbException::describe(const char *prefix, const char *description)
{
	char *msgbuf, *p, *end;

	msgbuf = new char[MAX_DESCRIPTION_LENGTH];
	p = msgbuf;
	end = msgbuf + MAX_DESCRIPTION_LENGTH - 1;

	if (prefix != NULL) {
		strncpy(p, prefix, (p < end) ? end - p: 0);
		p += strlen(prefix);
		strncpy(p, ": ", (p < end) ? end - p: 0);
		p += 2;
	}
	if (description != NULL) {
		strncpy(p, description, (p < end) ? end - p: 0);
		p += strlen(description);
		if (err_ != 0) {
			strncpy(p, ": ", (p < end) ? end - p: 0);
			p += 2;
		}
	}
	if (err_ != 0) {
		strncpy(p, db_strerror(err_), (p < end) ? end - p: 0);
		p += strlen(db_strerror(err_));
	}

	/*
	 * If the result was too long, the buffer will not be null-terminated,
	 * so we need to fix that here before duplicating it.
	 */
	if (p >= end)
		*end = '\0';

	what_ = dupString(msgbuf);
	delete [] msgbuf;
}
Example #2
0
Exception::Exception( const Exception& e )
    : std::exception(e)
    , m_file(dupString(e.m_file))
    , m_line(e.m_line)
    , m_msg(dupString(e.m_msg))
	, m_subClassId(e.m_subClassId)
    , m_subException(e.m_subException ? e.m_subException->clone() : 0)
	, m_errorCode(e.m_errorCode)
{
#if defined(BLOCXX_NON_THREAD_SAFE_EXCEPTION_HANDLING)
    m_mutex->acquire();
#endif
}
Example #3
0
Exception::Exception(const char* file, int line, const char* msg, int errorCode, const Exception* subException, int subClassId)
	: std::exception()
	, m_file(dupString(file))
	, m_line(line)
	, m_msg(dupString(msg))
	, m_subClassId(subClassId)
	, m_subException(subException ? subException->clone() : 0)
	, m_errorCode(errorCode)
{
#if defined(BLOCXX_NON_THREAD_SAFE_EXCEPTION_HANDLING)
	m_mutex->acquire();
#endif
}
Example #4
0
static myOption_t *myOptionAlloc(char *longOption,char shortOption, int has_arg, char type, void *dataPtr, int dataSize, char *help) {
  myOption_t *o;
  static int iBase=129;
  o = (myOption_t*)calloc(sizeof(myOption_t),1);
  o->help = dupString(help);
  o->longArg = dupString(longOption);
  if(shortOption) o->shortArg[0] = (unsigned char)shortOption;
  else {o->shortArg[0] = iBase; iBase++;}
  o->argFlag = has_arg;
  o->type = type;
  o->ptr = dataPtr;
  o->sz = dataSize;
  if(longOption) longest = (longest>strlen(longOption)?longest:strlen(longOption));
  return o;
}
Example #5
0
DirList *VIsoFile::getParent(DirList *dirList)
{
	DirList *tempList = rootList;
	char *parentPath;

	if (dirList == rootList)
		return dirList;

	parentPath = dupString(dirList->path);
	*(strrchr(parentPath, '/')) = 0;

	while (tempList)
	{
		if (strcmp(parentPath, tempList->path) == 0)
		{
			delete[] parentPath;
			return tempList;
		}

		tempList = tempList->next;
	}

	delete[] parentPath;
	return dirList;
}
Example #6
0
/**
 * Create a macro item entry.
 *
 * @param n      The name of the macro.
 * @param data   The image data for the macro.
 * @param l      The size of the image data.
 * @param p      The search position.
 */
MacroItem::MacroItem(const char *n, const char *data, size_t l, size_t p)
{
    next = NULL;
    name = dupString(n);
    imageBuffer = data;
    imageSize = l;
    searchPosition = p;
}
static MyOption* myOptionAlloc(
   const char* longOption, const char shortOption,
   int has_arg, const char type, void* dataPtr, int dataSize, const char* help)
{
   static int iBase=129;
   MyOption* o = (MyOption*)comdCalloc(1, sizeof(MyOption));
   o->help = dupString(help);
   o->longArg = dupString(longOption);
   if(shortOption) o->shortArg[0] = (unsigned char)shortOption;
   else 
   {
      o->shortArg[0] = iBase; 
      iBase++;
   }
   o->argFlag = has_arg;
   o->type = type;
   o->ptr = dataPtr;
   o->sz = dataSize;
   if(longOption) longest = (longest>strlen(longOption)?longest:strlen(longOption));
   return o;
}
Example #8
0
int main(int nargs, char *argv[])
{
	int i;
	char *copiedString;

	for (i=0; i<nargs; i++)
	{
		copiedString = dupString(argv[i]);
		printf("\nArgv[%d]: %s\n", i, *argv);
		printf("CopiedString = %s", copiedString);
		free(copiedString);
	}

	return 0;
}
 inline void setName(const char *name)
 {
     queueName = dupString(name);
 }
Example #10
0
bool VIsoFile::build(char *inDir)
{
	DirList *dirList, *tail;
	struct dirent2 **dirs;
	int count;
	int idx = 0;

	rootList = new DirList;
	rootList->path = dupString(inDir);
	rootList->content = NULL;
	rootList->contentJoliet = NULL;
	rootList->fileList = NULL;
	rootList->idx = idx++;
	rootList->next = NULL;
	dirList = tail = rootList;

	while (dirList)
	{
		count = scandir(dirList->path, &dirs, select_directories, alphasort);
		if (count < 0)
			return false;

		for (int i = 0; i < count; i++)
		{
			tail = tail->next = new DirList;
			tail->path = createPath(dirList->path, dirs[i]->d_name);
			tail->content = NULL;
			tail->contentJoliet = NULL;
			tail->idx = idx++;
			tail->fileList = NULL;
			tail->next = NULL;

			free(dirs[i]);
		}

		free(dirs);
		dirList = dirList->next;
	}

	dirList = rootList;
	while (dirList)
	{
		struct dirent2 **files;
		FileList *fileList = NULL;
		bool error = false;

		count = scandir(dirList->path, &files, select_files, alphasort);
		for (int i = 0; i < count; i++)
		{
			if (!error)
			{
				bool multipart = false;

				char *p = strrchr(files[i]->d_name, '.');
				if (p && strlen(p+1) == 5)
				{
					if (p[1] == '6' && p[2] == '6' && p[3] == '6' && isdigit(p[4]) && isdigit(p[5]))
					{
						multipart = true;

						if (p[4] != '0' || p[5] != '0')
						{
							free(files[i]);
							continue;
						}
					}
				}

				if (i == 0)
				{
					fileList = dirList->fileList = new FileList;
				}
				else
				{
					fileList = fileList->next = new FileList;
				}

				fileList->path = createPath(dirList->path, files[i]->d_name);
				fileList->multipart = multipart;
				fileList->next = NULL;

				if (getFileSizeAndProcessMultipart(fileList->path, &fileList->size))
				{
					fileList->rlba = filesSizeSectors;
					filesSizeSectors += bytesToSectors(fileList->size);
				}
				else
				{
					error = true;
				}
			}

			free(files[i]);
		}

		if (count >= 0)
			free(files);

		if (error)
			return false;

		dirList = dirList->next;
	}

	// Add iso directories
	dirList = rootList;
	while (dirList)
	{
		if (!buildContent(dirList, false))
		{
			return false;
		}

		dirList = dirList->next;
	}

	// Add joliet directories
	dirList = rootList;
	while (dirList)
	{
		if (!buildContent(dirList, true))
		{
			return false;
		}

		dirList = dirList->next;
	}

	pathTableL = buildPathTable(false, false, &pathTableSize);
	pathTableM = buildPathTable(true, false, &pathTableSize);
	pathTableJolietL = buildPathTable(false, true, &pathTableSizeJoliet);
	pathTableJolietM = buildPathTable(true, true, &pathTableSizeJoliet);

	uint32_t isoLba = (0xA000/0x800) + (bytesToSectors(pathTableSize) * 2) + (bytesToSectors(pathTableSizeJoliet) * 2);
	uint32_t jolietLba = isoLba + dirsSizeSectors;
	uint32_t filesLba = jolietLba + dirsSizeSectorsJoliet;

	fixLba(isoLba, jolietLba, filesLba);

	return true;
}