コード例 #1
0
ファイル: Image.cpp プロジェクト: SKIRT/SKIRT
void Image::import(const SimulationItem *item, QString filename, QString directory)
{
    // Cache a pointer to the logger
    Log* log = item->find<Log>();

    // Store a pointer to the units system
    _units = item->find<Units>();

    // Determine the path of the input FITS file
    QString filepath;
    filename = filename.endsWith(".fits") ? filename : filename + ".fits";
    if (directory.isNull())
    {
        filepath = item->find<FilePaths>()->input(filename);
    }
    else
    {
        QFileInfo test(directory);
        if (!test.isDir()) throw FATALERROR("Import directory does not exist: " + directory);
        filepath = directory + "/" + filename;
    }

    // Read the input image and store it
    log->info("Reading FITS file " + filepath);
    FITSInOut::read(filepath, _data, _xsize, _ysize, _nframes);

    // Verify that the FITS file contains only one frame
    if (_nframes != 1) throw FATALERROR("FITS image contains multiple frames");

    // Log the dimensions of the image
    log->info("Frame dimensions: " + QString::number(_xsize) + " x " + QString::number(_ysize));
}
コード例 #2
0
ファイル: launch.c プロジェクト: ludisnet/ludisoft
/*
 * extract from the archive
 * and copy to the filesystem 
 * relative to the directory the archive's in
 */
int extract2fs(TOC *ptoc)
{
#ifdef WIN32
	char *p;
#endif
	FILE *out;
	unsigned char *data = extract(ptoc);

	if (!f_workpath) {
		getTempPath(f_temppath);
#ifdef WIN32
		strcpy(f_temppathraw, f_temppath);
		for ( p=f_temppath; *p; p++ )
			if (*p == '\\')
				*p = '/';
#endif
		f_workpath = f_temppath;
	}
	out = openTarget(f_workpath, ptoc->name);

	if (out == NULL)  {
		FATALERROR(ptoc->name);
		FATALERROR(" could not be extracted!\n");
	}
	else {
		fwrite(data, ntohl(ptoc->ulen), 1, out);
#ifndef WIN32
		fchmod(fileno(out), S_IRUSR | S_IWUSR | S_IXUSR);
#endif
		fclose(out);
	}
	free(data);
	return 0;
}
コード例 #3
0
ファイル: launch.c プロジェクト: ludisnet/ludisoft
/*
 * Load the Python DLL, and get all of the necessary entry points
 * Windows only (dynamic load)
 */
int loadPython()
{
#ifdef WIN32
	HINSTANCE dll;
	char dllpath[_MAX_PATH + 1];

	/* Determine the path */
	sprintf(dllpath, "%spython%02d.dll", f_homepathraw, ntohl(f_cookie.pyvers));

	/* Load the DLL */
	dll = LoadLibraryEx(dllpath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);  
	if (dll) {
		VS(dllpath);
		VS("\n");
	}
	else {
		sprintf(dllpath, "%spython%02d.dll", f_temppathraw, ntohl(f_cookie.pyvers));
		dll = LoadLibraryEx(dllpath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH );
		if (dll) {
			VS(dllpath); 
			VS("\n");
		}
	}
	if (dll == 0) {
		FATALERROR("Error loading Python DLL: ");
		FATALERROR(dllpath);
		FATALERROR("\n");
		return -1;
	}

	mapNames(dll);
#endif

	return 0;
}
コード例 #4
0
void LogNormalGrainSizeDistribution::setupSelfBefore()
{
    RangeGrainSizeDistribution::setupSelfBefore();

    // verify the attributes
    if (_a0 <= 0) throw FATALERROR("The centroid of the log-normal law must be positive");
    if (_sigma <= 0) throw FATALERROR("The width of the log-normal law must be positive");
}
コード例 #5
0
void
YDustCompNormalization::setupSelfBefore()
{
    DustCompNormalization::setupSelfBefore();

    // verify that we have some wavelength and optical depth
    if (_wavelength <= 0) throw FATALERROR("Wavelength was not set");
    if (_tau <= 0) throw FATALERROR("Optical depth was not set");
}
コード例 #6
0
ファイル: TriaxialGeometry.cpp プロジェクト: lbignone/SKIRT
void
TriaxialGeometry::setupSelfBefore()
{
    GenGeometry::setupSelfBefore();

    // verify property values
    if (_p <= 0 || _p > 1.0) throw FATALERROR("the flattening parameter p should be between 0 and 1");
    if (_q <= 0 || _q > 1.0) throw FATALERROR("the flattening parameter q should be between 0 and 1");
}
コード例 #7
0
ファイル: if-candrv.c プロジェクト: LukeMeszar/CAS
   GMC_DCL(tp_Nod, Nod)
{
   tp_FilHdr FilHdr;
   tp_Nod RootNod, OprNod;
   tp_Key Key;

   if (Nod == ERROR) return ERROR;

   switch (Nod_NodTyp(Nod)) {
      case NSTDEF: case FILDEF: case SEGDEF: {
	 SystemError("Syntax error: Unexpected target.\n");
	 return ERROR; }/*case*/;
      case WORD: {
	 FilHdr = Str_FilHdr(Sym_Str(Nod_Sym(Nod)), NullPrmTyp);
	 return New_PrmFHdr(FilHdr, RootFilPrm); }/*case*/;
      case DRVFIL: {
	 break; }/*case*/;
      default: {
	 FATALERROR("Unexpected node type.\n"); };}/*switch*/;

   RootNod = Nod_Son(1, Nod);
   OprNod = Nod_Brother(RootNod);
   switch (Nod_NodTyp(RootNod)) {
      case EMPFIL: {
	 FilHdr = Copy_FilHdr(EmptyFilHdr);
	 break; }/*case*/;
      case ARTFIL: {
	 FilHdr = Copy_FilHdr(RootFilHdr);
	 break; }/*case*/;
      case OBJTID: {
	 FilHdr = LocHdr_FilHdr
	  ((tp_LocHdr)Str_PosInt(Sym_Str(Nod_Sym(RootNod))));
	 break; }/*case*/;
      case WORD: {
	 FilHdr = HostFN_FilHdr(Sym_Str(Nod_Sym(RootNod)));
	 break; }/*case*/;
      case ABSFIL: {
	 Key = Sym_Str(Nod_Sym(Nod_Son(1, RootNod)));
	 FilHdr = Do_Keys(Copy_FilHdr(RootFilHdr), Key);
	 break; }/*case*/;
      case SEGOPR: {
	 FilHdr = Get_BaseVTgtFilHdr(Top_ContextFilHdr());
	 OprNod = RootNod;
	 break; }/*case*/;
      case DRVOPR: {
	 FilHdr = Top_ContextFilHdr();
	 OprNod = RootNod;
	 break; }/*case*/;
      case STRING: {
	 FilHdr = Str_FilHdr(Sym_Str(Nod_Sym(Nod_Son(1, RootNod))), NullPrmTyp);
	 break; }/*case*/;
      default: {
	 FATALERROR("Unexpected node type.\n"); };}/*switch*/;

   return Apply_OprNods(FilHdr, RootFilPrm, OprNod);
   }/*Nod_PrmFHdr*/
コード例 #8
0
ファイル: createdc.c プロジェクト: OS2World/DEV-UTIL-MGL
/****************************************************************************
PARAMETERS:
dc  - Device context to destroy

RETURNS:
True if the context was destroyed, false on error.

REMARKS:
Searches for the display device context in the list of currently allocated
contexts, and destroys it if it exists. If this is the last display device
context, then we also shut down the graphics mode and restore the original
graphics mode.
{secret}
****************************************************************************/
ibool _MGL_destroyDisplayDC(
    MGLDC *dc)
{
    MGLDC   *prev;
    PM_HWND hwndConsole;

    if (!dc) {
        FATALERROR(grInvalidDC);
        return false;
        }
    if (DEV.dispDCList->count == 1) {
        /* There is only one active display context left, so restore
         * the original display mode and destroy the entire display
         * device context list
         */
        if (dc != _LST_first(DEV.dispDCList)) {
            FATALERROR(grInvalidDC);
            return false;
            }
        /* Save the console window handle for later as the DC structure
         * is destroyed before we close the console itself.
         */
        hwndConsole = (PM_HWND)dc->v->d.hwnd;
        dc->v->d.restoreTextMode(dc);
        _MGL_freeInternalDCVars(dc);
        dc->v->d.destroy(dc);
        _LST_destroy(DEV.dispDCList,_LST_freeNode);
        DEV.dispDCList = NULL;

        /* Restore the console state and close it */
        if (DEV.stateBuf) {
            PM_restoreConsoleState(DEV.stateBuf,hwndConsole);
            PM_free(DEV.stateBuf);
            DEV.stateBuf = NULL;
            PM_closeConsole(hwndConsole);
            }

        /* We are no longer in Windows full screen mode but on the desktop */
        if (_MGL_consoleSupport)
            _MS_setDisplayDC(NULL);
        }
    else {
        /* There is more than one active display context, so simply
         * remove the current one from the list and destroy it.
         */
        if ((prev = _LST_findNode(DEV.dispDCList,dc)) == NULL) {
            FATALERROR(grInvalidDC);
            return false;
            }
        _MGL_freeInternalDCVars(dc);
        dc->v->d.destroy(dc);
        _LST_removeNext(DEV.dispDCList,prev);
        _LST_freeNode(dc);
        }
    return true;
}
コード例 #9
0
ファイル: launch.c プロジェクト: ludisnet/ludisoft
/* 
 * Open the archive
 * Sets f_archiveFile, f_pkgstart, f_tocbuff and f_cookie.
 */
int openArchive()
{
	int filelen;

	/* Physically open the file */
	f_fp = fopen(f_archivename, "rb");
	if (f_fp == NULL) {
		VS("Cannot open archive: ");
		VS(f_archivename);
		VS("\n");
		return -1;
	}

	/* Seek to the Cookie at the end of the file. */
	fseek(f_fp, 0, SEEK_END);
	filelen = ftell(f_fp);
	if (fseek(f_fp, -(int)sizeof(COOKIE), SEEK_END)) 
	{
		VS(f_archivename);
		VS(" appears to be an invalid archive\n");
		return -1;
	}

	/* Read the Cookie, and check its MAGIC bytes */
	fread(&f_cookie, sizeof(COOKIE), 1, f_fp);
	if (strncmp(f_cookie.magic, MAGIC, strlen(MAGIC))) 
	{
		VS(f_archivename);
		VS(" has bad magic!\n");
		return -1;
	}

	/* From the cookie, calculate the archive start */
	f_pkgstart = filelen - ntohl(f_cookie.len);

	/* Read in in the table of contents */
	fseek(f_fp, f_pkgstart + ntohl(f_cookie.TOC), SEEK_SET);
	f_tocbuff = (TOC *) malloc(ntohl(f_cookie.TOClen));
	if (f_tocbuff == NULL) 
	{
		FATALERROR("Could not allocate buffer for TOC.");
		return -1;
	}
	fread(f_tocbuff, ntohl(f_cookie.TOClen), 1, f_fp);
	f_tocend = (TOC *) (((char *)f_tocbuff) + ntohl(f_cookie.TOClen));

	/* Check input file is still ok (should be). */
	if (ferror(f_fp))
	{
		FATALERROR("Error on file");
		return -1;
	}
	return 0;
}
コード例 #10
0
double AdaptiveMeshAsciiFile::value(int g) const
{
    // verify index range
    if (g < 0) throw FATALERROR("Field index out of range");
    if (g >= _columns.size()) throw FATALERROR("Insufficient number of field values in mesh data");

    // get the appropriate column value
    bool ok;
    double value = _columns.value(g).toDouble(&ok);
    if (!ok) throw FATALERROR("Invalid leaf line in mesh data");
    return value;
}
コード例 #11
0
ファイル: fontenum.c プロジェクト: OS2World/DEV-UTIL-MGL
/****************************************************************************
PARAMETERS:
dcache  - local cache for one directory
cache   - pointer to variable that holds list of found families

REMARKS:
Extracts information from dcache and translates it to cache.

This involves finding fonts with same family name and merging them into
one entry in cache.

Called exclusively by enumFontsInDir.
{secret}
****************************************************************************/
static void buildFontEnumCache(
    dirCache *dcache,
    fontEnumCache **cache)
{
    fontEnumCache  *ecache, *tail;
    size_t         i;
    fileCache      *f;

    if (dcache->filesCnt == 0)
        return;
    qsort(dcache->files, dcache->filesCnt, sizeof(fileCache),
          comparFileCacheByFamily);

    tail = ecache = NULL;
    for (i = 0, f = dcache->files; i < dcache->filesCnt; i++, f++) {
        /* new family: */
        if (tail == NULL ||
                    strcmp(tail->info.familyName, f->familyName) != 0) {
            if (tail == NULL) {
                if ((tail = ecache = PM_malloc(sizeof(fontEnumCache))) == NULL)
                    FATALERROR(grNoMem);
                }
            else {
                if ((tail->next = PM_malloc(sizeof(fontEnumCache))) == NULL)
                    FATALERROR(grNoMem);
                tail = tail->next;
                }
            tail->next = NULL;
            strcpy(tail->info.familyName, f->familyName);
            tail->info.fontLibType = f->fontLibType;
            tail->info.isFixed = f->isFixed;
            tail->info.regularFace[0] = '\0';
            tail->info.boldFace[0] = '\0';
            tail->info.italicFace[0] = '\0';
            tail->info.boldItalicFace[0] = '\0';
            }
        /* faces lookup: */
        if (!f->isBold && !f->isItalic)
            strcpy(tail->info.regularFace, f->fileName);
        else if (f->isBold && !f->isItalic)
            strcpy(tail->info.boldFace, f->fileName);
        else if (!f->isBold && f->isItalic)
            strcpy(tail->info.italicFace, f->fileName);
        else if (f->isBold && f->isItalic)
            strcpy(tail->info.boldItalicFace, f->fileName);
        }

    tail->next = *cache;
    *cache = ecache;
}
コード例 #12
0
ファイル: if-env.c プロジェクト: urnest/urnest
void
Init_Env(GMC_ARG_VOID)
{
   tps_FileName FileName;
   boolean Abort;
   size_t sz;

   OdinDirName = GetEnv("ODINCACHE");
   FORBIDDEN(OdinDirName == NIL);
   if (!IsDirectory_FileName(OdinDirName)) {
      SystemError("Odin root <%s> does not exist.\n", OdinDirName);
      FATALERROR("");}/*if*/;
   if (OdinDirName[0] != '/') {
      SystemError("Odin cache pathname <%s> must be absolute.\n", OdinDirName);
      FATALERROR("");}/*if*/;
   Set_ModeMask(OdinDirName);

   sz = snprintf(FileName, MAX_FileName, "%s/FILES", OdinDirName);
   if (sz >= MAX_FileName) {
      (void)fprintf(stderr, "File name too long (MAX_FileName=%d): %s/FILES\n",
                  MAX_FileName, OdinDirName);
      exit(1); }/*if*/;
   CacheDirName = Malloc_Str(FileName);
   MakeDirFile(&Abort, CacheDirName);
   if (Abort) FATALERROR("cannot create odin FILES directory");

   sz = snprintf(FileName, MAX_FileName, "%s/JOBS", OdinDirName);
   if (sz >= MAX_FileName) {
      (void)fprintf(stderr, "File name too long (MAX_FileName=%d): %s/JOBS\n",
                  MAX_FileName, OdinDirName);
      exit(1); }/*if*/;
   JobsDirName = Malloc_Str(FileName);
   MakeDirFile(&Abort, JobsDirName);
   if (Abort) FATALERROR("cannot create odin JOBS directory");

   sz = snprintf(FileName, MAX_FileName, "%s/ENV", OdinDirName);
   if (sz >= MAX_FileName) {
      (void)fprintf(stderr, "File name too long (MAX_FileName=%d): %s/ENV\n",
		  MAX_FileName, OdinDirName);
      exit(1); }/*if*/;
   Read_Env(FileName);

   DumpCore = (GetEnv("DUMPCORE") != NIL);
   RBS_Cmd = GetEnv("ODIN_RBSCMD");
   FORBIDDEN(RBS_Cmd == NIL);
   ShortCacheNameFlag = (GetEnv("ODIN_SHORTNAMES") != NIL);
   LocalIPCFlag = (GetEnv("ODIN_LOCALIPC") != NIL);
   }/*Init_Env*/
コード例 #13
0
ファイル: createdc.c プロジェクト: OS2World/DEV-UTIL-MGL
/****************************************************************************
PARAMETERS:
dc  - Device context to destroy

RETURNS:
True if the context was destroyed, false on error.

REMARKS:
Searches for the windowed device context in the list of currently allocated
contexts, and destroys it if it exists.
{secret}
****************************************************************************/
ibool _MGL_destroyWindowedDC(
    MGLDC *dc)
{
    MGLDC   *prev;
    PM_HWND hwndConsole;

    /* Remove the DC from the list of allocated memory DC's */
    if (!dc) {
        FATALERROR(grInvalidDC);
        return false;
        }
    if ((prev = _LST_findNode(_MGL_winDCList,dc)) == NULL) {
        __MGL_result = grInvalidDC;
        return false;
        }

    /* Unhook any window procedures that are hooked */
    _MGL_unhookWindowProc(dc);

    /* Free up all memory occupied by the DC */
    if (_MGL_winDCList->count == 1) {
        /* This is the last windowed device context, so destroy the list */
        if (dc != _LST_first(_MGL_winDCList)) {
            FATALERROR(grInvalidDC);
            return false;
            }
        hwndConsole = (PM_HWND)dc->v->d.hwnd;
        dc->v->d.restoreTextMode(dc);
        _MGL_freeInternalDCVars(dc);
        dc->v->w.destroy(dc);
        _LST_destroy(_MGL_winDCList,_LST_freeNode);
        _MGL_winDCList = NULL;

        /* Restore the console state and close it */
        PM_closeConsole(hwndConsole);

        /* We are no longer in Windows full screen mode but on the desktop */
        if (_MGL_consoleSupport)
            _MS_setDisplayDC(NULL);
        }
    else {
        _MGL_freeInternalDCVars(dc);
        dc->v->w.destroy(dc);
        _LST_removeNext(_MGL_winDCList,prev);
        _LST_freeNode(dc);
        }
    return true;
}
コード例 #14
0
void BinTreeDustGridStructure::setupSelfBefore()
{
    TreeDustGridStructure::setupSelfBefore();

    if (searchMethod() == TreeDustGridStructure::Bookkeeping)
        throw FATALERROR("Bookkeeping method is not compatible with binary tree");
}
コード例 #15
0
ファイル: launch.c プロジェクト: CNCBASHER/LasaurApp
/*
 * extract from the archive
 * and copy to the filesystem
 * relative to the directory the archive's in
 */
int extract2fs(ARCHIVE_STATUS *status, TOC *ptoc)
{
	FILE *out;
	unsigned char *data = extract(status, ptoc);

    if (createTempPath(status) == -1){
        return -1;
    }

	out = openTarget(status->temppath, ptoc->name);

	if (out == NULL)  {
		FATALERROR("%s could not be extracted!\n", ptoc->name);
		return -1;
	}
	else {
		fwrite(data, ntohl(ptoc->ulen), 1, out);
#ifndef WIN32
		fchmod(fileno(out), S_IRUSR | S_IWUSR | S_IXUSR);
#endif
		fclose(out);
	}
	free(data);
	return 0;
}
コード例 #16
0
void PowerLawGrainSizeDistribution::setupSelfBefore()
{
    RangeGrainSizeDistribution::setupSelfBefore();

    // verify the attributes
    if (_gamma <= 0) throw FATALERROR("The exponent must be positive");
}
コード例 #17
0
ファイル: launch.c プロジェクト: ludisnet/ludisoft
/* 
 * extract an archive entry
 * returns pointer to the data (must be freed)
 */
unsigned char *extract(TOC *ptoc)
{
	unsigned char *data;
	unsigned char *tmp;
	char msg[400];

	sprintf( msg, " extracting %1.20s (%d, %c)\n", ptoc->name, ptoc->cflag, ptoc->typcd);
	//VS(msg);
	fseek(f_fp, f_pkgstart + ntohl(ptoc->pos), SEEK_SET);
	data = (unsigned char *)malloc(ntohl(ptoc->len));
	if (data == NULL) {
		OTHERERROR("Could not allocate read buffer\n");
		return NULL;
	}
	fread(data, ntohl(ptoc->len), 1, f_fp);
	if (ptoc->cflag == '\1') {
#ifndef NOZLIB
		tmp = decompress(data, ptoc);
		free(data);
		data = tmp;
		if (data == NULL) {
			sprintf(msg, "Error decompressing %s\n", ptoc->name);
			OTHERERROR(msg);
			return NULL;
		}
#else
		FATALERROR("No ZLIB support but archive uses compression\n");
		return NULL;
#endif
	}
	return data;
}
コード例 #18
0
ファイル: createdc.c プロジェクト: OS2World/DEV-UTIL-MGL
/****************************************************************************
PARAMETERS:
list    - List to destroy the context from
dc      - Device context to destroy

RETURNS:
True if the context was destroyed, false on error.

REMARKS:
Searches for the device context in the list of currently allocated contexts,
and destroys it if it exists. If there are now more contexts in the list,
the list itself is destroyed.
{secret}
****************************************************************************/
ibool __MGL_destroyDC(
    LIST **listHandle,
    MGLDC *dc)
{
    LIST    *list = *listHandle;
    MGLDC   *prev;

    /* Remove the DC from the list of allocated DC's */
    CHECK(dc != NULL);
    if ((prev = _LST_findNode(list,dc)) == NULL) {
        FATALERROR(grInvalidDC);
        return false;
        }
    _LST_removeNext(list,prev);

    /* Free up all memory occupied by the DC */
    if (dc->offBuf)
        MGL_destroyBuffer(dc->offBuf);
    _MGL_freeInternalDCVars(dc);
    if (dc->v->m.destroy)
        dc->v->m.destroy(dc);
    _LST_freeNode(dc);

    /* If this is the last device context, destroy the list */
    if (list->count == 0) {
        _LST_destroy(list,_LST_freeNode);
        *listHandle = NULL;
        }
    return true;
}
コード例 #19
0
ファイル: ParameterRange.cpp プロジェクト: wsaftly/SKIRT-1
void ParameterRange::setupSelfBefore()
{
    SimulationItem::setupSelfBefore();

    if (_maximumValue < _minimumValue)
        throw FATALERROR("Maximum value of parameter range must be larger or equal than minimum value");
}
コード例 #20
0
ファイル: zoltan_timer.c プロジェクト: 00liujj/trilinos
int Zoltan_Timer_Init(
  ZTIMER *zt,           /* Ptr to Timer object */
  int use_barrier,      /* Flag indicating whether to perform a 
                           barrier operation before starting the
                           timer. */
  const char *name            /* Name of this timer */
)
{
/* Function that returns the index of the next available Timer timer. */
int ret;
static char *yo = "Zoltan_Timer_Init";

  TESTTIMER(zt, yo);
  
  ret = zt->NextTimeStruct++;

  if (ret >= zt->Length) {
    /* Realloc -- need more individual timers */
    zt->Length += INITLENGTH;
    zt->Times = (ZTIMER_TS *) ZOLTAN_REALLOC(zt->Times, zt->Length * sizeof(ZTIMER_TS));
  }

  Zoltan_Timer_Reset(zt, ret, use_barrier, name);

#ifdef VAMPIR
  if (VT_funcdef(name, VT_NOCLASS, &((zt->Times[ret]).vt_handle)) != VT_OK)
      FATALERROR(yo, "VT_funcdef failed.");
#endif

  return ret;
}
コード例 #21
0
ファイル: main.cpp プロジェクト: qroph/motion-solver
int main(int argc, char** argv)
{
    QCoreApplication app(argc, argv);

    if (argc == 2)
    {
        // Create new solver
        Solver* solver = new Solver;

        // Initialize and run
        solver->initialize(app.arguments().at(1));
        solver->run();
        solver->uninitialize();

        // Clean up
        delete solver;
        solver = NULL;

    }
    else
    {
        FATALERROR("Invalid arguments");
    }

    return 0;
}
コード例 #22
0
ファイル: if-candrv.c プロジェクト: LukeMeszar/CAS
   GMC_DCL(tp_PrmTyp, PrmTyp)
{
   tp_PrmFHdr PrmFHdr;
   tp_FilHdr FilHdr;
   tp_FilPrm FilPrm;
   tp_LocHdr LocHdr;

   if (Nod == ERROR || PrmTyp == ERROR) {
      return ERROR; }/*if*/;

   switch (Nod_NodTyp(Nod)) {
      case DRVFIL: {
	 PrmFHdr = Nod_PrmFHdr(Nod);
	 Use_PrmFHdr(&FilHdr, &FilPrm, PrmFHdr);
	 break;}/*case*/;
      case WORD: {
	 FilHdr = Str_FilHdr(Sym_Str(Nod_Sym(Nod)), PrmTyp);
	 break;}/*case*/;
      default: {
	 FATALERROR("illegal parameter value node"); };}/*select*/;
   if (FilHdr == ERROR) {
      return ERROR; }/*if*/;
   LocHdr = FilHdr_LocHdr(FilHdr);
   Ret_FilHdr(FilHdr);
   return LocHdr;
   }/*PrmValNod_LocHdr*/
コード例 #23
0
ファイル: utils.c プロジェクト: 3xp10it/evlal_win
int get_thisfile(char *thisfile, const char *programname)
{
    char buf[_MAX_PATH];
    char *p;

    /* Fill in thisfile. */
#ifdef __CYGWIN__
    if (strncasecmp(&programname[strlen(programname)-4], ".exe", 4)) {
        strcpy(thisfile, programname);
        strcat(thisfile, ".exe");
        PI_SetProgramName(thisfile);
    }
    else
#endif
    PI_SetProgramName(programname);

    strcpy(buf, PI_GetProgramFullPath());

    /* Make homepath absolute.
     * 'thisfile' starts ./ which breaks some modules when changing the CWD.
     */
    p = realpath(buf, thisfile);
    if(p == NULL) {
        FATALERROR("Error in making thisfile absolute.\n");
        return -1;
    }

    VS("thisfile is %s\n", thisfile);
    
    return 0;
}
コード例 #24
0
char * pyi_win32_wcs_to_mbs(const wchar_t *wstr) {
    DWORD len, ret;
    char * str;

    /* NOTE: setlocale hysterics are not needed on Windows - this function
       has an explicit codepage parameter. CP_ACP means "current ANSI codepage"
       which is set in the "Language for Non-Unicode Programs" control panel setting. */

    /* Get buffer size by passing NULL and 0 for output arguments */
    len = WideCharToMultiByte(CP_ACP,    // CodePage
                              0,         // dwFlags
                              wstr,      // lpWideCharStr
                              -1  ,      // cchWideChar - length in chars
                              NULL,      // lpMultiByteStr
                              0,         // cbMultiByte - length in bytes
                              NULL,      // lpDefaultChar
                              NULL       // lpUsedDefaultChar
                              );
    if(0 == len) {
        FATALERROR("Failed to get ANSI buffer size"
                   "(WideCharToMultiByte: %s)",
                   GetWinErrorString()
                   );
        return NULL;
    }

    str = (char *)malloc(sizeof(char) * wcslen(wstr) + 1);

    ret = WideCharToMultiByte(CP_ACP,    // CodePage
                              0,         // dwFlags
                              wstr,      // lpWideCharStr
                              -1,        // cchWideChar - length in chars
                              str,       // lpMultiByteStr
                              len,       // cbMultiByte - length in bytes
                              NULL,      // lpDefaultChar
                              NULL       // lpUsedDefaultChar
                              );

    if(0 == ret) {
        FATALERROR("Failed to encode filename as ANSI"
                   "(WideCharToMultiByte: %s)",
                   GetWinErrorString()
                   );
        return NULL;
    }
    return str;
}
コード例 #25
0
void
SpheroidalGeometry::setupSelfBefore()
{
    AxGeometry::setupSelfBefore();

    // verify property values
    if (_q <= 0 || _q > 1.0) throw FATALERROR("the flattening parameter q should be between 0 and 1");
}
コード例 #26
0
ファイル: launch.c プロジェクト: C4rt/pyinstaller
/*
 * Return pointer to next toc entry.
 */
TOC *incrementTocPtr(TOC* ptoc)
{
	TOC *result = (TOC*)((char *)ptoc + ntohl(ptoc->structlen));
	if (result < f_tocbuff) {
		FATALERROR("Cannot read Table of Contents.\n");
		return f_tocend;
	}
	return result;
}
コード例 #27
0
ファイル: utils.c プロジェクト: Matt-Esch/anaconda
int get_thisfile(char *thisfile, const char *programname)
{
	if (!GetModuleFileNameA(NULL, thisfile, _MAX_PATH)) {
		FATALERROR("System error - unable to load!");
		return -1;
	}
	
	return 0;
}
コード例 #28
0
ファイル: launch.c プロジェクト: CNCBASHER/LasaurApp
/*
 * Return pointer to next toc entry.
 */
TOC *incrementTocPtr(ARCHIVE_STATUS *status, TOC* ptoc)
{
	TOC *result = (TOC*)((char *)ptoc + ntohl(ptoc->structlen));
	if (result < status->tocbuff) {
		FATALERROR("Cannot read Table of Contents.\n");
		return status->tocend;
	}
	return result;
}
コード例 #29
0
ファイル: utils.c プロジェクト: Matt-Esch/anaconda
int get_thisfilew(LPWSTR thisfilew)
{
	if (!GetModuleFileNameW(NULL, thisfilew, _MAX_PATH)) {
		FATALERROR("System error - unable to load!");
		return -1;
	}
	
	return 0;
}
コード例 #30
0
ファイル: launch.c プロジェクト: C4rt/pyinstaller
/*
 * extract an archive entry
 * returns pointer to the data (must be freed)
 */
unsigned char *extract(TOC *ptoc)
{
	unsigned char *data;
	unsigned char *tmp;

	fseek(f_fp, f_pkgstart + ntohl(ptoc->pos), SEEK_SET);
	data = (unsigned char *)malloc(ntohl(ptoc->len));
	if (data == NULL) {
		OTHERERROR("Could not allocate read buffer\n");
		return NULL;
	}
	fread(data, ntohl(ptoc->len), 1, f_fp);
	if (ptoc->cflag == '\2') {
		PyObject *func_new;
		PyObject *aes_dict;
		PyObject *aes_obj;
		PyObject *ddata;
		long block_size;
		char *iv;

		if (!AES)
			AES = PI_PyImport_ImportModule("AES");
		aes_dict = PI_PyModule_GetDict(AES);
		func_new = PI_PyDict_GetItemString(aes_dict, "new");
		block_size = PI_PyInt_AsLong(PI_PyDict_GetItemString(aes_dict, "block_size"));
		iv = malloc(block_size);
		memset(iv, 0, block_size);

		aes_obj = PI_PyObject_CallFunction(func_new, "s#Os#",
			data, 32,
			PI_PyDict_GetItemString(aes_dict, "MODE_CFB"),
			iv, block_size);

		ddata = PI_PyObject_CallMethod(aes_obj, "decrypt", "s#", data+32, ntohl(ptoc->len)-32);
		memcpy(data, PI_PyString_AsString(ddata), ntohl(ptoc->len)-32);
		Py_DECREF(aes_obj);
		Py_DECREF(ddata);
		VS("decrypted ");
		VS(ptoc->name);
		VS("\n");
	}
	if (ptoc->cflag == '\1' || ptoc->cflag == '\2') {
#ifndef NOZLIB
		tmp = decompress(data, ptoc);
		free(data);
		data = tmp;
		if (data == NULL) {
			OTHERERROR("Error decompressing %s\n", ptoc->name);
			return NULL;
		}
#else
		FATALERROR("No ZLIB support but archive uses compression\n");
		return NULL;
#endif
	}
	return data;
}