diff --git a/Utilities/CAI/cai_dll/CMakeLists.txt b/Utilities/CAI/cai_dll/CMakeLists.txt deleted file mode 100755 index a90eb0908314c8df508ec6c67ee200b8e329cf82..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ - -SUBDIRS(src inc) - diff --git a/Utilities/CAI/cai_dll/README b/Utilities/CAI/cai_dll/README deleted file mode 100755 index 4a0b9fe13c278362440e0e2dc6860464ae2abb1d..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/README +++ /dev/null @@ -1,71 +0,0 @@ -# Version :$Header: README,v 1.5 01/01/15 15:24:06 cmf Exp $ - INSTALLATION COUCHE_ACCES_IMAGE ATLAS - ------------------------------------- -########################################################################## -# MOD : VERSION : 4.1 : DM : installation sur DEC UNIX -########################################################################## - -########################################################################## -# MOD : VERSION : 4.3 : DM : installation sur HP64Bits, pCNT, PC LINUX -########################################################################## - -La Couche Acces Image peut etre installee sur HP 32 bits et 64 bits Sun OS et SUN SOLARIS 32 bits et 64 bits, sur HP ITANIUM2 , sur DEC UNIX ainsi que PC LINUX et PC NT ainsi que station XEON EMT64 Linux Redhat - - - -Pour la generer, quatre variables d'environnement doivent etre positionnees : - - -MACHINE_ATLAS represente le type de machine sur lequel se fait l'installation - Les valeurs possibles : SOLARIS, SOLARIS64, HPUX, HPUX64, - WIN, LINUX, ITANIUM2, AIX, DEC, SUNOS - -RACINE_ATLAS indique le repertoire racine de stockage de CAI. - (exle : /home/ATALGO/regine/COUCHE_IMA_V5.2) - -RACINE_HDF indique le repertoire racine de stockage du freeware HDF - (exle : /home/ATALGO/HDF) - -########################################################################## -# MOD : VERSION : 4.0 : DM : s'affranchir du compilateur -########################################################################## -COMPILO : si cette variable n'est pas positionnee, le compilateur par defaut est - utilise : cc. - si elle est positionnee, c'est le compilateur indique qui est utilise - - -Pour generer, lancer $(RACINE_ATLAS)/ins/COUCHE_IMA.install - -Si vous ne voulez pas de bibliotheque dynamique, dans le fichier COUCHE_IMA.install, -enlever l'appel au deuxieme makefile - -Si vous n'avez pas la biblitheque HDF a votre disposition, dans le fichier -$(RACINE_ATLAS)/gen/genere.mk preciser all: CAI_NOHD - - - -Remarque : ----------- -Pour PC LINUX et PC NT et ITANIUM2 ainsi que XEON, seule la bibliotheque simple est generee - -Vérifier que la variable d'environnement $PATH est à jour de façon à pouvoir - acceder au précompilateur cpp - - - - INSTALLATION COUCHE_ACCES_IMAGE QIV SUR HP - ------------------------------------------ - -Pour generer libimage.a , deux variables d'environnement doivent etre positionnees : - - -MACHINE_ATLAS represente le type de machine sur lequel se fait l'installation - Les valeurs possibles : HPUX - - -RACINE_HDF indique le repertoire racine de stockage du freeware HDF - (exle : /home/ATALGO/HDF) - - -Pour generer : sous gen : - make -f cai_libimage.mk diff --git a/Utilities/CAI/cai_dll/cai_dll.dsp b/Utilities/CAI/cai_dll/cai_dll.dsp deleted file mode 100755 index e1be2de439e28ec113ec34aa18c17d076038b6cc..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/cai_dll.dsp +++ /dev/null @@ -1,299 +0,0 @@ -# Microsoft Developer Studio Project File - Name="cai_dll" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=cai_dll - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "cai_dll.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "cai_dll.mak" CFG="cai_dll - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "cai_dll - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "cai_dll - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "cai_dll - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CAI_DLL_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CAI_DLL_EXPORTS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x40c /d "NDEBUG" -# ADD RSC /l 0x40c /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 - -!ELSEIF "$(CFG)" == "cai_dll - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CAI_DLL_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "inc" /I "inc/inc_hdf" /I "inc/inc_unix2win" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CAI_DLL_EXPORTS" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x40c /d "_DEBUG" -# ADD RSC /l 0x40c /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 lib/hd421md.lib lib/hm421md.lib lib/libjpeg.lib lib/tiff.lib lib/unix2win.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"libcmtd.lib" /out:"Debug/cai.dll" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "cai_dll - Win32 Release" -# Name "cai_dll - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\src\cai_arcinfo.c -# End Source File -# Begin Source File - -SOURCE=.\src\cai_atg2.c -# End Source File -# Begin Source File - -SOURCE=.\src\cai_bandeau.c -# End Source File -# Begin Source File - -SOURCE=.\src\cai_bil.c -# End Source File -# Begin Source File - -SOURCE=.\src\cai_bip.c -# End Source File -# Begin Source File - -SOURCE=.\src\cai_bsq.c -# End Source File -# Begin Source File - -SOURCE=.\src\cai_DonAux.c -# End Source File -# Begin Source File - -SOURCE=.\src\cai_fonctions.c -# End Source File -# Begin Source File - -SOURCE=.\src\cai_gessimu.c -# End Source File -# Begin Source File - -SOURCE=.\src\cai_grilles.c -# End Source File -# Begin Source File - -SOURCE=.\src\cai_hdf.c -# End Source File -# Begin Source File - -SOURCE=.\src\cai_inria.c -# End Source File -# Begin Source File - -SOURCE=.\src\cai_jpeg.c -# End Source File -# Begin Source File - -SOURCE=.\src\cai_lum.c -# End Source File -# Begin Source File - -SOURCE=.\src\cai_mapsat.c -# End Source File -# Begin Source File - -SOURCE=.\src\cai_multis.c -# End Source File -# Begin Source File - -SOURCE=.\src\cai_onera.c -# End Source File -# Begin Source File - -SOURCE=.\src\cai_radar.c -# End Source File -# Begin Source File - -SOURCE=.\src\cai_rasterfile.c -# End Source File -# Begin Source File - -SOURCE=.\src\cai_spot.c -# End Source File -# Begin Source File - -SOURCE=.\src\cai_tiff.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\inc\cai_image.h -# End Source File -# Begin Source File - -SOURCE=.\inc\cderror.h -# End Source File -# Begin Source File - -SOURCE=.\inc\cdjpeg.h -# End Source File -# Begin Source File - -SOURCE=.\inc\g3states.h -# End Source File -# Begin Source File - -SOURCE=.\inc\jchuff.h -# End Source File -# Begin Source File - -SOURCE=.\inc\jconfig.h -# End Source File -# Begin Source File - -SOURCE=.\inc\jdct.h -# End Source File -# Begin Source File - -SOURCE=.\inc\jdhuff.h -# End Source File -# Begin Source File - -SOURCE=.\inc\jerror.h -# End Source File -# Begin Source File - -SOURCE=.\inc\jinclude.h -# End Source File -# Begin Source File - -SOURCE=.\inc\jmemsys.h -# End Source File -# Begin Source File - -SOURCE=.\inc\jmorecfg.h -# End Source File -# Begin Source File - -SOURCE=.\inc\jpegint.h -# End Source File -# Begin Source File - -SOURCE=.\inc\jpeglib.h -# End Source File -# Begin Source File - -SOURCE=.\inc\jversion.h -# End Source File -# Begin Source File - -SOURCE=.\inc\machdep.h -# End Source File -# Begin Source File - -SOURCE=.\inc\port.h -# End Source File -# Begin Source File - -SOURCE=.\inc\t4.h -# End Source File -# Begin Source File - -SOURCE=.\inc\tif_dir.h -# End Source File -# Begin Source File - -SOURCE=.\inc\tif_fax3.h -# End Source File -# Begin Source File - -SOURCE=.\inc\tif_predict.h -# End Source File -# Begin Source File - -SOURCE=.\inc\tiff.h -# End Source File -# Begin Source File - -SOURCE=.\inc\tiffcomp.h -# End Source File -# Begin Source File - -SOURCE=.\inc\tiffconf.h -# End Source File -# Begin Source File - -SOURCE=.\inc\tiffio.h -# End Source File -# Begin Source File - -SOURCE=.\inc\tiffiop.h -# End Source File -# Begin Source File - -SOURCE=.\inc\uvcode.h -# End Source File -# Begin Source File - -SOURCE=.\inc\version.h -# End Source File -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# End Group -# End Target -# End Project diff --git a/Utilities/CAI/cai_dll/cai_dll.dsw b/Utilities/CAI/cai_dll/cai_dll.dsw deleted file mode 100755 index d13fe7a6bbdcd83dd2bbb396af5a796d705d8a9a..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/cai_dll.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "cai_dll"=".\cai_dll.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/Utilities/CAI/cai_dll/cai_dll.ncb b/Utilities/CAI/cai_dll/cai_dll.ncb deleted file mode 100755 index 45842ab1cb5b10253660132b54f9ced67649c82d..0000000000000000000000000000000000000000 Binary files a/Utilities/CAI/cai_dll/cai_dll.ncb and /dev/null differ diff --git a/Utilities/CAI/cai_dll/cai_dll.opt b/Utilities/CAI/cai_dll/cai_dll.opt deleted file mode 100755 index 141839befae186f752518f390b3cd73e3cfad446..0000000000000000000000000000000000000000 Binary files a/Utilities/CAI/cai_dll/cai_dll.opt and /dev/null differ diff --git a/Utilities/CAI/cai_dll/cai_dll.plg b/Utilities/CAI/cai_dll/cai_dll.plg deleted file mode 100755 index 6a4ce7b0420af7a3e140abf384ffd1ffe1a71e55..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/cai_dll.plg +++ /dev/null @@ -1,16 +0,0 @@ -<html> -<body> -<pre> -<h1>Build Log</h1> -<h3> ---------------------Configuration: cai_dll - Win32 Debug-------------------- -</h3> -<h3>Command Lines</h3> - - - -<h3>Results</h3> -cai.dll - 0 error(s), 0 warning(s) -</pre> -</body> -</html> diff --git a/Utilities/CAI/cai_dll/dll/hd421md.dll b/Utilities/CAI/cai_dll/dll/hd421md.dll deleted file mode 100755 index ac89adeda270f270fa9141a1ed28c432713d43bc..0000000000000000000000000000000000000000 Binary files a/Utilities/CAI/cai_dll/dll/hd421md.dll and /dev/null differ diff --git a/Utilities/CAI/cai_dll/dll/hm421md.dll b/Utilities/CAI/cai_dll/dll/hm421md.dll deleted file mode 100755 index ffb7c04c35d423ac1fb7fba7f502a79432603e08..0000000000000000000000000000000000000000 Binary files a/Utilities/CAI/cai_dll/dll/hm421md.dll and /dev/null differ diff --git a/Utilities/CAI/cai_dll/dll/szlibdll.dll b/Utilities/CAI/cai_dll/dll/szlibdll.dll deleted file mode 100755 index 2e3d53b7fb40a148b3476bb46c0c2b7aced0a6b3..0000000000000000000000000000000000000000 Binary files a/Utilities/CAI/cai_dll/dll/szlibdll.dll and /dev/null differ diff --git a/Utilities/CAI/cai_dll/dll/tiff.dll b/Utilities/CAI/cai_dll/dll/tiff.dll deleted file mode 100755 index 5aec94192c2af88c1ce705d343066d0848a6189d..0000000000000000000000000000000000000000 Binary files a/Utilities/CAI/cai_dll/dll/tiff.dll and /dev/null differ diff --git a/Utilities/CAI/cai_dll/dll/zlib1.dll b/Utilities/CAI/cai_dll/dll/zlib1.dll deleted file mode 100755 index 4eb8adb9167b2826192b88bec87bc6c618329297..0000000000000000000000000000000000000000 Binary files a/Utilities/CAI/cai_dll/dll/zlib1.dll and /dev/null differ diff --git a/Utilities/CAI/cai_dll/inc/CMakeLists.txt b/Utilities/CAI/cai_dll/inc/CMakeLists.txt deleted file mode 100755 index 3f5eb00f910a09896e553d9ff50c9d24bf4671d2..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -# Sources of non-templated classes. - -INSTALL_FILES(/include/otb/Utilities/CAI "(\\.h)$") - -SUBDIRS( inc_unix2win ) diff --git a/Utilities/CAI/cai_dll/inc/cai_image.h b/Utilities/CAI/cai_dll/inc/cai_image.h deleted file mode 100755 index 185b17e44a8b4b502007fcefee64efe92f6eeac0..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/cai_image.h +++ /dev/null @@ -1,782 +0,0 @@ - -/* fichier include de toutes les informations necessaires au bon - fonctionnement de la bibliotheque Couche Acces Image */ - -/* MOD:VERSION:2:DM optimisation */ -/* VERSION : $Header: cai_image.h,v 1.12 01/02/15 14:24:43 cmf Exp $ */ -/* Octobre 1996 : prise en compte du format HDF pour QIV */ -/* Septembre 1999 : prise en compte du format GESSIMU */ -/* Septembre 1999 : prise en compte du format GDB et GDR */ -/* Regine CHAISEMARTIN (CISI) */ -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : DM : prototypage des fonctions */ -/*****************************************************************************/ /* MOD : VERSION : 4.3 : DM : integration des formats SPOT1a4 et SPOT5 */ -/*****************************************************************************/ -/* MOD : VERSION : 4.4 : DM : suppression du format multiscope, modif SPOT5 */ -/*****************************************************************************/ -/* MOD : VERSION : 4.6 : DM : integration du format RADAR_CNES */ -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : FA : PB de reconnaissance automatique RADAR */ -/*****************************************************************************/ -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : prise en compte de l'information INTEL ou IEEE*/ -/* et des types non signes */ -/*****************************************************************************/ -/* MOD : VERSION : 5.3 : DM : portage de la couche CAI dans plateforme */ -/* Microsof Visual C++ V6.0 */ -/*****************************************************************************/ -/* MOD : VERSION : 5.3 : DM : prise en compte du format bandeau */ -/*****************************************************************************/ - - -#ifndef CAI_IMAGE_H -#define CAI_IMAGE_H - - -#ifndef MAIN -#define WHERE extern -#else -#define WHERE -#endif - - -/* Code à ajouter si visual c++ */ -#ifdef _MSC_VER - #define _HDF16 - #ifdef CAI_DLL_EXPORTS - #define EXPORT __declspec(dllexport) - #define WHERE - #else - #define EXPORT __declspec(dllimport) - #endif - #define LIGNES_PAVE NB_LIG - #define COLONNES_PAVE NB_COL - #define F_OK 0 - #define PATH_MAX 4096 - #define strcasecmp(a,b) _stricmp(a,b) - #define ftruncate(a,b) _chsize(a,b) - #define strncasecmp(a,b,c) _strnicmp(a,b,c) - #define snprintf _snprintf -#else - #define EXPORT -#endif - - - -#ifndef IN_CAI_HDF -#define WHERE_HDF extern EXPORT -#else -#define WHERE_HDF EXPORT -#endif - -#ifndef IN_CAI_BSQ -#define WHERE_BSQ extern EXPORT -#else -#define WHERE_BSQ EXPORT -#endif - -#ifndef IN_CAI_BIP -#define WHERE_BIP extern EXPORT -#else -#define WHERE_BIP EXPORT -#endif - -#ifndef IN_CAI_INRIA -#define WHERE_INRIA extern EXPORT -#else -#define WHERE_INRIA EXPORT -#endif - -#ifndef IN_CAI_ONERA -#define WHERE_ONERA extern EXPORT -#else -#define WHERE_ONERA EXPORT -#endif - -#ifndef IN_CAI_TIFF -#define WHERE_TIFF extern EXPORT -#else -#define WHERE_TIFF EXPORT -#endif - -#ifndef IN_CAI_BIL -#define WHERE_BIL extern EXPORT -#else -#define WHERE_BIL EXPORT -#endif - -#ifndef IN_CAI_LUM -#define WHERE_LUM extern EXPORT -#else -#define WHERE_LUM EXPORT -#endif - -#ifndef IN_CAI_GESSIMU -#define WHERE_GESSIMU extern EXPORT -#else -#define WHERE_GESSIMU EXPORT -#endif - -#ifndef IN_CAI_RASTER -#define WHERE_RASTER extern EXPORT -#else -#define WHERE_RASTER EXPORT -#endif - -#ifndef IN_CAI_JPEG -#define WHERE_JPEG extern EXPORT -#else -#define WHERE_JPEG EXPORT -#endif - -#ifndef IN_CAI_GRIL -#define WHERE_GRIL extern EXPORT -#else -#define WHERE_GRIL EXPORT -#endif - -#ifndef IN_CAI_DA -#define WHERE_DA extern EXPORT -#else -#define WHERE_DA EXPORT -#endif - -#ifndef IN_CAI_FONC -#define WHERE_FONC extern EXPORT -#else -#define WHERE_FONC EXPORT -#endif - -#ifndef IN_CAI_SPOT -#define WHERE_SPOT extern EXPORT -#else -#define WHERE_SPOT EXPORT -#endif - -#ifndef IN_CAI_RADAR -#define WHERE_RADAR extern EXPORT -#else -#define WHERE_RADAR EXPORT -#endif - -#ifndef IN_CAI_BANDEAU -#define WHERE_BANDEAU extern EXPORT -#else -#define WHERE_BANDEAU EXPORT -#endif - -#include "tiffio.h" -#include "jpeglib.h" - -typedef char CAI_EXTENS[5]; -typedef char CH3[3]; -typedef char CH50[50]; - -#define CAI_NB_MAX_IMA 200 -#define CAI_NB_MAX_CAN 250 -#define CAI_SUFFIXE_DA ".aux" -#define CAI_NB_ALLOC 100 -#define CAI_TAILLE_MAX_CLEDA 70 -#define CAI_TAILLE_MAX_LIGDA 8192 -#define CAI_NB_MAX_CLE 100 -#define CAI_TAILLE_MAX_ASCII 600 -#define CAI_JPEG_LECTURE 0 -#define CAI_JPEG_ECRITURE 1 -#define CAI_JPEG_MODIFIER 2 - -/* cette taille doit etre paire et superieur a 2 fois la taille du plus - grand mot cle du fichier */ -#define CAI_TAILLE_BUFFER 8192 -/* */ - - - -/* definition de types */ - -typedef enum{CAI_LECTURE,CAI_ECRITURE} CAI_MODE_OUVERTURE; -typedef char CAI_MOT_CLE[CAI_TAILLE_MAX_CLEDA]; -typedef char CAI_CHAINE[1024]; -typedef long int CAI_TYPE; -typedef long int CAI_OK_KO; - - -typedef struct { - CAI_CHAINE nom_fichier; /* nom du fichier ouvert */ - int descr; /* file descriptor du fichier de DA */ - char *buffer; /* buffer de donnee ASCII */ - long taille_buffer; /* taille du buffer ASCII demande */ - long taille_buffer_lu; /* taille du buffer ASCII lu */ - long num_buffer; /*( -1 si non lu ou si ajout ou modif DA) */ - CAI_MOT_CLE *liste_mot_cle;/* liste des mot cle ASCII presents ds fichier*/ - long int *ad_mot_cle; /* adresse des mot cles ASCII dans le fichier */ - long int *ad_donnee; /* adr debut de donnee apres chaque mot cle */ - int nb_mot_cle; /* nombre de mot cles presents ( -1 si non alloue ou si ajout ou modif DA) */ - CAI_MOT_CLE dernier_mot_cle;/* dernier mot cle lu dans le fichier ( oper cai_caractDA ) */ - long int ad_dern_mot_cle; /* adresse du dernier mot cle ASCII lu dans le fichier - (-1 si non alloue ou ajout ou modif )*/ - long int ad_dern_donnee; /* adresse du debut de la donne apres le dernier mot cle lu */ - char REMPLI[128]; -}CAI_FILE_DA; - - -typedef struct { - char TYPE_IMAGE[20]; - char NOM_IMAGE[1024]; - char COD_PIX[5]; - int INV_OCTETS; - int NB_CANAUX; - int NB_LIG; - int NB_COL; - char COMMENT[80]; - int NB_BITS_PIX; - int NUM_LIG_DEB; - int NUM_COL_DEB; - int PAS_GRIL_LIG; - int PAS_GRIL_COL; - int DECAL_LIG; - int DECAL_COL; - char CAR_GRIL[20]; - char TYPE_COD[5]; - char NIVEAU[3]; /* Niveau de traitement de l'image (SPOT) */ - int TYPE_SPOT; /* =1 SPOT 1a4 ; =2 SPOT5 TIFF ; =3 SPOT5 BIL */ - int ACCES_SPOT[2];/* 0 pour le leader et 1 pour le volume */ - char SENS_COD[3]; - int NBOCT_PIX; - TIFF *ACCES_CANAL_TIFF[CAI_NB_MAX_CAN]; - struct jpeg_decompress_struct *ACCES_CANAL_JPEG_LEC; - struct jpeg_compress_struct *ACCES_CANAL_JPEG_ECR; - JSAMPLE *image_JPEG; - FILE *ACCES_FILE_JPEG; - int ACCES_CANAL_INT[CAI_NB_MAX_CAN]; - int POS_OCTET[CAI_NB_MAX_CAN]; - char NOM_FIC_CAN[100*CAI_NB_MAX_CAN]; - char NOM_UTIL_CAN[100*CAI_NB_MAX_CAN]; - - int COLORMAP; - int *TABCOLOR; - int HISTO[CAI_NB_MAX_CAN][256]; - int NB_PIX_ECRITS[CAI_NB_MAX_CAN]; - CAI_MODE_OUVERTURE MODE; -}CAI_IMAGE; - - -#ifdef _CAI_IMAGE - -#ifdef _HDF16 - -#define CAI_NB_FORMAT 18 -#define CAI_NB_EXTENSIONS 18 - -static long int CAI_NUMEROS[CAI_NB_EXTENSIONS]= - { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17}; -static char *CAI_SUFFIXES[CAI_NB_EXTENSIONS]= - { ".xs",".inf",".hd",".bil",".tif",".srf",".bip",".hdf",".lum", - ".jpg",".pfe",".gdb",".gdr"," "," "," ",".rad",".band"}; - -static char *CAI_NOM_FORMAT[CAI_NB_FORMAT]= -{"INRIA","ONERA","BSQ","BIL","TIFF","RASTERFILE","BIP","HDF","LUM","JPEG","GESSIMU","GDB","GDR","SPOT1A4","SPOT5TIF","SPOT5BIL","RADAR","BANDEAU"}; - - - -/* include necessaire pour le bon fonctionnement des fonctions d'acces des - donnees auxiliaires */ - -static char * CAI_SUF_FORMAT[2][CAI_NB_FORMAT]= - {{ ".xs",".inf",".hd",".bil",".tif",".srf",".bip",".hdf",".lum", - ".jpg",".pfe",".gdb",".gdr"," "," "," ",".rad",".band"}, - { ".xs",".inf",".hd",".bil",".tif",".srf",".bip",".hdf",".lum", - ".jpg",".pfe",".gdb",".gdr"," "," "," ",".rad",".band"}}; - -WHERE_HDF long int cai_liste_ima_hdf16(char *repert,char ***tab_ima); -WHERE_HDF CAI_OK_KO cai_dest_ima_hdf16(char *repertoire,char *nom_ima); -WHERE_HDF CAI_IMAGE *cai_ouvre_lecture_hdf16(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig); -WHERE_HDF CAI_IMAGE *cai_ouvre_modifie_hdf16(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig); -WHERE_HDF CAI_OK_KO cai_ferme_hdf16(CAI_IMAGE *image1); -WHERE_HDF CAI_IMAGE *cai_ouvre_creation_hdf16(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig, - char* label); -WHERE_HDF CAI_OK_KO cai_ecriture_canal_hdf16(CAI_IMAGE *image1, int *canal, - int *premiere_ligne, int *nombre_lignes_ecrire, - int *nombre_colonnes_ecrire,unsigned char *data_image); -WHERE_HDF CAI_OK_KO cai_lecture_canal_hdf16(CAI_IMAGE *image1, int *canal, - int *premiere_ligne, int *premiere_colonne, - int *nombre_lignes_lire, int *nombre_colonnes_lire, - int *pas_lig, int *pas_col,unsigned char *data); -WHERE_HDF CAI_OK_KO cai_rename_fichiers_hdf16(CAI_IMAGE *image1, - CAI_EXTENS *TabExtens); - -#endif - -#ifdef _NOHDF16 -#define CAI_NB_FORMAT 17 -#define CAI_NB_EXTENSIONS 17 - -static long int CAI_NUMEROS[CAI_NB_EXTENSIONS]= - { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}; -static char *CAI_SUFFIXES[CAI_NB_EXTENSIONS]= - { ".xs",".inf",".hd",".bil",".tif",".srf",".bip",".lum",".jpg",".pfe",".gdb",".gdr"," "," ",",",".rad",".band"}; - -static char *CAI_NOM_FORMAT[CAI_NB_FORMAT]= -{"INRIA","ONERA","BSQ","BIL","TIFF","RASTERFILE","BIP","LUM","JPEG","GESSIMU","GDB","GDR","SPOT1A4","SPOT5TIF","SPOT5BIL","RADAR","BANDEAU"}; - - -/* include necessaire pour le bon fonctionnement des fonctions d'acces des - donnees auxiliaires */ - -static char * CAI_SUF_FORMAT[2][CAI_NB_FORMAT]= - {{ ".xs",".inf",".hd",".bil",".tif",".srf",".bip",".lum", - ".jpg",".pfe",".gdb",".gdr"," "," "," ",".rad",".band"}, - { ".xs",".inf",".hd",".bil",".tif",".srf",".bip",".lum", - ".jpg",".pfe",".gdb",".gdr"," "," "," ",".rad",".band"}}; - -#endif - -WHERE_BSQ long int cai_liste_ima_bsq(char *repert,char ***tab_ima); -WHERE_BSQ CAI_OK_KO cai_dest_ima_bsq(char *repertoire,char *nom_ima); -WHERE_BSQ CAI_IMAGE *cai_ouvre_lecture_bsq(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig); -WHERE_BSQ CAI_IMAGE *cai_ouvre_modifie_bsq(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig); -WHERE_BSQ CAI_OK_KO cai_ferme_bsq(CAI_IMAGE *image1); -WHERE_BSQ CAI_IMAGE *cai_ouvre_creation_bsq(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig, - char* label); -WHERE_BSQ CAI_OK_KO cai_ecriture_canal_bsq(CAI_IMAGE *image1, int *canal, - int *premiere_ligne, int *nombre_lignes_ecrire, - int *nombre_colonnes_ecrire,unsigned char *data_image); -WHERE_BSQ CAI_OK_KO cai_lecture_canal_bsq(CAI_IMAGE *image1, int *canal, - int *premiere_ligne, int *premiere_colonne, - int *nombre_lignes_lire, int *nombre_colonnes_lire, - int *pas_lig, int *pas_col,unsigned char *data); -WHERE_BSQ CAI_OK_KO cai_modif_nbbitspix_bsq(CAI_IMAGE *image1, - int NbBitsPix); - - -WHERE_BIP long int cai_liste_ima_bip(char *repert,char ***tab_ima); -WHERE_BIP CAI_OK_KO cai_dest_ima_bip(char *repertoire,char *nom_ima); -WHERE_BIP CAI_IMAGE *cai_ouvre_lecture_bip(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig); -WHERE_BIP CAI_IMAGE *cai_ouvre_modifie_bip(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig); -WHERE_BIP CAI_OK_KO cai_ferme_bip(CAI_IMAGE *image1); -WHERE_BIP CAI_IMAGE *cai_ouvre_creation_bip(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig, - char* label); -WHERE_BIP CAI_OK_KO cai_ecriture_canal_bip(CAI_IMAGE *image1, int *canal, - int *premiere_ligne, int *nombre_lignes_ecrire, - int *nombre_colonnes_ecrire,unsigned char *data_image); -WHERE_BIP CAI_OK_KO cai_lecture_canal_bip(CAI_IMAGE *image1, int *canal, - int *premiere_ligne, int *premiere_colonne, - int *nombre_lignes_lire, int *nombre_colonnes_lire, - int *pas_lig, int *pas_col,unsigned char *data); -WHERE_BIP CAI_OK_KO cai_modif_nbbitspix_bip(CAI_IMAGE *image1, - int NbBitsPix); - -WHERE_INRIA long int cai_liste_ima_inria(char *repert,char ***tab_ima); -WHERE_INRIA CAI_OK_KO cai_dest_ima_inria(char *repertoire,char *nom_ima); -WHERE_INRIA CAI_IMAGE *cai_ouvre_lecture_inria(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig); -WHERE_INRIA CAI_IMAGE *cai_ouvre_modifie_inria(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig); -WHERE_INRIA CAI_OK_KO cai_ferme_inria(CAI_IMAGE *image1); -WHERE_INRIA CAI_IMAGE *cai_ouvre_creation_inria(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig, - char* label); -WHERE_INRIA CAI_OK_KO cai_ecriture_canal_inria(CAI_IMAGE *image1, int *canal, - int *premiere_ligne, int *nombre_lignes_ecrire, - int *nombre_colonnes_ecrire,unsigned char *data_image); -WHERE_INRIA CAI_OK_KO cai_lecture_canal_inria(CAI_IMAGE *image1, int *canal, - int *premiere_ligne, int *premiere_colonne, - int *nombre_lignes_lire, int *nombre_colonnes_lire, - int *pas_lig, int *pas_col,unsigned char *data); - - -WHERE_ONERA long int cai_liste_ima_onera(char *repert,char ***tab_ima); -WHERE_ONERA CAI_OK_KO cai_dest_ima_onera(char *repertoire,char *nom_ima); -WHERE_ONERA CAI_IMAGE *cai_ouvre_lecture_onera(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig); -WHERE_ONERA CAI_IMAGE *cai_ouvre_modifie_onera(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig); -WHERE_ONERA CAI_OK_KO cai_ferme_onera(CAI_IMAGE *image1); -WHERE_ONERA CAI_IMAGE *cai_ouvre_creation_onera(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig, - char* label); -WHERE_ONERA CAI_OK_KO cai_ecriture_canal_onera(CAI_IMAGE *image1, int *canal, - int *premiere_ligne, int *nombre_lignes_ecrire, - int *nombre_colonnes_ecrire,unsigned char *data_image); -WHERE_ONERA CAI_OK_KO cai_lecture_canal_onera(CAI_IMAGE *image1, int *canal, - int *premiere_ligne, int *premiere_colonne, - int *nombre_lignes_lire, int *nombre_colonnes_lire, - int *pas_lig, int *pas_col,unsigned char *data); - - -WHERE_TIFF long int cai_liste_ima_tiff(char *repert,char ***tab_ima); -WHERE_TIFF CAI_OK_KO cai_dest_ima_tiff(char *repertoire,char *nom_ima); -WHERE_TIFF CAI_IMAGE *cai_ouvre_lecture_tiff(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig); -WHERE_TIFF CAI_IMAGE *cai_ouvre_modifie_tiff(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig); -WHERE_TIFF CAI_OK_KO cai_ferme_tiff(CAI_IMAGE *image1); -WHERE_TIFF CAI_IMAGE *cai_ouvre_creation_tiff(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig, - char* label); -WHERE_TIFF CAI_OK_KO cai_ecriture_canal_tiff(CAI_IMAGE *image1, int *canal, - int *premiere_ligne, int *nombre_lignes_ecrire, - int *nombre_colonnes_ecrire,unsigned char *data_image); -WHERE_TIFF CAI_OK_KO cai_lecture_canal_tiff(CAI_IMAGE *image1, int *canal, - int *premiere_ligne, int *premiere_colonne, - int *nombre_lignes_lire, int *nombre_colonnes_lire, - int *pas_lig, int *pas_col,unsigned char *data); - -WHERE_BIL long int cai_liste_ima_bil(char *repert,char ***tab_ima); -WHERE_BIL CAI_OK_KO cai_dest_ima_bil(char *repertoire,char *nom_ima); -WHERE_BIL CAI_IMAGE *cai_ouvre_lecture_bil(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig); -WHERE_BIL CAI_IMAGE *cai_ouvre_modifie_bil(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig); -WHERE_BIL CAI_OK_KO cai_ferme_bil(CAI_IMAGE *image1); -WHERE_BIL CAI_IMAGE *cai_ouvre_creation_bil(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig, - char* label); -WHERE_BIL CAI_OK_KO cai_ecriture_canal_bil(CAI_IMAGE *image1, int *canal, - int *premiere_ligne, int *nombre_lignes_ecrire, - int *nombre_colonnes_ecrire,unsigned char *data_image); -WHERE_BIL CAI_OK_KO cai_lecture_canal_bil(CAI_IMAGE *image1, int *canal, - int *premiere_ligne, int *premiere_colonne, - int *nombre_lignes_lire, int *nombre_colonnes_lire, - int *pas_lig, int *pas_col,unsigned char *data); -WHERE_BIL CAI_OK_KO cai_modif_nbbitspix_bil(CAI_IMAGE *image1, - int NbBitsPix); - - -WHERE_LUM long int cai_liste_ima_lum(char *repert,char ***tab_ima); -WHERE_LUM CAI_OK_KO cai_dest_ima_lum(char *repertoire,char *nom_ima); -WHERE_LUM CAI_IMAGE *cai_ouvre_lecture_lum(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig); -WHERE_LUM CAI_IMAGE *cai_ouvre_modifie_lum(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig); -WHERE_LUM CAI_OK_KO cai_ferme_lum(CAI_IMAGE *image1); -WHERE_LUM CAI_IMAGE *cai_ouvre_creation_lum(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig, - char* label); -WHERE_LUM CAI_OK_KO cai_ecriture_canal_lum(CAI_IMAGE *image1, int *canal, - int *premiere_ligne, int *nombre_lignes_ecrire, - int *nombre_colonnes_ecrire,unsigned char *data_image); -WHERE_LUM CAI_OK_KO cai_lecture_canal_lum(CAI_IMAGE *image1, int *canal, - int *premiere_ligne, int *premiere_colonne, - int *nombre_lignes_lire, int *nombre_colonnes_lire, - int *pas_lig, int *pas_col,unsigned char *data); - - -WHERE_RASTER long int cai_liste_ima_sun_raster(char *repert,char ***tab_ima); -WHERE_RASTER CAI_OK_KO cai_dest_ima_sun_raster(char *repertoire,char *nom_ima); -WHERE_RASTER CAI_IMAGE *cai_ouvre_lecture_sun_raster(char *repert, - char *nom_image,int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig); -WHERE_RASTER CAI_IMAGE *cai_ouvre_modifie_sun_raster(char *repert, - char *nom_image, int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig); -WHERE_RASTER CAI_OK_KO cai_ferme_sun_raster(CAI_IMAGE *image1); -WHERE_RASTER CAI_IMAGE *cai_ouvre_creation_sun_raster(char *repert, - char *nom_image, int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig, char* label); -WHERE_RASTER CAI_OK_KO cai_ecriture_canal_sun_raster(CAI_IMAGE *image1, - int *canal, int *premiere_ligne, int *nombre_lignes_ecrire, - int *nombre_colonnes_ecrire,unsigned char *data_image); -WHERE_RASTER CAI_OK_KO cai_lecture_canal_sun_raster(CAI_IMAGE *image1, - int *canal,int *premiere_ligne, int *premiere_colonne, - int *nombre_lignes_lire, int *nombre_colonnes_lire, - int *pas_lig, int *pas_col,unsigned char *data); - - -WHERE_JPEG long int cai_liste_ima_jpeg(char *repert,char ***tab_ima); -WHERE_JPEG CAI_OK_KO cai_dest_ima_jpeg(char *repertoire,char *nom_ima); -WHERE_JPEG CAI_IMAGE *cai_ouvre_lecture_jpeg(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig); -WHERE_JPEG CAI_IMAGE *cai_ouvre_modifie_jpeg(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig); -WHERE_JPEG CAI_OK_KO cai_ferme_jpeg(CAI_IMAGE *image1); -WHERE_JPEG CAI_IMAGE *cai_ouvre_creation_jpeg(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig, - char* label); -WHERE_JPEG CAI_OK_KO cai_ecriture_canal_jpeg(CAI_IMAGE *image1, int *canal, - int *premiere_ligne, int *nombre_lignes_ecrire, - int *nombre_colonnes_ecrire,unsigned char *data_image); -WHERE_JPEG CAI_OK_KO cai_lecture_canal_jpeg(CAI_IMAGE *image1, int *canal, - int *premiere_ligne, int *premiere_colonne, - int *nombre_lignes_lire, int *nombre_colonnes_lire, - int *pas_lig, int *pas_col,unsigned char *data); - - -WHERE_GESSIMU long int cai_liste_ima_gessimu(char *repert,char ***tab_ima); -WHERE_GESSIMU CAI_OK_KO cai_dest_ima_gessimu(char *repertoire,char *nom_ima); -WHERE_GESSIMU CAI_IMAGE *cai_ouvre_lecture_gessimu(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig); -WHERE_GESSIMU CAI_IMAGE *cai_ouvre_modifie_gessimu(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig); -WHERE_GESSIMU CAI_OK_KO cai_ferme_gessimu(CAI_IMAGE *image1); -WHERE_GESSIMU CAI_IMAGE *cai_ouvre_creation_gessimu(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig, - char* label); -WHERE_GESSIMU CAI_OK_KO cai_ecriture_canal_gessimu(CAI_IMAGE *image1, int *canal, - int *premiere_ligne, int *nombre_lignes_ecrire, - int *nombre_colonnes_ecrire,unsigned char *data_image); -WHERE_GESSIMU CAI_OK_KO cai_lecture_canal_gessimu(CAI_IMAGE *image1, int *canal, - int *premiere_ligne, int *premiere_colonne, - int *nombre_lignes_lire, int *nombre_colonnes_lire, - int *pas_lig, int *pas_col,unsigned char *data); - - -WHERE_GRIL long int cai_liste_ima_grilles(char typgrille,char *repert, - char ***tab_ima); -WHERE_GRIL CAI_OK_KO cai_dest_ima_grilles(char typgrille,char *repertoire, - char *nom_ima); -WHERE_GRIL CAI_IMAGE *cai_ouvre_lecture_grilles(char typgrille,char *repert, - char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig); -WHERE_GRIL CAI_IMAGE *cai_ouvre_modifie_grilles(char typgrille,char *repert, - char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig); -WHERE_GRIL CAI_OK_KO cai_ferme_grilles(char typgrille,CAI_IMAGE *image1); -WHERE_GRIL CAI_IMAGE *cai_ouvre_creation_grilles(char typgrille, - char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig, - char* label); -WHERE_GRIL CAI_OK_KO cai_ecriture_canal_grilles(CAI_IMAGE *image1, int *canal, - int *premiere_ligne, int *nombre_lignes_ecrire, - int *nombre_colonnes_ecrire,unsigned char *data_image); -WHERE_GRIL CAI_OK_KO cai_lecture_canal_grilles(CAI_IMAGE *image1, int *canal, - int *premiere_ligne, int *premiere_colonne, - int *nombre_lignes_lire, int *nombre_colonnes_lire, - int *pas_lig, int *pas_col,unsigned char *data); -WHERE_GRIL CAI_OK_KO cai_modif_nbbitspix_grilles(CAI_IMAGE *image1, - int NbBitsPix); - -WHERE_SPOT long int cai_liste_ima_spot(char typspot,char *repert, - char ***tab_ima); -WHERE_SPOT CAI_OK_KO cai_dest_ima_spot(char typspot,char *repertoire, - char *nom_ima); -WHERE_SPOT CAI_IMAGE *cai_ouvre_lecture_spot(char typspot,char *repert, - char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig); -WHERE_SPOT CAI_IMAGE *cai_ouvre_modifie_spot(char typspot,char *repert, - char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig); -WHERE_SPOT CAI_OK_KO cai_ferme_spot(char typspot,CAI_IMAGE *image1); -WHERE_SPOT CAI_IMAGE *cai_ouvre_creation_spot(char typspot, - char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig, - char* label); -WHERE_SPOT CAI_OK_KO cai_ecriture_canal_spot(CAI_IMAGE *image1, int *canal, - int *premiere_ligne, int *nombre_lignes_ecrire, - int *nombre_colonnes_ecrire,unsigned char *data_image); -WHERE_SPOT CAI_OK_KO cai_lecture_canal_spot(CAI_IMAGE *image1, int *canal, - int *premiere_ligne, int *premiere_colonne, - int *nombre_lignes_lire, int *nombre_colonnes_lire, - int *pas_lig, int *pas_col,unsigned char *data); -WHERE_SPOT CAI_OK_KO cai_creat_leader_spot5( CAI_IMAGE *desc_im , - char *repertoire); - - -WHERE_RADAR long int cai_liste_ima_radar(char *repert,char ***tab_ima); -WHERE_RADAR CAI_OK_KO cai_dest_ima_radar(char *repertoire,char *nom_ima); -WHERE_RADAR CAI_IMAGE *cai_ouvre_lecture_radar(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig); -WHERE_RADAR CAI_IMAGE *cai_ouvre_modifie_radar(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig); -WHERE_RADAR CAI_OK_KO cai_ferme_radar(CAI_IMAGE *image1); -WHERE_RADAR CAI_IMAGE *cai_ouvre_creation_radar(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig, - char* label); -WHERE_RADAR CAI_OK_KO cai_ecriture_canal_radar(CAI_IMAGE *image1, int *canal, - int *premiere_ligne, int *nombre_lignes_ecrire, - int *nombre_colonnes_ecrire,unsigned char *data_image); -WHERE_RADAR CAI_OK_KO cai_lecture_canal_radar(CAI_IMAGE *image1, int *canal, - int *premiere_ligne, int *premiere_colonne, - int *nombre_lignes_lire, int *nombre_colonnes_lire, - int *pas_lig, int *pas_col,unsigned char *data); - -WHERE_RADAR int cai_istyp_radar(char *type_code,int *ind_typ, int *is_Cplx); - -WHERE_BANDEAU long int cai_liste_ima_bandeau(char *repert,char ***tab_ima); -WHERE_BANDEAU CAI_OK_KO cai_dest_ima_bandeau(char *repertoire,char *nom_ima); -WHERE_BANDEAU CAI_IMAGE *cai_ouvre_lecture_bandeau(char *repert,char *nom_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig); -WHERE_BANDEAU CAI_OK_KO cai_ferme_bandeau(CAI_IMAGE *image1); -WHERE_BANDEAU CAI_OK_KO cai_lecture_canal_bandeau(CAI_IMAGE *image1, int *canal, - int *premiere_ligne, int *premiere_colonne, - int *nombre_lignes_lire, int *nombre_colonnes_lire, - int *pas_lig, int *pas_col,unsigned char *data); -#endif - -#define CAI_MAX_LG_FORMAT 20 -#define CAI_MAX_LG_IMAGE 1024 - -#define PERMS 0666 -#define CAI_NB_RADAR 28 -#define CAI_NB_TYPE 8 -#define CAI_NB_LUM 8 - -WHERE char CAI_ERREUR[1024]; -WHERE CAI_IMAGE *FBANDEAU[20]; - -static int CAI_RADAR_LONG[CAI_NB_RADAR]= -{1,1,2,2,4,4,8,1,1,1,1,1,1,1,1,2,4,8,8,16,2,2,2,2,2,2,2,2}; -static char *CAI_RADAR_TYP[CAI_NB_RADAR]= -{"OCT","PHA","I2","UI2","I4","R4","R8","1B","2B","3B","4B","5B","6B","7B","8B", -"COCT","CI2","CI4","CR4","CR8","C1B","C2B","C3B","C4B","C5B", -"C6B","C7B","C8B"}; -static char *CAI_TYPE_CONNU[CAI_NB_TYPE]= - {"OCT","UOCT","I2","UI2","I4","UI4","R4","R8"}; -static char *CAI_LUM_TYP[CAI_NB_LUM]= - {"BI","LI","BU","LU","FLOA","FLOL","R8B","R8L"}; - -#define CAI_OK 0 -#define CAI_KO 1 -#define CAI_IMPOS 2 -#define CAI_EOF -1 -#define CAI_ERREUR_OUV -2 -#define CAI_PB_LSEEK -3 -#define CAI_DEB_NEG -4 -#define CAI_FIN_DEP -5 -#define CAI_ECRASEMENT -6 -#define CAI_PB_READ -7 -#define CAI_PB_WRITE -8 -#define CAI_PB_FTRUNC -9 -#define CAI_ERR_FORME_FIC -10 -#define CAI_ERR_DO -11 -#define CAI_ERR_TYP -12 -#define CAI_ERR_FIN_DO -13 -#define CAI_ERR_ASCII -14 -#define CAI_ERR_ALLOC -15 -#define CAI_ERR_REEL -16 -#define CAI_ERR_ENTIER -17 -#define CAI_ERR_DIM -18 -#define CAI_ERREUR_RECHERCHE_MOT -19 -#define CAI_MOT_DEJA_EXISTE -20 -#define CAI_ERREUR_ENCODE -21 -#define CAI_ERR_ADRESSE -22 -#define CAI_CLE_TROP_LONG -23 -#define CAI_MC_INCONNU -24 -#define CAI_PAS_MC -24 -#define CAI_ERR_CROCHET -25 -#define CAI_TROUVE -26 -#define CAI_NON_TROUVE -27 - - -/* constantes relatives aux types de donnees */ -#define CAI_INCONNU -1 -#define CAI_ENTIER4 1 -#define CAI_REEL4 2 -#define CAI_REEL8 3 -#define CAI_ASCII 4 -#define CAI_BLOC 5 - - -/* prototype des fonctions */ - -WHERE_DA CAI_FILE_DA * cai_openDA(char *nom_fichier, char *type_image, - int nb_can,CAI_MODE_OUVERTURE mode_ouv); -WHERE_DA CAI_OK_KO cai_closeDA(CAI_FILE_DA *fd); -WHERE_DA CAI_OK_KO cai_removeDA(char *nom_fichier,char *type_image,int nb_can); -WHERE_DA CAI_OK_KO cai_lirecaractDA(CAI_FILE_DA *fd,char *mot_cle, - CAI_TYPE *type,int *nb_lig,int *nb_col, - long *taille_cell); -WHERE_DA CAI_OK_KO cai_lireDA(CAI_FILE_DA *fd,char *mot_cle, - CAI_TYPE *type,int *nb_lig,int *nb_col, - long *taille_cell,void *donnees); -WHERE_DA CAI_OK_KO cai_modifieDA(CAI_FILE_DA *fd,char *mot_cle, - CAI_TYPE type,int nb_lig,int nb_col, - long taille_cell,void *donnees); -WHERE_DA CAI_OK_KO cai_detruitDA(CAI_FILE_DA *fd,char *mot_cle); -WHERE_DA CAI_OK_KO cai_listeDA(CAI_FILE_DA *fd); -WHERE_DA CAI_OK_KO cai_ajouteDA(CAI_FILE_DA *fd,char *mot_cle, - CAI_TYPE type,int nb_lig,int nb_col, - long taille_cell,void *donnees); -WHERE_DA CAI_OK_KO cai_lecture_colormap(CAI_IMAGE *fdima); -WHERE_DA CAI_OK_KO cai_ecriture_colormap(CAI_IMAGE *fdima); - - -WHERE_FONC long int cai_liste_image(char *repert,char *type_image, - char ***tab_ima); -WHERE_FONC long int cai_liste_format(char ***tab_format, - char **(tab_suffixe[2])); -WHERE_FONC CAI_OK_KO cai_destruction_image(char *format,char *nom_ima); -WHERE_FONC CAI_IMAGE *cai_ouvre_lecture_image(char *nom_image,char *type_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig); -WHERE_FONC CAI_IMAGE *cai_ouvre_modifie_image(char *nom_image,char *type_image, - int *nb_can, int *nboct_pix, - int *nb_col, int *nb_lig); -WHERE_FONC CAI_OK_KO cai_ferme_image(CAI_IMAGE *image1); -WHERE_FONC CAI_IMAGE *cai_ouvre_creation_image(char *nom_image,char *type_image, - int nb_can, int nboct_pix, - int nb_col, int nb_lig, - char* label); -WHERE_FONC CAI_OK_KO cai_ecriture_canal(CAI_IMAGE *image1, int canal, - int premiere_ligne, int nombre_lignes_ecrire, - int nombre_colonnes_ecrire,unsigned char *data_image); -WHERE_FONC CAI_OK_KO cai_lecture_canal(CAI_IMAGE *image1, int canal, - int premiere_ligne, int premiere_colonne, - int nombre_lignes_lire, int nombre_colonnes_lire, - int pas_lig, int pas_col,unsigned char *data); -WHERE_FONC CAI_OK_KO cai_modif_nbbitspix(char *format,CAI_IMAGE *image, - int NbBitsPix); - -WHERE_FONC CAI_OK_KO cai_modif_nbbitspix(char *format,CAI_IMAGE *image, - int NbBitsPix); -WHERE_FONC void cai_inverser_tableau(short *BufL,short *BufE,int Nb); -WHERE_FONC void cai_inverser_tableau_complet(unsigned char *data_image, - int nbpix, int oct_pix); -WHERE_FONC char* cai_test_pFpf(); -WHERE_FONC char* cai_En_majuscule( char *mot ); -WHERE_FONC char* cai_En_minuscule( char *mot ); -WHERE_FONC int cai_istyp_connu(char *type_code); -WHERE_FONC CAI_OK_KO cai_lead4to5spot ( CAI_IMAGE *desc_im ,char *repertoire); - -#endif -#ifndef _WIN -#define O_BINARY 0 -#endif diff --git a/Utilities/CAI/cai_dll/inc/cderror.h b/Utilities/CAI/cai_dll/inc/cderror.h deleted file mode 100755 index 41a29cd12f9aa31b226eb8849f7751c5ce87cd8f..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/cderror.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * cderror.h - * - * Copyright (C) 1994, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file defines the error and message codes for the cjpeg/djpeg - * applications. These strings are not needed as part of the JPEG library - * proper. - * Edit this file to add new codes, or to translate the message strings to - * some other language. - */ - -/* - * To define the enum list of message codes, include this file without - * defining macro JMESSAGE. To create a message string table, include it - * again with a suitable JMESSAGE definition (see jerror.c for an example). - */ -#ifndef JMESSAGE -#ifndef CDERROR_H -#define CDERROR_H -/* First time through, define the enum list */ -#define JMAKE_ENUM_LIST -#else -/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */ -#define JMESSAGE(code,string) -#endif /* CDERROR_H */ -#endif /* JMESSAGE */ - -#ifdef JMAKE_ENUM_LIST - -typedef enum { - -#define JMESSAGE(code,string) code , - -#endif /* JMAKE_ENUM_LIST */ - -JMESSAGE(JMSG_FIRSTADDONCODE=1000, NULL) /* Must be first entry! */ - -#ifdef BMP_SUPPORTED -JMESSAGE(JERR_BMP_BADCMAP, "Unsupported BMP colormap format") -JMESSAGE(JERR_BMP_BADDEPTH, "Only 8- and 24-bit BMP files are supported") -JMESSAGE(JERR_BMP_BADHEADER, "Invalid BMP file: bad header length") -JMESSAGE(JERR_BMP_BADPLANES, "Invalid BMP file: biPlanes not equal to 1") -JMESSAGE(JERR_BMP_COLORSPACE, "BMP output must be grayscale or RGB") -JMESSAGE(JERR_BMP_COMPRESSED, "Sorry, compressed BMPs not yet supported") -JMESSAGE(JERR_BMP_NOT, "Not a BMP file - does not start with BM") -JMESSAGE(JTRC_BMP, "%ux%u 24-bit BMP image") -JMESSAGE(JTRC_BMP_MAPPED, "%ux%u 8-bit colormapped BMP image") -JMESSAGE(JTRC_BMP_OS2, "%ux%u 24-bit OS2 BMP image") -JMESSAGE(JTRC_BMP_OS2_MAPPED, "%ux%u 8-bit colormapped OS2 BMP image") -#endif /* BMP_SUPPORTED */ - -#ifdef GIF_SUPPORTED -JMESSAGE(JERR_GIF_BUG, "GIF output got confused") -JMESSAGE(JERR_GIF_CODESIZE, "Bogus GIF codesize %d") -JMESSAGE(JERR_GIF_COLORSPACE, "GIF output must be grayscale or RGB") -JMESSAGE(JERR_GIF_IMAGENOTFOUND, "Too few images in GIF file") -JMESSAGE(JERR_GIF_NOT, "Not a GIF file") -JMESSAGE(JTRC_GIF, "%ux%ux%d GIF image") -JMESSAGE(JTRC_GIF_BADVERSION, - "Warning: unexpected GIF version number '%c%c%c'") -JMESSAGE(JTRC_GIF_EXTENSION, "Ignoring GIF extension block of type 0x%02x") -JMESSAGE(JTRC_GIF_NONSQUARE, "Caution: nonsquare pixels in input") -JMESSAGE(JWRN_GIF_BADDATA, "Corrupt data in GIF file") -JMESSAGE(JWRN_GIF_CHAR, "Bogus char 0x%02x in GIF file, ignoring") -JMESSAGE(JWRN_GIF_ENDCODE, "Premature end of GIF image") -JMESSAGE(JWRN_GIF_NOMOREDATA, "Ran out of GIF bits") -#endif /* GIF_SUPPORTED */ - -#ifdef PPM_SUPPORTED -JMESSAGE(JERR_PPM_COLORSPACE, "PPM output must be grayscale or RGB") -JMESSAGE(JERR_PPM_NONNUMERIC, "Nonnumeric data in PPM file") -JMESSAGE(JERR_PPM_NOT, "Not a PPM file") -JMESSAGE(JTRC_PGM, "%ux%u PGM image") -JMESSAGE(JTRC_PGM_TEXT, "%ux%u text PGM image") -JMESSAGE(JTRC_PPM, "%ux%u PPM image") -JMESSAGE(JTRC_PPM_TEXT, "%ux%u text PPM image") -#endif /* PPM_SUPPORTED */ - -#ifdef RLE_SUPPORTED -JMESSAGE(JERR_RLE_BADERROR, "Bogus error code from RLE library") -JMESSAGE(JERR_RLE_COLORSPACE, "RLE output must be grayscale or RGB") -JMESSAGE(JERR_RLE_DIMENSIONS, "Image dimensions (%ux%u) too large for RLE") -JMESSAGE(JERR_RLE_EMPTY, "Empty RLE file") -JMESSAGE(JERR_RLE_EOF, "Premature EOF in RLE header") -JMESSAGE(JERR_RLE_MEM, "Insufficient memory for RLE header") -JMESSAGE(JERR_RLE_NOT, "Not an RLE file") -JMESSAGE(JERR_RLE_TOOMANYCHANNELS, "Cannot handle %d output channels for RLE") -JMESSAGE(JERR_RLE_UNSUPPORTED, "Cannot handle this RLE setup") -JMESSAGE(JTRC_RLE, "%ux%u full-color RLE file") -JMESSAGE(JTRC_RLE_FULLMAP, "%ux%u full-color RLE file with map of length %d") -JMESSAGE(JTRC_RLE_GRAY, "%ux%u grayscale RLE file") -JMESSAGE(JTRC_RLE_MAPGRAY, "%ux%u grayscale RLE file with map of length %d") -JMESSAGE(JTRC_RLE_MAPPED, "%ux%u colormapped RLE file with map of length %d") -#endif /* RLE_SUPPORTED */ - -#ifdef TARGA_SUPPORTED -JMESSAGE(JERR_TGA_BADCMAP, "Unsupported Targa colormap format") -JMESSAGE(JERR_TGA_BADPARMS, "Invalid or unsupported Targa file") -JMESSAGE(JERR_TGA_COLORSPACE, "Targa output must be grayscale or RGB") -JMESSAGE(JTRC_TGA, "%ux%u RGB Targa image") -JMESSAGE(JTRC_TGA_GRAY, "%ux%u grayscale Targa image") -JMESSAGE(JTRC_TGA_MAPPED, "%ux%u colormapped Targa image") -#else -JMESSAGE(JERR_TGA_NOTCOMP, "Targa support was not compiled") -#endif /* TARGA_SUPPORTED */ - -JMESSAGE(JERR_BAD_CMAP_FILE, - "Color map file is invalid or of unsupported format") -JMESSAGE(JERR_TOO_MANY_COLORS, - "Output file format cannot handle %d colormap entries") -JMESSAGE(JERR_UNGETC_FAILED, "ungetc failed") -#ifdef TARGA_SUPPORTED -JMESSAGE(JERR_UNKNOWN_FORMAT, - "Unrecognized input file format --- perhaps you need -targa") -#else -JMESSAGE(JERR_UNKNOWN_FORMAT, "Unrecognized input file format") -#endif -JMESSAGE(JERR_UNSUPPORTED_FORMAT, "Unsupported output file format") - -#ifdef JMAKE_ENUM_LIST - - JMSG_LASTADDONCODE -} ADDON_MESSAGE_CODE; - -#undef JMAKE_ENUM_LIST -#endif /* JMAKE_ENUM_LIST */ - -/* Zap JMESSAGE macro so that future re-inclusions do nothing by default */ -#undef JMESSAGE diff --git a/Utilities/CAI/cai_dll/inc/cdjpeg.h b/Utilities/CAI/cai_dll/inc/cdjpeg.h deleted file mode 100755 index cc0d60016a470229b813ac210c2c6a2ef9844118..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/cdjpeg.h +++ /dev/null @@ -1,179 +0,0 @@ -/* - * cdjpeg.h - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains common declarations for the sample applications - * cjpeg and djpeg. It is NOT used by the core JPEG library. - */ - -#define JPEG_CJPEG_DJPEG /* define proper options in jconfig.h */ -#define JPEG_INTERNAL_OPTIONS /* cjpeg.c,djpeg.c need to see xxx_SUPPORTED */ -#include "jinclude.h" -#include "jpeglib.h" -#include "jerror.h" /* get library error codes too */ -#include "cderror.h" /* get application-specific error codes */ - - -/* - * Object interface for cjpeg's source file decoding modules - */ - -typedef struct cjpeg_source_struct * cjpeg_source_ptr; - -struct cjpeg_source_struct { - JMETHOD(void, start_input, (j_compress_ptr cinfo, - cjpeg_source_ptr sinfo)); - JMETHOD(JDIMENSION, get_pixel_rows, (j_compress_ptr cinfo, - cjpeg_source_ptr sinfo)); - JMETHOD(void, finish_input, (j_compress_ptr cinfo, - cjpeg_source_ptr sinfo)); - - FILE *input_file; - - JSAMPARRAY buffer; - JDIMENSION buffer_height; -}; - - -/* - * Object interface for djpeg's output file encoding modules - */ - -typedef struct djpeg_dest_struct * djpeg_dest_ptr; - -struct djpeg_dest_struct { - /* start_output is called after jpeg_start_decompress finishes. - * The color map will be ready at this time, if one is needed. - */ - JMETHOD(void, start_output, (j_decompress_ptr cinfo, - djpeg_dest_ptr dinfo)); - /* Emit the specified number of pixel rows from the buffer. */ - JMETHOD(void, put_pixel_rows, (j_decompress_ptr cinfo, - djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied)); - /* Finish up at the end of the image. */ - JMETHOD(void, finish_output, (j_decompress_ptr cinfo, - djpeg_dest_ptr dinfo)); - - /* Target file spec; filled in by djpeg.c after object is created. */ - FILE * output_file; - - /* Output pixel-row buffer. Created by module init or start_output. - * Width is cinfo->output_width * cinfo->output_components; - * height is buffer_height. - */ - JSAMPARRAY buffer; - JDIMENSION buffer_height; -}; - - -/* - * cjpeg/djpeg may need to perform extra passes to convert to or from - * the source/destination file format. The JPEG library does not know - * about these passes, but we'd like them to be counted by the progress - * monitor. We use an expanded progress monitor object to hold the - * additional pass count. - */ - -struct cdjpeg_progress_mgr { - struct jpeg_progress_mgr pub; /* fields known to JPEG library */ - int completed_extra_passes; /* extra passes completed */ - int total_extra_passes; /* total extra */ - /* last printed percentage stored here to avoid multiple printouts */ - int percent_done; -}; - -typedef struct cdjpeg_progress_mgr * cd_progress_ptr; - - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jinit_read_bmp jIRdBMP -#define jinit_write_bmp jIWrBMP -#define jinit_read_gif jIRdGIF -#define jinit_write_gif jIWrGIF -#define jinit_read_ppm jIRdPPM -#define jinit_write_ppm jIWrPPM -#define jinit_read_rle jIRdRLE -#define jinit_write_rle jIWrRLE -#define jinit_read_targa jIRdTarga -#define jinit_write_targa jIWrTarga -#define read_quant_tables RdQTables -#define read_scan_script RdScnScript -#define set_quant_slots SetQSlots -#define set_sample_factors SetSFacts -#define read_color_map RdCMap -#define enable_signal_catcher EnSigCatcher -#define start_progress_monitor StProgMon -#define end_progress_monitor EnProgMon -#define read_stdin RdStdin -#define write_stdout WrStdout -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - -/* Module selection routines for I/O modules. */ - -EXTERN(cjpeg_source_ptr) jinit_read_bmp JPP((j_compress_ptr cinfo)); -EXTERN(djpeg_dest_ptr) jinit_write_bmp JPP((j_decompress_ptr cinfo, - boolean is_os2)); -EXTERN(cjpeg_source_ptr) jinit_read_gif JPP((j_compress_ptr cinfo)); -EXTERN(djpeg_dest_ptr) jinit_write_gif JPP((j_decompress_ptr cinfo)); -EXTERN(cjpeg_source_ptr) jinit_read_ppm JPP((j_compress_ptr cinfo)); -EXTERN(djpeg_dest_ptr) jinit_write_ppm JPP((j_decompress_ptr cinfo)); -EXTERN(cjpeg_source_ptr) jinit_read_rle JPP((j_compress_ptr cinfo)); -EXTERN(djpeg_dest_ptr) jinit_write_rle JPP((j_decompress_ptr cinfo)); -EXTERN(cjpeg_source_ptr) jinit_read_targa JPP((j_compress_ptr cinfo)); -EXTERN(djpeg_dest_ptr) jinit_write_targa JPP((j_decompress_ptr cinfo)); - -/* cjpeg support routines (in rdswitch.c) */ - -EXTERN(boolean) read_quant_tables JPP((j_compress_ptr cinfo, char * filename, - int scale_factor, boolean force_baseline)); -EXTERN(boolean) read_scan_script JPP((j_compress_ptr cinfo, char * filename)); -EXTERN(boolean) set_quant_slots JPP((j_compress_ptr cinfo, char *arg)); -EXTERN(boolean) set_sample_factors JPP((j_compress_ptr cinfo, char *arg)); - -/* djpeg support routines (in rdcolmap.c) */ - -EXTERN(void) read_color_map JPP((j_decompress_ptr cinfo, FILE * infile)); - -/* common support routines (in cdjpeg.c) */ - -EXTERN(void) enable_signal_catcher JPP((j_common_ptr cinfo)); -EXTERN(void) start_progress_monitor JPP((j_common_ptr cinfo, - cd_progress_ptr progress)); -EXTERN(void) end_progress_monitor JPP((j_common_ptr cinfo)); -EXTERN(boolean) keymatch JPP((char * arg, const char * keyword, int minchars)); -EXTERN(FILE *) read_stdin JPP((void)); -EXTERN(FILE *) write_stdout JPP((void)); - -/* miscellaneous useful macros */ - -#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ -#define READ_BINARY "r" -#define WRITE_BINARY "w" -#else -#define READ_BINARY "rb" -#define WRITE_BINARY "wb" -#endif - -#ifndef EXIT_FAILURE /* define exit() codes if not provided */ -#define EXIT_FAILURE 1 -#endif -#ifndef EXIT_SUCCESS -#ifdef VMS -#define EXIT_SUCCESS 1 /* VMS is very nonstandard */ -#else -#define EXIT_SUCCESS 0 -#endif -#endif -#ifndef EXIT_WARNING -#ifdef VMS -#define EXIT_WARNING 1 /* VMS is very nonstandard */ -#else -#define EXIT_WARNING 2 -#endif -#endif diff --git a/Utilities/CAI/cai_dll/inc/g3states.h b/Utilities/CAI/cai_dll/inc/g3states.h deleted file mode 100755 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/atom.h b/Utilities/CAI/cai_dll/inc/inc_hdf/atom.h deleted file mode 100755 index 9caab48d9eb29999ce766583eb7308450f1e6a68..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/atom.h +++ /dev/null @@ -1,300 +0,0 @@ -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -/* $Id$ */ - -/*----------------------------------------------------------------------------- - * File: atom.h - * Purpose: header file for atom API - * Dependencies: - * Invokes: - * Contents: - * Structure definitions: - * Constant definitions: - *---------------------------------------------------------------------------*/ - -/* avoid re-inclusion */ -#ifndef __ATOM_H -#define __ATOM_H - -/* Atom Features control */ -/* Define the following macro for fast hash calculations (but limited hash sizes) */ -#define HASH_SIZE_POWER_2 - -/* Define the following macro for atom caching over all the atoms */ -#define ATOMS_ARE_CACHED - -/* Define the following macro for "inline" atom lookups from the cache */ -#ifdef ATOMS_ARE_CACHED /* required for this to work */ -#define ATOMS_CACHE_INLINE -#endif /* ATOMS_ARE_CACHED */ - -#ifdef ATOMS_CACHE_INLINE -/* Do swap using XOR operator. Ugly but fast... -QAK */ -#define HAIswap_cache(i,j) \ - atom_id_cache[i]^=atom_id_cache[j], \ - atom_obj_cache[i]=(void *)((hdf_pint_t)atom_obj_cache[j]^(hdf_pint_t)atom_obj_cache[i]), \ - atom_id_cache[j]^=atom_id_cache[i], \ - atom_obj_cache[j]=(void *)((hdf_pint_t)atom_obj_cache[i]^(hdf_pint_t)atom_obj_cache[j]), \ - atom_id_cache[i]^=atom_id_cache[j], \ - atom_obj_cache[i]=(void *)((hdf_pint_t)atom_obj_cache[i]^(hdf_pint_t)atom_obj_cache[j]) - -/* Note! This is hardwired to the atom cache value being 4 */ -#define HAatom_object(atm) \ - (atom_id_cache[0]==atm ? atom_obj_cache[0] : \ - atom_id_cache[1]==atm ? (HAIswap_cache(0,1),atom_obj_cache[0]) : \ - atom_id_cache[2]==atm ? (HAIswap_cache(1,2),atom_obj_cache[1]) : \ - atom_id_cache[3]==atm ? (HAIswap_cache(2,3),atom_obj_cache[2]) : \ - HAPatom_object(atm)) -#endif /* ATOMS_CACHE_INLINE */ - -#include "hdf.h" - -/* Group values allowed */ -typedef enum {BADGROUP=(-1), /* Invalid Group */ -DDGROUP=0, /* Group ID for DD objects */ -AIDGROUP=1, /* Group ID for access ID objects */ -FIDGROUP=2, /* Group ID for file ID objects */ -VGIDGROUP=3, /* Group ID for Vgroup ID objects */ -VSIDGROUP=4, /* Group ID for Vdata ID objects */ -GRIDGROUP=5, /* Group ID for GR ID objects */ -RIIDGROUP=6, /* Group ID for RI ID objects */ -BITIDGROUP=7, /* Group ID for Bitfile ID objects */ -ANIDGROUP=8, /* Group ID for Annotation ID objects */ -MAXGROUP /* Highest group in group_t (Invalid as true group) */ -} group_t; - -/* Type of atoms to return to users */ -typedef int32 atom_t; - -/* Type of the function to compare objects & keys */ -typedef intn (*HAsearch_func_t)(const void * obj, const void * key); - -#if defined ATOM_MASTER | defined ATOM_TESTER - -/* # of bits to use for Group ID in each atom (change if MAXGROUP>16) */ -#define GROUP_BITS 4 -#define GROUP_MASK 0x0F - -/* # of bits to use for the Atom index in each atom (change if MAXGROUP>16) */ -#define ATOM_BITS 28 -#define ATOM_MASK 0x0FFFFFFF - -#ifdef ATOMS_ARE_CACHED -/* # of previous atoms cached, change inline caching macros (HAatom_object & HAIswap_cache) if this changes */ -#define ATOM_CACHE_SIZE 4 -#endif /* ATOMS_ARE_CACHED */ - -/* Map an atom to a Group number */ -#define ATOM_TO_GROUP(a) ((group_t)((((atom_t)(a))>>((sizeof(atom_t)*8)-GROUP_BITS))&GROUP_MASK)) - -#ifdef HASH_SIZE_POWER_2 -/* Map an atom to a hash location (assumes s is a power of 2 and smaller than the ATOM_MASK constant) */ -#define ATOM_TO_LOC(a,s) ((atom_t)(a)&((s)-1)) -#else /* HASH_SIZE_POWER_2 */ -/* Map an atom to a hash location */ -#define ATOM_TO_LOC(a,s) (((atom_t)(a)&ATOM_MASK)%(s)) -#endif /* HASH_SIZE_POWER_2 */ - -/* Combine a Group number and an atom index into an atom */ -#define MAKE_ATOM(g,i) ((((atom_t)(g)&GROUP_MASK)<<((sizeof(atom_t)*8)-GROUP_BITS))|((atom_t)(i)&ATOM_MASK)) - -/* Atom information structure used */ -typedef struct atom_info_struct_tag { - atom_t id; /* atom ID for this info */ - VOIDP *obj_ptr; /* pointer associated with the atom */ - struct atom_info_struct_tag *next; /* link to next atom (in case of hash-clash) */ - }atom_info_t; - -/* Atom group structure used */ -typedef struct atom_group_struct_tag { - uintn count; /* # of times this group has been initialized */ - intn hash_size; /* size of the hash table to store the atoms in */ - uintn atoms; /* current number of atoms held */ - uintn nextid; /* atom ID to use for the next atom */ - atom_info_t **atom_list;/* pointer to an array of ptrs to atoms */ - }atom_group_t; - -/* Define this in only one place */ -#ifdef ATOM_MASTER - -/* Array of pointers to atomic groups */ -static atom_group_t *atom_group_list[MAXGROUP]={NULL}; - -/* Pointer to the atom node free list */ -static atom_info_t *atom_free_list=NULL; - -#ifdef ATOMS_ARE_CACHED -/* Array of pointers to atomic groups */ -#ifdef OLD_WAY -static atom_t atom_id_cache[ATOM_CACHE_SIZE]={-1,-1,-1,-1}; -static VOIDP atom_obj_cache[ATOM_CACHE_SIZE]={NULL}; -#else /* OLD_WAY */ -atom_t atom_id_cache[ATOM_CACHE_SIZE]={-1,-1,-1,-1}; -VOIDP atom_obj_cache[ATOM_CACHE_SIZE]={NULL}; -#endif /* OLD_WAY */ -#endif /* ATOMS_ARE_CACHED */ -#endif /* ATOM_MASTER */ - -/* Useful routines for generally private use */ - -#endif /* ATOM_MASTER | ATOM_TESTER */ - -#ifndef ATOM_MASTER -extern atom_t atom_id_cache[]; -extern VOIDP atom_obj_cache[]; -#endif /* ATOM_MASTER */ - -#if defined c_plusplus || defined __cplusplus -extern "C" -{ -#endif /* c_plusplus || __cplusplus */ - -/****************************************************************************** - NAME - HAinit_group - Initialize an atomic group - - DESCRIPTION - Creates an atomic group to store atoms in. If the group has already been - initialized, this routine just increments the count of # of initializations - and returns without trying to change the size of the hash table. - - RETURNS - Returns SUCCEED if successful and FAIL otherwise - -*******************************************************************************/ -intn HAinit_group(group_t grp, /* IN: Group to initialize */ - intn hash_size /* IN: Minimum hash table size to use for group */ -); - -/****************************************************************************** - NAME - HAdestroy_group - Destroy an atomic group - - DESCRIPTION - Destroys an atomic group which atoms are stored in. If the group still - has atoms which are registered, this routine fails. If there have been - multiple initializations of the group, this routine just decrements the - count of initializations and does not check the atoms out-standing. - - RETURNS - Returns SUCCEED if successful and FAIL otherwise - -*******************************************************************************/ -intn HAdestroy_group(group_t grp /* IN: Group to destroy */ -); - -/****************************************************************************** - NAME - HAregister_atom - Register an object in a group and get an atom for it. - - DESCRIPTION - Registers an object in a group and returns an atom for it. This routine - does _not_ check for unique-ness of the objects, if you register an object - twice, you will get two different atoms for it. This routine does make - certain that each atom in a group is unique. Atoms are created by getting - a unique number for the group the atom is in and incorporating the group - into the atom which is returned to the user. - - RETURNS - Returns atom if successful and FAIL otherwise - -*******************************************************************************/ -atom_t HAregister_atom(group_t grp, /* IN: Group to register the object in */ - VOIDP object /* IN: Object to attach to atom */ -); - -/****************************************************************************** - NAME - HAatom_object - Returns to the object ptr for the atom - - DESCRIPTION - Retrieves the object ptr which is associated with the atom. - - RETURNS - Returns object ptr if successful and NULL otherwise - -*******************************************************************************/ -#ifdef ATOMS_CACHE_INLINE -VOIDP HAPatom_object(atom_t atm /* IN: Atom to retrieve object for */ -); -#else /* ATOMS_CACHE_INLINE */ -VOIDP HAatom_object(atom_t atm /* IN: Atom to retrieve object for */ -); -#endif /* ATOMS_CACHE_INLINE */ - -/****************************************************************************** - NAME - HAatom_group - Returns to the group for the atom - - DESCRIPTION - Retrieves the group which is associated with the atom. - - RETURNS - Returns group if successful and FAIL otherwise - -*******************************************************************************/ -group_t HAatom_group(atom_t atm /* IN: Atom to retrieve group for */ -); - -/****************************************************************************** - NAME - HAremove_atom - Removes an atom from a group - - DESCRIPTION - Removes an atom from a group. - - RETURNS - Returns atom's object if successful and FAIL otherwise - -*******************************************************************************/ -VOIDP HAremove_atom(atom_t atm /* IN: Atom to remove */ -); - -/****************************************************************************** - NAME - HAsearch_atom - Search for an object in a group and get it's pointer. - - DESCRIPTION - Searchs for an object in a group and returns the pointer to it. - This routine calls the function pointer passed in for each object in the - group until it finds a match. Currently there is no way to resume a - search. - - RETURNS - Returns pointer an atom's object if successful and NULL otherwise - -*******************************************************************************/ -VOIDP HAsearch_atom(group_t grp, /* IN: Group to search for the object in */ - HAsearch_func_t func, /* IN: Ptr to the comparison function */ - const void * key /* IN: pointer to key to compare against */ -); - -/****************************************************************************** - NAME - HAshutdown - Terminate various static buffers. - - DESCRIPTION - Free various buffers allocated in the HA routines. - - RETURNS - Returns SUCCEED/FAIL - -*******************************************************************************/ -intn HAshutdown(void); - -#if defined c_plusplus || defined __cplusplus -} -#endif /* c_plusplus || __cplusplus */ - -#endif /* __ATOM_H */ - diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/bitvect.h b/Utilities/CAI/cai_dll/inc/inc_hdf/bitvect.h deleted file mode 100755 index fe3bec13522d8d3a658351010cdcf725b58cbfd7..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/bitvect.h +++ /dev/null @@ -1,385 +0,0 @@ -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -/* $Id$ */ - -/*----------------------------------------------------------------------------- - * File: bitvect.h - * Purpose: header file for bit-vector API - * Dependencies: - * Invokes: - * Contents: - * Structure definitions: - * Constant definitions: - *---------------------------------------------------------------------------*/ - -/* avoid re-inclusion */ -#ifndef __BITVECT_H -#define __BITVECT_H - -#include "hdf.h" - -/* Boolean values used */ -typedef enum {BV_FALSE=0, BV_TRUE=1} bv_bool; - -/* Flags for the bit-vector */ -#define BV_INIT_TO_ONE 0x00000001 /* to indicate whether to create the bit-vector with one's instead of zero's */ -#define BV_EXTENDABLE 0x00000002 /* to indicate that the bit-vector can be extended */ - -/* Default size of a bit-vector */ -#define BV_DEFAULT_BITS 128 - -/* Define the size of the chunks bits are allocated in */ -#define BV_CHUNK_SIZE 64 - -/* Create the external interface data structures needed */ -typedef struct bv_struct_tag *bv_ptr; - -#if defined BV_MASTER | defined BV_TESTER - -/* Base type of the array used to store the bits */ -typedef unsigned char bv_base; - -/* # of bits in the base type of the array used to store the bits */ -#define BV_BASE_BITS (sizeof(bv_base)*8) - -/* bit-vector structure used */ -typedef struct bv_struct_tag { - uint32 bits_used; /* The actual number of bits current in use */ - uint32 array_size; /* The number of bv_base elements in the bit-vector */ - uint32 flags; /* The flags used to create this bit-vector */ - int32 last_zero; /* The last location we know had a zero bit */ - bv_base *buffer; /* Pointer to the buffer used to store the bits */ - }bv_struct; - -/* Table of bits for each bit position */ -/* (This will need to be changed/expanded if another base type is used) */ -static const uint8 bv_bit_value[8]={ - 1, /* bit 0's value is 1 */ - 2, /* bit 1's value is 2 */ - 4, /* bit 2's value is 4 */ - 8, /* bit 3's value is 8 */ - 16, /* bit 4's value is 16 */ - 32, /* bit 5's value is 32 */ - 64, /* bit 6's value is 64 */ - 128 /* bit 7's value is 128 */ -}; - -/* Table of bit-masks for each number of bits in a byte */ -/* (This will need to be changed/expanded if another base type is used) */ -static const uint8 bv_bit_mask[9]={ - 0x00, /* 0 bits is a mask of 0x00 */ - 0x01, /* 1 bits is a mask of 0x01 */ - 0x03, /* 2 bits is a mask of 0x03 */ - 0x07, /* 3 bits is a mask of 0x07 */ - 0x0F, /* 4 bits is a mask of 0x0F */ - 0x1F, /* 5 bits is a mask of 0x1F */ - 0x3F, /* 6 bits is a mask of 0x3F */ - 0x7F, /* 7 bits is a mask of 0x7F */ - 0xFF /* 8 bits is a mask of 0xFF */ -}; - -/* Table of "first zero bit" for each byte value */ -/* (This will need to be changed/expanded if another base type is used) */ -static const int8 bv_first_zero[256]={ - 0, /* "0" - bit 0 is lowest zero */ 1, /* "1" - bit 1 is lowest zero */ - 0, /* "2" - bit 0 is lowest zero */ 2, /* "3" - bit 2 is lowest zero */ - 0, /* "4" - bit 0 is lowest zero */ 1, /* "5" - bit 1 is lowest zero */ - 0, /* "6" - bit 0 is lowest zero */ 3, /* "7" - bit 3 is lowest zero */ - 0, /* "8" - bit 0 is lowest zero */ 1, /* "9" - bit 1 is lowest zero */ - 0, /* "10" - bit 0 is lowest zero */ 2, /* "11" - bit 2 is lowest zero */ - 0, /* "12" - bit 0 is lowest zero */ 1, /* "13" - bit 1 is lowest zero */ - 0, /* "14" - bit 0 is lowest zero */ 4, /* "15" - bit 4 is lowest zero */ - 0, /* "16" - bit 0 is lowest zero */ 1, /* "17" - bit 1 is lowest zero */ - 0, /* "18" - bit 0 is lowest zero */ 2, /* "19" - bit 2 is lowest zero */ - 0, /* "20" - bit 0 is lowest zero */ 1, /* "21" - bit 1 is lowest zero */ - 0, /* "22" - bit 0 is lowest zero */ 3, /* "23" - bit 3 is lowest zero */ - 0, /* "24" - bit 0 is lowest zero */ 1, /* "25" - bit 1 is lowest zero */ - 0, /* "26" - bit 0 is lowest zero */ 2, /* "27" - bit 2 is lowest zero */ - 0, /* "28" - bit 0 is lowest zero */ 1, /* "29" - bit 1 is lowest zero */ - 0, /* "30" - bit 0 is lowest zero */ 5, /* "31" - bit 5 is lowest zero */ - 0, /* "32" - bit 0 is lowest zero */ 1, /* "33" - bit 1 is lowest zero */ - 0, /* "34" - bit 0 is lowest zero */ 2, /* "35" - bit 2 is lowest zero */ - 0, /* "36" - bit 0 is lowest zero */ 1, /* "37" - bit 1 is lowest zero */ - 0, /* "38" - bit 0 is lowest zero */ 3, /* "39" - bit 3 is lowest zero */ - 0, /* "40" - bit 0 is lowest zero */ 1, /* "41" - bit 1 is lowest zero */ - 0, /* "42" - bit 0 is lowest zero */ 2, /* "43" - bit 2 is lowest zero */ - 0, /* "44" - bit 0 is lowest zero */ 1, /* "45" - bit 1 is lowest zero */ - 0, /* "46" - bit 0 is lowest zero */ 4, /* "47" - bit 4 is lowest zero */ - 0, /* "48" - bit 0 is lowest zero */ 1, /* "49" - bit 1 is lowest zero */ - 0, /* "50" - bit 0 is lowest zero */ 2, /* "51" - bit 2 is lowest zero */ - 0, /* "52" - bit 0 is lowest zero */ 1, /* "53" - bit 1 is lowest zero */ - 0, /* "54" - bit 0 is lowest zero */ 3, /* "55" - bit 3 is lowest zero */ - 0, /* "56" - bit 0 is lowest zero */ 1, /* "57" - bit 1 is lowest zero */ - 0, /* "58" - bit 0 is lowest zero */ 2, /* "59" - bit 2 is lowest zero */ - 0, /* "60" - bit 0 is lowest zero */ 1, /* "61" - bit 1 is lowest zero */ - 0, /* "62" - bit 0 is lowest zero */ 6, /* "63" - bit 6 is lowest zero */ - 0, /* "64" - bit 0 is lowest zero */ 1, /* "65" - bit 1 is lowest zero */ - 0, /* "66" - bit 0 is lowest zero */ 2, /* "67" - bit 2 is lowest zero */ - 0, /* "68" - bit 0 is lowest zero */ 1, /* "69" - bit 1 is lowest zero */ - 0, /* "70" - bit 0 is lowest zero */ 3, /* "71" - bit 3 is lowest zero */ - 0, /* "72" - bit 0 is lowest zero */ 1, /* "73" - bit 1 is lowest zero */ - 0, /* "74" - bit 0 is lowest zero */ 2, /* "75" - bit 2 is lowest zero */ - 0, /* "76" - bit 0 is lowest zero */ 1, /* "77" - bit 1 is lowest zero */ - 0, /* "78" - bit 0 is lowest zero */ 4, /* "79" - bit 4 is lowest zero */ - 0, /* "80" - bit 0 is lowest zero */ 1, /* "81" - bit 1 is lowest zero */ - 0, /* "82" - bit 0 is lowest zero */ 2, /* "83" - bit 2 is lowest zero */ - 0, /* "84" - bit 0 is lowest zero */ 1, /* "85" - bit 1 is lowest zero */ - 0, /* "86" - bit 0 is lowest zero */ 3, /* "87" - bit 3 is lowest zero */ - 0, /* "88" - bit 0 is lowest zero */ 1, /* "89" - bit 1 is lowest zero */ - 0, /* "90" - bit 0 is lowest zero */ 2, /* "91" - bit 2 is lowest zero */ - 0, /* "92" - bit 0 is lowest zero */ 1, /* "93" - bit 1 is lowest zero */ - 0, /* "94" - bit 0 is lowest zero */ 5, /* "95" - bit 5 is lowest zero */ - 0, /* "96" - bit 0 is lowest zero */ 1, /* "97" - bit 1 is lowest zero */ - 0, /* "98" - bit 0 is lowest zero */ 2, /* "99" - bit 2 is lowest zero */ - 0, /* "100" - bit 0 is lowest zero */ 1, /* "101" - bit 1 is lowest zero */ - 0, /* "102" - bit 0 is lowest zero */ 3, /* "103" - bit 3 is lowest zero */ - 0, /* "104" - bit 0 is lowest zero */ 1, /* "105" - bit 1 is lowest zero */ - 0, /* "106" - bit 0 is lowest zero */ 2, /* "107" - bit 2 is lowest zero */ - 0, /* "108" - bit 0 is lowest zero */ 1, /* "109" - bit 1 is lowest zero */ - 0, /* "110" - bit 0 is lowest zero */ 4, /* "111" - bit 4 is lowest zero */ - 0, /* "112" - bit 0 is lowest zero */ 1, /* "113" - bit 1 is lowest zero */ - 0, /* "114" - bit 0 is lowest zero */ 2, /* "115" - bit 2 is lowest zero */ - 0, /* "116" - bit 0 is lowest zero */ 1, /* "117" - bit 1 is lowest zero */ - 0, /* "118" - bit 0 is lowest zero */ 3, /* "119" - bit 3 is lowest zero */ - 0, /* "120" - bit 0 is lowest zero */ 1, /* "121" - bit 1 is lowest zero */ - 0, /* "122" - bit 0 is lowest zero */ 2, /* "123" - bit 2 is lowest zero */ - 0, /* "124" - bit 0 is lowest zero */ 1, /* "125" - bit 1 is lowest zero */ - 0, /* "126" - bit 0 is lowest zero */ 7, /* "127" - bit 7 is lowest zero */ - 0, /* "128" - bit 0 is lowest zero */ 1, /* "129" - bit 1 is lowest zero */ - 0, /* "130" - bit 0 is lowest zero */ 2, /* "131" - bit 2 is lowest zero */ - 0, /* "132" - bit 0 is lowest zero */ 1, /* "133" - bit 1 is lowest zero */ - 0, /* "134" - bit 0 is lowest zero */ 3, /* "135" - bit 3 is lowest zero */ - 0, /* "136" - bit 0 is lowest zero */ 1, /* "137" - bit 1 is lowest zero */ - 0, /* "138" - bit 0 is lowest zero */ 2, /* "139" - bit 2 is lowest zero */ - 0, /* "140" - bit 0 is lowest zero */ 1, /* "141" - bit 1 is lowest zero */ - 0, /* "142" - bit 0 is lowest zero */ 4, /* "143" - bit 4 is lowest zero */ - 0, /* "144" - bit 0 is lowest zero */ 1, /* "145" - bit 1 is lowest zero */ - 0, /* "146" - bit 0 is lowest zero */ 2, /* "147" - bit 2 is lowest zero */ - 0, /* "148" - bit 0 is lowest zero */ 1, /* "149" - bit 1 is lowest zero */ - 0, /* "150" - bit 0 is lowest zero */ 3, /* "151" - bit 3 is lowest zero */ - 0, /* "152" - bit 0 is lowest zero */ 1, /* "153" - bit 1 is lowest zero */ - 0, /* "154" - bit 0 is lowest zero */ 2, /* "155" - bit 2 is lowest zero */ - 0, /* "156" - bit 0 is lowest zero */ 1, /* "157" - bit 1 is lowest zero */ - 0, /* "158" - bit 0 is lowest zero */ 5, /* "159" - bit 5 is lowest zero */ - 0, /* "160" - bit 0 is lowest zero */ 1, /* "161" - bit 1 is lowest zero */ - 0, /* "162" - bit 0 is lowest zero */ 2, /* "163" - bit 2 is lowest zero */ - 0, /* "164" - bit 0 is lowest zero */ 1, /* "165" - bit 1 is lowest zero */ - 0, /* "166" - bit 0 is lowest zero */ 3, /* "167" - bit 3 is lowest zero */ - 0, /* "168" - bit 0 is lowest zero */ 1, /* "169" - bit 1 is lowest zero */ - 0, /* "170" - bit 0 is lowest zero */ 2, /* "171" - bit 2 is lowest zero */ - 0, /* "172" - bit 0 is lowest zero */ 1, /* "173" - bit 1 is lowest zero */ - 0, /* "174" - bit 0 is lowest zero */ 4, /* "175" - bit 4 is lowest zero */ - 0, /* "176" - bit 0 is lowest zero */ 1, /* "177" - bit 1 is lowest zero */ - 0, /* "178" - bit 0 is lowest zero */ 2, /* "179" - bit 2 is lowest zero */ - 0, /* "180" - bit 0 is lowest zero */ 1, /* "181" - bit 1 is lowest zero */ - 0, /* "182" - bit 0 is lowest zero */ 3, /* "183" - bit 3 is lowest zero */ - 0, /* "184" - bit 0 is lowest zero */ 1, /* "185" - bit 1 is lowest zero */ - 0, /* "186" - bit 0 is lowest zero */ 2, /* "187" - bit 2 is lowest zero */ - 0, /* "188" - bit 0 is lowest zero */ 1, /* "189" - bit 1 is lowest zero */ - 0, /* "190" - bit 0 is lowest zero */ 6, /* "191" - bit 6 is lowest zero */ - 0, /* "192" - bit 0 is lowest zero */ 1, /* "193" - bit 1 is lowest zero */ - 0, /* "194" - bit 0 is lowest zero */ 2, /* "195" - bit 2 is lowest zero */ - 0, /* "196" - bit 0 is lowest zero */ 1, /* "197" - bit 1 is lowest zero */ - 0, /* "198" - bit 0 is lowest zero */ 3, /* "199" - bit 3 is lowest zero */ - 0, /* "200" - bit 0 is lowest zero */ 1, /* "201" - bit 1 is lowest zero */ - 0, /* "202" - bit 0 is lowest zero */ 2, /* "203" - bit 2 is lowest zero */ - 0, /* "204" - bit 0 is lowest zero */ 1, /* "205" - bit 1 is lowest zero */ - 0, /* "206" - bit 0 is lowest zero */ 4, /* "207" - bit 4 is lowest zero */ - 0, /* "208" - bit 0 is lowest zero */ 1, /* "209" - bit 1 is lowest zero */ - 0, /* "210" - bit 0 is lowest zero */ 2, /* "211" - bit 2 is lowest zero */ - 0, /* "212" - bit 0 is lowest zero */ 1, /* "213" - bit 1 is lowest zero */ - 0, /* "214" - bit 0 is lowest zero */ 3, /* "215" - bit 3 is lowest zero */ - 0, /* "216" - bit 0 is lowest zero */ 1, /* "217" - bit 1 is lowest zero */ - 0, /* "218" - bit 0 is lowest zero */ 2, /* "219" - bit 2 is lowest zero */ - 0, /* "220" - bit 0 is lowest zero */ 1, /* "221" - bit 1 is lowest zero */ - 0, /* "222" - bit 0 is lowest zero */ 5, /* "223" - bit 5 is lowest zero */ - 0, /* "224" - bit 0 is lowest zero */ 1, /* "225" - bit 1 is lowest zero */ - 0, /* "226" - bit 0 is lowest zero */ 2, /* "227" - bit 2 is lowest zero */ - 0, /* "228" - bit 0 is lowest zero */ 1, /* "229" - bit 1 is lowest zero */ - 0, /* "230" - bit 0 is lowest zero */ 3, /* "231" - bit 3 is lowest zero */ - 0, /* "232" - bit 0 is lowest zero */ 1, /* "233" - bit 1 is lowest zero */ - 0, /* "234" - bit 0 is lowest zero */ 2, /* "235" - bit 2 is lowest zero */ - 0, /* "236" - bit 0 is lowest zero */ 1, /* "237" - bit 1 is lowest zero */ - 0, /* "238" - bit 0 is lowest zero */ 4, /* "239" - bit 4 is lowest zero */ - 0, /* "240" - bit 0 is lowest zero */ 1, /* "241" - bit 1 is lowest zero */ - 0, /* "242" - bit 0 is lowest zero */ 2, /* "243" - bit 2 is lowest zero */ - 0, /* "244" - bit 0 is lowest zero */ 1, /* "245" - bit 1 is lowest zero */ - 0, /* "246" - bit 0 is lowest zero */ 3, /* "247" - bit 3 is lowest zero */ - 0, /* "248" - bit 0 is lowest zero */ 1, /* "249" - bit 1 is lowest zero */ - 0, /* "250" - bit 0 is lowest zero */ 2, /* "251" - bit 2 is lowest zero */ - 0, /* "252" - bit 0 is lowest zero */ 1, /* "253" - bit 1 is lowest zero */ - 0, /* "254" - bit 0 is lowest zero */ 8 /* "255" - bit 8 is lowest zero */ -}; - -/* Table of "number of 1 bits" for each byte value */ -/* (This will need to be changed/expanded if another base type is used) */ -static const int8 bv_num_ones[256]={ - 0, /* "0" - n bits are 1's */ 1, /* "1" - n bits are 1's */ - 1, /* "2" - n bits are 1's */ 2, /* "3" - n bits are 1's */ - 1, /* "4" - n bits are 1's */ 2, /* "5" - n bits are 1's */ - 2, /* "6" - n bits are 1's */ 3, /* "7" - n bits are 1's */ - 1, /* "8" - n bits are 1's */ 2, /* "9" - n bits are 1's */ - 2, /* "10" - n bits are 1's */ 3, /* "11" - n bits are 1's */ - 2, /* "12" - n bits are 1's */ 3, /* "13" - n bits are 1's */ - 3, /* "14" - n bits are 1's */ 4, /* "15" - n bits are 1's */ - 1, /* "16" - n bits are 1's */ 2, /* "17" - n bits are 1's */ - 2, /* "18" - n bits are 1's */ 3, /* "19" - n bits are 1's */ - 2, /* "20" - n bits are 1's */ 3, /* "21" - n bits are 1's */ - 3, /* "22" - n bits are 1's */ 4, /* "23" - n bits are 1's */ - 2, /* "24" - n bits are 1's */ 3, /* "25" - n bits are 1's */ - 3, /* "26" - n bits are 1's */ 4, /* "27" - n bits are 1's */ - 3, /* "28" - n bits are 1's */ 3, /* "29" - n bits are 1's */ - 4, /* "30" - n bits are 1's */ 5, /* "31" - n bits are 1's */ - 1, /* "32" - n bits are 1's */ 2, /* "33" - n bits are 1's */ - 2, /* "34" - n bits are 1's */ 3, /* "35" - n bits are 1's */ - 2, /* "36" - n bits are 1's */ 3, /* "37" - n bits are 1's */ - 3, /* "38" - n bits are 1's */ 4, /* "39" - n bits are 1's */ - 2, /* "40" - n bits are 1's */ 3, /* "41" - n bits are 1's */ - 3, /* "42" - n bits are 1's */ 4, /* "43" - n bits are 1's */ - 3, /* "44" - n bits are 1's */ 4, /* "45" - n bits are 1's */ - 4, /* "46" - n bits are 1's */ 5, /* "47" - n bits are 1's */ - 2, /* "48" - n bits are 1's */ 3, /* "49" - n bits are 1's */ - 3, /* "50" - n bits are 1's */ 4, /* "51" - n bits are 1's */ - 3, /* "52" - n bits are 1's */ 4, /* "53" - n bits are 1's */ - 4, /* "54" - n bits are 1's */ 5, /* "55" - n bits are 1's */ - 3, /* "56" - n bits are 1's */ 4, /* "57" - n bits are 1's */ - 4, /* "58" - n bits are 1's */ 5, /* "59" - n bits are 1's */ - 4, /* "60" - n bits are 1's */ 5, /* "61" - n bits are 1's */ - 5, /* "62" - n bits are 1's */ 6, /* "63" - n bits are 1's */ - 1, /* "64" - n bits are 1's */ 2, /* "65" - n bits are 1's */ - 2, /* "66" - n bits are 1's */ 3, /* "67" - n bits are 1's */ - 2, /* "68" - n bits are 1's */ 3, /* "69" - n bits are 1's */ - 3, /* "70" - n bits are 1's */ 4, /* "71" - n bits are 1's */ - 2, /* "72" - n bits are 1's */ 3, /* "73" - n bits are 1's */ - 3, /* "74" - n bits are 1's */ 4, /* "75" - n bits are 1's */ - 3, /* "76" - n bits are 1's */ 4, /* "77" - n bits are 1's */ - 4, /* "78" - n bits are 1's */ 5, /* "79" - n bits are 1's */ - 2, /* "80" - n bits are 1's */ 3, /* "81" - n bits are 1's */ - 3, /* "82" - n bits are 1's */ 4, /* "83" - n bits are 1's */ - 3, /* "84" - n bits are 1's */ 4, /* "85" - n bits are 1's */ - 4, /* "86" - n bits are 1's */ 5, /* "87" - n bits are 1's */ - 3, /* "88" - n bits are 1's */ 4, /* "89" - n bits are 1's */ - 4, /* "90" - n bits are 1's */ 5, /* "91" - n bits are 1's */ - 4, /* "92" - n bits are 1's */ 5, /* "93" - n bits are 1's */ - 5, /* "94" - n bits are 1's */ 6, /* "95" - n bits are 1's */ - 2, /* "96" - n bits are 1's */ 3, /* "97" - n bits are 1's */ - 3, /* "98" - n bits are 1's */ 4, /* "99" - n bits are 1's */ - 3, /* "100" - n bits are 1's */ 4, /* "101" - n bits are 1's */ - 4, /* "102" - n bits are 1's */ 5, /* "103" - n bits are 1's */ - 3, /* "104" - n bits are 1's */ 4, /* "105" - n bits are 1's */ - 4, /* "106" - n bits are 1's */ 5, /* "107" - n bits are 1's */ - 3, /* "108" - n bits are 1's */ 4, /* "109" - n bits are 1's */ - 4, /* "110" - n bits are 1's */ 5, /* "111" - n bits are 1's */ - 3, /* "112" - n bits are 1's */ 4, /* "113" - n bits are 1's */ - 4, /* "114" - n bits are 1's */ 5, /* "115" - n bits are 1's */ - 4, /* "116" - n bits are 1's */ 5, /* "117" - n bits are 1's */ - 5, /* "118" - n bits are 1's */ 6, /* "119" - n bits are 1's */ - 4, /* "120" - n bits are 1's */ 5, /* "121" - n bits are 1's */ - 5, /* "122" - n bits are 1's */ 6, /* "123" - n bits are 1's */ - 5, /* "124" - n bits are 1's */ 6, /* "125" - n bits are 1's */ - 6, /* "126" - n bits are 1's */ 7, /* "127" - n bits are 1's */ - 1, /* "128" - n bits are 1's */ 2, /* "129" - n bits are 1's */ - 2, /* "130" - n bits are 1's */ 3, /* "131" - n bits are 1's */ - 2, /* "132" - n bits are 1's */ 3, /* "133" - n bits are 1's */ - 3, /* "134" - n bits are 1's */ 4, /* "135" - n bits are 1's */ - 2, /* "136" - n bits are 1's */ 3, /* "137" - n bits are 1's */ - 3, /* "138" - n bits are 1's */ 4, /* "139" - n bits are 1's */ - 3, /* "140" - n bits are 1's */ 4, /* "141" - n bits are 1's */ - 4, /* "142" - n bits are 1's */ 5, /* "143" - n bits are 1's */ - 2, /* "144" - n bits are 1's */ 3, /* "145" - n bits are 1's */ - 3, /* "146" - n bits are 1's */ 4, /* "147" - n bits are 1's */ - 3, /* "148" - n bits are 1's */ 4, /* "149" - n bits are 1's */ - 4, /* "150" - n bits are 1's */ 5, /* "151" - n bits are 1's */ - 3, /* "152" - n bits are 1's */ 4, /* "153" - n bits are 1's */ - 4, /* "154" - n bits are 1's */ 5, /* "155" - n bits are 1's */ - 4, /* "156" - n bits are 1's */ 5, /* "157" - n bits are 1's */ - 5, /* "158" - n bits are 1's */ 6, /* "159" - n bits are 1's */ - 2, /* "160" - n bits are 1's */ 3, /* "161" - n bits are 1's */ - 3, /* "162" - n bits are 1's */ 4, /* "163" - n bits are 1's */ - 3, /* "164" - n bits are 1's */ 4, /* "165" - n bits are 1's */ - 4, /* "166" - n bits are 1's */ 5, /* "167" - n bits are 1's */ - 3, /* "168" - n bits are 1's */ 4, /* "169" - n bits are 1's */ - 4, /* "170" - n bits are 1's */ 5, /* "171" - n bits are 1's */ - 4, /* "172" - n bits are 1's */ 5, /* "173" - n bits are 1's */ - 5, /* "174" - n bits are 1's */ 6, /* "175" - n bits are 1's */ - 3, /* "176" - n bits are 1's */ 4, /* "177" - n bits are 1's */ - 4, /* "178" - n bits are 1's */ 5, /* "179" - n bits are 1's */ - 4, /* "180" - n bits are 1's */ 5, /* "181" - n bits are 1's */ - 5, /* "182" - n bits are 1's */ 6, /* "183" - n bits are 1's */ - 4, /* "184" - n bits are 1's */ 5, /* "185" - n bits are 1's */ - 5, /* "186" - n bits are 1's */ 6, /* "187" - n bits are 1's */ - 5, /* "188" - n bits are 1's */ 6, /* "189" - n bits are 1's */ - 6, /* "190" - n bits are 1's */ 7, /* "191" - n bits are 1's */ - 2, /* "192" - n bits are 1's */ 3, /* "193" - n bits are 1's */ - 3, /* "194" - n bits are 1's */ 4, /* "195" - n bits are 1's */ - 3, /* "196" - n bits are 1's */ 4, /* "197" - n bits are 1's */ - 4, /* "198" - n bits are 1's */ 5, /* "199" - n bits are 1's */ - 3, /* "200" - n bits are 1's */ 4, /* "201" - n bits are 1's */ - 4, /* "202" - n bits are 1's */ 5, /* "203" - n bits are 1's */ - 4, /* "204" - n bits are 1's */ 5, /* "205" - n bits are 1's */ - 5, /* "206" - n bits are 1's */ 6, /* "207" - n bits are 1's */ - 3, /* "208" - n bits are 1's */ 4, /* "209" - n bits are 1's */ - 4, /* "210" - n bits are 1's */ 5, /* "211" - n bits are 1's */ - 4, /* "212" - n bits are 1's */ 5, /* "213" - n bits are 1's */ - 5, /* "214" - n bits are 1's */ 6, /* "215" - n bits are 1's */ - 4, /* "216" - n bits are 1's */ 5, /* "217" - n bits are 1's */ - 5, /* "218" - n bits are 1's */ 6, /* "219" - n bits are 1's */ - 5, /* "220" - n bits are 1's */ 6, /* "221" - n bits are 1's */ - 6, /* "222" - n bits are 1's */ 7, /* "223" - n bits are 1's */ - 3, /* "224" - n bits are 1's */ 4, /* "225" - n bits are 1's */ - 4, /* "226" - n bits are 1's */ 5, /* "227" - n bits are 1's */ - 4, /* "228" - n bits are 1's */ 5, /* "229" - n bits are 1's */ - 5, /* "230" - n bits are 1's */ 6, /* "231" - n bits are 1's */ - 4, /* "232" - n bits are 1's */ 5, /* "233" - n bits are 1's */ - 5, /* "234" - n bits are 1's */ 6, /* "235" - n bits are 1's */ - 5, /* "236" - n bits are 1's */ 6, /* "237" - n bits are 1's */ - 6, /* "238" - n bits are 1's */ 7, /* "239" - n bits are 1's */ - 4, /* "240" - n bits are 1's */ 5, /* "241" - n bits are 1's */ - 5, /* "242" - n bits are 1's */ 6, /* "243" - n bits are 1's */ - 5, /* "244" - n bits are 1's */ 6, /* "245" - n bits are 1's */ - 6, /* "246" - n bits are 1's */ 7, /* "247" - n bits are 1's */ - 5, /* "248" - n bits are 1's */ 6, /* "249" - n bits are 1's */ - 6, /* "250" - n bits are 1's */ 7, /* "251" - n bits are 1's */ - 6, /* "252" - n bits are 1's */ 7, /* "253" - n bits are 1's */ - 7, /* "254" - n bits are 1's */ 8 /* "255" - n bits are 1's */ -}; - -/* Useful routines for generally private use */ - -#endif /* BV_MASTER | BV_TESTER */ -#if defined c_plusplus || defined __cplusplus -extern "C" -{ -#endif /* c_plusplus || __cplusplus */ -extern bv_ptr bv_new(int32 num_bits, uint32 flags); - -extern intn bv_delete(bv_ptr b); - -extern intn bv_set(bv_ptr b, int32 bit_num, bv_bool value); - -extern intn bv_get(bv_ptr b, int32 bit_num); - -extern intn bv_clear(bv_ptr b, bv_bool value); - -extern int32 bv_size(bv_ptr b); - -extern uint32 bv_flags(bv_ptr b); - -extern int32 bv_find(bv_ptr b, int32 last_find, bv_bool value); - -#if defined c_plusplus || defined __cplusplus -} -#endif /* c_plusplus || __cplusplus */ - -#endif /* __BITVECT_H */ - diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/cdeflate.h b/Utilities/CAI/cai_dll/inc/inc_hdf/cdeflate.h deleted file mode 100755 index 852c9552588498bec9915d295849231699eb2ccc..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/cdeflate.h +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - - /* $Id$ */ - - /*----------------------------------------------------------------------------- - * File: cdeflate.h - * Purpose: Header file for gzip 'deflate' encoding information. - * Dependencies: should only be included from hcompi.h - * Invokes: none - * Contents: Structures & definitions for gzip 'deflate' encoding. - * Structure definitions: - * Constant definitions: - *---------------------------------------------------------------------------*/ - -/* avoid re-inclusion */ -#ifndef __CDEFLATE_H -#define __CDEFLATE_H - -/* Get the gzip 'deflate' header */ -#define intf zintf -#include "zlib.h" -#undef zintf - -#if defined c_plusplus || defined __cplusplus -extern "C" -{ -#endif /* c_plusplus || __cplusplus */ - -/* - ** from cdeflate.c - */ - - extern int32 HCPcdeflate_stread - (accrec_t * rec); - - extern int32 HCPcdeflate_stwrite - (accrec_t * rec); - - extern int32 HCPcdeflate_seek - (accrec_t * access_rec, int32 offset, int origin); - - extern int32 HCPcdeflate_inquire - (accrec_t * access_rec, int32 *pfile_id, uint16 *ptag, uint16 *pref, - int32 *plength, int32 *poffset, int32 *pposn, int16 *paccess, - int16 *pspecial); - - extern int32 HCPcdeflate_read - (accrec_t * access_rec, int32 length, void * data); - - extern int32 HCPcdeflate_write - (accrec_t * access_rec, int32 length, const void * data); - - extern intn HCPcdeflate_endaccess - (accrec_t * access_rec); - -#if defined c_plusplus || defined __cplusplus -} -#endif /* c_plusplus || __cplusplus */ - -/* Define the [default] size of the buffer to interact with the file. */ -#define DEFLATE_BUF_SIZE 4096 -#define DEFLATE_TMP_BUF_SIZE 16384 - -/* gzip [en|de]coding information */ -typedef struct -{ - intn deflate_level; /* how hard to try to compress this data */ - int32 offset; /* offset in the de-compressed array */ - intn acc_init; /* is access mode initialized? */ - int16 acc_mode; /* access mode desired */ - void * io_buf; /* buffer for I/O with the file */ - z_stream deflate_context; /* pointer to the deflation context for each byte in the element */ -} -comp_coder_deflate_info_t; - -#ifndef CDEFLATE_MASTER -extern funclist_t cdeflate_funcs; /* functions to perform gzip encoding */ -#else -funclist_t cdeflate_funcs = -{ /* functions to perform gzip encoding */ - HCPcdeflate_stread, - HCPcdeflate_stwrite, - HCPcdeflate_seek, - HCPcdeflate_inquire, - HCPcdeflate_read, - HCPcdeflate_write, - HCPcdeflate_endaccess -}; -#endif - -#endif /* __CDEFLATE_H */ - diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/cnbit.h b/Utilities/CAI/cai_dll/inc/inc_hdf/cnbit.h deleted file mode 100755 index 0e7118d0de57ffe7dfca96f601716c24ab97feba..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/cnbit.h +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - - /* $Id$ */ - - /*----------------------------------------------------------------------------- - * File: cnbit.h - * Purpose: Header file for N-bit encoding information. - * Dependencies: should only be included from hcompi.h - * Invokes: none - * Contents: Structures & definitions for N-bit encoding. - * Structure definitions: - * Constant definitions: - *---------------------------------------------------------------------------*/ - -/* avoid re-inclusion */ -#ifndef __CNBIT_H -#define __CNBIT_H - -#if defined c_plusplus || defined __cplusplus -extern "C" -{ -#endif /* c_plusplus || __cplusplus */ - -/* - ** from cnbit.c - */ - - extern int32 HCPcnbit_stread - (accrec_t * rec); - - extern int32 HCPcnbit_stwrite - (accrec_t * rec); - - extern int32 HCPcnbit_seek - (accrec_t * access_rec, int32 offset, int origin); - - extern int32 HCPcnbit_inquire - (accrec_t * access_rec, int32 *pfile_id, uint16 *ptag, uint16 *pref, - int32 *plength, int32 *poffset, int32 *pposn, int16 *paccess, - int16 *pspecial); - - extern int32 HCPcnbit_read - (accrec_t * access_rec, int32 length, void * data); - - extern int32 HCPcnbit_write - (accrec_t * access_rec, int32 length, const void * data); - - extern intn HCPcnbit_endaccess - (accrec_t * access_rec); - -#if defined c_plusplus || defined __cplusplus -} -#endif /* c_plusplus || __cplusplus */ - -/* size of the N-bit buffer */ -#define NBIT_BUF_SIZE (MAX_NT_SIZE*64) -/* size of the N-bit mask buffer (same as buffer size for now) */ -#define NBIT_MASK_SIZE (MAX_NT_SIZE) - -typedef struct -{ /* structure to hold bit vector info */ - intn offset, /* offset of the bit information */ - length; /* number of bits in the information */ - uint8 mask; /* mask for this bit vector */ -} -nbit_mask_info_t; - -/* N-bit [en|de]coding information */ -typedef struct - { - int32 nt; /* number type of data we are encoding */ - intn nt_size; /* size of the number-type in the file */ - intn fill_one; /* whether to fill with 1's or not (0's) */ - intn sign_ext; /* whether to sign extend or not */ - uint8 buffer[NBIT_BUF_SIZE]; /* buffer for expanding n-bit data in */ - intn buf_pos; /* current offset in the expansion buffer */ - intn mask_off, /* offset of the bit to start masking with */ - mask_len; /* number of bits to mask */ - int32 offset; /* offset in the file in terms of bytes */ - uint8 mask_buf[NBIT_MASK_SIZE]; /* buffer to hold the bitmask */ - nbit_mask_info_t mask_info[NBIT_MASK_SIZE]; /* information about the mask */ - intn nt_pos; /* current byte to read or write */ - } -comp_coder_nbit_info_t; - -#ifndef CNBIT_MASTER -extern funclist_t cnbit_funcs; /* functions to perform N-bit encoding */ -#else -funclist_t cnbit_funcs = -{ /* functions to perform N-bit encoding */ - HCPcnbit_stread, - HCPcnbit_stwrite, - HCPcnbit_seek, - HCPcnbit_inquire, - HCPcnbit_read, - HCPcnbit_write, - HCPcnbit_endaccess -}; -#endif - -#endif /* __CNBIT_H */ diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/crle.h b/Utilities/CAI/cai_dll/inc/inc_hdf/crle.h deleted file mode 100755 index 9bb79ccf4ed2ecd541e9f227c2fcc58d9046c063..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/crle.h +++ /dev/null @@ -1,113 +0,0 @@ - -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -/* $Id$ */ - -/*----------------------------------------------------------------------------- - * File: crle.h - * Purpose: Header file for run-length encoding information. - * Dependencies: should only be included from hcompi.h - * Invokes: none - * Contents: Structures & definitions for run-length encoding. This header - * should only be included in hcomp.c and crle.c. - * Structure definitions: - * Constant definitions: - *---------------------------------------------------------------------------*/ - -/* avoid re-inclusion */ -#ifndef __CRLE_H -#define __CRLE_H - -#if defined c_plusplus || defined __cplusplus -extern "C" -{ -#endif /* c_plusplus || __cplusplus */ - -/* - ** from crle.c - */ - - extern int32 HCPcrle_stread - (accrec_t * rec); - - extern int32 HCPcrle_stwrite - (accrec_t * rec); - - extern int32 HCPcrle_seek - (accrec_t * access_rec, int32 offset, int origin); - - extern int32 HCPcrle_inquire - (accrec_t * access_rec, int32 *pfile_id, uint16 *ptag, uint16 *pref, - int32 *plength, int32 *poffset, int32 *pposn, int16 *paccess, - int16 *pspecial); - - extern int32 HCPcrle_read - (accrec_t * access_rec, int32 length, void * data); - - extern int32 HCPcrle_write - (accrec_t * access_rec, int32 length, const void * data); - - extern intn HCPcrle_endaccess - (accrec_t * access_rec); - -#if defined c_plusplus || defined __cplusplus -} -#endif /* c_plusplus || __cplusplus */ - -/* size of the RLE buffer */ -#define RLE_BUF_SIZE 128 -/* NIL code for run bytes */ -#define RLE_NIL (-1) -/* minimum length of run */ -#define RLE_MIN_RUN 3 -/* maximum length of run */ -#define RLE_MAX_RUN (RLE_BUF_SIZE+RLE_MIN_RUN-1) -/* minimum length of mix */ -#define RLE_MIN_MIX 1 - -/* RLE [en|de]coding information */ -typedef struct -{ - int32 offset; /* offset in the file */ - uint8 buffer[RLE_BUF_SIZE]; /* buffer for storing RLE bytes */ - intn buf_length; /* number of bytes in buffer */ - intn buf_pos; /* offset into the buffer */ - uintn last_byte, /* the last byte stored in the buffer */ - second_byte; /* the second to last byte stored in the buffer */ - enum - { - RLE_INIT, /* initial state, need to read a byte to determine - next state */ - RLE_RUN, /* buffer up to the current position is a run */ - RLE_MIX - } /* buffer up to the current position is a mix */ - rle_state; /* state of the buffer storage */ -} -comp_coder_rle_info_t; - -#ifndef CRLE_MASTER -extern funclist_t crle_funcs; /* functions to perform run-length encoding */ -#else -funclist_t crle_funcs = -{ /* functions to perform run-length encoding */ - HCPcrle_stread, - HCPcrle_stwrite, - HCPcrle_seek, - HCPcrle_inquire, - HCPcrle_read, - HCPcrle_write, - HCPcrle_endaccess -}; -#endif - -#endif /* __CRLE_H */ diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/cskphuff.h b/Utilities/CAI/cai_dll/inc/inc_hdf/cskphuff.h deleted file mode 100755 index 06b651347379d45b3090ae3ba8cd6c4ba3782c13..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/cskphuff.h +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - - /* $Id$ */ - - /*----------------------------------------------------------------------------- - * File: cskphuff.h - * Purpose: Header file for skipping huffman encoding information. - * Dependencies: should only be included from hcompi.h - * Invokes: none - * Contents: Structures & definitions for skipping huffman encoding. - * Structure definitions: - * Constant definitions: - *---------------------------------------------------------------------------*/ - -/* avoid re-inclusion */ -#ifndef __CSKPHUFF_H -#define __CSKPHUFF_H - -#if defined c_plusplus || defined __cplusplus -extern "C" -{ -#endif /* c_plusplus || __cplusplus */ - -/* - ** from cskphuff.c - */ - - extern int32 HCPcskphuff_stread - (accrec_t * rec); - - extern int32 HCPcskphuff_stwrite - (accrec_t * rec); - - extern int32 HCPcskphuff_seek - (accrec_t * access_rec, int32 offset, int origin); - - extern int32 HCPcskphuff_inquire - (accrec_t * access_rec, int32 *pfile_id, uint16 *ptag, uint16 *pref, - int32 *plength, int32 *poffset, int32 *pposn, int16 *paccess, - int16 *pspecial); - - extern int32 HCPcskphuff_read - (accrec_t * access_rec, int32 length, void * data); - - extern int32 HCPcskphuff_write - (accrec_t * access_rec, int32 length, const void * data); - - extern intn HCPcskphuff_endaccess - (accrec_t * access_rec); - -#if defined c_plusplus || defined __cplusplus -} -#endif /* c_plusplus || __cplusplus */ - -/* The maximum source character code: */ -#define SKPHUFF_MAX_CHAR 255 - -/* One greater than the maximum source character code: */ -#define SUCCMAX (SKPHUFF_MAX_CHAR+1) - -/* Twice the maximum source character code: */ -#define TWICEMAX (2*SUCCMAX+1) - -/* The root node in the tree */ -#define ROOT 0 - -/* Skipping huffman [en|de]coding information */ -typedef struct -{ - intn skip_size; /* number of bytes in each element */ - uintn **left, /* define the left and right pointer arrays */ - **right; - uint8 **up; /* define the up pointer array */ - intn skip_pos; /* current byte to read or write */ - int32 offset; /* offset in the de-compressed array */ -} -comp_coder_skphuff_info_t; - -#ifndef CSKPHUFF_MASTER -extern funclist_t cskphuff_funcs; /* functions to perform skipping huffman encoding */ -#else -funclist_t cskphuff_funcs = -{ /* functions to perform skipping huffman encoding */ - HCPcskphuff_stread, - HCPcskphuff_stwrite, - HCPcskphuff_seek, - HCPcskphuff_inquire, - HCPcskphuff_read, - HCPcskphuff_write, - HCPcskphuff_endaccess -}; -#endif - -#endif /* __CSKPHUFF_H */ diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/df.h b/Utilities/CAI/cai_dll/inc/inc_hdf/df.h deleted file mode 100755 index fc153ae88262723ee8d0f80d1ef93fbe7b4259cc..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/df.h +++ /dev/null @@ -1,212 +0,0 @@ -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -/* $Id$ */ - -/*----------------------------------------------------------------------------- - * File: df.h - * Purpose: header file for HDF routines - * Invokes: dfi.h - * Contents: - * Structure definitions: DFddh, DFdd, DFdesc, DFdle, DF, DFdi, DFdata - * Procedure type definitions - * Global variables - * Tag definitions - * Error return codes - * Logical constants - * Remarks: This file is included with user programs - * Since it includes stdio.h etc., do not include these after df.h - *---------------------------------------------------------------------------*/ - -#ifndef DF_H /* avoid re-inclusion */ -#define DF_H - -/* include DF (internal) header information */ -#include "hdf.h" - -/*-------------------------------------------------------------------------*/ -/* Type declarations */ - -typedef struct DFddh - { /*format of data descriptor headers in file */ - int16 dds; /* number of dds in header block */ - int32 next; /* offset of next header block */ - } -DFddh; - -typedef struct DFdd - { /* format of data descriptors as in file */ - uint16 tag; /* data tag */ - uint16 ref; /* data reference number */ - int32 offset; /* offset of data element in file */ - int32 length; /* number of bytes */ - } -DFdd; - -/* descriptor structure is same as dd structure. ###Note: may be changed */ -typedef DFdd DFdesc; - -/* DLE is the internal structure which stores data descriptor information */ -/* It is a linked list of DDs */ -typedef struct DFdle - { /* Data List element */ - struct DFdle *next; /* link to next dle */ - DFddh ddh; /* To store headers */ - DFdd dd[1]; /* dummy size */ - } -DFdle; - -/* DF is the internal structure associated with each DF file */ -/* It holds information associated with the file as a whole */ -/* ### Note: there are hooks for having multiple DF files open at a time */ -typedef struct DF - { - DFdle *list; /* Pointer to the DLE list */ - DFdle *last_dle; /* last_dle and last_dd are used in searches */ - /* to indicate element returned */ - /* by previous call to DFfind */ - DFdd *up_dd; /* DD of element being read/updated, */ - /* used by DFstart */ - uint16 last_tag; /* Last tag searched for by DFfind */ - uint16 last_ref; /* Last reference number searched for */ - intn type; /* 0= not in use, 1= normal, -1 = multiple */ - /* this is a hook for when */ - /* multiple files are open */ - intn access; /* permitted access types: */ - /* 0=none, 1=r, 2=w, 3=r/w */ - intn changed; /* True if anything in DDs modified */ - /* since last write */ - intn last_dd; /* see last_dle */ - intn defdds; /* default numer of DD's in each block */ - intn up_access; /* access permissions to element being */ - /* read/updated. Used by DFstart */ - /* File handle is a file pointer or file descriptor depending on whether */ - /* we use buffered or unbuffered I/O. But, since this structure is a */ - /* fake, it doesn't matter whether I/O is buffered or not. */ - intn file; /* file descriptor */ - } -DF; - -typedef struct DFdata - { /* structure for returning status information */ - int32 version; /* version number of program */ - } -DFdata; - -/*--------------------------------------------------------------------------*/ -/* Procedure types */ - -#if defined c_plusplus || defined __cplusplus -extern "C" -{ -#endif /* c_plusplus || __cplusplus */ - -/* prototypes for dfstubs.c */ - extern DF *DFopen - (char *name, int acc_mode, int ndds); - - extern int DFclose - (DF * dfile); - - extern int DFdescriptors - (DF * dfile, DFdesc ptr[], int begin, int num); - - extern int DFnumber - (DF * dfile, uint16 tag); - - extern int DFsetfind - (DF * dfile, uint16 tag, uint16 ref); - - extern int DFfind - (DF * dfile, DFdesc * ptr); - - extern int DFaccess - (DF * dfile, uint16 tag, uint16 ref, char *acc_mode); - - extern int DFstart - (DF * dfile, uint16 tag, uint16 ref, char *acc_mode); - - extern int32 DFread - (DF * dfile, char *ptr, int32 len); - - extern int32 DFseek - (DF * dfile, int32 offset); - - extern int32 DFwrite - (DF * dfile, char *ptr, int32 len); - - extern int DFupdate - (DF * dfile); - - extern int DFstat - (DF * dfile, DFdata * dfinfo); - - extern int32 DFgetelement - (DF * dfile, uint16 tag, uint16 ref, char *ptr); - - extern int32 DFputelement - (DF * dfile, uint16 tag, uint16 ref, char *ptr, int32 len); - - extern int DFdup - (DF * dfile, uint16 itag, uint16 iref, uint16 otag, uint16 oref); - - extern int DFdel - (DF * dfile, uint16 tag, uint16 ref); - - extern uint16 DFnewref - (DF * dfile); - - extern int DFishdf - (char *filename); - - extern int DFerrno - (void); - - extern int DFIerr - (DF * dfile); - - extern int DFImemcopy - (char *from, char *to, int length); - - extern void *DFIgetspace - (uint32 qty); - - extern void *DFIfreespace - (void *ptr); - - extern int DFIc2fstr - (char *str, int len); - - extern char *DFIf2cstring - (_fcd fdesc, intn len); - -/* prototypes for dfconv.c */ - extern int DFconvert - (uint8 *source, uint8 *dest, int ntype, int sourcetype, int desttype, int32 size); - -#if defined c_plusplus || defined __cplusplus -} -#endif /* c_plusplus || __cplusplus */ - -/*--------------------------------------------------------------------------*/ -/* Global Variables */ - -#ifndef DFMASTER -extern -#endif /*DFMASTER */ -int DFerror; /* Error code for DF routines */ - -#define DFSETERR(error) (DFerror=(DFerror?DFerror:error)) - -#define DFTOFID(df) (int32)(df->list) - -#endif /* DF_H */ diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/dfan.h b/Utilities/CAI/cai_dll/inc/inc_hdf/dfan.h deleted file mode 100755 index 8709a7490eb46c1a983d148caf4f0528c4595a13..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/dfan.h +++ /dev/null @@ -1,65 +0,0 @@ - -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -/* $Id$ */ - -/*------------------------------------------------------------------------------ - * File: dfan.h - * Purpose: header file for the Annotations set - * Invokes: df.h - * Contents: - * Structure definitions: DFANdirentry, DFANdirhead - * Constant definitions: DFAN_LABEL, DFAN_DESC - * Remarks: none - *----------------------------------------------------------------------------*/ - -#ifndef DFAN_H /* avoid re-inclusion */ -#define DFAN_H - -#include "hdf.h" - -#define DFAN_LABEL 0 -#define DFAN_DESC 1 - -#define DFAN_LAB_BLKSIZE 64 /* default blksize to use for labels */ -#define DFAN_DESC_BLKSIZE 512 /* default blksize to use for descriptions */ - -#define DFAN_DEFENTRIES 16 /* no of dir entries to add at a time */ - -/* - * This structure stores an entry in the label/desc directory - * for a label/desc in the file, it gives the ref of the label/desc, - * and the tag/ref of the data item to which the label/desc relates - */ -typedef struct - { - uint16 annref; /* ref of annotation */ - uint16 datatag; /* tag of data */ - uint16 dataref; /* ref of data */ - } -DFANdirentry; - -/* - * This structure is a head node for the directory, which is organized as - * as a linked list of arrays. DFANdirentry is the structure of an - * array element, while DFANdirhead is the list element - */ -typedef struct DFANdirhead - { - struct DFANdirhead *next; /* list element */ - int32 nentries; /* Numer of entries */ - DFANdirentry *entries; /* actually an arbitrary size array */ - } -DFANdirhead; - -#endif /* DFAN_H */ diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/dfgr.h b/Utilities/CAI/cai_dll/inc/inc_hdf/dfgr.h deleted file mode 100755 index 46dcf2ca08f40a06b8aa96929acee75496947b19..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/dfgr.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -/* $Id$ */ - -/*----------------------------------------------------------------------------- - * File: dfgr.h - * Purpose: header file for the Raster Image set - * Invokes: df.h - * Contents: - * Structure definitions: DFGRdr, DFGRrig - * Remarks: This is included with user programs which use general raster - *---------------------------------------------------------------------------*/ - -#ifndef DFGR_H /* avoid re-inclusion */ -#define DFGR_H - -/* description record: used to describe image data, palette data etc. */ -typedef struct - { - intn ncomponents; /* number of components */ - intn interlace; /* data ordering: chunky / planar etc */ - int32 xdim; /* X- dimension of data */ - int32 ydim; /* Y- dimensionsof data */ - DFdi nt; /* number type of data */ - DFdi compr; /* compression */ - /* ### Note: compression is currently uniquely described with a tag. - No data is attached to this tag/ref. But this capability is - provided for future expansion, when this tag/ref might point to - some data needed for decompression, such as the actual encodings */ - } -DFGRdr; - -/* structure to hold RIG info */ -typedef struct - { - char *cf; /* color format */ - int32 xpos; /* X position of image on screen */ - int32 ypos; /* Y position of image on screen */ - float32 aspectratio; /* ratio of pixel height to width */ - float32 ccngamma; /* gamma color correction parameter */ - float32 ccnred[3]; /* red color correction parameter */ - float32 ccngrren[3]; /* green color correction parameter */ - float32 ccnblue[3]; /* blue color correction parameter */ - float32 ccnwhite[3]; /* white color correction parameter */ - DFdi data[3]; /* image/lut/mattechannel */ - DFGRdr datadesc[3]; /* description of image/lut/mattechannel */ - } -DFGRrig; - -#if defined c_plusplus || defined __cplusplus -extern "C" -{ -#endif /* c_plusplus || __cplusplus */ - -/* Library-developer functions */ - extern int32 DFGRIopen - (const char *filename, int acc_mode); - -#if defined c_plusplus || defined __cplusplus -} -#endif /* c_plusplus || __cplusplus */ - -#endif /* DFGR_H */ diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/dfi.h b/Utilities/CAI/cai_dll/inc/inc_hdf/dfi.h deleted file mode 100755 index ee3cf04bd033027d46576c9fd4e8598bcaff021f..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/dfi.h +++ /dev/null @@ -1,220 +0,0 @@ - -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -/* $Id$ */ - -/*----------------------------------------------------------------------------- - * File: dfi.h - * Purpose: HDF internal header file - * Invokes: stdio.h, sys/file.h - * Contents: - * Compilation parameters - * Machine-dependent definitions - * Flexibility definitions: i/o buffering, dynamic memory, structure i/o - * Size parameters - * Remarks: To port to a new system, only dfi.h and Makefile need be modified. - * This file is included with user programs, but users do not see it. - *---------------------------------------------------------------------------*/ - -#ifndef DFI_H -#define DFI_H - -/*--------------------------------------------------------------------------*/ -/* Compilation Parameters for Flexibility and Portability */ - -/* modify this line for buffered/unbuffered i/o */ -#define DF_BUFFIO - -/* modify this line for dynamic/static memory allocation */ -#define DF_DYNAMIC - -/* modify this line if structures cannot be read/written as is */ -#undef DF_STRUCTOK /* leave it this way - hdfsh expects it */ - -/*--------------------------------------------------------------------------*/ -/* Machine dependencies */ -/*--------------------------------------------------------------------------*/ - -#ifdef IRIX -#undef DF_STRUCTOK -#include <sys/types.h> -#include <sys/file.h> /* for unbuffered i/o stuff */ -#ifndef DFmovmem -#define DFmovmem(from, to, len) bcopy(from, to, len) -#endif /* DFmovmem */ -#ifndef DF_STRUCTOK -#define UINT16READ(p, x) { x = ((*p++) & 255)<<8; x |= (*p++) & 255; } -#define INT16READ(p, x) { x = (*p++)<<8; x |= (*p++) & 255; } -#define INT32READ(p, x) { x = (*p++)<<24; x|=((*p++) & 255)<<16; \ - x|=((*p++) & 255)<<8; x|=(*p++) & 255; } -#define UINT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; } -#define INT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; } -#define INT32WRITE(p, x) { *p++ = (x>>24) & 255; *p++ = (x>>16) & 255; \ - *p++ = (x>>8) & 255; *p++ = x & 255; } -#endif /*DF_STRUCTOK */ -#define DF_CREAT(name, prot) creat(name, prot) -#ifndef DF_MT -#define DF_MT DFMT_IRIX -#endif /* DF_MT */ -#endif /*IRIX */ - -#ifdef IBM6000 /* NOTE: IBM6000 defines are same as for SUN */ -#if ! defined mc68010 && ! defined mc68020 && ! defined mc68030 -#undef DF_STRUCTOK -#endif -#include <sys/file.h> /* for unbuffered i/o stuff */ -#define DFmovmem(from, to, len) memcpy(to, from, len) -#ifndef DF_STRUCTOK -#define UINT16READ(p, x) { x = ((*p++) & 255)<<8; x |= (*p++) & 255; } -#define INT16READ(p, x) { x = (*p++)<<8; x |= (*p++) & 255; } -#define INT32READ(p, x) { x = (*p++)<<24; x|=((*p++) & 255)<<16; \ - x|=((*p++) & 255)<<8; x|=(*p++) & 255; } -#define UINT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; } -#define INT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; } -#define INT32WRITE(p, x) { *p++ = (x>>24) & 255; *p++ = (x>>16) & 255; \ - *p++ = (x>>8) & 255; *p++ = x & 255; } -#endif /*DF_STRUCTOK */ -#define DF_CREAT(name, prot) creat(name, prot) -#define DF_MT DFMT_IBM6000 -#endif /*IBM6000 */ - -#if defined (MAC) || defined (macintosh) || defined (SYMANTEC_C) -#undef DF_BUFFIO /* use unbuffered i/o */ -#include <memory.h> /* malloc stuff for MPW 3.0 */ -#include <fcntl.h> /* unbuffered IO stuff for MPW 3.0 */ -#ifdef SYMANTEC_C /* for LightSpeed C */ -#include <unix.h> -#else /*SYMANTEC_C MPW, possibly others */ -#include <Files.h> /* for unbuffered i/o stuff */ -#endif /*SYMANTEC_C */ -#define DF_CAPFNAMES /* fortran names are in all caps */ -#define DF_DYNAMIC /* use dynamic allocation */ -#ifdef SYMANTEC_C /* LightSpeed C does not have memcpy */ -#define DFmovmem(from, to, len) DFImemcopy(from, to, len) -#else /*SYMANTEC_C */ -#define DFmovmem(from, to, len) memcpy(to, from, len) -#endif /*SYMANTEC_C */ -#define malloc(x) NewPtr((Size) (x)) /* don't use malloc on the Mac */ -#define free(x) DisposPtr((Ptr) (x)) /* don't use free on the Nac */ -#undef DF_STRUCTOK -#define UINT16READ(p, x) { x = ((*p++) & 255)<<8; x |= (*p++) & 255; } -#define INT16READ(p, x) { x = (*p++)<<8; x |= (*p++) & 255; } -#define INT32READ(p, x) { x = (*p++)<<24; x|=((*p++) & 255)<<16; \ - x|=((*p++) & 255)<<8; x|=(*p++) & 255; } -#define UINT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; } -#define INT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; } -#define INT32WRITE(p, x) { *p++ = (x>>24) & 255; *p++ = (x>>16) & 255; \ - *p++ = (x>>8) & 255; *p++ = x & 255; } -#define DF_CREAT(name, prot) mopen(name, O_WRONLY|O_TRUNC|O_CREAT) -#define DF_MT DFMT_MAC -#endif /*MAC */ - -#ifdef VMS -/*#undef DF_BUFFIO should be buff !!!! */ - /* use only unbuff i/o - buff doesn't work! */ -#ifndef DFopen /* avoid double includes */ -/* #include "dfivms.h" */ -#endif /*DFopen */ -#undef DF_STRUCTOK -#define DF_CAPFNAMES /* fortran names are in all caps */ -#include <file.h> /* for unbuffered i/o stuff */ -#define DFmovmem(from, to, len) memcpy(to, from, len) -#ifndef DF_STRUCTOK -#define UINT16READ(p, x) { x = ((*p++) & 255)<<8; x |= (*p++) & 255; } -#define INT16READ(p, x) { x = (*p++)<<8; x |= (*p++) & 255; } -#define INT32READ(p, x) { x = (*p++)<<24; x|=((*p++) & 255)<<16; \ - x|=((*p++) & 255)<<8; x|=(*p++) & 255; } -#define UINT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; } -#define INT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; } -#define INT32WRITE(p, x) { *p++ = (x>>24) & 255; *p++ = (x>>16) & 255; \ - *p++ = (x>>8) & 255; *p++ = x & 255; } -#endif /*DF_STRUCTOK */ -#define DF_CREAT(name, prot) creat(name, prot) -#define DF_MT DFMT_VAX -#endif /*VMS */ - -#ifdef APOLLO -#if ! defined mc68010 && ! defined mc68020 && ! defined mc68030 -#undef DF_STRUCTOK -#endif -#include <sys/file.h> /* for unbuffered i/o stuff */ -#define int8 char -#define uint8 unsigned char -#define int16 short int -#define uint16 unsigned short int -#define int32 long int -#define uint32 unsigned long int -#define float32 float -#define DFmovmem(from, to, len) memcpy(to, from, len) -#ifndef DF_STRUCTOK -#define UINT16READ(p, x) { x = ((*p++) & 255)<<8; x |= (*p++) & 255; } -#define INT16READ(p, x) { x = (*p++)<<8; x |= (*p++) & 255; } -#define INT32READ(p, x) { x = (*p++)<<24; x|=((*p++) & 255)<<16; \ - x|=((*p++) & 255)<<8; x|=(*p++) & 255; } -#define UINT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; } -#define INT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; } -#define INT32WRITE(p, x) { *p++ = (x>>24) & 255; *p++ = (x>>16) & 255; \ - *p++ = (x>>8) & 255; *p++ = x & 255; } -#endif /*DF_STRUCTOK */ -#define DF_CREAT(name, prot) creat(name, prot) -#define DF_MT DFMT_APOLLO -#endif /*APOLLO */ - -/*--------------------------------------------------------------------------*/ -/* Flexibility parameters */ -#if defined (MAC) || defined (macintosh) || defined (SYMANTEC_C) /* MAC specific file manager calls */ -# define DF_OPEN(x,y) mopen(x,y) -# define DF_CLOSE(x) mclose(x) -# define DF_SEEK(x,y,z) mlseek(x,y,z) -# define DF_SKEND(x,y,z) mlseek(x,-1*y,z) -# define DF_TELL(x) mlseek(x,0L,1) -# define DF_READ(a,b,c,d) mread(d,a,b*c) -# define DF_WRITE(a,b,c,d) mwrite(d,a,b*c) -# define DF_FLUSH(a) /* no need to flush */ -# define DF_RDACCESS 0 /* dummy */ -# define DF_WRACCESS 0 /* dummy */ -# define DF_OPENERR(f) ((f) == -1) -#else /* !MAC */ -#ifdef DF_BUFFIO /* set all calls to do buffered I/O */ -#define DF_OPEN(x,y) fopen(x,y) -#define DF_CLOSE(x) fclose(x) -#define DF_SEEK(x,y,z) fseek(x,y,z) -#define DF_SKEND(x,y,z) fseek(x,y,z) -#define DF_TELL(x) ftell(x) -#define DF_READ(a,b,c,d) fread(a,b,c,d) -#define DF_WRITE(a,b,c,d) fwrite(a,b,c,d) -#define DF_FLUSH(a) fflush(a) -#define DF_OPENERR(f) (!(f)) -#define DF_RDACCESS "rb" -#define DF_WRACCESS "rb+" - -#else /*DF_BUFFIO unbuffered i/o */ -#define DF_OPEN(x,y) open(x,y) -#define DF_CLOSE(x) close(x) -#define DF_SEEK(x,y,z) lseek(x,y,z) -#define DF_SKEND(x,y,z) lseek(x,-1*y,z) -#define DF_TELL(x) lseek(x,0L,1) -#define DF_READ(a,b,c,d) read(d,a,b*c) -#define DF_WRITE(a,b,c,d) write(d,a,b*c) -#define DF_OPENERR(f) ((f) == -1) -#define DF_FLUSH(a) /* no need to flush */ -#define DF_RDACCESS O_RDONLY -#define DF_WRACCESS O_RDWR -#endif /* DF_BUFFIO */ -#endif /* !MAC */ - -#ifndef FILE -#include <stdio.h> -#endif /*FILE */ - -#endif /* DFI_H */ diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/dfrig.h b/Utilities/CAI/cai_dll/inc/inc_hdf/dfrig.h deleted file mode 100755 index 1070d851f71d92205f10bb79f00672c78e866f26..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/dfrig.h +++ /dev/null @@ -1,73 +0,0 @@ - -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -/* $Id$ */ - -/*----------------------------------------------------------------------------- - * File: dfrig.h - * Purpose: header file for the Raster Image set - * Invokes: df.h - * Contents: - * Structure definitions: DFRdr, DFRrig - * Remarks: This is included with user programs which use RIG - *---------------------------------------------------------------------------*/ - -#ifndef DFRIG /* avoid re-inclusion */ -#define DFRIG - -/* description record: used to describe image data, palette data etc. */ -typedef struct - { - int16 ncomponents; /* Number of components */ - int16 interlace; /* data ordering: chunky / planar etc */ - int32 xdim; /* X-dimension of data */ - int32 ydim; /* Y-dimensionsof data */ - DFdi nt; /* number type of data */ - DFdi compr; /* compression */ - /* ### Note: compression is currently uniquely described with a tag. - No data is attached to this tag/ref. But this capability is - provided for future expansion, when this tag/ref might point to - some data needed for decompression, such as the actual encodings */ - } -DFRdr; - -/* structure to hold RIG info */ -typedef struct - { - char *cf; /* color format */ - int32 xpos; /* X position of image on screen */ - int32 ypos; /* Y position of image on screen */ - float32 aspectratio; /* ratio of pixel height to width */ - float32 ccngamma; /* gamma color correction parameters */ - float32 ccnred[3]; /* red color correction parameters */ - float32 ccngrren[3]; /* green color correction parameters */ - float32 ccnblue[3]; /* blue color correction parameters */ - float32 ccnwhite[3]; /* white color correction parameters */ - DFdi image; /* image */ - DFRdr descimage; /* image data description */ - DFdi lut; /* color look-up table (palette) */ - DFRdr desclut; /* look-up table description */ - DFdi mattechannel; /* matte? */ - DFRdr descmattechannel; /* Description of matte? */ - } -DFRrig; - -/* dimensions of raster-8 image */ -typedef struct R8dim - { - uint16 xd; - uint16 yd; - } -R8dim; - -#endif /*DFRIG */ diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/dfsd.h b/Utilities/CAI/cai_dll/inc/inc_hdf/dfsd.h deleted file mode 100755 index 0e0cc7231ab1df587c3fff41660bac189e04c558..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/dfsd.h +++ /dev/null @@ -1,136 +0,0 @@ - -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -/* $Id$ */ - -/*----------------------------------------------------------------------------- - * File: dfsd.h - * Purpose: header file for the Scientific Data set - * Invokes: dfrig.h - * Contents: - * Structure definitions: DFSsdg - * Constant definitions: DFS_MAXLEN - * Remarks: This is included with user programs which use SDG - * Currently defined to be 2-D. Will later be increased to - * multiple dimensions - *---------------------------------------------------------------------------*/ - -#ifndef _DFSD_H /* avoid re-inclusion */ -#define _DFSD_H - -#include "hdf.h" - -/* include numbertype and aid for 3.2 S. Xu */ -/* structure to hold SDG info */ -typedef struct DFSsdg - { - DFdi data; /* tag/ref of data in file */ - intn rank; /* number of dimensions */ - int32 *dimsizes; /* dimensions of data */ - char *coordsys; - char *dataluf[3]; /* label/unit/format of data */ - char **dimluf[3]; /* label/unit/format for each dim */ - uint8 **dimscales; /* scales for each dimension */ - uint8 max_min[16]; /* max, min values of data, */ - /* currently atmost 8 bytes each */ - int32 numbertype; /* default is float32 */ - uint8 filenumsubclass; /* number format in the file, default is IEEE */ - int32 aid; /* access id */ - int32 compression; /* 0 -- not compressed */ - int32 isndg; /* 0 -- pure sdg, written by 3.1 else ndg */ - float64 cal, cal_err; /* calibration multiplier stuff */ - float64 ioff, ioff_err; /* calibration offset stuff */ - int32 cal_type; /* number type of data after calibration */ - uint8 fill_value[DFSD_MAXFILL_LEN]; /* fill value if any specified */ - intn fill_fixed; /* whether ther fill value is a fixed value, or it can change */ - } -DFSsdg; - -/* DFnsdgle is the internal structure which stores SDG or NDS and */ -/* related SDG in an HDF file. */ -/* It is a linked list. */ - -typedef struct DFnsdgle - { - DFdi nsdg; /* NDG from 3.2 or SDG from 3.1 */ - DFdi sdg; /* Only special NDF has values in this field */ - struct DFnsdgle *next; - } -DFnsdgle; - -typedef struct DFnsdg_t_hdr - { - uint32 size; - DFnsdgle *nsdg_t; - } -DFnsdg_t_hdr; - -#if defined c_plusplus || defined __cplusplus -extern "C" -{ -#endif /* c_plusplus || __cplusplus */ - - extern int32 DFSDIopen - (const char * filename, int acc_mode); - - extern int DFSDIsdginfo - (int32 file_id); - - extern int DFSDIclear - (DFSsdg * sdg); - - extern int DFSDIclearNT - (DFSsdg * sdg); - - extern int DFSDIgetdata - (const char * filename, intn rank, int32 maxsizes[], VOIDP data, - int isfortran); - - extern int DFSDIputdata - (const char * filename, intn rank, int32 * dimsizes, VOIDP data, - int accmode, int isfortran); - - extern int DFSDIgetslice - (const char * filename, int32 winst[], int32 windims[], VOIDP data, - int32 dims[], int isfortran); - - extern int DFSDIputslice - (int32 windims[], VOIDP data, int32 dims[], int isfortran); - - extern int DFSDIendslice - (int isfortran); - - extern intn DFSDIrefresh - (char * filename); - - extern int DFSDIisndg - (intn * isndg); - - extern int DFSDIgetrrank - (intn * rank); - - extern int DFSDIgetwrank - (intn * rank); - - extern int DFSDIsetdimstrs - (int dim, const char * label, const char * unit, const char * format); - - extern int DFSDIsetdatastrs - (const char * label, const char * unit, const char * format, - const char * coordsys); - -#if defined c_plusplus || defined __cplusplus -} -#endif /* c_plusplus || __cplusplus */ - -#endif /* _DFSD_H */ diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/dfstubs.h b/Utilities/CAI/cai_dll/inc/inc_hdf/dfstubs.h deleted file mode 100755 index 2cd1931ea085686393c91744486d248f3460a71d..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/dfstubs.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -/* $Id$ */ - -/* - ** FILE - ** dfstubs.h - ** PURPOSE - ** Header file for "dfstubs.c" HDF 3.1 emulation using new routines - ** from "hfile.c". - ** AUTHOR - ** Doug Ilg - */ - -#ifndef DFSTUBS_H /* avoid re-inclusion */ -#define DFSTUBS_H -/* This is the master HDF driver (taking the place of df.c), so... */ -#define DFMASTER -#undef PERM_OUT /* used to "comment out" code */ - -#include "df.h" -#undef DFMASTER - -#if !defined(__GNUC__) & !defined(CONVEX) & !defined(VMS) -#include <memory.h> -#endif /* !__GNUC__ & !CONVEX & !VMS */ - -#define DFACC_APPEND 8 -#define DFEL_ABSENT 0 -#define DFEL_RESIDENT 1 -#define DFSRCH_OLD 0 -#define DFSRCH_NEW 1 - -PRIVATE int32 DFid = 0; -PRIVATE int32 DFaid = 0; -PRIVATE int DFaccmode = 0; -PRIVATE int DFelaccmode = 0; -PRIVATE uint16 search_tag = 0; -PRIVATE uint16 search_ref = 0; -PRIVATE int search_stat = DFSRCH_NEW; -PRIVATE int32 search_aid = 0; -PRIVATE int DFelstat = DFEL_ABSENT; -PRIVATE int32 DFelsize = 0; -PRIVATE int32 DFelseekpos = 0; -PRIVATE uint16 acc_tag = 0; -PRIVATE uint16 acc_ref = 0; -PRIVATE char *DFelement = NULL; - -#if defined c_plusplus || defined __cplusplus -extern "C" -{ -#endif /* c_plusplus || __cplusplus */ - -/* prototypes for internal routines */ - PRIVATE int DFIclearacc - (void); - - PRIVATE int DFIcheck - (DF * dfile); - -#if defined c_plusplus || defined __cplusplus -} -#endif /* c_plusplus || __cplusplus */ - -#endif /* DFSTUBS_H */ diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/dfufp2i.h b/Utilities/CAI/cai_dll/inc/inc_hdf/dfufp2i.h deleted file mode 100755 index 09fe5656a28024df6b0042cc015622233c0098c1..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/dfufp2i.h +++ /dev/null @@ -1,85 +0,0 @@ - -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -/* $Id$ */ - -#ifndef DFUFP2IM_H /* avoid re-inclusion */ -#define DFUFP2IM_H - -/* Input structure */ -typedef struct - { - int32 hdim; /* horizontal dimension of input data */ - int32 vdim; /* vertical dimension of input data */ - intn is_pal; /* flag to tell whether there is a palette */ - intn is_vscale; /* flag telling whether vertical scale included */ - intn is_hscale; /* flag telling whether horizonatal scale included */ - intn ct_method; /* color transform method: EXPAND or INTERP */ - float32 max; /* max value of data */ - float32 min; /* min value of the data */ - float32 *hscale; /* horizontal scale */ - float32 *vscale; /* vertical scale */ - float32 *data; /* floating point data */ - } -Input; - -/* Output structure */ -typedef struct - { - int32 hres; /* horizontal resolution of image */ - int32 vres; /* vertical resolution of image */ - intn compress; /* compression scheme */ - char outfile[32]; /* output file name */ - uint8 *image; /* Image */ - uint8 *palette; /* Palette */ - } -Output; - -/*----------------------------------------------------------------------------*/ -/* Function Prototypes */ - -#if defined c_plusplus || defined __cplusplus -extern "C" -{ -#endif /* c_plusplus || __cplusplus */ - -/* prototypes for dfufp2im.c */ - -#ifdef OLD_WAY - extern int duif2i_(int32 *hdim, int32 *vdim, float32 *max, float32 *min, - float32 hscale[], float32 vscale[], float32 data[], - _fcd palette, _fcd outfile, int *ct_method, int32 *hres, - int32 *vres, int *compress, int *lenfn); - extern int DFUfptoimage(int32 hdim, int32 vdim, float32 max, float32 min, - float32 *hscale, float32 *vscale, float32 *data, - uint8 *palette, char *outfile, int ct_method, - int32 hres, int32 vres, int compress); -#endif - extern int process - (Input * in, Output * out); - extern int generate_scale - (int32 dim, float32 *scale); - extern int convert_interp - (Input * in, Output * out); - extern int pixrep_scaled - (Input * in, Output * out); - extern int compute_offsets - (float32 *scale, int32 dim, int32 *offsets, int32 res); - extern int pixrep_simple - (Input * in, Output * out); - -#if defined c_plusplus || defined __cplusplus -} -#endif /* c_plusplus || __cplusplus */ - -#endif /* DFUFP2IM_H */ diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/dynarray.h b/Utilities/CAI/cai_dll/inc/inc_hdf/dynarray.h deleted file mode 100755 index 30f407e0a15029d72f967f4423f8f83e3b6130e5..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/dynarray.h +++ /dev/null @@ -1,156 +0,0 @@ -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -/* $Id$ */ - -/*----------------------------------------------------------------------------- - * File: dynarray.h - * Purpose: header file for dynamic array API - * Dependencies: - * Invokes: - * Contents: - * Structure definitions: - * Constant definitions: - *---------------------------------------------------------------------------*/ - -/* avoid re-inclusion */ -#ifndef __DYNARRAY_H -#define __DYNARRAY_H - -#include "hdf.h" - -/* - Define the pointer to the dynarray without giving outside routines access - to the internal workings of the structure. -*/ -typedef struct dynarray_tag *dynarr_p; - -#if defined DYNARRAY_MASTER | defined DYNARRAY_TESTER -typedef struct dynarray_tag - { - intn num_elems; /* Number of elements in the array currently */ - intn incr_mult; /* Multiple to increment the array size by */ - VOIDP *arr; /* Pointer to the actual array of void *'s */ - }dynarr_t; - -#endif /* DYNARRAY_MASTER | DYNARRAY_TESTER */ - -#if defined c_plusplus || defined __cplusplus -extern "C" -{ -#endif /* c_plusplus || __cplusplus */ - -/****************************************************************************** - NAME - DAcreate_array - Create a dynarray - - DESCRIPTION - Create a dynarray for later use. This routine allocates the dynarray - structure and creates a dynarray with the specified minimum size. - - RETURNS - Returns pointer to the dynarray created if successful and NULL otherwise - -*******************************************************************************/ -dynarr_p DAcreate_array(intn start_size, /* IN: Initial array size */ - intn incr_mult /* IN: multiple to create additional elements in */ -); - -/****************************************************************************** - NAME - DAdestroy_array - Destroy a dynarray - - DESCRIPTION - Destroy an existing dynarray from use. This routine de-allocates the - dynarray structure and deletes the current dynarray. - - RETURNS - Returns SUCCEED if successful and FAIL otherwise - -*******************************************************************************/ -intn DAdestroy_array(dynarr_p arr, /* IN: Array to destroy */ - intn free_elem /* IN: whether to free each element */ -); - -/****************************************************************************** - NAME - DAdestroy_array - Get the current size of a dynarray - - DESCRIPTION - Get the number of elements in use currently. - - RETURNS - Returns # of dynarray elements if successful and FAIL otherwise - -*******************************************************************************/ -intn DAsize_array(dynarr_p arr /* IN: Array to get size of */ -); - -/****************************************************************************** - NAME - DAget_elem - Get an element from a dynarray - - DESCRIPTION - Retrieve an element from a dynarray. If the element to be retrieved is - beyond the end of the currently allocated array elements, the array is - not extended, a NULL pointer is merely returned. - - RETURNS - Returns object ptr if successful and NULL otherwise - -*******************************************************************************/ -VOIDP DAget_elem(dynarr_p arr_ptr, /* IN: Array to access */ - intn elem /* IN: Array element to retrieve */ -); - -/****************************************************************************** - NAME - DAset_elem - Set an element pointer for a dynarray - - DESCRIPTION - Set an element pointer for a dynarray. If the element to be set is - beyond the end of the currently allocated array elements, the array is - extended by whatever multiple of the incr_mult is needed to expand the - # of array elements to include the array element to set. - - RETURNS - Returns SUCCEED if successful and NULL otherwise - -*******************************************************************************/ -intn DAset_elem(dynarr_p arr_ptr, /* IN: Array to access */ - intn elem, /* IN: Array element to set */ - VOIDP obj /* IN: Pointer to the object to store */ -); - -/***************************************************************************** - NAME - DAdel_elem - Delete an element from a dynarray - - DESCRIPTION - Retrieve an element from a dynarray & delete it from the dynarray. If the - element to be retrieved is beyond the end of the currently allocated array - elements, the array is not extended, a NULL pointer is merely returned. - - RETURNS - Returns object ptr if successful and NULL otherwise - -*******************************************************************************/ -VOIDP DAdel_elem(dynarr_p arr_ptr, /* IN: Array to access */ - intn elem /* IN: Array element to retrieve */ -); - -#if defined c_plusplus || defined __cplusplus -} -#endif /* c_plusplus || __cplusplus */ - -#endif /* __DYNARRAY_H */ - diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/hbitio.h b/Utilities/CAI/cai_dll/inc/inc_hdf/hbitio.h deleted file mode 100755 index 9ad8defdbc57af8feb44ef8407db758ad1ee728e..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/hbitio.h +++ /dev/null @@ -1,85 +0,0 @@ - -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -/* $Id$ */ - -/* - ** hbitio.h - ** - ** Data structures and macros for bitfile access to HDF data objects. - ** These are mainly used for compression I/O and N-bit data objects. - */ - -#ifndef __HBITIO_H -#define __HBITIO_H - -/* Define the number of elements in the buffered array */ -#define BITBUF_SIZE 4096 -/* Macro to define the number of bits cached in the 'bits' variable */ -#define BITNUM (sizeof(uint8)*8) -/* Macro to define the number of bits able to be read/written at a time */ -#define DATANUM (sizeof(uint32)*8) - -typedef struct bitrec_t - { - int32 acc_id; /* Access ID for H layer I/O routines */ - int32 bit_id; /* Bitfile ID for internal use */ - /* Note that since HDF has signed 32bit offset limit we need to change this to signed - since the get passed to Hxxx calls which take signed 32bit arguments */ - int32 block_offset, /* offset of the current buffered block in the dataset */ - max_offset, /* offset of the last byte written to the dataset */ - byte_offset; /* offset of the current byte in the dataset */ - - intn count, /* bit count to next boundary */ - buf_read; /* number of bytes read into buffer (necessary for random I/O) */ - uint8 access; /* What the access on this file is ('r', 'w', etc..) */ - uint8 mode; /* how are we interacting with the data now ('r', 'w', etc) */ - uint8 bits; /* extra bit buffer, 0..BITNUM-1 bits */ - uint8 *bytep; /* current position in buffer */ - uint8 *bytez; /* end of buffer to compare */ - uint8 *bytea; /* byte buffer */ - } -bitrec_t; - -#ifndef BITMASTER -extern -#endif -const uint8 maskc[9] -#ifdef BITMASTER -= -{0, 1, 3, 7, 15, 31, 63, 127, 255} -#endif - ; - -#ifndef BITMASTER -extern -#endif -const uint32 maskl[33] -#ifdef BITMASTER -= -{0x00000000, - 0x00000001, 0x00000003, 0x00000007, 0x0000000f, - 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff, - 0x000001ff, 0x000003ff, 0x000007ff, 0x00000fff, - 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff, - 0x0001ffff, 0x0003ffff, 0x0007ffff, 0x000fffff, - 0x001fffff, 0x003fffff, 0x007fffff, 0x00ffffff, - 0x01ffffff, 0x03ffffff, 0x07ffffff, 0x0fffffff, - 0x1fffffff, 0x3fffffff, 0x7fffffff, 0xffffffffUL} -#endif - ; - -/* Function-like Macros */ -#define Hputbit(bitid,bit) ((Hbitwrite(bitid,1,(uint32)bit)==FAIL) ? FAIL : SUCCEED) - -#endif /* __HBITIO_H */ diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/hchunks.h b/Utilities/CAI/cai_dll/inc/inc_hdf/hchunks.h deleted file mode 100755 index 6c42ea00e61083592ff6527c972160c4879f33f9..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/hchunks.h +++ /dev/null @@ -1,294 +0,0 @@ -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -/* $Id$ */ - -/*----------------------------------------------------------------------------- - * File: hchunks.h - * Purpose: Header file for Chunked elements - * Dependencies: tbbt.c mcache.c - * Invokes: none - * Contents: Structures & definitions for chunked elements - * Structure definitions: DIM_DEF, HCHUNK_DEF - * Constant definitions: - * Author: -GeorgeV - 9/3/96 - *---------------------------------------------------------------------------*/ - -/* avoid re-inclusion */ -#ifndef __HCHUNKS_H -#define __HCHUNKS_H - -/* required includes */ -#include "hfile.h" /* special info stuff */ - -#ifdef _HCHUNKS_MAIN_ -/* Private to 'hchunks.c' */ - -#include "tbbt.h" /* TBBT stuff */ -#include "mcache.h" /* caching routines */ -#include "hcomp.h" /* For Compression */ - -/* Define class, class version and name(partial) for chunk table i.e. Vdata */ -#if 0 /* moved definition of class of vdata to hlimits.h */ -#define _HDF_CHK_TBL_CLASS "_HDF_CHK_TBL_" /* 13 bytes */ -#define _HDF_CHK_TBL_CLASS_VER 0 /* zero version number for class */ -#endif /* moved definition of class of vdata to hlimits.h */ -#define _HDF_CHK_TBL_NAME "_HDF_CHK_TBL_" /* 13 bytes */ - -/* Define field name for each chunk record i.e. Vdata record */ -#define _HDF_CHK_FIELD_1 "origin" /* 6 bytes */ -#define _HDF_CHK_FIELD_2 "chk_tag" /* 7 bytes */ -#define _HDF_CHK_FIELD_3 "chk_ref" /* 7 bytes */ -#define _HDF_CHK_FIELD_NAMES "origin,chk_tag,chk_ref" /* 22 bytes */ - -/* Define version number for chunked header format */ -#define _HDF_CHK_HDR_VER 0 /* zero version for format header */ - -#endif /* _HCHUNKS_MAIN_ */ - -/* Public structures */ - -/* Structure for each Data array dimension Defintion */ -typedef struct dim_def_struct { - int32 dim_length; /* length of this dimension */ - int32 chunk_length; /* chunk length along this dimension */ - int32 distrib_type; /* Data distribution along this dimension */ -} DIM_DEF, * DIM_DEF_PTR; - -/* Structure for each Chunk Definition*/ -typedef struct hchunk_def_struct { - int32 chunk_size; /* size of this chunk*/ - int32 nt_size; /* number type size i.e. size of data type */ - int32 num_dims; /* number of actual dimensions */ - DIM_DEF *pdims; /* ptr to array of dimension records for this chunk*/ - int32 chunk_flag; /* multiply specialness? SPECIAL_COMP */ - - /* For Compression info */ - comp_coder_t comp_type; /* Compression type */ - comp_model_t model_type; /* Compression model type */ - comp_info *cinfo; /* Compression info struct */ - model_info *minfo; /* Compression model info struct */ -}HCHUNK_DEF, * HCHUNK_DEF_PTR; - -/* Private structues */ -#ifdef _HCHUNKS_MAIN_ -/* Private to 'hchunks.c' */ - -/* Structure for each Data array dimension */ -typedef struct dim_rec_struct { - /* fields stored in chunked header */ - int32 flag; /* distrib_type(low 8 bits 0-7) - - Data distribution along this dimension - other(medium low 8 bits 8-15) - - regular/unlimited dimension? */ - int32 dim_length; /* length of this dimension */ - int32 chunk_length; /* chunk length along this dimension */ - - /* info determined from 'flag' field */ - int32 distrib_type; /* Data distribution along this dimension */ - int32 unlimited; /* regular(0) or unlimited dimension(1) */ - - /* computed fields */ - int32 last_chunk_length; /* last chunk length along this dimension */ - int32 num_chunks; /* i.e. "dim_length / chunk_length" */ -} DIM_REC, * DIM_REC_PTR; - -/* Structure for each Chunk */ -typedef struct chunk_rec_struct { - int32 chunk_number; /* chunk number from coordinates i.e. origin */ - int32 chk_vnum; /* chunk vdata record number i.e. position in table*/ - - /* chunk record fields stored in Vdata Table */ - int32 *origin; /* origin -> position of chunk */ - uint16 chk_tag; /* DFTAG_CHUNK or another Chunked element? */ - uint16 chk_ref; /* reference number of this chunk */ -}CHUNK_REC, * CHUNK_REC_PTR; - -/* information on this special chunk data elt */ -typedef struct chunkinfo_t -{ - intn attached; /* how many access records refer to this elt */ - int32 aid; /* Access id of chunk table i.e. Vdata */ - - /* chunked element format header fields */ - int32 sp_tag_header_len; /* length of the special element header */ - uint8 version; /* Version of this Chunked element */ - int32 flag; /* flag for multiply specialness ...*/ - int32 length; /* the actual length of the data elt */ - int32 chunk_size; /* the logical size of the chunks */ - int32 nt_size; /* number type size i.e. size of data type */ - uint16 chktbl_tag; /* DFTAG_VH - Vdata header */ - uint16 chktbl_ref; /* ref of the first chunk table structure(VDATA) */ - uint16 sp_tag; /* For future use.. */ - uint16 sp_ref; /* For future use.. */ - int32 ndims; /* number of dimensions of chunk */ - DIM_REC *ddims; /* array of dimension records */ - int32 fill_val_len; /* fill value number of bytes */ - VOID *fill_val; /* fill value */ - /* For each specialness, only one for now SPECIAL_COMP */ - int32 comp_sp_tag_head_len; /* Compression header length */ - VOID *comp_sp_tag_header; /* compression header */ - - /* For Compression info */ - comp_coder_t comp_type; /* Compression type */ - comp_model_t model_type; /* Compression model type */ - comp_info *cinfo; /* Compression info struct */ - model_info *minfo; /* Compression model info struct */ - - /* additional memory resident data structures to be used */ - int32 *seek_chunk_indices; /* chunk array indicies relative - to the other chunks */ - int32 *seek_pos_chunk; /* postion within the current chunk */ - int32 *seek_user_indices; /* user postion within the element */ - TBBT_TREE *chk_tree; /* TBBT tree of all accessed table entries - i.e. CHUNK_REC's read/written/modified */ - MCACHE *chk_cache; /* chunk cache */ - int32 num_recs; /* number of Table(Vdata) records */ -} -chunkinfo_t; -#endif /* _HCHUNKS_MAIN_ */ - -#if defined c_plusplus || defined __cplusplus -extern "C" -{ -#endif /* c_plusplus || __cplusplus */ - -/* -** from hchunks.c -*/ - -/* User Public */ - HDFLIBAPI int32 HMCcreate - (int32 file_id, /* IN: file to put linked chunk element in */ - uint16 tag, /* IN: tag of element */ - uint16 ref, /* IN: ref of element */ - uint8 nlevels, /* IN: number of levels of chunks */ - int32 fill_val_len, /* IN: fill value length in bytes */ - VOID *fill_val, /* IN: fill value */ - HCHUNK_DEF *chk_array /* IN: structure describing chunk distribution - can be an array? but we only handle 1 level */); - - HDFLIBAPI int32 HMCgetcompress - (accrec_t* access_rec, /* IN: access record */ - comp_coder_t* comp_type, /* OUT: compression type */ - comp_info* c_info /* OUT: retrieved compression info */); - - HDFLIBAPI int32 HMCsetMaxcache - (int32 access_id, /* IN: access aid to mess with */ - int32 maxcache, /* IN: max number of pages to cache */ - int32 flags /* IN: flags = 0, HMC_PAGEALL */); - - HDFLIBAPI int32 HMCwriteChunk - (int32 access_id, /* IN: access aid to mess with */ - int32 *origin, /* IN: origin of chunk to write */ - const VOID *datap /* IN: buffer for data */); - - HDFLIBAPI int32 HMCreadChunk - (int32 access_id, /* IN: access aid to mess with */ - int32 *origin, /* IN: origin of chunk to read */ - VOID *datap /* IN: buffer for data */); - - HDFLIBAPI int32 HMCPcloseAID - (accrec_t *access_rec /* IN: access record of file to close */); - -/* Library Private */ -#ifdef _HCHUNKS_MAIN_ - /* tbbt.h helper routines */ - intn chkcompare(void * k1, /* IN: first key */ - void * k2, /* IN: second key */ - intn cmparg /* IN: not sure? */); - void chkfreekey(void * key /*IN: chunk key */ ); - void chkdestroynode(void * n /* IN: chunk record */ ); - -/* Private to 'hchunks.c' */ - extern int32 HMCPstread - (accrec_t *access_rec /* IN: access record to fill in */); - - extern int32 HMCPstwrite - (accrec_t *access_rec /* IN: access record to fill in */); - - extern int32 HMCPseek - (accrec_t *access_rec, /* IN: access record to mess with */ - int32 offset, /* IN: seek offset */ - int origin /* IN: where we should calc the offset from */); - - extern int32 HMCPchunkread - (VOID *cookie, /* IN: access record to mess with */ - int32 chunk_num, /* IN: chunk to read */ - VOID *datap /* OUT: buffer for data */); - - extern int32 HMCPread - (accrec_t * access_rec, /* IN: access record to mess with */ - int32 length, /* IN: number of bytes to read */ - void * data /* OUT: buffer for data */); - - extern int32 HMCPchunkwrite - (VOID *cookie, /* IN: access record to mess with */ - int32 chunk_num, /* IN: chunk number */ - const VOID *datap /* IN: buffer for data */); - - extern int32 HMCPwrite - (accrec_t *access_rec, /* IN: access record to mess with */ - int32 length, /* IN: number of bytes to write */ - const void * data /* IN: buffer for data */); - - extern intn HMCPendaccess - (accrec_t *access_rec /* IN: access record to close */); - - extern int32 HMCPinfo - (accrec_t *access_rec, /* IN: access record of access elemement */ - sp_info_block_t *info_chunk /* OUT: information about the special element */); - - extern int32 HMCPinquire - (accrec_t * access_rec, /* IN: access record to return info about */ - int32 *pfile_id, /* OUT: file ID; */ - uint16 *ptag, /* OUT: tag of info record; */ - uint16 *pref, /* OUT: ref of info record; */ - int32 *plength, /* OUT: length of element; */ - int32 *poffset, /* OUT: offset of element -- meaningless */ - int32 *pposn, /* OUT: current position in element; */ - int16 *paccess, /* OUT: access mode; */ - int16 *pspecial /* OUT: special code; */); - - extern int32 HMCPgetnumrecs - (accrec_t * access_rec, /* IN: access record to return info about */ - int32 *num_recs /* OUT: length of the chunked elt */); - -#endif /* _HCHUNKS_MAIN_ */ - -#if defined c_plusplus || defined __cplusplus -} -#endif /* c_plusplus || __cplusplus */ - -#ifndef _HCHUNKS_MAIN_ -/* not in master file hchunk.c */ -extern funclist_t chunked_funcs; /* functions to perform chunking */ - -#else /* in hchunks.c */ - -/* the accessing special function table for chunks */ -funclist_t chunked_funcs = -{ - HMCPstread, - HMCPstwrite, - HMCPseek, - HMCPinquire, - HMCPread, - HMCPwrite, - HMCPendaccess, - HMCPinfo, - NULL /* no routine registerd */ -}; - -#endif - -#endif /* __HCHUNKS_H */ diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/hcomp.h b/Utilities/CAI/cai_dll/inc/inc_hdf/hcomp.h deleted file mode 100755 index 35c38488b9ff6fe89ef0e09ee7d9a70aa7fe0bac..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/hcomp.h +++ /dev/null @@ -1,143 +0,0 @@ -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -/* $Id$ */ - -/*----------------------------------------------------------------------------- - * File: hcomp.h - * Purpose: header file for compression information & structures - * Dependencies: should be included after hdf.h - * Invokes: - * Contents: - * Structure definitions: comp_info - * Constant definitions: lots... - *---------------------------------------------------------------------------*/ - -/* avoid re-inclusion */ -#ifndef __HCOMP_H -#define __HCOMP_H - -/* For determining which type of modeling is being done */ -typedef enum - { - COMP_MODEL_STDIO = 0 /* for Standard C I/O model */ - } -comp_model_t; - -/* For determining which type of encoding is being done */ -typedef enum - { - COMP_CODE_NONE = 0, /* don't encode at all, just store */ - COMP_CODE_RLE, /* for simple RLE encoding */ - COMP_CODE_NBIT, /* for N-bit encoding */ - COMP_CODE_SKPHUFF, /* for Skipping huffman encoding */ - COMP_CODE_DEFLATE, /* for gzip 'deflate' encoding */ - COMP_CODE_SZIP, /* for szip encoding */ - COMP_CODE_INVALID, /* invalid last code, for range checking */ - COMP_CODE_JPEG /* _Ugly_ hack to allow JPEG images to be created with GRsetcompress */ - } -comp_coder_t; - -/* Compression types available */ -#define COMP_NONE 0 -#define COMP_JPEG 2 -#define COMP_RLE 11 -#define COMP_IMCOMP 12 - -/* Compression encoder/decoder configuration */ -#define COMP_DECODER_ENABLED 1 -#define COMP_ENCODER_ENABLED 2 - -#ifndef COMPRESS_MASTER -extern uint16 compress_map[]; -#else -uint16 compress_map[COMP_MAX_COMP + 1] = -{ /* Mapping from compression types to tags */ - 0, /* No corresponding tag for un-compressed data */ - 0, /* (1) */ - DFTAG_JPEG5, /* COMP_JPEG -> DFTAG_JPEG5 (for JPEG compression) */ - 0, /* (3) */ - 0, /* (4) */ - 0, /* (5) */ - 0, /* (6) */ - 0, /* (7) */ - 0, /* (8) */ - 0, /* (9) */ - 0, /* (10) */ - DFTAG_RLE, /* COMP_RLE -> DFTAG_RLE (for Run-length compression) */ - DFTAG_IMC /* COMP_IMCOMP -> DFTAG_IMC (for IMCOMP compression) */ -}; -#endif - -typedef union tag_model_info - { /* Union to contain modeling information */ - struct - { - int32 nt; /* number type */ - intn ndim; /* number of dimensions */ - int32 *dims; /* array of dimensions */ - } - dim; - } -model_info; - -typedef union tag_comp_info - { /* Union to contain compression information */ - struct - { /* Struct to contain information about how to compress */ - /* or decompress a JPEG encoded 24-bit image */ - intn quality; /* Quality factor for JPEG compression, should be from */ - /* 0 (terrible) to 100 (very good) */ - intn force_baseline; /* If force_baseline is set to TRUE then */ - /* quantization tables are limited to */ - /* 0..255 for JPEG baseline compability */ - /* This is only an issue for quality */ - /* settings below 24 */ - } - jpeg; - struct - { /* struct to contain information about how to compress */ - /* or decompress a N-bit encoded dataset */ - int32 nt; /* number type of the data to encode */ - intn sign_ext; /* whether to sign extend or not */ - intn fill_one; /* whether to fill with 1's or 0's */ - intn start_bit; /* offset of the start bit in the data */ - intn bit_len; /* number of bits to store */ - } - nbit; - struct - { /* struct to contain info about how to compress */ - /* or decompress a "skipping" huffman encoded dataset */ - intn skp_size; /* size of the individual elements when skipping */ - } - skphuff; - struct - { /* struct to contain info about how to compress */ - /* or decompress a gzip encoded dataset */ - intn level; /* how hard to work when compressing the data */ - } - deflate; - struct - { - int32 options_mask; /* IN */ - int32 pixels_per_block; /* IN */ - int32 pixels_per_scanline; /* OUT: computed */ - int32 bits_per_pixel; /* OUT: size of NT */ - int32 pixels; /* OUT: size of dataset or chunk */ - } - szip; /* for szip encoding */ - - } -comp_info; - -#endif /* __HCOMP_H */ - diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/hcompi.h b/Utilities/CAI/cai_dll/inc/inc_hdf/hcompi.h deleted file mode 100755 index 99606c46dcc040280eb923247a0933973cecf827..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/hcompi.h +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -/* $Id$ */ - -/*----------------------------------------------------------------------------- - * File: hcompi.h - * Purpose: Internal library header file for compression information - * Dependencies: should be included after hdf.h - * Invokes: - * Contents: - * Structure definitions: - * Constant definitions: - *---------------------------------------------------------------------------*/ - -/* avoid re-inclusion */ -#ifndef __HCOMPI_H -#define __HCOMPI_H - -#include "hfile.h" - -/* Modeling information */ - -/* structure for storing modeling information */ -/* only allow modeling and master compression routines access */ - -#include "mstdio.h" /* stdio modeling header */ - -typedef struct comp_model_info_tag - { - comp_model_t model_type; /* model this stream is using */ - union - { /* union of all the different types of model information */ - comp_model_stdio_info_t stdio_info; /* stdio model info */ - } - model_info; - funclist_t model_funcs; /* functions to perform modeling */ - } -comp_model_info_t; - -/* Coding information */ - -/* structure for storing modeling information */ -/* only allow encoding and master compression routines access */ - -#include "cnone.h" /* no encoding header */ -#include "crle.h" /* run-length encoding header */ -#include "cnbit.h" /* N-bit encoding header */ -#include "cskphuff.h" /* Skipping huffman encoding header */ -#include "cdeflate.h" /* gzip 'deflate' encoding header */ -#include "cszip.h" /* szip encoding header */ - -typedef struct comp_coder_info_tag - { - comp_coder_t coder_type; /* coding scheme this stream is using */ - union - { /* union of all the different types of coding information */ - comp_coder_none_info_t none_info; /* "None" coding info */ - comp_coder_rle_info_t rle_info; /* RLE coding info */ - comp_coder_nbit_info_t nbit_info; /* N-bit coding info */ - comp_coder_skphuff_info_t skphuff_info; /* Skipping huffman coding info */ - comp_coder_deflate_info_t deflate_info; /* gzip 'deflate' coding info */ - comp_coder_szip_info_t szip_info; /* szip coding info */ - - } - coder_info; - funclist_t coder_funcs; /* functions to perform encoding */ - } -comp_coder_info_t; - -/* structure for storing a state */ -typedef struct comp_stateinfo_tag - { - uint32 d_offset; /* the offset of the state in the dataset */ - uint32 c_offset; /* offset of the state in the compressed data */ - comp_model_info_t minfo; /* modeling information */ - comp_coder_info_t cinfo; /* coding information */ - } -comp_stateinfo_t; - -/* structure for storing state caching information */ -typedef struct comp_state_cache_tag - { - intn num_states; /* the number of states cached */ - comp_stateinfo_t **comp_state; /* pointer to an array of pointers to - compression states */ - } -comp_state_cache_t; - -/* compinfo_t -- compressed element information structure */ -typedef struct compinfo_tag - { - intn attached; /* number of access records attached - to this information structure */ - int32 length; /* the actual length of the data elt */ - uint16 comp_ref; /* compressed info ref. number */ - int32 aid; /* AID of the compressed info */ - comp_model_info_t minfo; /* modeling information */ - comp_coder_info_t cinfo; /* coding information */ - intn caching; /* whether caching is turned on */ - comp_state_cache_t sinfo; /* state information for caching */ - } -compinfo_t; - -#endif /* __HCOMPI_H */ diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/hconv.h b/Utilities/CAI/cai_dll/inc/inc_hdf/hconv.h deleted file mode 100755 index ec9132441eef1dda1d4fc12564453f359c188c89..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/hconv.h +++ /dev/null @@ -1,272 +0,0 @@ - -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -/* $Id$ */ - -/*----------------------------------------------------------------------------- - * File: hconv.h - * Purpose: header file for data conversion information & structures - * Invokes: - * Contents: - * Structure definitions: - * Constant definitions: lots... - *---------------------------------------------------------------------------*/ - -/* avoid re-inclusion */ -#ifndef _HCONV_H -#define _HCONV_H - -#ifndef VMS -#define DUFF -#else -#ifdef DUFF -#undef DUFF -#endif -#endif -#ifdef DUFF -#define DUFF_sb4b - -#define DUFF_ui2i -#define DUFF_ui2s -#define DUFF_uo2i -#define DUFF_ui4i -#define DUFF_ui4s -#define DUFF_uo4i -#define DUFF_ui4f -#define DUFF_uo4f -#define DUFF_ui8f -#define DUFF_uo8f - -#define DUFF_lui2i -#define DUFF_lui2s -#define DUFF_luo2i -#define DUFF_lui4i -#define DUFF_lui4s -#define DUFF_luo4i -#define DUFF_lui4f -#define DUFF_luo4f -#define DUFF_lui8f -#define DUFF_luo8f -#endif - -/*****************************************************************************/ -/* CONSTANT DEFINITIONS */ -/*****************************************************************************/ -/* Generally Big-Endian machines */ -#if !defined(VMS) && !defined(INTEL86) && !defined(MIPSEL) && !defined(DEC_ALPHA) && !defined(I860) && !defined(SUN386) && !defined(__ia64) && !defined(__x86_64__) -# if !defined(UNICOS) -# define UI8_IN DFKnb1b /* Unsigned Integer, 8 bits */ -# define UI8_OUT DFKnb1b -# if defined(CRAYMPP) -# define SI16_IN DFKmi2s -# define SI16_OUT DFKmo2b -# define UI16_IN DFKmi2i -# define UI16_OUT DFKmo2b -# else -# define SI16_IN DFKnb2b /* S = Signed */ -# define SI16_OUT DFKnb2b -# define UI16_IN DFKnb2b -# define UI16_OUT DFKnb2b -# endif -# define SI32_IN DFKnb4b -# define SI32_OUT DFKnb4b -# define UI32_IN DFKnb4b -# define UI32_OUT DFKnb4b -# if defined(CONVEXNATIVE) -# define F32_IN DFKci4f /* CONVEX stuff */ -# define F32_OUT DFKco4f -# define F64_IN DFKci8f -# define F64_OUT DFKco8f -# elif defined(VP) -# define F32_IN DFKpi4f /* Fujitsu VP stuff */ -# define F32_OUT DFKpo4f -# define F64_IN DFKpi8f -# define F64_OUT DFKpo8f -# else /* !CONVEXNATIVE */ -# define F32_IN DFKnb4b /* Float, 32 bits */ -# define F32_OUT DFKnb4b -# define F64_IN DFKnb8b -# define F64_OUT DFKnb8b -# endif /* CONVEXNATIVE */ - -# define LUI8_IN DFKnb1b /* Little Endian Unsigned Integer, 8 bits */ -# define LUI8_OUT DFKnb1b -# if defined(CRAYMPP) -# define LSI16_IN DFKlmi2s -# define LSI16_OUT DFKlmo2b -# define LUI16_IN DFKlmi2i -# define LUI16_OUT DFKlmo2b -# else -# define LSI16_IN DFKsb2b -# define LSI16_OUT DFKsb2b -# define LUI16_IN DFKsb2b -# define LUI16_OUT DFKsb2b -# endif -# define LSI32_IN DFKsb4b -# define LSI32_OUT DFKsb4b -# define LUI32_IN DFKsb4b -# define LUI32_OUT DFKsb4b -# if defined(CONVEXNATIVE) -# define LF32_IN DFKlci4f /* CONVEX little-endian routines */ -# define LF32_OUT DFKlco4f -# define LF64_IN DFKlci8f -# define LF64_OUT DFKlco8f -# elif defined(VP) -# define LF32_IN DFKlpi4f /* Fujitsu VP little-endian routines */ -# define LF32_OUT DFKlpo4f -# define LF64_IN DFKlpi8f -# define LF64_OUT DFKlpo8f -# else /* !CONVEXNATIVE */ -# define LF32_IN DFKsb4b -# define LF32_OUT DFKsb4b -# define LF64_IN DFKsb8b -# define LF64_OUT DFKsb8b -# endif /* CONVEXNATIVE */ - -# else /* UNICOS */ -# define UI8_IN DFKnb1b /* Big-Endian IEEE support */ -# define UI8_OUT DFKnb1b -# define SI16_IN DFKui2s -# define SI16_OUT DFKuo2s -# define UI16_IN DFKui2i -# define UI16_OUT DFKuo2i -# define SI32_IN DFKui4s -# define SI32_OUT DFKuo4s -# define UI32_IN DFKui4i -# define UI32_OUT DFKuo4i -# define F32_IN DFKui4f -# define F32_OUT DFKuo4f -# define F64_IN DFKui8f -# define F64_OUT DFKuo8f - -# define LUI8_IN DFKnb1b /* Little-endian IEEE support */ -# define LUI8_OUT DFKnb1b -# define LSI16_IN DFKlui2s -# define LSI16_OUT DFKluo2s -# define LUI16_IN DFKlui2i -# define LUI16_OUT DFKluo2i -# define LSI32_IN DFKlui4s -# define LSI32_OUT DFKluo4s -# define LUI32_IN DFKlui4i -# define LUI32_OUT DFKluo4i -# define LF32_IN DFKlui4f -# define LF32_OUT DFKluo4f -# define LF64_IN DFKlui8f -# define LF64_OUT DFKluo8f - -# endif /* !UNICOS */ -#else /* must be VMS || INTEL86 || MIPSEL || DEC_ALPHA || I860 || SUN386 || IA64 || Linux64 (Generally, little-endian machines */ -# define UI8_IN DFKnb1b /* Big-Endian IEEE support */ -# define UI8_OUT DFKnb1b /* The s in DFKsb2b is for swap */ -# define SI16_IN DFKsb2b -# define SI16_OUT DFKsb2b -# define UI16_IN DFKsb2b -# define UI16_OUT DFKsb2b -# define SI32_IN DFKsb4b -# define SI32_OUT DFKsb4b -# define UI32_IN DFKsb4b -# define UI32_OUT DFKsb4b -# if defined(VMS) -# define F32_IN DFKvi4f -# define F32_OUT DFKvo4f -# define F64_IN DFKvi8f -# define F64_OUT DFKvo8f -# else /* !VMS */ -# define F32_IN DFKsb4b -# define F32_OUT DFKsb4b -# define F64_IN DFKsb8b -# define F64_OUT DFKsb8b -# endif /* VMS */ - -# define LUI8_IN DFKnb1b /* Little-Endian IEEE support */ -# define LUI8_OUT DFKnb1b -# define LSI16_IN DFKnb2b -# define LSI16_OUT DFKnb2b -# define LUI16_IN DFKnb2b -# define LUI16_OUT DFKnb2b -# define LSI32_IN DFKnb4b -# define LSI32_OUT DFKnb4b -# define LUI32_IN DFKnb4b -# define LUI32_OUT DFKnb4b -# if defined(VMS) -# define LF32_IN DFKlvi4f -# define LF32_OUT DFKlvo4f -# define LF64_IN DFKlvi8f -# define LF64_OUT DFKlvo8f -# else /* !VMS */ -# define LF32_IN DFKnb4b -# define LF32_OUT DFKnb4b -# define LF64_IN DFKnb8b -# define LF64_OUT DFKnb8b -# endif /* VMS */ - -#endif /* !VMS && !INTEL86 && !MIPS && !DEC_ALPHA && !I860 && !SUN386 && !IA64 && !Linux64*/ - -/* All Machines (except the Cray) currently use the same routines */ -/* for Native mode "conversions" */ -#ifndef UNICOS -# define NUI8_IN DFKnb1b -# define NUI8_OUT DFKnb1b -# if defined(CRAYMPP) -# define NSI16_IN DFKmi2s -# define NSI16_OUT DFKmo2b -# define NUI16_IN DFKmi2i -# define NUI16_OUT DFKmo2b -# else -# define NSI16_IN DFKnb2b -# define NSI16_OUT DFKnb2b -# define NUI16_IN DFKnb2b -# define NUI16_OUT DFKnb2b -# endif -# define NSI32_IN DFKnb4b -# define NSI32_OUT DFKnb4b -# define NUI32_IN DFKnb4b -# define NUI32_OUT DFKnb4b -# define NF32_IN DFKnb4b -# define NF32_OUT DFKnb4b -# define NF64_IN DFKnb8b -# define NF64_OUT DFKnb8b -#else /* UNICOS */ -# define NUI8_IN DFKnb1b -# define NUI8_OUT DFKnb1b -# define NSI16_IN DFKnb8b -# define NSI16_OUT DFKnb8b -# define NUI16_IN DFKnb8b -# define NUI16_OUT DFKnb8b -# define NSI32_IN DFKnb8b -# define NSI32_OUT DFKnb8b -# define NUI32_IN DFKnb8b -# define NUI32_OUT DFKnb8b -# define NF32_IN DFKnb8b -# define NF32_OUT DFKnb8b -# define NF64_IN DFKnb8b -# define NF64_OUT DFKnb8b -#endif /* UNICOS */ - -/*****************************************************************************/ -/* STRUCTURE DEFINTIONS */ -/*****************************************************************************/ -union fpx - { - float f; - long l; - }; - -union float_uint_uchar - { - float32 f; - int32 i; - unsigned char c[4]; - }; - -#endif /* _HCONV_H */ diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/hdf2netcdf.h b/Utilities/CAI/cai_dll/inc/inc_hdf/hdf2netcdf.h deleted file mode 100755 index f0438d2b8eec3e59ed07b3bb41a57364ef1878e2..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/hdf2netcdf.h +++ /dev/null @@ -1,56 +0,0 @@ -/* $Id$ */ - -/* If we disable the HDF version of the netCDF API (ncxxx interface) - (-DHAVE_NETCDF) we need to rename all the relevant function names - In this version we exclude renaming the netCDF fortran API so - the MFHDF side must be compilied without fortran support. */ -#ifdef HAVE_NETCDF -#define HNAME(x) sd_##x /* pre-append 'sd_' to all netCDF fcn names */ -#else /* !HAVE_NETCDF i.e USING HDF NETCDF */ -#define HNAME(x) x -#endif /* !HAVE_NETCDF i.e. USING HDF NETCDF */ - -/* If using the real netCDF library and API (use -DHAVE_NETCDF) - need to mangle the HDF versions of netCDF API function names - to not conflict w/ oriinal netCDF ones */ -#ifdef HAVE_NETCDF -#define ncerr HNAME(ncerr) -#define ncopts HNAME(ncopts) -#define nccreate HNAME(nccreate) -#define ncopen HNAME(ncopen) -#define ncredef HNAME(ncredef) -#define ncendef HNAME(ncendef) -#define ncclose HNAME(ncclose) -#define ncinquire HNAME(ncinquire) -#define ncsync HNAME(ncsync) -#define ncabort HNAME(ncabort) -#define ncdimdef HNAME(ncdimdef) -#define ncdimid HNAME(ncdimid) -#define ncdiminq HNAME(ncdiminq) -#define ncdimrename HNAME(ncdimrename) -#define ncvardef HNAME(ncvardef) -#define ncvarid HNAME(ncvarid) -#define ncvarinq HNAME(ncvarinq) -#define ncvarput1 HNAME(ncvarput1) -#define ncvarget1 HNAME(ncvarget1) -#define ncvarput HNAME(ncvarput) -#define ncvarget HNAME(ncvarget) -#define ncvarputs HNAME(ncvarputs) -#define ncvargets HNAME(ncvargets) -#define ncvarputg HNAME(ncvarputg) -#define ncvargetg HNAME(ncvargetg) -#define ncvarrename HNAME(ncvarrename) -#define ncattput HNAME(ncattput) -#define ncattinq HNAME(ncattinq) -#define ncattget HNAME(ncattget) -#define ncattcopy HNAME(ncattcopy) -#define ncattname HNAME(ncattname) -#define ncattrename HNAME(ncattrename) -#define ncattdel HNAME(ncattdel) -#define nctypelen HNAME(nctypelen) -#define ncsetfill HNAME(ncsetfill) -#define ncrecinq HNAME(ncrecinq) -#define ncrecget HNAME(ncrecget) -#define ncrecput HNAME(ncrecput) -#define ncnobuf HNAME(ncnobuf) /* no prototype for this one */ -#endif /* HAVE_NETCDF i.e NOT USING HDF version of netCDF API */ diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/herr.h b/Utilities/CAI/cai_dll/inc/inc_hdf/herr.h deleted file mode 100755 index 93d983d06f5d1623984c93bf55b21f6a084ab636..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/herr.h +++ /dev/null @@ -1,457 +0,0 @@ -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -/* $Id$ */ - -/*+ herr.h - *** header file for using error routines - *** to be included by all ".c" files - + */ - -#ifndef __HERR_H -#define __HERR_H - -/* if these symbols are not provided by the compiler, we'll have to - fake them. These are used in HERROR for recording location of - error in code. */ - -#ifndef __FILE__ -# define __FILE__ "File name not supported" -#endif -#ifndef __LINE__ -# define __LINE__ 0 -#endif - -/* HERROR macro, used to facilitate error reporting. Assumes that - there's a variable called FUNC which holds the function name. - Assume that func and file are both stored in static space, or at - least be not corrupted in the meanwhile. */ - -#define HERROR(e) HEpush(e, FUNC, __FILE__, __LINE__) - -/* HRETURN_ERROR macro, used to facilitate error reporting. Makes - same assumptions as HERROR. IN ADDITION, this macro causes - a return from the calling routine */ - -#define HRETURN_ERROR(err, ret_val) {HERROR(err); return(ret_val);} - -/* HCLOSE_RETURN_ERROR macro, used to facilitate error reporting. Makes - same assumptions as HRETURN_ERROR. IN ADDITION, this macro causes - the file specified by the id "fid" to be closed */ - -#define HCLOSE_RETURN_ERROR(hfid, err, ret_val) {HERROR(err); Hclose(hfid); \ - return(ret_val);} - -/* HGOTO_ERROR macro, used to facilitate error reporting. Makes - same assumptions as HERROR. IN ADDITION, this macro causes - a jump to the label 'done' which should be in every fucntion - Also there is an assumption of a variable 'ret_value' */ - -#define HGOTO_ERROR(err, ret_val) {HERROR(err); ret_value = ret_val; \ - goto done;} - -/* HCLOSE_RETURN_ERROR macro, used to facilitate error reporting. Makes - same assumptions as HRETURN_ERROR. IN ADDITION, this macro causes - the file specified by the id "fid" to be closed - Also , this macro causes a jump to the label 'done' which should - be in every fucntion. There is an assumption of a variable 'ret_value' */ - -#define HCLOSE_GOTO_ERROR(hfid, err, ret_val) {HERROR(err); Hclose(hfid); \ - ret_value = ret_val; goto done;} - -/* HGOTO_DONE macro, used to facilitate the new error reporting model. - This macro is just a wrapper to set the return value and jump to the 'done' - label. Also assumption of a variable 'ret_value' */ - -#define HGOTO_DONE(ret_val) {ret_value = ret_val; goto done;} - -/* For further error reporting */ -#define HE_REPORT(msg) HEreport(msg) -#define HE_REPORT_RETURN(msg, ret_val) { HEreport(msg); return(ret_val); } -#define HE_CLOSE_REPORT_RETURN(hfid,msg, ret_val) { HEreport(msg); \ - Hclose(hfid); \ - return(ret_val);} - -#define HE_REPORT_GOTO(msg, ret_val) { HEreport(msg); ret_value = ret_val; \ - goto done;} -#define HE_CLOSE_REPORT_GOTO(hfid,msg, ret_val) { HEreport(msg); \ - Hclose(hfid); \ - ret_value = ret_val; \ - goto done;} - - -/* always points to the next available slot; the last error record is in slot (top-1) */ -#ifndef _H_ERR_MASTER_ -#if defined WIN32 && defined HDFAPDLL -__declspec(dllimport) -#else -extern -#endif -#else -#if defined WIN32 && defined HDFLIBDLL -__declspec(dllexport) -#endif -#endif /* _H_ERR_MASTER_ */ -int32 error_top -#ifdef _H_ERR_MASTER_ -= 0 -#endif /* _H_ERR_MASTER_ */ -; - -/* Macro to wrap around calls to HEPclear, so it doesn't get called zillions of times */ -#define HEclear() {if(error_top!=0) HEPclear(); } - -/* - ====================================================================== - Error codes - - NOTE: Remember to update the error_messages[] structure in herr.c - whenever errors are added/deleted from this list. - ====================================================================== - */ -/* Declare an enumerated type which holds all the valid HDF error codes */ -typedef enum - { - DFE_NONE = 0, /* special zero, no error */ -/* Low-level I/O errors */ - DFE_FNF, /* File not found */ - DFE_DENIED, /* Access to file denied */ - DFE_ALROPEN, /* File already open */ - DFE_TOOMANY, /* Too Many AID's or files open */ - DFE_BADNAME, /* Bad file name on open */ - DFE_BADACC, /* Bad file access mode */ - DFE_BADOPEN, /* Other open error */ - DFE_NOTOPEN, /* File can't be closed 'cause it isn't open */ - DFE_CANTCLOSE, /* fclose wouldn't work! */ - DFE_READERROR, /* There was a read error */ - DFE_WRITEERROR, /* There was a write error */ - DFE_SEEKERROR, /* There was a seek error */ - DFE_RDONLY, /* The DF is read only */ - DFE_BADSEEK, /* Attempt to seek past end of element */ - -/* Low-level HDF I/O errors */ - DFE_PUTELEM, /* Hputelement failed in some way */ - DFE_GETELEM, /* Hgetelement failed in some way */ - DFE_CANTLINK, /* Can't initialize link information */ - DFE_CANTSYNC, /* Cannot syncronize memory with file */ - -/* Old group interface errors */ - DFE_BADGROUP, /* Error from DFdiread in opening a group */ - DFE_GROUPSETUP, /* Error from DFdisetup in opening a group */ - DFE_PUTGROUP, /* Error when putting a tag/ref into a group */ - DFE_GROUPWRITE, /* Error when writing out a group */ - -/* Internal HDF errors */ - DFE_DFNULL, /* DF is a null pointer */ - DFE_ILLTYPE, /* DF has an illegal type: internal error */ - DFE_BADDDLIST, /* The DD list is non-existent: internal error */ - DFE_NOTDFFILE, /* This is not a DF file and it is not 0 length */ - DFE_SEEDTWICE, /* The DD list already seeded: internal error */ - DFE_NOSUCHTAG, /* No such tag in the file: search failed */ - DFE_NOFREEDD, /* There are no free DD's left: internal error */ - DFE_BADTAG, /* illegal WILDCARD tag */ - DFE_BADREF, /* illegal WILDCARD reference # */ - DFE_NOMATCH, /* No (more) DDs which match specified tag/ref */ - DFE_NOTINSET, /* Warning: Set contained unknown tag: ignored */ - DFE_BADOFFSET, /* Illegal offset specified */ - DFE_CORRUPT, /* File is corrupted */ - DFE_NOREF, /* no more reference numbers are available */ - DFE_DUPDD, /* the new tag/ref is already used */ - DFE_CANTMOD, /* old element not exist, cannot modify */ - DFE_DIFFFILES, /* Attempt to merge objs in diff files */ - DFE_BADAID, /* Got a bogus aid */ - DFE_OPENAID, /* There are still active AIDs */ - DFE_CANTFLUSH, /* Can't flush DD back to file */ - DFE_CANTUPDATE, /* Cannot update the DD block */ - DFE_CANTHASH, /* Cannot add a DD to the hash table */ - DFE_CANTDELDD, /* Cannot delete a DD in the file */ - DFE_CANTDELHASH, /* Cannot delete a DD from the hash table */ - DFE_CANTACCESS, /* Cannot access specified tag/ref */ - DFE_CANTENDACCESS, /* Cannot end access to data element */ - DFE_TABLEFULL, /* Access table is full */ - DFE_NOTINTABLE, /* Cannot find element in table */ - -/* Generic errors */ - DFE_UNSUPPORTED, /* Feature not currently supported */ - DFE_NOSPACE, /* Malloc failed */ - DFE_BADCALL, /* Calls in wrong order */ - DFE_BADPTR, /* NULL ptr argument */ - DFE_BADLEN, /* Invalid len specified */ - DFE_NOTENOUGH, /* space provided insufficient for size of data */ - DFE_NOVALS, /* Values not available */ - DFE_ARGS, /* bad arguments to routine */ - DFE_INTERNAL, /* serious internal error */ - DFE_NORESET, /* Too late to modify this value */ - DFE_GENAPP, /* Generic application,level error */ - -/* Generic interface errors */ - DFE_UNINIT, /* Interface was not initialized correctly */ - DFE_CANTINIT, /* Can't initialize an interface we depend on */ - DFE_CANTSHUTDOWN, /* Can't shut down an interface we depend on */ - -/* General Dataset errors */ - DFE_BADDIM, /* negative or zero dimensions specified */ - DFE_BADFP, /* File contained an illegal floating point num */ - DFE_BADDATATYPE, /* unknown or unavailable data type specified */ - DFE_BADMCTYPE, /* unknown or unavailable machine type specified */ - DFE_BADNUMTYPE, /* unknown or unavailable number type specified */ - DFE_BADORDER, /* unknown or illegal array order specified */ - DFE_RANGE, /* improper range for attempted acess */ - DFE_BADCONV, /* Don't know how to convert data type */ - DFE_BADTYPE, /* Incompatible types specified */ - -/* Compression errors */ - DFE_BADSCHEME, /* Unknown compression scheme specified */ - DFE_BADMODEL, /* Invalid compression model specified */ - DFE_BADCODER, /* Invalid compression encoder specified */ - DFE_MODEL, /* Error in modeling layer of compression */ - DFE_CODER, /* Error in encoding layer of compression */ - DFE_CINIT, /* Error in encoding initialization */ - DFE_CDECODE, /* Error in decoding compressed data */ - DFE_CENCODE, /* Error in encoding compressed data */ - DFE_CTERM, /* Error in encoding termination */ - DFE_CSEEK, /* Error seekging in encoded dataset */ - DFE_MINIT, /* Error in modeling initialization */ - DFE_COMPINFO, /* Invalid compression header */ - DFE_CANTCOMP, /* Can't compress an object */ - DFE_CANTDECOMP, /* Can't de-compress an object */ - DFE_NOENCODER, /* Encoder not available */ - -/* Raster errors */ - DFE_NODIM, /* No dimension record associated with image */ - DFE_BADRIG, /* Error processing a RIG */ - DFE_RINOTFOUND, /* Can't find raster image */ - DFE_BADATTR, /* Bad Attribute */ - DFE_LUTNOTFOUND, /* No palette information for RIG */ - -/* SDG/NDG errors */ - DFE_BADTABLE, /* the nsdg table is wrong */ - DFE_BADSDG, /* error processing an sdg */ - DFE_BADNDG, /* error processing an ndg */ - -/* Vset errors */ - DFE_VGSIZE, /* Too many elements in VGroup */ - DFE_VTAB, /* Elmt not in vtab[] */ - DFE_CANTADDELEM, /* Cannot add tag/ref to VGroup */ - DFE_BADVGNAME, /* Cannot set VGroup name */ - DFE_BADVGCLASS, /* Cannot set VGroup class */ - -/* Vdata errors */ - DFE_BADFIELDS, /* Bad fields string passed to Vset routine */ - DFE_NOVS, /* Counldn't find VS in file */ - DFE_SYMSIZE, /* Too many symbols in users table */ - DFE_BADATTACH, /* Cannot write to a previously attached VData */ - DFE_BADVSNAME, /* Cannot set VData name */ - DFE_BADVSCLASS, /* Cannot set VData class */ - DFE_VSWRITE, /* Error writing to VData */ - DFE_VSREAD, /* Error reading from VData */ - DFE_BADVH, /* Error in VData Header */ - DFE_FIELDSSET, /* Fields already set for vdata */ -/* High-level Vdata/Vset errors */ - DFE_VSCANTCREATE, /* Cannot create VData */ - DFE_VGCANTCREATE, /* Cannot create VGroup */ - -/* Generic Vdata/Vset errors */ - DFE_CANTATTACH, /* Cannot attach to a VData/Vset */ - DFE_CANTDETACH, /* Cannot detach a VData/Vset with access 'w' */ - -/* bit I/O errors */ - DFE_BITREAD, /* There was a bit-read error */ - DFE_BITWRITE, /* There was a bit-write error */ - DFE_BITSEEK, /* There was a bit-seek error */ - -/* tbbt interface errors */ - DFE_TBBTINS, /* Failed to insert element into tree */ - -/* bit-vector interface errors */ - DFE_BVNEW, /* Failed to create a bit-vector */ - DFE_BVSET, /* Failed when setting a bit in a bit-vector */ - DFE_BVGET, /* Failed when getting a bit in a bit-vector */ - DFE_BVFIND /* Failed when finding a bit in a bit-vector */ - } -hdf_err_code_t; - -#ifdef _H_ERR_MASTER_ - -/* error_messages is the list of error messages in the system, kept as - error_code-message pairs. To look up a message, a linear search is - required but efficiency should be okay. */ - -typedef struct error_messages_t - { - hdf_err_code_t error_code; - const char *str; - } -error_messages_t; - -PRIVATE const struct error_messages_t error_messages[] = -{ - {DFE_NONE, "No error"}, -/* Low-level I/O errors */ - {DFE_FNF, "File not found"}, - {DFE_DENIED, "Access to file denied"}, - {DFE_ALROPEN, "File already open"}, - {DFE_TOOMANY, "Too Many AID's or files open"}, - {DFE_BADNAME, "Bad file name on open"}, - {DFE_BADACC, "Bad file access mode"}, - {DFE_BADOPEN, "Error opening file"}, - {DFE_NOTOPEN, "File can't be closed; It isn't open"}, - {DFE_CANTCLOSE, "Unable to close file"}, - {DFE_READERROR, "Read error"}, - {DFE_WRITEERROR, "Write error"}, - {DFE_SEEKERROR, "Error performing seek operation"}, - {DFE_RDONLY, "Attempt to write to read-only HDF file"}, - {DFE_BADSEEK, "Attempt to seek past end of element"}, - -/* Low-level HDF I/O errors */ - {DFE_PUTELEM, "Hputelement failed in some way"}, - {DFE_GETELEM, "Hgetelement failed in some way"}, - {DFE_CANTLINK, "Can't initialize link information"}, - {DFE_CANTSYNC, "Cannot syncronize memory with file"}, - -/* Old group interface errors */ - {DFE_BADGROUP, "Error from DFdiread in opening a group"}, - {DFE_GROUPSETUP, "Error from DFdisetup in opening a group"}, - {DFE_PUTGROUP, "Error when putting a tag/ref into a group"}, - {DFE_GROUPWRITE, "Error when writing out a group"}, - -/* Internal HDF errors */ - {DFE_DFNULL, "DF has a null pointer"}, - {DFE_ILLTYPE, "Internal error: DF has an illegal type"}, - {DFE_BADDDLIST, "Internal error: The DD list is non-existent"}, - {DFE_NOTDFFILE, "This is not an HDF file"}, - {DFE_SEEDTWICE, "Internal error: The DD list is already seeded"}, - {DFE_NOSUCHTAG, "No such tag in the file: search failed"}, - {DFE_NOFREEDD, "There are no free DD's left"}, - {DFE_BADTAG, "Illegal WILDCARD tag"}, - {DFE_BADREF, "Illegal WILDCARD reference"}, - {DFE_NOMATCH, "No (more) DDs which match specified tag/ref"}, - {DFE_NOTINSET, "Set contained unknown tag: ignored"}, - {DFE_BADOFFSET, "Illegal offset specified"}, - {DFE_CORRUPT, "File is corrupted"}, - {DFE_NOREF, "No more reference numbers are available"}, - {DFE_DUPDD, "Tag/ref is already used"}, - {DFE_CANTMOD, "Old element does not exist, cannot modify"}, - {DFE_DIFFFILES, "Attempt to merge objects in different files"}, - {DFE_BADAID, "Unable to create a new AID"}, - {DFE_OPENAID, "There are still active AIDs"}, - {DFE_CANTFLUSH, "Cannot flush the changed DD back to the file"}, - {DFE_CANTUPDATE, "Cannot update the DD block"}, - {DFE_CANTHASH, "Cannot add a DD to the hash table"}, - {DFE_CANTDELDD, "Cannot delete a DD in the file"}, - {DFE_CANTDELHASH, "Cannot delete a DD from the hash table"}, - {DFE_CANTACCESS, "Cannot access specified tag/ref"}, - {DFE_CANTENDACCESS, "Cannot end access to data element"}, - {DFE_TABLEFULL, "Access table is full"}, - {DFE_NOTINTABLE, "Cannot find element in table"}, - -/* Generic errors */ - {DFE_UNSUPPORTED, "Feature not currently supported"}, - {DFE_NOSPACE, "Internal error: Out of space"}, - {DFE_BADCALL, "Calls in wrong order"}, - {DFE_BADPTR, "NULL ptr argument"}, - {DFE_BADLEN, "Invalid length specified"}, - {DFE_NOTENOUGH, "Space provided insufficient for size of data"}, - {DFE_NOVALS, "Values not available"}, - {DFE_ARGS, "Invalid arguments to routine"}, - {DFE_INTERNAL, "HDF Internal error"}, - {DFE_NORESET, "Can not reset this value"}, - {DFE_GENAPP, "Generic application-level error"}, - -/* Generic interface errors */ - {DFE_UNINIT, "Interface was not initialized correctly"}, - {DFE_CANTINIT, "Can't initialize an interface we depend on"}, - {DFE_CANTSHUTDOWN, "Can't shut down an interface we depend on"}, - -/* Dataset errors */ - {DFE_BADDIM, "Negative or zero dimensions specified"}, - {DFE_BADFP, "File contained an illegal floating point number"}, - {DFE_BADDATATYPE, "Unknown or unavailable data type specified"}, - {DFE_BADMCTYPE, "Unknown or unavailable machine type specified"}, - {DFE_BADNUMTYPE, "Unknown or unavailable number type specified"}, - {DFE_BADORDER, "Unknown or illegal array order specified"}, - {DFE_RANGE, "Improper range for attempted access"}, - {DFE_BADCONV, "Don't know how to convert data type"}, - {DFE_BADTYPE, "Incompatible type specified"}, - -/* Compression errors */ - {DFE_BADSCHEME, "Unknown compression scheme specified"}, - {DFE_BADMODEL, "Invalid compression model specified"}, - {DFE_BADCODER, "Invalid compression coder specified"}, - {DFE_MODEL, "Error in modeling layer of compression"}, - {DFE_CODER, "Error in encoding layer of compression"}, - {DFE_CINIT, "Error in encoding initialization"}, - {DFE_CDECODE, "Error in decoding compressed data"}, - {DFE_CENCODE, "Error in encoding compressed data"}, - {DFE_CTERM, "Error in encoding termination"}, - {DFE_CSEEK, "Error seeking in encoded dataset"}, - {DFE_MINIT, "Error in modeling initialization"}, - {DFE_COMPINFO, "Invalid compression header"}, - {DFE_CANTCOMP, "Can't compress an object"}, - {DFE_CANTDECOMP, "Can't de-compress an object"}, - {DFE_NOENCODER, "Encoder not available"}, - -/* Raster errors */ - {DFE_NODIM, "No dimension record associated with image"}, - {DFE_BADRIG, "Error processing a RIG"}, - {DFE_RINOTFOUND, "Can't find raster image"}, - {DFE_BADATTR, "Bad Attribute"}, - {DFE_LUTNOTFOUND, "No palette information for RIG"}, - -/* SDG/NDG errors */ - {DFE_BADTABLE, "The nsdg table is wrong"}, - {DFE_BADSDG, "Error processing an sdg"}, - {DFE_BADNDG, "Error processing an ndg"}, - -/* Vset errors */ - {DFE_VGSIZE, "No more elements will fit in this VGroup"}, - {DFE_VTAB, "Element is not in VSet tables"}, - {DFE_CANTADDELEM, "Cannot add tag/ref to VGroup"}, - {DFE_BADVGNAME, "Cannot set VGroup name"}, - {DFE_BADVGCLASS, "Cannot set VGroup class"}, - -/* Vdata errors */ - {DFE_BADFIELDS, "Unable to parse fields string correctly"}, - {DFE_NOVS, "Could not find specified VS or VG in file"}, - {DFE_SYMSIZE, "Too many symbols in table"}, - {DFE_BADATTACH, "Cannot write to a previously attached VData"}, - {DFE_BADVSNAME, "Cannot set VData name"}, - {DFE_BADVSCLASS, "Cannot set VData class"}, - {DFE_VSWRITE, "Error writing to VData"}, - {DFE_VSREAD, "Error reading from VData"}, - {DFE_FIELDSSET, "Fields already set for vdata"}, - -/* High-level Vdata/Vset errors */ - {DFE_VSCANTCREATE, "Cannot create VData"}, - {DFE_VGCANTCREATE, "Cannot create VGroup"}, - -/* Generic Vdata/Vset errors */ - {DFE_CANTATTACH, "Cannot attach to a VData"}, - {DFE_CANTDETACH, "Cannot detach a VData with access 'w'"}, - -/* bit I/O errors */ - {DFE_BITREAD, "There was a bit-read error"}, - {DFE_BITWRITE, "There was a bit-write error"}, - {DFE_BITSEEK, "There was a bit-seek error"}, - -/* tbbt interface errors */ - {DFE_TBBTINS, "Failed to insert element into tree"}, - -/* bit-vector interface errors */ - {DFE_BVNEW, "Failed to create a bit-vector"}, - {DFE_BVSET, "Failed when setting a bit in a bit-vector"}, - {DFE_BVGET, "Failed when getting a bit in a bit-vector"}, - {DFE_BVFIND, "Failed when finding a bit in a bit-vector"} -}; -#endif /* _H_ERR_MASTER_ */ - -#endif /* __HERR_H */ diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/hfile.h b/Utilities/CAI/cai_dll/inc/inc_hdf/hfile.h deleted file mode 100755 index ad7f25e933e4eb52dfa4f4a6fcdf3902e18a5199..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/hfile.h +++ /dev/null @@ -1,1015 +0,0 @@ -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -/* $Id$ */ - -/*+ hfile.h - *** Header for hfile.c, routines for low level data element I/O - + */ - -#ifndef HFILE_H -#define HFILE_H - -#include "tbbt.h" -#include "bitvect.h" -#include "atom.h" -#include "linklist.h" -#include "dynarray.h" - -/* Magic cookie for HDF data files */ -#define MAGICLEN 4 /* length */ -#define HDFMAGIC "\016\003\023\001" /* ^N^C^S^A */ - -/* sizes of elements in a file. This is necessary because - the size of variables need not be the same as in the file - (cannot use sizeof) */ -#define DD_SZ 12 /* 2+2+4+4 */ -#define NDDS_SZ 2 -#define OFFSET_SZ 4 - -/* invalid offset & length to indicate a partially defined element -* written to the HDF file i.e. can handle the case where the the -* element is defined but not written out */ -#define INVALID_OFFSET -1 -#define INVALID_LENGTH -1 - - -/* ----------------------------- Version Tags ----------------------------- */ -/* Library version numbers */ - -#define LIBVER_MAJOR 4 -#define LIBVER_MINOR 2 -#define LIBVER_RELEASE 1 -#define LIBVER_STRING "NCSA HDF Version 4.2 Release 1, February 17, 2005" -#define LIBVSTR_LEN 80 /* length of version string */ -#define LIBVER_LEN 92 /* 4+4+4+80 = 92 */ -/* end of version tags */ - -/* -------------------------- File I/O Functions -------------------------- */ -/* FILELIB -- file library to use for file access: 1 stdio, 2 fcntl - default to stdio library i.e. UNIX buffered I/O */ - -#ifndef FILELIB -# define FILELIB UNIXBUFIO /* UNIX buffered I/O is the default */ -#endif /* FILELIB */ - -#if (FILELIB == UNIXBUFIO) -/* using C buffered file I/O routines to access files */ -#include <stdio.h> -typedef FILE *hdf_file_t; -#ifdef VMS -/* For VMS, use "mbc=64" to improve performance */ -# define HI_OPEN(p, a) (((a) & DFACC_WRITE) ? \ - fopen((p), "r+", "mbc=64") : \ - fopen((p), "r", "mbc=64")) -# define HI_CREATE(p) (fopen((p), "w+", "mbc=64")) -#else /* !VMS */ -#if defined SUN && defined (__GNUC__) -# define HI_OPEN(p, a) (((a) & DFACC_WRITE) ? \ - fopen((p), "r+") : fopen((p), "r")) -# define HI_CREATE(p) (fopen((p), "w+")) -#else /* !SUN w/ GNU CC */ -# define HI_OPEN(p, a) (((a) & DFACC_WRITE) ? \ - fopen((p), "rb+") : fopen((p), "rb")) -# define HI_CREATE(p) (fopen((p), "wb+")) -#endif /* !SUN w/ GNU CC */ -#endif /* VMS */ -# define HI_READ(f, b, n) (((size_t)(n) == (size_t)fread((b), 1, (size_t)(n), (f))) ? \ - SUCCEED : FAIL) -# define HI_WRITE(f, b, n) (((size_t)(n) == (size_t)fwrite((b), 1, (size_t)(n), (f))) ? \ - SUCCEED : FAIL) -# define HI_CLOSE(f) (fclose(f)) -# define HI_FLUSH(f) (fflush(f)==0 ? SUCCEED : FAIL) -# define HI_SEEK(f,o) (fseek((f), (long)(o), SEEK_SET)==0 ? SUCCEED : FAIL) -# define HI_SEEK_CUR(f,o) (fseek((f), (long)(o), SEEK_CUR)==0 ? SUCCEED : FAIL) -# define HI_SEEKEND(f) (fseek((f), (long)0, SEEK_END)==0 ? SUCCEED : FAIL) -# define HI_TELL(f) (ftell(f)) -# define OPENERR(f) ((f) == (FILE *)NULL) -#endif /* FILELIB == UNIXBUFIO */ - -#if (FILELIB == UNIXUNBUFIO) -/* using UNIX unbuffered file I/O routines to access files */ -typedef int hdf_file_t; -# define HI_OPEN(p, a) (((a) & DFACC_WRITE) ? \ - open((p), O_RDWR) : open((p), O_RDONLY)) -# define HI_CREATE(p) (open((p), O_RDWR | O_CREAT | O_TRUNC, 0666)) -# define HI_CLOSE(f) (close(f)) -# define HI_FLUSH(f) (SUCCEED) -# define HI_READ(f, b, n) (((n)==read((f), (char *)(b), (n))) ? SUCCEED : FAIL) -# define HI_WRITE(f, b, n) (((n)==write((f), (char *)(b), (n))) ? SUCCEED : FAIL) -# define HI_SEEK(f, o) (lseek((f), (off_t)(o), SEEK_SET)!=(-1) ? SUCCEED : FAIL) -# define HI_SEEKEND(f) (lseek((f), (off_t)0, SEEK_END)!=(-1) ? SUCCEED : FAIL) -# define HI_TELL(f) (lseek((f), (off_t)0, SEEK_CUR)) -# define OPENERR(f) (f < 0) -#endif /* FILELIB == UNIXUNBUFIO */ - -#if (FILELIB == MACIO) -/* using special routines to redirect to Mac Toolkit I/O */ -typedef short hdf_file_t; -# define HI_OPEN(x,y) mopen(x,y) -# define HI_CREATE(name) mopen(name, DFACC_CREATE) -# define HI_CLOSE(x) mclose(x) -# define HI_FLUSH(a) (SUCCEED) -# define HI_READ(a,b,c) mread(a, (char *) b, (int32) c) -# define HI_WRITE(a,b,c) mwrite(a, (char *) b, (int32) c) -# define HI_SEEK(x,y) mlseek(x, (int32 )y, 0) -# define HI_SEEKEND(x) mlseek(x, 0L, 2) -# define HI_TELL(x) mlseek(x,0L,1) -# define DF_OPENERR(f) ((f) == -1) -# define OPENERR(f) (f < 0) -#endif /* FILELIB == MACIO */ - -#ifdef NOT_USED /* Deprecated routines, not supported any more */ -#if (FILELIB == PCIO) -/* using special PC functions to enable reading/writing large chunks */ -typedef FILE *hdf_file_t; -# define HI_OPEN(p, a) (((a) & DFACC_WRITE) ? \ - fopen((p), "rb+") : fopen((p), "rb")) -# define HI_CREATE(p) (fopen((p), "wb+")) -/* Alias the HI_READ and HI_WRITE macros to functions which can handle */ -/* 32-bits of data to read/write */ -# define HI_READ(f, b, n) (((int32)(n) == HDfreadbig((b), (n), (f))) ? \ - SUCCEED : FAIL) -# define HI_WRITE(f, b, n) (((int32)(n) == HDfwritebig((b), (n), (f))) ? \ - SUCCEED : FAIL) -# define HI_CLOSE(f) (fclose(f)) -# define HI_FLUSH(f) (fflush(f)==0 ? SUCCEED : FAIL) -# define HI_SEEK(f,o) (fseek((f), (long)(o), SEEK_SET)==0 ? SUCCEED : FAIL) -# define HI_SEEKEND(f) (fseek((f), (long)0, SEEK_END)==0 ? SUCCEED : FAIL) -# define HI_TELL(f) (ftell(f)) -# define OPENERR(f) ((f) == (FILE *)NULL) -#endif /* FILELIB == PCIO */ - -#if (FILELIB == WINIO) -/* using special MS Windows functions to enable reading/writing large chunks */ -typedef HFILE hdf_file_t; -# define HI_OPEN(p, a) (((a) & DFACC_WRITE) ? \ - _lopen((p), READ_WRITE) : _lopen((p), READ)) -# define HI_CREATE(p) (_lcreat((p), 0)) -/* Alias the HI_READ and HI_WRITE macros to functions which can handle */ -/* 32-bits of data to read/write */ -# define HI_READ(f, b, n) (((int32)(n) == HDfreadbig((b), (n), (f))) ? \ - SUCCEED : FAIL) -# define HI_WRITE(f, b, n) (((int32)(n) == HDfwritebig((b), (n), (f))) ? \ - SUCCEED : FAIL) -# define HI_CLOSE(f) (_lclose(f)) -# define HI_FLUSH(f) (0) -# define HI_SEEK(f, o) (_llseek((f), (long)(o), SEEK_SET)) -# define HI_SEEKEND(f) (_llseek((f), (long)0, SEEK_END)) -# define HI_TELL(f) (_llseek((f),0l,SEEK_CUR)) -# define OPENERR(f) ((f) == (HFILE)HFILE_ERROR) -#endif /* FILELIB == WINIO */ - -#if (FILELIB == WINNTIO) -/* using special Windows NT functions to enable reading/writing large chunks */ -typedef HFILE hdf_file_t; -# define HI_OPEN(p, a) (((a) & DFACC_WRITE) ? \ - _lopen((p), OF_READWRITE) : _lopen((p), OF_READ)) -# define HI_CREATE(p) (_lcreat((p), 0)) -# define HI_READ(f, b, n) (((int32)(n) == _hread((f), (b), (n))) ? \ - SUCCEED : FAIL) -# define HI_WRITE(f, b, n) (((int32)(n) == _hwrite((f), (b), (n))) ? \ - SUCCEED : FAIL) -# define HI_CLOSE(f) (_lclose(f)==0 ? SUCCEED : FAIL) -# define HI_FLUSH(f) (0) -# define HI_SEEK(f, o) (_llseek((f), (long)(o), 0)) -# define HI_SEEKEND(f) (_llseek((f), (long)0, 2)) -# define HI_TELL(f) (_llseek((f),0l,1)) -# define OPENERR(f) ((f) == (HFILE)HFILE_ERROR) -#endif /* FILELIB == WINNTIO */ -#endif /* NOT_USED */ - -#if (FILELIB == PAGEBUFIO) -#include "fmpio.h" -/* using page buffered file I/O routines to access files */ -typedef MPFILE *hdf_file_t; -# define HI_OPEN(p, a) (MPopen((p), (a))) -# define HI_CREATE(p) (MPopen((p), DFACC_CREATE)) -# define HI_CLOSE(f) (MPclose(f)) -# define HI_FLUSH(f) (MPflush(f)) -# define HI_READ(f, b, n) (MPread((f), (char *)(b), (n))) -# define HI_WRITE(f, b, n) (MPwrite((f), (char *)(b), (n))) -# define HI_SEEK(f, o) (MPseek((f), (off_t)(o), SEEK_SET)) -# define HI_SEEKEND(f) (MPseek((f), (off_t)0, SEEK_END)) -# define HI_TELL(f) (MPseek((f), (off_t)0, SEEK_CUR)) -# define OPENERR(f) ((f) == (MPFILE *)NULL) -#endif /* FILELIB == PAGEBUFIO */ - -/* ----------------------- Internal Data Structures ----------------------- */ -/* The internal structure used to keep track of the files opened: an - array of filerec_t structures, each has a linked list of ddblock_t. - Each ddblock_t struct points to an array of dd_t structs. - - File Header(4 bytes) - =================== - <--- 32 bits -----> - ------------------ - |HDF magic number | - ------------------ - - HDF magic number - 0x0e031301 (Hexadecimal) - - Data Descriptor(DD - 12 bytes) - ============================== - <- 16 bits -> <- 16 bits -> <- 32 bits -> <- 32 bits -> - -------------------------------------------------------- - | Tag | reference | Offset | Length | - | | number | | | - -------------------------------------------------------- - \____________/ - V - tag/ref (unique data indentifier in file) - - Tag -- identifies the type of data, 16 bit unsigned integer whose - value ranges from 1 - 65535. Tags are assigned by NCSA. - The HDF tag space is divided as follows based on the 2 highest bits: - - 00: NCSA reserved ordinary tags - 01: NCSA reserved special tags(i.e. regular tags made into - linked-block, external, - compressed or chunked.) - 10, 11: User tags. - - Current tag assingments are: - 00001 - 32767 - reserved for NCSA use - 00001 - 16383 - NCSA regular tags - 16384 - 32767 - NCSA special tags - 32768 - 64999 - user definable - 65000 - 65535 - reserved for expansion of format - - Refererence number - 16 bit unsigned integer whose assignment is not - gauranteed to be consecutive. Provides a way to distinguish - elements with the same tag in the file. - - Offset - Specifies the byte offset of the data element from the - beginning of the file - 32 bit unsigned integer - - Length - Indicates the byte length of the data element - 32 bit unsigned integer - - Data Descriptor Header(DDH - 6 bytes) - ==================================== - <- 16 bits -> <- 32 bits -> - ----------------------------- - | Block Size | Next Block | - ----------------------------- - - Block Size - Indicates the number of DD's in the DD Block, - 16 bit unsigned integer value - Next Block - Gives the offset of the next DD Block. The last DD Block has - a ZERO(0) in the "Next Block" field in the DDH. - 32 bit unsigned integer value - - Data Descriptor Block(DDB - variable size) - ========================================== - <- DD Header -> <--------------- DD's ---------------------> - --------------------------------------------------------...- - |Block | Next | DD | DD | DD | DD | DD | DD | DD | DD |...| - |Size | Block | | | | | | | | | | - --------------------------------------------------------...- - <-------------------------- DD Block ----------------------> - - Note: default number of DD's in a DD Block is 16 - - HDF file layout - ============================= - (one example) - --------------------------------------------------------------------- - | FH | DD Block | Data | DD Block | Data | DD Block | Data | ..... - --------------------------------------------------------------------- - -*/ - -/* record of each data decsriptor */ -typedef struct dd_t - { - uint16 tag; /* Tag number of element i.e. type of data */ - uint16 ref; /* Reference number of element */ - int32 length; /* length of data element */ - int32 offset; /* byte offset of data element from */ - struct ddblock_t *blk; /* Pointer to the block this dd is in */ - } /* beginning of file */ -dd_t; - -/* version tags */ -typedef struct version_t - { - uint32 majorv; /* major version number */ - uint32 minorv; /* minor version number */ - uint32 release; /* release number */ - char string[LIBVSTR_LEN + 1]; /* optional text description, len 80+1 */ - int16 modified; /* indicates file was modified */ - } -version_t; - -/* record of a block of data descriptors, mirrors structure of a HDF file. */ -typedef struct ddblock_t - { - uintn dirty; /* boolean: should this DD block be flushed? */ - int32 myoffset; /* offset of this DD block in the file */ - int16 ndds; /* number of dd's in this block */ - int32 nextoffset; /* offset to the next ddblock in the file */ - struct filerec_t *frec; /* Pointer to the filerec this block is in */ - struct ddblock_t *next; /* pointer to the next ddblock in memory */ - struct ddblock_t *prev; /* Pointer to previous ddblock. */ - struct dd_t *ddlist; /* pointer to array of dd's */ - } -ddblock_t; - -/* Tag tree node structure */ -typedef struct tag_info_str - { - uint16 tag; /* tag value for this node */ - /* Needs to be first in this structure */ - bv_ptr b; /* bit-vector to keep track of which refs are used */ - dynarr_p d; /* dynarray of the refs for this tag */ - }tag_info; - -/* For determining what the last file operation was */ -typedef enum - { - H4_OP_UNKNOWN = 0, /* Don't know what the last operation was (after fopen frex) */ - H4_OP_SEEK, /* Last operation was a seek */ - H4_OP_WRITE, /* Last operation was a write */ - H4_OP_READ /* Last operation was a read */ - } -fileop_t; - -/* File record structure */ -typedef struct filerec_t - { - char *path; /* name of file */ - hdf_file_t file; /* either file descriptor or pointer */ - uint16 maxref; /* highest ref in this file */ - intn access; /* access mode */ - intn refcount; /* reference count / times opened */ - intn attach; /* number of access elts attached */ - intn version_set; /* version tag stuff */ - version_t version; /* file version info */ - - /* Seek caching info */ - int32 f_cur_off; /* Current location in the file */ - fileop_t last_op; /* the last file operation performed */ - - /* DD block caching info */ - intn cache; /* boolean: whether caching is on */ - intn dirty; /* boolean: if dd list needs to be flushed */ - int32 f_end_off; /* offset of the end of the file */ - - /* DD list pointers */ - struct ddblock_t *ddhead; /* head of ddblock list */ - struct ddblock_t *ddlast; /* end of ddblock list */ - - /* NULL DD pointers (for fast lookup of DFTAG_NULL) */ - struct ddblock_t *ddnull; /* location of last ddblock with a DFTAG_NULL */ - int32 ddnull_idx; /* offset of the last location with DFTAG_NULL */ - - /* tag tree for file */ - TBBT_TREE *tag_tree; /* TBBT of the tags in the file */ - - /* annotation stuff for file */ - intn an_num[4]; /* Holds number of annotations found of each type */ - TBBT_TREE *an_tree[4]; /* tbbt trees for each type of annotation in file - * i.e. file/data labels and descriptions. - * This is done for faster searching of annotations - * of a particular type. */ - } -filerec_t; - -/* bits for filerec_t 'dirty' flag */ -#define DDLIST_DIRTY 0x01 /* mark whether to flush dirty DD blocks */ -#define FILE_END_DIRTY 0x02 /* indicate that the file needs to be extended */ - -/* Each access element is associated with a tag/ref to keep track of - the dd it is pointing at. To facilitate searching for next dd's, - instead of pointing directly to the dd, we point to the ddblock and - index into the ddlist of that ddblock. */ -typedef struct accrec_t - { - /* Flags for this access record */ - intn appendable; /* whether appends to the data are allowed */ - intn special; /* special element ? */ - intn new_elem; /* is a new element (i.e. no length set yet) */ - int32 block_size; /* size of the blocks for linked-block element*/ - int32 num_blocks; /* number blocks in the linked-block element */ - uint32 access; /* access codes */ - uintn access_type; /* I/O access type: serial/parallel/... */ - int32 file_id; /* id of attached file */ - atom_t ddid; /* DD id for the DD attached to */ - int32 posn; /* seek position with respect to start of element */ - void * special_info; /* special element info? */ - struct funclist_t *special_func; /* ptr to special function? */ - struct accrec_t *next; /* for free-list linking */ - } -accrec_t; - -#ifdef HFILE_MASTER -/* Pointer to the access record node free list */ -static accrec_t *accrec_free_list=NULL; -#endif /* HFILE_MASTER */ - -/* this type is returned to applications programs or other special - interfaces when they need to know information about a given - special element. This is all information that would not be returned - via Hinquire(). This should probably be a union of structures. */ -typedef struct sp_info_block_t - { - int16 key; /* type of special element this is */ - - /* external elements */ - int32 offset; /* offset in the file */ - char *path; /* file name - should not be freed by user */ - - /* linked blocks */ - int32 first_len; /* length of first block */ - int32 block_len; /* length of standard block */ - int32 nblocks; /* number of blocks per chunk */ - - /* compressed elements */ - int32 comp_type; /* compression type */ - int32 model_type; /* model type */ - int32 comp_size; /* size of compressed information */ - - /* variable-length linked blocks */ - int32 min_block; /* the minimum block size */ - - /* Chunked elements */ - int32 chunk_size; /* logical size of chunks */ - int32 ndims; /* number of dimensions */ - int32 *cdims; /* array of chunk lengths for each dimension */ - - /* Buffered elements */ - int32 buf_aid; /* AID of element buffered */ - } -sp_info_block_t; - -/* a function table record for accessing special data elements. - special data elements of a key could be accessed through the list - of functions in array pointed to by tab. */ -typedef struct funclist_t - { - int32 (*stread) (accrec_t * rec); - int32 (*stwrite) (accrec_t * rec); - int32 (*seek) (accrec_t * access_rec, int32 offset, intn origin); - int32 (*inquire) (accrec_t * access_rec, int32 *pfile_id, - uint16 *ptag, uint16 *pref, int32 *plength, - int32 *poffset, int32 *pposn, int16 *paccess, - int16 *pspecial); - int32 (*read) (accrec_t * access_rec, int32 length, void * data); - int32 (*write) (accrec_t * access_rec, int32 length, const void * data); - intn (*endaccess) (accrec_t * access_rec); - int32 (*info) (accrec_t * access_rec, sp_info_block_t * info); - int32 (*reset) (accrec_t * access_rec, sp_info_block_t * info); - } -funclist_t; - -typedef struct functab_t - { - int16 key; /* the key for this type of special elt */ - funclist_t *tab; /* table of accessing functions */ - } -functab_t; - -/* ---------------------- ID Types and Manipulation ----------------------- */ -/* each id, what ever the type, will be represented with a 32-bit word, - the most-significant 16 bits is a number unique for type. The less- - significant 16 bits is an id unique to each type; in this, we use the - internal slot number. */ - -#define FIDTYPE 1 -#define AIDTYPE 2 -#define GROUPTYPE 3 -#define SDSTYPE 4 -#define DIMTYPE 5 -#define CDFTYPE 6 -#define VGIDTYPE 8 /* also defined in vg.h for Vgroups */ -#define VSIDTYPE 9 /* also defined in vg.h for Vsets */ -#define BITTYPE 10 /* For bit-accesses */ -#define GRIDTYPE 11 /* for GR access */ -#define RIIDTYPE 12 /* for RI access */ - -#define BADFREC(r) ((r)==NULL || (r)->refcount==0) - -/* --------------------------- Special Elements --------------------------- */ -/* The HDF tag space is divided as follows based on the 2 highest bits: - 00: NCSA reserved ordinary tags - 01: NCSA reserved special tags(e.g. linked-block, external, compressed,..) - 10, 11: User tags. - - It is relatively cheap to operate with special tags within the NCSA - reserved tags range. For users to specify special tags and their - corresponding ordinary tag, the pair has to be added to the - special_table in hfile.c and SPECIAL_TABLE must be defined. */ - -#ifdef SPECIAL_TABLE -#define BASETAG(t) (HDbase_tag(t)) -#define SPECIALTAG(t) (HDis_special_tag(t)) -#define MKSPECIALTAG(t) (HDmake_special_tag(t)) -#else -/* This macro converts a (potentially) special tag into a normal tag */ -#define BASETAG(t) (uint16)((~(t) & 0x8000) ? ((t) & ~0x4000) : (t)) -/* This macro checks if a tag is special */ -#define SPECIALTAG(t) (uint16)((~(t) & 0x8000) && ((t) & 0x4000)) -/* This macro (potentially) converts a regular tag into a special tag */ -#define MKSPECIALTAG(t) (uint16)((~(t) & 0x8000) ? ((t) | 0x4000) : DFTAG_NULL) -#endif /*SPECIAL_TABLE */ - -/* -------------------------- H-Layer Prototypes -------------------------- */ -/* - ** Functions to get information of special elt from other access records. - ** defined in hfile.c - ** These should really be HD... routines, but they are only used within - ** the H-layer... - */ - -#if defined c_plusplus || defined __cplusplus -extern "C" -{ -#endif /* c_plusplus || __cplusplus */ - - HDFLIBAPI accrec_t *HIget_access_rec - (void); - - HDFLIBAPI void HIrelease_accrec_node(accrec_t *acc); - - HDFLIBAPI void * HIgetspinfo - (accrec_t * access_rec); - - HDFLIBAPI intn HPcompare_filerec_path - (const void * obj, const void * key); - - HDFLIBAPI intn HPcompare_accrec_tagref - (const void * rec1, const void * rec2); - - HDFLIBAPI int32 HPgetdiskblock - (filerec_t * file_rec, int32 block_size, intn moveto); - - HDFLIBAPI intn HPfreediskblock - (filerec_t * file_rec, int32 block_offset, int32 block_size); - - HDFLIBAPI int32 HDcheck_empty - (int32 file_id, uint16 tag, uint16 ref, intn *emptySDS); - - HDFLIBAPI int32 HDget_special_info - (int32 access_id, sp_info_block_t * info_block); - - HDFLIBAPI int32 HDset_special_info - (int32 access_id, sp_info_block_t * info_block); - - HDFLIBAPI intn HP_read - (filerec_t *file_rec,void * buf,int32 bytes); - - HDFLIBAPI intn HPseek - (filerec_t *file_rec,int32 offset); - - HDFLIBAPI intn HP_write - (filerec_t *file_rec,const void * buf,int32 bytes); - - HDFLIBAPI intn tagcompare - (void * k1, void * k2, intn cmparg); - - HDFLIBAPI VOID tagdestroynode - (void * n); - -/* - ** from hblocks.c - */ - HDFLIBAPI int32 HLPstread - (accrec_t * access_rec); - - HDFLIBAPI int32 HLPstwrite - (accrec_t * access_rec); - - HDFLIBAPI int32 HLPseek - (accrec_t * access_rec, int32 offset, int origin); - - HDFLIBAPI int32 HLPread - (accrec_t * access_rec, int32 length, void * data); - - HDFLIBAPI int32 HLPwrite - (accrec_t * access_rec, int32 length, const void * data); - - HDFLIBAPI int32 HLPinquire - (accrec_t * access_rec, int32 *pfile_id, uint16 *ptag, uint16 *pref, - int32 *plength, int32 *poffset, int32 *pposn, int16 *paccess, - int16 *pspecial); - - HDFLIBAPI intn HLPendaccess - (accrec_t * access_rec); - - HDFLIBAPI int32 HLPcloseAID - (accrec_t * access_rec); - - HDFLIBAPI int32 HLPinfo - (accrec_t * access_rec, sp_info_block_t * info_block); - -/* - ** from hextelt.c - */ - HDFLIBAPI int32 HXPstread - (accrec_t * rec); - - HDFLIBAPI int32 HXPstwrite - (accrec_t * rec); - - HDFLIBAPI int32 HXPseek - (accrec_t * access_rec, int32 offset, int origin); - - HDFLIBAPI int32 HXPread - (accrec_t * access_rec, int32 length, void * data); - - HDFLIBAPI int32 HXPwrite - (accrec_t * access_rec, int32 length, const void * data); - - HDFLIBAPI int32 HXPinquire - (accrec_t * access_rec, int32 *pfile_id, uint16 *ptag, uint16 *pref, - int32 *plength, int32 *poffset, int32 *pposn, int16 *paccess, - int16 *pspecial); - - HDFLIBAPI intn HXPendaccess - (accrec_t * access_rec); - - HDFLIBAPI int32 HXPcloseAID - (accrec_t * access_rec); - - HDFLIBAPI int32 HXPinfo - (accrec_t * access_rec, sp_info_block_t * info_block); - - HDFLIBAPI int32 HXPreset - (accrec_t * access_rec, sp_info_block_t * info_block); - - HDFLIBAPI intn HXPsetaccesstype - (accrec_t * access_rec); - - HDFLIBAPI intn HXPshutdown - (void); - -/* - ** from hcomp.c - */ - - HDFLIBAPI int32 HCPstread - (accrec_t * rec); - - HDFLIBAPI int32 HCPstwrite - (accrec_t * rec); - - HDFLIBAPI int32 HCPseek - (accrec_t * access_rec, int32 offset, int origin); - - HDFLIBAPI int32 HCPinquire - (accrec_t * access_rec, int32 *pfile_id, uint16 *ptag, uint16 *pref, - int32 *plength, int32 *poffset, int32 *pposn, int16 *paccess, - int16 *pspecial); - - HDFLIBAPI int32 HCPread - (accrec_t * access_rec, int32 length, void * data); - - HDFLIBAPI int32 HCPwrite - (accrec_t * access_rec, int32 length, const void * data); - - HDFLIBAPI intn HCPendaccess - (accrec_t * access_rec); - - HDFLIBAPI int32 HCPcloseAID - (accrec_t * access_rec); - - HDFLIBAPI int32 HCPinfo - (accrec_t * access_rec, sp_info_block_t * info_block); - - HDFLIBAPI int32 get_comp_len - (accrec_t* access_rec); - -/* - ** from hchunks.c - should be the same as found in 'hchunks.h' - */ -#include "hchunks.h" - -#if defined (MAC) || defined (macintosh) || defined (SYMANTEC_C) - HDFLIBAPI hdf_file_t mopen - (char *filename, intn access); - - HDFLIBAPI int32 mclose - (hdf_file_t rn); - - HDFLIBAPI int32 mlseek - (hdf_file_t rn, int32 n, intn m); - - HDFLIBAPI int32 mread - (hdf_file_t rn, char *buf, int32 n); - - HDFLIBAPI int32 mwrite - (hdf_file_t rn, char *buf, int32 n); - HDFLIBAPI intn mstat - (char *path); - -#endif /* macintosh */ - -/* - ** from hbuffer.c - */ - - HDFLIBAPI int32 HBPstread - (accrec_t * rec); - - HDFLIBAPI int32 HBPstwrite - (accrec_t * rec); - - HDFLIBAPI int32 HBPseek - (accrec_t * access_rec, int32 offset, int origin); - - HDFLIBAPI int32 HBPinquire - (accrec_t * access_rec, int32 *pfile_id, uint16 *ptag, uint16 *pref, - int32 *plength, int32 *poffset, int32 *pposn, int16 *paccess, - int16 *pspecial); - - HDFLIBAPI int32 HBPread - (accrec_t * access_rec, int32 length, void * data); - - HDFLIBAPI int32 HBPwrite - (accrec_t * access_rec, int32 length, const void * data); - - HDFLIBAPI intn HBPendaccess - (accrec_t * access_rec); - - HDFLIBAPI int32 HBPcloseAID - (accrec_t * access_rec); - - HDFLIBAPI int32 HBPinfo - (accrec_t * access_rec, sp_info_block_t * info_block); - -/* - ** from hcompri.c - */ - - HDFLIBAPI int32 HRPstread - (accrec_t * rec); - - HDFLIBAPI int32 HRPstwrite - (accrec_t * rec); - - HDFLIBAPI int32 HRPseek - (accrec_t * access_rec, int32 offset, int origin); - - HDFLIBAPI int32 HRPinquire - (accrec_t * access_rec, int32 *pfile_id, uint16 *ptag, uint16 *pref, - int32 *plength, int32 *poffset, int32 *pposn, int16 *paccess, - int16 *pspecial); - - HDFLIBAPI int32 HRPread - (accrec_t * access_rec, int32 length, void * data); - - HDFLIBAPI int32 HRPwrite - (accrec_t * access_rec, int32 length, const void * data); - - HDFLIBAPI intn HRPendaccess - (accrec_t * access_rec); - - HDFLIBAPI int32 HRPcloseAID - (accrec_t * access_rec); - - HDFLIBAPI int32 HRPinfo - (accrec_t * access_rec, sp_info_block_t * info_block); - -/* - ** from hfiledd.c - */ -/****************************************************************************** - NAME - HTPstart - Initialize the DD list in memory - - DESCRIPTION - Reads the DD blocks from disk and creates the in-memory structures for - handling them. This routine should only be called once for a given - file and HTPend should be called when finished with the DD list (i.e. - when the file is being closed). - - RETURNS - Returns SUCCEED if successful and FAIL otherwise - -*******************************************************************************/ -intn HTPstart(filerec_t *file_rec /* IN: File record to store info in */ -); - -/****************************************************************************** - NAME - HTPinit - Create a new DD list in memory - - DESCRIPTION - Creates a new DD list in memory for a newly created file. This routine - should only be called once for a given file and HTPend should be called - when finished with the DD list (i.e. when the file is being closed). - - RETURNS - Returns SUCCEED if successful and FAIL otherwise - -*******************************************************************************/ -intn HTPinit(filerec_t *file_rec, /* IN: File record to store info in */ - int16 ndds /* IN: # of DDs to store in each block */ -); - -/****************************************************************************** - NAME - HTPsync - Flush the DD list in memory - - DESCRIPTION - Syncronizes the in-memory copy of the DD list with the copy on disk by - writing out the DD blocks which have changed to disk. - - RETURNS - Returns SUCCEED if successful and FAIL otherwise - -*******************************************************************************/ -intn HTPsync(filerec_t *file_rec /* IN: File record to store info in */ -); - -/****************************************************************************** - NAME - HTPend - Terminate the DD list in memory - - DESCRIPTION - Terminates access to the DD list in memory, writing the DD blocks out to - the disk (if they've changed). After this routine is called, no further - access to tag/refs (or essentially any other HDF objects) can be performed - on the file. - - RETURNS - Returns SUCCEED if successful and FAIL otherwise - -*******************************************************************************/ -intn HTPend(filerec_t *file_rec /* IN: File record to store info in */ -); - -/****************************************************************************** - NAME - HTPcreate - Create (and attach to) a tag/ref pair - - DESCRIPTION - Creates a new tag/ref pair in memory and inserts the tag/ref pair into the - DD list to be written out to disk. This routine returns a DD id which can - be used in the other tag/ref routines to modify the DD. - - RETURNS - Returns DD id if successful and FAIL otherwise - -*******************************************************************************/ -atom_t HTPcreate(filerec_t *file_rec, /* IN: File record to store info in */ - uint16 tag, /* IN: Tag to create */ - uint16 ref /* IN: ref to create */ -); - -/****************************************************************************** - NAME - HTPselect - Attach to an existing tag/ref pair - - DESCRIPTION - Attaches to an existing tag/ref pair. This routine returns a DD id which - can be used in the other tag/ref routines to modify the DD. - - RETURNS - Returns DD id if successful and FAIL otherwise - -*******************************************************************************/ -atom_t HTPselect(filerec_t *file_rec, /* IN: File record to store info in */ - uint16 tag, /* IN: Tag to select */ - uint16 ref /* IN: ref to select */ -); - -/****************************************************************************** - NAME - HTPendaccess - End access to an existing tag/ref pair - - DESCRIPTION - Ends access to an existing tag/ref pair. Any further access to the tag/ref - pair may result in incorrect information being recorded about the DD in - memory or on disk. - - RETURNS - Returns SUCCEED if successful and FAIL otherwise - -*******************************************************************************/ -intn HTPendaccess(atom_t ddid /* IN: DD id to end access to */ -); - -/****************************************************************************** - NAME - HTPdelete - Delete an existing tag/ref pair - - DESCRIPTION - Deletes a tag/ref from the file. Also ends access to the tag/ref pair. - Any further access to the tag/ref pair may result in incorrect information - being recorded about the DD in memory or on disk. - - RETURNS - Returns SUCCEED if successful and FAIL otherwise - -*******************************************************************************/ -intn HTPdelete(atom_t ddid /* IN: DD id to delete */ -); - -/****************************************************************************** - NAME - HTPupdate - Change the offset or length of an existing tag/ref pair - - DESCRIPTION - Updates a tag/ref in the file, allowing the length and/or offset to be - modified. Note: "INVALID_OFFSET" & "INVALID_LENGTH" are used to indicate - that the length or offset (respectively) is unchanged. - - RETURNS - Returns SUCCEED if successful and FAIL otherwise - -*******************************************************************************/ -intn HTPupdate(atom_t ddid, /* IN: DD id to update */ - int32 new_off, /* IN: new offset for DD */ - int32 new_len /* IN: new length for DD */ -); - -/****************************************************************************** - NAME - HTPinquire - Get the DD information for a DD (i.e. tag/ref/offset/length) - - DESCRIPTION - Get the DD information for a DD id from the DD block. Passing NULL for - any parameter does not try to update that parameter. - - RETURNS - Returns SUCCEED if successful and FAIL otherwise - -*******************************************************************************/ -intn HTPinquire(atom_t ddid, /* IN: DD id to inquire about */ - uint16 *tag, /* IN: tag of DD */ - uint16 *ref, /* IN: ref of DD */ - int32 *off, /* IN: offset of DD */ - int32 *len /* IN: length of DD */ -); - -/****************************************************************************** - NAME - HTPis_special - Check if a DD id is associated with a special tag - - DESCRIPTION - Checks if the tag for the DD id is a special tag. - - RETURNS - Returns TRUE(1)/FALSE(0) if successful and FAIL otherwise - -*******************************************************************************/ -intn HTPis_special(atom_t ddid /* IN: DD id to inquire about */ -); - -/****************************************************************************** - NAME - HTPdump_dds -- Dump out the dd information for a file - - DESCRIPTION - Prints out all the information (that you could _ever_ want to know) about - the dd blocks and dd list for a file. - - RETURNS - returns SUCCEED (0) if successful and FAIL (-1) if failed. - -*******************************************************************************/ -intn HTPdump_dds(int32 file_id, /* IN: file ID of HDF file to dump info for */ - FILE *fout /* IN: file stream to output to */ -); - -#if defined c_plusplus || defined __cplusplus -} -#endif /* c_plusplus || __cplusplus */ - -/* #define DISKBLOCK_DEBUG */ -#ifdef DISKBLOCK_DEBUG - -#ifndef HFILE_MASTER -extern -#endif /* HFILE_MASTER */ -const uint8 diskblock_header[4] -#ifdef HFILE_MASTER -={0xde, 0xad, 0xbe, 0xef} -#endif /* HFILE_MASTER */ -; - -#ifndef HFILE_MASTER -extern -#endif /* HFILE_MASTER */ -const uint8 diskblock_tail[4] -#ifdef HFILE_MASTER -={0xfe, 0xeb, 0xda, 0xed} -#endif /* HFILE_MASTER */ -; -#define DISKBLOCK_HSIZE sizeof(diskblock_header) -#define DISKBLOCK_TSIZE sizeof(diskblock_tail) - -#endif /* DISKBLOCK_DEBUG */ - -#endif /* HFILE_H */ diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/hkit.h b/Utilities/CAI/cai_dll/inc/inc_hdf/hkit.h deleted file mode 100755 index bea56f142effdb3b353f0b81578cf976b311ca4b..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/hkit.h +++ /dev/null @@ -1,171 +0,0 @@ - -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -/* $Id$ */ - -/*+ hkit.h - *** private header file for hkit routines - + */ - -#ifndef __HKIT_H -#include "hdf.h" -#include "hfile.h" - -/* tag_messages is the list of tag descriptions in the system, kept as - tag-description pairs. To look up a description, a linear search is - required but efficiency should be okay. */ -typedef struct tag_descript_t - { - uint16 tag; /* tag for description ? */ - const char *desc; /* tag description ? */ - const char *name; /* tag name ? */ - } -tag_descript_t; - -/* stringizing macro */ -#if defined MIPSEL | defined KNRSUN | defined __SUNPRO_C -#define string(x) #x -#else -#define string(x) "x" -#endif /* MIPSEL */ - -/* NOTE: - * Please keep tag descriptions <= 30 characters - a - * lot of pretty-printing code depends on it. - */ -PRIVATE const tag_descript_t tag_descriptions[] = -{ -/* low-level set */ - {DFTAG_NULL, string(DFTAG_NULL), "No Data"}, - {DFTAG_LINKED, string(DFTAG_LINKED), "Linked Blocks Indicator"}, - {DFTAG_VERSION, string(DFTAG_VERSION), "Version Descriptor"}, - {DFTAG_COMPRESSED, string(DFTAG_COMPRESSED), "Compressed Data Indicator"}, - {DFTAG_CHUNK, string(DFTAG_CHUNK), "Data Chunk"}, - -/* utility set */ - {DFTAG_FID, string(DFTAG_FID), "File Identifier"}, - {DFTAG_FD, string(DFTAG_FD), "File Description"}, - {DFTAG_TID, string(DFTAG_TID), "Tag Identifier"}, - {DFTAG_TD, string(DFTAG_TD), "Tag Description"}, - {DFTAG_DIL, string(DFTAG_DIL), "Data Id Label"}, - {DFTAG_DIA, string(DFTAG_DIA), "Data Id Annotation"}, - {DFTAG_NT, string(DFTAG_NT), "Number type"}, - {DFTAG_MT, string(DFTAG_MT), "Machine type"}, - {DFTAG_FREE, string(DFTAG_FREE), "Free space"}, - - /* raster-8 Tags */ - {DFTAG_ID8, string(DFTAG_ID8), "Image Dimensions-8"}, - {DFTAG_IP8, string(DFTAG_IP8), "Image Palette-8"}, - {DFTAG_RI8, string(DFTAG_RI8), "Raster Image-8"}, - {DFTAG_CI8, string(DFTAG_CI8), "RLE Compressed Image-8"}, - {DFTAG_II8, string(DFTAG_II8), "Imcomp Image-8"}, - - /* Raster Image Tags */ - {DFTAG_ID, string(DFTAG_ID), "Image Dimensions"}, - {DFTAG_LUT, string(DFTAG_LUT), "Image Palette"}, - {DFTAG_RI, string(DFTAG_RI), "Raster Image Data"}, - {DFTAG_CI, string(DFTAG_CI), "Compressed Image"}, - {DFTAG_RIG, string(DFTAG_RIG), "Raster Image Group"}, - {DFTAG_LD, string(DFTAG_LD), "Palette Dimension"}, - {DFTAG_MD, string(DFTAG_MD), "Matte Dimension"}, - {DFTAG_MA, string(DFTAG_MA), "Matte Data"}, - {DFTAG_CCN, string(DFTAG_CCN), "Color Correction"}, - {DFTAG_CFM, string(DFTAG_CFM), "Color Format"}, - {DFTAG_AR, string(DFTAG_AR), "Aspect Ratio"}, - {DFTAG_DRAW, string(DFTAG_DRAW), "Sequenced images"}, - {DFTAG_RUN, string(DFTAG_RUN), "Runable program / script"}, - {DFTAG_XYP, string(DFTAG_XYP), "X-Y position"}, - {DFTAG_MTO, string(DFTAG_MTO), "M/c-Type override"}, - - /* Tektronix */ - {DFTAG_T14, string(DFTAG_T14), "TEK 4014 Data"}, - {DFTAG_T105, string(DFTAG_T105), "TEK 4105 data"}, - - /* Scientific / Numeric Data Sets */ - {DFTAG_SDG, string(DFTAG_SDG), "Scientific Data Group"}, - {DFTAG_SDD, string(DFTAG_SDD), "SciData dimension record"}, - {DFTAG_SD, string(DFTAG_SD), "Scientific Data"}, - {DFTAG_SDS, string(DFTAG_SDS), "SciData scales"}, - {DFTAG_SDL, string(DFTAG_SDL), "SciData labels"}, - {DFTAG_SDU, string(DFTAG_SDU), "SciData units"}, - {DFTAG_SDF, string(DFTAG_SDF), "SciData formats"}, - {DFTAG_SDM, string(DFTAG_SDM), "SciData max/min"}, - {DFTAG_SDC, string(DFTAG_SDC), "SciData coordsys"}, - {DFTAG_SDT, string(DFTAG_SDT), "Transpose"}, - {DFTAG_SDLNK, string(DFTAG_SDLNK), "Links related to the dataset"}, - {DFTAG_NDG, string(DFTAG_NDG), "Numeric Data Group"}, - {DFTAG_CAL, string(DFTAG_CAL), "Calibration information"}, - {DFTAG_FV, string(DFTAG_FV), "Fill value information"}, - - /* V Group Tags */ - {DFTAG_VG, string(DFTAG_VG), "Vgroup"}, - {DFTAG_VH, string(DFTAG_VH), "Vdata"}, - {DFTAG_VS, string(DFTAG_VS), "Vdata Storage"}, - - /* Compression Schemes */ - {DFTAG_RLE, string(DFTAG_RLE), "Run Length Encoding"}, - {DFTAG_IMCOMP, string(DFTAG_IMCOMP), "IMCOMP Encoding"}, - {DFTAG_JPEG, string(DFTAG_JPEG), "24-bit JPEG Encoding"}, - {DFTAG_GREYJPEG, string(DFTAG_GREYJPEG), "8-bit JPEG Encoding"}, - {DFTAG_JPEG5, string(DFTAG_JPEG5), "24-bit JPEG Encoding"}, - {DFTAG_GREYJPEG5, string(DFTAG_GREYJPEG5), "8-bit JPEG Encoding"} - -}; - -/* nt_message is the list of NT descriptions in the system, kept as - NT-description pairs. To look up a description, a linear search is - required but efficiency should be okay. */ -typedef struct nt_descript_t - { - int32 nt; /* nt for description */ - const char *name; /* nt name */ - const char *desc; /* nt description */ - } -nt_descript_t; - -PRIVATE const nt_descript_t nt_descriptions[] = -{ - -/* Masks for types */ - {DFNT_NATIVE, string(DFNT_NATIVE), "native format"}, - {DFNT_CUSTOM, string(DFNT_CUSTOM), "custom format"}, - {DFNT_LITEND, string(DFNT_LITEND), "little-endian format"}, - - {DFNT_NONE, string(DFNT_NONE), "number-type not set"}, - -/* Floating point types */ - {DFNT_FLOAT32, string(DFNT_FLOAT32), "32-bit floating point"}, - {DFNT_FLOAT64, string(DFNT_FLOAT64), "64-bit floating point"}, - {DFNT_FLOAT128, string(DFNT_FLOAT128), "128-bit floating point"}, - -/* Integer types */ - {DFNT_INT8, string(DFNT_INT8), "8-bit signed integer"}, - {DFNT_UINT8, string(DFNT_UINT8), "8-bit unsigned integer"}, - {DFNT_INT16, string(DFNT_INT16), "16-bit signed integer"}, - {DFNT_UINT16, string(DFNT_UINT16), "16-bit unsigned integer"}, - {DFNT_INT32, string(DFNT_INT32), "32-bit signed integer"}, - {DFNT_UINT32, string(DFNT_UINT32), "32-bit unsigned integer"}, - {DFNT_INT64, string(DFNT_INT64), "64-bit signed integer"}, - {DFNT_UINT64, string(DFNT_UINT64), "64-bit unsigned integer"}, - {DFNT_INT128, string(DFNT_INT128), "128-bit signed integer"}, - {DFNT_UINT128, string(DFNT_UINT128), "128-bit unsigned integer"}, - -/* Character types */ - {DFNT_CHAR8, string(DFNT_CHAR8), "8-bit signed char"}, - {DFNT_UCHAR8, string(DFNT_UCHAR8), "8-bit unsigned char"}, - {DFNT_CHAR16, string(DFNT_CHAR16), "16-bit signed char"}, - {DFNT_UCHAR16, string(DFNT_UCHAR16), "16-bit unsigned char"} - -}; - -#endif /* __HKIT_H */ diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/hntdefs.h b/Utilities/CAI/cai_dll/inc/inc_hdf/hntdefs.h deleted file mode 100755 index 64a2770985250c49a9569b0663edbf60f02b15ba..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/hntdefs.h +++ /dev/null @@ -1,275 +0,0 @@ -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -/* $Id$ */ - -/*+ hnt.h - *** This file contains all the number-type definitions for HDF - + */ - -#ifndef _HNT_H -#define _HNT_H - -/* masks for types */ -#define DFNT_HDF 0x00000000 /* standard HDF format */ -#define DFNT_NATIVE 0x00001000 /* native format */ -#define DFNT_CUSTOM 0x00002000 /* custom format */ -#define DFNT_LITEND 0x00004000 /* Little Endian format */ -#define DFNT_MASK 0x00000fff /* format mask */ - -/* type info codes */ - -#define DFNT_NONE 0 /* indicates that number type not set */ -#define DFNT_QUERY 0 /* use this code to find the current type */ -#define DFNT_VERSION 1 /* current version of NT info */ - -#define DFNT_FLOAT32 5 -#define DFNT_FLOAT 5 /* For backward compat; don't use */ -#define DFNT_FLOAT64 6 -#define DFNT_DOUBLE 6 /* For backward compat; don't use */ -#define DFNT_FLOAT128 7 /* No current plans for support */ - -#define DFNT_INT8 20 -#define DFNT_UINT8 21 - -#define DFNT_INT16 22 -#define DFNT_UINT16 23 -#define DFNT_INT32 24 -#define DFNT_UINT32 25 -#define DFNT_INT64 26 -#define DFNT_UINT64 27 -#define DFNT_INT128 28 /* No current plans for support */ -#define DFNT_UINT128 30 /* No current plans for support */ - -#define DFNT_UCHAR8 3 /* 3 chosen for backward compatibility */ -#define DFNT_UCHAR 3 /* uchar=uchar8 for backward combatibility */ -#define DFNT_CHAR8 4 /* 4 chosen for backward compatibility */ -#define DFNT_CHAR 4 /* uchar=uchar8 for backward combatibility */ -#define DFNT_CHAR16 42 /* No current plans for support */ -#define DFNT_UCHAR16 43 /* No current plans for support */ - -/* Type info codes for Native Mode datasets */ -#define DFNT_NFLOAT32 (DFNT_NATIVE | DFNT_FLOAT32) -#define DFNT_NFLOAT64 (DFNT_NATIVE | DFNT_FLOAT64) -#define DFNT_NFLOAT128 (DFNT_NATIVE | DFNT_FLOAT128) /* Unsupported */ - -#define DFNT_NINT8 (DFNT_NATIVE | DFNT_INT8) -#define DFNT_NUINT8 (DFNT_NATIVE | DFNT_UINT8) -#define DFNT_NINT16 (DFNT_NATIVE | DFNT_INT16) -#define DFNT_NUINT16 (DFNT_NATIVE | DFNT_UINT16) -#define DFNT_NINT32 (DFNT_NATIVE | DFNT_INT32) -#define DFNT_NUINT32 (DFNT_NATIVE | DFNT_UINT32) -#define DFNT_NINT64 (DFNT_NATIVE | DFNT_INT64) -#define DFNT_NUINT64 (DFNT_NATIVE | DFNT_UINT64) -#define DFNT_NINT128 (DFNT_NATIVE | DFNT_INT128) /* Unsupported */ -#define DFNT_NUINT128 (DFNT_NATIVE | DFNT_UINT128) /* Unsupported */ - -#define DFNT_NCHAR8 (DFNT_NATIVE | DFNT_CHAR8) -#define DFNT_NCHAR (DFNT_NATIVE | DFNT_CHAR8) /* backward compat */ -#define DFNT_NUCHAR8 (DFNT_NATIVE | DFNT_UCHAR8) -#define DFNT_NUCHAR (DFNT_NATIVE | DFNT_UCHAR8) /* backward compat */ -#define DFNT_NCHAR16 (DFNT_NATIVE | DFNT_CHAR16) /* Unsupported */ -#define DFNT_NUCHAR16 (DFNT_NATIVE | DFNT_UCHAR16) /* Unsupported */ - -/* Type info codes for Little Endian data */ -#define DFNT_LFLOAT32 (DFNT_LITEND | DFNT_FLOAT32) -#define DFNT_LFLOAT64 (DFNT_LITEND | DFNT_FLOAT64) -#define DFNT_LFLOAT128 (DFNT_LITEND | DFNT_FLOAT128) /* Unsupported */ - -#define DFNT_LINT8 (DFNT_LITEND | DFNT_INT8) -#define DFNT_LUINT8 (DFNT_LITEND | DFNT_UINT8) -#define DFNT_LINT16 (DFNT_LITEND | DFNT_INT16) -#define DFNT_LUINT16 (DFNT_LITEND | DFNT_UINT16) -#define DFNT_LINT32 (DFNT_LITEND | DFNT_INT32) -#define DFNT_LUINT32 (DFNT_LITEND | DFNT_UINT32) -#define DFNT_LINT64 (DFNT_LITEND | DFNT_INT64) -#define DFNT_LUINT64 (DFNT_LITEND | DFNT_UINT64) -#define DFNT_LINT128 (DFNT_LITEND | DFNT_INT128) /* Unsupported */ -#define DFNT_LUINT128 (DFNT_LITEND | DFNT_UINT128) /* Unsupported */ - -#define DFNT_LCHAR8 (DFNT_LITEND | DFNT_CHAR8) -#define DFNT_LCHAR (DFNT_LITEND | DFNT_CHAR8) /* backward compat */ -#define DFNT_LUCHAR8 (DFNT_LITEND | DFNT_UCHAR8) -#define DFNT_LUCHAR (DFNT_LITEND | DFNT_UCHAR8) /* backward compat */ -#define DFNT_LCHAR16 (DFNT_LITEND | DFNT_CHAR16) /* Unsupported */ -#define DFNT_LUCHAR16 (DFNT_LITEND | DFNT_UCHAR16) /* Unsupported */ - -/* class info codes for int */ -#define DFNTI_MBO 1 /* Motorola byte order 2's compl */ -#define DFNTI_VBO 2 /* Vax byte order 2's compl */ -#define DFNTI_IBO 4 /* Intel byte order 2's compl */ - -/* class info codes for float */ -#define DFNTF_NONE 0 /* indicates subclass is not set */ -#define DFNTF_HDFDEFAULT 1 /* hdf default float format is ieee */ -#define DFNTF_IEEE 1 /* IEEE format */ -#define DFNTF_VAX 2 /* Vax format */ -#define DFNTF_CRAY 3 /* Cray format */ -#define DFNTF_PC 4 /* PC floats - flipped IEEE */ -#define DFNTF_CONVEX 5 /* CONVEX native format */ -#define DFNTF_VP 6 /* Fujitsu VP native format */ -#define DFNTF_CRAYMPP 7 /* Cray MPP format */ - -/* class info codes for char */ -#define DFNTC_BYTE 0 /* bitwise/numeric field */ -#define DFNTC_ASCII 1 /* ASCII */ -#define DFNTC_EBCDIC 5 /* EBCDIC */ - -/* array order */ -#define DFO_FORTRAN 1 /* column major order */ -#define DFO_C 2 /* row major order */ - -/*******************************************************************/ -/* Sizes of number types */ -/*******************************************************************/ - -/* first the standard sizes of number types */ - -# define SIZE_FLOAT32 4 -# define SIZE_FLOAT64 8 -# define SIZE_FLOAT128 16 /* No current plans for support */ - -# define SIZE_INT8 1 -# define SIZE_UINT8 1 -# define SIZE_INT16 2 -# define SIZE_UINT16 2 -# define SIZE_INT32 4 -# define SIZE_UINT32 4 -# define SIZE_INT64 8 -# define SIZE_UINT64 8 -# define SIZE_INT128 16 /* No current plans for support */ -# define SIZE_UINT128 16 /* No current plans for support */ - -# define SIZE_CHAR8 1 -# define SIZE_CHAR 1 /* For backward compat char8 == char */ -# define SIZE_UCHAR8 1 -# define SIZE_UCHAR 1 /* For backward compat uchar8 == uchar */ -# define SIZE_CHAR16 2 /* No current plans for support */ -# define SIZE_UCHAR16 2 /* No current plans for support */ - -/* then the native sizes of number types */ - -/* Unusual number sizes */ -/* Cray (UNICOS) native number sizes: - Char = 8 bits, unsigned - Short=64 int=64 long=64 float=64 double=64 bits - Long double=128 bits - Char pointers = 64 bits - Int pointers = 64 bits -*/ -/* T3D/T3E (CRAYMPP) native number sizes: - Char = 8 bits, unsigned - Short=32 int=64 long=64 float=32 double=64 bits - Long double=64 bits - Char pointers = 64 bits - Int pointers = 64 bits - Big endian, IEEE floating point -*/ -/* IA64 (IA64) native number sizes: - Char = 8 bits, signed - Short=16 int=32 long=64 float=32 double=64 bits - Long double=64 bits - Char pointers = 64 bits - Int pointers = 64 bits - Little endian, IEEE floating point -*/ - -#if !defined(UNICOS) -# define SIZE_NFLOAT32 4 -# define SIZE_NFLOAT64 8 -# define SIZE_NFLOAT128 16 /* No current plans for support */ - -# define SIZE_NINT8 1 -# define SIZE_NUINT8 1 -#if defined(CRAYMPP) -# define SIZE_NINT16 4 -# define SIZE_NUINT16 4 -#else -# define SIZE_NINT16 2 -# define SIZE_NUINT16 2 -#endif -# define SIZE_NINT32 4 -# define SIZE_NUINT32 4 -# define SIZE_NINT64 8 -# define SIZE_NUINT64 8 -# define SIZE_NINT128 16 /* No current plans for support */ -# define SIZE_NUINT128 16 /* No current plans for support */ - -# define SIZE_NCHAR8 1 -# define SIZE_NCHAR 1 /* For backward compat char8 == char */ -# define SIZE_NUCHAR8 1 -# define SIZE_NUCHAR 1 /* For backward compat uchar8 == uchar */ -#if defined(CRAYMPP) -# define SIZE_NCHAR16 4 /* No current plans for support */ -# define SIZE_NUCHAR16 4 /* No current plans for support */ -#else -# define SIZE_NCHAR16 2 /* No current plans for support */ -# define SIZE_NUCHAR16 2 /* No current plans for support */ -#endif -#else /* !!!!!! SOMEBODY NEEDS TO CHECK THESE !!!!! */ -# define SIZE_NFLOAT32 8 -# define SIZE_NFLOAT64 8 -# define SIZE_NFLOAT128 16 /* No current plans for support */ - -# define SIZE_NINT8 1 -# define SIZE_NUINT8 1 -# define SIZE_NINT16 8 -# define SIZE_NUINT16 8 -# define SIZE_NINT32 8 -# define SIZE_NUINT32 8 -# define SIZE_NINT64 8 -# define SIZE_NUINT64 8 -# define SIZE_NINT128 16 /* No current plans for support */ -# define SIZE_NUINT128 16 /* No current plans for support */ -# define SIZE_NCHAR8 1 -# define SIZE_NCHAR 1 -# define SIZE_NCHAR 1 /* For backward compat char8 == char */ -# define SIZE_NUCHAR8 1 -# define SIZE_NUCHAR 1 /* For backward compat uchar8 == uchar */ -# define SIZE_NCHAR16 2 /* No current plans for support */ -# define SIZE_NUCHAR16 2 /* No current plans for support */ -#endif /* UNICOS */ - -/* then the sizes of little-endian number types */ -# define SIZE_LFLOAT32 4 -# define SIZE_LFLOAT64 8 -# define SIZE_LFLOAT128 16 /* No current plans for support */ - -# define SIZE_LINT8 1 -# define SIZE_LUINT8 1 -# define SIZE_LINT16 2 -# define SIZE_LUINT16 2 -# define SIZE_LINT32 4 -# define SIZE_LUINT32 4 -# define SIZE_LINT64 8 -# define SIZE_LUINT64 8 -# define SIZE_LINT128 16 /* No current plans for support */ -# define SIZE_LUINT128 16 /* No current plans for support */ - -# define SIZE_LCHAR8 1 -# define SIZE_LCHAR 1 /* For backward compat char8 == char */ -# define SIZE_LUCHAR8 1 -# define SIZE_LUCHAR 1 /* For backward compat uchar8 == uchar */ -# define SIZE_LCHAR16 2 /* No current plans for support */ -# define SIZE_LUCHAR16 2 /* No current plans for support */ - - /* sizes of different number types */ -# define MACHINE_I8_SIZE 1 -# define MACHINE_I16_SIZE 2 -# define MACHINE_I32_SIZE 4 -# define MACHINE_F32_SIZE 4 -# define MACHINE_F64_SIZE 8 - - /* maximum size of the atomic data types */ -# define MAX_NT_SIZE 16 -#endif /* _HNT_H */ - diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/hproto.h b/Utilities/CAI/cai_dll/inc/inc_hdf/hproto.h deleted file mode 100755 index 0a37068a1e93ed9617a567d07794fb2eb5483b52..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/hproto.h +++ /dev/null @@ -1,4221 +0,0 @@ -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -/* $Id$ */ - -#ifndef _H_PROTO -#define _H_PROTO - -/* Usefull macros, which someday might become actual functions */ -/* Wrappers for Hinquire. feb-2-92 */ -#define HQueryfileid(aid, fileid) \ - (Hinquire ((int32) aid, (int32*) fileid, (uint16*) NULL,\ - (uint16*) NULL, (int32*) NULL, (int32*) NULL,\ - (int32*) NULL, (int16*) NULL, (int16*) NULL)) - -#define HQuerytagref(aid, tag, ref) \ - (Hinquire ((int32) aid, (int32*) NULL, (uint16*) tag,\ - (uint16*) ref, (int32*) NULL, (int32*) NULL,\ - (int32*) NULL, (int16*) NULL, (int16*) NULL)) - -#define HQuerylength(aid, length) \ - (Hinquire ((int32) aid, (int32*) NULL, (uint16*) NULL, \ - (uint16*) NULL, (int32*) length, (int32*) NULL, \ - (int32*) NULL, (int16*) NULL, (int16*) NULL)) - -#define HQueryoffset(aid, offset) \ - (Hinquire ((int32) aid, (int32*) NULL, (uint16*) NULL, \ - (uint16*) NULL, (int32*) NULL, (int32*) offset, \ - (int32*) NULL, (int16*) NULL, (int16*) NULL)) - -#define HQueryposition(aid, position) \ - (Hinquire ((int32) aid, (int32*) NULL, (uint16*) NULL, \ - (uint16*) NULL, (int32*) NULL, (int32*) NULL, \ - (int32*) position, (int16*) NULL, (int16*) NULL)) - -#define HQueryaccess(aid, access) \ - (Hinquire ((int32) aid, (int32*) NULL, (uint16*) NULL, \ - (uint16*) NULL, (int32*) NULL, (int32*) NULL, \ - (int32*) NULL, (int16*) access, (int16*) NULL)) - -#define HQueryspecial(aid, special) \ - (Hinquire ((int32) aid, (int32*) NULL, (uint16*) NULL, \ - (uint16*) NULL, (int32*) NULL, (int32*) NULL, \ - (int32*) NULL, (int16*) NULL, (int16*) special)) - - -#if defined c_plusplus || defined __cplusplus -extern "C" -{ -#endif /* c_plusplus || __cplusplus */ - -/* - ** from hfile.c - */ - HDFLIBAPI int32 Hopen - (const char *path, intn acc_mode, int16 ndds); - - HDFLIBAPI intn Hclose - (int32 file_id); - - HDFLIBAPI int32 Hstartread - (int32 file_id, uint16 tag, uint16 ref); - - HDFLIBAPI intn Hnextread - (int32 access_id, uint16 tag, uint16 ref, intn origin); - - HDFLIBAPI intn Hexist - (int32 file_id, uint16 search_tag, uint16 search_ref); - - HDFLIBAPI intn Hinquire - (int32 access_id, int32 * pfile_id, uint16 * ptag, - uint16 * pref, int32 * plength, int32 * poffset, - int32 * pposn, int16 * paccess, int16 * pspecial); - - HDFLIBAPI int32 Hstartwrite - (int32 file_id, uint16 tag, uint16 ref, int32 length); - - HDFLIBAPI int32 Hstartaccess - (int32 file_id, uint16 tag, uint16 ref, uint32 flags); - - HDFLIBAPI intn Hsetlength - (int32 file_id, int32 length); - - HDFLIBAPI intn Happendable - (int32 aid); - - HDFLIBAPI intn HPisappendable - (int32 aid); - - HDFLIBAPI intn HPregister_term_func - (hdf_termfunc_t term_func); - - HDFLIBAPI intn Hseek - (int32 access_id, int32 offset, intn origin); - - HDFLIBAPI int32 Htell - (int32 access_id); - - HDFLIBAPI int32 Hread - (int32 access_id, int32 length, void * data); - - HDFLIBAPI int32 Hwrite - (int32 access_id, int32 length, const void * data); - - HDFLIBAPI int32 Htrunc - (int32 access_id, int32 trunc_len); - - HDFLIBAPI intn Hendaccess - (int32 access_id); - - HDFLIBAPI intn HDgetc - (int32 access_id); - - HDFLIBAPI intn HDputc - (uint8 c, int32 access_id); - - HDFLIBAPI int32 Hgetelement - (int32 file_id, uint16 tag, uint16 ref, uint8 * data); - - HDFLIBAPI int32 Hputelement - (int32 file_id, uint16 tag, uint16 ref, const uint8 * data, int32 length); - - HDFLIBAPI int32 Hlength - (int32 file_id, uint16 tag, uint16 ref); - - HDFLIBAPI int32 Hoffset - (int32 file_id, uint16 tag, uint16 ref); - - HDFLIBAPI intn Hsync - (int32 file_id); - - HDFLIBAPI intn Hcache - (int32 file_id, intn cache_on); - - HDFLIBAPI intn Hgetlibversion - (uint32 * majorv, uint32 * minorv, - uint32 * releasev, char * string); - - HDFLIBAPI intn Hgetfileversion - (int32 file_id, uint32 * majorv, uint32 * minorv, - uint32 * release, char * string); - - HDFLIBAPI intn Hsetaccesstype(int32 access_id, uintn accesstype); - - HDFLIBAPI uint16 HDmake_special_tag - (uint16 tag); - - HDFLIBAPI intn HDis_special_tag - (uint16 tag); - - HDFLIBAPI uint16 HDbase_tag - (uint16 tag); - - HDFLIBAPI int HDerr - (int32 file_id); - - HDFLIBAPI intn HDvalidfid - (int32 file_id); - - HDFLIBAPI const char *HDgettagdesc - (uint16 tag); - - HDFLIBAPI char *HDgettagsname - (uint16 tag); - - HDFLIBAPI intn HDgettagnum - (const char *tag_name); - - HDFLIBAPI char *HDgetNTdesc - (int32 nt); - - HDFLIBAPI const char *HDfidtoname - (int32 fid); - - HDFLIBAPI intn Hishdf - (const char * filename); - - HDFLIBAPI intn Hfidinquire - (int32 file_id, char ** fname, intn * acc_mode, - intn * attach); - - HDFLIBAPI intn Hshutdown(void); - - HDFLIBAPI void HPend(void); - - HDFLIBAPI intn HDdont_atexit(void); - -/* - ** from hfiledd.c - */ -/****************************************************************************** - NAME - Hdupdd - Duplicate a data descriptor - - DESCRIPTION - Duplicates a data descriptor so that the new tag/ref points to the - same data element pointed to by the old tag/ref. Return FAIL if - the given tag/ref are already in use. - - RETURNS - returns SUCCEED (0) if successful, FAIL (-1) otherwise - -*******************************************************************************/ -HDFLIBAPI intn Hdupdd(int32 file_id, /* IN: File ID the tag/refs are in */ - uint16 tag, /* IN: Tag of new tag/ref */ - uint16 ref, /* IN: Ref of new tag/ref */ - uint16 old_tag, /* IN: Tag of old tag/ref */ - uint16 old_ref /* IN: Ref of old tag/ref */ -); - -/****************************************************************************** - NAME - Hnumber - Determine the number of objects of a given type - - DESCRIPTION - Determine how many objects of the given tag are in the file. - tag may be set to DFTAG_WILDCARD to get back the total number - of objects in the file. - - Note, a return value of zero is not a fail condition. - - RETURNS - the number of objects of type 'tag' else FAIL - -*******************************************************************************/ -HDFLIBAPI int32 Hnumber(int32 file_id, /* IN: File ID the tag/refs are in */ - uint16 tag /* IN: Tag to count */ -); - -/****************************************************************************** - NAME - Hnewref - Returns a ref that is guaranteed to be unique in the file - - DESCRIPTION - Returns a ref number that can be used with any tag to produce a - unique tag/ref. Successive calls to Hnewref will generate a - strictly increasing sequence until the highest possible ref had been - returned, then Hnewref will return unused ref's starting from 1. - - RETURNS - returns the ref number, 0 otherwise - -*******************************************************************************/ -HDFLIBAPI uint16 Hnewref(int32 file_id /* IN: File ID the tag/refs are in */ -); - -/****************************************************************************** - NAME - Htagnewref - returns a ref that is unique in the file for a given tag - - DESCRIPTION - Returns a ref number that can be used with any tag to produce a - unique tag/ref. Successive calls to Hnewref will generate a - strictly increasing sequence until the highest possible ref had been - returned, then Hnewref will return unused ref's starting from 1. - - RETURNS - returns the ref number, 0 otherwise - -*******************************************************************************/ -HDFLIBAPI uint16 Htagnewref(int32 file_id, /* IN: File ID the tag/refs are in */ - uint16 tag /* IN: Tag to search for a new ref for */ -); - -/****************************************************************************** - NAME - Hfind - locate the next object of a search in an HDF file - - DESCRIPTION - Searches for the `next' DD that fits the search tag/ref. Wildcards - apply. If origin is DF_FORWARD, search from current position forwards - in the file, otherwise DF_BACKWARD searches backward from the current - position in the file. If *find_tag and *find_ref are both set to - 0, this indicates the beginning of a search, and the search will - start from the beginning of the file if the direction is DF_FORWARD - and from the and of the file if the direction is DF_BACKWARD. - - RETURNS - returns SUCCEED (0) if successful and FAIL (-1) otherwise - -*******************************************************************************/ -HDFLIBAPI intn Hfind(int32 file_id, /* IN: file ID to search in */ - uint16 search_tag, /* IN: the tag to search for (can be DFTAG_WILDCARD) */ - uint16 search_ref, /* IN: ref to search for (can be DFREF_WILDCARD) */ - uint16 *find_tag, /* IN: if (*find_tag==0) and (*find_ref==0) then start search */ - /* OUT: tag matching the search tag */ - uint16 *find_ref, /* IN: if (*find_tag==0) and (*find_ref==0) then start search */ - /* OUT: ref matching the search ref */ - int32 *find_offset, /* OUT: offset of the data element found */ - int32 *find_length, /* OUT: length of the data element found */ - intn direction /* IN: Direction to search in: */ - /* DF_FORWARD searches forward from the current location */ - /* DF_BACKWARD searches backward from the current location */ -); - - -/****************************************************************************** - NAME - HDcheck_tagref - Checks to see if tag/ref is in DD list i.e. created already - - DESCRIPTION - Routine checks to see if tag/ref exists in the DD list i.e. has - been created. - - RETURNS - 0-> tag/ref does not exist - 1-> tag/ref exists - -1-> function failed - -*******************************************************************************/ -HDFLIBAPI intn -HDcheck_tagref(int32 file_id, /* IN: id of file */ - uint16 tag, /* IN: Tag to check */ - uint16 ref /* IN: ref to check */); - -/************************************************************************ -NAME - HDreuse_tagref -- reuse a data descriptor preserving tag/ref - -DESCRIPTION - Reuses the data descriptor of tag/ref in the dd list of the file. - The tag/ref must already exist in the DD list. - This routine is unsafe and may leave a file in a condition that is - not usable by some routines. Use with care. Not valid for - special elments right now. Used for allowing the data to change - and move somewhere else in the file for non-special elements. - Must be carefully if apply to higher-level objects like GR's and SDS - that are comprised of other objects. - Usefull when re-writing simple elements whose size changes while - preserving the original tag/ref of the element since other elements - might refer to this element by tag/ref e.g. in a Vgroup. - -RETURNS - returns SUCCEED (0) if successful, FAIL (-1) otherwise -************************************************************************/ -HDFLIBAPI intn -HDreuse_tagref(int32 file_id, /* IN: id of file */ - uint16 tag, /* IN: tag of data descriptor to reuse */ - uint16 ref /* IN: ref of data descriptor to reuse */ ); - -/****************************************************************************** - NAME - Hdeldd - Delete a data descriptor - - DESCRIPTION - Deletes a data descriptor of tag/ref from the dd list of the file. - This routine is unsafe and may leave a file in a condition that is - not usable by some routines. Use with care. - For example, if this element is contained in a Vgroup, that group - will *NOT* get updated to reflect that this element has been deleted. - - RETURNS - returns SUCCEED (0) if successful, FAIL (-1) otherwise - -*******************************************************************************/ -HDFLIBAPI intn Hdeldd(int32 file_id, /* IN: File ID the tag/refs are in */ - uint16 tag, /* IN: Tag of tag/ref to delete */ - uint16 ref /* IN: Ref of tag/ref to delete */ -); - -/* - ** from hdfalloc.c - */ - - HDFLIBAPI void * HDmemfill - (void * dest, const void * src, uint32 item_size, uint32 num_items); - - HDFLIBAPI char *HIstrncpy - (char * dest, const char * source, int32 len); - - HDFLIBAPI int32 HDspaceleft - (void); - -#if defined(MALLOC_CHECK) || defined(_HDFDLL_) - HDFPUBLIC extern void * HDmalloc - (uint32 qty); - - HDFPUBLIC extern void * HDrealloc - (void * where, uint32 qty); - - HDFPUBLIC extern void * HDcalloc - (uint32 n, uint32 size); - - HDFPUBLIC extern void HDfree - (void * ptr); - -#endif /* defined MALLOC_CHECK */ - -#if defined VMS || defined macintosh || defined MAC || defined SYMANTEC_C || defined MIPSEL || defined NEXT || defined CONVEX || defined IBM6000 || defined SUN || defined IRIX || defined _HDFDLL_ - HDFPUBLIC extern char *HDstrdup - (const char *s); - -#endif - - HDFLIBAPI intn HDc2fstr - (char * str, intn len); - - HDFLIBAPI char *HDf2cstring - (_fcd fdesc, intn len); - - HDFLIBAPI intn HDflush - (int32 file_id); - - HDFLIBAPI intn HDpackFstring - (char * src, char * dest, intn len); - -/* - ** from hblocks.c - */ - HDFLIBAPI int32 HLcreate - (int32 file_id, uint16 tag, uint16 ref, int32 block_length, - int32 number_blocks); - - HDFLIBAPI intn HLconvert - (int32 aid, int32 block_length, int32 number_blocks); - - HDFLIBAPI int HDinqblockinfo - (int32 aid, int32 *length, int32 *first_length, int32 *block_length, - int32 *number_blocks); - - HDFLIBAPI intn HLsetblockinfo - (int32 aid, int32 block_size, int32 num_blocks); - - HDFLIBAPI intn HLgetblockinfo - (int32 aid, int32* block_size, int32* num_blocks); - -/* - ** from hextelt.c - */ - HDFLIBAPI int32 HXcreate - (int32 file_id, uint16 tag, uint16 ref, const char * extern_file_name, - int32 offset, int32 start_len); - - HDFLIBAPI intn HXsetcreatedir - (const char *dir); - - HDFLIBAPI intn HXsetdir - (const char *dir); - -/* - ** from hcomp.c - */ - HDFLIBAPI int32 HCcreate - (int32 file_id, uint16 tag, uint16 ref, - comp_model_t model_type, model_info * m_info, - comp_coder_t coder_type, comp_info * c_info); - - HDFLIBAPI intn HCPgetcompress - (int32 file_id, uint16 data_tag, uint16 data_ref, - comp_coder_t *coder_type, comp_info * c_info); - - HDFPUBLIC intn HCget_config_info ( comp_coder_t coder_type, uint32 *compression_config_info); - - HDFLIBAPI int32 HCPquery_encode_header(comp_model_t model_type, model_info * m_info, - comp_coder_t coder_type, comp_info * c_info); - - HDFLIBAPI intn HCPencode_header(uint8 *p, comp_model_t model_type, model_info * m_info, - comp_coder_t coder_type, comp_info * c_info); - - HDFLIBAPI intn HCPdecode_header(uint8 *p, comp_model_t *model_type, model_info * m_info, - comp_coder_t *coder_type, comp_info * c_info); - -/* - ** from cszip.c - */ - - HDFLIBAPI intn HCPsetup_szip_parms ( comp_info *c_info, int32 nt, int32 ncomp, int32 ndims, int32 *dims, int32 *cdims); -/* - ** from hbuffer.c - */ - HDFLIBAPI intn HBconvert - (int32 aid); - -/* - ** from hcompri.c - */ - HDFLIBAPI int32 HRPconvert - (int32 fid, uint16 tag, uint16 ref, int32 xdim, int32 ydim,int16 scheme, comp_info *cinfo, uintn pixel_size); - -/* - ** from herr.c - */ - HDFLIBAPI const char *HEstring - (hdf_err_code_t error_code); - - HDFLIBAPI void HEpush - (hdf_err_code_t error_code, const char * function_name, - const char * file_name, intn line); - - HDFLIBAPI void HEreport - (const char *,...); - - HDFLIBAPI void HEprint - (FILE * stream, int32 print_level); - - HDFLIBAPI int16 HEvalue - (int32 level); - - HDFLIBAPI void HEPclear - (void); - - HDFLIBAPI intn HEshutdown(void); - -/* - ** from hbitio.c - */ - HDFLIBAPI int32 Hstartbitread - (int32 file_id, uint16 tag, uint16 ref); - - HDFLIBAPI int32 Hstartbitwrite - (int32 file_id, uint16 tag, uint16 ref, int32 length); - - HDFLIBAPI intn Hbitappendable - (int32 bitid); - - HDFLIBAPI intn Hbitwrite - (int32 bitid, intn count, uint32 data); - - HDFLIBAPI intn Hbitread - (int32 bitid, intn count, uint32 *data); - - HDFLIBAPI intn Hbitseek - (int32 bitid, int32 byte_offset, intn bit_offset); - - HDFLIBAPI intn Hgetbit - (int32 bitid); - - HDFLIBAPI int32 Hendbitaccess - (int32 bitfile_id, intn flushbit); - - HDFLIBAPI intn HPbitshutdown(void); - -/* - ** from dfcomp.c - */ - HDFLIBAPI intn DFputcomp - (int32 file_id, uint16 tag, uint16 ref, const uint8 * image, - int32 xdim, int32 ydim, uint8 * palette, uint8 * newpal, - int16 scheme, comp_info * cinfo); - - HDFLIBAPI int DFgetcomp - (int32 file_id, uint16 tag, uint16 ref, uint8 * image, - int32 xdim, int32 ydim, uint16 scheme); - -/* - ** from dfrle.c - */ - HDFLIBAPI int32 DFCIrle - (const void * buf, void * bufto, int32 len); - - HDFLIBAPI int32 DFCIunrle - (uint8 * buf, uint8 *bufto, int32 outlen, int resetsave); - -/* - ** from dfimcomp.c - */ - HDFLIBAPI void DFCIimcomp - (int32 xdim, int32 ydim, const uint8 *in, uint8 out[], - uint8 in_pal[], uint8 out_pal[], int mode); - - HDFLIBAPI void DFCIunimcomp - (int32 xdim, int32 ydim, uint8 in[], uint8 out[]); - -/* - ** from dfjpeg.c - */ - - HDFLIBAPI intn DFCIjpeg - (int32 file_id, uint16 tag, uint16 ref, int32 xdim, int32 ydim, - const void * image, int16 scheme, comp_info * scheme_info); - -/* - ** from dfunjpeg.c - */ - - HDFLIBAPI intn DFCIunjpeg - (int32 file_id, uint16 tag, uint16 ref, void * image, int32 xdim, - int32 ydim, int16 scheme); - -/* - ** from dfgroup.c - */ - HDFLIBAPI int32 DFdiread - (int32 file_id, uint16 tag, uint16 ref); - - HDFLIBAPI intn DFdiget - (int32 list, uint16 * ptag, uint16 * pref); - - HDFLIBAPI intn DFdinobj - (int32 list); - - HDFLIBAPI int32 DFdisetup - (int maxsize); - - HDFLIBAPI intn DFdiput - (int32 list, uint16 tag, uint16 ref); - - HDFLIBAPI intn DFdiwrite - (int32 file_id, int32 list, uint16 tag, uint16 ref); - - HDFLIBAPI void DFdifree - (int32 groupID); - -/* - ** from dfp.c - */ - HDFLIBAPI intn DFPgetpal - (const char * filename, void * palette); - - HDFLIBAPI intn DFPputpal - (const char * filename, const void * palette, intn overwrite, const char * filemode); - - HDFLIBAPI intn DFPaddpal - (const char * filename, const void * palette); - - HDFLIBAPI intn DFPnpals - (const char * filename); - - HDFLIBAPI intn DFPreadref - (const char * filename, uint16 ref); - - HDFLIBAPI intn DFPwriteref - (const char * filename, uint16 ref); - - HDFLIBAPI intn DFPrestart - (void); - - HDFLIBAPI uint16 DFPlastref - (void); - -/* - ** from dfr8.c - */ - HDFLIBAPI int DFR8setcompress - (int32 scheme, comp_info * cinfo); - - HDFLIBAPI intn DFR8getdims - (const char * filename, int32 * pxdim, int32 * pydim, - int * pispal); - - HDFLIBAPI intn DFR8getimage - (const char * filename, uint8 * image, int32 xdim, int32 ydim, - uint8 * pal); - - HDFLIBAPI intn DFR8setpalette - (uint8 * pal); - - HDFLIBAPI intn DFR8putimage - (const char * filename, const void * image, int32 xdim, int32 ydim, uint16 compress); - - HDFLIBAPI intn DFR8addimage - (const char * filename, const void * image, int32 xdim, int32 ydim, uint16 compress); - - HDFLIBAPI intn DFR8nimages - (const char * filename); - - HDFLIBAPI intn DFR8readref - (const char * filename, uint16 ref); - - HDFLIBAPI intn DFR8writeref - (const char * filename, uint16 ref); - - HDFLIBAPI intn DFR8restart - (void); - - HDFLIBAPI uint16 DFR8lastref - (void); - - HDFLIBAPI intn DFR8getpalref(uint16 *pal_ref); - - HDFLIBAPI intn DFR8Pshutdown(void); - -/* - ** from dfgr.c - */ - HDFLIBAPI intn DFGRgetlutdims - (const char * filename, int32 * pxdim, int32 * pydim, - intn * pncomps, intn * pil); - - HDFLIBAPI intn DFGRreqlutil - (intn il); - - HDFLIBAPI intn DFGRgetlut - (const char * filename, void * lut, int32 xdim, int32 ydim); - - HDFLIBAPI intn DFGRgetimdims - (const char * filename, int32 * pxdim, int32 * pydim, - intn * pncomps, intn * pil); - - HDFLIBAPI intn DFGRreqimil - (intn il); - - HDFLIBAPI intn DFGRgetimage - (const char * filename, void * image, int32 xdim, int32 ydim); - - HDFLIBAPI intn DFGRsetcompress - (int32 scheme, comp_info * cinfo); - - HDFLIBAPI intn DFGRsetlutdims - (int32 xdim, int32 ydim, intn ncomps, intn il); - - HDFLIBAPI intn DFGRsetlut - (void * lut, int32 xdim, int32 ydim); - - HDFLIBAPI intn DFGRaddlut - (const char * filename, void * lut, int32 xdim, int32 ydim); - - HDFLIBAPI intn DFGRsetimdims - (int32 xdim, int32 ydim, intn ncomps, intn il); - - HDFLIBAPI intn DFGRaddimage - (const char * filename, void * image, int32 xdim, int32 ydim); - - HDFLIBAPI intn DFGRputimage - (const char * filename, void * image, int32 xdim, int32 ydim); - - HDFLIBAPI intn DFGRreadref - (const char * filename, uint16 ref); - - HDFLIBAPI uint16 DFGRIlastref - (void); - - HDFLIBAPI intn DFGRIgetdims - (const char * filename, int32 * pxdim, int32 * pydim, - intn * pncomps, intn * pil, intn type); - - HDFLIBAPI intn DFGRIreqil - (intn il, intn type); - - HDFLIBAPI intn DFGRIgetimlut - (const char * filename, void * imlut, int32 xdim, int32 ydim, intn type, - intn isfortran, int *compressed, uint16 *compr_type, int *has_pal); - - HDFLIBAPI intn DFGRIsetdims - (int32 xdim, int32 ydim, intn ncomps, intn type); - - HDFLIBAPI intn DFGRIsetil - (intn il, intn type); - - HDFLIBAPI intn DFGRIrestart - (void); - - HDFLIBAPI intn DFGRIaddimlut - (const char * filename, const void * imlut, int32 xdim, int32 ydim, intn type, - intn isfortran, intn newfile); - - HDFLIBAPI intn DFGRPshutdown(void); - -/* - ** from df24.c - */ - HDFLIBAPI intn DF24getdims - (const char * filename, int32 * pxdim, int32 * pydim, - intn * pil); - - HDFLIBAPI intn DF24reqil - (intn il); - - HDFLIBAPI intn DF24getimage - (const char * filename, void * image, int32 xdim, int32 ydim); - - HDFLIBAPI intn DF24setdims - (int32 xdim, int32 ydim); - - HDFLIBAPI intn DF24setil - (intn il); - - HDFLIBAPI intn DF24setcompress - (int32 type, comp_info * cinfo); - - HDFLIBAPI intn DF24restart - (void); - - HDFLIBAPI intn DF24addimage - (const char * filename, const void * image, int32 xdim, int32 ydim); - - HDFLIBAPI intn DF24putimage - (const char * filename, const void * image, int32 xdim, int32 ydim); - - HDFLIBAPI intn DF24nimages - (const char * filename); - - HDFLIBAPI intn DF24readref - (const char * filename, uint16 ref); - - HDFLIBAPI uint16 DF24lastref - (void); - -/* - ** from dfan.c - */ - - HDFLIBAPI int32 DFANgetlablen - (const char * filename, uint16 tag, uint16 ref); - - HDFLIBAPI intn DFANgetlabel - (const char * filename, uint16 tag, uint16 ref, char * label, - int32 maxlen); - - HDFLIBAPI int32 DFANgetdesclen - (const char * filename, uint16 tag, uint16 ref); - - HDFLIBAPI intn DFANgetdesc - (const char * filename, uint16 tag, uint16 ref, char * desc, - int32 maxlen); - - HDFLIBAPI int32 DFANgetfidlen - (int32 file_id, intn isfirst); - - HDFLIBAPI int32 DFANgetfid - (int32 file_id, char * id, int32 maxlen, intn isfirst); - - HDFLIBAPI int32 DFANgetfdslen - (int32 file_id, intn isfirst); - - HDFLIBAPI int32 DFANgetfds - (int32 file_id, char * desc, int32 maxlen, intn isfirst); - - HDFLIBAPI intn DFANputlabel - (const char * filename, uint16 tag, uint16 ref, char * label); - - HDFLIBAPI intn DFANputdesc - (const char * filename, uint16 tag, uint16 ref, char * desc, - int32 desclen); - - HDFLIBAPI intn DFANaddfid - (int32 file_id, char * id); - - HDFLIBAPI intn DFANaddfds - (int32 file_id, char * desc, int32 desclen); - - HDFLIBAPI uint16 DFANlastref - (void); - - HDFLIBAPI intn DFANlablist - (const char * filename, uint16 tag, uint16 reflist[], - char * labellist, intn listsize, intn maxlen, intn startpos); - - HDFLIBAPI intn DFANclear - (void); - - HDFLIBAPI intn DFANIclear - (void); - - HDFLIBAPI uint16 DFANIlocate - (int32 file_id, int type, uint16 tag, uint16 ref); - - HDFLIBAPI int DFANIaddentry - (int type, uint16 annref, uint16 datatag, uint16 dataref); - - HDFLIBAPI int32 DFANIgetannlen - (const char * filename, uint16 tag, uint16 ref, int type); - - HDFLIBAPI intn DFANIgetann - (const char * filename, uint16 tag, uint16 ref, uint8 * ann, - int32 maxlen, int type); - - HDFLIBAPI intn DFANIputann - (const char * filename, uint16 tag, uint16 ref, uint8 * ann, - int32 annlen, int type); - - HDFLIBAPI int DFANIlablist - (const char * filename, uint16 tag, uint16 reflist[], - uint8 * labellist, int listsize, int maxlen, int startpos, - int isfortran); - - HDFLIBAPI int DFANIaddfann - (int32 file_id, char * ann, int32 annlen, int type); - - HDFLIBAPI int32 DFANIgetfannlen - (int32 file_id, int type, int isfirst); - - HDFLIBAPI int32 DFANIgetfann - (int32 file_id, char * ann, int32 maxlen, int type, int isfirst); - - HDFLIBAPI intn DFANPshutdown(void); - -/* - ** from dfsd.c - */ - - HDFLIBAPI int DFSDgetdims - (const char * filename, intn * prank, int32 sizes[], intn maxrank); - - HDFLIBAPI int DFSDgetdatastrs - (char * label, char * unit, char * format, char * coordsys); - - HDFLIBAPI int DFSDgetdimstrs - (int dim, char * label, char * unit, char * format); - - HDFLIBAPI int DFSDgetdatalen - (int * llabel, int * lunit, int * lformat, int * lcoordsys); - - HDFLIBAPI int DFSDgetdimlen - (int dim, int * llabel, int * lunit, int * lformat); - - HDFLIBAPI int DFSDgetdimscale - (intn dim, int32 maxsize, void * scale); - - HDFLIBAPI int DFSDgetrange - (void * pmax, void * pmin); - - HDFLIBAPI int DFSDgetdata - (const char * filename, intn rank, int32 maxsizes[], void * data); - - HDFLIBAPI int DFSDsetlengths - (int maxlen_label, int maxlen_unit, int maxlen_format, - int maxlen_coordsys); - - HDFLIBAPI int DFSDsetdims - (intn rank, int32 dimsizes[]); - - HDFLIBAPI int DFSDsetdatastrs - (const char * label, const char * unit, const char * format, const char * coordsys); - - HDFLIBAPI int DFSDsetdimstrs - (int dim, const char * label, const char * unit, const char * format); - - HDFLIBAPI int DFSDsetdimscale - (intn dim, int32 dimsize, void * scale); - - HDFLIBAPI int DFSDsetrange - (void * maxi, void * mini); - - HDFLIBAPI int DFSDputdata - (const char * filename, intn rank, int32 dimsizes[], void * data); - - HDFLIBAPI int DFSDadddata - (const char * filename, intn rank, int32 dimsizes[], void * data); - - HDFLIBAPI int DFSDrestart - (void); - - HDFLIBAPI int32 DFSDndatasets - (char * filename); - - HDFLIBAPI int DFSDclear - (void); - - HDFLIBAPI uint16 DFSDlastref - (void); - - HDFLIBAPI int DFSDreadref - (char * filename, uint16 ref); - - HDFLIBAPI int DFSDgetslice - (const char * filename, int32 winst[], int32 windims[], void * data, - int32 dims[]); - - HDFLIBAPI int DFSDstartslice - (const char * filename); - - HDFLIBAPI int DFSDputslice - (int32 winend[], void * data, int32 dims[]); - - HDFLIBAPI int DFSDendslice - (void); - - HDFLIBAPI int DFSDsetNT - (int32 numbertype); - - HDFLIBAPI int DFSDsetorder - (int arrayorder); - - HDFLIBAPI int DFSDgetNT - (int32 * pnumbertype); - - HDFLIBAPI intn DFSDpre32sdg - (char * filename, uint16 ref, intn * ispre32); - - HDFLIBAPI int DFSDsetcal - (float64 cal, float64 cal_err, float64 ioff, - float64 ioff_err, int32 cal_nt); - - HDFLIBAPI int DFSDgetcal - (float64 * pcal, float64 * pcal_err, float64 * pioff, - float64 * pioff_err, int32 * cal_nt); - - HDFLIBAPI int DFSDwriteref - (const char * filename, uint16 ref); - - HDFLIBAPI int DFSDsetfillvalue - (void * fill_value); - - HDFLIBAPI int DFSDgetfillvalue - (void * fill_value); - - HDFLIBAPI int DFSDstartslab - (const char * filename); - - HDFLIBAPI int DFSDwriteslab - (int32 start[], int32 stride[], int32 count[], - void * data); - - HDFLIBAPI int DFSDendslab - (void); - - HDFLIBAPI int DFSDreadslab - (const char *filename, int32 start[], int32 slab_size[], - int32 stride[], void * buffer, int32 buffer_size[]); - - HDFLIBAPI intn DFSDPshutdown(void); - -/* - ** from dfconv.c - */ - - HDFLIBAPI int DFKNTsize - (int32 number_type); - - HDFLIBAPI int32 DFKisnativeNT - (int32 numbertype); - - HDFLIBAPI int32 DFKislitendNT - (int32 numbertype); - - HDFLIBAPI int8 DFKgetPNSC - (int32 numbertype, int32 machinetype); - - HDFLIBAPI intn DFKsetNT - (int32 ntype); - - HDFLIBAPI int32 DFKconvert - (void * source, void * dest, int32 ntype, int32 num_elm, - int16 acc_mode, int32 source_stride, int32 dest_stride); - -/* - ** from dfknat.c - */ - - HDFLIBAPI intn DFKnb1b - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKnb2b - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKnb4b - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKnb8b - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - -/* - ** from dfkswap.c - */ - - HDFLIBAPI intn DFKsb2b - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKsb4b - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKsb8b - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - -/* - ** from dfkcray.c - */ - - HDFLIBAPI intn DFKui2i - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKui2s - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKuo2i - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKuo2s - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKui4i - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKui4s - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKuo4i - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKuo4s - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKui4f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKuo4f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKui8f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKuo8f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKlui2i - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKlui2s - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKluo2i - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKluo2s - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKlui4i - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKlui4s - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKluo4i - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKluo4s - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKlui4f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKluo4f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKlui8f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKluo8f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - -/* CRAY-MPP */ - HDFLIBAPI intn DFKmi2i - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKmi2s - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKmo2b - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKlmi2i - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKlmi2s - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKlmo2b - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - -/* - ** from dfkvms.c - */ - - HDFLIBAPI intn DFKvi4f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKvo4f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKvi8f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKvo8f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKlvi4f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKlvo4f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKlvi8f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKlvo8f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - -/* - ** from dfkconv.c - */ - - HDFLIBAPI intn DFKci4f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKco4f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKci8f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKco8f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKlci4f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKlco4f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKlci8f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKlco8f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - -/* - ** from dfkfuji.c - */ - - HDFLIBAPI intn DFKpi4f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKpo4f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKpi8f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKpo8f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKlpi4f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKlpo4f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKlpi8f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - - HDFLIBAPI intn DFKlpo8f - (void * s, void * d, uint32 num_elm, uint32 source_stride, uint32 dest_stride); - -/* - ** from dfanF.c - */ -#ifndef DFAN_FNAMES -# define DFAN_FNAMES -#ifdef DF_CAPFNAMES -# define ndaiganl FNAME(DAIGANL) -# define ndaigann FNAME(DAIGANN) -# define ndaipann FNAME(DAIPANN) -# define ndailist FNAME(DAILIST) -# define ndalref FNAME(DALREF) -# define ndaclear FNAME(DACLEAR) -# define ndfanlastref FNAME(DFANLASTREF) - -# define ndfanaddfds FNAME(DFANADDFDS) -# define ndfangetfidlen FNAME(DFANGETFIDLEN) -# define ndfangetfdslen FNAME(DFANGETFDSLEN) -# define ndfangetfid FNAME(DFANGETFID) -# define ndfangetfds FNAME(DFANGETFDS) -# define ndaafds FNAME(DAAFDS) -# define ndagfidl FNAME(DAGFIDL) -# define ndagfdsl FNAME(DAGFDSL) -# define ndagfid FNAME(DAGFID) -# define ndagfds FNAME(DAGFDS) -# define ndaiafid FNAME(DAIAFID) -#else /* DF_CAPFNAMES */ -# define ndaiganl FNAME(daiganl) -# define ndaigann FNAME(daigann) -# define ndaipann FNAME(daipann) -# define ndailist FNAME(dailist) -# define ndalref FNAME(dalref) -# define ndaclear FNAME(daclear) -# define ndfanlastref FNAME(dfanlastref) - -# define ndfanaddfds FNAME(dfanaddfds) -# define ndfangetfidlen FNAME(dfangetfidlen) -# define ndfangetfdslen FNAME(dfangetfdslen) -# define ndfangetfid FNAME(dfangetfid) -# define ndfangetfds FNAME(dfangetfds) -# define ndaafds FNAME(daafds) -# define ndagfidl FNAME(dagfidl) -# define ndagfdsl FNAME(dagfdsl) -# define ndagfid FNAME(dagfid) -# define ndagfds FNAME(dagfds) -# define ndaiafid FNAME(daiafid) -#endif /* DF_CAPFNAMES */ -#endif /* DFAN_FNAMES */ - - HDFLIBAPI FRETVAL(intf) ndaiganl - (_fcd filename, intf * tag, intf * ref, intf * type, - intf * fnlen); - - HDFLIBAPI FRETVAL(intf) ndaigann - (_fcd filename, intf * tag, intf * ref, _fcd annotation, - intf * maxlen, intf * type, intf * fnlen); - - HDFLIBAPI FRETVAL(intf) ndaipann - (_fcd filename, intf * tag, intf * ref, _fcd annotation, - intf * annlen, intf * type, intf * fnlen); - - HDFLIBAPI FRETVAL(intf) ndailist - (_fcd filename, intf * tag, intf reflist[], _fcd labellist, - intf * listsize, intf * maxlen, intf * startpos, - intf * fnlen); - - HDFLIBAPI FRETVAL(intf) ndalref - (void); - - HDFLIBAPI FRETVAL(intf) ndaclear - (void); - - HDFLIBAPI FRETVAL(intf) ndfanlastref - (void); - - HDFLIBAPI FRETVAL(intf) ndfanaddfds - (intf * dfile, _fcd desc, intf * desclen); - - HDFLIBAPI FRETVAL(intf) ndfangetfidlen - (intf * dfile, intf * isfirst); - - HDFLIBAPI FRETVAL(intf) ndfangetfdslen - (intf * dfile, intf * isfirst); - - HDFLIBAPI FRETVAL(intf) ndfangetfid - (intf * dfile, _fcd id, intf * maxlen, intf * isfirst); - - HDFLIBAPI FRETVAL(intf) ndfangetfds - (intf * dfile, _fcd id, intf * maxlen, intf * isfirst); - - HDFLIBAPI FRETVAL(intf) ndaafds - (intf * dfile, _fcd desc, intf * desclen); - - HDFLIBAPI FRETVAL(intf) ndagfidl - (intf * dfile, intf * isfirst); - - HDFLIBAPI FRETVAL(intf) ndagfdsl - (intf * dfile, intf * isfirst); - - HDFLIBAPI FRETVAL(intf) ndagfid - (intf * dfile, _fcd id, intf * maxlen, intf * isfirst); - - HDFLIBAPI FRETVAL(intf) ndagfds - (intf * dfile, _fcd id, intf * maxlen, intf * isfirst); - - HDFLIBAPI FRETVAL(intf) ndaiafid - (intf * dfile, _fcd id, intf * idlen); - -/* - ** from dfr8F.c - */ -#ifndef DFR8_FNAMES -# define DFR8_FNAMES -#ifdef DF_CAPFNAMES -# define nd8spal FNAME(D8SPAL) -# define nd8first FNAME(D8FIRST) -# define nd8igdim FNAME(D8IGDIM) -# define nd8igimg FNAME(D8IGIMG) -# define nd8ipimg FNAME(D8IPIMG) -# define nd8iaimg FNAME(D8IAIMG) -# define nd8irref FNAME(D8IRREF) -# define nd8iwref FNAME(D8IWREF) -# define nd8inims FNAME(D8INIMS) -# define nd8lref FNAME(D8LREF) -# define ndfr8lastref FNAME(DFR8LASTREF) -# define ndfr8setpalette FNAME(DFR8SETPALETTE) -# define ndfr8restart FNAME(DFR8RESTART) -# define nd8scomp FNAME(D8SCOMP) -# define ndfr8scompress FNAME(DFR8SCOMPRESS) -# define nd8sjpeg FNAME(D8SJPEG) -# define ndfr8sjpeg FNAME(DFR8SJPEG) -#else /* !DF_CAPFNAMES */ -# define nd8spal FNAME(d8spal) -# define nd8first FNAME(d8first) -# define nd8igdim FNAME(d8igdim) -# define nd8igimg FNAME(d8igimg) -# define nd8ipimg FNAME(d8ipimg) -# define nd8iaimg FNAME(d8iaimg) -# define nd8irref FNAME(d8irref) -# define nd8iwref FNAME(d8iwref) -# define nd8inims FNAME(d8inims) -# define nd8lref FNAME(d8lref) -# define ndfr8lastref FNAME(dfr8lastref) -# define ndfr8setpalette FNAME(dfr8setpalette) -# define ndfr8restart FNAME(dfr8restart) -# define nd8scomp FNAME(d8scomp) -# define ndfr8scompress FNAME(dfr8scompress) -# define nd8sjpeg FNAME(d8sjpeg) -# define ndfr8sjpeg FNAME(dfr8sjpeg) -#endif /* DF_CAPFNAMES */ -#endif /* DFR8_FNAMES */ - - HDFLIBAPI FRETVAL(intf) nd8spal - (_fcd pal); - - HDFLIBAPI FRETVAL(intf) nd8first - (void); - - HDFLIBAPI FRETVAL(intf) nd8igdim - (_fcd filename, intf * xdim, intf * ydim, intf * ispal, - intf * lenfn); - - HDFLIBAPI FRETVAL(intf) nd8igimg - (_fcd filename, _fcd image, intf * xdim, intf * ydim, - _fcd pal, intf * lenfn); - - HDFLIBAPI FRETVAL(intf) nd8ipimg - (_fcd filename, _fcd image, intf * xdim, intf * ydim, - intf * compress, intf * lenfn); - - HDFLIBAPI FRETVAL(intf) nd8iaimg - (_fcd filename, _fcd image, intf * xdim, intf * ydim, - intf * compress, intf * lenfn); - - HDFLIBAPI FRETVAL(intf) nd8irref - (_fcd filename, intf * ref, intf * fnlen); - - HDFLIBAPI FRETVAL(intf) nd8iwref - (_fcd filename, intf * ref, intf * fnlen); - - HDFLIBAPI FRETVAL(intf) nd8inims - (_fcd filename, intf * fnlen); - - HDFLIBAPI FRETVAL(intf) nd8lref - (void); - - HDFLIBAPI FRETVAL(intf) ndfr8lastref - (void); - - HDFLIBAPI FRETVAL(intf) ndfr8setpalette - (_fcd pal); - - HDFLIBAPI FRETVAL(intf) ndfr8restart - (void); - - HDFLIBAPI FRETVAL(intf) nd8scomp - (intf * scheme); - - HDFLIBAPI FRETVAL(intf) ndfr8scompress - (intf * scheme); - - HDFLIBAPI FRETVAL(intf) nd8sjpeg - (intf * quality, intf * force_baseline); - - HDFLIBAPI FRETVAL(intf) ndfr8sjpeg - (intf * quality, intf * force_baseline); - -/* - ** from dfsdF.c - */ -#ifndef DFSD_FNAMES -# define DFSD_FNAMES -#ifdef DF_CAPFNAMES -# define ndsgdast FNAME(DSGDAST) -# define ndsgdisc FNAME(DSGDISC) -# define ndsgrang FNAME(DSGRANG) -# define ndssdims FNAME(DSSDIMS) -# define ndssdisc FNAME(DSSDISC) -# define ndssrang FNAME(DSSRANG) -# define ndsclear FNAME(DSCLEAR) -# define ndsslens FNAME(DSSLENS) -# define ndsgdiln FNAME(DSGDILN) -# define ndsgdaln FNAME(DSGDALN) -# define ndsfirst FNAME(DSFIRST) -# define ndspslc FNAME(DSPSLC) -# define ndseslc FNAME(DSESLC) -# define ndsgnt FNAME(DSGNT) -# define ndssnt FNAME(DSSNT) -# define ndsigdim FNAME(DSIGDIM) -# define ndsigdat FNAME(DSIGDAT) -# define ndsipdat FNAME(DSIPDAT) -# define ndsiadat FNAME(DSIADAT) -# define ndsigdas FNAME(DSIGDAS) -# define ndsigslc FNAME(DSIGSLC) -# define ndsigdis FNAME(DSIGDIS) -# define ndsisslc FNAME(DSISSLC) -# define ndsisdas FNAME(DSISDAS) -# define ndsisdis FNAME(DSISDIS) -# define ndsirref FNAME(DSIRREF) -# define ndslref FNAME(DSLREF) -# define ndsinum FNAME(DSINUM) -# define ndsip32s FNAME(DSIP32S) -# define ndsscal FNAME(DSSCAL) -# define ndsgcal FNAME(DSGCAL) -# define ndfsdgetdatastrs FNAME(DFSDGETDATASTRS) -# define ndfsdgetdimscale FNAME(DFSDGETDIMSCALE) -# define ndfsdgetrange FNAME(DFSDGETRANGE) -# define ndfsdsetdims FNAME(DFSDSETDIMS) -# define ndfsdsetdimscale FNAME(DFSDSETDIMSCALE) -# define ndfsdsetrange FNAME(DFSDSETRANGE) -# define ndfsdclear FNAME(DFSDCLEAR) -# define ndfsdsetlengths FNAME(DFSDSETLENGTHS) -# define ndfsdgetdimlen FNAME(DFSDGETDIMLEN) -# define ndfsdgetdatalen FNAME(DFSDGETDATALEN) -# define ndfsdrestart FNAME(DFSDRESTART) -# define ndfsdputslice FNAME(DFSDPUTSLICE) -# define ndfsdendslice FNAME(DFSDENDSLICE) -# define ndfsdsetnt FNAME(DFSDSETNT) -# define ndfsdgetnt FNAME(DFSDGETNT) -# define ndfsdlastref FNAME(DFSDLASTREF) -# define ndsiwref FNAME(DSIWREF) -# define ndssfill FNAME(DSSFILL) -# define ndsgfill FNAME(DSGFILL) -# define ndsisslab FNAME(DSISSLAB) -# define ndswslab FNAME(DSWSLAB) -# define ndseslab FNAME(DSESLAB) -# define ndsirslab FNAME(DSIRSLAB) -#else -# define ndsgdast FNAME(dsgdast) -# define ndsgdisc FNAME(dsgdisc) -# define ndsgrang FNAME(dsgrang) -# define ndssdims FNAME(dssdims) -# define ndssdisc FNAME(dssdisc) -# define ndssrang FNAME(dssrang) -# define ndsclear FNAME(dsclear) -# define ndsslens FNAME(dsslens) -# define ndsgdiln FNAME(dsgdiln) -# define ndsgdaln FNAME(dsgdaln) -# define ndsfirst FNAME(dsfirst) -# define ndspslc FNAME(dspslc) -# define ndseslc FNAME(dseslc) -# define ndsgnt FNAME(dsgnt) -# define ndssnt FNAME(dssnt) -# define ndsigdim FNAME(dsigdim) -# define ndsigdat FNAME(dsigdat) -# define ndsipdat FNAME(dsipdat) -# define ndsiadat FNAME(dsiadat) -# define ndsigdas FNAME(dsigdas) -# define ndsigslc FNAME(dsigslc) -# define ndsigdis FNAME(dsigdis) -# define ndsisslc FNAME(dsisslc) -# define ndsisdas FNAME(dsisdas) -# define ndsisdis FNAME(dsisdis) -# define ndsirref FNAME(dsirref) -# define ndslref FNAME(dslref) -# define ndsinum FNAME(dsinum) -# define ndsip32s FNAME(dsip32s) -# define ndsscal FNAME(dsscal) -# define ndsgcal FNAME(dsgcal) -# define ndfsdgetdatastrs FNAME(dfsdgetdatastrs) -# define ndfsdgetdimscale FNAME(dfsdgetdimscale) -# define ndfsdgetrange FNAME(dfsdgetrange) -# define ndfsdsetdims FNAME(dfsdsetdims) -# define ndfsdsetdimscale FNAME(dfsdsetdimscale) -# define ndfsdsetrange FNAME(dfsdsetrange) -# define ndfsdclear FNAME(dfsdclear) -# define ndfsdsetlengths FNAME(dfsdsetlengths) -# define ndfsdgetdimlen FNAME(dfsdgetdimlen) -# define ndfsdgetdatalen FNAME(dfsdgetdatalen) -# define ndfsdrestart FNAME(dfsdrestart) -# define ndfsdputslice FNAME(dfsdputslice) -# define ndfsdendslice FNAME(dfsdendslice) -# define ndfsdsetnt FNAME(dfsdsetnt) -# define ndfsdgetnt FNAME(dfsdgetnt) -# define ndfsdlastref FNAME(dfsdlastref) -# define ndsiwref FNAME(dsiwref) -# define ndssfill FNAME(dssfill) -# define ndsgfill FNAME(dsgfill) -# define ndsisslab FNAME(dsisslab) -# define ndswslab FNAME(dswslab) -# define ndseslab FNAME(dseslab) -# define ndsirslab FNAME(dsirslab) -#endif /* DF_CAPFNAMES */ -#endif /* DFSD_FNAMES */ - - HDFLIBAPI FRETVAL(intf) ndsgdisc - (intf * dim, intf * maxsize, void * scale); - - HDFLIBAPI FRETVAL(intf) ndsgrang - (void * pmax, void * pmin); - - HDFLIBAPI FRETVAL(intf) ndssdims - (intf * rank, intf dimsizes[]); - - HDFLIBAPI FRETVAL(intf) ndssdisc - (intf * dim, intf * dimsize, void * scale); - - HDFLIBAPI FRETVAL(intf) ndssrang - (void * max, void * min); - - HDFLIBAPI FRETVAL(intf) ndsclear - (void); - - HDFLIBAPI FRETVAL(intf) ndsslens - (intf * maxlen_label, intf * maxlen_unit, - intf * maxlen_format, intf * maxlen_coordsys); - - HDFLIBAPI FRETVAL(intf) ndsgdiln - (intf * dim, intf * llabel, intf * lunit, - intf * lformat); - - HDFLIBAPI FRETVAL(intf) ndsgdaln - (intf * llabel, intf * lunit, intf * lformat, - intf * lcoordsys); - - HDFLIBAPI FRETVAL(intf) ndsfirst - (void); - - HDFLIBAPI FRETVAL(intf) ndspslc - (intf windims[], void * data, intf dims[]); - - HDFLIBAPI FRETVAL(intf) ndseslc - (void); - - HDFLIBAPI FRETVAL(intf) ndssnt - (intf * numbertype); - - HDFLIBAPI FRETVAL(intf) ndsgnt - (intf * pnumbertype); - - HDFLIBAPI FRETVAL(intf) ndsigdim - (_fcd filename, intf * prank, intf sizes[], - intf * maxrank, intf * lenfn); - - HDFLIBAPI FRETVAL(intf) ndsigdat - (_fcd filename, intf * rank, intf maxsizes[], - void * data, intf * fnlen); - - HDFLIBAPI FRETVAL(intf) ndsipdat - (_fcd filename, intf * rank, intf dimsizes[], - void * data, intf * fnlen); - - HDFLIBAPI FRETVAL(intf) ndsiadat - (_fcd filename, intf * rank, intf dimsizes[], - void * data, intf * fnlen); - - HDFLIBAPI FRETVAL(intf) ndsigslc - (_fcd filename, intf winst[], intf windims[], - void * data, intf dims[], intf * fnlen); - - HDFLIBAPI FRETVAL(intf) ndsisslc - (_fcd filename, intf * fnlen); - - HDFLIBAPI FRETVAL(intf) ndsirref - (_fcd filename, intf * ref, intf * fnlen); - - HDFLIBAPI FRETVAL(intf) ndslref - (void); - - HDFLIBAPI FRETVAL(intf) ndsinum - (_fcd filename, intf * len); - - HDFLIBAPI FRETVAL(intf) ndsip32s - (_fcd filename, intf * ref, intf * ispre32, intf * len); - - HDFLIBAPI FRETVAL(intf) ndfsdgetdatastrs - (_fcd label, _fcd unit, _fcd format, _fcd coordsys); - - HDFLIBAPI FRETVAL(intf) ndfsdgetdimstrs - (intf * dim, _fcd label, _fcd unit, _fcd format); - - HDFLIBAPI FRETVAL(intf) ndfsdgetdimscale - (intf * dim, intf * maxsize, void * scale); - - HDFLIBAPI FRETVAL(intf) ndfsdgetrange - (void * pmax, void * pmin); - - HDFLIBAPI FRETVAL(intf) ndfsdsetdims - (intf * rank, intf dimsizes[]); - - HDFLIBAPI FRETVAL(intf) ndfsdsetdimscale - (intf * dim, intf * dimsize, void * scale); - - HDFLIBAPI FRETVAL(intf) ndfsdsetrange - (void * max, void * min); - - HDFLIBAPI FRETVAL(intf) ndfsdclear - (void); - - HDFLIBAPI FRETVAL(intf) ndfsdsetlengths - (intf * maxlen_label, intf * maxlen_unit, - intf * maxlen_format, intf * maxlen_coordsys); - - HDFLIBAPI FRETVAL(intf) ndfsdgetdimlen - (intf * dim, intf * llabel, intf * lunit, - intf * lformat); - - HDFLIBAPI FRETVAL(intf) ndfsdgetdatalen - (intf * llabel, intf * lunit, intf * lformat, - intf * lcoordsys); - - HDFLIBAPI FRETVAL(intf) ndfsdrestart - (void); - - HDFLIBAPI FRETVAL(intf) ndfsdputslice - (intf windims[], void * data, intf dims[]); - - HDFLIBAPI FRETVAL(intf) ndfsdendslice - (void); - - HDFLIBAPI FRETVAL(intf) ndfsdsetnt - (intf * numbertype); - - HDFLIBAPI FRETVAL(intf) ndfsdgetnt - (intf * pnumbertype); - - HDFLIBAPI FRETVAL(intf) ndfsdlastref - (void); - - HDFLIBAPI FRETVAL(intf) ndsisdis - (intf * dim, _fcd flabel, _fcd funit, _fcd fformat, - intf * llabel, intf * lunit, intf * lformat); - - HDFLIBAPI FRETVAL(intf) ndsigdis - (intf * dim, _fcd label, _fcd unit, _fcd format, - intf * llabel, intf * lunit, intf * lformat); - - HDFLIBAPI FRETVAL(intf) ndsisdas - (_fcd flabel, _fcd funit, _fcd fformat, _fcd fcoordsys, - intf * isfortran, intf * llabel, intf * lunit, - intf * lformat, intf * lcoordsys); - - HDFLIBAPI FRETVAL(intf) ndsigdas - (_fcd label, _fcd unit, _fcd format, _fcd coordsys, intf * llabel, - intf * lunit, intf * lformat, intf * lcoord); - - HDFLIBAPI FRETVAL(intf) ndsscal - (float64 * cal, float64 * cal_err, float64 * ioff, - float64 * ioff_err, intf * cal_type); - - HDFLIBAPI FRETVAL(intf) ndsgcal - (float64 * cal, float64 * cal_err, float64 * ioff, - float64 * ioff_err, intf * cal_type); - - HDFLIBAPI FRETVAL(intf) ndswref - (_fcd filename, intf * fnlen, intf * ref); - - HDFLIBAPI FRETVAL(intf) ndssfill - (void * fill_value); - - HDFLIBAPI FRETVAL(intf) ndsgfill - (void * fill_value); - - HDFLIBAPI FRETVAL(intf) ndssslab - (_fcd filename, intf * fnlen); - - HDFLIBAPI FRETVAL(intf) ndswslab - (intf start[], intf stride[], - intf cont[], void * data); - - HDFLIBAPI FRETVAL(intf) ndseslab - (void); - - HDFLIBAPI FRETVAL(intf) ndsiwref - (_fcd filename, intf * fnlen, intf * ref); - - HDFLIBAPI FRETVAL(intf) ndsisslab - (_fcd filename, intf * fnlen); - - HDFLIBAPI FRETVAL(intf) ndsirslab - (_fcd filename, intf * fnlen, intf start[], intf slab_size[], - intf stride[], void * buffer, intf buffer_size[]); - -/* - ** from dfpF.c - */ - -#ifndef DFP_FNAMES -# define DFP_FNAMES -#ifdef DF_CAPFNAMES -# define ndpigpal FNAME(DPIGPAL) -# define ndpippal FNAME(DPIPPAL) -# define ndpinpal FNAME(DPINPAL) -# define ndpiwref FNAME(DPIWREF) -# define ndpirref FNAME(DPIRREF) -# define ndprest FNAME(DPREST) -# define ndplref FNAME(DPLREF) -# define ndfprestart FNAME(DFPRESTART) -# define ndfplastref FNAME(DFPLASTREF) -#else /* !DF_CAPNAMES */ -# define ndpigpal FNAME(dpigpal) -# define ndpippal FNAME(dpippal) -# define ndpinpal FNAME(dpinpal) -# define ndpiwref FNAME(dpiwref) -# define ndpirref FNAME(dpirref) -# define ndprest FNAME(dprest) -# define ndplref FNAME(dplref) -# define ndfprestart FNAME(dfprestart) -# define ndfplastref FNAME(dfplastref) -#endif /* DF_CAPFNAMES */ -#endif /* DFP_FNAMES */ - - HDFLIBAPI FRETVAL(intf) ndpigpal - (_fcd filename, _fcd pal, intf * fnlen); - - HDFLIBAPI FRETVAL(intf) ndpippal - (_fcd filename, _fcd pal, intf * overwrite, _fcd filemode, - intf * fnlen); - - HDFLIBAPI FRETVAL(intf) ndpinpal - (_fcd filename, intf * fnlen); - - HDFLIBAPI FRETVAL(intf) ndpirref - (_fcd filename, intf * ref, intf * fnlen); - - HDFLIBAPI FRETVAL(intf) ndpiwref - (_fcd filename, intf * ref, intf * fnlen); - - HDFLIBAPI FRETVAL(intf) ndprest - (void); - - HDFLIBAPI FRETVAL(intf) ndplref - (void); - - HDFLIBAPI FRETVAL(intf) ndfprestart - (void); - - HDFLIBAPI FRETVAL(intf) ndfplastref - (void); - -/* - ** from df24F.c - */ -#ifndef DF24_FNAMES -# define DF24_FNAMES -#ifdef DF_CAPFNAMES -# define nd2reqil FNAME(D2REQIL) -# define ndf24reqil FNAME(DF24REQIL) -# define nd2sdims FNAME(D2SDIMS) -# define ndf24setdims FNAME(DF24SETDIMS) -# define nd2setil FNAME(D2SETIL) -# define ndf24setil FNAME(DF24SETIL) -# define nd2first FNAME(D2FIRST) -# define ndf24restart FNAME(DF24RESTART) -# define nd2igdim FNAME(D2IGDIM) -# define nd2igimg FNAME(D2IGIMG) -# define nd2iaimg FNAME(D2IAIMG) -# define nd2irref FNAME(D2IRREF) -# define nd2inimg FNAME(D2INIMG) -# define nd2lref FNAME(D2LREF) -# define nd2scomp FNAME(D2SCOMP) -# define ndf24scompress FNAME(DF24SCOMPRESS) -# define nd2sjpeg FNAME(D2SJPEG) -# define ndf24sjpeg FNAME(DF24SJPEG) -#else -# define nd2reqil FNAME(d2reqil) -# define ndf24reqil FNAME(df24reqil) -# define nd2sdims FNAME(d2sdims) -# define ndf24setdims FNAME(df24setdims) -# define nd2setil FNAME(d2setil) -# define ndf24setil FNAME(df24setil) -# define nd2first FNAME(d2first) -# define ndf24restart FNAME(df24restart) -# define nd2igdim FNAME(d2igdim) -# define nd2igimg FNAME(d2igimg) -# define nd2iaimg FNAME(d2iaimg) -# define nd2irref FNAME(d2irref) -# define nd2inimg FNAME(d2inimg) -# define nd2lref FNAME(d2lref) -# define nd2scomp FNAME(d2scomp) -# define ndf24scompress FNAME(df24scompress) -# define nd2sjpeg FNAME(d2sjpeg) -# define ndf24sjpeg FNAME(df24sjpeg) -#endif /* DF_CAPFNAMES */ -#endif /* DF24_FNAMES */ - - HDFLIBAPI FRETVAL(intf) nd2reqil - (intf * il); - - HDFLIBAPI FRETVAL(intf) nd2sdims - (intf * xdim, intf * ydim); - - HDFLIBAPI FRETVAL(intf) nd2igdim - (_fcd filename, intf * pxdim, intf * pydim, intf * pil, - intf * fnlen); - - HDFLIBAPI FRETVAL(intf) nd2igimg - (_fcd filename, _fcd image, intf * xdim, intf * ydim, - intf * fnlen); - - HDFLIBAPI FRETVAL(intf) nd2iaimg - (_fcd filename, _fcd image, intf * xdim, intf * ydim, - intf * fnlen, intf * newfile); - - HDFLIBAPI FRETVAL(intf) nd2setil - (intf * il); - - HDFLIBAPI FRETVAL(intf) nd2first - (void); - - HDFLIBAPI FRETVAL(intf) ndf24reqil - (intf * il); - - HDFLIBAPI FRETVAL(intf) ndf24setdims - (intf * xdim, intf * ydim); - - HDFLIBAPI FRETVAL(intf) ndf24setil - (intf * il); - - HDFLIBAPI FRETVAL(intf) ndf24restart - (void); - - HDFLIBAPI FRETVAL(intf) nd2irref - (_fcd filename, intf * ref, intf * fnlen); - - HDFLIBAPI FRETVAL(intf) nd2inimg - (_fcd filename, intf * fnlen); - - HDFLIBAPI FRETVAL(intf) nd2lref - (void); - - HDFLIBAPI FRETVAL(intf) nd2scomp - (intf * scheme); - - HDFLIBAPI FRETVAL(intf) ndf24scompress - (intf * scheme); - - HDFLIBAPI FRETVAL(intf) nd2sjpeg - (intf * quality, intf * force_baseline); - - HDFLIBAPI FRETVAL(intf) ndf24sjpeg - (intf * quality, intf * force_baseline); - -/* - ** from dfF.c - */ -#ifndef DF_FNAMES -# define DF_FNAMES -#ifdef DF_CAPFNAMES -# define ndfiaccess FNAME(DFIACCESS) -# define ndfiopen FNAME(DFIOPEN) -# define ndfclose FNAME(DFCLOSE) -# define ndfdesc FNAME(DFDESC) -# define ndfdup FNAME(DFDUP) -# define ndfdel FNAME(DFDEL) -# define ndfstart FNAME(DFSTART) -# define ndfread FNAME(DFREAD) -# define ndfseek FNAME(DFSEEK) -# define ndfwrite FNAME(DFWRITE) -# define ndfupdate FNAME(DFUPDATE) -# define ndfget FNAME(DFGET) -# define ndfput FNAME(DFPUT) -# define ndfsfind FNAME(DFSFIND) -# define ndffind FNAME(DFFIND) -# define ndferrno FNAME(DFERRNO) -# define ndfnewref FNAME(DFNEWREF) -# define ndfnumber FNAME(DFNUMBER) -# define ndfstat FNAME(DFSTAT) -# define ndfiishdf FNAME(DFIISHDF) -#else /* !DF_CAPFNAMES */ -# define ndfiaccess FNAME(dfiaccess) -# define ndfiopen FNAME(dfiopen) -# define ndfclose FNAME(dfclose) -# define ndfdesc FNAME(dfdesc) -# define ndfdup FNAME(dfdup) -# define ndfdel FNAME(dfdel) -# define ndfstart FNAME(dfstart) -# define ndfread FNAME(dfread) -# define ndfseek FNAME(dfseek) -# define ndfwrite FNAME(dfwrite) -# define ndfupdate FNAME(dfupdate) -# define ndfget FNAME(dfget) -# define ndfput FNAME(dfput) -# define ndfsfind FNAME(dfsfind) -# define ndffind FNAME(dffind) -# define ndferrno FNAME(dferrno) -# define ndfnewref FNAME(dfnewref) -# define ndfnumber FNAME(dfnumber) -# define ndfstat FNAME(dfstat) -# define ndfiishdf FNAME(dfiishdf) -#endif /* DF_CAPFNAMES */ -#endif /* DF_FNAMES */ - - HDFLIBAPI FRETVAL(intf) ndfiopen - (_fcd name, intf * acc_mode, intf * defdds, intf * namelen); - - HDFLIBAPI FRETVAL(intf) ndfclose - (intf * dfile); - - HDFLIBAPI FRETVAL(intf) ndfdesc - (intf * dfile, intf ptr[][4], intf * begin, - intf * num); - - HDFLIBAPI FRETVAL(intf) ndfdup - (intf * dfile, intf * tag, intf * ref, intf * otag, - intf * oref); - - HDFLIBAPI FRETVAL(intf) ndfdel - (intf * dfile, intf * tag, intf * ref); - - HDFLIBAPI FRETVAL(intf) ndfiaccess - (intf * dfile, intf * tag, intf * ref, _fcd acc_mode, intf * acclen); - - HDFLIBAPI FRETVAL(intf) ndfstart - (intf * dfile, intf * tag, intf * ref, char * acc_mode); - - HDFLIBAPI FRETVAL(intf) ndfread - (intf * dfile, _fcd ptr, intf * len); - - HDFLIBAPI FRETVAL(intf) ndfseek - (intf * dfile, intf * offset); - - HDFLIBAPI FRETVAL(intf) ndfwrite - (intf * dfile, _fcd ptr, intf * len); - - HDFLIBAPI FRETVAL(intf) ndfupdate - (intf * dfile); - - HDFLIBAPI FRETVAL(intf) ndfget - (intf * dfile, intf * tag, intf * ref, _fcd ptr); - - HDFLIBAPI FRETVAL(intf) ndfput - (intf * dfile, intf * tag, intf * ref, _fcd ptr, intf * len); - - HDFLIBAPI FRETVAL(intf) ndfsfind - (intf * dfile, intf * tag, intf * ref); - - HDFLIBAPI FRETVAL(intf) ndffind - (intf * dfile, intf * itag, intf * iref, intf * len); - - HDFLIBAPI FRETVAL(intf) ndferrno - (void); - - HDFLIBAPI FRETVAL(intf) ndfnewref - (intf * dfile); - - HDFLIBAPI FRETVAL(intf) ndfnumber - (intf * dfile, intf * tag); - - HDFLIBAPI FRETVAL(intf) ndfiishdf - (_fcd name, intf * namelen); - -/* - ** from dfutil.c - */ - HDFLIBAPI uint16 DFfindnextref - (int32 file_id, uint16 tag, uint16 lref); - -/* - ** from dfutilF.c - */ -#ifndef DFUTIL_FNAMES -# define DFUTIL_FNAMES -#ifdef DF_CAPFNAMES -# define ndfindnr FNAME(DFINDNR) -# define ndffindnextref FNAME(DFFINDNEXTREF) -#else -# define ndfindnr FNAME(dfindnr) -# define ndffindnextref FNAME(dffindnextref) -#endif /* DF_CAPFNAMES */ -#endif /* DFUTIL_FNAMES */ - - HDFLIBAPI FRETVAL(intf) ndfindnr - (intf * dfile, intf * tag, intf * lref); - - HDFLIBAPI FRETVAL(intf) ndffindnextref - (intf * dfile, intf * tag, intf * lref); - -/* - ** from herrF.c - */ -#ifndef HERR_FNAMES -# define HERR_FNAMES -#ifdef DF_CAPFNAMES -# define nheprnt FNAME(HEPRNT) -# define nheprntc FNAME(HEPRNTC) -# define nhestringc FNAME(HESTRINGC) -#else -# define nheprnt FNAME(heprnt) -# define nheprntc FNAME(heprntc) -# define nhestringc FNAME(hestringc) -#endif /* DF_CAPFNAMES */ -#endif /* HERR_FNAMES */ - - HDFLIBAPI FRETVAL(void) nheprnt - (intf * print_levels); - - HDFLIBAPI FRETVAL(intf) nheprntc - (_fcd filename, intf * print_levels, intf *namelen); - - HDFLIBAPI FRETVAL(intf) nhestringc - (intf *error_code,_fcd error_message, intf *len); -/* - ** from hfileF.c - */ -#ifndef HFILE_FNAMES -# define HFILE_FNAMES -#ifdef DF_CAPFNAMES -# if defined(UNIX386) || (!(defined INTEL86) && !(defined WIN32)) -# define nhiopen FNAME(HIOPEN) -# define nhclose FNAME(HCLOSE) -# define nhnumber FNAME(HNUMBER) -# define nhxisdir FNAME(HXISDIR) -# define nhxiscdir FNAME(HXISCDIR) -# define nhddontatexit FNAME(HDDONTATEXIT) -# define nhglibverc FNAME(HGLIBVERC) -# define nhgfilverc FNAME(HGFILVERC) -# define nhiishdf FNAME(HIISHDF) -# else /* !sl */ -# define nhiopen FNAME(HIOPEN) -# define nhiclose FNAME(HICLOSE) -# define nhinumbr FNAME(HINUMBR) -# define nhxisdir FNAME(HXISDIR) -# define nhxiscdir FNAME(HXISCDIR) -# define nhddontatexit FNAME(HDDONTATEXIT) -# define nhglibverc FNAME(HGLIBVERC) -# define nhgfilverc FNAME(HGFILVERC) -# define nhiishdf FNAME(HIISHDF) -# endif - -#else -# if defined(UNIX386) || (!(defined INTEL86) && !(defined WIN32)) -# define nhiopen FNAME(hiopen) -# define nhclose FNAME(hclose) -# define nhnumber FNAME(hnumber) -# define nhxisdir FNAME(hxisdir) -# define nhxiscdir FNAME(hxiscdir) -# define nhddontatexit FNAME(hddontatexit) -# define nhglibverc FNAME(hglibverc) -# define nhgfilverc FNAME(hgfilverc) -# define nhiishdf FNAME(hiishdf) -# else /* !sl */ -# define nhiopen FNAME(hiopen) -# define nhiclose FNAME(hiclose) -# define nhinumbr FNAME(hinumbr) -# define nhxisdir FNAME(hxisdir) -# define nhxiscdir FNAME(hxiscdir) -# define nhddontatexit FNAME(hddontatexit) -# define nhglibverc FNAME(hglibverc) -# define nhgfilverc FNAME(hgfilverc) -# define nhiishdf FNAME(hiishdF) -# endif - -#endif /* DF_CAPFNAMES */ -#endif /* HFILE_FNAMES */ - - HDFLIBAPI FRETVAL(intf) nhiopen - (_fcd name, intf * acc_mode, intf * defdds, intf * namelen); - - HDFLIBAPI FRETVAL(intf) nhclose - (intf * file_id); - - HDFLIBAPI FRETVAL(intf) nhnumber - (intf * file_id, intf * tag); - - HDFLIBAPI FRETVAL(intf) nhxisdir - (_fcd dir, intf * dirlen); - - HDFLIBAPI FRETVAL(intf) nhxiscdir - (_fcd dir, intf * dirlen); - - HDFLIBAPI FRETVAL(intf) - nhddontatexit(void); - - HDFLIBAPI FRETVAL(intf) - nhglibverc(intf *major_v, intf *minor_v, intf *release, - _fcd string, intf *len); - - HDFLIBAPI FRETVAL(intf) - nhgfilverc(intf *file_id, intf *major_v, intf *minor_v, - intf *release, _fcd string, intf *len); - - HDFLIBAPI FRETVAL(intf) nhiishdf - (_fcd name, intf * namelen); - - - -/* - ** from dfufp2im.c - */ -#ifndef DFUFP2I_FNAMES -# define DFUFP2I_FNAMES -#ifdef DF_CAPFNAMES -# define nduif2i FNAME(DUIF2I) -#else -# define nduif2i FNAME(duif2i) -#endif /* DF_CAPFNAMES */ -#endif /* DFUFP2I_FNAMES */ - - HDFLIBAPI FRETVAL(int) nduif2i - (int32 * hdim, int32 * vdim, float32 * max, - float32 * min, float32 hscale[], float32 vscale[], - float32 data[], _fcd palette, _fcd outfile, - int * ct_method, int32 * hres, int32 * vres, - int * compress, int * lenfn); - - HDFLIBAPI int DFUfptoimage - (int32 hdim, int32 vdim, float32 max, float32 min, - float32 * hscale, float32 * vscale, float32 * data, - uint8 * palette, char * outfile, int ct_method, - int32 hres, int32 vres, int compress); - -/* for Multi-file fortran Annotation inteface */ -#ifndef MFAN_FNAMES -# define MFAN_FNAMES -#ifdef DF_CAPFNAMES -# if defined(UNIX386) || (!(defined INTEL86) && !(defined WIN32)) -# define nafstart FNAME(AFSTART) -# define naffileinfo FNAME(AFFILEINFO) -# define nafend FNAME(AFEND) -# define nafcreate FNAME(AFCREATE) -# define naffcreate FNAME(AFFCREATE) -# define nafselect FNAME(AFSELECT) -# define nafnumann FNAME(AFNUMANN) -# define nafannlist FNAME(AFANNLIST) -# define nafannlen FNAME(AFANNLEN) -# define nafwriteann FNAME(AFWRITEANN) -# define nafreadann FNAME(AFREADANN) -# define nafendaccess FNAME(AFENDACCESS) -# define nafgettagref FNAME(AFGETTAGREF) -# define nafidtagref FNAME(AFIDTAGREF) -# define naftagrefid FNAME(AFTAGREFID) -# define nafatypetag FNAME(AFATYPETAG) -# define naftagatype FNAME(AFTAGATYPE) -# else /* !sl */ -# define nafistart FNAME(AFISTART) -# define nafifinf FNAME(AFIFINF) -# define nafiend FNAME(AFIEND) -# define naficreat FNAME(AFICREAT) -# define nafifcreat FNAME(AFIFCREAT) -# define nafiselct FNAME(AFISELCT) -# define nafinann FNAME(AFINANN) -# define nafialst FNAME(AFIALST) -# define nafialen FNAME(AFIALEN) -# define nafiwann FNAME(AFIWANN) -# define nafirann FNAME(AFIRANN) -# define nafiendac FNAME(AFIENDAC) -# define nafigtr FNAME(AFIGTR) -# define nafiid2tr FNAME(AFIID2TR) -# define nafitr2id FNAME(AFITR2ID) -# define nafitp2tg FNAME(AFITP2TG) -# define nafitg2tp FNAME(AFITG2TP) -# endif -#else /* !DF_CAPFNAMES */ -# if defined(UNIX386) || (!(defined INTEL86) && !(defined WIN32)) -# define nafstart FNAME(afstart) -# define naffileinfo FNAME(affileinfo) -# define nafend FNAME(afend) -# define nafcreate FNAME(afcreate) -# define naffcreate FNAME(affcreate) -# define nafselect FNAME(afselect) -# define nafnumann FNAME(afnumann) -# define nafannlist FNAME(afannlist) -# define nafannlen FNAME(afannlen) -# define nafwriteann FNAME(afwriteann) -# define nafreadann FNAME(afreadann) -# define nafendaccess FNAME(afendaccess) -# define nafgettagref FNAME(afgettagref) -# define nafidtagref FNAME(afidtagref) -# define naftagrefid FNAME(aftagrefid) -# define nafatypetag FNAME(afatypetag) -# define naftagatype FNAME(aftagatype) -# else /* !sl */ -# define nafistart FNAME(afistart) -# define nafifinf FNAME(afifinf) -# define nafiend FNAME(afiend) -# define naficreat FNAME(aficreat) -# define nafifcreat FNAME(afifcreat) -# define nafiselct FNAME(afiselct) -# define nafinann FNAME(afinamm) -# define nafialst FNAME(afialst) -# define nafialen FNAME(afialen) -# define nafiwann FNAME(afiwann) -# define nafirann FNAME(afirann) -# define nafiendac FNAME(afiendac) -# define nafigtr FNAME(afigtr) -# define nafiid2tr FNAME(afiid2tr) -# define nafitr2id FNAME(afitr2id) -# define nafitp2tg FNAME(afitp2tg) -# define nafitg2tp FNAME(afitg2tp) -# endif -#endif /* DF_CAPFNAMES */ -#endif /* MFAN_FNAMES */ - -/* Multi-file Annotation C-stubs for fortan interface found in mfanf.c */ - -HDFLIBAPI FRETVAL(intf) -nafstart(intf *file_id); - -HDFLIBAPI FRETVAL(intf) -naffileinfo(intf *an_id, intf *num_flabel, intf *num_fdesc, intf *num_olabel, - intf *num_odesc); - -HDFLIBAPI FRETVAL(intf) -nafend(intf *an_id); - -HDFLIBAPI FRETVAL(intf) -nafcreate(intf *an_id, intf *etag, intf *eref, intf *atype); - -HDFLIBAPI FRETVAL(intf) -naffcreate(intf *an_id, intf *atype); - -HDFLIBAPI FRETVAL(intf) -nafselect(intf *an_id, intf *idx, intf *atype); - -HDFLIBAPI FRETVAL(intf) -nafnumann(intf *an_id, intf *atype, intf *etag, intf *eref); - -HDFLIBAPI FRETVAL(intf) -nafannlist(intf *an_id, intf *atype, intf *etag, intf *eref, intf alist[]); - -HDFLIBAPI FRETVAL(intf) -nafannlen(intf *ann_id); - -HDFLIBAPI FRETVAL(intf) -nafwriteann(intf *ann_id,_fcd ann, intf *annlen); - -HDFLIBAPI FRETVAL(intf) -nafreadann(intf *ann_id,_fcd ann, intf *maxlen); - -HDFLIBAPI FRETVAL(intf) -nafendaccess(intf *ann_id); - -HDFLIBAPI FRETVAL(intf) -nafgettagref(intf *an_id, intf *idx, intf *type, intf *tag, intf *ref); - -HDFLIBAPI FRETVAL(intf) -nafidtagref(intf *ann_id, intf *tag, intf *ref); - -HDFLIBAPI FRETVAL(intf) -naftagrefid(intf *an_id, intf *tag, intf *ref); - -HDFLIBAPI FRETVAL(intf) -nafatypetag(intf *atype); - -HDFLIBAPI FRETVAL(intf) -naftagatype(intf *tag); - -/* Multi-file Annotation C-routines found in mfan.c */ -HDFLIBAPI int32 ANstart(int32 file_id); - -HDFLIBAPI intn ANfileinfo(int32 an_id, int32 *n_file_label, int32 *n_file_desc, - int32 *n_obj_label, int32 *n_obj_desc); - -HDFLIBAPI int32 ANend(int32 an_id); - -HDFLIBAPI int32 ANcreate(int32 an_id, uint16 elem_tag, uint16 elem_ref, - ann_type type); - -HDFLIBAPI int32 ANcreatef(int32 an_id, ann_type type); - -HDFLIBAPI int32 ANselect(int32 an_id, int32 idx, ann_type type); - -HDFLIBAPI intn ANnumann(int32 an_id, ann_type type, uint16 elem_tag, - uint16 elem_ref); - -HDFLIBAPI intn ANannlist(int32 an_id, ann_type type, uint16 elem_tag, - uint16 elem_ref, int32 ann_list[]); - -HDFLIBAPI int32 ANannlen(int32 ann_id); - -HDFLIBAPI int32 ANwriteann(int32 ann_id, const char *ann, int32 annlen); - -HDFLIBAPI int32 ANreadann(int32 ann_id, char *ann, int32 maxlen); - -HDFLIBAPI intn ANendaccess(int32 ann_id); - -HDFLIBAPI int32 ANget_tagref(int32 an_id, int32 idx, ann_type type, - uint16 *ann_tag, uint16 *ann_ref); - -HDFLIBAPI int32 ANid2tagref(int32 an_id, uint16 *ann_tag, uint16 *ann_ref); - -HDFLIBAPI int32 ANtagref2id(int32 an_id, uint16 ann_tag, uint16 ann_ref); - -HDFLIBAPI uint16 ANatype2tag(ann_type atype); - -HDFLIBAPI ann_type ANtag2atype(uint16 atag); - -HDFLIBAPI intn ANdestroy(void); - -/* for Multi-file fortran GR interface */ -#ifndef MFGR_FNAMES -# define MFGR_FNAMES -#ifdef DF_CAPFNAMES -# if defined(UNIX386) || (!(defined INTEL86) && !(defined WIN32)) -# define nmgstart FNAME(MGSTART) -# define nmgfinfo FNAME(MGFINFO) -# define nmgend FNAME(MGEND) -# define nmgicreat FNAME(MGICREAT) -# define nmgselct FNAME(MGSELCT) -# define nmgin2ndx FNAME(MGIN2NDX) -# define nmggiinf FNAME(MGGIINF) -# define nmgwcimg FNAME(MGWCIMG) -# define nmgrcimg FNAME(MGRCIMG) -# define nmgwrimg FNAME(MGWRIMG) -# define nmgrdimg FNAME(MGRDIMG) -# define nmgendac FNAME(MGENDAC) -# define nmgid2rf FNAME(MGID2RF) -# define nmgr2idx FNAME(MGR2IDX) -# define nmgrltil FNAME(MGRLTIL) -# define nmgrimil FNAME(MGRIMIL) -# define nmggltid FNAME(MGGLTID) -# define nmgglinf FNAME(MGGLINF) -# define nmgwrlut FNAME(MGWRLUT) -# define nmgwclut FNAME(MGWCLUT) -# define nmgrdlut FNAME(MGRDLUT) -# define nmgrclut FNAME(MGRCLUT) -# define nmgisxfil FNAME(MGISXFIL) -# define nmgssctp FNAME(MGSACTP) -# define nmgiscatt FNAME(MGISCATT) -# define nmgisattr FNAME(MGISATTR) -# define nmgatinf FNAME(MGATINF) -# define nmggcatt FNAME(MGGCATT) -# define nmggnatt FNAME(MGGNATT) -# define nmggattr FNAME(MGGATTR) -# define nmgifndat FNAME(MGIFNDAT) -# define nmgcgichnk FNAME(MGCGICHNK) -# define nmgcrcchnk FNAME(MGCRCCHNK) -# define nmgcrchnk FNAME(MGCRCHNK) -# define nmgcscchnk FNAME(MGCSCCHNK) -# define nmgcschnk FNAME(MGCSCHNK) -# define nmgcwcchnk FNAME(MGCWCCHNK) -# define nmgcwchnk FNAME(MGCWCHNK) -# define nmgcscompress FNAME(MGCSCOMPRESS) -# define nmgcgcompress FNAME(MGCGCOMPRESS) -# define nmglt2rf FNAME(MGLT2RF) -# define nmgcgnluts FNAME(MGCGNLUTS) -# else /* !sl */ -# define nmgistrt FNAME(MGISTRT) -# define nmgifinf FNAME(MGIFINF) -# define nmgiend FNAME(MGIEND) -# define nmgicreat FNAME(MGICREAT) -# define nmgislct FNAME(MGISLCT) -# define nmgin2ndx FNAME(MGIN2NDX) -# define nmgigiinf FNAME(MGIGIINF) -# define nmgiwcim FNAME(MGIWCIM) -# define nmgircim FNAME(MGIRCIM) -# define nmgiwimg FNAME(MGIWIMG) -# define nmgirimg FNAME(MGIRIMG) -# define nmgiendac FNAME(MGIENDAC) -# define nmgiid2r FNAME(MGIID2R) -# define nmgir2dx FNAME(MGIR2DX) -# define nmgiltil FNAME(MGILTIL) -# define nmgiimil FNAME(MGIIMIL) -# define nmgiglid FNAME(MGIGLID) -# define nmgiglinf FNAME(MGIGLINF) -# define nmgiwrlt FNAME(MGIWRLT) -# define nmgiwclt FNAME(MGIWCLT) -# define nmgirdlt FNAME(MGIRDLT) -# define nmgirclt FNAME(MGIRCLT) -# define nmgisxfil FNAME(MGISXFIL) -# define nmgiactp FNAME(MGIACTP) -# define nmgiscatt FNAME(MGISCATT) -# define nmgisattr FNAME(MGISATTR) -# define nmgiainf FNAME(MGIAINF) -# define nmgigcat FNAME(MGIGCAT) -# define nmgignat FNAME(MGIGNAT) -# define nmgigatt FNAME(MGIGATT) -# define nmgifndat FNAME(MGIFNDAT) -# define nmgcgichnk FNAME(MGCGICHNK) -# define nmgcrcchnk FNAME(MGCRCCHNK) -# define nmgcrchnk FNAME(MGCRCHNK) -# define nmgcscchnk FNAME(MGCSCCHNK) -# define nmgcschnk FNAME(MGCSCHNK) -# define nmgcwcchnk FNAME(MGCWCCHNK) -# define nmgcwchnk FNAME(MGCWCHNK) -# define nmgcscompress FNAME(MGCSCOMPRESS) -# define nmgcgcompress FNAME(MGCGCOMPRESS) -# define nmglt2rf FNAME(MGLT2RF) -# define nmgcgnluts FNAME(MGCGNLUTS) -# endif -#else /* !DF_CAPFNAMES */ -# if defined(UNIX386) || (!(defined INTEL86) && !(defined WIN32)) -# define nmgstart FNAME(mgstart) -# define nmgfinfo FNAME(mgfinfo) -# define nmgend FNAME(mgend) -# define nmgicreat FNAME(mgicreat) -# define nmgselct FNAME(mgselct) -# define nmgin2ndx FNAME(mgin2ndx) -# define nmggiinf FNAME(mggiinf) -# define nmgwcimg FNAME(mgwcimg) -# define nmgrcimg FNAME(mgrcimg) -# define nmgwrimg FNAME(mgwrimg) -# define nmgrdimg FNAME(mgrdimg) -# define nmgendac FNAME(mgendac) -# define nmgid2rf FNAME(mgid2rf) -# define nmgr2idx FNAME(mgr2idx) -# define nmgrltil FNAME(mgrltil) -# define nmgrimil FNAME(mgrimil) -# define nmggltid FNAME(mggltid) -# define nmgglinf FNAME(mgglinf) -# define nmgwrlut FNAME(mgwrlut) -# define nmgwclut FNAME(mgwclut) -# define nmgrdlut FNAME(mgrdlut) -# define nmgrclut FNAME(mgrclut) -# define nmgisxfil FNAME(mgisxfil) -# define nmgssctp FNAME(mgsactp) -# define nmgiscatt FNAME(mgiscatt) -# define nmgisattr FNAME(mgisattr) -# define nmgatinf FNAME(mgatinf) -# define nmggcatt FNAME(mggcatt) -# define nmggnatt FNAME(mggnatt) -# define nmggattr FNAME(mggattr) -# define nmgifndat FNAME(mgifndat) -# define nmgcgichnk FNAME(mgcgichnk) -# define nmgcrcchnk FNAME(mgcrcchnk) -# define nmgcrchnk FNAME(mgcrchnk) -# define nmgcscchnk FNAME(mgcscchnk) -# define nmgcschnk FNAME(mgcschnk) -# define nmgcwcchnk FNAME(mgcwcchnk) -# define nmgcwchnk FNAME(mgcwchnk) -# define nmgcscompress FNAME(mgcscompress) -# define nmgcgcompress FNAME(mgcgcompress) -# define nmglt2rf FNAME(mglt2rf) -# define nmgcgnluts FNAME(mgcgnluts) -# else /* !sl */ -# define nmgistrt FNAME(mgistrt) -# define nmgifinf FNAME(mgifinf) -# define nmgiend FNAME(mgiend) -# define nmgicreat FNAME(mgicreat) -# define nmgislct FNAME(mgislct) -# define nmgin2ndx FNAME(mgin2ndx) -# define nmgigiinf FNAME(mgigiinf) -# define nmgiwcim FNAME(mgiwcim) -# define nmgircim FNAME(mgircim) -# define nmgwimg FNAME(mgiwimg) -# define nmgrimg FNAME(mgirimg) -# define nmgiendac FNAME(mgiendac) -# define nmgiid2r FNAME(mgiid2r) -# define nmgir2dx FNAME(mgir2dx) -# define nmgiltil FNAME(mgiltil) -# define nmgiimil FNAME(mgiimil) -# define nmgiglid FNAME(mgiglid) -# define nmgiglinf FNAME(mgiglinf) -# define nmgiwrlt FNAME(mgiwrlt) -# define nmgiwclt FNAME(mgiwclt) -# define nmgirdlt FNAME(mgirdlt) -# define nmgirclt FNAME(mgirclt) -# define nmgisxfil FNAME(mgisxfil) -# define nmgiactp FNAME(mgiactp) -# define nmgiscatt FNAME(mgiscatt) -# define nmgisattr FNAME(mgisattr) -# define nmgiainf FNAME(mgiainf) -# define nmgigcat FNAME(mgigcat) -# define nmgignat FNAME(mgignat) -# define nmgigatt FNAME(mgigatt) -# define nmgifndat FNAME(mgifndat) -# define nmgcgichnk FNAME(mgcgichnk) -# define nmgcrcchnk FNAME(mgcrcchnk) -# define nmgcrchnk FNAME(mgcrchnk) -# define nmgcscchnk FNAME(mgcscchnk) -# define nmgcschnk FNAME(mgcschnk) -# define nmgcwcchnk FNAME(mgcwcchnk) -# define nmgcwchnk FNAME(mgcwchnk) -# define nmgcscompress FNAME(mgcscompress) -# define nmgcgcompress FNAME(mgcgcompress) -# define nmglt2rf FNAME(mglt2rf) -# define nmgcgnluts FNAME(mgcgnluts) -# endif - -#endif /* DF_CAPFNAMES */ -#endif /* MFGR_FNAMES */ - -/* Multi-file GR C-stubs for FORTRAN interface found in mfgrf.c */ -HDFLIBAPI FRETVAL(intf) /* !sl */ -nmgiwimg(intf * riid, intf *start, intf *stride, intf *count, VOIDP data); - -HDFLIBAPI FRETVAL(intf) /* !sl */ -nmgirimg(intf * riid, intf *start, intf *stride, intf *count, VOIDP data); - -HDFLIBAPI FRETVAL(intf) /* !sl */ -nmgignat(intf * riid, intf *idx, VOIDP data); - -HDFLIBAPI FRETVAL(intf) -nmgstart(intf * fid); - -HDFLIBAPI FRETVAL(intf) -nmgfinfo(intf * grid,intf *n_datasets,intf *n_attrs); - -HDFLIBAPI FRETVAL(intf) -nmgend(intf * grid); - -HDFLIBAPI FRETVAL(intf) -nmgicreat(intf * grid, _fcd name, intf *ncomp, intf *nt, intf *il, intf dimsizes[2], intf *nlen); - -HDFLIBAPI FRETVAL(intf) -nmgselct(intf * grid, intf *idx); - -HDFLIBAPI FRETVAL(intf) -nmgin2ndx(intf * grid, _fcd name, intf *nlen); - -HDFLIBAPI FRETVAL(intf) -nmggiinf(intf * riid, _fcd name, intf *ncomp, intf *nt, intf *il, intf *dimsizes, intf *nattr); - - -HDFLIBAPI FRETVAL(intf) -nmgwcimg(intf * riid, intf *start, intf *stride, intf *count, _fcd data); - -HDFLIBAPI FRETVAL(intf) -nmgrcimg(intf * riid, intf *start, intf *stride, intf *count, _fcd data); - -HDFLIBAPI FRETVAL(intf) -nmgwrimg(intf * riid, intf *start, intf *stride, intf *count, void * data); - -HDFLIBAPI FRETVAL(intf) -nmgrdimg(intf * riid, intf *start, intf *stride, intf *count, void * data); - -HDFLIBAPI FRETVAL(intf) -nmgendac(intf * riid); - -HDFLIBAPI FRETVAL(intf) -nmgid2rf(intf * riid); - -HDFLIBAPI FRETVAL(intf) -nmgr2idx(intf * grid, intf *ref); - -HDFLIBAPI FRETVAL(intf) -nmgrltil(intf * riid, intf *il); - -HDFLIBAPI FRETVAL(intf) -nmgrimil(intf * riid, intf *il); - -HDFLIBAPI FRETVAL(intf) -nmggltid(intf * riid, intf *lut_index); - -HDFLIBAPI FRETVAL(intf) -nmgglinf(intf * lutid, intf *ncomp, intf *nt, intf *il, intf *nentries); - -HDFLIBAPI FRETVAL(intf) -nmgwrlut(intf * lutid, intf *ncomp, intf *nt, intf *il, intf *nentries, void * data); - -HDFLIBAPI FRETVAL(intf) -nmgwclut(intf * lutid, intf *ncomp, intf *nt, intf *il, intf *nentries, _fcd data); - -HDFLIBAPI FRETVAL(intf) -nmgrdlut(intf * lutid, void * data); - -HDFLIBAPI FRETVAL(intf) -nmgrclut(intf * lutid, _fcd data); - -HDFLIBAPI FRETVAL(intf) -nmgisxfil(intf * riid, _fcd filename, intf *offset, intf *nlen); - -HDFLIBAPI FRETVAL(intf) -nmgsactp(intf * riid, intf *accesstype); - -HDFLIBAPI FRETVAL(intf) -nmgiscatt(intf * riid, _fcd name, intf *nt, intf *count, _fcd data, intf *nlen); - -HDFLIBAPI FRETVAL(intf) -nmgisattr(intf * riid, _fcd name, intf *nt, intf *count, void * data, intf *nlen); - -HDFLIBAPI FRETVAL(intf) -nmgatinf(intf * riid, intf *idx, _fcd name, intf *nt, intf *count); - -HDFLIBAPI FRETVAL(intf) -nmggcatt(intf * riid, intf *idx, _fcd data); - -HDFLIBAPI FRETVAL(intf) -nmggnatt(intf * riid, intf *idx, void * data); - -HDFLIBAPI FRETVAL(intf) -nmggattr(intf * riid, intf *idx, void * data); - -HDFLIBAPI FRETVAL(intf) -nmgifndat(intf * riid, _fcd name, intf *nlen); - - HDFLIBAPI FRETVAL (intf) - nmgcgichnk(intf *id, intf *dim_length, intf *flags); - - HDFLIBAPI FRETVAL (intf) - nmgcrcchnk(intf *id, intf *start, _fcd char_data); - - HDFLIBAPI FRETVAL (intf) - nmgcrchnk(intf *id, intf *start, VOIDP num_data); - - HDFLIBAPI FRETVAL (intf) - nmgcscchnk(intf *id, intf *maxcache, intf *flags); - - HDFLIBAPI FRETVAL (intf) - nmgcschnk(intf *id, intf *dim_length, intf *comp_type, - intf *comp_prm); - HDFLIBAPI FRETVAL (intf) - nmgcwcchnk(intf *id, intf *start, _fcd char_data); - - HDFLIBAPI FRETVAL (intf) - nmgcwchnk(intf *id, intf *start, VOIDP num_data); - - HDFLIBAPI FRETVAL (intf) - nmgcscompress(intf *id, intf *comp_type, intf *comp_prm); - - HDFLIBAPI FRETVAL (intf) - nmgcgcompress(intf *id, intf *comp_type, intf *comp_prm); - - HDFLIBAPI FRETVAL (intf) - nmglt2rf(intf *id); - - HDFLIBAPI FRETVAL (intf) - nmgcgnluts(intf *id); - -/* Multi-file Raster C-routines found in mfgr.c */ -HDFLIBAPI intn rigcompare(void * k1, void * k2, intn cmparg); - -HDFLIBAPI int32 GRstart(int32 hdf_file_id); - -HDFLIBAPI intn GRfileinfo(int32 grid,int32 *n_datasets,int32 *n_attrs); - -HDFLIBAPI intn GRend(int32 grid); - -HDFLIBAPI int32 GRcreate(int32 grid,const char *name,int32 ncomp,int32 nt,int32 il, - int32 dimsizes[2]); - -HDFLIBAPI int32 GRselect(int32 grid,int32 idx); - -HDFLIBAPI int32 GRnametoindex(int32 grid,const char *name); - -HDFLIBAPI intn GRgetiminfo(int32 riid,char *name,int32 *ncomp,int32 *nt,int32 *il, - int32 dimsizes[2],int32 *n_attr); - -HDFLIBAPI intn GRgetnluts(int32 riid); - -HDFLIBAPI intn GRwriteimage(int32 riid,int32 start[2],int32 stride[2], - int32 count[2],void * data); - -HDFLIBAPI intn GRreadimage(int32 riid,int32 start[2],int32 stride[2], - int32 count[2],void * data); - -HDFLIBAPI intn GRendaccess(int32 riid); - -HDFLIBAPI uint16 GRidtoref(int32 riid); - -HDFLIBAPI int32 GRreftoindex(int32 grid,uint16 ref); - -HDFLIBAPI intn GRreqlutil(int32 riid,intn il); - -HDFLIBAPI intn GRreqimageil(int32 riid,intn il); - -HDFLIBAPI int32 GRgetlutid(int32 riid,int32 idx); - -HDFLIBAPI uint16 GRluttoref(int32 lutid); - -HDFLIBAPI intn GRgetlutinfo(int32 riid,int32 *ncomp,int32 *nt, - int32 *il,int32 *nentries); - -HDFLIBAPI intn GRwritelut(int32 riid,int32 ncomps,int32 nt, - int32 il,int32 nentries,void * data); - -HDFLIBAPI intn GRreadlut(int32 lutid,void * data); - -HDFLIBAPI intn GRsetexternalfile(int32 riid,const char *filename,int32 offset); - -HDFLIBAPI intn GRsetaccesstype(int32 riid,uintn accesstype); - -HDFLIBAPI intn GRsetcompress(int32 riid,comp_coder_t comp_type,comp_info *cinfo); - -HDFLIBAPI intn GRgetcompress(int32 riid,comp_coder_t* comp_type,comp_info *cinfo); - -HDFLIBAPI intn GRsetattr(int32 id,const char *name,int32 attr_nt,int32 count,const void * data); - -HDFLIBAPI intn GRattrinfo(int32 id,int32 idx,char *name,int32 *attr_nt,int32 *count); - -HDFLIBAPI intn GRgetattr(int32 id,int32 idx,void * data); - -HDFLIBAPI int32 GRfindattr(int32 id,const char *name); - -HDFLIBAPI intn GRPshutdown(void); - -/*=== HDF_CHUNK_DEF same as in mfhdf.h - moved here ====*/ - -/* Bit flags used for SDsetchunk(), SDgetchunkinfo() - GRsetchunk() and GRgetchunkinfo(). Note that GRs do not support NBIT */ -#define HDF_NONE 0x0 -#define HDF_CHUNK 0x1 -#define HDF_COMP 0x3 -#define HDF_NBIT 0x5 - -/* Cache flags */ -#define HDF_CACHEALL 0x1 - -/* Chunk Defintion, Note that GRs need only 2 dimensions for the chunk_lengths */ -typedef union hdf_chunk_def_u -{ - /* Chunk Lengths only */ - int32 chunk_lengths[MAX_VAR_DIMS]; /* chunk lengths along each dimension */ - - struct - { /* For Compression info */ - int32 chunk_lengths[MAX_VAR_DIMS]; /* chunk lengths along each dimension */ - int32 comp_type; /* Compression type */ - int32 model_type; /* Compression model type */ - comp_info cinfo; /* Compression info struct */ - model_info minfo; /* Compression model info struct */ - }comp; - - struct - { /* For NBIT, Used by SDS and not by GR */ - int32 chunk_lengths[MAX_VAR_DIMS]; /* chunk lengths along each dimension */ - intn start_bit; /* offset of the start bit in the data */ - intn bit_len; /* number of bits to store */ - intn sign_ext; /* whether to sign extend or not */ - intn fill_one; /* whether to fill with 1's or not (0's) */ - } nbit; - -} HDF_CHUNK_DEF; - -/*=== GR Chunking Routines ====*/ - -/****************************************************************************** - NAME - GRsetchunk -- make GR a chunked GR - - DESCRIPTION - This routine makes the GR a chunked GR according to the chunk - definition passed in. - - The image currently cannot be special already. i.e. NBIT, - COMPRESSED, or EXTERNAL. This is an Error. - - The defintion of the HDF_CHUNK_DEF union with relvant fields is: - - typedef union hdf_chunk_def_u - { - int32 chunk_lengths[2]; Chunk lengths along each dimension - - struct - { - int32 chunk_lengths[2]; Chunk lengths along each dimension - int32 comp_type; Compression type - comp_info cinfo; Compression info struct - }comp; - - } HDF_CHUNK_DEF - - The simplist is the 'chunk_lengths' array specifiying chunk - lengths for each dimension where the 'flags' argument set to - 'HDF_CHUNK'; - - COMPRESSION is set by using the 'HDF_CHUNK_DEF' structure to set the - appropriate compression information along with the required chunk lengths - for each dimension. The compression information is the same as - that set in 'SDsetcompress()'. The bit-or'd'flags' argument' is set to - 'HDF_CHUNK | HDF_COMP'. - - See the example in pseudo-C below for further usage. - - The maximum number of Chunks in an HDF file is 65,535. - - The performance of the GRxxx interface with chunking is greatly - affected by the users access pattern over the image and by - the maximum number of chunks set in the chunk cache. The cache contains - the Least Recently Used(LRU cache replacment policy) chunks. See the - routine GRsetchunkcache() for further info on the chunk cache and how - to set the maximum number of chunks in the chunk cache. A default chunk - cache is always created. - - The following example shows the organization of chunks for a 2D iamge. - e.g. 4x4 image with 2x2 chunks. The array shows the layout of - chunks in the chunk array. - - 4 --------------------- - | | | - Y | (0,1) | (1,1) | - ^ | | | - | 2 --------------------- - | | | | - | | (0,0) | (1,0) | - | | | | - | --------------------- - | 0 2 4 - ---------------> X - - --Without compression--: - { - HDF_CHUNK_DEF chunk_def; - - ....... - -- Set chunk lengths -- - chunk_def.chunk_lengths[0]= 2; - chunk_def.chunk_lengths[1]= 2; - - -- Set Chunking -- - GRsetchunk(riid, chunk_def, HDF_CHUNK); - ...... - } - - --With compression--: - { - HDF_CHUNK_DEF chunk_def; - - ....... - -- Set chunk lengths first -- - chunk_def.chunk_lengths[0]= 2; - chunk_def.chunk_lengths[1]= 2; - - -- Set compression -- - chunk_def.comp.cinfo.deflate.level = 9; - chunk_def.comp.comp_type = COMP_CODE_DEFLATE; - - -- Set Chunking with Compression -- - GRsetchunk(riid, chunk_def, HDF_CHUNK | HDF_COMP); - ...... - } - - RETURNS - SUCCEED/FAIL -******************************************************************************/ -HDFLIBAPI intn GRsetchunk - (int32 riid, /* IN: raster access id */ - HDF_CHUNK_DEF chunk_def, /* IN: chunk definition */ - int32 flags /* IN: flags */); - -/****************************************************************************** - NAME - GRgetchunkinfo -- get Info on GR - - DESCRIPTION - This routine gets any special information on the GR. If its chunked, - chunked and compressed or just a regular GR. Currently it will only - fill the array of chunk lengths for each dimension as specified in - the 'HDF_CHUNK_DEF' union. You can pass in a NULL for 'chunk_def' - if don't want the chunk lengths for each dimension. - Additionaly if successfull it will return a bit-or'd value in 'flags' - indicating if the GR is: - - Chunked -> flags = HDF_CHUNK - Chunked and compressed -> flags = HDF_CHUNK | HDF_COMP - Non-chunked -> flags = HDF_NONE - - e.g. 4x4 array - Pseudo-C - { - int32 rcdims[3]; - HDF_CHUNK_DEF rchunk_def; - int32 cflags; - ... - rchunk_def.chunk_lengths = rcdims; - GRgetchunkinfo(riid, &rchunk_def, &cflags); - ... - } - - RETURNS - SUCCEED/FAIL -******************************************************************************/ -HDFLIBAPI intn GRgetchunkinfo - (int32 riid, /* IN: Raster access id */ - HDF_CHUNK_DEF *chunk_def, /* IN/OUT: chunk definition */ - int32 *flags /* IN/OUT: flags */); - - -/****************************************************************************** - NAME - GRwritechunk -- write the specified chunk to the GR - - DESCRIPTION - This routine writes a whole chunk of data to the chunked GR - specified by chunk 'origin' for the given GR and can be used - instead of GRwriteimage() when this information is known. This - routine has less overhead and is much faster than using GRwriteimage(). - - Origin specifies the co-ordinates of the chunk according to the chunk - position in the overall chunk array. - - 'datap' must point to a whole chunk of data. - - See GRsetchunk() for a description of the organization of chunks in an GR. - - RETURNS - SUCCEED/FAIL -******************************************************************************/ -HDFLIBAPI intn GRwritechunk - (int32 riid, /* IN: raster access id */ - int32 *origin, /* IN: origin of chunk to write */ - const void *datap /* IN: buffer for data */); - -/****************************************************************************** - NAME - GRreadchunk -- read the specified chunk to the GR - - DESCRIPTION - This routine reads a whole chunk of data from the chunked GR - specified by chunk 'origin' for the given GR and can be used - instead of GRreadimage() when this information is known. This - routine has less overhead and is much faster than using GRreadimage(). - - Origin specifies the co-ordinates of the chunk according to the chunk - position in the overall chunk array. - - 'datap' must point to a whole chunk of data. - - See GRsetchunk() for a description of the organization of chunks in an GR. - - RETURNS - SUCCEED/FAIL -******************************************************************************/ -HDFLIBAPI intn GRreadchunk - (int32 riid, /* IN: raster access id */ - int32 *origin, /* IN: origin of chunk to read */ - void *datap /* IN/OUT: buffer for data */); - - -/****************************************************************************** -NAME - GRsetchunkcache -- maximum number of chunks to cache - -DESCRIPTION - Set the maximum number of chunks to cache. - - The cache contains the Least Recently Used(LRU cache replacment policy) - chunks. This routine allows the setting of maximum number of chunks that - can be cached, 'maxcache'. - - The performance of the GRxxx interface with chunking is greatly - affected by the users access pattern over the image and by - the maximum number of chunks set in the chunk cache. The number chunks - that can be set in the cache is process memory limited. It is a good - idea to always set the maximum number of chunks in the cache as the - default heuristic does not take into account the memory available for - the application. - - By default when the GR is promoted to a chunked element the - maximum number of chunks in the cache 'maxcache' is set to the number of - chunks along the last dimension. - - The values set here affects the current object's caching behaviour. - - If the chunk cache is full and 'maxcache' is greater then the - current 'maxcache' value, then the chunk cache is reset to the new - 'maxcache' value, else the chunk cache remains at the current - 'maxcache' value. - - If the chunk cache is not full, then the chunk cache is set to the - new 'maxcache' value only if the new 'maxcache' value is greater than the - current number of chunks in the cache. - - Use flags argument of 'HDF_CACHEALL' if the whole object is to be cached - in memory, otherwise pass in zero(0). Currently you can only - pass in zero. - - See GRsetchunk() for a description of the organization of chunks in an GR. - -RETURNS - Returns the 'maxcache' value for the chunk cache if successful - and FAIL otherwise -******************************************************************************/ -HDFLIBAPI intn GRsetchunkcache - (int32 riid, /* IN: raster access id */ - int32 maxcache, /* IN: max number of chunks to cache */ - int32 flags /* IN: flags = 0, HDF_CACHEALL */); - - -#ifdef HAVE_FMPOOL -/****************************************************************************** -NAME - Hmpset - set pagesize and maximum number of pages to cache on next open/create - -DESCRIPTION - Set the pagesize and maximum number of pages to cache on the next - open/create of a file. A pagesize that is a power of 2 is recommended. - - The values set here only affect the next open/creation of a file and - do not change a particular file's paging behaviour after it has been - opened or created. This maybe changed in a later release. - - Use flags arguement of 'MP_PAGEALL' if the whole file is to be cached - in memory otherwise passs in zero. - -RETURNS - Returns SUCCEED if successful and FAIL otherwise - -NOTE - This calls the real routine MPset(). - Currently 'maxcache' has to be greater than 1. Maybe use special - case of 0 to specify you want to turn page buffering off or use - the flags arguement. - -******************************************************************************/ -HDFLIBAPI int Hmpset(int pagesize, /* IN: pagesize to use for next open/create */ - int maxcache, /* IN: max number of pages to cache */ - int flags /* IN: flags = 0, MP_PAGEALL */); - -/****************************************************************************** -NAME - Hmpget - get last pagesize and max number of pages cached for open/create - -DESCRIPTION - This gets the last pagesize and maximum number of pages cached for - the last open/create of a file. - -RETURNS - Returns SUCCEED. - -NOTES - This routine calls the real routine MPget(). -******************************************************************************/ -HDFLIBAPI int Hmpget(int *pagesize, /*OUT: pagesize to used in last open/create */ - int *maxcache, /*OUT: max number of pages cached in last open/create */ - int flags /* IN: */); - -#endif /* HAVE_FMPOOL */ - -/* Vset interface functions (used to be in vproto.h) */ - -/* Useful macros, which someday might become actuall functions */ -/* - * macros for VSinquire - * all these macros should be public for users - */ -#define VSQuerycount(vs, count) \ - (VSinquire (vs, (int32 *) count, (int32*) NULL, (char*) NULL, (int32*) NULL, (char*) NULL)) - -#define VSQueryinterlace(vs, intr) \ - (VSinquire (vs, (int32 *) NULL, (int32*) intr, (char*) NULL, (int32*) NULL, (char*) NULL)) - -#define VSQueryfields(vs, flds) \ - (VSinquire (vs, (int32 *) NULL, (int32*) NULL, (char*) flds, (int32*) NULL, (char*) NULL)) - -#define VSQueryvsize(vs, size) \ - (VSinquire (vs, (int32 *) NULL, (int32*) NULL, (char*) NULL, (int32*) size, (char*) NULL)) - -#define VSQueryname(vs, name) \ - (VSinquire (vs, (int32 *) NULL, (int32*) NULL, (char*) NULL, (int32*) NULL, (char*) name)) - -/* - ** from vattr.c - */ - HDFLIBAPI intn Vsetattr - (int32 vgid, const char *attrname, int32 datatype, - int32 count, const void * values); - HDFLIBAPI intn Vnattrs - (int32 vgid); - HDFLIBAPI intn Vfindattr - (int32 vgid, const char *attrname); - HDFLIBAPI intn Vattrinfo - (int32 vgid, intn attrindex, char *name, - int32 *datatype, int32 *count, int32 *size); - HDFLIBAPI intn Vgetattr - (int32 vgid, intn attrindex, void * values); - HDFLIBAPI int32 Vgetversion - (int32 vgid); - HDFLIBAPI intn VSfindex - (int32 vsid, const char *fieldname, int32 *fldindex); - HDFLIBAPI intn VSsetattr - (int32 vsid, int32 findex, const char *attrname, - int32 datatype, int32 count, const void * values); - HDFLIBAPI intn VSnattrs - (int32 vsid); - HDFLIBAPI intn VSfnattrs - (int32 vsid, int32 findex); - HDFLIBAPI intn VSfindattr - (int32 vsid, int32 findex, const char *attrname); - HDFLIBAPI intn VSattrinfo - (int32 vsid, int32 findex, intn attrindex, - char *name, int32 *datatype, int32 *count, - int32 *size); - HDFLIBAPI intn VSgetattr - (int32 vsid, int32 findex, intn attrindex, - void * values); - HDFLIBAPI intn VSisattr - (int32 vsid); -/* - ** from vconv.c - */ - HDFLIBAPI int32 vicheckcompat - (HFILEID f); - - HDFLIBAPI int32 vimakecompat - (HFILEID f); - - HDFLIBAPI int32 vcheckcompat - (char * fs); - - HDFLIBAPI int32 vmakecompat - (char * fs); - -/* - ** from vg.c - */ - HDFLIBAPI int32 VSelts - (int32 vkey); - - HDFLIBAPI int32 VSgetinterlace - (int32 vkey); - - HDFLIBAPI intn VSsetinterlace - (int32 vkey, int32 interlace); - - HDFLIBAPI int32 VSgetfields - (int32 vkey, char * fields); - - HDFLIBAPI intn VSfexist - (int32 vkey, char * fields); - - HDFLIBAPI int32 VSsizeof - (int32 vkey, char * fields); - - HDFLIBAPI void VSdump - (int32 vkey); - - HDFLIBAPI int32 VSsetname - (int32 vkey, const char * vsname); - - HDFLIBAPI int32 VSsetclass - (int32 vkey, const char * vsclass); - - HDFLIBAPI int32 VSgetname - (int32 vkey, char * vsname); - - HDFLIBAPI int32 VSgetclass - (int32 vkey, char * vsclass); - - HDFLIBAPI intn VSinquire - (int32 vkey, int32 * nelt, int32 * interlace, - char * fields, int32 * eltsize, char * vsname); - - HDFLIBAPI int32 VSlone - (HFILEID f, int32 * idarray, int32 asize); - - HDFLIBAPI int32 Vlone - (HFILEID f, int32 * idarray, int32 asize); - - HDFLIBAPI int32 Vfind - (HFILEID f, const char * vgname); - - HDFLIBAPI int32 VSfind - (HFILEID f, const char * vsname); - - HDFLIBAPI int32 Vfindclass - (HFILEID f, const char * vgclass); - - HDFLIBAPI int32 VSfindclass - (HFILEID f, const char * vsclass); - - HDFLIBAPI intn VSsetblocksize - (int32 vkey, int32 block_size); - - HDFLIBAPI intn VSsetnumblocks - (int32 vkey, int32 num_blocks); - - HDFLIBAPI intn VSgetblockinfo - (int32 vkey, int32* block_size, int32* num_blocks); - - HDFLIBAPI void Vsetzap - (void); - -/* - ** from vgp.c - */ - HDFLIBAPI intn vcompare - (void * k1, void * k2, intn cmparg); - - HDFLIBAPI intn vcompareref - (void * k1, void * k2, intn cmparg); - - HDFLIBAPI void vdestroynode - (void * n); - - HDFLIBAPI void vtfreekey - (void * k); - - HDFLIBAPI intn Vinitialize - (HFILEID f); - - HDFLIBAPI intn Vfinish - (HFILEID f); - - HDFLIBAPI HFILEID Vopen - (char *path, intn acc_mode, int16 ndds); - - HDFLIBAPI intn Vclose - (HFILEID f); - - HDFLIBAPI int32 vexistvg - (HFILEID f, uint16 vgid); - - HDFLIBAPI int32 Vattach - (HFILEID f, int32 vgid, const char * accesstype); - - HDFLIBAPI int32 Vdetach - (int32 vkey); - - HDFLIBAPI int32 Vinsert - (int32 vkey, int32 vskey); - /* note: 2nd arg of Vinsert can also be (VGROUP *) */ - - HDFLIBAPI int32 Vflocate - (int32 vkey, char * field); - - HDFLIBAPI intn Vinqtagref - (int32 vkey, int32 tag, int32 ref); - - HDFLIBAPI int32 Vntagrefs - (int32 vkey); - - HDFLIBAPI int32 Vnrefs - (int32 vkey,int32 tag); - - HDFLIBAPI int32 Vgettagrefs - (int32 vkey, int32 tagarray[], int32 refarray[], int32 n); - - HDFLIBAPI intn Vgettagref - (int32 vkey, int32 which, int32 * tag, int32 * ref); - - HDFLIBAPI int32 VQueryref - (int32 vkey); - - HDFLIBAPI int32 VQuerytag - (int32 vkey); - - HDFLIBAPI int32 Vaddtagref - (int32 vkey, int32 tag, int32 ref); - - HDFLIBAPI int32 Ventries - (HFILEID f, int32 vgid); - - HDFLIBAPI int32 Vsetname - (int32 vkey, const char * vgname); - - HDFLIBAPI int32 Vsetclass - (int32 vkey, const char * vgclass); - - HDFLIBAPI intn Visvg - (int32 vkey, int32 id); - - HDFLIBAPI intn Visvs - (int32 vkey, int32 id); - - HDFLIBAPI int32 Vgetid - (HFILEID f, int32 vgid); - - HDFLIBAPI int32 Vgetnext - (int32 vkey, int32 id); - - HDFLIBAPI int32 Vgetname - (int32 vkey, char * vgname); - - HDFLIBAPI int32 Vgetclass - (int32 vkey, char * vgclass); - - HDFLIBAPI intn Vinquire - (int32 vkey, int32 * nentries, char * vgname); - - HDFLIBAPI int32 Vdelete - (int32 f, int32 ref); - -/******************************************************************************* -NAME - Vdeletetagref - delete tag/ref pair in Vgroup - -DESCRIPTION - Deletes the given tag/ref pair from the Vgroup. If the given tag/ref pair - does not exist in the vgroup the routine will return FAIL. Users should use - Vinqtagref() to check if the tag/ref pair exists before deleting. - -RETURNS - Returns SUCCEED if the tag/ref pair is deleted from Vgroup and - FAIL if unsuccessful. - -*******************************************************************************/ -HDFLIBAPI intn -Vdeletetagref(int32 vkey, /* IN: vgroup key */ - int32 tag, /* IN: tag to delete in vgroup */ - int32 ref /* IN: ref to delete in vgroup */); - - HDFLIBAPI intn VPshutdown(void); - -/* - ** from vparse.c - */ - HDFLIBAPI int32 scanattrs - (const char * attrs, int32 * attrc, char *** attrv); - -/* - ** from vhi.c - */ - HDFLIBAPI int32 VHstoredata - (HFILEID f, const char * field, const uint8 *buf, int32 n, int32 datatype, - const char * vsname, const char * vsclass); - - HDFLIBAPI int32 VHstoredatam - (HFILEID f, const char * field, const uint8 *buf, int32 n, int32 datatype, - const char * vsname, const char * vsclass, int32 order); - - HDFLIBAPI int32 VHmakegroup - (HFILEID f, int32 tagarray[], int32 refarray[], int32 n, - const char * vgname, const char * vgclass); - -/* - ** from vio.c - */ - - HDFLIBAPI intn VSPhshutdown(void); - - HDFLIBAPI int32 vexistvs - (HFILEID f, uint16 vsref); - - HDFLIBAPI void vsdestroynode - (void * n); - - HDFLIBAPI void vfdestroynode - (void * n); - - HDFLIBAPI int32 VSattach - (HFILEID f, int32 vsref, const char * accesstype); - - HDFLIBAPI int32 VSdetach - (int32 vkey); - - HDFLIBAPI int32 VSQuerytag - (int32 vkey); - - HDFLIBAPI int32 VSQueryref - (int32 vkey); - - HDFLIBAPI int32 VSgetid - (HFILEID f, int32 vsref); - - HDFLIBAPI int32 VSgetversion - (int32 vkey); - - HDFLIBAPI int32 VSdelete - (int32 f, int32 ref); - - HDFLIBAPI int32 VSappendable - (int32 vkey, int32 blk); - -/* - ** from vsfld.c - */ - - HDFLIBAPI intn VSsetfields - (int32 vkey, const char * fields); - - HDFLIBAPI intn VSfdefine - (int32 vkey, const char * field, int32 localtype, int32 order); - - HDFLIBAPI int32 VFnfields - (int32 vkey); - - HDFLIBAPI char *VFfieldname - (int32 vkey, int32 idx); - - HDFLIBAPI int32 VFfieldtype - (int32 vkey, int32 idx); - - HDFLIBAPI int32 VFfieldisize - (int32 vkey, int32 idx); - - HDFLIBAPI int32 VFfieldesize - (int32 vkey, int32 idx); - - HDFLIBAPI int32 VFfieldorder - (int32 vkey, int32 idx); - - HDFLIBAPI intn VSsetexternalfile - (int32 vkey, const char *filename, int32 offset); - - HDFLIBAPI intn VSfpack - (int32 vsid, intn packtype, const char *fields_in_buf, - void * buf, intn bufsz, intn n_records, - const char *fields, void * fldbufpt[]); - -/* - ** from vrw.c - */ - HDFLIBAPI intn VSPshutdown(void); - - HDFLIBAPI int32 VSseek - (int32 vkey, int32 eltpos); - - HDFLIBAPI int32 VSread - (int32 vkey, uint8 buf[], int32 nelt, int32 interlace); - - HDFLIBAPI int32 VSwrite - (int32 vkey, const uint8 buf[], int32 nelt, int32 interlace); - -/* - ** from vgF.c - */ -#ifndef VG_FNAMES -# define VG_FNAMES -#ifdef DF_CAPFNAMES -# if defined(UNIX386) || (!(defined INTEL86) && !(defined WIN32)) -# define ndfivopn FNAME(DFIVOPN) -# define ndfvclos FNAME(DFVCLOS) -# define nvatchc FNAME(VATCHC) -# define nvdtchc FNAME(VDTCHC) -# define nvgnamc FNAME(VGNAMC) -# define nvgclsc FNAME(VGCLSC) -# define nvinqc FNAME(VINQC) -# define nvdeletec FNAME(VDELETEC) -# define nvgidc FNAME(VGIDC) -# define nvgnxtc FNAME(VGNXTC) -# define nvsnamc FNAME(VSNAMC) -# define nvsclsc FNAME(VSCLSC) -# define nvinsrtc FNAME(VINSRTC) -# define nvisvgc FNAME(VISVGC) -# define nvisvsc FNAME(VISVSC) -# define nvsatchc FNAME(VSATCHC) -# define nvsdtchc FNAME(VSDTCHC) -# define nvsqref FNAME(VSQREF) -# define nvsqtag FNAME(VSQTAG) -# define nvsgver FNAME(VSGVER) -# define nvsseekc FNAME(VSSEEKC) -# define nvsgnamc FNAME(VSGNAMC) -# define nvsgclsc FNAME(VSGCLSC) -# define nvsinqc FNAME(VSINQC) -# define nvsfexc FNAME(VSFEXC) -# define nvsfndc FNAME(VSFNDC) -# define nvsgidc FNAME(VSGIDC) -# define nvsdltc FNAME(VSDLTC) -# define nvsapp FNAME(VSAPP) -# define nvssnamc FNAME(VSSNAMC) -# define nvssclsc FNAME(VSSCLSC) -# define nvssfldc FNAME(VSSFLDC) -# define nvssintc FNAME(VSSINTC) -# define nvsfdefc FNAME(VSFDEFC) -# define nvssextfc FNAME(VSSEXTFC) -# define nvfnflds FNAME(VFNFLDS) -# define nvffnamec FNAME(VFFNAMEC) -# define nvfftype FNAME(VFFTYPE) -# define nvffisiz FNAME(VFFISIZ) -# define nvffesiz FNAME(VFFESIZ) -# define nvffordr FNAME(VFFORDR) -# define nvsfrdc FNAME(VSFRDC) -# define nvsfrd FNAME(VSFRD) -# define nvsreadc FNAME(VSREADC) -# define nvsfwrt FNAME(VSFWRT) -# define nvsfwrtc FNAME(VSFWRTC) -# define nvswritc FNAME(VSWRITC) -# define nvsgintc FNAME(VSGINTC) -# define nvseltsc FNAME(VSELTSC) -# define nvsgfldc FNAME(VSGFLDC) -# define nvssizc FNAME(VSSIZC) -# define nventsc FNAME(VENTSC) -# define nvlonec FNAME(VLONEC) -# define nvslonec FNAME(VSLONEC) -# define nvfindc FNAME(VFINDC) -# define nvfndclsc FNAME(VFNDCLSC) -# define nvhscdc FNAME(VHSCDC) -# define nvhsdc FNAME(VHSDC) -# define nvhscdmc FNAME(VHSCDMC) -# define nvhsdmc FNAME(VHSDMC) -# define nvhmkgpc FNAME(VHMKGPC) -# define nvflocc FNAME(VFLOCC) -# define nvinqtrc FNAME(VINQTRC) -# define nvntrc FNAME(VNTRC) -# define nvnrefs FNAME(VNREFS) -# define nvgttrsc FNAME(VGTTRSC) -# define nvqref FNAME(VQREF) -# define nvqtag FNAME(VQTAG) -# define nvgttrc FNAME(VGTTRC) -# define nvadtrc FNAME(VADTRC) -# define nvfstart FNAME(VFSTART) -# define nvfend FNAME(VFEND) -# define nvsqfnelt FNAME(VSQFNELT) -# define nvsqfintr FNAME(VSQFINTR) -# define nvsqfldsc FNAME(VSQFLDSC) -# define nvsqfvsiz FNAME(VSQFVSIZ) -# define nvsqnamec FNAME(VSQNAMEC) -# define nvsfccpk FNAME(VSFCCPK) -# define nvsfncpk FNAME(VSFNCPK) -# define nvdtrc FNAME(VDTRC) -# define nvscfcls FNAME(VSCFCLS) -# define nvscsetblsz FNAME(VSCSETBLSZ) -# define nvscsetnmbl FNAME (VSCSETNMBL) -# define nvscgblinfo FNAME(VSCGBLINFO) -# else /* !sl */ -# define ndfivopn FNAME(DFIVOPN) -# define ndfvclos FNAME(DFVCLOS) -# define nvatchc FNAME(VATCHC) -# define nvdtchc FNAME(VDTCHC) -# define nvgnamc FNAME(VGNAMC) -# define nvgclsc FNAME(VGCLSC) -# define nvinqc FNAME(VINQC) -# define nvdeletec FNAME(VDELETEC) -# define nvgidc FNAME(VGIDC) -# define nvgnxtc FNAME(VGNXTC) -# define nvsnamc FNAME(VSNAMC) -# define nvsclsc FNAME(VSCLSC) -# define nvinsrtc FNAME(VINSRTC) -# define nvisvgc FNAME(VISVGC) -# define nvfistart FNAME(VFISTART) -# define nvfiend FNAME(VFIEND) -# define nvisvsc FNAME(VISVSC) -# define nvsatchc FNAME(VSATCHC) -# define nvsdtchc FNAME(VSDTCHC) -# define nvsiqref FNAME(VSIQREF) -# define nvsiqtag FNAME(VSIQTAG) -# define nvsigver FNAME(VSIGVER) -# define nvsseekc FNAME(VSSEEKC) -# define nvsgnamc FNAME(VSGNAMC) -# define nvsgclsc FNAME(VSGCLSC) -# define nvsinqc FNAME(VSINQC) -# define nvsfexc FNAME(VSFEXC) -# define nvsfndc FNAME(VSFNDC) -# define nvsgidc FNAME(VSGIDC) -# define nvsdltc FNAME(VSDLTC) -# define nvsapp FNAME(VSAPP) -# define nvssnamc FNAME(VSSNAMC) -# define nvssclsc FNAME(VSSCLSC) -# define nvssfldc FNAME(VSSFLDC) -# define nvssintc FNAME(VSSINTC) -# define nvsfdefc FNAME(VSFDEFC) -# define nvssextfc FNAME(VSSEXTFC) -# define nvfinflds FNAME(VFINFLDS) -# define nvfifnm FNAME(VFIFNM) -# define nvfiftp FNAME(VFIFTP) -# define nvfifisz FNAME(VFIFISZ) -# define nvfifesz FNAME(VFIFESZ) -# define nvfifodr FNAME(VFIFODR) -# define nvsfirdc FNAME(VSFIRDC) -# define nvsfird FNAME(VSFIRD) -# define nvsreadc FNAME(VSREADC) -# define nvsfiwrc FNAME(VSFIWRC) -# define nvsfiwr FNAME(VSFIWR) -# define nvswritc FNAME(VSWRITC) -# define nvsgintc FNAME(VSGINTC) -# define nvseltsc FNAME(VSELTSC) -# define nvsgfldc FNAME(VSGFLDC) -# define nvssizc FNAME(VSSIZC) -# define nventsc FNAME(VENTSC) -# define nvlonec FNAME(VLONEC) -# define nvslonec FNAME(VSLONEC) -# define nvfindc FNAME(VFINDC) -# define nvfndclsc FNAME(VFNDCLSC) -# define nvhsdc FNAME(VHSDC) -# define nvhscdc FNAME(VHSCDC) -# define nvhscdmc FNAME(VHSCDMC) -# define nvhsdmc FNAME(VHSDMC) -# define nvhmkgpc FNAME(VHMKGPC) -# define nvflocc FNAME(VFLOCC) -# define nvfirefs FNAME(VFIREFS) -# define nvfiqref FNAME(VFIQREF) -# define nvfiqtag FNAME(VFIQTAG) -# define nvinqtrc FNAME(VINQTRC) -# define nvntrc FNAME(VNTRC) -# define nvgttrsc FNAME(VGTTRSC) -# define nvgttrc FNAME(VGTTRC) -# define nvadtrc FNAME(VADTRC) -# define nvsiqintr FNAME(VSIQINTR) -# define nvsiqnelt FNAME(VSIQNELT) -# define nvsqfldsc FNAME(VSQFLDSC) -# define nvsiqvsz FNAME(VSIQVSZ) -# define nvsqnamec FNAME(VSQNAMEC) -# define nvsfccpk FNAME(VSFCCPK) -# define nvsfncpk FNAME(VSFNCPK) -# define nvdtrc FNAME(VDTRC) -# define nvscfcls FNAME(VSCFCLS) -# define nvscsetblsz FNAME(VSCSETBLSZ) -# define nvscsetnmbl FNAME (VSCSETNMBL) -# define nvscgblinfo FNAME(VSCGBLINFO) -# endif -#else /* !DF_CAPFNAMES */ -# if defined(UNIX386) || (!(defined INTEL86) && !(defined WIN32)) -# define ndfivopn FNAME(dfivopn) -# define ndfvclos FNAME(dfvclos) -# define nvatchc FNAME(vatchc) -# define nvdtchc FNAME(vdtchc) -# define nvgnamc FNAME(vgnamc) -# define nvgclsc FNAME(vgclsc) -# define nvinqc FNAME(vinqc) -# define nvdeletec FNAME(vdeletec) -# define nvgidc FNAME(vgidc) -# define nvgnxtc FNAME(vgnxtc) -# define nvsnamc FNAME(vsnamc) -# define nvsclsc FNAME(vsclsc) -# define nvinsrtc FNAME(vinsrtc) -# define nvisvgc FNAME(visvgc) -# define nvisvsc FNAME(visvsc) -# define nvsatchc FNAME(vsatchc) -# define nvsdtchc FNAME(vsdtchc) -# define nvsqref FNAME(vsqref) -# define nvsqtag FNAME(vsqtag) -# define nvsgver FNAME(vsgver) -# define nvsseekc FNAME(vsseekc) -# define nvsgnamc FNAME(vsgnamc) -# define nvsgclsc FNAME(vsgclsc) -# define nvsinqc FNAME(vsinqc) -# define nvsfexc FNAME(vsfexc) -# define nvsfndc FNAME(vsfndc) -# define nvsgidc FNAME(vsgidc) -# define nvsdltc FNAME(vsdltc) -# define nvsapp FNAME(vsapp) -# define nvssnamc FNAME(vssnamc) -# define nvssclsc FNAME(vssclsc) -# define nvssfldc FNAME(vssfldc) -# define nvssintc FNAME(vssintc) -# define nvsfdefc FNAME(vsfdefc) -# define nvssextfc FNAME(vssextfc) -# define nvfnflds FNAME(vfnflds) -# define nvffnamec FNAME(vffnamec) -# define nvfftype FNAME(vfftype) -# define nvffisiz FNAME(vffisiz) -# define nvffesiz FNAME(vffesiz) -# define nvffordr FNAME(vffordr) -# define nvsfrdc FNAME(vsfrdc) -# define nvsfrd FNAME(vsfrd) -# define nvsreadc FNAME(vsreadc) -# define nvsfwrtc FNAME(vsfwrtc) -# define nvsfwrt FNAME(vsfwrt) -# define nvswritc FNAME(vswritc) -# define nvsgintc FNAME(vsgintc) -# define nvseltsc FNAME(vseltsc) -# define nvsgfldc FNAME(vsgfldc) -# define nvssizc FNAME(vssizc) -# define nventsc FNAME(ventsc) -# define nvlonec FNAME(vlonec) -# define nvslonec FNAME(vslonec) -# define nvfindc FNAME(vfindc) -# define nvfndclsc FNAME(vfndclsc) -# define nvhscdc FNAME(vhscdc) -# define nvhsdc FNAME(vhsdc) -# define nvhscdmc FNAME(vhscdmc) -# define nvhsdmc FNAME(vhsdmc) -# define nvhmkgpc FNAME(vhmkgpc) -# define nvflocc FNAME(vflocc) -# define nvinqtrc FNAME(vinqtrc) -# define nvntrc FNAME(vntrc) -# define nvnrefs FNAME(vnrefs) -# define nvgttrsc FNAME(vgttrsc) -# define nvqref FNAME(vqref) -# define nvqtag FNAME(vqtag) -# define nvgttrc FNAME(vgttrc) -# define nvadtrc FNAME(vadtrc) -# define nvfstart FNAME(vfstart) -# define nvfend FNAME(vfend) -# define nvsqfnelt FNAME(vsqfnelt) -# define nvsqfintr FNAME(vsqfintr) -# define nvsqfldsc FNAME(vsqfldsc) -# define nvsqfvsiz FNAME(vsqfvsiz) -# define nvsqnamec FNAME(vsqnamec) -# define nvsfccpk FNAME(vsfccpk) -# define nvsfncpk FNAME(vsfncpk) -# define nvdtrc FNAME(vdtrc) -# define nvscfcls FNAME(vscfcls) -# define nvscsetblsz FNAME(vscsetblsz) -# define nvscsetnmbl FNAME (vscsetnmbl) -# define nvscgblinfo FNAME(vscgblinfo) -# else /* !sl */ -# define ndfivopn FNAME(dfivopn) -# define ndfvclos FNAME(dfvclos) -# define nvatchc FNAME(vatchc) -# define nvdtchc FNAME(vdtchc) -# define nvgnamc FNAME(vgnamc) -# define nvgclsc FNAME(vgclsc) -# define nvinqc FNAME(vinqc) -# define nvdeletec FNAME(vdeletec) -# define nvgidc FNAME(vgidc) -# define nvgnxtc FNAME(vgnxtc) -# define nvsnamc FNAME(vsnamc) -# define nvsclsc FNAME(vsclsc) -# define nvinsrtc FNAME(vinsrtc) -# define nvisvgc FNAME(visvgc) -# define nvfistart FNAME(vfistart) -# define nvfiend FNAME(vfiend) -# define nvisvsc FNAME(visvsc) -# define nvsatchc FNAME(vsatchc) -# define nvsdtchc FNAME(vsdtchc) -# define nvsiqref FNAME(vsiqref) -# define nvsiqtag FNAME(vsiqtag) -# define nvsigver FNAME(vsigver) -# define nvsseekc FNAME(vsseekc) -# define nvsgnamc FNAME(vsgnamc) -# define nvsgclsc FNAME(vsgclsc) -# define nvsinqc FNAME(vsinqc) -# define nvsfexc FNAME(vsfexc) -# define nvsfndc FNAME(vsfndc) -# define nvsgidc FNAME(vsgidc) -# define nvsdltc FNAME(vsdltc) -# define nvsapp FNAME(vsapp) -# define nvssnamc FNAME(vssnamc) -# define nvssclsc FNAME(vssclsc) -# define nvssfldc FNAME(vssfldc) -# define nvssintc FNAME(vssintc) -# define nvsfdefc FNAME(vsfdefc) -# define nvssextfc FNAME(vssextfc) -# define nvfinflds FNAME(vfinflds) -# define nvfifnm FNAME(vfifnm) -# define nvfiftp FNAME(vfiftp) -# define nvfifisz FNAME(vfifisz) -# define nvfifesz FNAME(vfifesz) -# define nvfifodr FNAME(vfifodr) -# define nvsfirdc FNAME(vsfirdc) -# define nvsfird FNAME(vsfird) -# define nvsreadc FNAME(vsreadc) -# define nvsfiwrc FNAME(vsfiwrc) -# define nvsfiwr FNAME(vsfiwr) -# define nvswritc FNAME(vswritc) -# define nvsgintc FNAME(vsgintc) -# define nvseltsc FNAME(vseltsc) -# define nvsgfldc FNAME(vsgfldc) -# define nvssizc FNAME(vssizc) -# define nventsc FNAME(ventsc) -# define nvlonec FNAME(vlonec) -# define nvslonec FNAME(vslonec) -# define nvfindc FNAME(vfindc) -# define nvfndclsc FNAME(vfndclsc) -# define nvhsdc FNAME(vhsdc) -# define nvhscdc FNAME(vhscdc) -# define nvhscdmc FNAME(vhscdmc) -# define nvhsdmc FNAME(vhsdmc) -# define nvhmkgpc FNAME(vhmkgpc) -# define nvflocc FNAME(vflocc) -# define nvfirefs FNAME(vfirefs) -# define nvfiqref FNAME(vfiqref) -# define nvfiqtag FNAME(vfiqtag) -# define nvinqtrc FNAME(vinqtrc) -# define nvntrc FNAME(vntrc) -# define nvgttrsc FNAME(vgttrsc) -# define nvgttrc FNAME(vgttrc) -# define nvadtrc FNAME(vadtrc) -# define nvsiqintr FNAME(vsiqintr) -# define nvsiqnelt FNAME(vsiqnelt) -# define nvsqfldsc FNAME(vsqfldsc) -# define nvsiqvsz FNAME(vsiqvsz) -# define nvsqnamec FNAME(vsqnamec) -# define nvsfccpk FNAME(vsfccpk) -# define nvsfncpk FNAME(vsfncpk) -# define nvdtrc FNAME(vdtrc) -# define nvscfcls FNAME(vscfcls) -# define nvscsetblsz FNAME(vscsetblsz) -# define nvscsetnmbl FNAME (vscsetnmbl) -# define nvscgblinfo FNAME(vscgblinfo) -# endif -#endif /* DF_CAPFNAMES */ -#endif /* VG_FNAMES */ - - HDFLIBAPI FRETVAL(intf) ndfivopn - (_fcd filename, intf * acc_mode, intf * defdds, intf * namelen); - - HDFLIBAPI FRETVAL(intf) ndfvclos - (intf * file_id); - - HDFLIBAPI FRETVAL(intf) nvatchc - (intf * f, intf * vgid, _fcd accesstype); - - HDFLIBAPI FRETVAL(intf) nvdtchc - (intf * vkey); - - HDFLIBAPI FRETVAL(intf) nvgnamc - (intf * vkey, _fcd vgname); - - HDFLIBAPI FRETVAL(intf) nvgclsc - (intf * vkey, _fcd vgclass); - - HDFLIBAPI FRETVAL(intf) nvinqc - (intf * vkey, intf * nentries, _fcd vgname); - - HDFLIBAPI FRETVAL(intf) nvdeletec - (intf *f, intf * vkey); - - HDFLIBAPI FRETVAL(intf) nvgidc - (intf * f, intf * vgid); - - HDFLIBAPI FRETVAL(intf) nvgnxtc - (intf * vkey, intf * id); - - HDFLIBAPI FRETVAL(intf) nvsnamc - (intf * vkey, _fcd vgname, intf * vgnamelen); - - HDFLIBAPI FRETVAL(intf) nvsclsc - (intf * vkey, _fcd vgclass, intf * vgclasslen); - - HDFLIBAPI FRETVAL(intf) nvinsrtc - (intf * vkey, intf * vobjptr); - - HDFLIBAPI FRETVAL(intf) nvisvgc - (intf * vkey, intf * id); - - HDFLIBAPI FRETVAL(intf) nvfstart - (intf * f); - - HDFLIBAPI FRETVAL(intf) nvfend - (intf * f); - - HDFLIBAPI FRETVAL(intf) nvisvsc - (intf * vkey, intf * id); - - HDFLIBAPI FRETVAL(intf) nvsatchc - (intf * f, intf * vsref, _fcd accesstype); - - HDFLIBAPI FRETVAL(intf) nvsdtchc - (intf * vkey); - - HDFLIBAPI FRETVAL(intf) nvsqref - (intf * vkey); - - HDFLIBAPI FRETVAL(intf) nvsqtag - (intf * vkey); - - HDFLIBAPI FRETVAL(intf) nvsqnfld - (intf * vkey); - - HDFLIBAPI FRETVAL(intf) nvsgver - (intf * vkey); - - HDFLIBAPI FRETVAL(intf) nvsseekc - (intf * vkey, intf * eltpos); - - HDFLIBAPI FRETVAL(intf) nvsgnamc - (intf * vkey, _fcd vsname, intf *vsnamelen); - - HDFLIBAPI FRETVAL(intf) nvsgclsc - (intf * vkey, _fcd vsclass, intf *vsclasslen); - - HDFLIBAPI FRETVAL(intf) nvsinqc - (intf * vkey, intf * nelt, intf * interlace, _fcd fields, - intf * eltsize, _fcd vsname, intf *fieldslen, intf *vsnamelen); - - HDFLIBAPI FRETVAL(intf) nvsfexc - (intf * vkey, _fcd fields, intf * fieldslen); - - HDFLIBAPI FRETVAL(intf) nvsfndc - (intf * f, _fcd name, intf * namelen); - - HDFLIBAPI FRETVAL(intf) nvsgidc - (intf * f, intf * vsref); - - HDFLIBAPI FRETVAL(intf) nvsdltc - (intf * f, intf * vsref); - - HDFLIBAPI FRETVAL(intf) nvsapp - (intf * vkey, intf *blk); - - HDFLIBAPI FRETVAL(intf) nvssnamc - (intf * vkey, _fcd vsname, intf * vsnamelen); - - HDFLIBAPI FRETVAL(intf) nvssclsc - (intf * vkey, _fcd vsclass, intf * vsclasslen); - - HDFLIBAPI FRETVAL(intf) nvssfldc - (intf * vkey, _fcd fields, intf * fieldslen); - - HDFLIBAPI FRETVAL(intf) nvssintc - (intf * vkey, intf * interlace); - - HDFLIBAPI FRETVAL(intf) nvsfdefc - (intf * vkey, _fcd field, intf * localtype, - intf * order, intf * fieldlen); - - HDFLIBAPI FRETVAL(intf) nvssextfc - (intf * vkey, _fcd fname, intf * offset, - intf * fnamelen); - - HDFLIBAPI FRETVAL(intf) nvfnflds - (intf * vkey); - - HDFLIBAPI FRETVAL(intf) nvffnamec - (intf * vkey, intf *idx, _fcd fname, intf *len); - - HDFLIBAPI FRETVAL(intf) nvfftype - (intf * vkey, intf *idx); - - HDFLIBAPI FRETVAL(intf) nvffisiz - (intf * vkey, intf *idx); - - HDFLIBAPI FRETVAL(intf) nvffesiz - (intf * vkey, intf *idx); - - HDFLIBAPI FRETVAL(intf) nvffordr - (intf * vkey, intf *idx); - - HDFLIBAPI FRETVAL(intf) nvsfrdc - (intf * vkey, _fcd cbuf, intf * nelt, - intf * interlace); - - HDFLIBAPI FRETVAL(intf) nvsfrd - (intf * vkey, intf * buf, intf * nelt, - intf * interlace); - - HDFLIBAPI FRETVAL(intf) nvsreadc - (intf * vkey, uint8 * buf, intf * nelt, - intf * interlace); - - HDFLIBAPI FRETVAL(intf) nvsfwrtc - (intf * vkey, _fcd cbuf, intf * nelt, - intf * interlace); - - HDFLIBAPI FRETVAL(intf) nvsfwrt - (intf * vkey, intf * buf, intf * nelt, - intf * interlace); - - HDFLIBAPI FRETVAL(intf) nvswritc - (intf * vkey, uint8 * buf, intf * nelt, - intf * interlace); - - HDFLIBAPI FRETVAL(intf) nvsgintc - (intf * vkey); - - HDFLIBAPI FRETVAL(intf) nvseltsc - (intf * vkey); - - HDFLIBAPI FRETVAL(intf) nvsgfldc - (intf * vkey, _fcd fields); - - HDFLIBAPI FRETVAL(intf) nvssizc - (intf * vkey, _fcd fields, intf * fieldslen); - - HDFLIBAPI FRETVAL(intf) nventsc - (intf * f, intf * vgid); - - HDFLIBAPI FRETVAL(intf) nvlonec - (intf * f, intf * idarray, intf * asize); - - HDFLIBAPI FRETVAL(intf) nvslonec - (intf * f, intf * idarray, intf * asize); - - HDFLIBAPI FRETVAL(intf) nvfindc - (intf * f, _fcd name, intf * namelen); - - HDFLIBAPI FRETVAL(intf) nvfndclsc - (intf * f, _fcd vgclass, intf * classlen); - - HDFLIBAPI FRETVAL(intf) nvhscdc - (intf * f, _fcd field, _fcd cbuf, intf * n, - intf * datatype, _fcd vsname, _fcd vsclass, - intf * fieldlen, intf * vsnamelen, - intf * vsclasslen); - - HDFLIBAPI FRETVAL(intf) nvhsdc - (intf * f, _fcd field, uint8 * buf, intf * n, - intf * datatype, _fcd vsname, _fcd vsclass, - intf * fieldlen, intf * vsnamelen, - intf * vsclasslen); - - HDFLIBAPI FRETVAL(intf) nvhscdmc - (intf * f, _fcd field, _fcd cbuf, intf * n, - intf * datatype, _fcd vsname, _fcd vsclass, - intf * order, intf * fieldlen, intf * vsnamelen, - intf * vsclasslen); - - HDFLIBAPI FRETVAL(intf) nvhsdmc - (intf * f, _fcd field, uint8 * buf, intf * n, - intf * datatype, _fcd vsname, _fcd vsclass, - intf * order, intf * fieldlen, intf * vsnamelen, - intf * vsclasslen); - - HDFLIBAPI FRETVAL(intf) nvhmkgpc - (intf * f, intf * tagarray, intf * refarray, intf * n, - _fcd vgname, _fcd vgclass, intf * vgnamelen, intf * vgclasslen); - - HDFLIBAPI FRETVAL(intf) nvflocc - (intf * vkey, _fcd field, intf * fieldlen); - - HDFLIBAPI FRETVAL(intf) nvinqtrc - (intf * vkey, intf * tag, intf * ref); - - HDFLIBAPI FRETVAL(intf) nvntrc - (intf * vkey); - - HDFLIBAPI FRETVAL(intf) nvnrefs - (intf * vkey, intf *tag); - - HDFLIBAPI FRETVAL(intf) nvqref - (intf * vkey); - - HDFLIBAPI FRETVAL(intf) nvqtag - (intf * vkey); - - HDFLIBAPI FRETVAL(intf) nvgttrsc - (intf * vkey, intf * tagarray, intf * refarray, intf * n); - - HDFLIBAPI FRETVAL(intf) nvgttrc - (intf * vkey, intf * which, intf * tag, intf * ref); - - HDFLIBAPI FRETVAL(intf) nvadtrc - (intf * vkey, intf * tag, intf * ref); - - HDFLIBAPI FRETVAL(intf) nvdtrc - (intf * vkey, intf * tag, intf * ref); - - HDFLIBAPI FRETVAL(intf) nvsqfnelt - (intf * vkey, intf * nelt); - - HDFLIBAPI FRETVAL(intf) nvsqfintr - (intf * vkey, intf * interlace); - - HDFLIBAPI FRETVAL(intf) nvsqfldsc - (intf * vkey, _fcd fields, intf *fieldslen); - - HDFLIBAPI FRETVAL(intf) nvsqfvsiz - (intf * vkey, intf * size); - - HDFLIBAPI FRETVAL(intf) nvsqnamec - (intf * vkey, _fcd name, intf *namelen); - - HDFLIBAPI FRETVAL(intf) nvsfccpk - (intf *vs, intf *packtype, _fcd buflds, intf *buf, intf *bufsz, - intf *nrecs, _fcd pckfld, _fcd fldbuf, intf *buflds_len, intf *fld_len); - - HDFLIBAPI FRETVAL(intf) nvsfncpk - (intf *vs, intf *packtype, _fcd buflds, intf *buf, intf *bufsz, - intf *nrecs, _fcd pckfld, intf *fldbuf, intf *buflds_len, intf *fld_len); - - HDFLIBAPI FRETVAL(intf) nvscsetblsz - (intf *id, intf *block_size); - - HDFLIBAPI FRETVAL(intf) nvscsetnmbl - (intf *id, intf *num_blocks); - - HDFLIBAPI FRETVAL(intf) nvscgblinfo - (intf *id, intf *block_size, intf *num_blocks); - -/* - ** from vattrf.c - */ -#ifndef VATTR_FNAMES -# define VATTR_FNAMES -#ifdef DF_CAPFNAMES -# if defined(UNIX386) || (!(defined INTEL86) && !(defined WIN32)) -# define nvsfcfdx FNAME(VSFCFDX) -# define nvsfcsat FNAME(VSFCSAT) -# define nvsfcsca FNAME(VSFCSCA) -# define nvsfnats FNAME(VSFNATS) -# define nvsffnas FNAME(VSFFNAS) -# define nvsfcfda FNAME(VSFCFDA) -# define nvsfcain FNAME(VSFCAIN) -# define nvsfgnat FNAME(VSFGNAT) -# define nvsfgcat FNAME(VSFGCAT) -# define nvsfisat FNAME(VSFISAT) -# define nvfcsatt FNAME(VFCSATT) -# define nvfcscat FNAME(VFCSCAT) -# define nvfnatts FNAME(VFNATTS) -# define nvfcfdat FNAME(VFCFDAT) -# define nvfainfo FNAME(VFAINFO) -# define nvfgnatt FNAME(VFGNATT) -# define nvfgcatt FNAME(VFGCATT) -# define nvfgver FNAME(VFGVER) -# else /* !sl */ -# define nvsfcfdx FNAME(VSFCFDX) -# define nvsfcsat FNAME(VSFCSAT) -# define nvsfcsca FNAME(VSFCSCA) -# define nvsfcnats FNAME(VSFCNATS) -# define nvsfcfnas FNAME(VSFCFNAS) -# define nvsfcfda FNAME(VSFCFDA) -# define nvsfcainf FNAME(VSFCAINF) -# define nvsfcgna FNAME(VSFCGNA) -# define nvsfcgca FNAME(VSFCGCA) -# define nvsfcisa FNAME(VSFCISA) -# define nvfcsatt FNAME(VFCSATT) -# define nvfcscat FNAME(VFCSCAT) -# define nvfcnats FNAME(VFCNATS) -# define nvfcfdat FNAME(VFCFDAT) -# define nvfcainf FNAME(VFCAINF) -# define nvfcgnat FNAME(VFCGNAT) -# define nvfcgcat FNAME(VFCGCAT) -# define nvfcgver FNAME(VFCGVER) -# endif -#else /* !DF_CAPFNAMES */ -# if defined(UNIX386) || (!(defined INTEL86) && !(defined WIN32)) -# define nvsfcfdx FNAME(vsfcfdx) -# define nvsfcsat FNAME(vsfcsat) -# define nvsfcsca FNAME(vsfcsca) -# define nvsfnats FNAME(vsfnats) -# define nvsffnas FNAME(vsffnas) -# define nvsfcfda FNAME(vsfcfda) -# define nvsfcain FNAME(vsfcain) -# define nvsfgnat FNAME(vsfgnat) -# define nvsfgcat FNAME(vsfgcat) -# define nvsfisat FNAME(vsfisat) -# define nvfcsatt FNAME(vfcsatt) -# define nvfcscat FNAME(vfcscat) -# define nvfnatts FNAME(vfnatts) -# define nvfcfdat FNAME(vfcfdat) -# define nvfainfo FNAME(vfainfo) -# define nvfgnatt FNAME(vfgnatt) -# define nvfgcatt FNAME(vfgcatt) -# define nvfgver FNAME(vfgver) -# else /* !sl */ -# define nvsfcfdx FNAME(vsfcfdx) -# define nvsfcsat FNAME(vsfcsat) -# define nvsfcsca FNAME(vsfcsca) -# define nvsfcnats FNAME(vsfcnats) -# define nvsfcfnas FNAME(vsfcfnas) -# define nvsfcfda FNAME(vsfcfda) -# define nvsfcainf FNAME(vsfcainf) -# define nvsfcgna FNAME(vsfcgna) -# define nvsfcgca FNAME(vsfcgca) -# define nvsfcisa FNAME(vsfcisa) -# define nvfcsatt FNAME(vfcsatt) -# define nvfcscat FNAME(vfcscat) -# define nvfcnats FNAME(vfcnats) -# define nvfcfdat FNAME(vfcfdat) -# define nvfcainf FNAME(vfcainf) -# define nvfcgnat FNAME(vfcgnat) -# define nvfcgcat FNAME(vfcgcat) -# define nvfcgver FNAME(vfcgver) -# endif -#endif /* DF_CAPFNAMES */ -#endif /* VATTR_FNAMES */ - HDFLIBAPI FRETVAL(intf) nvsfcfdx - (intf *vsid, _fcd fldnm, intf *findex, intf *fldnmlen); - HDFLIBAPI FRETVAL(intf) nvsfcsat - (intf *vsid, intf *findex, _fcd attrnm, intf *dtype, - intf *count, intf *values, intf *attrnmlen); - HDFLIBAPI FRETVAL(intf) nvsfcsca - (intf *vsid, intf *findex, _fcd attrnm, intf *dtype, - intf *count, _fcd values, intf *attrnmlen); - HDFLIBAPI FRETVAL(intf) nvsfnats - (intf *vsid); - HDFLIBAPI FRETVAL(intf) nvsffnas - (intf *vsid, intf *findex); - HDFLIBAPI FRETVAL(intf) nvsfcfda - (intf *vsid, intf *findex, _fcd attrnm, intf *attrnmlen); - HDFLIBAPI FRETVAL(intf) nvsfcain - (intf *vsid, intf *findex, intf *aindex, _fcd attrname, - intf *dtype, intf *count, intf *size, intf *attrnamelen); - HDFLIBAPI FRETVAL(intf) nvsfgnat - (intf *vsid, intf *findex, intf *aindex, intf *values); - HDFLIBAPI FRETVAL(intf) nvsfgcat - (intf *vsid, intf *findex, intf *aindex, _fcd values); - HDFLIBAPI FRETVAL(intf) nvsfisat - (intf *vsid); - HDFLIBAPI FRETVAL(intf) nvfcsatt - (intf *vgid, _fcd attrnm, intf *dtype, - intf *count, intf *values, intf *attrnmlen); - HDFLIBAPI FRETVAL(intf) nvfcscat - (intf *vgid, _fcd attrnm, intf *dtype, intf *count, - _fcd values, intf *attrnmlen); - HDFLIBAPI FRETVAL(intf) nvfnatts - (intf *vgid); - HDFLIBAPI FRETVAL(intf) nvfcfdat - (intf *vgid, _fcd attrnm, intf *attrnmlen); - HDFLIBAPI FRETVAL(intf) nvfainfo - (intf *vgid, intf *aindex, _fcd attrname, - intf *dtype, intf *count, intf *size); - HDFLIBAPI FRETVAL(intf) nvfgnatt - (intf *vgid, intf *aindex, intf *values); - HDFLIBAPI FRETVAL(intf) nvfgcatt - (intf *vgid, intf *aindex, _fcd values); - HDFLIBAPI FRETVAL(intf) nvfgver - (intf *vgid); - -#if defined c_plusplus || defined __cplusplus -} -#endif /* c_plusplus || __cplusplus */ - -#endif /* _H_PROTO */ - diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/linklist.h b/Utilities/CAI/cai_dll/inc/inc_hdf/linklist.h deleted file mode 100755 index 9e3a817749f0125939fb47667774c7c78055d9f1..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/linklist.h +++ /dev/null @@ -1,210 +0,0 @@ -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -/* $Id$ */ - -/*----------------------------------------------------------------------------- - * File: linklist.h - * Purpose: header file for linked list API - * Dependencies: - * Invokes: - * Contents: - * Structure definitions: - * Constant definitions: - *---------------------------------------------------------------------------*/ - -/* avoid re-inclusion */ -#ifndef __LINKLIST_H -#define __LINKLIST_H - -#include "hdf.h" - -/* Definitions for linked-list creation flags */ -#define HUL_UNSORTED_LIST 0x0000 -#define HUL_SORTED_LIST 0x0001 - -/* Type of the function to compare objects & keys */ -typedef intn (*HULsearch_func_t)(const VOIDP obj, const VOIDP key); - -/* Type of the function to compare two objects */ -typedef intn (*HULfind_func_t)(const VOIDP obj1, const VOIDP obj2); - -/* Linked list information structure used */ -typedef struct node_info_struct_tag { - VOIDP *obj_ptr; /* pointer associated with the linked list node */ - struct node_info_struct_tag *next; /* link to list node */ - }node_info_t; - -/* Linked list head structure */ -typedef struct list_head_struct_tag { - uintn count; /* # of nodes in the list */ - uintn flags; /* list creation flags */ - HULfind_func_t cmp_func; /* node comparison function */ - node_info_t *node_list; /* pointer to a linked list of nodes */ - node_info_t *curr_node; /* pointer to the current node when iterating */ - }list_head_t; - -#if defined LIST_MASTER | defined LIST_TESTER - -/* Define this in only one place */ -#ifdef LIST_MASTER -/* Pointer to the list node free list */ -static node_info_t *node_free_list=NULL; - -#endif /* LIST_MASTER */ - -/* Useful routines for generally private use */ - -#endif /* LIST_MASTER | LIST_TESTER */ - -#if defined c_plusplus || defined __cplusplus -extern "C" -{ -#endif /* c_plusplus || __cplusplus */ - -/****************************************************************************** - NAME - HULcreate_list - Create a linked list - - DESCRIPTION - Creates a linked list. The list may either be sorted or un-sorted, based - on the comparison function. - - RETURNS - Returns a pointer to the list if successful and NULL otherwise - -*******************************************************************************/ -list_head_t *HULcreate_list(HULfind_func_t find_func /* IN: object comparison function */ -); - -/****************************************************************************** - NAME - HULdestroy_list - Destroys a linked list - - DESCRIPTION - Destroys a linked list created by HULcreate_list(). This function - walks through the list and frees all the nodes, then frees the list head. - Note: this function does not (currently) free the objects in the nodes, - it just leaves 'em hanging. - - RETURNS - Returns SUCCEED/FAIL. - -*******************************************************************************/ -intn HULdestroy_list(list_head_t *lst /* IN: list to destroy */ -); - -/****************************************************************************** - NAME - HULadd_node - Adds an object to a linked-list - - DESCRIPTION - Adds an object to the linked list. If the list is sorted, the comparison - function is used to determine where to insert the node, otherwise it is - inserted at the head of the list. - - RETURNS - Returns SUCCEED/FAIL. - -*******************************************************************************/ -intn HULadd_node(list_head_t *lst, /* IN: list to modify */ - VOIDP obj /* IN: object to add to the list */ -); - -/****************************************************************************** - NAME - HULsearch_node - Search for an object in a linked-list - - DESCRIPTION - Locate an object in a linked list using a key and comparison function. - - RETURNS - Returns a pointer to the object found in the list, or NULL on failure. - -*******************************************************************************/ -VOIDP HULsearch_node(list_head_t *lst, /* IN: list to search */ - HULsearch_func_t srch_func, /* IN: function to use to find node */ - VOIDP key /* IN: key of object to search for */ -); - -/****************************************************************************** - NAME - HULfirst_node - Get the first object in a linked-list - - DESCRIPTION - Returns the first object in a linked-list and prepares the list for - interating through. - - RETURNS - Returns a pointer to the first object found in the list, or NULL on failure. - -*******************************************************************************/ -VOIDP HULfirst_node(list_head_t *lst /* IN: list to search */ -); - -/****************************************************************************** - NAME - HULnext_node - Get the next object in a linked-list - - DESCRIPTION - Returns the next object in a linked-list by walking through the list - - RETURNS - Returns a pointer to the next object found in the list, or NULL on failure. - -*******************************************************************************/ -VOIDP HULnext_node(list_head_t *lst /* IN: list to search */ -); - -/****************************************************************************** - NAME - HULremove_node - Removes an object from a linked-list - - DESCRIPTION - Remove an object from a linked list. The key and comparison function are - provided locate the object to delete. - - RETURNS - Returns a pointer to the object deleted from the list, or NULL on failure. - -*******************************************************************************/ -VOIDP HULremove_node(list_head_t *lst, /* IN: list to modify */ - HULsearch_func_t srch_func, /* IN: function to use to find node to remove */ - VOIDP key /* IN: object to add to the list */ -); - -/*-------------------------------------------------------------------------- - NAME - HULshutdown - PURPOSE - Terminate various global items. - USAGE - intn HULshutdown() - RETURNS - Returns SUCCEED/FAIL - DESCRIPTION - Free various buffers allocated in the HUL routines. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - Should only ever be called by the "atexit" function HDFend - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -intn -HULshutdown(void); - -#if defined c_plusplus || defined __cplusplus -} -#endif /* c_plusplus || __cplusplus */ - -#endif /* __LINKLIST_H */ - diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/mfan.h b/Utilities/CAI/cai_dll/inc/inc_hdf/mfan.h deleted file mode 100755 index 9865cc7a0641d3c4f91cc778f66f23c723c402a0..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/mfan.h +++ /dev/null @@ -1,372 +0,0 @@ -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -/* $Id$ */ - -/*------------------------------------------------------------------------------ - * File: mfan.h - * Author: GeorgeV - * Purpose: header file for the Multi-file Annotation Interface - * Invokes: - * Contents: - * Structure definitions: ANnode, ANentry - * Constant definitions: AN_DATA_LABEL, AN_DATA_DESC - * (-moved to hdf.h) AN_FILE_LABEL, AN_FILE_DESC - * - *----------------------------------------------------------------------------*/ - -#ifndef _MFAN_H /* avoid re-inclusion */ -#define _MFAN_H - -#include "hdf.h" - -#if 0 -/* enumerated types of the varous annotation types - * NOTE: moved to hdf.h since they are used by end users. */ -typedef enum -{ - AN_DATA_LABEL = 0, /* Data label */ - AN_DATA_DESC, /* Data description */ - AN_FILE_LABEL, /* File label */ - AN_FILE_DESC /* File description */ -} ann_type; -#endif - -#ifdef MFAN_C -/* WE ARE IN MAIN ANNOTATION SOURCE FILE "mfan.c" */ - -/* PRIVATE variables and definitions */ - -/* This sturcture is used to find which file the annotation belongs to - * and use the subsequent file specific annotation 'key' to find the - * annotation. The annotation atom group(ANIDGROUP) keeps track of - * all anotations across the file. */ -typedef struct ANnode -{ - int32 file_id; /* which file this annotation belongs to */ - int32 ann_key; /* type/ref: used to find annotation in corresponding - TBBT in filerec_t->tree[]. */ - intn new_ann; /* flag */ -} ANnode; - -/* - * This structure is an entry in the label/desc tree - * for a label/desc in the file, it gives the ref of the label/desc, - * and the tag/ref of the data item to which the label/desc relates - * The filerec_t->an_tree[] TBBT members will contain these entries. - **/ -typedef struct ANentry -{ - int32 ann_id; /* annotation id */ - uint16 annref; /* ref of annotation */ - uint16 elmtag; /* tag of data */ - uint16 elmref; /* ref of data */ -} ANentry; - - -/* This is the size of the hash tables used for annotation IDs */ -#define ANATOM_HASH_SIZE 64 - -/* Used to create unique 32bit keys from annotation type and reference number - * This key is used to add nodes to a corresponding TBBT in - * filrerec_t->an_tree[]. - * ---------------------------- - * | type(16bits) | ref(16bits) | - * -----------------------------*/ -#define AN_CREATE_KEY(t,r) ((((int32)t & 0xffff) << 16) | r) - -/* Obtain Reference number from key */ -#define AN_KEY2REF(k) ((uint16)((int32)k & 0xffff)) - -/* Obtain Annotation type from key */ -#define AN_KEY2TYPE(k) ((int32)((int32)k >> 16)) - -#else /* !MFAN_C */ -/* WE are NOT in main ANNOTATION source file - * Nothing EXPORTED except Public fcns */ - - -/****************************************************************************** - NAME - ANdestroy -- Un-Initialize Annotation Interface - - DESCRIPTION - Unallocates global annotaton node list and file list. - - RETURNS - SUCCEED or FAIL -*******************************************************************************/ -extern intn ANdestroy(void); - -/****************************************************************************** - NAME - ANstart - open file for annotation handling - - DESCRIPTION - Start annotation handling on the file return a annotation ID to the file. - - RETURNS - A file ID or FAIL. -*******************************************************************************/ -extern int32 ANstart(int32 file_id /* IN: file to start annotation access on */); - -/****************************************************************************** - NAME - ANfileinfo - Report high-level information about the ANxxx interface for a given file. - - DESCRIPTION - Reports general information about the number of file and object(i.e. data) - annotations in the file. This routine is generally used to find - the range of acceptable indices for ANselect calls. - - RETURNS - Returns SUCCEED if successful and FAIL othewise - -*******************************************************************************/ -extern intn ANfileinfo(int32 an_id, /* IN: annotation interface id */ - int32 *n_file_label, /* OUT: the # of file labels */ - int32 *n_file_desc, /* OUT: the # of file descriptions */ - int32 *n_obj_label, /* OUT: the # of object labels */ - int32 *n_obj_desc /* OUT: the # of object descriptions */); - -/****************************************************************************** - NAME - ANend - End annotation access to file file - - DESCRIPTION - End annotation access to file. - - RETURNS - SUCCEED if successful and FAIL otherwise. -*******************************************************************************/ -extern int32 ANend(int32 an_id /* IN: Annotation ID of file to close */); - -/****************************************************************************** - NAME - ANcreate - create a new element annotation and return a handle(id) - - DESCRIPTION - Creates a data annotation, returns an 'an_id' to work with the new - annotation which can either be a label or description. - Valid annotation types are AN_DATA_LABEL for data labels and - AN_DATA_DESC for data descriptions. - - RETURNS - An ID to an annotation which can either be a label or description. -*******************************************************************************/ -extern int32 ANcreate(int32 an_id, /* IN: annotation interface ID */ - uint16 elem_tag, /* IN: tag of item to be assigned annotation */ - uint16 elem_ref, /* IN: reference number of itme to be assigned ann*/ - ann_type type /* IN: annotation type */); - - -/****************************************************************************** - NAME - ANcreatef - create a new file annotation and return a handle(id) - - DESCRIPTION - Creates a file annotation, returns an 'an_id' to work with the new - file annotation which can either be a label or description. - Valid annotation types are AN_FILE_LABEL for file labels and - AN_FILE_DESC for file descritpions. - - RETURNS - An ID to an annotation which can either be a file label or description -*******************************************************************************/ -extern int32 ANcreatef(int32 an_id, /* IN: annotation interface ID */ - ann_type type /* IN: annotation type */); - -/****************************************************************************** - NAME - ANselect - get an annotation ID from index of 'type' - - DESCRIPTION - Get an annotation Id from index of 'type'. - The position index is ZERO based - - RETURNS - An ID to an annotation type which can either be a label or description -*******************************************************************************/ -extern int32 ANselect(int32 an_id, /* IN: annotation interface ID */ - int32 index, /* IN: index of annottion to get ID for */ - ann_type type /* IN: annotation type */); - -/****************************************************************************** - NAME - ANnumann - find number of annotation of 'type' that match the given element tag/ref - - DESCRIPTION - Find number of annotation of 'type' for the given element - tag/ref pair.Should not be used for File labels and - descriptions. - - RETURNS - number of annotation found if successful and FAIL (-1) otherwise - -*******************************************************************************/ -extern intn ANnumann(int32 an_id, /* IN: annotation interface id */ - ann_type type, /* IN: annotation type */ - uint16 elem_tag, /* IN: tag of item of which this is annotation */ - uint16 elem_ref /* IN: ref of item of which this is annotation*/); - -/****************************************************************************** - NAME - ANannlist - generate list of annotation ids of 'type' that match the given element tag/ref - - DESCRIPTION - Find and generate list of annotation ids of 'type' for the given - element tag/ref pair.Should not be used for File labels and - descriptions. - - RETURNS - number of annotations ids found if successful and FAIL (-1) otherwise - -*******************************************************************************/ -extern intn ANannlist(int32 an_id, /* IN: annotation interface id */ - ann_type type, /* IN: annotation type */ - uint16 elem_tag, /* IN: tag of item of which this is annotation */ - uint16 elem_ref, /* IN: ref of item of which this is annotation*/ - int32 ann_list[] /* OUT: array of ann_id's that match criteria.*/); - -/****************************************************************************** - NAME - ANannlen - get length of annotation givne annotation id - - DESCRIPTION - Uses the annotation id to find ann_key & file_id - - RETURNS - length of annotation if successful and FAIL (-1) otherwise - -*******************************************************************************/ -extern int32 ANannlen(int32 ann_id /* IN: annotation id */); - -/****************************************************************************** - NAME - ANwriteann - write annotation given ann_id - - DESCRIPTION - Checks for pre-existence of given annotation, replacing old one if it - exists. Writes out annotation. - - RETURNS - SUCCEED (0) if successful and FAIL (-1) otherwise - -*******************************************************************************/ -extern int32 ANwriteann(int32 ann_id, /* IN: annotation id */ - const char *ann, /* IN: annotation to write */ - int32 annlen /* IN: length of annotation*/); - -/****************************************************************************** - NAME - ANreadann - read annotation given ann_id - - DESCRIPTION - Gets tag and ref of annotation. Finds DD for that annotation. - Reads the annotation, taking care of NULL terminator, if necessary. - - RETURNS - SUCCEED (0) if successful and FAIL (-1) otherwise - -*******************************************************************************/ -extern int32 ANreadann(int32 ann_id, /* IN: annotation id (handle) */ - char *ann, /* OUT: space to return annotation in */ - int32 maxlen /* IN: size of space to return annotation in */); - -/****************************************************************************** - NAME - ANendaccess - end access to an annotation given it's id - - DESCRIPTION - Terminates access to an annotation. For now does nothing - - RETURNS - SUCCEED(0) or FAIL(-1) -*******************************************************************************/ -extern intn ANendaccess(int32 ann_id /* IN: annotation id */); - -/****************************************************************************** - NAME - ANget_tagref - get tag/ref pair for annotation based on type and index - - DESCRIPTION - Get the tag/ref of the annotation based on the type and index of the - annotation. The position index is zero based - - RETURNS - A tag/ref pairt to an annotation type which can either be a - label or description. - -*******************************************************************************/ -extern int32 ANget_tagref(int32 an_id, /* IN: annotation interface ID */ - int32 index, /* IN: index of annotation to get tag/ref for*/ - ann_type type, /* IN: annotation type */ - uint16 *ann_tag,/* OUT: Tag for annotation */ - uint16 *ann_ref /* OUT: ref for annotation */); - -/****************************************************************************** - NAME - ANid2tagref -- get tag/ref given annotation id - - DESCRIPTION - Uses the annotation id to find ann_node entry which contains ann_ref - - RETURNS - SUCCEED(0) if successful and FAIL (-1) otherwise. -*******************************************************************************/ -extern int32 ANid2tagref(int32 ann_id, /* IN: annotation id */ - uint16 *ann_tag, /* OUT: Tag for annotation */ - uint16 *ann_ref /* OUT: ref for annotation */); - -/****************************************************************************** - NAME - ANtagref2id -- get annotation id given tag/ref - - DESCRIPTION - Gets the annotation id of the annotation given the tag/ref of - the annotation itself and the annotation interface id. - - RETURNS - Annotation id of annotation if successful and FAIL(-1) otherwise. -*******************************************************************************/ -extern int32 ANtagref2id(int32 an_id, /* IN Annotation interface id */ - uint16 ann_tag, /* IN: Tag for annotation */ - uint16 ann_ref /* IN: ref for annotation */); - -/****************************************************************************** - NAME - ANatype2tag - annotation type to corresponding annotation TAG - - DESCRIPTION - Translate annotation type to corresponding TAG. - - RETURNS - Returns TAG corresponding to annotatin type. -*******************************************************************************/ -extern uint16 ANatype2tag(ann_type atype /* IN: Annotation type */); - -/****************************************************************************** - NAME - ANtag2atype - annotation TAG to corresponding annotation type - - DESCRIPTION - Translate annotation TAG to corresponding atype - - RETURNS - Returns type corresponding to annotatin TAG. -*******************************************************************************/ -extern ann_type ANtag2atype(uint16 atag /* IN: annotation tag */); - - -#endif /* !MFAN_C */ - -#endif /* _MFAN_H */ diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/mfgr.h b/Utilities/CAI/cai_dll/inc/inc_hdf/mfgr.h deleted file mode 100755 index 9459b81a33dc638ab68c96a6810f016eca824c7a..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/mfgr.h +++ /dev/null @@ -1,143 +0,0 @@ -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -/* $Id$ */ - -/*----------------------------------------------------------------------------- - * File: mfgr.h - * Purpose: header file for multi-file general raster information - * Dependencies: - * Invokes: - * Contents: - * Structure definitions: - * Constant definitions: - *---------------------------------------------------------------------------*/ - -/* avoid re-inclusion */ -#ifndef __MFGR_H -#define __MFGR_H - -/* Interlace types available */ -typedef int16 gr_interlace_t; -#define MFGR_INTERLACE_PIXEL 0 /* pixel interlacing scheme */ -#define MFGR_INTERLACE_LINE 1 /* line interlacing scheme */ -#define MFGR_INTERLACE_COMPONENT 2 /* component interlacing scheme */ - -#if defined MFGR_MASTER | defined MFGR_TESTER - -#include "hfile.h" -#include "tbbt.h" /* Get tbbt routines */ - -/* This is the size of the hash tables used for GR & RI IDs */ -#define GRATOM_HASH_SIZE 32 - -/* The tag of the attribute data */ -#define RI_TAG DFTAG_VG /* Current RI groups are stored in Vgroups */ -#define ATTR_TAG DFTAG_VH /* Current GR attributes are stored in VDatas */ - -/* The default threshhold for attributes which will be cached */ -#define GR_ATTR_THRESHHOLD 2048 - -#define VALIDRIINDEX(i,gp) ((i)>=0 && (i)<(gp)->gr_count) - -/* - * Each gr_info_t maintains 2 threaded-balanced-binary-tress: one of - * raster images and one of global attributes - */ - -typedef struct gr_info { - int32 hdf_file_id; /* the corresponding HDF file ID (must be first in the structure) */ - uint16 gr_ref; /* ref # of the Vgroup of the GR in the file */ - - int32 gr_count; /* # of image entries in gr_tab so far */ - TBBT_TREE *grtree; /* Root of image B-Tree */ - uintn gr_modified; /* whether any images have been modified */ - - int32 gattr_count; /* # of global attr entries in gr_tab so far */ - TBBT_TREE *gattree; /* Root of global attribute B-Tree */ - uintn gattr_modified; /* whether any global attributes have been modified */ - - intn access; /* the number of active pointers to this file's GRstuff */ - uint32 attr_cache; /* the threshhold for the attribute sizes to cache */ -} gr_info_t; - -typedef struct at_info { - int32 index; /* index of the attribute (needs to be first in the struct) */ - int32 nt; /* number type of the attribute */ - int32 len; /* length/order of the attribute */ - uint16 ref; /* ref of the attribute (stored in VData) */ - uintn data_modified; /* flag to indicate whether the attribute data has been modified */ - uintn new_at; /* flag to indicate whether the attribute was added to the Vgroup */ - char *name; /* name of the attribute */ - void * data; /* data for the attribute */ -} at_info_t; - -typedef struct dim_info { - uint16 dim_ref; /* reference # of the Dim record */ - int32 xdim,ydim, /* dimensions of the image */ - ncomps, /* number of components of each pixel in image */ - nt, /* number type of the components */ - file_nt_subclass; /* number type subclass of data on disk */ - gr_interlace_t il; /* interlace of the components (stored on disk) */ - uint16 nt_tag,nt_ref; /* tag & ref of the number-type info */ - uint16 comp_tag,comp_ref; /* tag & ref of the compression info */ -} dim_info_t; - -typedef struct ri_info { - int32 index; /* index of this image (needs to be first in the struct) */ - uint16 ri_ref; /* ref # of the RI Vgroup */ - uint16 rig_ref; /* ref # of the RIG group */ - gr_info_t *gr_ptr; /* ptr to the GR info that this ri_info applies to */ - dim_info_t img_dim; /* image dimension information */ - dim_info_t lut_dim; /* palette dimension information */ - uint16 img_tag,img_ref; /* tag & ref of the image data */ - int32 img_aid; /* AID for the image data */ - intn acc_perm; /* Access permission (read/write) for image AID */ - uint16 lut_tag,lut_ref; /* tag & ref of the palette data */ - gr_interlace_t im_il; /* interlace of image when next read (default PIXEL) */ - gr_interlace_t lut_il; /* interlace of LUT when next read */ - uintn data_modified; /* whether the image or palette data has been modified */ - uintn meta_modified; /* whether the image or palette meta-info has been modified */ - uintn attr_modified; /* whether the attributes have been modified */ - char *name; /* name of the image */ - int32 lattr_count; /* # of local attr entries in ri_info so far */ - TBBT_TREE *lattree; /* Root of the local attribute B-Tree */ - intn access; /* the number of times this image has been selected */ - uintn use_buf_drvr; /* access to image needs to be through the buffered special element driver */ - uintn use_cr_drvr; /* access to image needs to be through the compressed raster special element driver */ - uintn comp_img; /* whether to compress image data */ - comp_coder_t comp_type; /* compression type */ - comp_info cinfo; /* compression information */ - uintn ext_img; /* whether to make image data external */ - char *ext_name; /* name of the external file */ - int32 ext_offset; /* offset in the external file */ - uintn acc_img; /* whether to make image data a different access type */ - uintn acc_type; /* type of access-mode to get image data with */ - uintn fill_img; /* whether to fill image, or just store fill value */ - void * fill_value; /* pointer to the fill value (NULL means use default fill value of 0) */ - uintn store_fill; /* whether to add fill value attribute or not */ -} ri_info_t; - -/* Useful raster routines for generally private use */ - -HDFLIBAPI intn GRIil_convert(const void * inbuf,gr_interlace_t inil,void * outbuf, - gr_interlace_t outil,int32 dims[2],int32 ncomp,int32 nt); - -extern VOID GRIgrdestroynode(void * n); - -extern VOID GRIattrdestroynode(void * n); - -extern VOID GRIridestroynode(void * n); - -#endif /* MFGR_MASTER | MFGR_TESTER */ - -#endif /* __MFGR_H */ diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/mstdio.h b/Utilities/CAI/cai_dll/inc/inc_hdf/mstdio.h deleted file mode 100755 index 0af1d823029443ab9baa679f87cca2a0fe672b56..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/mstdio.h +++ /dev/null @@ -1,89 +0,0 @@ - -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -/* $Id$ */ - -/*----------------------------------------------------------------------------- - * File: mstdio.h - * Purpose: Header file for stdio-like modeling information. - * Dependencies: should be included after hdf.h - * Invokes: - * Contents: Structures & definitions for stdio modeling. This header - * should only be included in hcomp.c and mstdio.c. - * Structure definitions: - * Constant definitions: - *---------------------------------------------------------------------------*/ - -/* avoid re-inclusion */ -#ifndef __MSTDIO_H -#define __MSTDIO_H - -#if defined c_plusplus || defined __cplusplus -extern "C" -{ -#endif /* c_plusplus || __cplusplus */ - -/* - ** from mstdio.c - */ - - extern int32 HCPmstdio_stread - (accrec_t * rec); - - extern int32 HCPmstdio_stwrite - (accrec_t * rec); - - extern int32 HCPmstdio_seek - (accrec_t * access_rec, int32 offset, int origin); - - extern int32 HCPmstdio_inquire - (accrec_t * access_rec, int32 *pfile_id, uint16 *ptag, uint16 *pref, - int32 *plength, int32 *poffset, int32 *pposn, int16 *paccess, - int16 *pspecial); - - extern int32 HCPmstdio_read - (accrec_t * access_rec, int32 length, void * data); - - extern int32 HCPmstdio_write - (accrec_t * access_rec, int32 length, const void * data); - - extern intn HCPmstdio_endaccess - (accrec_t * access_rec); - -#if defined c_plusplus || defined __cplusplus -} -#endif /* c_plusplus || __cplusplus */ - -/* model information about stdio model */ -typedef struct -{ - int32 pos; /* postion ? */ -} -comp_model_stdio_info_t; - -#ifndef MSTDIO_MASTER -extern funclist_t mstdio_funcs; /* functions to perform run-length encoding */ -#else -funclist_t mstdio_funcs = -{ /* functions to perform run-length encoding */ - HCPmstdio_stread, - HCPmstdio_stwrite, - HCPmstdio_seek, - HCPmstdio_inquire, - HCPmstdio_read, - HCPmstdio_write, - HCPmstdio_endaccess -}; -#endif - -#endif /* __MSTDIO_H */ diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/netcdf.h b/Utilities/CAI/cai_dll/inc/inc_hdf/netcdf.h deleted file mode 100755 index bae79fa0db81359fb06aaca5b1699af97306ee6c..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/netcdf.h +++ /dev/null @@ -1,581 +0,0 @@ -/* Generated automatically from netcdf.h.in by configure. */ -/* - * Copyright 1993, University Corporation for Atmospheric Research - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose without fee is hereby granted, provided - * that the above copyright notice appear in all copies, that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of UCAR/Unidata not be used in - * advertising or publicity pertaining to distribution of the software - * without specific, written prior permission. UCAR makes no - * representations about the suitability of this software for any purpose. - * It is provided "as is" without express or implied warranty. It is - * provided with no support and without obligation on the part of UCAR - * Unidata, to assist in its use, correction, modification, or enhancement. - * - */ -/* "$Id$" */ - -#ifndef _NETCDF_ -#define _NETCDF_ - -//RWR Modification Start 07/14/98 -//#include "api_adpt.h" -#include "hdfi.h" -//RWR Modification End - -/* - * The definitions ncvoid, USE_ENUM, and MAX_NC_OPEN, may need to be set - * properly for your installation. - */ - -/* - * Argument type in user functions (deprecated, backward compatibility) - */ -#ifndef UD_NO_VOID -#define ncvoid void -#else -/* system doesn't have void type */ -#define ncvoid char -#endif - - -/* - * If xdr_enum works properly on your system, you can define - * USE_ENUM so that nc_type is an enum. - * Otherwise, delete this definition so that the nc_type is - * an int and the valid values are #defined. - */ -#define USE_ENUM - - -/* - * The following macro is provided for backward compatibility only. If you - * are a new user of netCDF, then you may safely ignore it. If, however, - * you have an existing archive of netCDF files that use default - * floating-point fill values, then you should know that the definition of - * the default floating-point fill values changed with version 2.3 of the - * netCDF package. Prior to this release, the default floating-point fill - * values were not very portable: their correct behavior depended not only - * upon the particular platform, but also upon the compilation - * environment. This led to the definition of new, default floating-point - * fill values that are portable across all platforms and compilation - * environments. If you wish, however, to obtain the old, non-portable - * floating-point fill values, then the following macro should have a true - * value PRIOR TO BUILDING THE netCDF LIBRARY. - * - * Implementation details are contained in the section below on fill values. - */ -#define NC_OLD_FILLVALUES 0 - -/* - * Fill values - * These values are stuffed into newly allocated space as appropriate. - * The hope is that one might use these to notice that a particular datum - * has not been set. - */ - -#define FILL_BYTE ((char)-127) /* Largest Negative value */ -#define FILL_CHAR ((char)0) -#define FILL_SHORT ((short)-32767) -#define FILL_LONG ((long)-2147483647) - -#if !NC_OLD_FILLVALUES - -# define FILL_FLOAT 9.9692099683868690e+36 /* near 15 * 2^119 */ -# define FILL_DOUBLE 9.9692099683868690e+36 - -#else /* NC_OLD_FILLVALUES below */ - -/* - * This section is provided for backward compatibility only. Using - * XDR infinities for floating-point fill values has caused more problems - * than it has solved. We encourage you to define your own data-specific - * fill values rather than use default ones (see `_FillValue' below). - * If, however, you *must* use default fill values, then you should use - * the above fill values rather than the ones in this section. - */ - -/* - * XDR_F_INFINITY is a float value whose EXTERNAL (xdr) - * represention is ieee floating infinity. - * XDR_D_INFINITY is a double value whose EXTERNAL (xdr) - * represention is ieee double floating point infinity. - * These are used as default fill values below. - * - * This section shows three techniques for setting these: - * Direct assignment (vax, cray) - works for non IEEE machines - * Doesn't work when IEEE machines don't allow - * float or double constants whose values are infinity. - * Use of a union (preferred portable method) - should work on - * any ANSI compiler with IEEE floating point representations, - * modulo byte order and sizeof() considerations. - * Use of pointer puns - may work with many older compilers - * which don't allow intialization of unions. - * Often doesn't work with compilers which have strict - * alignment rules. - */ - - /* Direct assignment. All cases should be mutually exclusive */ - -#ifdef vax -#define XDR_D_INFINITY 1.7014118346046923e+38 -#define XDR_F_INFINITY 1.70141173e+38 -#endif /* vax */ - -#ifdef cray -#define XDR_D_INFINITY 1.797693134862313000e+308 -#define XDR_F_INFINITY XDR_D_INFINITY -#endif /* cray */ - -#ifdef notdef /* you might want to try these, on an IEEE machine */ -#define XDR_D_INFINITY 1.797693134862315900e+308 -#define XDR_F_INFINITY 3.40282357e+38 -#endif - -#ifdef __STDC__ - /* Use of a union, assumes IEEE representation and 1 byte unsigned char */ - -#ifndef XDR_D_INFINITY -#define USE_D_UNION - union xdr_d_union {unsigned char bb[8]; double dd;} ; - extern union xdr_d_union xdr_d_infs ; /* instantiated in array.c */ -#define XDR_D_INFINITY (xdr_d_infs.dd) -#endif /* !XDR_D_INFINITY */ - -#ifndef XDR_F_INFINITY -#define USE_F_UNION - union xdr_f_union {unsigned char bb[4]; float ff;} ; - extern union xdr_f_union xdr_f_infs ; /* instantiated in array.c */ -#define XDR_F_INFINITY (xdr_f_infs.ff) -#endif /* !XDR_F_INFINITY */ - - -#else /* __STDC__ */ - /* Use of a pointer pun, assumes IEEE representation, 4 byte long */ - -#ifndef XDR_D_INFINITY -#define USE_D_LONG_PUN - extern long xdr_d_infinity[] ; /* instantiated in array.c */ -#define XDR_D_INFINITY *(double *)xdr_d_infinity -#endif /* !XDR_D_INFINITY */ - -#ifndef XDR_F_INFINITY -#define USE_F_LONG_PUN - extern long xdr_f_infinity ; /* instantiated in array.c */ -#define XDR_F_INFINITY *((float *)&xdr_f_infinity) -#endif /* !XDR_F_INFINITY */ - -#endif /* __STDC__ */ - -/* End of INFINITY section */ - -#define FILL_FLOAT XDR_F_INFINITY /* IEEE Infinity */ -#define FILL_DOUBLE XDR_D_INFINITY - -#endif /* NC_OLD_FILLVALUES above */ - -/* - * masks for the struct NC flags field; passed in as 'mode' arg to - * nccreate and ncopen. - * - */ -#define NC_RDWR 1 /* read/write, 0 => readonly */ -#define NC_CREAT 2 /* in create phase, cleared by ncendef */ -#define NC_EXCL 4 /* on create, don't destroy existing file */ -#define NC_INDEF 8 /* in define mode, cleared by ncendef */ -#define NC_NSYNC 0x10 /* synchronise numrecs on change */ -#define NC_HSYNC 0x20 /* synchronise whole header on change */ -#define NC_NDIRTY 0x40 /* numrecs has changed */ -#define NC_HDIRTY 0x80 /* header info has changed */ -#define NC_NOFILL 0x100 /* Don't fill vars on endef and increase of record */ -#define NC_LINK 0x8000 /* isa link */ - -#define NC_FILL 0 /* argument to ncsetfill to clear NC_NOFILL */ - -/* - * 'mode' arguments for nccreate and ncopen - */ -#define NC_NOWRITE 0 -#define NC_WRITE NC_RDWR -#define NC_CLOBBER (NC_INDEF | NC_CREAT | NC_RDWR) -#define NC_NOCLOBBER (NC_INDEF | NC_EXCL | NC_CREAT | NC_RDWR) - -/* - * 'size' argument to ncdimdef for an unlimited dimension - */ -#define NC_UNLIMITED 0L - -/* - * attribute id to put/get a global attribute - */ -#define NC_GLOBAL -1 - -#ifndef HDF -/* - * This can be as large as the maximum number of stdio streams - * you can have open on your system. - */ -#define MAX_NC_OPEN 32 - -/* - * These maximums are enforced by the interface, to facilitate writing - * applications and utilities. However, nothing is statically allocated to - * these sizes internally. - */ -#define MAX_NC_DIMS 5000 /* max dimensions per file */ -#define MAX_NC_ATTRS 3000 /* max global or per variable attributes */ -#define MAX_NC_VARS 5000 /* max variables per file */ -#define MAX_NC_NAME 256 /* max length of a name */ -#define MAX_VAR_DIMS 32 /* max per variable dimensions */ - -/* - * Added feature. - * If you wish a variable to use a different value than the above - * defaults, create an attribute with the same type as the variable - * and the following reserved name. The value you give the attribute - * will be used as the fill value for that variable. - */ -#define _FillValue "_FillValue" - -#else /* HDF */ - -#include "hlimits.h" /* Hard coded constants for HDF library */ - -#endif /* HDF */ - -#ifdef USE_ENUM -/* - * The netcdf data types - */ -typedef enum { - NC_UNSPECIFIED, /* private */ - NC_BYTE, - NC_CHAR, - NC_SHORT, - NC_LONG, - NC_FLOAT, - NC_DOUBLE, - /* private */ - NC_BITFIELD, - NC_STRING, - NC_IARRAY, - NC_DIMENSION, - NC_VARIABLE, - NC_ATTRIBUTE -} nc_type ; -#else -typedef int nc_type ; -#define NC_UNSPECIFIED 0 /* private */ -#define NC_BYTE 1 -#define NC_CHAR 2 -#define NC_SHORT 3 -#define NC_LONG 4 -#define NC_FLOAT 5 -#define NC_DOUBLE 6 - /* private */ -#define NC_BITFIELD 7 -#define NC_STRING 8 -#define NC_IARRAY 9 -#define NC_DIMENSION 10 -#define NC_VARIABLE 11 -#define NC_ATTRIBUTE 12 -#endif - - -/* - * C data types corresponding to netCDF data types: - */ -/* Don't use these or the C++ interface gets confused -typedef char ncchar; -typedef char ncbyte; -typedef short ncshort; -typedef float ncfloat; -typedef double ncdouble; -*/ - -/* - * Variables/attributes of type NC_LONG should use the C type 'nclong' - */ -#ifdef __alpha -typedef int nclong; -#else -typedef long nclong; /* default, compatible type */ -#endif - - -/* - * Global netcdf error status variable - * Initialized in error.c - */ -#define NC_NOERR 0 /* No Error */ -#define NC_EBADID 1 /* Not a netcdf id */ -#define NC_ENFILE 2 /* Too many netcdfs open */ -#define NC_EEXIST 3 /* netcdf file exists && NC_NOCLOBBER */ -#define NC_EINVAL 4 /* Invalid Argument */ -#define NC_EPERM 5 /* Write to read only */ -#define NC_ENOTINDEFINE 6 /* Operation not allowed in data mode */ -#define NC_EINDEFINE 7 /* Operation not allowed in define mode */ -#define NC_EINVALCOORDS 8 /* Coordinates out of Domain */ -#define NC_EMAXDIMS 9 /* MAX_NC_DIMS exceeded */ -#define NC_ENAMEINUSE 10 /* String match to name in use */ -#define NC_ENOTATT 11 /* Attribute not found */ -#define NC_EMAXATTS 12 /* MAX_NC_ATTRS exceeded */ -#define NC_EBADTYPE 13 /* Not a netcdf data type */ -#define NC_EBADDIM 14 /* Invalid dimension id */ -#define NC_EUNLIMPOS 15 /* NC_UNLIMITED in the wrong index */ -#define NC_EMAXVARS 16 /* MAX_NC_VARS exceeded */ -#define NC_ENOTVAR 17 /* Variable not found */ -#define NC_EGLOBAL 18 /* Action prohibited on NC_GLOBAL varid */ -#define NC_ENOTNC 19 /* Not a netcdf file */ -#define NC_ESTS 20 /* In Fortran, string too short */ -#define NC_EMAXNAME 21 /* MAX_NC_NAME exceeded */ -#define NC_ENTOOL NC_EMAXNAME /* Backward compatibility */ -#define NC_EUNLIMIT 22 /* NC_UNLIMITED size already in use */ - -#define NC_EXDR 32 /* */ -#define NC_SYSERR -1 - -extern int ncerr ; - -/* - * Global options variable. Used to determine behavior of error handler. - * Initialized in lerror.c - */ -#define NC_FATAL 1 -#define NC_VERBOSE 2 - -HDFLIBAPI int ncopts ; /* default is (NC_FATAL | NC_VERBOSE) */ - -/* - * NB: The following feature-test line is too long in order to accomodate a - * bug in the VMS 5.3 C compiler. - */ -#ifndef HAVE_PROTOTYPES -# if defined(__STDC__) || defined(__GNUC__) || defined(__cplusplus) || defined(c_plusplus) -# define HAVE_PROTOTYPES -# endif -#endif - -#undef PROTO -#ifdef HAVE_PROTOTYPES -# define PROTO(x) x -#else -# define PROTO(x) () -#endif - -#include "hdf2netcdf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -HDFLIBAPI int nccreate PROTO(( - const char* path, - int cmode -)); -HDFLIBAPI int ncopen PROTO(( - const char* path, - int mode -)); -HDFLIBAPI int ncredef PROTO(( - int cdfid -)); -HDFLIBAPI int ncendef PROTO(( - int cdfid -)); -HDFLIBAPI int ncclose PROTO(( - int cdfid -)); -HDFLIBAPI int ncinquire PROTO(( - int cdfid, - int* ndims, - int* nvars, - int* natts, - int* recdim -)); -HDFLIBAPI int ncsync PROTO(( - int cdfid -)); -HDFLIBAPI int ncabort PROTO(( - int cdfid -)); -HDFLIBAPI int ncdimdef PROTO(( - int cdfid, - const char* name, - long length -)); -HDFLIBAPI int ncdimid PROTO(( - int cdfid, - const char* name -)); -HDFLIBAPI int ncdiminq PROTO(( - int cdfid, - int dimid, - char* name, - long* length -)); -HDFLIBAPI int ncdimrename PROTO(( - int cdfid, - int dimid, - const char* name -)); -HDFLIBAPI int ncvardef PROTO(( - int cdfid, - const char* name, - nc_type datatype, - int ndims, - const int* dim -)); -HDFLIBAPI int ncvarid PROTO(( - int cdfid, - const char* name -)); -HDFLIBAPI int ncvarinq PROTO(( - int cdfid, - int varid, - char* name, - nc_type* datatype, - int* ndims, - int* dim, - int* natts -)); -HDFLIBAPI int ncvarput1 PROTO(( - int cdfid, - int varid, - const long* coords, - const void* value -)); -HDFLIBAPI int ncvarget1 PROTO(( - int cdfid, - int varid, - const long* coords, - void* value -)); -HDFLIBAPI int ncvarput PROTO(( - int cdfid, - int varid, - const long* start, - const long* count, - const void* value -)); -HDFLIBAPI int ncvarget PROTO(( - int cdfid, - int varid, - const long* start, - const long* count, - void* value -)); -HDFLIBAPI int ncvarputs PROTO(( - int cdfid, - int varid, - const long* start, - const long* count, - const long* stride, - const void* values -)); -HDFLIBAPI int ncvargets PROTO(( - int cdfid, - int varid, - const long* start, - const long* count, - const long* stride, - void* values -)); -HDFLIBAPI int ncvarputg PROTO(( - int cdfid, - int varid, - const long* start, - const long* count, - const long* stride, - const long* imap, - const void* values -)); -HDFLIBAPI int ncvargetg PROTO(( - int cdfid, - int varid, - const long* start, - const long* count, - const long* stride, - const long* imap, - void* values -)); -HDFLIBAPI int ncvarrename PROTO(( - int cdfid, - int varid, - const char* name -)); -HDFLIBAPI int ncattput PROTO(( - int cdfid, - int varid, - const char* name, - nc_type datatype, - int len, - const void* value -)); -HDFLIBAPI int ncattinq PROTO(( - int cdfid, - int varid, - const char* name, - nc_type* datatype, - int* len -)); -HDFLIBAPI int ncattget PROTO(( - int cdfid, - int varid, - const char* name, - void* value -)); -HDFLIBAPI int ncattcopy PROTO(( - int incdf, - int invar, - const char* name, - int outcdf, - int outvar -)); -HDFLIBAPI int ncattname PROTO(( - int cdfid, - int varid, - int attnum, - char* name -)); -HDFLIBAPI int ncattrename PROTO(( - int cdfid, - int varid, - const char* name, - const char* newname -)); -HDFLIBAPI int ncattdel PROTO(( - int cdfid, - int varid, - const char* name -)); -HDFLIBAPI int nctypelen PROTO(( - nc_type datatype -)); -HDFLIBAPI int ncsetfill PROTO(( - int cdfid, - int fillmode -)); -HDFLIBAPI int ncrecinq PROTO(( - int cdfid, - int* nrecvars, - int* recvarids, - long* recsizes -)); -HDFLIBAPI int ncrecget PROTO(( - int cdfid, - long recnum, - void** datap -)); -HDFLIBAPI int ncrecput PROTO(( - int cdfid, - long recnum, - void* const* datap -)); -#ifdef __cplusplus -} -#endif - -#endif /* _NETCDF_ */ diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/tbbt.h b/Utilities/CAI/cai_dll/inc/inc_hdf/tbbt.h deleted file mode 100755 index eebf864df29f7b509acce231ecd9cf1d959187c4..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/tbbt.h +++ /dev/null @@ -1,327 +0,0 @@ -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -/* $Id$ */ - -/* "tbbt.h" -- Data types/routines for threaded, balanced, binary trees. */ -/* Extended from Knuth 6.2.3, Algorithm A */ - -#ifndef TBBT_H -#define TBBT_H - -#ifdef lint /* lint always complains but may complain more if... */ -# define TBBT_INTERNALS /* TBBT_INTERNALS not always defined */ -#endif /* lint */ - -typedef struct tbbt_node TBBT_NODE; - -/* Threaded node structure */ -struct tbbt_node - { - VOIDP data; /* Pointer to user data to be associated with node */ - VOIDP key; /* Field to sort nodes on */ - -#ifdef TBBT_INTERNALS -# define PARENT 0 -# define LEFT 1 -# define RIGHT 2 - TBBT_NODE *link[3]; /* Pointers to parent, left child, and right child */ -# define Parent link[PARENT] -# define Lchild link[LEFT] -# define Rchild link[RIGHT] -# define TBBT_FLAG unsigned long -# define TBBT_LEAF unsigned long - TBBT_FLAG flags; /* Combination of the following bit fields: */ -# define TBBT_HEAVY(s) s /* If the `s' sub-tree is deeper than the other */ -# define TBBT_DOUBLE 4 /* If "heavy" sub-tree is two levels deeper */ -# define TBBT_INTERN 8 /* If node is internal (has two children) */ -# define TBBT_UNBAL ( TBBT_HEAVY(LEFT) | TBBT_HEAVY(RIGHT) ) -# define TBBT_FLAGS ( TBBT_UNBAL | TBBT_INTERN | TBBT_DOUBLE ) -# define TBBT_CHILD(s) ( TBBT_INTERN | TBBT_HEAVY(s) ) - TBBT_LEAF lcnt; /* count of left children */ - TBBT_LEAF rcnt; /* count of right children */ -# define LeftCnt(node) ( (node)->lcnt ) /* Left descendants */ -# define RightCnt(node) ( (node)->rcnt ) /* Left descendants */ -#if defined macintosh || defined MAC || defined SYMANTEC_C /* Macro substitution limit */ -# define Cnt(node,s) ( 1==(s) ? LeftCnt(node) : RightCnt(node) ) -#else /* !macintosh */ -# define Cnt(node,s) ( LEFT==(s) ? LeftCnt(node) : RightCnt(node) ) -#endif /* !macintosh */ -# define HasChild(n,s) ( Cnt(n,s)>0 ) -# define Heavy(n,s) ( (s) & (LeftCnt(n)>RightCnt(n) ? LEFT : \ - LeftCnt(n)==RightCnt(n) ? 0 : RIGHT)) -# define Intern(n) ( LeftCnt(n) && RightCnt(n) ) -# define UnBal(n) ( LeftCnt(n)>RightCnt(n) ? LEFT : \ - LeftCnt(n)==RightCnt(n) ? 0 : RIGHT) -# define Double(n) ( TBBT_DOUBLE & (n)->flags ) -# define Other(side) ( LEFT + RIGHT - (side) ) -# define Delta(n,s) ( ( Heavy(n,s) ? 1 : -1 ) \ - * ( Double(n) ? 2 : UnBal(n) ? 1 : 0 ) ) -# define SetFlags(n,s,b,i) ( ( -2<(b) && (b)<2 ? 0 : TBBT_DOUBLE ) \ - | ( 0>(b) ? TBBT_HEAVY(s) : (b)>0 ? TBBT_HEAVY(Other(s)) : 0 ) \ - | ( (i) ? TBBT_INTERN : 0 ) ) - }; - -/* Pointer to the tbbt node free list */ -static TBBT_NODE *tbbt_free_list=NULL; - -typedef struct tbbt_tree TBBT_TREE; -/* Threaded tree structure */ -struct tbbt_tree - { - TBBT_NODE *root; - unsigned long count; /* The number of nodes in the tree currently */ - uintn fast_compare; /* use a faster in-line compare (with casts) instead of function call */ - intn (*compar) (VOIDP k1, VOIDP k2, intn cmparg); - intn cmparg; -#endif /* TBBT_INTERNALS */ - }; - -/* Define the "fast compare" values */ -#define TBBT_FAST_UINT16_COMPARE 1 -#define TBBT_FAST_INT32_COMPARE 2 - -#ifndef TBBT_INTERNALS -typedef TBBT_NODE **TBBT_TREE; -#endif /* TBBT_INTERNALS */ - -/* Return maximum of two scalar values (use arguments w/o side effects): */ -#define Max(a,b) ( (a) > (b) ? (a) : (b) ) - -/* These routines are designed to allow use of a general-purpose balanced tree - * implimentation. These trees are appropriate for maintaining in memory one - * or more lists of items, each list sorted according to key values (key values - * must form a "completely ordered set") where no two items in a single list - * can have the same key value. The following operations are supported: - * Create an empty list - * Add an item to a list - * Look up an item in a list by key value - * Look up the Nth item in a list - * Delete an item from a list - * Find the first/last/next/previous item in a list - * Destroy a list - * Each of the above operations requires Order(log(N)) time where N is the - * number of items in the list (except for list creation which requires - * constant time and list destruction which requires Order(N) time if the user- - * supplied free-data-item or free-key-value routines require constant time). - * Each of the above operations (except create and destroy) can be performed - * on a subtree. - * - * Each node of a tree has associated with it a generic pointer (void *) which - * is set to point to one such "item" and a generic pointer to point to that - * item's "key value". The structure of the items and key values is up to the - * user to define. The user must specify a method for comparing key values. - * This routine takes three arguments, two pointers to key values and a third - * integer argument. You can specify a routine that expects pointers to "data - * items" rather than key values in which case the pointer to the key value in - * each node will be set equal to the pointer to the data item. - * - * Since the "data item" pointer is the first field of each tree node, these - * routines may be used without this "tbbt.h" file. For example, assume "ITM" - * is the structre definition for the data items you want to store in lists: - * ITM ***tbbtdmake( int (*cmp)(void *,void *,int), int arg ); - * ITM **root= NULL; (* How to create an empty tree w/o tbbtdmake() *) - * ITM **tbbtdfind( ITM ***tree, void *key, ITM ***pp ); - * ITM **tbbtfind( ITM **root, void *key, int (*cmp)(), int arg, ITM ***pp ); - * ITM **tbbtdless( ITM ***tree, void *key, ITM ***pp ); - * ITM **tbbtless( ITM **root, void *key, int (*cmp)(), int arg, ITM ***pp ); - * ITM **tbbtindx( ITM **root, long indx ); - * ITM **tbbtdins( ITM ***tree, ITM *item, void *key ); - * ITM **tbbtins( ITM ***root, ITM *item, void *key, int (*cmp)(), int arg ); - * ITM *tbbtrem( ITM ***root, ITM **node, void **kp ); - * ITM **tbbtfirst( ITM **root ), **tbbtlast( ITM **root ); - * ITM **tbbtnext( ITM **node ), **tbbtprev( ITM **node ); - * ITM ***tbbtdfree( ITM ***tree, void (*df)(ITM *), void (*kf)(void *) ); - * void tbbtfree( ITM ***root, void (*df)(ITM *), void (*kf)(void *) ); - */ - -#if defined c_plusplus || defined __cplusplus -extern "C" -{ -#endif /* c_plusplus || __cplusplus */ - - TBBT_TREE *tbbtdmake - (intn (*compar) (VOIDP, VOIDP, intn), intn arg, uintn fast_compare); -/* Allocates and initializes an empty threaded, balanced, binary tree and - * returns a pointer to the control structure for it. You can also create - * empty trees without this function as long as you never use tbbtd* routines - * (tbbtdfind, tbbtdins, tbbtdfree) on them. - * Examples: - * int keycmp(); - * TBBT_ROOT *root= tbbtdmake( keycmp, (int)keysiz , 0); - * or - * void *root= tbbtdmake( strcmp, 0 , 0); - * or - * void *root= tbbtdmake( keycmp, (int)keysiz , TBBT_FAST_UINT16_COMPARE); - * or - * TBBT_NODE *root= NULL; (* Don't use tbbtd* routines *) - * `cmp' is the routine to be used to compare two key values [in tbbtdfind() - * and tbbtdins()]. The arguments to `cmp' are the two keys to compare - * and `arg': (*cmp)(k1,k2,arg). `cmp' is expected to return 0 if its first - * two arguments point to identical key values, -1 (or any integer less than 0) - * if k1 points to a key value lower than that pointed to by k2, and 1 (or any - * integer greater than 0) otherwise. If `cmp' is NULL, memcmp is used. If - * `cmp' is NULL and `arg' is not greater than 0L, `1+strlen(key1)' is used in - * place of `arg' to emulate strcmp(): memcmp( k1, k2, 1+strlen(k1) ). You - * can use strcmp() directly (as in the second example above) as long as your C - * compiler does not assume strcmp() will always be passed exactly 2 arguments - * (only newer, ANSI-influenced C compilers are likely to be able to make this - * kind of assumption). You can also use a key comparison routine that expects - * pointers to data items rather than key values. - * The "fast compare" option is for keys of simple numeric types (currently - * uint16 and int32) and avoids the function call for faster searches in - * some cases. The key comparison routine is still required for some - * insertion routines which use it. - * - * Most of the other routines expect a pointer to a root node of a tree, not - * a pointer to the tree's control structure (only tbbtdfind(), tbbtdins(), - * and tbbtdfree() expect pointers to control structures). However TBBT_TREE - * is just defined as "**TBBT_NODE" (unless you have defined TBBT_INTERNALS so - * you have access to the internal structure of the nodes) so - * TBBT_TREE *tree1= tbbtdmake( NULL, 0 ); - * is equivalent to - * TBBT_NODE **tree1= tbbtdmake( NULL, 0 ); - * So could be used as: - * node= tbbtdfind( tree1, key, NULL ); - * node= tbbtfind( *tree1, key, compar, arg, NULL ); - * node= tbbtdless( tree1, key, NULL ); - * node= tbbtless( *tree1, key, compar, arg, NULL ); - * node= tbbtdins( tree1, item, key ); - * node= tbbtins( tree1, item, key, compar, arg ); - * item= tbbtrem( tree1, tbbtdfind(tree1,key,NULL), NULL ); - * item= tbbtrem( tree1, tbbtfind(*tree1,key,compar,arg,NULL), NULL ); - * tree1= tbbtdfree( tree1, free, NULL ); (* or whatever *) - * while - * TBBT_NODE *root= NULL; - * would be used like: - * node= tbbtfind( root, key ); - * node= tbbtins( &root, item, key ); - * node= tbbtrem( &root, tbbtfind(root,key), NULL ); - * tbbtfree( &root, free, NULL ); (* or whatever *) - * Never use tbbtfree() on a tree allocated with tbbtdmake() or on a sub-tree - * of ANY tree. Never use tbbtdfree() except on a tbbtdmake()d tree. - */ - - TBBT_NODE *tbbtdfind - (TBBT_TREE * tree, VOIDP key, TBBT_NODE ** pp); - TBBT_NODE *tbbtfind - (TBBT_NODE * root, VOIDP key, intn (*cmp) (VOIDP, VOIDP, intn), - intn arg, TBBT_NODE ** pp); - TBBT_NODE *tbbtdless - (TBBT_TREE * tree, VOIDP key, TBBT_NODE ** pp); - TBBT_NODE *tbbtless - (TBBT_NODE * root, VOIDP key, intn (*cmp) (VOIDP, VOIDP, intn), - intn arg, TBBT_NODE ** pp); -/* Locate a node based on the key given. A pointer to the node in the tree - * with a key value matching `key' is returned. If no such node exists, NULL - * is returned. Whether a node is found or not, if `pp' is not NULL, `*pp' - * will be set to point to the parent of the node we are looking for (or that - * node that would be the parent if the node is not found). tbbtdfind() is - * used on trees created using tbbtdmake() (so that `cmp' and `arg' don't have - * to be passed). tbbtfind() can be used on the root or any subtree of a tree - * create using tbbtdmake() and is used on any tree (or subtree) created with- - * out using tbbtdmake(). tbbtless() & tbbtdless() work exactly like tbbtfind() - * and tbbtdfind() except that they find the node with a key which is less than - * or equal to the key given to them. - */ - - TBBT_NODE *tbbtindx - (TBBT_NODE * root, int32 indx); -/* Locate the node that has `indx' nodes with lesser key values. This is like - * an array lookup with the first item in the list having index 0. For large - * values of `indx', this call is much faster than tbbtfirst() followed by - * `indx' tbbtnext()s. Thus `tbbtindx(&root,0L)' is equivalent to (and almost - * as fast as) `tbbtfirst(root)'. - */ - - TBBT_NODE *tbbtdins - (TBBT_TREE * tree, VOIDP item, VOIDP key); - TBBT_NODE *tbbtins - (TBBT_NODE ** root, VOIDP item, VOIDP key, intn (*cmp) (VOIDP, VOIDP, intn), intn arg); -/* Insert a new node to the tree having a key value of `key' and a data pointer - * of `item'. If a node already exists in the tree with key value `key' or if - * malloc() fails, NULL is returned (no node is inserted), otherwise a pointer - * to the inserted node is returned. `cmp' and `arg' are as for tbbtfind(). - */ - - VOIDP tbbtrem - (TBBT_NODE ** root, TBBT_NODE * node, VOIDP *kp); -/* Remove the node pointed to by `node' from the tree with root `root'. The - * data pointer for the deleted node is returned. If the second argument is - * NULL, NULL is returned. If `kp' is not NULL, `*kp' is set to point to the - * key value for the deleted node. Examples: - * data= tbbtrem( tree, tbbtdfind(tree,key), &kp ); free(data); free(kp); - * data= tbbtrem( &root, tbbtfind(root,key,compar,arg), NULL ); - * data= tbbtrem( &tree->root, tbbtdfind(tree,key), NULL ); - */ - - TBBT_NODE *tbbtfirst - (TBBT_NODE * root); - TBBT_NODE *tbbtlast - (TBBT_NODE * root); -/* Returns a pointer to node from the tree with the lowest(first)/highest(last) - * key value. If the tree is empy NULL is returned. Examples: - * node= tbbtfirst(*tree); - * node= tbbtfirst(root); - * node= tbbtlast(tree->root); - * node= tbbtlast(node); (* Last node in a sub-tree *) - */ - - TBBT_NODE *tbbtnext - (TBBT_NODE * node); - TBBT_NODE *tbbtprev - (TBBT_NODE * node); -/* Returns a pointer the node from the tree with the next highest (previous - * lowest) key value relative to the node pointed to by `node'. If `node' - * points the last (first) node of the tree, NULL is returned. - */ - - TBBT_TREE *tbbtdfree - (TBBT_TREE * tree, VOID(*fd) (VOIDP), VOID(*fk) (VOIDP)); - VOID tbbtfree - (TBBT_NODE ** root, VOID(*fd) (VOIDP), VOID(*fk) (VOIDP)); -/* Frees up an entire tree. `fd' is a pointer to a function that frees/ - * destroys data items, and `fk' is the same for key values. - * void free(); - * tree= tbbtdfree( tree, free, free ); - * tbbtfree( &root, free, free ); - * is a typical usage, where keys and data are individually malloc()d. If `fk' - * is NULL, no action is done for the key values (they were allocated on the - * stack, as a part of each data item, or together with one malloc() call, for - * example) and likewise for `fd'. tbbtdfree() always returns NULL and - * tbbtfree() always sets `root' to be NULL. - */ - - VOID tbbtprint - (TBBT_NODE * node); -/* Prints out the data in a node */ - - VOID tbbtdump - (TBBT_TREE * tree, intn method); -/* Prints an entire tree. The method variable determines which sort of - * traversal is used: - * -1 : Pre-Order Traversal - * 1 : Post-Order Traversal - * 0 : In-Order Traversal - */ - - long tbbtcount - (TBBT_TREE * tree); - -/* Terminate the buffers used in the tbbt*() interface */ - intn tbbt_shutdown(void); - -#if defined c_plusplus || defined __cplusplus -} -#endif /* c_plusplus || __cplusplus */ - -#endif /* TBBT_H */ diff --git a/Utilities/CAI/cai_dll/inc/inc_hdf/vg.h b/Utilities/CAI/cai_dll/inc/inc_hdf/vg.h deleted file mode 100755 index eb46fd04e4c731f51399f929ce52818087c14d83..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_hdf/vg.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -/* $Id$ */ - -/***************************************************************************** -* -* vg.h -* -* Part of HDF VSet interface -* -* defines symbols and structures used in all v*.c files -* -* NOTES: -* This include file depends on the basic HDF *.h files hdfi.h and hdf.h. -* An 'S' in the comment means that that data field is saved in the HDF file. -* -******************************************************************************/ - -#ifndef _VG_H -#define _VG_H - -/* -------------- H D F V S E T tags ---------------------------- */ - -/* In what versions were these valid? */ -#define OLD_VGDESCTAG 61820 /* tag for a vgroup d */ -#define OLD_VSDESCTAG 61821 /* tag for a vdata descriptor */ -#define OLD_VSDATATAG 61822 /* tag for actual raw data of a vdata */ - -/* re-define what new ones are. Don't know why there are two sets but - made them conform to what was in 'htags.h' */ -#define NEW_VGDESCTAG DFTAG_VG -#define NEW_VSDESCTAG DFTAG_VH -#define NEW_VSDATATAG DFTAG_VS - -#define VGDESCTAG NEW_VGDESCTAG -#define VSDESCTAG NEW_VSDESCTAG -#define VSDATATAG NEW_VSDATATAG - -#define _HDF_VSPACK 0 -#define _HDF_VSUNPACK 1 -#define VG_ATTR_SET 0x00000001 /* this vgroup has attribute(s) */ -#define VS_ATTR_SET 0x00000001 /* this vdata has attribute(s) */ -#define _HDF_VDATA -1 /* used in vdata attr interface - findex to represent the entire vdata */ -#define _HDF_ENTIRE_VDATA _HDF_VDATA /* if users have already used - _HDF_ENTIRE_VDATA since 4.1b1 was out */ - -/* Size of the atom hash table */ -#define VATOM_HASH_SIZE 256 - -/* .................................................................. */ -#define VSET_NEW_VERSION 4 /* if attr or other new features are set */ -#define VSET_VERSION 3 /* DO NOT CHANGE!! */ -#define VSET_OLD_VERSION 2 /* All version <= 2 use old type mappings */ -#define VSET_OLD_TYPES VSET_OLD_VERSION /* For backward compatibility */ - -/* Only include the library header if the VSET_INTERFACE macro is defined */ -#ifdef VSET_INTERFACE -#include "vgint.h" /* Library VSet information header */ -#endif /* VSET_INTERFACE */ - -#endif /* _VG_H */ diff --git a/Utilities/CAI/cai_dll/inc/inc_unix2win/asm/atomic.h b/Utilities/CAI/cai_dll/inc/inc_unix2win/asm/atomic.h deleted file mode 100755 index f2d2b872f065f8bb4b8f8d8a49fb10af1d7d145e..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_unix2win/asm/atomic.h +++ /dev/null @@ -1,107 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: atomic.h - * - * Purpose: Declaration of Linux like atomic functions for the - * Win32 platform. - * - * Created: 21st November 2003 - * Updated: 19th September 2005 - * - * Home: http://synesis.com.au/software/ - * - * Copyright (c) 2003-2005, Matthew Wilson and Synesis Software - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the names of Matthew Wilson and Synesis Software nor the names of - * any contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef SYNSOFT_UNIXEM_INCL_SYS_H_ATOMIC -#define SYNSOFT_UNIXEM_INCL_SYS_H_ATOMIC - -#ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION -# define SYNSOFT_UNIXEM_VER_SYS_H_ATOMIC_MAJOR 2 -# define SYNSOFT_UNIXEM_VER_SYS_H_ATOMIC_MINOR 1 -# define SYNSOFT_UNIXEM_VER_SYS_H_ATOMIC_REVISION 1 -# define SYNSOFT_UNIXEM_VER_SYS_H_ATOMIC_EDIT 14 -#endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _WIN32 -# error This file is only currently defined for compilation on Win32 systems -#endif /* _WIN32 */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Constants and definitions - */ - - -/* ///////////////////////////////////////////////////////////////////////////// - * Typedefs - */ - -typedef signed long atomic_t; - -/* ///////////////////////////////////////////////////////////////////////////// - * API functions - */ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define ATOMIC_INIT(i) (i) - -void atomic_set(atomic_t volatile *v, int i); -int atomic_write(atomic_t volatile *v, int i); -int atomic_read(atomic_t volatile *v); - -void atomic_add(int i, atomic_t volatile *v); -void atomic_sub(int i, atomic_t volatile *v); - -void atomic_inc(atomic_t volatile *v); -void atomic_dec(atomic_t volatile *v); - -/** Returns the previous value */ -int atomic_inc_and_test(atomic_t volatile *v); -/** Returns the previous value */ -int atomic_dec_and_test(atomic_t volatile *v); - -/** Returns the previous value */ -int atomic_add_and_test(int i, atomic_t volatile *v); -/** Returns the previous value */ -int atomic_sub_and_test(int i, atomic_t volatile *v); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* SYNSOFT_UNIXEM_INCL_SYS_H_ATOMIC */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/Utilities/CAI/cai_dll/inc/inc_unix2win/dirent.h b/Utilities/CAI/cai_dll/inc/inc_unix2win/dirent.h deleted file mode 100755 index fdf73948b4c9340286fa3d60e21ffe990df4dffc..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_unix2win/dirent.h +++ /dev/null @@ -1,186 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: dirent.h - * - * Purpose: Declaration of the opendir() API functions and types for the - * Win32 platform. - * - * Created: 19th October 2002 - * Updated: 21st September 2005 - * - * Home: http://synesis.com.au/software/ - * - * Copyright (c) 2002-2005, Matthew Wilson and Synesis Software - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the names of Matthew Wilson and Synesis Software nor the names of - * any contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -/** \file dirent.h - * - * Contains the declarations for the opendir()/readdir() API. - */ - -#ifndef SYNSOFT_UNIXEM_INCL_H_DIRENT -#define SYNSOFT_UNIXEM_INCL_H_DIRENT - -#ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION -# define SYNSOFT_UNIXEM_VER_H_DIRENT_MAJOR 3 -# define SYNSOFT_UNIXEM_VER_H_DIRENT_MINOR 3 -# define SYNSOFT_UNIXEM_VER_H_DIRENT_REVISION 1 -# define SYNSOFT_UNIXEM_VER_H_DIRENT_EDIT 28 -#endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -/** \weakgroup unixem Synesis Software UNIX Emulation for Win32 - * \brief The UNIX emulation library - */ - -/** \weakgroup unixem_dirent opendir()/readdir() API - * \ingroup UNIXem unixem - * \brief This API provides facilities for enumerating the contents of directories - * @{ - */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _WIN32 -# error This file is only currently defined for compilation on Win32 systems -#endif /* _WIN32 */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#include <stddef.h> - -/* ///////////////////////////////////////////////////////////////////////////// - * Constants and definitions - */ - -#ifndef NAME_MAX -# define NAME_MAX (260) /*!< \brief The maximum number of characters (including null terminator) in a directory entry name */ -#endif /* !NAME_MAX */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Typedefs - */ - -typedef struct dirent_dir DIR; /*!< \brief Handle type for ANSI directory enumeration. \note dirent_dir is defined internally */ -typedef struct wdirent_dir wDIR; /*!< \brief Handle type for Unicode directory enumeration. \note dirent_dir is defined internally */ - -/** \brief Results structure for readdir() - */ -struct dirent -{ - char d_name[NAME_MAX + 1]; /*!< file name (null-terminated) */ - int d_mode; -}; - -/** \brief Results structure for wreaddir() - */ -struct wdirent -{ - wchar_t d_name[NAME_MAX + 1]; /*!< file name (null-terminated) */ - int d_mode; -}; - -/* ///////////////////////////////////////////////////////////////////////////// - * API functions - */ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** \brief Returns a pointer to the next directory entry. - * - * This function opens the directory named by filename, and returns a - * directory to be used to in subsequent operations. NULL is returned - * if name cannot be accessed, or if resources cannot be acquired to - * process the request. - * - * \param name The name of the directory to search - * \return The directory handle from which the entries are read or NULL - */ -DIR *opendir(const char *name); -/** \brief Identical semantics to opendir(), but for Unicode searches. - */ -wDIR *wopendir(const wchar_t *name); - -/** \brief Closes a directory handle - * - * This function closes a directory handle that was opened with opendir() - * and releases any resources associated with that directory handle. - * - * \param dir The directory handle from which the entries are read - * \return 0 on success, or -1 to indicate error. - */ -int closedir(DIR *dir); -/** \brief Identical semantics to closedir(), but for Unicode searches. - */ -int wclosedir(wDIR *dir); - -/** \brief Resets a directory search position - * - * This function resets the position of the named directory handle to - * the beginning of the directory. - * - * \param dir The directory handle whose position should be reset - */ -void rewinddir(DIR *dir); -/** \brief Identical semantics to rewinddir(), but for Unicode searches. - */ -void wrewinddir(wDIR *dir); - -/** \brief Returns a pointer to the next directory entry. - * - * This function returns a pointer to the next directory entry, or NULL upon - * reaching the end of the directory or detecting an invalid seekdir() operation - * - * \param dir The directory handle from which the entries are read - * \return A dirent structure or NULL - */ -struct dirent *readdir(DIR *dir); -/** \brief Identical semantics to readdir(), but for Unicode searches. - */ -struct wdirent *wreaddir(wDIR *dir); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -/** @} // end of group unixem_dirent */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* SYNSOFT_UNIXEM_INCL_H_DIRENT */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/Utilities/CAI/cai_dll/inc/inc_unix2win/dlfcn.h b/Utilities/CAI/cai_dll/inc/inc_unix2win/dlfcn.h deleted file mode 100755 index ecb71485bb77936a0c6616823e11410bfb04388d..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_unix2win/dlfcn.h +++ /dev/null @@ -1,142 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: dlfcn.h - * - * Purpose: Declaration of the dlopen, dlclose(), dlsym() and dlerror() API - * functions. - * - * Created: 1st January 2004 - * Updated: 19th September 2005 - * - * Home: http://synesis.com.au/software/ - * - * Copyright (c) 2004-2005, Matthew Wilson and Synesis Software - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the names of Matthew Wilson and Synesis Software nor the names of - * any contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -/** \file dlfcn.h - * - * Contains the declarations for the dlopen() API. - */ - -#ifndef SYNSOFT_UNIXEM_INCL_H_DLFCN -#define SYNSOFT_UNIXEM_INCL_H_DLFCN - -#ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION -# define SYNSOFT_UNIXEM_VER_H_DLFCN_MAJOR 2 -# define SYNSOFT_UNIXEM_VER_H_DLFCN_MINOR 1 -# define SYNSOFT_UNIXEM_VER_H_DLFCN_REVISION 2 -# define SYNSOFT_UNIXEM_VER_H_DLFCN_EDIT 12 -#endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */ - -#include <sys/types.h> - -/* ////////////////////////////////////////////////////////////////////////// */ - -/** \weakgroup unixem Synesis Software UNIX Emulation for Win32 - * \brief The UNIX emulation library - */ - -/** \weakgroup unixem_dlopen dlopen() API - * \ingroup UNIXem unixem - * \brief This API provides facilities for manipulating dynamically loaded - * executable modules - * @{ - */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _WIN32 -# error This file is only currently defined for compilation on Win32 systems -#endif /* _WIN32 */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Constants and definitions - */ - -#define RTLD_LAZY (0x00001) /*!< Lazy function call binding. */ -#define RTLD_NOW (0x00002) /*!< Immediate function call binding. */ - -/* ///////////////////////////////////////////////////////////////////////////// - * API functions - */ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/** \brief Loads the given module, - * - * \param moduleName The name of the module. The name is passed through to Win32's - * LoadLibrary(), so the value of this parameter is interpreted according to Win32's - * loading rules. - * \param mode The loading mode. This is ignored on Win32 platforms, and the function - * always behaves as if RTLD_NOW was specified - * \note - */ -void *dlopen(char const *moduleName, int mode); - -/** \brief Closes the given module - * - * \param hModule The handle of the executable module to close - * \retval 0 success - * \retval !0 failure. dlerror() will return an error string - */ -int dlclose(void *hModule); - -/** \brief Looks up a symbol - * - * \param hModule The handle of the executable module in which to search for the symbol - * \param symbolName The name of the symbol - * \return The pointer to the symbol, or NULL if no matching symbol was found - * \retval NULL The symbol was not found - */ -void *dlsym(void *hModule, char const *symbolName); - -/** \brief Returns a descriptive string for the last error - * - * \return A pointer to a string describing the last error, or NULL. - * \retval NULL No error occured, or dlerror() already called - * \note Each call to this function resets it, so that a second call will always return NULL - */ -char const *dlerror(void); - -#ifdef __cplusplus -} /* extern "C" */ -#endif /* __cplusplus */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -/** @} // end of group unixem_dlopen */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* SYNSOFT_UNIXEM_INCL_H_DLFCN */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/Utilities/CAI/cai_dll/inc/inc_unix2win/glob.h b/Utilities/CAI/cai_dll/inc/inc_unix2win/glob.h deleted file mode 100755 index 5a698600fb509ffc5260011863a7fd03c5ef24f5..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_unix2win/glob.h +++ /dev/null @@ -1,173 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: glob.h - * - * Purpose: Declaration of the glob() API functions and types for the - * Win32 platform. - * - * Created: 13th November 2002 - * Updated: 19th September 2005 - * - * Home: http://synesis.com.au/software/ - * - * Copyright (c) 2002-2005, Matthew Wilson and Synesis Software - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the names of Matthew Wilson and Synesis Software nor the names of - * any contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -/** \file glob.h - * - * Contains the declarations for the glob() API. - */ - -#ifndef SYNSOFT_UNIXEM_INCL_H_GLOB -#define SYNSOFT_UNIXEM_INCL_H_GLOB - -#ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION -# define SYNSOFT_UNIXEM_VER_H_GLOB_MAJOR 2 -# define SYNSOFT_UNIXEM_VER_H_GLOB_MINOR 2 -# define SYNSOFT_UNIXEM_VER_H_GLOB_REVISION 1 -# define SYNSOFT_UNIXEM_VER_H_GLOB_EDIT 30 -#endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -/** \weakgroup unixem Synesis Software UNIX Emulation for Win32 - * \brief The UNIX emulation library - */ - -/** \weakgroup unixem_glob glob() API - * \ingroup UNIXem unixem - * \brief This API provides facilities for enumerating the file-system contents - * @{ - */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _WIN32 -# error This file is only currently defined for compilation on Win32 systems -#endif /* _WIN32 */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Constants and definitions - */ - -/* Error codes */ -#define GLOB_NOSPACE (1) /*!< \brief (Error result code:) An attempt to allocate memory failed, or if errno was 0 GLOB_LIMIT was specified in the flags and ARG_MAX patterns were matched. */ -#define GLOB_ABORTED (2) /*!< \brief (Error result code:) The scan was stopped because an error was encountered and either GLOB_ERR was set or (*errfunc)() returned non-zero. */ -#define GLOB_NOMATCH (3) /*!< \brief (Error result code:) The pattern does not match any existing pathname, and GLOB_NOCHECK was not set int flags. */ -#define GLOB_NOSYS (4) /*!< \brief (Error result code:) . */ -#define GLOB_ABEND GLOB_ABORTED /*!< \brief (Error result code:) . */ - -/* Flags */ -#define GLOB_ERR 0x00000001 /*!< \brief Return on read errors. */ -#define GLOB_MARK 0x00000002 /*!< \brief Append a slash to each name. */ -#define GLOB_NOSORT 0x00000004 /*!< \brief Don't sort the names. */ -#define GLOB_DOOFFS 0x00000008 /*!< \brief Insert PGLOB->gl_offs NULLs. Supported from version 1.6 of UNIXEm. */ -#define GLOB_NOCHECK 0x00000010 /*!< \brief If nothing matches, return the pattern. Supported from version 1.6 of UNIXEm. */ -#define GLOB_APPEND 0x00000020 /*!< \brief Append to results of a previous call. Not currently supported in this implementation. */ -#define GLOB_NOESCAPE 0x00000040 /*!< \brief Backslashes don't quote metacharacters. Has no effect in this implementation, since escaping is not supported. */ - -#define GLOB_PERIOD 0x00000080 /*!< \brief Leading `.' can be matched by metachars. Supported from version 1.6 of UNIXEm. */ -#define GLOB_MAGCHAR 0x00000100 /*!< \brief Set in gl_flags if any metachars seen. Supported from version 1.6 of UNIXEm. */ -/* #define GLOB_ALTDIRFUNC 0x00000200 */ /*!< \brief Use gl_opendir et al functions. Not currently supported in this implementation. */ -/* #define GLOB_BRACE 0x00000400 */ /*!< \brief Expand "{a,b}" to "a" "b". Not currently supported in this implementation. */ -#define GLOB_NOMAGIC 0x00000800 /*!< \brief If no magic chars, return the pattern. Supported from version 1.6 of UNIXEm. */ -#define GLOB_TILDE 0x00001000 /*!< \brief Expand ~user and ~ to home directories. Partially supported from version 1.6 of UNIXEm: leading ~ is expanded to %HOMEDRIVE%%HOMEPATH%. */ -#define GLOB_ONLYDIR 0x00002000 /*!< \brief Match only directories. This implementation guarantees to only return directories when this flag is specified. */ -#define GLOB_TILDE_CHECK 0x00004000 /*!< \brief Like GLOB_TILDE but return an GLOB_NOMATCH even if GLOB_NOCHECK specified. Supported from version 1.6 of UNIXEm. */ -#define GLOB_ONLYFILE 0x00008000 /*!< \brief Match only files. Supported from version 1.6 of UNIXEm. */ -#define GLOB_NODOTSDIRS 0x00010000 /*!< \brief Elide "." and ".." directories from wildcard searches. Supported from version 1.6 of UNIXEm. */ -#define GLOB_LIMIT 0x00020000 /*!< \brief Limits the search to the number specified by the caller in gl_matchc. Supported from version 1.6 of UNIXEm. */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Typedefs - */ - -/** \brief Result structure for glob() - * - * This structure is used by glob() to return the results of the search. - */ -typedef struct -{ - int gl_pathc; /*!< count of total paths so far */ - int gl_matchc; /*!< count of paths matching pattern */ - int gl_offs; /*!< reserved at beginning of gl_pathv */ - int gl_flags; /*!< returned flags */ - char **gl_pathv; /*!< list of paths matching pattern */ -} glob_t; - -/* ///////////////////////////////////////////////////////////////////////////// - * API functions - */ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** \brief Generates pathnames matching a pattern - * - * This function is a pathname generator that implements the rules for - * file name pattern matching used by the UNIX shell. - * - * \param pattern The pattern controlling the search - * \param flags A combination of the <b>GLOB_*</b> flags - * \param errfunc A function that is called each time part of the search processing fails - * \param pglob Pointer to a glob_t structure to receive the search results - * \return 0 on success, otherwise one of the <b>GLOB_*</b> error codes - */ -int glob( char const *pattern - , int flags -#if defined(__COMO__) - , int (*errfunc)(char const *, int) -#else /* ? compiler */ - , const int (*errfunc)(char const *, int) -#endif /* compiler */ - , glob_t *pglob); - -/** \brief Frees the results of a call to glob - * - * This function releases any memory allocated in a call to glob. It must - * always be called for a successful call to glob. - * - * \param pglob Pointer to a glob_t structure to receive the search results - */ -void globfree(glob_t *pglob); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -/** @} // end of group unixem_glob */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* SYNSOFT_UNIXEM_INCL_H_GLOB */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/Utilities/CAI/cai_dll/inc/inc_unix2win/sys/mman.h b/Utilities/CAI/cai_dll/inc/inc_unix2win/sys/mman.h deleted file mode 100755 index c53003f94ebd689e022b7ca1cf9f52750f435ef4..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_unix2win/sys/mman.h +++ /dev/null @@ -1,160 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: mman.h (sys/mman.h) - * - * Purpose: Declaration of the mmap() and munmap() API functions. - * - * Created: 18th December 2003 - * Updated: 21st September 2005 - * - * Home: http://synesis.com.au/software/ - * - * Copyright (c) 2003-2005, Matthew Wilson and Synesis Software - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the names of Matthew Wilson and Synesis Software nor the names of - * any contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -/** \file sys/mman.h - * - * Contains the declarations for the mmap() API. - */ - -#ifndef SYNSOFT_UNIXEM_INCL_SYS_H_MMAP -#define SYNSOFT_UNIXEM_INCL_SYS_H_MMAP - -#ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION -# define SYNSOFT_UNIXEM_VER_SYS_H_MMAP_MAJOR 2 -# define SYNSOFT_UNIXEM_VER_SYS_H_MMAP_MINOR 1 -# define SYNSOFT_UNIXEM_VER_SYS_H_MMAP_REVISION 2 -# define SYNSOFT_UNIXEM_VER_SYS_H_MMAP_EDIT 17 -#endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */ - -#if defined(__MWERKS__) -# include <sys/stat.h> /* For off_t */ -#endif /* compiler */ -#include <sys/types.h> - -/* ////////////////////////////////////////////////////////////////////////// */ - -/** \weakgroup unixem Synesis Software UNIX Emulation for Win32 - * \brief The UNIX emulation library - */ - -/** \weakgroup unixem_mmap mmap() API - * \ingroup UNIXem unixem - * \brief This API provides facilities for manipulating memory-mapped files - * @{ - */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _WIN32 -# error This file is only currently defined for compilation on Win32 systems -#endif /* _WIN32 */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Constants and definitions - */ - -#define PROT_READ (0x01) /*!< \brief page can be read */ -#define PROT_WRITE (0x02) /*!< \brief page can be written */ -#define PROT_EXEC (0x04) /*!< \brief page can be executed */ -#define PROT_NONE (0x00) /*!< \brief page can not be accessed */ - -#define MAP_PRIVATE (0x02) /*!< \brief Changes are private */ -#define MAP_ANONYMOUS (0x20) /*!< \brief Ignore fd and offset parameters */ -#define MAP_FIXED (0x10) /*!< \brief Interpret addr exactly */ - -#define MAP_FAILED ((void*)-1) /*!< \brief Returned from mmap() when the mapping fails */ - -/* ///////////////////////////////////////////////////////////////////////////// - * API functions - */ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/** \brief Maps a file into memory, and returns a pointer to it - * - * \param addr Suggested address for the mapping - * \param len The number of bytes in the mapped region. The combination of - * len and offset must not exceed the length of the mapped file - * \param prot Either PROT_NONE, or a combination of the other PROT_* flags - * \param flags One of MAP_PRIVATE, MAP_ANONYMOUS or MAP_FIXED. - * \param fd The file descriptor of the file to map, or -1 to allocate an anonymous map - * \param offset The offset within the file to start the mapped region - * - * \retval pointer to mapped region if successful - * \retval MAP_FAILED if failed - * - * \note The current implementation supports the following three modes: - * 1. Read-only file; 2. Read-write file; 3. Anonymous Read-write block of - * system paging file. - */ - -void *mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset); - -/** \brief Deletes a mapped region - * - * The munmap() system call deletes the mappings for the specified address - * range, and causes further references to addresses within the range to - * generate invalid memory references. - * - * \param addr The base address of the mapped region to unmap - * \param len The length of the mapped region. Ignore in the Win32 implementation - * - * \retval 0 if successful - * \retval -1 if failed - */ - -int munmap(void *addr, size_t len); - -/** \brief Writes any dirty pages within the given range to disk - * - * \param addr The base address of the mapped region - * \param len The length of the mapped region to flush to disk. Will be rounded up - * to next page boundary. - * \param flags Ignored - */ - -int msync(void *addr, size_t len, int flags); - -#ifdef __cplusplus -} /* extern "C" */ -#endif /* __cplusplus */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -/** @} // end of group unixem_mmap */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* SYNSOFT_UNIXEM_INCL_SYS_H_MMAP */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/Utilities/CAI/cai_dll/inc/inc_unix2win/sys/time.h b/Utilities/CAI/cai_dll/inc/inc_unix2win/sys/time.h deleted file mode 100755 index effc027ba9c97882e7a30a50ad028960a6d8a521..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_unix2win/sys/time.h +++ /dev/null @@ -1,136 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: time.h (sys/time.h) - * - * Purpose: Declaration of the gettimeofday() API function and supporting - * types for the Win32 platform. - * - * Created: 8th December 2002 - * Updated: 21st September 2005 - * - * Home: http://synesis.com.au/software/ - * - * Copyright (c) 2002-2005, Matthew Wilson and Synesis Software - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the names of Matthew Wilson and Synesis Software nor the names of - * any contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -/** \file sys/time.h - * - * Contains time functions and types. - */ - -#ifndef SYNSOFT_UNIXEM_INCL_SYS_H_TIME -#define SYNSOFT_UNIXEM_INCL_SYS_H_TIME - -#ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION -# define SYNSOFT_UNIXEM_VER_SYS_H_TIME_MAJOR 2 -# define SYNSOFT_UNIXEM_VER_SYS_H_TIME_MINOR 0 -# define SYNSOFT_UNIXEM_VER_SYS_H_TIME_REVISION 2 -# define SYNSOFT_UNIXEM_VER_SYS_H_TIME_EDIT 14 -#endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -/** \weakgroup unixem Synesis Software UNIX Emulation for Win32 - * \brief The UNIX emulation library - */ - -/** \weakgroup unixem_time time() API - * \ingroup UNIXem unixem - * \brief Time functions and types - * @{ - */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/** \brief A representation of current time, used by gettimeofday(). - * - * This structure represents the time, in seconds and microseconds, since Jan. - * 1, 1970, in UTC. Returned by the gettimeofday() function. - */ - -#if !defined(_WINSOCKAPI_) && \ - !defined(_WINSOCK2API_) && \ - !defined(_WINSOCK2_H) && \ - !defined(_TIMEVAL_DEFINED) - -/* - ( !defined(__GNUC__) || \ - !defined(_TIMEVAL_DEFINED)) -*/ - -struct timeval -{ - long tv_sec; /*!< The number of seconds, since Jan. 1, 1970, in the time value. */ - long tv_usec; /*!< The number of microseconds in the time value. */ -}; - -# if !defined(_TIMEVAL_DEFINED) -# define _TIMEVAL_DEFINED -# endif /* __GNUC__ */ - -#endif /* _WINSOCKAPI_ / _TIMEVAL_DEFINED */ - -/** \brief - * - * This structure is NOT used in any meaningful way by the gettimeofday() function - * implementation in this library. - */ -struct timezone -{ - int tz_minuteswest; /*!< minutes west of Greenwich. */ - int tz_dsttime; /*!< type of dst corrections to apply. */ -}; - -/** \brief Accesses the current UTC time - * - * Retrieves the current time and timezone information, relative to Greenwich Mean Time - * - * \param tv Pointer to a timeval structure to receive the time information - * \param tz Pointer to a timezone structure to receive the timezone information - */ -extern void gettimeofday(struct timeval *tv, struct timezone *tz); - -#ifdef __cplusplus -} /* extern "C" */ -#endif /* __cplusplus */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -/** @} // end of group unixem_time */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* SYNSOFT_UNIXEM_INCL_SYS_H_TIME */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/Utilities/CAI/cai_dll/inc/inc_unix2win/sys/uio.h b/Utilities/CAI/cai_dll/inc/inc_unix2win/sys/uio.h deleted file mode 100755 index fbc39ff78b97e58fcfa12c259223b7e7cedae507..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_unix2win/sys/uio.h +++ /dev/null @@ -1,107 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: uio.h (sys/uio.h) - * - * Purpose: Vector file read/write. - * - * Created: 19th September 2005 - * Updated: 21st September 2005 - * - * Home: http://synesis.com.au/software/ - * - * Copyright (c) 2005, Matthew Wilson and Synesis Software - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the names of Matthew Wilson and Synesis Software nor the names of - * any contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -/** \file sys/uio.h - * - * Vector file read/write. - */ - -#ifndef SYNSOFT_UNIXEM_INCL_SYS_H_UIO -#define SYNSOFT_UNIXEM_INCL_SYS_H_UIO - -#ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION -# define SYNSOFT_UNIXEM_VER_SYS_H_UIO_MAJOR 1 -# define SYNSOFT_UNIXEM_VER_SYS_H_UIO_MINOR 0 -# define SYNSOFT_UNIXEM_VER_SYS_H_UIO_REVISION 2 -# define SYNSOFT_UNIXEM_VER_SYS_H_UIO_EDIT 3 -#endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -/** \weakgroup unixem Synesis Software UNIX Emulation for Win32 - * \brief The UNIX emulation library - */ - -/** \weakgroup unixem_uio uio() API - * \ingroup UNIXem unixem - * \brief UIO functions and types - * @{ - */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Typedefs - */ - -/* TODO: Check which compilers (' libraries) define this for Win32. */ -typedef signed long ssize_t; - -struct iovec -{ - void *iov_base; /* Base address */ - size_t iov_len; /* Number of bytes referenced */ -}; - -/* ///////////////////////////////////////////////////////////////////////////// - * Functions - */ - -ssize_t readv(int fd, struct iovec const *vector, int count); -ssize_t writev(int fd, struct iovec const *vector, int count); - -#ifdef __cplusplus -} /* extern "C" */ -#endif /* __cplusplus */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -/** @} // end of group unixem_time */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* SYNSOFT_UNIXEM_INCL_SYS_H_UIO */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/Utilities/CAI/cai_dll/inc/inc_unix2win/unistd.h b/Utilities/CAI/cai_dll/inc/inc_unix2win/unistd.h deleted file mode 100755 index bf431bde8f5e088f28a1bd0ed59af485fac07419..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_unix2win/unistd.h +++ /dev/null @@ -1,247 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: unistd.h - * - * Purpose: Declaration of the . - * - * Created: 1st November 2003 - * Updated: 21st September 2005 - * - * Home: http://synesis.com.au/software/ - * - * Copyright (c) 2003-2005, Matthew Wilson and Synesis Software - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the names of Matthew Wilson and Synesis Software nor the names of - * any contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -/** \file unistd.h - * - * Contains standard limits and declarations. - */ - -#ifndef SYNSOFT_UNIXEM_INCL_H_UNISTD -#define SYNSOFT_UNIXEM_INCL_H_UNISTD - -#ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION -# define SYNSOFT_UNIXEM_VER_H_UNISTD_MAJOR 2 -# define SYNSOFT_UNIXEM_VER_H_UNISTD_MINOR 3 -# define SYNSOFT_UNIXEM_VER_H_UNISTD_REVISION 4 -# define SYNSOFT_UNIXEM_VER_H_UNISTD_EDIT 26 -#endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#include <stddef.h> /* for size_t */ -#include <sys/types.h> /* for mode_t */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -/** \weakgroup unixem Synesis Software UNIX Emulation for Win32 - * \brief The UNIX emulation library - */ - -/** \weakgroup unixem_unistd unistd.h - * \ingroup UNIXem unixem - * \brief Standard limits and declarations - * @{ - */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _WIN32 -# error This file is only currently defined for compilation on Win32 systems -#endif /* _WIN32 */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Constants and definitions - */ - -//#ifndef PATH_MAX -//# define PATH_MAX (260) /*!< \brief The maximum number of characters (including null terminator) in a directory entry name */ -//#endif /* !PATH_MAX */ - -enum -{ - _PC_LINK_MAX /*!< The maximum number of links to the file. */ -#define _PC_LINK_MAX _PC_LINK_MAX - , _PC_MAX_CANON /*!< Maximum number of bytes in canonical input line. Applicable only to terminal devices. */ -#define _PC_MAX_CANON _PC_MAX_CANON - , _PC_MAX_INPUT /*!< Maximum number of bytes allowed in an input queue. Applicable only to terminal devices. */ -#define _PC_MAX_INPUT _PC_MAX_INPUT - , _PC_NAME_MAX /*!< Maximum number of bytes in a file name, not including a nul terminator. This number can range from 14 through 255. This value is applicable only to a directory file. */ -#define _PC_NAME_MAX _PC_NAME_MAX - , _PC_PATH_MAX /*!< Maximum number of bytes in a path name, including a nul terminator. */ -#define _PC_PATH_MAX _PC_PATH_MAX - - , _PC_PIPE_BUF /*!< Maximum number of bytes guaranteed to be written atomically. This value is applicable only to a first-in-first-out (FIFO). */ -#define _PC_PIPE_BUF _PC_PIPE_BUF - , _PC_CHOWN_RESTRICTED /*!< Returns 0 if the use of the chown subroutine is restricted to a process with appropriate privileges, and if the chown subroutine is restricted to changing the group ID of a file only to the effective group ID of the process or to one of its supplementary group IDs. */ -#define _PC_CHOWN_RESTRICTED _PC_CHOWN_RESTRICTED - , _PC_NO_TRUNC /*!< Returns 0 if long component names are truncated. This value is applicable only to a directory file. */ -#define _PC_NO_TRUNC _PC_NO_TRUNC - , _PC_VDISABLE /*!< This is always 0. No disabling character is defined. This value is applicable only to a terminal device. */ -#define _PC_VDISABLE _PC_VDISABLE - , _PC_AIX_DISK_PARTITION /*!< Determines the physical partition size of the disk. -Note: -The _PC_AIX_DISK_PARTITION variable is available only to the root user. */ -#define _PC_AIX_DISK_PARTITION _PC_AIX_DISK_PARTITION - , _PC_AIX_DISK_SIZE /*!< Determines the disk size in megabytes. -Note: -The _PC_AIX_DISK_SIZE variable is available only to the root user. -Note: -The _PC_FILESIZEBITS and PC_SYNC_IO flags apply to AIX 4.3 and later releases. */ -#define _PC_AIX_DISK_SIZE _PC_AIX_DISK_SIZE - , _PC_FILESIZEBITS /*!< Returns the minimum number of bits required to hold the file system's maximum file size as a signed integer. The smallest value returned is 32. */ -#define _PC_FILESIZEBITS _PC_FILESIZEBITS - , _PC_SYNC_IO /*!< Returns -1 if the file system does not support the Synchronized Input and Output option. Any value other than -1 is returned if the file system supports the option. */ -#define _PC_SYNC_IO _PC_SYNC_IO -}; - -/* ///////////////////////////////////////////////////////////////////////////// - * API functions - */ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** \brief Creates a hardlink. - * - * This function creates a link from \c originalFile to \c linkName. - * - * \param originalFile Path of the original file - * \param linkName Path of the link - * - * \return O on success, or -1 if there is an error - * - * \note Hardlink support is only available on Windows 2000 and later, and only - * works within a single drive. - */ -int link(const char *originalFile, const char *linkName); - - -/** \brief Unlinks a file or directory - * - * \param path The path of the file or directory to unlink - * - * \return O on success, or -1 if there is an error - */ -int unlink(const char *path); - -/** \brief Change the current working directory. - * - * This function changes the current working directory to the directory - * specified by dirName. dirName must refer to an existing directory. - * - * \param dirName Path of new working directory - * \return O on success, or -1 if there is an error - */ -int chdir(const char *dirName); - -/** \brief Get the current working directory - * - * This function gets the full path of the current working directory - * and stores it in buffer. - * - * \param buffer Storage location for the current working directory - * \param max_len Maximum length of path (in characters) - * \return buffer on success, or NULL to indicate error. - */ -char *getcwd(char *buffer, size_t max_len); - -#if !defined(__MWERKS__) - -/** \brief Creates the given directory - * - * This function creates the named directory. - * - * \param dirName Path of directory to remove - * \param mode The access permissions of the directory - * - * \return O on success, or -1 if there is an error - */ -int mkdir(const char *dirName, unsigned mode); - -#endif /* !__MWERKS__ */ - -/** \brief Removes the given directory - * - * This function removes the named directory. - * - * \param dirName Path of directory to remove - * \return O on success, or -1 if there is an error - */ -int rmdir(const char *dirName); - -/** \brief Closes a file - * - * \param handle The handle of the file to be closed - * \return 0 on success, or -1 if there is an error - */ -int close(int handle); - -/** \brief Creates a pipe - * - * \param handles An array of two handles. handles[0] will be set to the - * read stream. handels[1] will be set to the write stream - * \return 0 on success, or -1 if there is an error - */ -/* int pipe(int handles[2]); */ - -/** \brief Returns the size, in bytes, of the page size - */ -int getpagesize(void); - -/** \brief Provides access to various system limits not available at compile time - */ -long pathconf(char const *path, int name); - - -/** \brief Turns \c path into a fully qualified path, resolving all symbolic - * links, multiple /, /./ and /../ - * - * \param path The relative path to be converted into absolute form - * \param resolvedPath Pointer to a buffer to receive the path. This must contain - * sufficient storage for a valid path - */ -char *realpath(char const *path, char resolvedPath[]); - -#ifdef __cplusplus -} /* extern "C" */ -#endif /* __cplusplus */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -/** @} // end of group unixem_unistd */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* SYNSOFT_UNIXEM_INCL_H_UNISTD */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/Utilities/CAI/cai_dll/inc/inc_unix2win/unixem/implicit_link.h b/Utilities/CAI/cai_dll/inc/inc_unix2win/unixem/implicit_link.h deleted file mode 100755 index 3b9e65a439bb53d766d2b469884838ffbe29f1e4..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_unix2win/unixem/implicit_link.h +++ /dev/null @@ -1,185 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: unixem/implicit_link.h - * - * Purpose: Implicit linking for the UNIXEm API. - * - * Created: 29th August 2005 - * Updated: 29th August 2005 - * - * Home: http://synesis.com.au/software/ - * - * Copyright 1994-2005, Matthew Wilson and Synesis Software - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the names of Matthew Wilson and Synesis Software nor the names of - * any contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -/** \file unixem/implicit_link.h Implicit linking for the UNIXEm API - */ - -#ifndef UNIXEM_INCL_UNIXEM_H_IMPLICIT_LINK -#define UNIXEM_INCL_UNIXEM_H_IMPLICIT_LINK - -/* ///////////////////////////////////////////////////////////////////////////// - * Version - */ - -#ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION -# define UNIXEM_VER_UNIXEM_H_IMPLICIT_LINK_MAJOR 1 -# define UNIXEM_VER_UNIXEM_H_IMPLICIT_LINK_MINOR 0 -# define UNIXEM_VER_UNIXEM_H_IMPLICIT_LINK_REVISION 1 -# define UNIXEM_VER_UNIXEM_H_IMPLICIT_LINK_EDIT 1 -#endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#include <unixem/unixem.h> - -/* ///////////////////////////////////////////////////////////////////////////// - * Implicit linking - */ - -#if defined(WIN32) || \ - defined(_WIN32) - -# if defined(__BORLANDC__) || \ - /* defined(__DMC__) || */ \ - defined(__INTEL_COMPILER) || \ - defined(__MWERKS__) || \ - defined(_MSC_VER) -# define UNIXEM_IMPLICIT_LINK_SUPPORT -# endif /* compiler */ - - -# if defined(UNIXEM_IMPLICIT_LINK_SUPPORT) - -# if defined(__BORLANDC__) -# if __BORLANDC__ == 0x0550 -# define UNIXEM_IMPL_LINK_COMPILER_NAME "bc55" -# elif (__BORLANDC__ == 0x0551) -# define UNIXEM_IMPL_LINK_COMPILER_NAME "bc551" -# elif (__BORLANDC__ == 0x0560) -# define UNIXEM_IMPL_LINK_COMPILER_NAME "bc56" -# elif (__BORLANDC__ == 0x0564) -# define UNIXEM_IMPL_LINK_COMPILER_NAME "bc564" -# else /* ? __BORLANDC__ */ -# error Unrecognised value of __BORLANDC__ -# endif /* __BORLANDC__ */ - -/* -# elif defined(__DMC__) -# define UNIXEM_IMPL_LINK_COMPILER_NAME "dm" - */ - -# elif defined(__INTEL_COMPILER) -# if (__INTEL_COMPILER == 600) -# define UNIXEM_IMPL_LINK_COMPILER_NAME "icl6" -# elif (__INTEL_COMPILER == 700) -# define UNIXEM_IMPL_LINK_COMPILER_NAME "icl7" -# elif (__INTEL_COMPILER == 800) -# define UNIXEM_IMPL_LINK_COMPILER_NAME "icl8" -# else /* ? __INTEL_COMPILER */ -# error Unrecognised value of __INTEL_COMPILER -# endif /* __INTEL_COMPILER */ - -# elif defined(__MWERKS__) -# if ((__MWERKS__ & 0xFF00) == 0x2400) -# define UNIXEM_IMPL_LINK_COMPILER_NAME "cw7" -# elif ((__MWERKS__ & 0xFF00) == 0x3000) -# define UNIXEM_IMPL_LINK_COMPILER_NAME "cw8" -# elif ((__MWERKS__ & 0xFF00) == 0x3200) -# define UNIXEM_IMPL_LINK_COMPILER_NAME "cw9" -# else /* ? __MWERKS__ */ -# error Unrecognised value of __MWERKS__ -# endif /* __MWERKS__ */ - -# elif defined(_MSC_VER) -# if _MSC_VER == 1000 -# define UNIXEM_IMPL_LINK_COMPILER_NAME "vc4" -# elif _MSC_VER == 1020 -# define UNIXEM_IMPL_LINK_COMPILER_NAME "vc42" -# elif _MSC_VER == 1100 -# define UNIXEM_IMPL_LINK_COMPILER_NAME "vc5" -# elif _MSC_VER == 1200 -# define UNIXEM_IMPL_LINK_COMPILER_NAME "vc6" -# elif _MSC_VER == 1300 -# define UNIXEM_IMPL_LINK_COMPILER_NAME "vc7" -# elif _MSC_VER == 1310 -# define UNIXEM_IMPL_LINK_COMPILER_NAME "vc71" -# elif _MSC_VER == 1400 -# define UNIXEM_IMPL_LINK_COMPILER_NAME "vc8" -# else /* ? _MSC_VER */ -# error Unrecognised value of _MSC_VER -# endif /* _MSC_VER */ - -# else /* ? compiler */ -# error Unrecognised compiler -# endif /* compiler */ - - -# if defined(__MT__) || \ - defined(_REENTRANT) || \ - defined(_MT) -# if defined(_DLL) || \ - defined(__DLL) -# define UNIXEM_IMPL_LINK_THREADING_TYPE ".dll" -# else /* ? dll */ -# define UNIXEM_IMPL_LINK_THREADING_TYPE ".mt" -# endif /* dll */ -# else /* ? mt */ -# define UNIXEM_IMPL_LINK_THREADING_TYPE "" -# endif /* mt */ - - -# if !defined(NDEBUG) && \ - defined(_DEBUG) -# define UNIXEM_IMPL_LINK_DEBUG_TYPE ".debug" -# else /* ? debug */ -# define UNIXEM_IMPL_LINK_DEBUG_TYPE "" -# endif /* debug */ - -# define UNIXEM_IMPL_LINK_LIBRARY_BASENAME_s_(x) #x -# define UNIXEM_IMPL_LINK_LIBRARY_BASENAME_s(x) UNIXEM_IMPL_LINK_LIBRARY_BASENAME_s_(x) -# define UNIXEM_IMPL_LINK_LIBRARY_BASENAME "unixem." UNIXEM_IMPL_LINK_LIBRARY_BASENAME_s(UNIXEM_VER_MAJOR) "." - -# define UNIXEM_IMPL_LINK_LIBRARY_NAME UNIXEM_IMPL_LINK_LIBRARY_BASENAME UNIXEM_IMPL_LINK_COMPILER_NAME UNIXEM_IMPL_LINK_THREADING_TYPE UNIXEM_IMPL_LINK_DEBUG_TYPE ".lib" - -# pragma message("lib: " UNIXEM_IMPL_LINK_LIBRARY_NAME) - -# pragma comment(lib, UNIXEM_IMPL_LINK_LIBRARY_NAME) - -# endif /* UNIXEM_IMPLICIT_LINK_SUPPORT */ - -#endif /* Win32 */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* UNIXEM_INCL_UNIXEM_H_IMPLICIT_LINK */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/Utilities/CAI/cai_dll/inc/inc_unix2win/unixem/internal/util.h b/Utilities/CAI/cai_dll/inc/inc_unix2win/unixem/internal/util.h deleted file mode 100755 index 4e2369ede1be47bd1ee15a5c8c5eed3dcf285d68..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_unix2win/unixem/internal/util.h +++ /dev/null @@ -1,97 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: unixem/internal/util.h - * - * Purpose: Internal utility header for the UNIXEm API. - * - * Created: 2nd September 2005 - * Updated: 2nd September 2005 - * - * Home: http://synesis.com.au/software/ - * - * Copyright 1994-2005, Matthew Wilson and Synesis Software - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the names of Matthew Wilson and Synesis Software nor the names of - * any contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -/** \file unixem/internal/util Internal utility header for the UNIXEm API - */ - -#ifndef UNIXEM_INCL_UNIXEM_INTERNAL_H_UTIL -#define UNIXEM_INCL_UNIXEM_INTERNAL_H_UTIL - -/* ///////////////////////////////////////////////////////////////////////////// - * Version - */ - -#ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION -# define UNIXEM_VER_UNIXEM_INTERNAL_H_UTIL_MAJOR 1 -# define UNIXEM_VER_UNIXEM_INTERNAL_H_UTIL_MINOR 0 -# define UNIXEM_VER_UNIXEM_INTERNAL_H_UTIL_REVISION 1 -# define UNIXEM_VER_UNIXEM_INTERNAL_H_UTIL_EDIT 1 -#endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#include <unixem/unixem.h> - -/* ///////////////////////////////////////////////////////////////////////////// - * Macros - */ - -#ifndef NUM_ELEMENTS -# define NUM_ELEMENTS(x) (sizeof(x) / sizeof(0[x])) -#endif /* !NUM_ELEMENTS */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Function declarations - */ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -int errno_from_Win32(unsigned long); - -/** Gets the drive letter of the current working directory - * - * \retval Either an uppercase letter, or '\0' on failure; - */ -char get_current_drive(void); - -#ifdef __cplusplus -} /* extern "C" */ -#endif /* __cplusplus */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* UNIXEM_INCL_UNIXEM_INTERNAL_H_UTIL */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/Utilities/CAI/cai_dll/inc/inc_unix2win/unixem/unixem.h b/Utilities/CAI/cai_dll/inc/inc_unix2win/unixem/unixem.h deleted file mode 100755 index 24442d87db48c5ad48c774773df31be185cae04b..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/inc_unix2win/unixem/unixem.h +++ /dev/null @@ -1,98 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: unixem/unixem.h - * - * Purpose: Root header for the UNIXEm API. - * - * Created: 29th August 2005 - * Updated: 2nd September 2005 - * - * Home: http://synesis.com.au/software/ - * - * Copyright 1994-2005, Matthew Wilson and Synesis Software - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the names of Matthew Wilson and Synesis Software nor the names of - * any contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -/** \file unixem/unixem.h Root header for the UNIXEm API - */ - -#ifndef UNIXEM_INCL_UNIXEM_H_UNIXEM -#define UNIXEM_INCL_UNIXEM_H_UNIXEM - -/* ///////////////////////////////////////////////////////////////////////////// - * Version - */ - -#ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION -# define UNIXEM_VER_UNIXEM_H_UNIXEM_MAJOR 1 -# define UNIXEM_VER_UNIXEM_H_UNIXEM_MINOR 0 -# define UNIXEM_VER_UNIXEM_H_UNIXEM_REVISION 1 -# define UNIXEM_VER_UNIXEM_H_UNIXEM_EDIT 1 -#endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */ - -/** \def UNIXEM_VER_MAJOR - * The major version number of UNIXEm - */ - -/** \def UNIXEM_VER_MINOR - * The minor version number of UNIXEm - */ - -/** \def UNIXEM_VER_REVISION - * The revision version number of UNIXEm - */ - -/** \def UNIXEM_VER - * The current composite version number of UNIXEm - */ - -#define UNIXEM_VER_MAJOR 1 -#define UNIXEM_VER_MINOR 6 -#define UNIXEM_VER_REVISION 1 - -#ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION -# define UNIXEM_VER_1_0_1 0x01000100 -# define UNIXEM_VER_1_1_1 0x01010100 -# define UNIXEM_VER_1_2_1 0x01020100 -# define UNIXEM_VER_1_3_1 0x01030100 -# define UNIXEM_VER_1_4_1 0x01040100 -# define UNIXEM_VER_1_5_1 0x01050100 -# define UNIXEM_VER_1_5_2 0x01050200 -# define UNIXEM_VER_1_5_3 0x01050300 -# define UNIXEM_VER_1_6_1 0x01060100 - -# define UNIXEM_VER UNIXEM_VER_1_6_1 -#else /* ? UNIXEM_DOCUMENTATION_SKIP_SECTION */ -# define UNIXEM_VER 0x01060100 -#endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* UNIXEM_INCL_UNIXEM_H_UNIXEM */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/Utilities/CAI/cai_dll/inc/jchuff.h b/Utilities/CAI/cai_dll/inc/jchuff.h deleted file mode 100755 index fa4643a4e79b509a042cd33d8f8322817ef104e5..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/jchuff.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * jchuff.h - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains declarations for Huffman entropy encoding routines - * that are shared between the sequential encoder (jchuff.c) and the - * progressive encoder (jcphuff.c). No other modules need to see these. - */ - -/* Derived data constructed for each Huffman table */ - -typedef struct { - unsigned int ehufco[256]; /* code for each symbol */ - char ehufsi[256]; /* length of code for each symbol */ - /* If no code has been allocated for a symbol S, ehufsi[S] contains 0 */ -} c_derived_tbl; - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_make_c_derived_tbl jMkCDerived -#define jpeg_gen_optimal_table jGenOptTbl -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - -/* Expand a Huffman table definition into the derived format */ -EXTERN(void) jpeg_make_c_derived_tbl - JPP((j_compress_ptr cinfo, JHUFF_TBL * htbl, c_derived_tbl ** pdtbl)); - -/* Generate an optimal table definition given the specified counts */ -EXTERN(void) jpeg_gen_optimal_table - JPP((j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])); diff --git a/Utilities/CAI/cai_dll/inc/jconfig.h b/Utilities/CAI/cai_dll/inc/jconfig.h deleted file mode 100755 index 1673c5d99cf85f1471c9edb7c8dd8399935ea313..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/jconfig.h +++ /dev/null @@ -1,50 +0,0 @@ -/* jconfig.vc --- jconfig.h for Microsoft Visual C++ on Windows 95 or NT. */ -/* see jconfig.doc for explanations */ - -#ifndef _JCONFIG_H_ -#define _JCONFIG_H_ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS /* we presume a 32-bit flat memory model */ -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN - -/* Define "boolean" as unsigned char, not int, per Windows custom */ -#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ -typedef unsigned char boolean; -#endif -#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ - - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#define TWO_FILE_COMMANDLINE /* optional */ -#define USE_SETMODE /* Microsoft has setmode() */ -#undef NEED_SIGNAL_CATCHER -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ - -#endif diff --git a/Utilities/CAI/cai_dll/inc/jdct.h b/Utilities/CAI/cai_dll/inc/jdct.h deleted file mode 100755 index 04192a266ae148072feecb5feff6bca796c2b71a..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/jdct.h +++ /dev/null @@ -1,176 +0,0 @@ -/* - * jdct.h - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This include file contains common declarations for the forward and - * inverse DCT modules. These declarations are private to the DCT managers - * (jcdctmgr.c, jddctmgr.c) and the individual DCT algorithms. - * The individual DCT algorithms are kept in separate files to ease - * machine-dependent tuning (e.g., assembly coding). - */ - - -/* - * A forward DCT routine is given a pointer to a work area of type DCTELEM[]; - * the DCT is to be performed in-place in that buffer. Type DCTELEM is int - * for 8-bit samples, INT32 for 12-bit samples. (NOTE: Floating-point DCT - * implementations use an array of type FAST_FLOAT, instead.) - * The DCT inputs are expected to be signed (range +-CENTERJSAMPLE). - * The DCT outputs are returned scaled up by a factor of 8; they therefore - * have a range of +-8K for 8-bit data, +-128K for 12-bit data. This - * convention improves accuracy in integer implementations and saves some - * work in floating-point ones. - * Quantization of the output coefficients is done by jcdctmgr.c. - */ - -#if BITS_IN_JSAMPLE == 8 -typedef int DCTELEM; /* 16 or 32 bits is fine */ -#else -typedef INT32 DCTELEM; /* must have 32 bits */ -#endif - -typedef JMETHOD(void, forward_DCT_method_ptr, (DCTELEM * data)); -typedef JMETHOD(void, float_DCT_method_ptr, (FAST_FLOAT * data)); - - -/* - * An inverse DCT routine is given a pointer to the input JBLOCK and a pointer - * to an output sample array. The routine must dequantize the input data as - * well as perform the IDCT; for dequantization, it uses the multiplier table - * pointed to by compptr->dct_table. The output data is to be placed into the - * sample array starting at a specified column. (Any row offset needed will - * be applied to the array pointer before it is passed to the IDCT code.) - * Note that the number of samples emitted by the IDCT routine is - * DCT_scaled_size * DCT_scaled_size. - */ - -/* typedef inverse_DCT_method_ptr is declared in jpegint.h */ - -/* - * Each IDCT routine has its own ideas about the best dct_table element type. - */ - -typedef MULTIPLIER ISLOW_MULT_TYPE; /* short or int, whichever is faster */ -#if BITS_IN_JSAMPLE == 8 -typedef MULTIPLIER IFAST_MULT_TYPE; /* 16 bits is OK, use short if faster */ -#define IFAST_SCALE_BITS 2 /* fractional bits in scale factors */ -#else -typedef INT32 IFAST_MULT_TYPE; /* need 32 bits for scaled quantizers */ -#define IFAST_SCALE_BITS 13 /* fractional bits in scale factors */ -#endif -typedef FAST_FLOAT FLOAT_MULT_TYPE; /* preferred floating type */ - - -/* - * Each IDCT routine is responsible for range-limiting its results and - * converting them to unsigned form (0..MAXJSAMPLE). The raw outputs could - * be quite far out of range if the input data is corrupt, so a bulletproof - * range-limiting step is required. We use a mask-and-table-lookup method - * to do the combined operations quickly. See the comments with - * prepare_range_limit_table (in jdmaster.c) for more info. - */ - -#define IDCT_range_limit(cinfo) ((cinfo)->sample_range_limit + CENTERJSAMPLE) - -#define RANGE_MASK (MAXJSAMPLE * 4 + 3) /* 2 bits wider than legal samples */ - - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_fdct_islow jFDislow -#define jpeg_fdct_ifast jFDifast -#define jpeg_fdct_float jFDfloat -#define jpeg_idct_islow jRDislow -#define jpeg_idct_ifast jRDifast -#define jpeg_idct_float jRDfloat -#define jpeg_idct_4x4 jRD4x4 -#define jpeg_idct_2x2 jRD2x2 -#define jpeg_idct_1x1 jRD1x1 -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - -/* Extern declarations for the forward and inverse DCT routines. */ - -EXTERN(void) jpeg_fdct_islow JPP((DCTELEM * data)); -EXTERN(void) jpeg_fdct_ifast JPP((DCTELEM * data)); -EXTERN(void) jpeg_fdct_float JPP((FAST_FLOAT * data)); - -EXTERN(void) jpeg_idct_islow - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); -EXTERN(void) jpeg_idct_ifast - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); -EXTERN(void) jpeg_idct_float - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); -EXTERN(void) jpeg_idct_4x4 - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); -EXTERN(void) jpeg_idct_2x2 - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); -EXTERN(void) jpeg_idct_1x1 - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); - - -/* - * Macros for handling fixed-point arithmetic; these are used by many - * but not all of the DCT/IDCT modules. - * - * All values are expected to be of type INT32. - * Fractional constants are scaled left by CONST_BITS bits. - * CONST_BITS is defined within each module using these macros, - * and may differ from one module to the next. - */ - -#define ONE ((INT32) 1) -#define CONST_SCALE (ONE << CONST_BITS) - -/* Convert a positive real constant to an integer scaled by CONST_SCALE. - * Caution: some C compilers fail to reduce "FIX(constant)" at compile time, - * thus causing a lot of useless floating-point operations at run time. - */ - -#define FIX(x) ((INT32) ((x) * CONST_SCALE + 0.5)) - -/* Descale and correctly round an INT32 value that's scaled by N bits. - * We assume RIGHT_SHIFT rounds towards minus infinity, so adding - * the fudge factor is correct for either sign of X. - */ - -#define DESCALE(x,n) RIGHT_SHIFT((x) + (ONE << ((n)-1)), n) - -/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. - * This macro is used only when the two inputs will actually be no more than - * 16 bits wide, so that a 16x16->32 bit multiply can be used instead of a - * full 32x32 multiply. This provides a useful speedup on many machines. - * Unfortunately there is no way to specify a 16x16->32 multiply portably - * in C, but some C compilers will do the right thing if you provide the - * correct combination of casts. - */ - -#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */ -#define MULTIPLY16C16(var,const) (((INT16) (var)) * ((INT16) (const))) -#endif -#ifdef SHORTxLCONST_32 /* known to work with Microsoft C 6.0 */ -#define MULTIPLY16C16(var,const) (((INT16) (var)) * ((INT32) (const))) -#endif - -#ifndef MULTIPLY16C16 /* default definition */ -#define MULTIPLY16C16(var,const) ((var) * (const)) -#endif - -/* Same except both inputs are variables. */ - -#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */ -#define MULTIPLY16V16(var1,var2) (((INT16) (var1)) * ((INT16) (var2))) -#endif - -#ifndef MULTIPLY16V16 /* default definition */ -#define MULTIPLY16V16(var1,var2) ((var1) * (var2)) -#endif diff --git a/Utilities/CAI/cai_dll/inc/jdhuff.h b/Utilities/CAI/cai_dll/inc/jdhuff.h deleted file mode 100755 index bcc3ab1271e5157b000b7e099feec60f570ac80a..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/jdhuff.h +++ /dev/null @@ -1,202 +0,0 @@ -/* - * jdhuff.h - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains declarations for Huffman entropy decoding routines - * that are shared between the sequential decoder (jdhuff.c) and the - * progressive decoder (jdphuff.c). No other modules need to see these. - */ - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_make_d_derived_tbl jMkDDerived -#define jpeg_fill_bit_buffer jFilBitBuf -#define jpeg_huff_decode jHufDecode -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - - -/* Derived data constructed for each Huffman table */ - -#define HUFF_LOOKAHEAD 8 /* # of bits of lookahead */ - -typedef struct { - /* Basic tables: (element [0] of each array is unused) */ - INT32 mincode[17]; /* smallest code of length k */ - INT32 maxcode[18]; /* largest code of length k (-1 if none) */ - /* (maxcode[17] is a sentinel to ensure jpeg_huff_decode terminates) */ - int valptr[17]; /* huffval[] index of 1st symbol of length k */ - - /* Link to public Huffman table (needed only in jpeg_huff_decode) */ - JHUFF_TBL *pub; - - /* Lookahead tables: indexed by the next HUFF_LOOKAHEAD bits of - * the input data stream. If the next Huffman code is no more - * than HUFF_LOOKAHEAD bits long, we can obtain its length and - * the corresponding symbol directly from these tables. - */ - int look_nbits[1<<HUFF_LOOKAHEAD]; /* # bits, or 0 if too long */ - UINT8 look_sym[1<<HUFF_LOOKAHEAD]; /* symbol, or unused */ -} d_derived_tbl; - -/* Expand a Huffman table definition into the derived format */ -EXTERN(void) jpeg_make_d_derived_tbl JPP((j_decompress_ptr cinfo, - JHUFF_TBL * htbl, d_derived_tbl ** pdtbl)); - - -/* - * Fetching the next N bits from the input stream is a time-critical operation - * for the Huffman decoders. We implement it with a combination of inline - * macros and out-of-line subroutines. Note that N (the number of bits - * demanded at one time) never exceeds 15 for JPEG use. - * - * We read source bytes into get_buffer and dole out bits as needed. - * If get_buffer already contains enough bits, they are fetched in-line - * by the macros CHECK_BIT_BUFFER and GET_BITS. When there aren't enough - * bits, jpeg_fill_bit_buffer is called; it will attempt to fill get_buffer - * as full as possible (not just to the number of bits needed; this - * prefetching reduces the overhead cost of calling jpeg_fill_bit_buffer). - * Note that jpeg_fill_bit_buffer may return FALSE to indicate suspension. - * On TRUE return, jpeg_fill_bit_buffer guarantees that get_buffer contains - * at least the requested number of bits --- dummy zeroes are inserted if - * necessary. - */ - -typedef INT32 bit_buf_type; /* type of bit-extraction buffer */ -#define BIT_BUF_SIZE 32 /* size of buffer in bits */ - -/* If long is > 32 bits on your machine, and shifting/masking longs is - * reasonably fast, making bit_buf_type be long and setting BIT_BUF_SIZE - * appropriately should be a win. Unfortunately we can't do this with - * something like #define BIT_BUF_SIZE (sizeof(bit_buf_type)*8) - * because not all machines measure sizeof in 8-bit bytes. - */ - -typedef struct { /* Bitreading state saved across MCUs */ - bit_buf_type get_buffer; /* current bit-extraction buffer */ - int bits_left; /* # of unused bits in it */ - boolean printed_eod; /* flag to suppress multiple warning msgs */ -} bitread_perm_state; - -typedef struct { /* Bitreading working state within an MCU */ - /* current data source state */ - const JOCTET * next_input_byte; /* => next byte to read from source */ - size_t bytes_in_buffer; /* # of bytes remaining in source buffer */ - int unread_marker; /* nonzero if we have hit a marker */ - /* bit input buffer --- note these values are kept in register variables, - * not in this struct, inside the inner loops. - */ - bit_buf_type get_buffer; /* current bit-extraction buffer */ - int bits_left; /* # of unused bits in it */ - /* pointers needed by jpeg_fill_bit_buffer */ - j_decompress_ptr cinfo; /* back link to decompress master record */ - boolean * printed_eod_ptr; /* => flag in permanent state */ -} bitread_working_state; - -/* Macros to declare and load/save bitread local variables. */ -#define BITREAD_STATE_VARS \ - register bit_buf_type get_buffer; \ - register int bits_left; \ - bitread_working_state br_state - -#define BITREAD_LOAD_STATE(cinfop,permstate) \ - br_state.cinfo = cinfop; \ - br_state.next_input_byte = cinfop->src->next_input_byte; \ - br_state.bytes_in_buffer = cinfop->src->bytes_in_buffer; \ - br_state.unread_marker = cinfop->unread_marker; \ - get_buffer = permstate.get_buffer; \ - bits_left = permstate.bits_left; \ - br_state.printed_eod_ptr = & permstate.printed_eod - -#define BITREAD_SAVE_STATE(cinfop,permstate) \ - cinfop->src->next_input_byte = br_state.next_input_byte; \ - cinfop->src->bytes_in_buffer = br_state.bytes_in_buffer; \ - cinfop->unread_marker = br_state.unread_marker; \ - permstate.get_buffer = get_buffer; \ - permstate.bits_left = bits_left - -/* - * These macros provide the in-line portion of bit fetching. - * Use CHECK_BIT_BUFFER to ensure there are N bits in get_buffer - * before using GET_BITS, PEEK_BITS, or DROP_BITS. - * The variables get_buffer and bits_left are assumed to be locals, - * but the state struct might not be (jpeg_huff_decode needs this). - * CHECK_BIT_BUFFER(state,n,action); - * Ensure there are N bits in get_buffer; if suspend, take action. - * val = GET_BITS(n); - * Fetch next N bits. - * val = PEEK_BITS(n); - * Fetch next N bits without removing them from the buffer. - * DROP_BITS(n); - * Discard next N bits. - * The value N should be a simple variable, not an expression, because it - * is evaluated multiple times. - */ - -#define CHECK_BIT_BUFFER(state,nbits,action) \ - { if (bits_left < (nbits)) { \ - if (! jpeg_fill_bit_buffer(&(state),get_buffer,bits_left,nbits)) \ - { action; } \ - get_buffer = (state).get_buffer; bits_left = (state).bits_left; } } - -#define GET_BITS(nbits) \ - (((int) (get_buffer >> (bits_left -= (nbits)))) & ((1<<(nbits))-1)) - -#define PEEK_BITS(nbits) \ - (((int) (get_buffer >> (bits_left - (nbits)))) & ((1<<(nbits))-1)) - -#define DROP_BITS(nbits) \ - (bits_left -= (nbits)) - -/* Load up the bit buffer to a depth of at least nbits */ -EXTERN(boolean) jpeg_fill_bit_buffer - JPP((bitread_working_state * state, register bit_buf_type get_buffer, - register int bits_left, int nbits)); - - -/* - * Code for extracting next Huffman-coded symbol from input bit stream. - * Again, this is time-critical and we make the main paths be macros. - * - * We use a lookahead table to process codes of up to HUFF_LOOKAHEAD bits - * without looping. Usually, more than 95% of the Huffman codes will be 8 - * or fewer bits long. The few overlength codes are handled with a loop, - * which need not be inline code. - * - * Notes about the HUFF_DECODE macro: - * 1. Near the end of the data segment, we may fail to get enough bits - * for a lookahead. In that case, we do it the hard way. - * 2. If the lookahead table contains no entry, the next code must be - * more than HUFF_LOOKAHEAD bits long. - * 3. jpeg_huff_decode returns -1 if forced to suspend. - */ - -#define HUFF_DECODE(result,state,htbl,failaction,slowlabel) \ -{ register int nb, look; \ - if (bits_left < HUFF_LOOKAHEAD) { \ - if (! jpeg_fill_bit_buffer(&state,get_buffer,bits_left, 0)) {failaction;} \ - get_buffer = state.get_buffer; bits_left = state.bits_left; \ - if (bits_left < HUFF_LOOKAHEAD) { \ - nb = 1; goto slowlabel; \ - } \ - } \ - look = PEEK_BITS(HUFF_LOOKAHEAD); \ - if ((nb = htbl->look_nbits[look]) != 0) { \ - DROP_BITS(nb); \ - result = htbl->look_sym[look]; \ - } else { \ - nb = HUFF_LOOKAHEAD+1; \ -slowlabel: \ - if ((result=jpeg_huff_decode(&state,get_buffer,bits_left,htbl,nb)) < 0) \ - { failaction; } \ - get_buffer = state.get_buffer; bits_left = state.bits_left; \ - } \ -} - -/* Out-of-line case for Huffman code fetching */ -EXTERN(int) jpeg_huff_decode - JPP((bitread_working_state * state, register bit_buf_type get_buffer, - register int bits_left, d_derived_tbl * htbl, int min_bits)); diff --git a/Utilities/CAI/cai_dll/inc/jerror.h b/Utilities/CAI/cai_dll/inc/jerror.h deleted file mode 100755 index fc2fffeac297bcee557400beefb7b6ce790e79a7..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/jerror.h +++ /dev/null @@ -1,291 +0,0 @@ -/* - * jerror.h - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file defines the error and message codes for the JPEG library. - * Edit this file to add new codes, or to translate the message strings to - * some other language. - * A set of error-reporting macros are defined too. Some applications using - * the JPEG library may wish to include this file to get the error codes - * and/or the macros. - */ - -/* - * To define the enum list of message codes, include this file without - * defining macro JMESSAGE. To create a message string table, include it - * again with a suitable JMESSAGE definition (see jerror.c for an example). - */ -#ifndef JMESSAGE -#ifndef JERROR_H -/* First time through, define the enum list */ -#define JMAKE_ENUM_LIST -#else -/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */ -#define JMESSAGE(code,string) -#endif /* JERROR_H */ -#endif /* JMESSAGE */ - -#ifdef JMAKE_ENUM_LIST - -typedef enum { - -#define JMESSAGE(code,string) code , - -#endif /* JMAKE_ENUM_LIST */ - -JMESSAGE(JMSG_NOMESSAGE, "Bogus message code %d") /* Must be first entry! */ - -/* For maintenance convenience, list is alphabetical by message code name */ -JMESSAGE(JERR_ARITH_NOTIMPL, - "Sorry, there are legal restrictions on arithmetic coding") -JMESSAGE(JERR_BAD_ALIGN_TYPE, "ALIGN_TYPE is wrong, please fix") -JMESSAGE(JERR_BAD_ALLOC_CHUNK, "MAX_ALLOC_CHUNK is wrong, please fix") -JMESSAGE(JERR_BAD_BUFFER_MODE, "Bogus buffer control mode") -JMESSAGE(JERR_BAD_COMPONENT_ID, "Invalid component ID %d in SOS") -JMESSAGE(JERR_BAD_DCT_COEF, "DCT coefficient out of range") -JMESSAGE(JERR_BAD_DCTSIZE, "IDCT output block size %d not supported") -JMESSAGE(JERR_BAD_HUFF_TABLE, "Bogus Huffman table definition") -JMESSAGE(JERR_BAD_IN_COLORSPACE, "Bogus input colorspace") -JMESSAGE(JERR_BAD_J_COLORSPACE, "Bogus JPEG colorspace") -JMESSAGE(JERR_BAD_LENGTH, "Bogus marker length") -JMESSAGE(JERR_BAD_LIB_VERSION, - "Wrong JPEG library version: library is %d, caller expects %d") -JMESSAGE(JERR_BAD_MCU_SIZE, "Sampling factors too large for interleaved scan") -JMESSAGE(JERR_BAD_POOL_ID, "Invalid memory pool code %d") -JMESSAGE(JERR_BAD_PRECISION, "Unsupported JPEG data precision %d") -JMESSAGE(JERR_BAD_PROGRESSION, - "Invalid progressive parameters Ss=%d Se=%d Ah=%d Al=%d") -JMESSAGE(JERR_BAD_PROG_SCRIPT, - "Invalid progressive parameters at scan script entry %d") -JMESSAGE(JERR_BAD_SAMPLING, "Bogus sampling factors") -JMESSAGE(JERR_BAD_SCAN_SCRIPT, "Invalid scan script at entry %d") -JMESSAGE(JERR_BAD_STATE, "Improper call to JPEG library in state %d") -JMESSAGE(JERR_BAD_STRUCT_SIZE, - "JPEG parameter struct mismatch: library thinks size is %u, caller expects %u") -JMESSAGE(JERR_BAD_VIRTUAL_ACCESS, "Bogus virtual array access") -JMESSAGE(JERR_BUFFER_SIZE, "Buffer passed to JPEG library is too small") -JMESSAGE(JERR_CANT_SUSPEND, "Suspension not allowed here") -JMESSAGE(JERR_CCIR601_NOTIMPL, "CCIR601 sampling not implemented yet") -JMESSAGE(JERR_COMPONENT_COUNT, "Too many color components: %d, max %d") -JMESSAGE(JERR_CONVERSION_NOTIMPL, "Unsupported color conversion request") -JMESSAGE(JERR_DAC_INDEX, "Bogus DAC index %d") -JMESSAGE(JERR_DAC_VALUE, "Bogus DAC value 0x%x") -JMESSAGE(JERR_DHT_INDEX, "Bogus DHT index %d") -JMESSAGE(JERR_DQT_INDEX, "Bogus DQT index %d") -JMESSAGE(JERR_EMPTY_IMAGE, "Empty JPEG image (DNL not supported)") -JMESSAGE(JERR_EMS_READ, "Read from EMS failed") -JMESSAGE(JERR_EMS_WRITE, "Write to EMS failed") -JMESSAGE(JERR_EOI_EXPECTED, "Didn't expect more than one scan") -JMESSAGE(JERR_FILE_READ, "Input file read error") -JMESSAGE(JERR_FILE_WRITE, "Output file write error --- out of disk space?") -JMESSAGE(JERR_FRACT_SAMPLE_NOTIMPL, "Fractional sampling not implemented yet") -JMESSAGE(JERR_HUFF_CLEN_OVERFLOW, "Huffman code size table overflow") -JMESSAGE(JERR_HUFF_MISSING_CODE, "Missing Huffman code table entry") -JMESSAGE(JERR_IMAGE_TOO_BIG, "Maximum supported image dimension is %u pixels") -JMESSAGE(JERR_INPUT_EMPTY, "Empty input file") -JMESSAGE(JERR_INPUT_EOF, "Premature end of input file") -JMESSAGE(JERR_MISMATCHED_QUANT_TABLE, - "Cannot transcode due to multiple use of quantization table %d") -JMESSAGE(JERR_MISSING_DATA, "Scan script does not transmit all data") -JMESSAGE(JERR_MODE_CHANGE, "Invalid color quantization mode change") -JMESSAGE(JERR_NOTIMPL, "Not implemented yet") -JMESSAGE(JERR_NOT_COMPILED, "Requested feature was omitted at compile time") -JMESSAGE(JERR_NO_BACKING_STORE, "Backing store not supported") -JMESSAGE(JERR_NO_HUFF_TABLE, "Huffman table 0x%02x was not defined") -JMESSAGE(JERR_NO_IMAGE, "JPEG datastream contains no image") -JMESSAGE(JERR_NO_QUANT_TABLE, "Quantization table 0x%02x was not defined") -JMESSAGE(JERR_NO_SOI, "Not a JPEG file: starts with 0x%02x 0x%02x") -JMESSAGE(JERR_OUT_OF_MEMORY, "Insufficient memory (case %d)") -JMESSAGE(JERR_QUANT_COMPONENTS, - "Cannot quantize more than %d color components") -JMESSAGE(JERR_QUANT_FEW_COLORS, "Cannot quantize to fewer than %d colors") -JMESSAGE(JERR_QUANT_MANY_COLORS, "Cannot quantize to more than %d colors") -JMESSAGE(JERR_SOF_DUPLICATE, "Invalid JPEG file structure: two SOF markers") -JMESSAGE(JERR_SOF_NO_SOS, "Invalid JPEG file structure: missing SOS marker") -JMESSAGE(JERR_SOF_UNSUPPORTED, "Unsupported JPEG process: SOF type 0x%02x") -JMESSAGE(JERR_SOI_DUPLICATE, "Invalid JPEG file structure: two SOI markers") -JMESSAGE(JERR_SOS_NO_SOF, "Invalid JPEG file structure: SOS before SOF") -JMESSAGE(JERR_TFILE_CREATE, "Failed to create temporary file %s") -JMESSAGE(JERR_TFILE_READ, "Read failed on temporary file") -JMESSAGE(JERR_TFILE_SEEK, "Seek failed on temporary file") -JMESSAGE(JERR_TFILE_WRITE, - "Write failed on temporary file --- out of disk space?") -JMESSAGE(JERR_TOO_LITTLE_DATA, "Application transferred too few scanlines") -JMESSAGE(JERR_UNKNOWN_MARKER, "Unsupported marker type 0x%02x") -JMESSAGE(JERR_VIRTUAL_BUG, "Virtual array controller messed up") -JMESSAGE(JERR_WIDTH_OVERFLOW, "Image too wide for this implementation") -JMESSAGE(JERR_XMS_READ, "Read from XMS failed") -JMESSAGE(JERR_XMS_WRITE, "Write to XMS failed") -JMESSAGE(JMSG_COPYRIGHT, JCOPYRIGHT) -JMESSAGE(JMSG_VERSION, JVERSION) -JMESSAGE(JTRC_16BIT_TABLES, - "Caution: quantization tables are too coarse for baseline JPEG") -JMESSAGE(JTRC_ADOBE, - "Adobe APP14 marker: version %d, flags 0x%04x 0x%04x, transform %d") -JMESSAGE(JTRC_APP0, "Unknown APP0 marker (not JFIF), length %u") -JMESSAGE(JTRC_APP14, "Unknown APP14 marker (not Adobe), length %u") -JMESSAGE(JTRC_DAC, "Define Arithmetic Table 0x%02x: 0x%02x") -JMESSAGE(JTRC_DHT, "Define Huffman Table 0x%02x") -JMESSAGE(JTRC_DQT, "Define Quantization Table %d precision %d") -JMESSAGE(JTRC_DRI, "Define Restart Interval %u") -JMESSAGE(JTRC_EMS_CLOSE, "Freed EMS handle %u") -JMESSAGE(JTRC_EMS_OPEN, "Obtained EMS handle %u") -JMESSAGE(JTRC_EOI, "End Of Image") -JMESSAGE(JTRC_HUFFBITS, " %3d %3d %3d %3d %3d %3d %3d %3d") -JMESSAGE(JTRC_JFIF, "JFIF APP0 marker: version %d.%02d, density %dx%d %d") -JMESSAGE(JTRC_JFIF_BADTHUMBNAILSIZE, - "Warning: thumbnail image size does not match data length %u") -JMESSAGE(JTRC_JFIF_EXTENSION, - "JFIF extension marker: type 0x%02x, length %u") -JMESSAGE(JTRC_JFIF_THUMBNAIL, " with %d x %d thumbnail image") -JMESSAGE(JTRC_MISC_MARKER, "Miscellaneous marker 0x%02x, length %u") -JMESSAGE(JTRC_PARMLESS_MARKER, "Unexpected marker 0x%02x") -JMESSAGE(JTRC_QUANTVALS, " %4u %4u %4u %4u %4u %4u %4u %4u") -JMESSAGE(JTRC_QUANT_3_NCOLORS, "Quantizing to %d = %d*%d*%d colors") -JMESSAGE(JTRC_QUANT_NCOLORS, "Quantizing to %d colors") -JMESSAGE(JTRC_QUANT_SELECTED, "Selected %d colors for quantization") -JMESSAGE(JTRC_RECOVERY_ACTION, "At marker 0x%02x, recovery action %d") -JMESSAGE(JTRC_RST, "RST%d") -JMESSAGE(JTRC_SMOOTH_NOTIMPL, - "Smoothing not supported with nonstandard sampling ratios") -JMESSAGE(JTRC_SOF, "Start Of Frame 0x%02x: width=%u, height=%u, components=%d") -JMESSAGE(JTRC_SOF_COMPONENT, " Component %d: %dhx%dv q=%d") -JMESSAGE(JTRC_SOI, "Start of Image") -JMESSAGE(JTRC_SOS, "Start Of Scan: %d components") -JMESSAGE(JTRC_SOS_COMPONENT, " Component %d: dc=%d ac=%d") -JMESSAGE(JTRC_SOS_PARAMS, " Ss=%d, Se=%d, Ah=%d, Al=%d") -JMESSAGE(JTRC_TFILE_CLOSE, "Closed temporary file %s") -JMESSAGE(JTRC_TFILE_OPEN, "Opened temporary file %s") -JMESSAGE(JTRC_THUMB_JPEG, - "JFIF extension marker: JPEG-compressed thumbnail image, length %u") -JMESSAGE(JTRC_THUMB_PALETTE, - "JFIF extension marker: palette thumbnail image, length %u") -JMESSAGE(JTRC_THUMB_RGB, - "JFIF extension marker: RGB thumbnail image, length %u") -JMESSAGE(JTRC_UNKNOWN_IDS, - "Unrecognized component IDs %d %d %d, assuming YCbCr") -JMESSAGE(JTRC_XMS_CLOSE, "Freed XMS handle %u") -JMESSAGE(JTRC_XMS_OPEN, "Obtained XMS handle %u") -JMESSAGE(JWRN_ADOBE_XFORM, "Unknown Adobe color transform code %d") -JMESSAGE(JWRN_BOGUS_PROGRESSION, - "Inconsistent progression sequence for component %d coefficient %d") -JMESSAGE(JWRN_EXTRANEOUS_DATA, - "Corrupt JPEG data: %u extraneous bytes before marker 0x%02x") -JMESSAGE(JWRN_HIT_MARKER, "Corrupt JPEG data: premature end of data segment") -JMESSAGE(JWRN_HUFF_BAD_CODE, "Corrupt JPEG data: bad Huffman code") -JMESSAGE(JWRN_JFIF_MAJOR, "Warning: unknown JFIF revision number %d.%02d") -JMESSAGE(JWRN_JPEG_EOF, "Premature end of JPEG file") -JMESSAGE(JWRN_MUST_RESYNC, - "Corrupt JPEG data: found marker 0x%02x instead of RST%d") -JMESSAGE(JWRN_NOT_SEQUENTIAL, "Invalid SOS parameters for sequential JPEG") -JMESSAGE(JWRN_TOO_MUCH_DATA, "Application transferred too many scanlines") - -#ifdef JMAKE_ENUM_LIST - - JMSG_LASTMSGCODE -} J_MESSAGE_CODE; - -#undef JMAKE_ENUM_LIST -#endif /* JMAKE_ENUM_LIST */ - -/* Zap JMESSAGE macro so that future re-inclusions do nothing by default */ -#undef JMESSAGE - - -#ifndef JERROR_H -#define JERROR_H - -/* Macros to simplify using the error and trace message stuff */ -/* The first parameter is either type of cinfo pointer */ - -/* Fatal errors (print message and exit) */ -#define ERREXIT(cinfo,code) \ - ((cinfo)->err->msg_code = (code), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT1(cinfo,code,p1) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT2(cinfo,code,p1,p2) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT3(cinfo,code,p1,p2,p3) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (cinfo)->err->msg_parm.i[2] = (p3), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT4(cinfo,code,p1,p2,p3,p4) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (cinfo)->err->msg_parm.i[2] = (p3), \ - (cinfo)->err->msg_parm.i[3] = (p4), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXITS(cinfo,code,str) \ - ((cinfo)->err->msg_code = (code), \ - strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) - -#define MAKESTMT(stuff) do { stuff } while (0) - -/* Nonfatal errors (we can keep going, but the data is probably corrupt) */ -#define WARNMS(cinfo,code) \ - ((cinfo)->err->msg_code = (code), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) -#define WARNMS1(cinfo,code,p1) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) -#define WARNMS2(cinfo,code,p1,p2) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) - -/* Informational/debugging messages */ -#define TRACEMS(cinfo,lvl,code) \ - ((cinfo)->err->msg_code = (code), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) -#define TRACEMS1(cinfo,lvl,code,p1) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) -#define TRACEMS2(cinfo,lvl,code,p1,p2) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) -#define TRACEMS3(cinfo,lvl,code,p1,p2,p3) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMS4(cinfo,lvl,code,p1,p2,p3,p4) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMS5(cinfo,lvl,code,p1,p2,p3,p4,p5) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ - _mp[4] = (p5); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMS8(cinfo,lvl,code,p1,p2,p3,p4,p5,p6,p7,p8) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ - _mp[4] = (p5); _mp[5] = (p6); _mp[6] = (p7); _mp[7] = (p8); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMSS(cinfo,lvl,code,str) \ - ((cinfo)->err->msg_code = (code), \ - strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) - -#endif /* JERROR_H */ diff --git a/Utilities/CAI/cai_dll/inc/jinclude.h b/Utilities/CAI/cai_dll/inc/jinclude.h deleted file mode 100755 index 0a4f15146aeb2070601838439e169509f6fe5b7d..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/jinclude.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * jinclude.h - * - * Copyright (C) 1991-1994, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file exists to provide a single place to fix any problems with - * including the wrong system include files. (Common problems are taken - * care of by the standard jconfig symbols, but on really weird systems - * you may have to edit this file.) - * - * NOTE: this file is NOT intended to be included by applications using the - * JPEG library. Most applications need only include jpeglib.h. - */ - - -/* Include auto-config file to find out which system include files we need. */ - -#include "jconfig.h" /* auto configuration options */ -#define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */ - -/* - * We need the NULL macro and size_t typedef. - * On an ANSI-conforming system it is sufficient to include <stddef.h>. - * Otherwise, we get them from <stdlib.h> or <stdio.h>; we may have to - * pull in <sys/types.h> as well. - * Note that the core JPEG library does not require <stdio.h>; - * only the default error handler and data source/destination modules do. - * But we must pull it in because of the references to FILE in jpeglib.h. - * You can remove those references if you want to compile without <stdio.h>. - */ - -#ifdef HAVE_STDDEF_H -#include <stddef.h> -#endif - -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif - -#ifdef NEED_SYS_TYPES_H -#include <sys/types.h> -#endif - -#include <stdio.h> - -/* - * We need memory copying and zeroing functions, plus strncpy(). - * ANSI and System V implementations declare these in <string.h>. - * BSD doesn't have the mem() functions, but it does have bcopy()/bzero(). - * Some systems may declare memset and memcpy in <memory.h>. - * - * NOTE: we assume the size parameters to these functions are of type size_t. - * Change the casts in these macros if not! - */ - -#ifdef NEED_BSD_STRINGS - -#include <strings.h> -#define MEMZERO(target,size) bzero((void *)(target), (size_t)(size)) -#define MEMCOPY(dest,src,size) bcopy((const void *)(src), (void *)(dest), (size_t)(size)) - -#else /* not BSD, assume ANSI/SysV string lib */ - -#include <string.h> -#define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size)) -#define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size)) - -#endif - -/* - * In ANSI C, and indeed any rational implementation, size_t is also the - * type returned by sizeof(). However, it seems there are some irrational - * implementations out there, in which sizeof() returns an int even though - * size_t is defined as long or unsigned long. To ensure consistent results - * we always use this SIZEOF() macro in place of using sizeof() directly. - */ - -#define SIZEOF(object) ((size_t) sizeof(object)) - -/* - * The modules that use fread() and fwrite() always invoke them through - * these macros. On some systems you may need to twiddle the argument casts. - * CAUTION: argument order is different from underlying functions! - */ - -#define JFREAD(file,buf,sizeofbuf) \ - ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) -#define JFWRITE(file,buf,sizeofbuf) \ - ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) diff --git a/Utilities/CAI/cai_dll/inc/jmemsys.h b/Utilities/CAI/cai_dll/inc/jmemsys.h deleted file mode 100755 index 6d4c7f2ae411a265963e1f4a98fb4c44f5e781ab..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/jmemsys.h +++ /dev/null @@ -1,183 +0,0 @@ -/* - * jmemsys.h - * - * Copyright (C) 1992-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This include file defines the interface between the system-independent - * and system-dependent portions of the JPEG memory manager. No other - * modules need include it. (The system-independent portion is jmemmgr.c; - * there are several different versions of the system-dependent portion.) - * - * This file works as-is for the system-dependent memory managers supplied - * in the IJG distribution. You may need to modify it if you write a - * custom memory manager. If system-dependent changes are needed in - * this file, the best method is to #ifdef them based on a configuration - * symbol supplied in jconfig.h, as we have done with USE_MSDOS_MEMMGR. - */ - - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_get_small jGetSmall -#define jpeg_free_small jFreeSmall -#define jpeg_get_large jGetLarge -#define jpeg_free_large jFreeLarge -#define jpeg_mem_available jMemAvail -#define jpeg_open_backing_store jOpenBackStore -#define jpeg_mem_init jMemInit -#define jpeg_mem_term jMemTerm -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - - -/* - * These two functions are used to allocate and release small chunks of - * memory. (Typically the total amount requested through jpeg_get_small is - * no more than 20K or so; this will be requested in chunks of a few K each.) - * Behavior should be the same as for the standard library functions malloc - * and free; in particular, jpeg_get_small must return NULL on failure. - * On most systems, these ARE malloc and free. jpeg_free_small is passed the - * size of the object being freed, just in case it's needed. - * On an 80x86 machine using small-data memory model, these manage near heap. - */ - -EXTERN(void *) jpeg_get_small JPP((j_common_ptr cinfo, size_t sizeofobject)); -EXTERN(void) jpeg_free_small JPP((j_common_ptr cinfo, void * object, - size_t sizeofobject)); - -/* - * These two functions are used to allocate and release large chunks of - * memory (up to the total free space designated by jpeg_mem_available). - * The interface is the same as above, except that on an 80x86 machine, - * far pointers are used. On most other machines these are identical to - * the jpeg_get/free_small routines; but we keep them separate anyway, - * in case a different allocation strategy is desirable for large chunks. - */ - -EXTERN(void FAR *) jpeg_get_large JPP((j_common_ptr cinfo, - size_t sizeofobject)); -EXTERN(void) jpeg_free_large JPP((j_common_ptr cinfo, void FAR * object, - size_t sizeofobject)); - -/* - * The macro MAX_ALLOC_CHUNK designates the maximum number of bytes that may - * be requested in a single call to jpeg_get_large (and jpeg_get_small for that - * matter, but that case should never come into play). This macro is needed - * to model the 64Kb-segment-size limit of far addressing on 80x86 machines. - * On those machines, we expect that jconfig.h will provide a proper value. - * On machines with 32-bit flat address spaces, any large constant may be used. - * - * NB: jmemmgr.c expects that MAX_ALLOC_CHUNK will be representable as type - * size_t and will be a multiple of sizeof(align_type). - */ - -#ifndef MAX_ALLOC_CHUNK /* may be overridden in jconfig.h */ -#define MAX_ALLOC_CHUNK 1000000000L -#endif - -/* - * This routine computes the total space still available for allocation by - * jpeg_get_large. If more space than this is needed, backing store will be - * used. NOTE: any memory already allocated must not be counted. - * - * There is a minimum space requirement, corresponding to the minimum - * feasible buffer sizes; jmemmgr.c will request that much space even if - * jpeg_mem_available returns zero. The maximum space needed, enough to hold - * all working storage in memory, is also passed in case it is useful. - * Finally, the total space already allocated is passed. If no better - * method is available, cinfo->mem->max_memory_to_use - already_allocated - * is often a suitable calculation. - * - * It is OK for jpeg_mem_available to underestimate the space available - * (that'll just lead to more backing-store access than is really necessary). - * However, an overestimate will lead to failure. Hence it's wise to subtract - * a slop factor from the true available space. 5% should be enough. - * - * On machines with lots of virtual memory, any large constant may be returned. - * Conversely, zero may be returned to always use the minimum amount of memory. - */ - -EXTERN(long) jpeg_mem_available JPP((j_common_ptr cinfo, - long min_bytes_needed, - long max_bytes_needed, - long already_allocated)); - - -/* - * This structure holds whatever state is needed to access a single - * backing-store object. The read/write/close method pointers are called - * by jmemmgr.c to manipulate the backing-store object; all other fields - * are private to the system-dependent backing store routines. - */ - -#define TEMP_NAME_LENGTH 64 /* max length of a temporary file's name */ - -#ifdef USE_MSDOS_MEMMGR /* DOS-specific junk */ - -typedef unsigned short XMSH; /* type of extended-memory handles */ -typedef unsigned short EMSH; /* type of expanded-memory handles */ - -typedef union { - short file_handle; /* DOS file handle if it's a temp file */ - XMSH xms_handle; /* handle if it's a chunk of XMS */ - EMSH ems_handle; /* handle if it's a chunk of EMS */ -} handle_union; - -#endif /* USE_MSDOS_MEMMGR */ - -typedef struct backing_store_struct * backing_store_ptr; - -typedef struct backing_store_struct { - /* Methods for reading/writing/closing this backing-store object */ - JMETHOD(void, read_backing_store, (j_common_ptr cinfo, - backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count)); - JMETHOD(void, write_backing_store, (j_common_ptr cinfo, - backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count)); - JMETHOD(void, close_backing_store, (j_common_ptr cinfo, - backing_store_ptr info)); - - /* Private fields for system-dependent backing-store management */ -#ifdef USE_MSDOS_MEMMGR - /* For the MS-DOS manager (jmemdos.c), we need: */ - handle_union handle; /* reference to backing-store storage object */ - char temp_name[TEMP_NAME_LENGTH]; /* name if it's a file */ -#else - /* For a typical implementation with temp files, we need: */ - FILE * temp_file; /* stdio reference to temp file */ - char temp_name[TEMP_NAME_LENGTH]; /* name of temp file */ -#endif -} backing_store_info; - -/* - * Initial opening of a backing-store object. This must fill in the - * read/write/close pointers in the object. The read/write routines - * may take an error exit if the specified maximum file size is exceeded. - * (If jpeg_mem_available always returns a large value, this routine can - * just take an error exit.) - */ - -EXTERN(void) jpeg_open_backing_store JPP((j_common_ptr cinfo, - backing_store_ptr info, - long total_bytes_needed)); - - -/* - * These routines take care of any system-dependent initialization and - * cleanup required. jpeg_mem_init will be called before anything is - * allocated (and, therefore, nothing in cinfo is of use except the error - * manager pointer). It should return a suitable default value for - * max_memory_to_use; this may subsequently be overridden by the surrounding - * application. (Note that max_memory_to_use is only important if - * jpeg_mem_available chooses to consult it ... no one else will.) - * jpeg_mem_term may assume that all requested memory has been freed and that - * all opened backing-store objects have been closed. - */ - -EXTERN(long) jpeg_mem_init JPP((j_common_ptr cinfo)); -EXTERN(void) jpeg_mem_term JPP((j_common_ptr cinfo)); diff --git a/Utilities/CAI/cai_dll/inc/jmorecfg.h b/Utilities/CAI/cai_dll/inc/jmorecfg.h deleted file mode 100755 index dbd0f1414720ac57c65f7de5ec4480d5a8d494bf..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/jmorecfg.h +++ /dev/null @@ -1,369 +0,0 @@ -/* - * jmorecfg.h - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains additional configuration options that customize the - * JPEG software for special applications or support machine-dependent - * optimizations. Most users will not need to touch this file. - */ - -#ifndef _JMORECFG_H_ -#define _JMORECFG_H_ - -/* - * Define BITS_IN_JSAMPLE as either - * 8 for 8-bit sample values (the usual setting) - * 12 for 12-bit sample values - * Only 8 and 12 are legal data precisions for lossy JPEG according to the - * JPEG standard, and the IJG code does not support anything else! - * We do not support run-time selection of data precision, sorry. - */ - -#define BITS_IN_JSAMPLE 8 /* use 8 or 12 */ - - -/* - * Maximum number of components (color channels) allowed in JPEG image. - * To meet the letter of the JPEG spec, set this to 255. However, darn - * few applications need more than 4 channels (maybe 5 for CMYK + alpha - * mask). We recommend 10 as a reasonable compromise; use 4 if you are - * really short on memory. (Each allowed component costs a hundred or so - * bytes of storage, whether actually used in an image or not.) - */ - -#define MAX_COMPONENTS 10 /* maximum number of image components */ - - -/* - * Basic data types. - * You may need to change these if you have a machine with unusual data - * type sizes; for example, "char" not 8 bits, "short" not 16 bits, - * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits, - * but it had better be at least 16. - */ - -/* Representation of a single sample (pixel element value). - * We frequently allocate large arrays of these, so it's important to keep - * them small. But if you have memory to burn and access to char or short - * arrays is very slow on your hardware, you might want to change these. - */ - -#if BITS_IN_JSAMPLE == 8 -/* JSAMPLE should be the smallest type that will hold the values 0..255. - * You can use a signed char by having GETJSAMPLE mask it with 0xFF. - */ - -#ifdef HAVE_UNSIGNED_CHAR - -typedef unsigned char JSAMPLE; -#define GETJSAMPLE(value) ((int) (value)) - -#else /* not HAVE_UNSIGNED_CHAR */ - -typedef char JSAMPLE; -#ifdef CHAR_IS_UNSIGNED -#define GETJSAMPLE(value) ((int) (value)) -#else -#define GETJSAMPLE(value) ((int) (value) & 0xFF) -#endif /* CHAR_IS_UNSIGNED */ - -#endif /* HAVE_UNSIGNED_CHAR */ - -#define MAXJSAMPLE 255 -#define CENTERJSAMPLE 128 - -#endif /* BITS_IN_JSAMPLE == 8 */ - - -#if BITS_IN_JSAMPLE == 12 -/* JSAMPLE should be the smallest type that will hold the values 0..4095. - * On nearly all machines "short" will do nicely. - */ - -typedef short JSAMPLE; -#define GETJSAMPLE(value) ((int) (value)) - -#define MAXJSAMPLE 4095 -#define CENTERJSAMPLE 2048 - -#endif /* BITS_IN_JSAMPLE == 12 */ - - -/* Representation of a DCT frequency coefficient. - * This should be a signed value of at least 16 bits; "short" is usually OK. - * Again, we allocate large arrays of these, but you can change to int - * if you have memory to burn and "short" is really slow. - */ - -typedef short JCOEF; - - -/* Compressed datastreams are represented as arrays of JOCTET. - * These must be EXACTLY 8 bits wide, at least once they are written to - * external storage. Note that when using the stdio data source/destination - * managers, this is also the data type passed to fread/fwrite. - */ - -#ifdef HAVE_UNSIGNED_CHAR - -typedef unsigned char JOCTET; -#define GETJOCTET(value) (value) - -#else /* not HAVE_UNSIGNED_CHAR */ - -typedef char JOCTET; -#ifdef CHAR_IS_UNSIGNED -#define GETJOCTET(value) (value) -#else -#define GETJOCTET(value) ((value) & 0xFF) -#endif /* CHAR_IS_UNSIGNED */ - -#endif /* HAVE_UNSIGNED_CHAR */ - - -/* These typedefs are used for various table entries and so forth. - * They must be at least as wide as specified; but making them too big - * won't cost a huge amount of memory, so we don't provide special - * extraction code like we did for JSAMPLE. (In other words, these - * typedefs live at a different point on the speed/space tradeoff curve.) - */ - -/* UINT8 must hold at least the values 0..255. */ - -#ifdef HAVE_UNSIGNED_CHAR -typedef unsigned char UINT8; -#else /* not HAVE_UNSIGNED_CHAR */ -#ifdef CHAR_IS_UNSIGNED -typedef char UINT8; -#else /* not CHAR_IS_UNSIGNED */ -typedef short UINT8; -#endif /* CHAR_IS_UNSIGNED */ -#endif /* HAVE_UNSIGNED_CHAR */ - -/* UINT16 must hold at least the values 0..65535. */ - -#ifdef HAVE_UNSIGNED_SHORT -typedef unsigned short UINT16; -#else /* not HAVE_UNSIGNED_SHORT */ -typedef unsigned int UINT16; -#endif /* HAVE_UNSIGNED_SHORT */ - -/* INT16 must hold at least the values -32768..32767. */ - -#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */ -typedef short INT16; -#endif - -/* INT32 must hold at least signed 32-bit values. */ - -#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */ -typedef int INT32; -#endif - -/* Datatype used for image dimensions. The JPEG standard only supports - * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore - * "unsigned int" is sufficient on all machines. However, if you need to - * handle larger images and you don't mind deviating from the spec, you - * can change this datatype. - */ - -typedef unsigned int JDIMENSION; - -#define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */ - - -/* These macros are used in all function definitions and extern declarations. - * You could modify them if you need to change function linkage conventions; - * in particular, you'll need to do that to make the library a Windows DLL. - * Another application is to make all functions global for use with debuggers - * or code profilers that require it. - */ - -/* a function called through method pointers: */ -#define METHODDEF(type) static type -/* a function used only in its module: */ -#define LOCAL(type) static type -/* a function referenced thru EXTERNs: */ -#define GLOBAL(type) type -/* a reference to a GLOBAL function: */ -#define EXTERN(type) extern type - - -/* This macro is used to declare a "method", that is, a function pointer. - * We want to supply prototype parameters if the compiler can cope. - * Note that the arglist parameter must be parenthesized! - * Again, you can customize this if you need special linkage keywords. - */ - -#ifdef HAVE_PROTOTYPES -#define JMETHOD(type,methodname,arglist) type (*methodname) arglist -#else -#define JMETHOD(type,methodname,arglist) type (*methodname) () -#endif - - -/* Here is the pseudo-keyword for declaring pointers that must be "far" - * on 80x86 machines. Most of the specialized coding for 80x86 is handled - * by just saying "FAR *" where such a pointer is needed. In a few places - * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol. - */ - -#ifndef FAR -#ifdef NEED_FAR_POINTERS -#define FAR far -#else -#define FAR -#endif -#endif - - -/* - * On a few systems, type boolean and/or its values FALSE, TRUE may appear - * in standard header files. Or you may have conflicts with application- - * specific header files that you want to include together with these files. - * Defining HAVE_BOOLEAN before including jpeglib.h should make it work. - */ - -#ifndef HAVE_BOOLEAN -typedef int boolean; -#endif -#ifndef FALSE /* in case these macros already exist */ -#define FALSE 0 /* values of boolean */ -#endif -#ifndef TRUE -#define TRUE 1 -#endif - - -/* - * The remaining options affect code selection within the JPEG library, - * but they don't need to be visible to most applications using the library. - * To minimize application namespace pollution, the symbols won't be - * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined. - */ - -#ifdef JPEG_INTERNALS -#define JPEG_INTERNAL_OPTIONS -#endif - -#ifdef JPEG_INTERNAL_OPTIONS - - -/* - * These defines indicate whether to include various optional functions. - * Undefining some of these symbols will produce a smaller but less capable - * library. Note that you can leave certain source files out of the - * compilation/linking process if you've #undef'd the corresponding symbols. - * (You may HAVE to do that if your compiler doesn't like null source files.) - */ - -/* Arithmetic coding is unsupported for legal reasons. Complaints to IBM. */ - -/* Capability options common to encoder and decoder: */ - -#define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */ -#define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */ -#define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */ - -/* Encoder capability options: */ - -#undef C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ -#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ -#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ -#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */ -/* Note: if you selected 12-bit data precision, it is dangerous to turn off - * ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit - * precision, so jchuff.c normally uses entropy optimization to compute - * usable tables for higher precision. If you don't want to do optimization, - * you'll have to supply different default Huffman tables. - * The exact same statements apply for progressive JPEG: the default tables - * don't work for progressive mode. (This may get fixed, however.) - */ -#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */ - -/* Decoder capability options: */ - -#undef D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ -#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ -#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ -#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */ -#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */ -#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */ -#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */ -#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */ -#define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */ -#define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */ - -/* more capability options later, no doubt */ - - -/* - * Ordering of RGB data in scanlines passed to or from the application. - * If your application wants to deal with data in the order B,G,R, just - * change these macros. You can also deal with formats such as R,G,B,X - * (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing - * the offsets will also change the order in which colormap data is organized. - * RESTRICTIONS: - * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats. - * 2. These macros only affect RGB<=>YCbCr color conversion, so they are not - * useful if you are using JPEG color spaces other than YCbCr or grayscale. - * 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE - * is not 3 (they don't understand about dummy color components!). So you - * can't use color quantization if you change that value. - */ - -#define RGB_RED 0 /* Offset of Red in an RGB scanline element */ -#define RGB_GREEN 1 /* Offset of Green */ -#define RGB_BLUE 2 /* Offset of Blue */ -#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */ - - -/* Definitions for speed-related optimizations. */ - - -/* If your compiler supports inline functions, define INLINE - * as the inline keyword; otherwise define it as empty. - */ - -#ifndef INLINE -#ifdef __GNUC__ /* for instance, GNU C knows about inline */ -#define INLINE __inline__ -#endif -#ifndef INLINE -#define INLINE /* default is to define it as empty */ -#endif -#endif - - -/* On some machines (notably 68000 series) "int" is 32 bits, but multiplying - * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER - * as short on such a machine. MULTIPLIER must be at least 16 bits wide. - */ - -#ifndef MULTIPLIER -#define MULTIPLIER int /* type for fastest integer multiply */ -#endif - - -/* FAST_FLOAT should be either float or double, whichever is done faster - * by your compiler. (Note that this type is only used in the floating point - * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.) - * Typically, float is faster in ANSI C compilers, while double is faster in - * pre-ANSI compilers (because they insist on converting to double anyway). - * The code below therefore chooses float if we have ANSI-style prototypes. - */ - -#ifndef FAST_FLOAT -#ifdef HAVE_PROTOTYPES -#define FAST_FLOAT float -#else -#define FAST_FLOAT double -#endif -#endif - -#endif /* JPEG_INTERNAL_OPTIONS */ - -#endif \ No newline at end of file diff --git a/Utilities/CAI/cai_dll/inc/jpegint.h b/Utilities/CAI/cai_dll/inc/jpegint.h deleted file mode 100755 index 7ba30c3fa90e932ed4c702a90a442f01fa31729f..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/jpegint.h +++ /dev/null @@ -1,388 +0,0 @@ -/* - * jpegint.h - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file provides common declarations for the various JPEG modules. - * These declarations are considered internal to the JPEG library; most - * applications using the library shouldn't need to include this file. - */ - - -/* Declarations for both compression & decompression */ - -typedef enum { /* Operating modes for buffer controllers */ - JBUF_PASS_THRU, /* Plain stripwise operation */ - /* Remaining modes require a full-image buffer to have been created */ - JBUF_SAVE_SOURCE, /* Run source subobject only, save output */ - JBUF_CRANK_DEST, /* Run dest subobject only, using saved data */ - JBUF_SAVE_AND_PASS /* Run both subobjects, save output */ -} J_BUF_MODE; - -/* Values of global_state field (jdapi.c has some dependencies on ordering!) */ -#define CSTATE_START 100 /* after create_compress */ -#define CSTATE_SCANNING 101 /* start_compress done, write_scanlines OK */ -#define CSTATE_RAW_OK 102 /* start_compress done, write_raw_data OK */ -#define CSTATE_WRCOEFS 103 /* jpeg_write_coefficients done */ -#define DSTATE_START 200 /* after create_decompress */ -#define DSTATE_INHEADER 201 /* reading header markers, no SOS yet */ -#define DSTATE_READY 202 /* found SOS, ready for start_decompress */ -#define DSTATE_PRELOAD 203 /* reading multiscan file in start_decompress*/ -#define DSTATE_PRESCAN 204 /* performing dummy pass for 2-pass quant */ -#define DSTATE_SCANNING 205 /* start_decompress done, read_scanlines OK */ -#define DSTATE_RAW_OK 206 /* start_decompress done, read_raw_data OK */ -#define DSTATE_BUFIMAGE 207 /* expecting jpeg_start_output */ -#define DSTATE_BUFPOST 208 /* looking for SOS/EOI in jpeg_finish_output */ -#define DSTATE_RDCOEFS 209 /* reading file in jpeg_read_coefficients */ -#define DSTATE_STOPPING 210 /* looking for EOI in jpeg_finish_decompress */ - - -/* Declarations for compression modules */ - -/* Master control module */ -struct jpeg_comp_master { - JMETHOD(void, prepare_for_pass, (j_compress_ptr cinfo)); - JMETHOD(void, pass_startup, (j_compress_ptr cinfo)); - JMETHOD(void, finish_pass, (j_compress_ptr cinfo)); - - /* State variables made visible to other modules */ - boolean call_pass_startup; /* True if pass_startup must be called */ - boolean is_last_pass; /* True during last pass */ -}; - -/* Main buffer control (downsampled-data buffer) */ -struct jpeg_c_main_controller { - JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); - JMETHOD(void, process_data, (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail)); -}; - -/* Compression preprocessing (downsampling input buffer control) */ -struct jpeg_c_prep_controller { - JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); - JMETHOD(void, pre_process_data, (j_compress_ptr cinfo, - JSAMPARRAY input_buf, - JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail, - JSAMPIMAGE output_buf, - JDIMENSION *out_row_group_ctr, - JDIMENSION out_row_groups_avail)); -}; - -/* Coefficient buffer control */ -struct jpeg_c_coef_controller { - JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); - JMETHOD(boolean, compress_data, (j_compress_ptr cinfo, - JSAMPIMAGE input_buf)); -}; - -/* Colorspace conversion */ -struct jpeg_color_converter { - JMETHOD(void, start_pass, (j_compress_ptr cinfo)); - JMETHOD(void, color_convert, (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPIMAGE output_buf, - JDIMENSION output_row, int num_rows)); -}; - -/* Downsampling */ -struct jpeg_downsampler { - JMETHOD(void, start_pass, (j_compress_ptr cinfo)); - JMETHOD(void, downsample, (j_compress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION in_row_index, - JSAMPIMAGE output_buf, - JDIMENSION out_row_group_index)); - - boolean need_context_rows; /* TRUE if need rows above & below */ -}; - -/* Forward DCT (also controls coefficient quantization) */ -struct jpeg_forward_dct { - JMETHOD(void, start_pass, (j_compress_ptr cinfo)); - /* perhaps this should be an array??? */ - JMETHOD(void, forward_DCT, (j_compress_ptr cinfo, - jpeg_component_info * compptr, - JSAMPARRAY sample_data, JBLOCKROW coef_blocks, - JDIMENSION start_row, JDIMENSION start_col, - JDIMENSION num_blocks)); -}; - -/* Entropy encoding */ -struct jpeg_entropy_encoder { - JMETHOD(void, start_pass, (j_compress_ptr cinfo, boolean gather_statistics)); - JMETHOD(boolean, encode_mcu, (j_compress_ptr cinfo, JBLOCKROW *MCU_data)); - JMETHOD(void, finish_pass, (j_compress_ptr cinfo)); -}; - -/* Marker writing */ -struct jpeg_marker_writer { - /* write_any_marker is exported for use by applications */ - /* Probably only COM and APPn markers should be written */ - JMETHOD(void, write_any_marker, (j_compress_ptr cinfo, int marker, - const JOCTET *dataptr, unsigned int datalen)); - JMETHOD(void, write_file_header, (j_compress_ptr cinfo)); - JMETHOD(void, write_frame_header, (j_compress_ptr cinfo)); - JMETHOD(void, write_scan_header, (j_compress_ptr cinfo)); - JMETHOD(void, write_file_trailer, (j_compress_ptr cinfo)); - JMETHOD(void, write_tables_only, (j_compress_ptr cinfo)); -}; - - -/* Declarations for decompression modules */ - -/* Master control module */ -struct jpeg_decomp_master { - JMETHOD(void, prepare_for_output_pass, (j_decompress_ptr cinfo)); - JMETHOD(void, finish_output_pass, (j_decompress_ptr cinfo)); - - /* State variables made visible to other modules */ - boolean is_dummy_pass; /* True during 1st pass for 2-pass quant */ -}; - -/* Input control module */ -struct jpeg_input_controller { - JMETHOD(int, consume_input, (j_decompress_ptr cinfo)); - JMETHOD(void, reset_input_controller, (j_decompress_ptr cinfo)); - JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo)); - JMETHOD(void, finish_input_pass, (j_decompress_ptr cinfo)); - - /* State variables made visible to other modules */ - boolean has_multiple_scans; /* True if file has multiple scans */ - boolean eoi_reached; /* True when EOI has been consumed */ -}; - -/* Main buffer control (downsampled-data buffer) */ -struct jpeg_d_main_controller { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)); - JMETHOD(void, process_data, (j_decompress_ptr cinfo, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); -}; - -/* Coefficient buffer control */ -struct jpeg_d_coef_controller { - JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo)); - JMETHOD(int, consume_data, (j_decompress_ptr cinfo)); - JMETHOD(void, start_output_pass, (j_decompress_ptr cinfo)); - JMETHOD(int, decompress_data, (j_decompress_ptr cinfo, - JSAMPIMAGE output_buf)); - /* Pointer to array of coefficient virtual arrays, or NULL if none */ - jvirt_barray_ptr *coef_arrays; -}; - -/* Decompression postprocessing (color quantization buffer control) */ -struct jpeg_d_post_controller { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)); - JMETHOD(void, post_process_data, (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, - JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, - JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); -}; - -/* Marker reading & parsing */ -struct jpeg_marker_reader { - JMETHOD(void, reset_marker_reader, (j_decompress_ptr cinfo)); - /* Read markers until SOS or EOI. - * Returns same codes as are defined for jpeg_consume_input: - * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. - */ - JMETHOD(int, read_markers, (j_decompress_ptr cinfo)); - /* Read a restart marker --- exported for use by entropy decoder only */ - jpeg_marker_parser_method read_restart_marker; - /* Application-overridable marker processing methods */ - jpeg_marker_parser_method process_COM; - jpeg_marker_parser_method process_APPn[16]; - - /* State of marker reader --- nominally internal, but applications - * supplying COM or APPn handlers might like to know the state. - */ - boolean saw_SOI; /* found SOI? */ - boolean saw_SOF; /* found SOF? */ - int next_restart_num; /* next restart number expected (0-7) */ - unsigned int discarded_bytes; /* # of bytes skipped looking for a marker */ -}; - -/* Entropy decoding */ -struct jpeg_entropy_decoder { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); - JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo, - JBLOCKROW *MCU_data)); -}; - -/* Inverse DCT (also performs dequantization) */ -typedef JMETHOD(void, inverse_DCT_method_ptr, - (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col)); - -struct jpeg_inverse_dct { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); - /* It is useful to allow each component to have a separate IDCT method. */ - inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS]; -}; - -/* Upsampling (note that upsampler must also call color converter) */ -struct jpeg_upsampler { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); - JMETHOD(void, upsample, (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, - JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, - JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); - - boolean need_context_rows; /* TRUE if need rows above & below */ -}; - -/* Colorspace conversion */ -struct jpeg_color_deconverter { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); - JMETHOD(void, color_convert, (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows)); -}; - -/* Color quantization or color precision reduction */ -struct jpeg_color_quantizer { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo, boolean is_pre_scan)); - JMETHOD(void, color_quantize, (j_decompress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPARRAY output_buf, - int num_rows)); - JMETHOD(void, finish_pass, (j_decompress_ptr cinfo)); - JMETHOD(void, new_color_map, (j_decompress_ptr cinfo)); -}; - - -/* Miscellaneous useful macros */ - -#undef MAX -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#undef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) - - -/* We assume that right shift corresponds to signed division by 2 with - * rounding towards minus infinity. This is correct for typical "arithmetic - * shift" instructions that shift in copies of the sign bit. But some - * C compilers implement >> with an unsigned shift. For these machines you - * must define RIGHT_SHIFT_IS_UNSIGNED. - * RIGHT_SHIFT provides a proper signed right shift of an INT32 quantity. - * It is only applied with constant shift counts. SHIFT_TEMPS must be - * included in the variables of any routine using RIGHT_SHIFT. - */ - -#ifdef RIGHT_SHIFT_IS_UNSIGNED -#define SHIFT_TEMPS INT32 shift_temp; -#define RIGHT_SHIFT(x,shft) \ - ((shift_temp = (x)) < 0 ? \ - (shift_temp >> (shft)) | ((~((INT32) 0)) << (32-(shft))) : \ - (shift_temp >> (shft))) -#else -#define SHIFT_TEMPS -#define RIGHT_SHIFT(x,shft) ((x) >> (shft)) -#endif - - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jinit_compress_master jICompress -#define jinit_c_master_control jICMaster -#define jinit_c_main_controller jICMainC -#define jinit_c_prep_controller jICPrepC -#define jinit_c_coef_controller jICCoefC -#define jinit_color_converter jICColor -#define jinit_downsampler jIDownsampler -#define jinit_forward_dct jIFDCT -#define jinit_huff_encoder jIHEncoder -#define jinit_phuff_encoder jIPHEncoder -#define jinit_marker_writer jIMWriter -#define jinit_master_decompress jIDMaster -#define jinit_d_main_controller jIDMainC -#define jinit_d_coef_controller jIDCoefC -#define jinit_d_post_controller jIDPostC -#define jinit_input_controller jIInCtlr -#define jinit_marker_reader jIMReader -#define jinit_huff_decoder jIHDecoder -#define jinit_phuff_decoder jIPHDecoder -#define jinit_inverse_dct jIIDCT -#define jinit_upsampler jIUpsampler -#define jinit_color_deconverter jIDColor -#define jinit_1pass_quantizer jI1Quant -#define jinit_2pass_quantizer jI2Quant -#define jinit_merged_upsampler jIMUpsampler -#define jinit_memory_mgr jIMemMgr -#define jdiv_round_up jDivRound -#define jround_up jRound -#define jcopy_sample_rows jCopySamples -#define jcopy_block_row jCopyBlocks -#define jzero_far jZeroFar -#define jpeg_zigzag_order jZIGTable -#define jpeg_natural_order jZAGTable -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - - -/* Compression module initialization routines */ -EXTERN(void) jinit_compress_master JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_c_master_control JPP((j_compress_ptr cinfo, - boolean transcode_only)); -EXTERN(void) jinit_c_main_controller JPP((j_compress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_c_prep_controller JPP((j_compress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_c_coef_controller JPP((j_compress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_color_converter JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_downsampler JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_forward_dct JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_huff_encoder JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_phuff_encoder JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_marker_writer JPP((j_compress_ptr cinfo)); -/* Decompression module initialization routines */ -EXTERN(void) jinit_master_decompress JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_d_main_controller JPP((j_decompress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_d_coef_controller JPP((j_decompress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_d_post_controller JPP((j_decompress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_input_controller JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_marker_reader JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_huff_decoder JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_phuff_decoder JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_inverse_dct JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_upsampler JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_color_deconverter JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_1pass_quantizer JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_2pass_quantizer JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_merged_upsampler JPP((j_decompress_ptr cinfo)); -/* Memory manager initialization */ -EXTERN(void) jinit_memory_mgr JPP((j_common_ptr cinfo)); - -/* Utility routines in jutils.c */ -EXTERN(long) jdiv_round_up JPP((long a, long b)); -EXTERN(long) jround_up JPP((long a, long b)); -EXTERN(void) jcopy_sample_rows JPP((JSAMPARRAY input_array, int source_row, - JSAMPARRAY output_array, int dest_row, - int num_rows, JDIMENSION num_cols)); -EXTERN(void) jcopy_block_row JPP((JBLOCKROW input_row, JBLOCKROW output_row, - JDIMENSION num_blocks)); -EXTERN(void) jzero_far JPP((void FAR * target, size_t bytestozero)); -/* Constant tables in jutils.c */ -extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */ -extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */ - -/* Suppress undefined-structure complaints if necessary. */ - -#ifdef INCOMPLETE_TYPES_BROKEN -#ifndef AM_MEMORY_MANAGER /* only jmemmgr.c defines these */ -struct jvirt_sarray_control { long dummy; }; -struct jvirt_barray_control { long dummy; }; -#endif -#endif /* INCOMPLETE_TYPES_BROKEN */ diff --git a/Utilities/CAI/cai_dll/inc/jpeglib.h b/Utilities/CAI/cai_dll/inc/jpeglib.h deleted file mode 100755 index d1be8ddeff1bfee59f56d3ea04379f4b6f4d1c0e..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/jpeglib.h +++ /dev/null @@ -1,1096 +0,0 @@ -/* - * jpeglib.h - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file defines the application interface for the JPEG library. - * Most applications using the library need only include this file, - * and perhaps jerror.h if they want to know the exact error codes. - */ - -#ifndef JPEGLIB_H -#define JPEGLIB_H - -/* - * First we include the configuration files that record how this - * installation of the JPEG library is set up. jconfig.h can be - * generated automatically for many systems. jmorecfg.h contains - * manual configuration options that most people need not worry about. - */ - -#ifndef JCONFIG_INCLUDED /* in case jinclude.h already did */ -#include "jconfig.h" /* widely used configuration options */ -#endif -#include "jmorecfg.h" /* seldom changed options */ - - -/* Version ID for the JPEG library. - * Might be useful for tests like "#if JPEG_LIB_VERSION >= 60". - */ - -#define JPEG_LIB_VERSION 62 /* Version 6b */ - - -/* Various constants determining the sizes of things. - * All of these are specified by the JPEG standard, so don't change them - * if you want to be compatible. - */ - -#define DCTSIZE 8 /* The basic DCT block is 8x8 samples */ -#define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */ -#define NUM_QUANT_TBLS 4 /* Quantization tables are numbered 0..3 */ -#define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */ -#define NUM_ARITH_TBLS 16 /* Arith-coding tables are numbered 0..15 */ -#define MAX_COMPS_IN_SCAN 4 /* JPEG limit on # of components in one scan */ -#define MAX_SAMP_FACTOR 4 /* JPEG limit on sampling factors */ -/* Unfortunately, some bozo at Adobe saw no reason to be bound by the standard; - * the PostScript DCT filter can emit files with many more than 10 blocks/MCU. - * If you happen to run across such a file, you can up D_MAX_BLOCKS_IN_MCU - * to handle it. We even let you do this from the jconfig.h file. However, - * we strongly discourage changing C_MAX_BLOCKS_IN_MCU; just because Adobe - * sometimes emits noncompliant files doesn't mean you should too. - */ -#define C_MAX_BLOCKS_IN_MCU 10 /* compressor's limit on blocks per MCU */ -#ifndef D_MAX_BLOCKS_IN_MCU -#define D_MAX_BLOCKS_IN_MCU 10 /* decompressor's limit on blocks per MCU */ -#endif - - -/* Data structures for images (arrays of samples and of DCT coefficients). - * On 80x86 machines, the image arrays are too big for near pointers, - * but the pointer arrays can fit in near memory. - */ - -typedef JSAMPLE FAR *JSAMPROW; /* ptr to one image row of pixel samples. */ -typedef JSAMPROW *JSAMPARRAY; /* ptr to some rows (a 2-D sample array) */ -typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */ - -typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */ -typedef JBLOCK FAR *JBLOCKROW; /* pointer to one row of coefficient blocks */ -typedef JBLOCKROW *JBLOCKARRAY; /* a 2-D array of coefficient blocks */ -typedef JBLOCKARRAY *JBLOCKIMAGE; /* a 3-D array of coefficient blocks */ - -typedef JCOEF FAR *JCOEFPTR; /* useful in a couple of places */ - - -/* Types for JPEG compression parameters and working tables. */ - - -/* DCT coefficient quantization tables. */ - -typedef struct { - /* This array gives the coefficient quantizers in natural array order - * (not the zigzag order in which they are stored in a JPEG DQT marker). - * CAUTION: IJG versions prior to v6a kept this array in zigzag order. - */ - UINT16 quantval[DCTSIZE2]; /* quantization step for each coefficient */ - /* This field is used only during compression. It's initialized FALSE when - * the table is created, and set TRUE when it's been output to the file. - * You could suppress output of a table by setting this to TRUE. - * (See jpeg_suppress_tables for an example.) - */ - boolean sent_table; /* TRUE when table has been output */ -} JQUANT_TBL; - - -/* Huffman coding tables. */ - -typedef struct { - /* These two fields directly represent the contents of a JPEG DHT marker */ - UINT8 bits[17]; /* bits[k] = # of symbols with codes of */ - /* length k bits; bits[0] is unused */ - UINT8 huffval[256]; /* The symbols, in order of incr code length */ - /* This field is used only during compression. It's initialized FALSE when - * the table is created, and set TRUE when it's been output to the file. - * You could suppress output of a table by setting this to TRUE. - * (See jpeg_suppress_tables for an example.) - */ - boolean sent_table; /* TRUE when table has been output */ -} JHUFF_TBL; - - -/* Basic info about one component (color channel). */ - -typedef struct { - /* These values are fixed over the whole image. */ - /* For compression, they must be supplied by parameter setup; */ - /* for decompression, they are read from the SOF marker. */ - int component_id; /* identifier for this component (0..255) */ - int component_index; /* its index in SOF or cinfo->comp_info[] */ - int h_samp_factor; /* horizontal sampling factor (1..4) */ - int v_samp_factor; /* vertical sampling factor (1..4) */ - int quant_tbl_no; /* quantization table selector (0..3) */ - /* These values may vary between scans. */ - /* For compression, they must be supplied by parameter setup; */ - /* for decompression, they are read from the SOS marker. */ - /* The decompressor output side may not use these variables. */ - int dc_tbl_no; /* DC entropy table selector (0..3) */ - int ac_tbl_no; /* AC entropy table selector (0..3) */ - - /* Remaining fields should be treated as private by applications. */ - - /* These values are computed during compression or decompression startup: */ - /* Component's size in DCT blocks. - * Any dummy blocks added to complete an MCU are not counted; therefore - * these values do not depend on whether a scan is interleaved or not. - */ - JDIMENSION width_in_blocks; - JDIMENSION height_in_blocks; - /* Size of a DCT block in samples. Always DCTSIZE for compression. - * For decompression this is the size of the output from one DCT block, - * reflecting any scaling we choose to apply during the IDCT step. - * Values of 1,2,4,8 are likely to be supported. Note that different - * components may receive different IDCT scalings. - */ - int DCT_scaled_size; - /* The downsampled dimensions are the component's actual, unpadded number - * of samples at the main buffer (preprocessing/compression interface), thus - * downsampled_width = ceil(image_width * Hi/Hmax) - * and similarly for height. For decompression, IDCT scaling is included, so - * downsampled_width = ceil(image_width * Hi/Hmax * DCT_scaled_size/DCTSIZE) - */ - JDIMENSION downsampled_width; /* actual width in samples */ - JDIMENSION downsampled_height; /* actual height in samples */ - /* This flag is used only for decompression. In cases where some of the - * components will be ignored (eg grayscale output from YCbCr image), - * we can skip most computations for the unused components. - */ - boolean component_needed; /* do we need the value of this component? */ - - /* These values are computed before starting a scan of the component. */ - /* The decompressor output side may not use these variables. */ - int MCU_width; /* number of blocks per MCU, horizontally */ - int MCU_height; /* number of blocks per MCU, vertically */ - int MCU_blocks; /* MCU_width * MCU_height */ - int MCU_sample_width; /* MCU width in samples, MCU_width*DCT_scaled_size */ - int last_col_width; /* # of non-dummy blocks across in last MCU */ - int last_row_height; /* # of non-dummy blocks down in last MCU */ - - /* Saved quantization table for component; NULL if none yet saved. - * See jdinput.c comments about the need for this information. - * This field is currently used only for decompression. - */ - JQUANT_TBL * quant_table; - - /* Private per-component storage for DCT or IDCT subsystem. */ - void * dct_table; -} jpeg_component_info; - - -/* The script for encoding a multiple-scan file is an array of these: */ - -typedef struct { - int comps_in_scan; /* number of components encoded in this scan */ - int component_index[MAX_COMPS_IN_SCAN]; /* their SOF/comp_info[] indexes */ - int Ss, Se; /* progressive JPEG spectral selection parms */ - int Ah, Al; /* progressive JPEG successive approx. parms */ -} jpeg_scan_info; - -/* The decompressor can save APPn and COM markers in a list of these: */ - -typedef struct jpeg_marker_struct FAR * jpeg_saved_marker_ptr; - -struct jpeg_marker_struct { - jpeg_saved_marker_ptr next; /* next in list, or NULL */ - UINT8 marker; /* marker code: JPEG_COM, or JPEG_APP0+n */ - unsigned int original_length; /* # bytes of data in the file */ - unsigned int data_length; /* # bytes of data saved at data[] */ - JOCTET FAR * data; /* the data contained in the marker */ - /* the marker length word is not counted in data_length or original_length */ -}; - -/* Known color spaces. */ - -typedef enum { - JCS_UNKNOWN, /* error/unspecified */ - JCS_GRAYSCALE, /* monochrome */ - JCS_RGB, /* red/green/blue */ - JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */ - JCS_CMYK, /* C/M/Y/K */ - JCS_YCCK /* Y/Cb/Cr/K */ -} J_COLOR_SPACE; - -/* DCT/IDCT algorithm options. */ - -typedef enum { - JDCT_ISLOW, /* slow but accurate integer algorithm */ - JDCT_IFAST, /* faster, less accurate integer method */ - JDCT_FLOAT /* floating-point: accurate, fast on fast HW */ -} J_DCT_METHOD; - -#ifndef JDCT_DEFAULT /* may be overridden in jconfig.h */ -#define JDCT_DEFAULT JDCT_ISLOW -#endif -#ifndef JDCT_FASTEST /* may be overridden in jconfig.h */ -#define JDCT_FASTEST JDCT_IFAST -#endif - -/* Dithering options for decompression. */ - -typedef enum { - JDITHER_NONE, /* no dithering */ - JDITHER_ORDERED, /* simple ordered dither */ - JDITHER_FS /* Floyd-Steinberg error diffusion dither */ -} J_DITHER_MODE; - - -/* Common fields between JPEG compression and decompression master structs. */ - -#define jpeg_common_fields \ - struct jpeg_error_mgr * err; /* Error handler module */\ - struct jpeg_memory_mgr * mem; /* Memory manager module */\ - struct jpeg_progress_mgr * progress; /* Progress monitor, or NULL if none */\ - void * client_data; /* Available for use by application */\ - boolean is_decompressor; /* So common code can tell which is which */\ - int global_state /* For checking call sequence validity */ - -/* Routines that are to be used by both halves of the library are declared - * to receive a pointer to this structure. There are no actual instances of - * jpeg_common_struct, only of jpeg_compress_struct and jpeg_decompress_struct. - */ -struct jpeg_common_struct { - jpeg_common_fields; /* Fields common to both master struct types */ - /* Additional fields follow in an actual jpeg_compress_struct or - * jpeg_decompress_struct. All three structs must agree on these - * initial fields! (This would be a lot cleaner in C++.) - */ -}; - -typedef struct jpeg_common_struct * j_common_ptr; -typedef struct jpeg_compress_struct * j_compress_ptr; -typedef struct jpeg_decompress_struct * j_decompress_ptr; - - -/* Master record for a compression instance */ - -struct jpeg_compress_struct { - jpeg_common_fields; /* Fields shared with jpeg_decompress_struct */ - - /* Destination for compressed data */ - struct jpeg_destination_mgr * dest; - - /* Description of source image --- these fields must be filled in by - * outer application before starting compression. in_color_space must - * be correct before you can even call jpeg_set_defaults(). - */ - - JDIMENSION image_width; /* input image width */ - JDIMENSION image_height; /* input image height */ - int input_components; /* # of color components in input image */ - J_COLOR_SPACE in_color_space; /* colorspace of input image */ - - double input_gamma; /* image gamma of input image */ - - /* Compression parameters --- these fields must be set before calling - * jpeg_start_compress(). We recommend calling jpeg_set_defaults() to - * initialize everything to reasonable defaults, then changing anything - * the application specifically wants to change. That way you won't get - * burnt when new parameters are added. Also note that there are several - * helper routines to simplify changing parameters. - */ - - int data_precision; /* bits of precision in image data */ - - int num_components; /* # of color components in JPEG image */ - J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ - - jpeg_component_info * comp_info; - /* comp_info[i] describes component that appears i'th in SOF */ - - JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; - /* ptrs to coefficient quantization tables, or NULL if not defined */ - - JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; - JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; - /* ptrs to Huffman coding tables, or NULL if not defined */ - - UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ - UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ - UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ - - int num_scans; /* # of entries in scan_info array */ - const jpeg_scan_info * scan_info; /* script for multi-scan file, or NULL */ - /* The default value of scan_info is NULL, which causes a single-scan - * sequential JPEG file to be emitted. To create a multi-scan file, - * set num_scans and scan_info to point to an array of scan definitions. - */ - - boolean raw_data_in; /* TRUE=caller supplies downsampled data */ - boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ - boolean optimize_coding; /* TRUE=optimize entropy encoding parms */ - boolean CCIR601_sampling; /* TRUE=first samples are cosited */ - int smoothing_factor; /* 1..100, or 0 for no input smoothing */ - J_DCT_METHOD dct_method; /* DCT algorithm selector */ - - /* The restart interval can be specified in absolute MCUs by setting - * restart_interval, or in MCU rows by setting restart_in_rows - * (in which case the correct restart_interval will be figured - * for each scan). - */ - unsigned int restart_interval; /* MCUs per restart, or 0 for no restart */ - int restart_in_rows; /* if > 0, MCU rows per restart interval */ - - /* Parameters controlling emission of special markers. */ - - boolean write_JFIF_header; /* should a JFIF marker be written? */ - UINT8 JFIF_major_version; /* What to write for the JFIF version number */ - UINT8 JFIF_minor_version; - /* These three values are not used by the JPEG code, merely copied */ - /* into the JFIF APP0 marker. density_unit can be 0 for unknown, */ - /* 1 for dots/inch, or 2 for dots/cm. Note that the pixel aspect */ - /* ratio is defined by X_density/Y_density even when density_unit=0. */ - UINT8 density_unit; /* JFIF code for pixel size units */ - UINT16 X_density; /* Horizontal pixel density */ - UINT16 Y_density; /* Vertical pixel density */ - boolean write_Adobe_marker; /* should an Adobe marker be written? */ - - /* State variable: index of next scanline to be written to - * jpeg_write_scanlines(). Application may use this to control its - * processing loop, e.g., "while (next_scanline < image_height)". - */ - - JDIMENSION next_scanline; /* 0 .. image_height-1 */ - - /* Remaining fields are known throughout compressor, but generally - * should not be touched by a surrounding application. - */ - - /* - * These fields are computed during compression startup - */ - boolean progressive_mode; /* TRUE if scan script uses progressive mode */ - int max_h_samp_factor; /* largest h_samp_factor */ - int max_v_samp_factor; /* largest v_samp_factor */ - - JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */ - /* The coefficient controller receives data in units of MCU rows as defined - * for fully interleaved scans (whether the JPEG file is interleaved or not). - * There are v_samp_factor * DCTSIZE sample rows of each component in an - * "iMCU" (interleaved MCU) row. - */ - - /* - * These fields are valid during any one scan. - * They describe the components and MCUs actually appearing in the scan. - */ - int comps_in_scan; /* # of JPEG components in this scan */ - jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; - /* *cur_comp_info[i] describes component that appears i'th in SOS */ - - JDIMENSION MCUs_per_row; /* # of MCUs across the image */ - JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ - - int blocks_in_MCU; /* # of DCT blocks per MCU */ - int MCU_membership[C_MAX_BLOCKS_IN_MCU]; - /* MCU_membership[i] is index in cur_comp_info of component owning */ - /* i'th block in an MCU */ - - int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ - - /* - * Links to compression subobjects (methods and private variables of modules) - */ - struct jpeg_comp_master * master; - struct jpeg_c_main_controller * main; - struct jpeg_c_prep_controller * prep; - struct jpeg_c_coef_controller * coef; - struct jpeg_marker_writer * marker; - struct jpeg_color_converter * cconvert; - struct jpeg_downsampler * downsample; - struct jpeg_forward_dct * fdct; - struct jpeg_entropy_encoder * entropy; - jpeg_scan_info * script_space; /* workspace for jpeg_simple_progression */ - int script_space_size; -}; - - -/* Master record for a decompression instance */ - -struct jpeg_decompress_struct { - jpeg_common_fields; /* Fields shared with jpeg_compress_struct */ - - /* Source of compressed data */ - struct jpeg_source_mgr * src; - - /* Basic description of image --- filled in by jpeg_read_header(). */ - /* Application may inspect these values to decide how to process image. */ - - JDIMENSION image_width; /* nominal image width (from SOF marker) */ - JDIMENSION image_height; /* nominal image height */ - int num_components; /* # of color components in JPEG image */ - J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ - - /* Decompression processing parameters --- these fields must be set before - * calling jpeg_start_decompress(). Note that jpeg_read_header() initializes - * them to default values. - */ - - J_COLOR_SPACE out_color_space; /* colorspace for output */ - - unsigned int scale_num, scale_denom; /* fraction by which to scale image */ - - double output_gamma; /* image gamma wanted in output */ - - boolean buffered_image; /* TRUE=multiple output passes */ - boolean raw_data_out; /* TRUE=downsampled data wanted */ - - J_DCT_METHOD dct_method; /* IDCT algorithm selector */ - boolean do_fancy_upsampling; /* TRUE=apply fancy upsampling */ - boolean do_block_smoothing; /* TRUE=apply interblock smoothing */ - - boolean quantize_colors; /* TRUE=colormapped output wanted */ - /* the following are ignored if not quantize_colors: */ - J_DITHER_MODE dither_mode; /* type of color dithering to use */ - boolean two_pass_quantize; /* TRUE=use two-pass color quantization */ - int desired_number_of_colors; /* max # colors to use in created colormap */ - /* these are significant only in buffered-image mode: */ - boolean enable_1pass_quant; /* enable future use of 1-pass quantizer */ - boolean enable_external_quant;/* enable future use of external colormap */ - boolean enable_2pass_quant; /* enable future use of 2-pass quantizer */ - - /* Description of actual output image that will be returned to application. - * These fields are computed by jpeg_start_decompress(). - * You can also use jpeg_calc_output_dimensions() to determine these values - * in advance of calling jpeg_start_decompress(). - */ - - JDIMENSION output_width; /* scaled image width */ - JDIMENSION output_height; /* scaled image height */ - int out_color_components; /* # of color components in out_color_space */ - int output_components; /* # of color components returned */ - /* output_components is 1 (a colormap index) when quantizing colors; - * otherwise it equals out_color_components. - */ - int rec_outbuf_height; /* min recommended height of scanline buffer */ - /* If the buffer passed to jpeg_read_scanlines() is less than this many rows - * high, space and time will be wasted due to unnecessary data copying. - * Usually rec_outbuf_height will be 1 or 2, at most 4. - */ - - /* When quantizing colors, the output colormap is described by these fields. - * The application can supply a colormap by setting colormap non-NULL before - * calling jpeg_start_decompress; otherwise a colormap is created during - * jpeg_start_decompress or jpeg_start_output. - * The map has out_color_components rows and actual_number_of_colors columns. - */ - int actual_number_of_colors; /* number of entries in use */ - JSAMPARRAY colormap; /* The color map as a 2-D pixel array */ - - /* State variables: these variables indicate the progress of decompression. - * The application may examine these but must not modify them. - */ - - /* Row index of next scanline to be read from jpeg_read_scanlines(). - * Application may use this to control its processing loop, e.g., - * "while (output_scanline < output_height)". - */ - JDIMENSION output_scanline; /* 0 .. output_height-1 */ - - /* Current input scan number and number of iMCU rows completed in scan. - * These indicate the progress of the decompressor input side. - */ - int input_scan_number; /* Number of SOS markers seen so far */ - JDIMENSION input_iMCU_row; /* Number of iMCU rows completed */ - - /* The "output scan number" is the notional scan being displayed by the - * output side. The decompressor will not allow output scan/row number - * to get ahead of input scan/row, but it can fall arbitrarily far behind. - */ - int output_scan_number; /* Nominal scan number being displayed */ - JDIMENSION output_iMCU_row; /* Number of iMCU rows read */ - - /* Current progression status. coef_bits[c][i] indicates the precision - * with which component c's DCT coefficient i (in zigzag order) is known. - * It is -1 when no data has yet been received, otherwise it is the point - * transform (shift) value for the most recent scan of the coefficient - * (thus, 0 at completion of the progression). - * This pointer is NULL when reading a non-progressive file. - */ - int (*coef_bits)[DCTSIZE2]; /* -1 or current Al value for each coef */ - - /* Internal JPEG parameters --- the application usually need not look at - * these fields. Note that the decompressor output side may not use - * any parameters that can change between scans. - */ - - /* Quantization and Huffman tables are carried forward across input - * datastreams when processing abbreviated JPEG datastreams. - */ - - JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; - /* ptrs to coefficient quantization tables, or NULL if not defined */ - - JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; - JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; - /* ptrs to Huffman coding tables, or NULL if not defined */ - - /* These parameters are never carried across datastreams, since they - * are given in SOF/SOS markers or defined to be reset by SOI. - */ - - int data_precision; /* bits of precision in image data */ - - jpeg_component_info * comp_info; - /* comp_info[i] describes component that appears i'th in SOF */ - - boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */ - boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ - - UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ - UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ - UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ - - unsigned int restart_interval; /* MCUs per restart interval, or 0 for no restart */ - - /* These fields record data obtained from optional markers recognized by - * the JPEG library. - */ - boolean saw_JFIF_marker; /* TRUE iff a JFIF APP0 marker was found */ - /* Data copied from JFIF marker; only valid if saw_JFIF_marker is TRUE: */ - UINT8 JFIF_major_version; /* JFIF version number */ - UINT8 JFIF_minor_version; - UINT8 density_unit; /* JFIF code for pixel size units */ - UINT16 X_density; /* Horizontal pixel density */ - UINT16 Y_density; /* Vertical pixel density */ - boolean saw_Adobe_marker; /* TRUE iff an Adobe APP14 marker was found */ - UINT8 Adobe_transform; /* Color transform code from Adobe marker */ - - boolean CCIR601_sampling; /* TRUE=first samples are cosited */ - - /* Aside from the specific data retained from APPn markers known to the - * library, the uninterpreted contents of any or all APPn and COM markers - * can be saved in a list for examination by the application. - */ - jpeg_saved_marker_ptr marker_list; /* Head of list of saved markers */ - - /* Remaining fields are known throughout decompressor, but generally - * should not be touched by a surrounding application. - */ - - /* - * These fields are computed during decompression startup - */ - int max_h_samp_factor; /* largest h_samp_factor */ - int max_v_samp_factor; /* largest v_samp_factor */ - - int min_DCT_scaled_size; /* smallest DCT_scaled_size of any component */ - - JDIMENSION total_iMCU_rows; /* # of iMCU rows in image */ - /* The coefficient controller's input and output progress is measured in - * units of "iMCU" (interleaved MCU) rows. These are the same as MCU rows - * in fully interleaved JPEG scans, but are used whether the scan is - * interleaved or not. We define an iMCU row as v_samp_factor DCT block - * rows of each component. Therefore, the IDCT output contains - * v_samp_factor*DCT_scaled_size sample rows of a component per iMCU row. - */ - - JSAMPLE * sample_range_limit; /* table for fast range-limiting */ - - /* - * These fields are valid during any one scan. - * They describe the components and MCUs actually appearing in the scan. - * Note that the decompressor output side must not use these fields. - */ - int comps_in_scan; /* # of JPEG components in this scan */ - jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; - /* *cur_comp_info[i] describes component that appears i'th in SOS */ - - JDIMENSION MCUs_per_row; /* # of MCUs across the image */ - JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ - - int blocks_in_MCU; /* # of DCT blocks per MCU */ - int MCU_membership[D_MAX_BLOCKS_IN_MCU]; - /* MCU_membership[i] is index in cur_comp_info of component owning */ - /* i'th block in an MCU */ - - int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ - - /* This field is shared between entropy decoder and marker parser. - * It is either zero or the code of a JPEG marker that has been - * read from the data source, but has not yet been processed. - */ - int unread_marker; - - /* - * Links to decompression subobjects (methods, private variables of modules) - */ - struct jpeg_decomp_master * master; - struct jpeg_d_main_controller * main; - struct jpeg_d_coef_controller * coef; - struct jpeg_d_post_controller * post; - struct jpeg_input_controller * inputctl; - struct jpeg_marker_reader * marker; - struct jpeg_entropy_decoder * entropy; - struct jpeg_inverse_dct * idct; - struct jpeg_upsampler * upsample; - struct jpeg_color_deconverter * cconvert; - struct jpeg_color_quantizer * cquantize; -}; - - -/* "Object" declarations for JPEG modules that may be supplied or called - * directly by the surrounding application. - * As with all objects in the JPEG library, these structs only define the - * publicly visible methods and state variables of a module. Additional - * private fields may exist after the public ones. - */ - - -/* Error handler object */ - -struct jpeg_error_mgr { - /* Error exit handler: does not return to caller */ - JMETHOD(void, error_exit, (j_common_ptr cinfo)); - /* Conditionally emit a trace or warning message */ - JMETHOD(void, emit_message, (j_common_ptr cinfo, int msg_level)); - /* Routine that actually outputs a trace or error message */ - JMETHOD(void, output_message, (j_common_ptr cinfo)); - /* Format a message string for the most recent JPEG error or message */ - JMETHOD(void, format_message, (j_common_ptr cinfo, char * buffer)); -#define JMSG_LENGTH_MAX 200 /* recommended size of format_message buffer */ - /* Reset error state variables at start of a new image */ - JMETHOD(void, reset_error_mgr, (j_common_ptr cinfo)); - - /* The message ID code and any parameters are saved here. - * A message can have one string parameter or up to 8 int parameters. - */ - int msg_code; -#define JMSG_STR_PARM_MAX 80 - union { - int i[8]; - char s[JMSG_STR_PARM_MAX]; - } msg_parm; - - /* Standard state variables for error facility */ - - int trace_level; /* max msg_level that will be displayed */ - - /* For recoverable corrupt-data errors, we emit a warning message, - * but keep going unless emit_message chooses to abort. emit_message - * should count warnings in num_warnings. The surrounding application - * can check for bad data by seeing if num_warnings is nonzero at the - * end of processing. - */ - long num_warnings; /* number of corrupt-data warnings */ - - /* These fields point to the table(s) of error message strings. - * An application can change the table pointer to switch to a different - * message list (typically, to change the language in which errors are - * reported). Some applications may wish to add additional error codes - * that will be handled by the JPEG library error mechanism; the second - * table pointer is used for this purpose. - * - * First table includes all errors generated by JPEG library itself. - * Error code 0 is reserved for a "no such error string" message. - */ - const char * const * jpeg_message_table; /* Library errors */ - int last_jpeg_message; /* Table contains strings 0..last_jpeg_message */ - /* Second table can be added by application (see cjpeg/djpeg for example). - * It contains strings numbered first_addon_message..last_addon_message. - */ - const char * const * addon_message_table; /* Non-library errors */ - int first_addon_message; /* code for first string in addon table */ - int last_addon_message; /* code for last string in addon table */ -}; - - -/* Progress monitor object */ - -struct jpeg_progress_mgr { - JMETHOD(void, progress_monitor, (j_common_ptr cinfo)); - - long pass_counter; /* work units completed in this pass */ - long pass_limit; /* total number of work units in this pass */ - int completed_passes; /* passes completed so far */ - int total_passes; /* total number of passes expected */ -}; - - -/* Data destination object for compression */ - -struct jpeg_destination_mgr { - JOCTET * next_output_byte; /* => next byte to write in buffer */ - size_t free_in_buffer; /* # of byte spaces remaining in buffer */ - - JMETHOD(void, init_destination, (j_compress_ptr cinfo)); - JMETHOD(boolean, empty_output_buffer, (j_compress_ptr cinfo)); - JMETHOD(void, term_destination, (j_compress_ptr cinfo)); -}; - - -/* Data source object for decompression */ - -struct jpeg_source_mgr { - const JOCTET * next_input_byte; /* => next byte to read from buffer */ - size_t bytes_in_buffer; /* # of bytes remaining in buffer */ - - JMETHOD(void, init_source, (j_decompress_ptr cinfo)); - JMETHOD(boolean, fill_input_buffer, (j_decompress_ptr cinfo)); - JMETHOD(void, skip_input_data, (j_decompress_ptr cinfo, long num_bytes)); - JMETHOD(boolean, resync_to_restart, (j_decompress_ptr cinfo, int desired)); - JMETHOD(void, term_source, (j_decompress_ptr cinfo)); -}; - - -/* Memory manager object. - * Allocates "small" objects (a few K total), "large" objects (tens of K), - * and "really big" objects (virtual arrays with backing store if needed). - * The memory manager does not allow individual objects to be freed; rather, - * each created object is assigned to a pool, and whole pools can be freed - * at once. This is faster and more convenient than remembering exactly what - * to free, especially where malloc()/free() are not too speedy. - * NB: alloc routines never return NULL. They exit to error_exit if not - * successful. - */ - -#define JPOOL_PERMANENT 0 /* lasts until master record is destroyed */ -#define JPOOL_IMAGE 1 /* lasts until done with image/datastream */ -#define JPOOL_NUMPOOLS 2 - -typedef struct jvirt_sarray_control * jvirt_sarray_ptr; -typedef struct jvirt_barray_control * jvirt_barray_ptr; - - -struct jpeg_memory_mgr { - /* Method pointers */ - JMETHOD(void *, alloc_small, (j_common_ptr cinfo, int pool_id, - size_t sizeofobject)); - JMETHOD(void FAR *, alloc_large, (j_common_ptr cinfo, int pool_id, - size_t sizeofobject)); - JMETHOD(JSAMPARRAY, alloc_sarray, (j_common_ptr cinfo, int pool_id, - JDIMENSION samplesperrow, - JDIMENSION numrows)); - JMETHOD(JBLOCKARRAY, alloc_barray, (j_common_ptr cinfo, int pool_id, - JDIMENSION blocksperrow, - JDIMENSION numrows)); - JMETHOD(jvirt_sarray_ptr, request_virt_sarray, (j_common_ptr cinfo, - int pool_id, - boolean pre_zero, - JDIMENSION samplesperrow, - JDIMENSION numrows, - JDIMENSION maxaccess)); - JMETHOD(jvirt_barray_ptr, request_virt_barray, (j_common_ptr cinfo, - int pool_id, - boolean pre_zero, - JDIMENSION blocksperrow, - JDIMENSION numrows, - JDIMENSION maxaccess)); - JMETHOD(void, realize_virt_arrays, (j_common_ptr cinfo)); - JMETHOD(JSAMPARRAY, access_virt_sarray, (j_common_ptr cinfo, - jvirt_sarray_ptr ptr, - JDIMENSION start_row, - JDIMENSION num_rows, - boolean writable)); - JMETHOD(JBLOCKARRAY, access_virt_barray, (j_common_ptr cinfo, - jvirt_barray_ptr ptr, - JDIMENSION start_row, - JDIMENSION num_rows, - boolean writable)); - JMETHOD(void, free_pool, (j_common_ptr cinfo, int pool_id)); - JMETHOD(void, self_destruct, (j_common_ptr cinfo)); - - /* Limit on memory allocation for this JPEG object. (Note that this is - * merely advisory, not a guaranteed maximum; it only affects the space - * used for virtual-array buffers.) May be changed by outer application - * after creating the JPEG object. - */ - long max_memory_to_use; - - /* Maximum allocation request accepted by alloc_large. */ - long max_alloc_chunk; -}; - - -/* Routine signature for application-supplied marker processing methods. - * Need not pass marker code since it is stored in cinfo->unread_marker. - */ -typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo)); - - -/* Declarations for routines called by application. - * The JPP macro hides prototype parameters from compilers that can't cope. - * Note JPP requires double parentheses. - */ - -#ifdef HAVE_PROTOTYPES -#define JPP(arglist) arglist -#else -#define JPP(arglist) () -#endif - - -/* Short forms of external names for systems with brain-damaged linkers. - * We shorten external names to be unique in the first six letters, which - * is good enough for all known systems. - * (If your compiler itself needs names to be unique in less than 15 - * characters, you are out of luck. Get a better compiler.) - */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_std_error jStdError -#define jpeg_CreateCompress jCreaCompress -#define jpeg_CreateDecompress jCreaDecompress -#define jpeg_destroy_compress jDestCompress -#define jpeg_destroy_decompress jDestDecompress -#define jpeg_stdio_dest jStdDest -#define jpeg_stdio_src jStdSrc -#define jpeg_set_defaults jSetDefaults -#define jpeg_set_colorspace jSetColorspace -#define jpeg_default_colorspace jDefColorspace -#define jpeg_set_quality jSetQuality -#define jpeg_set_linear_quality jSetLQuality -#define jpeg_add_quant_table jAddQuantTable -#define jpeg_quality_scaling jQualityScaling -#define jpeg_simple_progression jSimProgress -#define jpeg_suppress_tables jSuppressTables -#define jpeg_alloc_quant_table jAlcQTable -#define jpeg_alloc_huff_table jAlcHTable -#define jpeg_start_compress jStrtCompress -#define jpeg_write_scanlines jWrtScanlines -#define jpeg_finish_compress jFinCompress -#define jpeg_write_raw_data jWrtRawData -#define jpeg_write_marker jWrtMarker -#define jpeg_write_m_header jWrtMHeader -#define jpeg_write_m_byte jWrtMByte -#define jpeg_write_tables jWrtTables -#define jpeg_read_header jReadHeader -#define jpeg_start_decompress jStrtDecompress -#define jpeg_read_scanlines jReadScanlines -#define jpeg_finish_decompress jFinDecompress -#define jpeg_read_raw_data jReadRawData -#define jpeg_has_multiple_scans jHasMultScn -#define jpeg_start_output jStrtOutput -#define jpeg_finish_output jFinOutput -#define jpeg_input_complete jInComplete -#define jpeg_new_colormap jNewCMap -#define jpeg_consume_input jConsumeInput -#define jpeg_calc_output_dimensions jCalcDimensions -#define jpeg_save_markers jSaveMarkers -#define jpeg_set_marker_processor jSetMarker -#define jpeg_read_coefficients jReadCoefs -#define jpeg_write_coefficients jWrtCoefs -#define jpeg_copy_critical_parameters jCopyCrit -#define jpeg_abort_compress jAbrtCompress -#define jpeg_abort_decompress jAbrtDecompress -#define jpeg_abort jAbort -#define jpeg_destroy jDestroy -#define jpeg_resync_to_restart jResyncRestart -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - - -/* Default error-management setup */ -EXTERN(struct jpeg_error_mgr *) jpeg_std_error - JPP((struct jpeg_error_mgr * err)); - -/* Initialization of JPEG compression objects. - * jpeg_create_compress() and jpeg_create_decompress() are the exported - * names that applications should call. These expand to calls on - * jpeg_CreateCompress and jpeg_CreateDecompress with additional information - * passed for version mismatch checking. - * NB: you must set up the error-manager BEFORE calling jpeg_create_xxx. - */ -#define jpeg_create_compress(cinfo) \ - jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \ - (size_t) sizeof(struct jpeg_compress_struct)) -#define jpeg_create_decompress(cinfo) \ - jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \ - (size_t) sizeof(struct jpeg_decompress_struct)) -EXTERN(void) jpeg_CreateCompress JPP((j_compress_ptr cinfo, - int version, size_t structsize)); -EXTERN(void) jpeg_CreateDecompress JPP((j_decompress_ptr cinfo, - int version, size_t structsize)); -/* Destruction of JPEG compression objects */ -EXTERN(void) jpeg_destroy_compress JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_destroy_decompress JPP((j_decompress_ptr cinfo)); - -/* Standard data source and destination managers: stdio streams. */ -/* Caller is responsible for opening the file before and closing after. */ -EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile)); -EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile)); - -/* Default parameter setup for compression */ -EXTERN(void) jpeg_set_defaults JPP((j_compress_ptr cinfo)); -/* Compression parameter setup aids */ -EXTERN(void) jpeg_set_colorspace JPP((j_compress_ptr cinfo, - J_COLOR_SPACE colorspace)); -EXTERN(void) jpeg_default_colorspace JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_set_quality JPP((j_compress_ptr cinfo, int quality, - boolean force_baseline)); -EXTERN(void) jpeg_set_linear_quality JPP((j_compress_ptr cinfo, - int scale_factor, - boolean force_baseline)); -EXTERN(void) jpeg_add_quant_table JPP((j_compress_ptr cinfo, int which_tbl, - const unsigned int *basic_table, - int scale_factor, - boolean force_baseline)); -EXTERN(int) jpeg_quality_scaling JPP((int quality)); -EXTERN(void) jpeg_simple_progression JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_suppress_tables JPP((j_compress_ptr cinfo, - boolean suppress)); -EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table JPP((j_common_ptr cinfo)); -EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table JPP((j_common_ptr cinfo)); - -/* Main entry points for compression */ -EXTERN(void) jpeg_start_compress JPP((j_compress_ptr cinfo, - boolean write_all_tables)); -EXTERN(JDIMENSION) jpeg_write_scanlines JPP((j_compress_ptr cinfo, - JSAMPARRAY scanlines, - JDIMENSION num_lines)); -EXTERN(void) jpeg_finish_compress JPP((j_compress_ptr cinfo)); - -/* Replaces jpeg_write_scanlines when writing raw downsampled data. */ -EXTERN(JDIMENSION) jpeg_write_raw_data JPP((j_compress_ptr cinfo, - JSAMPIMAGE data, - JDIMENSION num_lines)); - -/* Write a special marker. See libjpeg.doc concerning safe usage. */ -EXTERN(void) jpeg_write_marker - JPP((j_compress_ptr cinfo, int marker, - const JOCTET * dataptr, unsigned int datalen)); -/* Same, but piecemeal. */ -EXTERN(void) jpeg_write_m_header - JPP((j_compress_ptr cinfo, int marker, unsigned int datalen)); -EXTERN(void) jpeg_write_m_byte - JPP((j_compress_ptr cinfo, int val)); - -/* Alternate compression function: just write an abbreviated table file */ -EXTERN(void) jpeg_write_tables JPP((j_compress_ptr cinfo)); - -/* Decompression startup: read start of JPEG datastream to see what's there */ -EXTERN(int) jpeg_read_header JPP((j_decompress_ptr cinfo, - boolean require_image)); -/* Return value is one of: */ -#define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */ -#define JPEG_HEADER_OK 1 /* Found valid image datastream */ -#define JPEG_HEADER_TABLES_ONLY 2 /* Found valid table-specs-only datastream */ -/* If you pass require_image = TRUE (normal case), you need not check for - * a TABLES_ONLY return code; an abbreviated file will cause an error exit. - * JPEG_SUSPENDED is only possible if you use a data source module that can - * give a suspension return (the stdio source module doesn't). - */ - -/* Main entry points for decompression */ -EXTERN(boolean) jpeg_start_decompress JPP((j_decompress_ptr cinfo)); -EXTERN(JDIMENSION) jpeg_read_scanlines JPP((j_decompress_ptr cinfo, - JSAMPARRAY scanlines, - JDIMENSION max_lines)); -EXTERN(boolean) jpeg_finish_decompress JPP((j_decompress_ptr cinfo)); - -/* Replaces jpeg_read_scanlines when reading raw downsampled data. */ -EXTERN(JDIMENSION) jpeg_read_raw_data JPP((j_decompress_ptr cinfo, - JSAMPIMAGE data, - JDIMENSION max_lines)); - -/* Additional entry points for buffered-image mode. */ -EXTERN(boolean) jpeg_has_multiple_scans JPP((j_decompress_ptr cinfo)); -EXTERN(boolean) jpeg_start_output JPP((j_decompress_ptr cinfo, - int scan_number)); -EXTERN(boolean) jpeg_finish_output JPP((j_decompress_ptr cinfo)); -EXTERN(boolean) jpeg_input_complete JPP((j_decompress_ptr cinfo)); -EXTERN(void) jpeg_new_colormap JPP((j_decompress_ptr cinfo)); -EXTERN(int) jpeg_consume_input JPP((j_decompress_ptr cinfo)); -/* Return value is one of: */ -/* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */ -#define JPEG_REACHED_SOS 1 /* Reached start of new scan */ -#define JPEG_REACHED_EOI 2 /* Reached end of image */ -#define JPEG_ROW_COMPLETED 3 /* Completed one iMCU row */ -#define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */ - -/* Precalculate output dimensions for current decompression parameters. */ -EXTERN(void) jpeg_calc_output_dimensions JPP((j_decompress_ptr cinfo)); - -/* Control saving of COM and APPn markers into marker_list. */ -EXTERN(void) jpeg_save_markers - JPP((j_decompress_ptr cinfo, int marker_code, - unsigned int length_limit)); - -/* Install a special processing method for COM or APPn markers. */ -EXTERN(void) jpeg_set_marker_processor - JPP((j_decompress_ptr cinfo, int marker_code, - jpeg_marker_parser_method routine)); - -/* Read or write raw DCT coefficients --- useful for lossless transcoding. */ -EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients JPP((j_decompress_ptr cinfo)); -EXTERN(void) jpeg_write_coefficients JPP((j_compress_ptr cinfo, - jvirt_barray_ptr * coef_arrays)); -EXTERN(void) jpeg_copy_critical_parameters JPP((j_decompress_ptr srcinfo, - j_compress_ptr dstinfo)); - -/* If you choose to abort compression or decompression before completing - * jpeg_finish_(de)compress, then you need to clean up to release memory, - * temporary files, etc. You can just call jpeg_destroy_(de)compress - * if you're done with the JPEG object, but if you want to clean it up and - * reuse it, call this: - */ -EXTERN(void) jpeg_abort_compress JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_abort_decompress JPP((j_decompress_ptr cinfo)); - -/* Generic versions of jpeg_abort and jpeg_destroy that work on either - * flavor of JPEG object. These may be more convenient in some places. - */ -EXTERN(void) jpeg_abort JPP((j_common_ptr cinfo)); -EXTERN(void) jpeg_destroy JPP((j_common_ptr cinfo)); - -/* Default restart-marker-resync procedure for use by data source modules */ -EXTERN(boolean) jpeg_resync_to_restart JPP((j_decompress_ptr cinfo, - int desired)); - - -/* These marker codes are exported since applications and data source modules - * are likely to want to use them. - */ - -#define JPEG_RST0 0xD0 /* RST0 marker code */ -#define JPEG_EOI 0xD9 /* EOI marker code */ -#define JPEG_APP0 0xE0 /* APP0 marker code */ -#define JPEG_COM 0xFE /* COM marker code */ - - -/* If we have a brain-damaged compiler that emits warnings (or worse, errors) - * for structure definitions that are never filled in, keep it quiet by - * supplying dummy definitions for the various substructures. - */ - -#ifdef INCOMPLETE_TYPES_BROKEN -#ifndef JPEG_INTERNALS /* will be defined in jpegint.h */ -struct jvirt_sarray_control { long dummy; }; -struct jvirt_barray_control { long dummy; }; -struct jpeg_comp_master { long dummy; }; -struct jpeg_c_main_controller { long dummy; }; -struct jpeg_c_prep_controller { long dummy; }; -struct jpeg_c_coef_controller { long dummy; }; -struct jpeg_marker_writer { long dummy; }; -struct jpeg_color_converter { long dummy; }; -struct jpeg_downsampler { long dummy; }; -struct jpeg_forward_dct { long dummy; }; -struct jpeg_entropy_encoder { long dummy; }; -struct jpeg_decomp_master { long dummy; }; -struct jpeg_d_main_controller { long dummy; }; -struct jpeg_d_coef_controller { long dummy; }; -struct jpeg_d_post_controller { long dummy; }; -struct jpeg_input_controller { long dummy; }; -struct jpeg_marker_reader { long dummy; }; -struct jpeg_entropy_decoder { long dummy; }; -struct jpeg_inverse_dct { long dummy; }; -struct jpeg_upsampler { long dummy; }; -struct jpeg_color_deconverter { long dummy; }; -struct jpeg_color_quantizer { long dummy; }; -#endif /* JPEG_INTERNALS */ -#endif /* INCOMPLETE_TYPES_BROKEN */ - - -/* - * The JPEG library modules define JPEG_INTERNALS before including this file. - * The internal structure declarations are read only when that is true. - * Applications using the library should not include jpegint.h, but may wish - * to include jerror.h. - */ - -#ifdef JPEG_INTERNALS -#include "jpegint.h" /* fetch private declarations */ -#include "jerror.h" /* fetch error codes too */ -#endif - -#endif /* JPEGLIB_H */ diff --git a/Utilities/CAI/cai_dll/inc/jversion.h b/Utilities/CAI/cai_dll/inc/jversion.h deleted file mode 100755 index b903be7d468ca5034afdca10efe5cdaa7161a51f..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/jversion.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * jversion.h - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains software version identification. - */ - - -#define JVERSION "6a 7-Feb-96" - -#define JCOPYRIGHT "Copyright (C) 1996, Thomas G. Lane" diff --git a/Utilities/CAI/cai_dll/inc/machdep.h b/Utilities/CAI/cai_dll/inc/machdep.h deleted file mode 100755 index 055749fc48824609251fc719ae6da69aef4dd512..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/machdep.h +++ /dev/null @@ -1,258 +0,0 @@ -/* $Header: machdep.h,v 1.1 96/07/15 15:06:52 cmf Exp $ */ - -/* - * Copyright (c) 1988, 1989, 1990, 1991 Sam Leffler - * Copyright (c) 1991 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _MACHDEP_ -#define _MACHDEP_ -/* - * Machine dependent definitions: - * o floating point formats - * o byte ordering - * - * NB, there are lots of assumptions here: - * - 32-bit natural integers (sign extension code) - * - native float is 4 bytes (floating point conversion) - * - native double is 8 bytes (floating point conversion) - */ - -#if defined(sun) || defined(sparc) || defined(stellar) || defined(MIPSEB) || defined(hpux) || defined(apollo) || defined(NeXT) || defined(_IBMR2) -#define BIGENDIAN 1 -#define IEEEFP -#endif /* sun || sparc || stellar || MIPSEB || hpux || apollo || NeXT || _IBMR2 */ - -/* MIPSEL = MIPS w/ Little Endian byte ordering (e.g. DEC 3100) */ -#if defined(MIPSEL) -#define BIGENDIAN 0 -#define IEEEFP -#endif /* MIPSEL */ - -#ifdef transputer -#define BIGENDIAN 0 -#define IEEEFP /* IEEE floating point supported */ -#endif /* transputer */ - -#if defined(m386) || defined(M_I86) || defined(i386) -#define BIGENDIAN 0 -#define IEEEFP /* IEEE floating point supported */ -#endif /* m386 || M_I86 || i386 */ - -#ifdef IEEEFP -typedef struct ieeedouble nativedouble; -typedef struct ieeefloat nativefloat; -#define ISFRACTION(e) (1022 - 4 <= (e) && (e) <= 1022 + 15) -#define EXTRACTFRACTION(dp, fract) \ - ((fract) = ((unsigned long)(1<<31)|((dp)->native.mant<<11)|\ - ((dp)->native.mant2>>21)) >> (1022+16-(dp)->native.exp)) -#define EXTRACTEXPONENT(dp, exponent) ((exponent) = (dp)->native.exp) -#define NATIVE2IEEEFLOAT(fp) -#define IEEEFLOAT2NATIVE(fp) -#define IEEEDOUBLE2NATIVE(dp) - -#define TIFFSwabArrayOfFloat(fp,n) TIFFSwabArrayOfLong((unsigned long *)fp,n) -#define TIFFSwabArrayOfDouble(dp,n) TIFFSwabArrayOfLong((unsigned long *)dp,2*n) -#endif /* IEEEFP */ - -#ifdef tahoe -#define BIGENDIAN 1 - -typedef struct { - unsigned sign:1; - unsigned exp:8; - unsigned mant:23; - unsigned mant2; -} nativedouble; -typedef struct { - unsigned sign:1; - unsigned exp:8; - unsigned mant:23; -} nativefloat; -#define ISFRACTION(e) (128 - 4 <= (e) && (e) <= 128 + 15) -#define EXTRACTFRACTION(dp, fract) \ - ((fract) = ((1<<31)|((dp)->native.mant<<8)|((dp)->native.mant2>>15)) >> \ - (128+16-(dp)->native.exp)) -#define EXTRACTEXPONENT(dp, exponent) ((exponent) = (dp)->native.exp - 2) -/* - * Beware, over/under-flow in conversions will - * result in garbage values -- handling it would - * require a subroutine call or lots more code. - */ -#define NATIVE2IEEEFLOAT(fp) { \ - if ((fp)->native.exp) \ - (fp)->ieee.exp = (fp)->native.exp - 129 + 127; /* alter bias */\ -} -#define IEEEFLOAT2NATIVE(fp) { \ - if ((fp)->ieee.exp) \ - (fp)->native.exp = (fp)->ieee.exp - 127 + 129; /* alter bias */\ -} -#define IEEEDOUBLE2NATIVE(dp) { \ - if ((dp)->native.exp = (dp)->ieee.exp) \ - (dp)->native.exp += -1023 + 129; \ - (dp)->native.mant = ((dp)->ieee.mant<<3)|((dp)->native.mant2>>29); \ - (dp)->native.mant2 <<= 3; \ -} -/* the following is to work around a compiler bug... */ -#define SIGNEXTEND(a,b) { char ch; ch = (a); (b) = ch; } - -#define TIFFSwabArrayOfFloat(fp,n) TIFFSwabArrayOfLong((unsigned long *)fp,n) -#define TIFFSwabArrayOfDouble(dp,n) TIFFSwabArrayOfLong((unsigned long *)dp,2*n) -#endif /* tahoe */ - -#ifdef vax -#define BIGENDIAN 0 - -typedef struct { - unsigned mant1:7; - unsigned exp:8; - unsigned sign:1; - unsigned mant2:16; - unsigned mant3; -} nativedouble; -typedef struct { - unsigned mant1:7; - unsigned exp:8; - unsigned sign:1; - unsigned mant2:16; -} nativefloat; -#define ISFRACTION(e) (128 - 4 <= (e) && (e) <= 128 + 15) -#define EXTRACTFRACTION(dp, fract) \ - ((fract) = ((1<<31)|((dp)->native.mant1<<16)|(dp)->native.mant2)) >> \ - (128+16-(dp)->native.exp)) -#define EXTRACTEXPONENT(dp, exponent) ((exponent) = (dp)->native.exp - 2) -/* - * Beware, these do not handle over/under-flow - * during conversion from ieee to native format. - */ -#define NATIVE2IEEEFLOAT(fp) { \ - float_t t; \ - if (t.ieee.exp = (fp)->native.exp) \ - t.ieee.exp += -129 + 127; \ - t.ieee.sign = (fp)->native.sign; \ - t.ieee.mant = ((fp)->native.mant1<<16)|(fp)->native.mant2; \ - *(fp) = t; \ -} -#define IEEEFLOAT2NATIVE(fp) { \ - float_t t; int v = (fp)->ieee.exp; \ - if (v) v += -127 + 129; /* alter bias of exponent */\ - t.native.exp = v; /* implicit truncation of exponent */\ - t.native.sign = (fp)->ieee.sign; \ - v = (fp)->ieee.mant; \ - t.native.mant1 = v >> 16; \ - t.native.mant2 = v;\ - *(fp) = v; \ -} -#define IEEEDOUBLE2NATIVE(dp) { \ - double_t t; int v = (dp)->ieee.exp; \ - if (v) v += -1023 + 129; /* if can alter bias of exponent */\ - t.native.exp = v; /* implicit truncation of exponent */\ - v = (dp)->ieee.mant; \ - t.native.sign = (dp)->ieee.sign; \ - t.native.mant1 = v >> 16; \ - t.native.mant2 = v;\ - t.native.mant3 = (dp)->mant2; \ - *(dp) = t; \ -} - -#define TIFFSwabArrayOfFloat(fp,n) TIFFSwabArrayOfLong((unsigned long *)fp,n) -#define TIFFSwabArrayOfDouble(dp,n) TIFFSwabArrayOfLong((unsigned long *)dp,2*n) -#endif /* vax */ - -/* - * These unions are used during floating point - * conversions. The macros given above define - * the conversion operations. - */ - -typedef struct ieeedouble { -#if BIGENDIAN == 1 -#if !defined(_IBMR2) - unsigned sign:1; - unsigned exp:11; - unsigned long mant:20; - unsigned mant2; -#else /* _IBMR2 */ - unsigned sign:1; - unsigned exp:11; - unsigned mant:20; - unsigned mant2; -#endif /* _IBMR2 */ -#else -#if !defined(vax) -#ifdef INT_16_BIT /* MSDOS C compilers */ - unsigned long mant2; - unsigned long mant:20; - unsigned long exp:11; - unsigned long sign:1; -#else /* 32 bit ints */ - unsigned mant2; - unsigned long mant:20; - unsigned exp:11; - unsigned sign:1; -#endif /* 32 bit ints */ -#else - unsigned long mant:20; - unsigned exp:11; - unsigned sign:1; - unsigned mant2; -#endif /* !vax */ -#endif -} ieeedouble; -typedef struct ieeefloat { -#if BIGENDIAN == 1 -#if !defined(_IBMR2) - unsigned sign:1; - unsigned exp:8; - unsigned long mant:23; -#else /* _IBMR2 */ - unsigned sign:1; - unsigned exp:8; - unsigned mant:23; -#endif /* _IBMR2 */ -#else -#ifdef INT_16_BIT /* MSDOS C compilers */ - unsigned long mant:23; - unsigned long exp:8; - unsigned long sign:1; -#else /* 32 bit ints */ - unsigned long mant:23; - unsigned exp:8; - unsigned sign:1; -#endif /* 32 bit ints */ -#endif -} ieeefloat; - -typedef union { - ieeedouble ieee; - nativedouble native; - char b[8]; - double d; -} double_t; - -typedef union { - ieeefloat ieee; - nativefloat native; - char b[4]; - float f; -} float_t; -#endif /* _MACHDEP_ */ diff --git a/Utilities/CAI/cai_dll/inc/port.h b/Utilities/CAI/cai_dll/inc/port.h deleted file mode 100755 index 806bedfa6bded9c628f8164db8ca47747a041eb7..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/port.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Warning, this file was automatically created by the TIFF configure script - * VERSION: v3.5.5 - * DATE: Fri Oct 6 16:24:03 MET DST 2000 - * TARGET: sparc-sun-solaris2.7 - * CCOMPILER: /usr/local/bin/gcc-2.95.2 19991024 (release) - */ -#ifndef _PORT_ -#define _PORT_ 1 -#ifdef __cplusplus -extern "C" { -#endif -#include <sys/types.h> -#define HOST_FILLORDER FILLORDER_MSB2LSB -#define HOST_BIGENDIAN 1 -#define HAVE_MMAP 1 -#include <stdio.h> -#include <unistd.h> -#include <string.h> -#include <stdlib.h> -#include <fcntl.h> -typedef double dblparam_t; -#ifdef __STRICT_ANSI__ -#define INLINE __inline__ -#else -#define INLINE inline -#endif -#define GLOBALDATA(TYPE,NAME) extern TYPE NAME -#ifdef __cplusplus -} -#endif -#endif diff --git a/Utilities/CAI/cai_dll/inc/t4.h b/Utilities/CAI/cai_dll/inc/t4.h deleted file mode 100755 index fa4f5f75d0f837e490c26accae3b0f70c5e1e231..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/t4.h +++ /dev/null @@ -1,285 +0,0 @@ -/* $Id$ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _T4_ -#define _T4_ -/* - * CCITT T.4 1D Huffman runlength codes and - * related definitions. Given the small sizes - * of these tables it does not seem - * worthwhile to make code & length 8 bits. - */ -typedef struct tableentry { - unsigned short length; /* bit length of g3 code */ - unsigned short code; /* g3 code */ - short runlen; /* run length in bits */ -} tableentry; - -#define EOL 0x001 /* EOL code value - 0000 0000 0000 1 */ - -/* status values returned instead of a run length */ -#define G3CODE_EOL -1 /* NB: ACT_EOL - ACT_WRUNT */ -#define G3CODE_INVALID -2 /* NB: ACT_INVALID - ACT_WRUNT */ -#define G3CODE_EOF -3 /* end of input data */ -#define G3CODE_INCOMP -4 /* incomplete run code */ - -/* - * Note that these tables are ordered such that the - * index into the table is known to be either the - * run length, or (run length / 64) + a fixed offset. - * - * NB: The G3CODE_INVALID entries are only used - * during state generation (see mkg3states.c). - */ -#ifdef G3CODES -const tableentry TIFFFaxWhiteCodes[] = { - { 8, 0x35, 0 }, /* 0011 0101 */ - { 6, 0x7, 1 }, /* 0001 11 */ - { 4, 0x7, 2 }, /* 0111 */ - { 4, 0x8, 3 }, /* 1000 */ - { 4, 0xB, 4 }, /* 1011 */ - { 4, 0xC, 5 }, /* 1100 */ - { 4, 0xE, 6 }, /* 1110 */ - { 4, 0xF, 7 }, /* 1111 */ - { 5, 0x13, 8 }, /* 1001 1 */ - { 5, 0x14, 9 }, /* 1010 0 */ - { 5, 0x7, 10 }, /* 0011 1 */ - { 5, 0x8, 11 }, /* 0100 0 */ - { 6, 0x8, 12 }, /* 0010 00 */ - { 6, 0x3, 13 }, /* 0000 11 */ - { 6, 0x34, 14 }, /* 1101 00 */ - { 6, 0x35, 15 }, /* 1101 01 */ - { 6, 0x2A, 16 }, /* 1010 10 */ - { 6, 0x2B, 17 }, /* 1010 11 */ - { 7, 0x27, 18 }, /* 0100 111 */ - { 7, 0xC, 19 }, /* 0001 100 */ - { 7, 0x8, 20 }, /* 0001 000 */ - { 7, 0x17, 21 }, /* 0010 111 */ - { 7, 0x3, 22 }, /* 0000 011 */ - { 7, 0x4, 23 }, /* 0000 100 */ - { 7, 0x28, 24 }, /* 0101 000 */ - { 7, 0x2B, 25 }, /* 0101 011 */ - { 7, 0x13, 26 }, /* 0010 011 */ - { 7, 0x24, 27 }, /* 0100 100 */ - { 7, 0x18, 28 }, /* 0011 000 */ - { 8, 0x2, 29 }, /* 0000 0010 */ - { 8, 0x3, 30 }, /* 0000 0011 */ - { 8, 0x1A, 31 }, /* 0001 1010 */ - { 8, 0x1B, 32 }, /* 0001 1011 */ - { 8, 0x12, 33 }, /* 0001 0010 */ - { 8, 0x13, 34 }, /* 0001 0011 */ - { 8, 0x14, 35 }, /* 0001 0100 */ - { 8, 0x15, 36 }, /* 0001 0101 */ - { 8, 0x16, 37 }, /* 0001 0110 */ - { 8, 0x17, 38 }, /* 0001 0111 */ - { 8, 0x28, 39 }, /* 0010 1000 */ - { 8, 0x29, 40 }, /* 0010 1001 */ - { 8, 0x2A, 41 }, /* 0010 1010 */ - { 8, 0x2B, 42 }, /* 0010 1011 */ - { 8, 0x2C, 43 }, /* 0010 1100 */ - { 8, 0x2D, 44 }, /* 0010 1101 */ - { 8, 0x4, 45 }, /* 0000 0100 */ - { 8, 0x5, 46 }, /* 0000 0101 */ - { 8, 0xA, 47 }, /* 0000 1010 */ - { 8, 0xB, 48 }, /* 0000 1011 */ - { 8, 0x52, 49 }, /* 0101 0010 */ - { 8, 0x53, 50 }, /* 0101 0011 */ - { 8, 0x54, 51 }, /* 0101 0100 */ - { 8, 0x55, 52 }, /* 0101 0101 */ - { 8, 0x24, 53 }, /* 0010 0100 */ - { 8, 0x25, 54 }, /* 0010 0101 */ - { 8, 0x58, 55 }, /* 0101 1000 */ - { 8, 0x59, 56 }, /* 0101 1001 */ - { 8, 0x5A, 57 }, /* 0101 1010 */ - { 8, 0x5B, 58 }, /* 0101 1011 */ - { 8, 0x4A, 59 }, /* 0100 1010 */ - { 8, 0x4B, 60 }, /* 0100 1011 */ - { 8, 0x32, 61 }, /* 0011 0010 */ - { 8, 0x33, 62 }, /* 0011 0011 */ - { 8, 0x34, 63 }, /* 0011 0100 */ - { 5, 0x1B, 64 }, /* 1101 1 */ - { 5, 0x12, 128 }, /* 1001 0 */ - { 6, 0x17, 192 }, /* 0101 11 */ - { 7, 0x37, 256 }, /* 0110 111 */ - { 8, 0x36, 320 }, /* 0011 0110 */ - { 8, 0x37, 384 }, /* 0011 0111 */ - { 8, 0x64, 448 }, /* 0110 0100 */ - { 8, 0x65, 512 }, /* 0110 0101 */ - { 8, 0x68, 576 }, /* 0110 1000 */ - { 8, 0x67, 640 }, /* 0110 0111 */ - { 9, 0xCC, 704 }, /* 0110 0110 0 */ - { 9, 0xCD, 768 }, /* 0110 0110 1 */ - { 9, 0xD2, 832 }, /* 0110 1001 0 */ - { 9, 0xD3, 896 }, /* 0110 1001 1 */ - { 9, 0xD4, 960 }, /* 0110 1010 0 */ - { 9, 0xD5, 1024 }, /* 0110 1010 1 */ - { 9, 0xD6, 1088 }, /* 0110 1011 0 */ - { 9, 0xD7, 1152 }, /* 0110 1011 1 */ - { 9, 0xD8, 1216 }, /* 0110 1100 0 */ - { 9, 0xD9, 1280 }, /* 0110 1100 1 */ - { 9, 0xDA, 1344 }, /* 0110 1101 0 */ - { 9, 0xDB, 1408 }, /* 0110 1101 1 */ - { 9, 0x98, 1472 }, /* 0100 1100 0 */ - { 9, 0x99, 1536 }, /* 0100 1100 1 */ - { 9, 0x9A, 1600 }, /* 0100 1101 0 */ - { 6, 0x18, 1664 }, /* 0110 00 */ - { 9, 0x9B, 1728 }, /* 0100 1101 1 */ - { 11, 0x8, 1792 }, /* 0000 0001 000 */ - { 11, 0xC, 1856 }, /* 0000 0001 100 */ - { 11, 0xD, 1920 }, /* 0000 0001 101 */ - { 12, 0x12, 1984 }, /* 0000 0001 0010 */ - { 12, 0x13, 2048 }, /* 0000 0001 0011 */ - { 12, 0x14, 2112 }, /* 0000 0001 0100 */ - { 12, 0x15, 2176 }, /* 0000 0001 0101 */ - { 12, 0x16, 2240 }, /* 0000 0001 0110 */ - { 12, 0x17, 2304 }, /* 0000 0001 0111 */ - { 12, 0x1C, 2368 }, /* 0000 0001 1100 */ - { 12, 0x1D, 2432 }, /* 0000 0001 1101 */ - { 12, 0x1E, 2496 }, /* 0000 0001 1110 */ - { 12, 0x1F, 2560 }, /* 0000 0001 1111 */ - { 12, 0x1, G3CODE_EOL }, /* 0000 0000 0001 */ - { 9, 0x1, G3CODE_INVALID }, /* 0000 0000 1 */ - { 10, 0x1, G3CODE_INVALID }, /* 0000 0000 01 */ - { 11, 0x1, G3CODE_INVALID }, /* 0000 0000 001 */ - { 12, 0x0, G3CODE_INVALID }, /* 0000 0000 0000 */ -}; - -const tableentry TIFFFaxBlackCodes[] = { - { 10, 0x37, 0 }, /* 0000 1101 11 */ - { 3, 0x2, 1 }, /* 010 */ - { 2, 0x3, 2 }, /* 11 */ - { 2, 0x2, 3 }, /* 10 */ - { 3, 0x3, 4 }, /* 011 */ - { 4, 0x3, 5 }, /* 0011 */ - { 4, 0x2, 6 }, /* 0010 */ - { 5, 0x3, 7 }, /* 0001 1 */ - { 6, 0x5, 8 }, /* 0001 01 */ - { 6, 0x4, 9 }, /* 0001 00 */ - { 7, 0x4, 10 }, /* 0000 100 */ - { 7, 0x5, 11 }, /* 0000 101 */ - { 7, 0x7, 12 }, /* 0000 111 */ - { 8, 0x4, 13 }, /* 0000 0100 */ - { 8, 0x7, 14 }, /* 0000 0111 */ - { 9, 0x18, 15 }, /* 0000 1100 0 */ - { 10, 0x17, 16 }, /* 0000 0101 11 */ - { 10, 0x18, 17 }, /* 0000 0110 00 */ - { 10, 0x8, 18 }, /* 0000 0010 00 */ - { 11, 0x67, 19 }, /* 0000 1100 111 */ - { 11, 0x68, 20 }, /* 0000 1101 000 */ - { 11, 0x6C, 21 }, /* 0000 1101 100 */ - { 11, 0x37, 22 }, /* 0000 0110 111 */ - { 11, 0x28, 23 }, /* 0000 0101 000 */ - { 11, 0x17, 24 }, /* 0000 0010 111 */ - { 11, 0x18, 25 }, /* 0000 0011 000 */ - { 12, 0xCA, 26 }, /* 0000 1100 1010 */ - { 12, 0xCB, 27 }, /* 0000 1100 1011 */ - { 12, 0xCC, 28 }, /* 0000 1100 1100 */ - { 12, 0xCD, 29 }, /* 0000 1100 1101 */ - { 12, 0x68, 30 }, /* 0000 0110 1000 */ - { 12, 0x69, 31 }, /* 0000 0110 1001 */ - { 12, 0x6A, 32 }, /* 0000 0110 1010 */ - { 12, 0x6B, 33 }, /* 0000 0110 1011 */ - { 12, 0xD2, 34 }, /* 0000 1101 0010 */ - { 12, 0xD3, 35 }, /* 0000 1101 0011 */ - { 12, 0xD4, 36 }, /* 0000 1101 0100 */ - { 12, 0xD5, 37 }, /* 0000 1101 0101 */ - { 12, 0xD6, 38 }, /* 0000 1101 0110 */ - { 12, 0xD7, 39 }, /* 0000 1101 0111 */ - { 12, 0x6C, 40 }, /* 0000 0110 1100 */ - { 12, 0x6D, 41 }, /* 0000 0110 1101 */ - { 12, 0xDA, 42 }, /* 0000 1101 1010 */ - { 12, 0xDB, 43 }, /* 0000 1101 1011 */ - { 12, 0x54, 44 }, /* 0000 0101 0100 */ - { 12, 0x55, 45 }, /* 0000 0101 0101 */ - { 12, 0x56, 46 }, /* 0000 0101 0110 */ - { 12, 0x57, 47 }, /* 0000 0101 0111 */ - { 12, 0x64, 48 }, /* 0000 0110 0100 */ - { 12, 0x65, 49 }, /* 0000 0110 0101 */ - { 12, 0x52, 50 }, /* 0000 0101 0010 */ - { 12, 0x53, 51 }, /* 0000 0101 0011 */ - { 12, 0x24, 52 }, /* 0000 0010 0100 */ - { 12, 0x37, 53 }, /* 0000 0011 0111 */ - { 12, 0x38, 54 }, /* 0000 0011 1000 */ - { 12, 0x27, 55 }, /* 0000 0010 0111 */ - { 12, 0x28, 56 }, /* 0000 0010 1000 */ - { 12, 0x58, 57 }, /* 0000 0101 1000 */ - { 12, 0x59, 58 }, /* 0000 0101 1001 */ - { 12, 0x2B, 59 }, /* 0000 0010 1011 */ - { 12, 0x2C, 60 }, /* 0000 0010 1100 */ - { 12, 0x5A, 61 }, /* 0000 0101 1010 */ - { 12, 0x66, 62 }, /* 0000 0110 0110 */ - { 12, 0x67, 63 }, /* 0000 0110 0111 */ - { 10, 0xF, 64 }, /* 0000 0011 11 */ - { 12, 0xC8, 128 }, /* 0000 1100 1000 */ - { 12, 0xC9, 192 }, /* 0000 1100 1001 */ - { 12, 0x5B, 256 }, /* 0000 0101 1011 */ - { 12, 0x33, 320 }, /* 0000 0011 0011 */ - { 12, 0x34, 384 }, /* 0000 0011 0100 */ - { 12, 0x35, 448 }, /* 0000 0011 0101 */ - { 13, 0x6C, 512 }, /* 0000 0011 0110 0 */ - { 13, 0x6D, 576 }, /* 0000 0011 0110 1 */ - { 13, 0x4A, 640 }, /* 0000 0010 0101 0 */ - { 13, 0x4B, 704 }, /* 0000 0010 0101 1 */ - { 13, 0x4C, 768 }, /* 0000 0010 0110 0 */ - { 13, 0x4D, 832 }, /* 0000 0010 0110 1 */ - { 13, 0x72, 896 }, /* 0000 0011 1001 0 */ - { 13, 0x73, 960 }, /* 0000 0011 1001 1 */ - { 13, 0x74, 1024 }, /* 0000 0011 1010 0 */ - { 13, 0x75, 1088 }, /* 0000 0011 1010 1 */ - { 13, 0x76, 1152 }, /* 0000 0011 1011 0 */ - { 13, 0x77, 1216 }, /* 0000 0011 1011 1 */ - { 13, 0x52, 1280 }, /* 0000 0010 1001 0 */ - { 13, 0x53, 1344 }, /* 0000 0010 1001 1 */ - { 13, 0x54, 1408 }, /* 0000 0010 1010 0 */ - { 13, 0x55, 1472 }, /* 0000 0010 1010 1 */ - { 13, 0x5A, 1536 }, /* 0000 0010 1101 0 */ - { 13, 0x5B, 1600 }, /* 0000 0010 1101 1 */ - { 13, 0x64, 1664 }, /* 0000 0011 0010 0 */ - { 13, 0x65, 1728 }, /* 0000 0011 0010 1 */ - { 11, 0x8, 1792 }, /* 0000 0001 000 */ - { 11, 0xC, 1856 }, /* 0000 0001 100 */ - { 11, 0xD, 1920 }, /* 0000 0001 101 */ - { 12, 0x12, 1984 }, /* 0000 0001 0010 */ - { 12, 0x13, 2048 }, /* 0000 0001 0011 */ - { 12, 0x14, 2112 }, /* 0000 0001 0100 */ - { 12, 0x15, 2176 }, /* 0000 0001 0101 */ - { 12, 0x16, 2240 }, /* 0000 0001 0110 */ - { 12, 0x17, 2304 }, /* 0000 0001 0111 */ - { 12, 0x1C, 2368 }, /* 0000 0001 1100 */ - { 12, 0x1D, 2432 }, /* 0000 0001 1101 */ - { 12, 0x1E, 2496 }, /* 0000 0001 1110 */ - { 12, 0x1F, 2560 }, /* 0000 0001 1111 */ - { 12, 0x1, G3CODE_EOL }, /* 0000 0000 0001 */ - { 9, 0x1, G3CODE_INVALID }, /* 0000 0000 1 */ - { 10, 0x1, G3CODE_INVALID }, /* 0000 0000 01 */ - { 11, 0x1, G3CODE_INVALID }, /* 0000 0000 001 */ - { 12, 0x0, G3CODE_INVALID }, /* 0000 0000 0000 */ -}; -#else -extern const tableentry TIFFFaxWhiteCodes[]; -extern const tableentry TIFFFaxBlackCodes[]; -#endif -#endif /* _T4_ */ diff --git a/Utilities/CAI/cai_dll/inc/tif_dir.h b/Utilities/CAI/cai_dll/inc/tif_dir.h deleted file mode 100755 index 59c671a123d9558ed6d608df1a90c5610ee20a1e..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/tif_dir.h +++ /dev/null @@ -1,268 +0,0 @@ -/* $Header: tif_dir.h,v 1.1 01/01/15 15:24:36 cmf Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _TIFFDIR_ -#define _TIFFDIR_ -/* - * ``Library-private'' Directory-related Definitions. - */ - -/* - * Internal format of a TIFF directory entry. - */ -typedef struct { -#define FIELD_SETLONGS 3 - /* bit vector of fields that are set */ - u_long td_fieldsset[FIELD_SETLONGS]; - - uint32 td_imagewidth, td_imagelength, td_imagedepth; - uint32 td_tilewidth, td_tilelength, td_tiledepth; - uint32 td_subfiletype; - uint16 td_bitspersample; - uint16 td_sampleformat; - uint16 td_compression; - uint16 td_photometric; - uint16 td_threshholding; - uint16 td_fillorder; - uint16 td_orientation; - uint16 td_samplesperpixel; - uint32 td_rowsperstrip; - uint16 td_minsamplevalue, td_maxsamplevalue; - double td_sminsamplevalue, td_smaxsamplevalue; - float td_xresolution, td_yresolution; - uint16 td_resolutionunit; - uint16 td_planarconfig; - float td_xposition, td_yposition; - uint16 td_pagenumber[2]; - uint16* td_colormap[3]; - uint16 td_halftonehints[2]; - uint16 td_extrasamples; - uint16* td_sampleinfo; - double td_stonits; - char* td_documentname; - char* td_artist; - char* td_datetime; - char* td_hostcomputer; - char* td_imagedescription; - char* td_make; - char* td_model; - char* td_software; - char* td_pagename; - tstrip_t td_stripsperimage; - tstrip_t td_nstrips; /* size of offset & bytecount arrays */ - uint32* td_stripoffset; - uint32* td_stripbytecount; -#if SUBIFD_SUPPORT - uint16 td_nsubifd; - uint32* td_subifd; -#endif -#ifdef YCBCR_SUPPORT - float* td_ycbcrcoeffs; - uint16 td_ycbcrsubsampling[2]; - uint16 td_ycbcrpositioning; -#endif -#ifdef COLORIMETRY_SUPPORT - float* td_whitepoint; - float* td_primarychromas; - float* td_refblackwhite; - uint16* td_transferfunction[3]; -#endif -#ifdef CMYK_SUPPORT - uint16 td_inkset; - uint16 td_ninks; - uint16 td_dotrange[2]; - int td_inknameslen; - char* td_inknames; - char* td_targetprinter; -#endif -#ifdef ICC_SUPPORT - uint32 td_profileLength; - void *td_profileData; -#endif -#ifdef PHOTOSHOP_SUPPORT - uint32 td_photoshopLength; - void *td_photoshopData; -#endif -#ifdef IPTC_SUPPORT - uint32 td_richtiffiptcLength; - void *td_richtiffiptcData; -#endif - /* Begin Pixar Tag values. */ - uint32 td_imagefullwidth, td_imagefulllength; - char* td_textureformat; - char* td_wrapmodes; - float td_fovcot; - float* td_matrixWorldToScreen; - float* td_matrixWorldToCamera; - /* End Pixar Tag Values. */ -} TIFFDirectory; - -/* - * Field flags used to indicate fields that have - * been set in a directory, and to reference fields - * when manipulating a directory. - */ - -/* - * FIELD_IGNORE is used to signify tags that are to - * be processed but otherwise ignored. This permits - * antiquated tags to be quietly read and discarded. - * Note that a bit *is* allocated for ignored tags; - * this is understood by the directory reading logic - * which uses this fact to avoid special-case handling - */ -#define FIELD_IGNORE 0 - -/* multi-item fields */ -#define FIELD_IMAGEDIMENSIONS 1 -#define FIELD_TILEDIMENSIONS 2 -#define FIELD_RESOLUTION 3 -#define FIELD_POSITION 4 - -/* single-item fields */ -#define FIELD_SUBFILETYPE 5 -#define FIELD_BITSPERSAMPLE 6 -#define FIELD_COMPRESSION 7 -#define FIELD_PHOTOMETRIC 8 -#define FIELD_THRESHHOLDING 9 -#define FIELD_FILLORDER 10 -#define FIELD_DOCUMENTNAME 11 -#define FIELD_IMAGEDESCRIPTION 12 -#define FIELD_MAKE 13 -#define FIELD_MODEL 14 -#define FIELD_ORIENTATION 15 -#define FIELD_SAMPLESPERPIXEL 16 -#define FIELD_ROWSPERSTRIP 17 -#define FIELD_MINSAMPLEVALUE 18 -#define FIELD_MAXSAMPLEVALUE 19 -#define FIELD_PLANARCONFIG 20 -#define FIELD_PAGENAME 21 -#define FIELD_RESOLUTIONUNIT 22 -#define FIELD_PAGENUMBER 23 -#define FIELD_STRIPBYTECOUNTS 24 -#define FIELD_STRIPOFFSETS 25 -#define FIELD_COLORMAP 26 -#define FIELD_ARTIST 27 -#define FIELD_DATETIME 28 -#define FIELD_HOSTCOMPUTER 29 -#define FIELD_SOFTWARE 30 -#define FIELD_EXTRASAMPLES 31 -#define FIELD_SAMPLEFORMAT 32 -#define FIELD_SMINSAMPLEVALUE 33 -#define FIELD_SMAXSAMPLEVALUE 34 -#define FIELD_IMAGEDEPTH 35 -#define FIELD_TILEDEPTH 36 -#define FIELD_HALFTONEHINTS 37 -#define FIELD_YCBCRCOEFFICIENTS 38 -#define FIELD_YCBCRSUBSAMPLING 39 -#define FIELD_YCBCRPOSITIONING 40 -#define FIELD_REFBLACKWHITE 41 -#define FIELD_WHITEPOINT 42 -#define FIELD_PRIMARYCHROMAS 43 -#define FIELD_TRANSFERFUNCTION 44 -#define FIELD_INKSET 45 -#define FIELD_INKNAMES 46 -#define FIELD_DOTRANGE 47 -#define FIELD_TARGETPRINTER 48 -#define FIELD_SUBIFD 49 -#define FIELD_NUMBEROFINKS 50 -#define FIELD_ICCPROFILE 51 -#define FIELD_PHOTOSHOP 52 -#define FIELD_RICHTIFFIPTC 53 -#define FIELD_STONITS 54 -/* Begin PIXAR */ -#define FIELD_IMAGEFULLWIDTH 55 -#define FIELD_IMAGEFULLLENGTH 56 -#define FIELD_TEXTUREFORMAT 57 -#define FIELD_WRAPMODES 58 -#define FIELD_FOVCOT 59 -#define FIELD_MATRIX_WORLDTOSCREEN 60 -#define FIELD_MATRIX_WORLDTOCAMERA 61 -/* end of support for well-known tags; codec-private tags follow */ -#define FIELD_CODEC 62 /* base of codec-private tags */ -/* - * Pseudo-tags don't normally need field bits since they - * are not written to an output file (by definition). - * The library also has express logic to always query a - * codec for a pseudo-tag so allocating a field bit for - * one is a waste. If codec wants to promote the notion - * of a pseudo-tag being ``set'' or ``unset'' then it can - * do using internal state flags without polluting the - * field bit space defined for real tags. - */ -#define FIELD_PSEUDO 0 - -#define FIELD_LAST (32*FIELD_SETLONGS-1) - -#define TIFFExtractData(tif, type, v) \ - ((uint32) ((tif)->tif_header.tiff_magic == TIFF_BIGENDIAN ? \ - ((v) >> (tif)->tif_typeshift[type]) & (tif)->tif_typemask[type] : \ - (v) & (tif)->tif_typemask[type])) -#define TIFFInsertData(tif, type, v) \ - ((uint32) ((tif)->tif_header.tiff_magic == TIFF_BIGENDIAN ? \ - ((v) & (tif)->tif_typemask[type]) << (tif)->tif_typeshift[type] : \ - (v) & (tif)->tif_typemask[type])) - -typedef struct { - ttag_t field_tag; /* field's tag */ - short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */ - short field_writecount; /* write count/TIFF_VARIABLE */ - TIFFDataType field_type; /* type of associated data */ - u_short field_bit; /* bit in fieldsset bit vector */ - u_char field_oktochange; /* if true, can change while writing */ - u_char field_passcount; /* if true, pass dir count on set */ - char *field_name; /* ASCII name */ -} TIFFFieldInfo; - -#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */ -#define TIFF_VARIABLE -1 /* marker for variable length tags */ -#define TIFF_SPP -2 /* marker for SamplesPerPixel tags */ -#define TIFF_VARIABLE2 -3 /* marker for uint32 var-length tags */ - -extern const int tiffDataWidth[]; /* table of tag datatype widths */ - -#define BITn(n) (((u_long)1L)<<((n)&0x1f)) -#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n)/32]) -#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field)) -#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field)) -#define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field)) - -#define FieldSet(fields, f) (fields[(f)/32] & BITn(f)) -#define ResetFieldBit(fields, f) (fields[(f)/32] &= ~BITn(f)) - -#if defined(__cplusplus) -extern "C" { -#endif -extern void _TIFFSetupFieldInfo(TIFF*); -extern void _TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], int); -extern void _TIFFPrintFieldInfo(TIFF*, FILE*); -extern const TIFFFieldInfo* _TIFFFindFieldInfo(TIFF*, ttag_t, TIFFDataType); -extern const TIFFFieldInfo* _TIFFFieldWithTag(TIFF*, ttag_t); -extern TIFFDataType _TIFFSampleToTagType(TIFF*); -#if defined(__cplusplus) -} -#endif -#endif /* _TIFFDIR_ */ diff --git a/Utilities/CAI/cai_dll/inc/tif_fax3.h b/Utilities/CAI/cai_dll/inc/tif_fax3.h deleted file mode 100755 index a9f1fcb23b389f4dd08a641abae475ecb911bbf8..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/tif_fax3.h +++ /dev/null @@ -1,522 +0,0 @@ -/* $Id$ */ - -/* - * Copyright (c) 1990-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _FAX3_ -#define _FAX3_ -/* - * TIFF Library. - * - * CCITT Group 3 (T.4) and Group 4 (T.6) Decompression Support. - * - * Decoder support is derived, with permission, from the code - * in Frank Cringle's viewfax program; - * Copyright (C) 1990, 1995 Frank D. Cringle. - */ -#include "tiff.h" - -/* - * To override the default routine used to image decoded - * spans one can use the pseduo tag TIFFTAG_FAXFILLFUNC. - * The routine must have the type signature given below; - * for example: - * - * fillruns(unsigned char* buf, uint32* runs, uint32* erun, uint32 lastx) - * - * where buf is place to set the bits, runs is the array of b&w run - * lengths (white then black), erun is the last run in the array, and - * lastx is the width of the row in pixels. Fill routines can assume - * the run array has room for at least lastx runs and can overwrite - * data in the run array as needed (e.g. to append zero runs to bring - * the count up to a nice multiple). - */ -typedef void (*TIFFFaxFillFunc)(unsigned char*, uint32*, uint32*, uint32); - -/* - * The default run filler; made external for other decoders. - */ -#if defined(__cplusplus) -extern "C" { -#endif -extern void _TIFFFax3fillruns(unsigned char*, uint32*, uint32*, uint32); -#if defined(__cplusplus) -} -#endif - - -/* finite state machine codes */ -#define S_Null 0 -#define S_Pass 1 -#define S_Horiz 2 -#define S_V0 3 -#define S_VR 4 -#define S_VL 5 -#define S_Ext 6 -#define S_TermW 7 -#define S_TermB 8 -#define S_MakeUpW 9 -#define S_MakeUpB 10 -#define S_MakeUp 11 -#define S_EOL 12 - -typedef struct { /* state table entry */ - unsigned char State; /* see above */ - unsigned char Width; /* width of code in bits */ - uint32 Param; /* unsigned 32-bit run length in bits */ -} TIFFFaxTabEnt; - -extern const TIFFFaxTabEnt TIFFFaxMainTable[]; -extern const TIFFFaxTabEnt TIFFFaxWhiteTable[]; -extern const TIFFFaxTabEnt TIFFFaxBlackTable[]; - -/* - * The following macros define the majority of the G3/G4 decoder - * algorithm using the state tables defined elsewhere. To build - * a decoder you need some setup code and some glue code. Note - * that you may also need/want to change the way the NeedBits* - * macros get input data if, for example, you know the data to be - * decoded is properly aligned and oriented (doing so before running - * the decoder can be a big performance win). - * - * Consult the decoder in the TIFF library for an idea of what you - * need to define and setup to make use of these definitions. - * - * NB: to enable a debugging version of these macros define FAX3_DEBUG - * before including this file. Trace output goes to stdout. - */ - -#ifndef EndOfData -#define EndOfData() (cp >= ep) -#endif -/* - * Need <=8 or <=16 bits of input data. Unlike viewfax we - * cannot use/assume a word-aligned, properly bit swizzled - * input data set because data may come from an arbitrarily - * aligned, read-only source such as a memory-mapped file. - * Note also that the viewfax decoder does not check for - * running off the end of the input data buffer. This is - * possible for G3-encoded data because it prescans the input - * data to count EOL markers, but can cause problems for G4 - * data. In any event, we don't prescan and must watch for - * running out of data since we can't permit the library to - * scan past the end of the input data buffer. - * - * Finally, note that we must handle remaindered data at the end - * of a strip specially. The coder asks for a fixed number of - * bits when scanning for the next code. This may be more bits - * than are actually present in the data stream. If we appear - * to run out of data but still have some number of valid bits - * remaining then we makeup the requested amount with zeros and - * return successfully. If the returned data is incorrect then - * we should be called again and get a premature EOF error; - * otherwise we should get the right answer. - */ -#ifndef NeedBits8 -#define NeedBits8(n,eoflab) do { \ - if (BitsAvail < (n)) { \ - if (EndOfData()) { \ - if (BitsAvail == 0) /* no valid bits */ \ - goto eoflab; \ - BitsAvail = (n); /* pad with zeros */ \ - } else { \ - BitAcc |= ((uint32) bitmap[*cp++])<<BitsAvail; \ - BitsAvail += 8; \ - } \ - } \ -} while (0) -#endif -#ifndef NeedBits16 -#define NeedBits16(n,eoflab) do { \ - if (BitsAvail < (n)) { \ - if (EndOfData()) { \ - if (BitsAvail == 0) /* no valid bits */ \ - goto eoflab; \ - BitsAvail = (n); /* pad with zeros */ \ - } else { \ - BitAcc |= ((uint32) bitmap[*cp++])<<BitsAvail; \ - if ((BitsAvail += 8) < (n)) { \ - if (EndOfData()) { \ - /* NB: we know BitsAvail is non-zero here */ \ - BitsAvail = (n); /* pad with zeros */ \ - } else { \ - BitAcc |= ((uint32) bitmap[*cp++])<<BitsAvail; \ - BitsAvail += 8; \ - } \ - } \ - } \ - } \ -} while (0) -#endif -#define GetBits(n) (BitAcc & ((1<<(n))-1)) -#define ClrBits(n) do { \ - BitsAvail -= (n); \ - BitAcc >>= (n); \ -} while (0) - -#ifdef FAX3_DEBUG -static const char* StateNames[] = { - "Null ", - "Pass ", - "Horiz ", - "V0 ", - "VR ", - "VL ", - "Ext ", - "TermW ", - "TermB ", - "MakeUpW", - "MakeUpB", - "MakeUp ", - "EOL ", -}; -#define DEBUG_SHOW putchar(BitAcc & (1 << t) ? '1' : '0') -#define LOOKUP8(wid,tab,eoflab) do { \ - int t; \ - NeedBits8(wid,eoflab); \ - TabEnt = tab + GetBits(wid); \ - printf("%08lX/%d: %s%5d\t", (long) BitAcc, BitsAvail, \ - StateNames[TabEnt->State], TabEnt->Param); \ - for (t = 0; t < TabEnt->Width; t++) \ - DEBUG_SHOW; \ - putchar('\n'); \ - fflush(stdout); \ - ClrBits(TabEnt->Width); \ -} while (0) -#define LOOKUP16(wid,tab,eoflab) do { \ - int t; \ - NeedBits16(wid,eoflab); \ - TabEnt = tab + GetBits(wid); \ - printf("%08lX/%d: %s%5d\t", (long) BitAcc, BitsAvail, \ - StateNames[TabEnt->State], TabEnt->Param); \ - for (t = 0; t < TabEnt->Width; t++) \ - DEBUG_SHOW; \ - putchar('\n'); \ - fflush(stdout); \ - ClrBits(TabEnt->Width); \ -} while (0) - -#define SETVAL(x) do { \ - *pa++ = RunLength + (x); \ - printf("SETVAL: %d\t%d\n", RunLength + (x), a0); \ - a0 += x; \ - RunLength = 0; \ -} while (0) -#else -#define LOOKUP8(wid,tab,eoflab) do { \ - NeedBits8(wid,eoflab); \ - TabEnt = tab + GetBits(wid); \ - ClrBits(TabEnt->Width); \ -} while (0) -#define LOOKUP16(wid,tab,eoflab) do { \ - NeedBits16(wid,eoflab); \ - TabEnt = tab + GetBits(wid); \ - ClrBits(TabEnt->Width); \ -} while (0) - -/* - * Append a run to the run length array for the - * current row and reset decoding state. - */ -#define SETVAL(x) do { \ - *pa++ = RunLength + (x); \ - a0 += (x); \ - RunLength = 0; \ -} while (0) -#endif - -/* - * Synchronize input decoding at the start of each - * row by scanning for an EOL (if appropriate) and - * skipping any trash data that might be present - * after a decoding error. Note that the decoding - * done elsewhere that recognizes an EOL only consumes - * 11 consecutive zero bits. This means that if EOLcnt - * is non-zero then we still need to scan for the final flag - * bit that is part of the EOL code. - */ -#define SYNC_EOL(eoflab) do { \ - if (EOLcnt == 0) { \ - for (;;) { \ - NeedBits16(11,eoflab); \ - if (GetBits(11) == 0) \ - break; \ - ClrBits(1); \ - } \ - } \ - for (;;) { \ - NeedBits8(8,eoflab); \ - if (GetBits(8)) \ - break; \ - ClrBits(8); \ - } \ - while (GetBits(1) == 0) \ - ClrBits(1); \ - ClrBits(1); /* EOL bit */ \ - EOLcnt = 0; /* reset EOL counter/flag */ \ -} while (0) - -/* - * Cleanup the array of runs after decoding a row. - * We adjust final runs to insure the user buffer is not - * overwritten and/or undecoded area is white filled. - */ -#define CLEANUP_RUNS() do { \ - if (RunLength) \ - SETVAL(0); \ - if (a0 != lastx) { \ - badlength(a0, lastx); \ - while (a0 > lastx && pa > thisrun) \ - a0 -= *--pa; \ - if (a0 < lastx) { \ - if (a0 < 0) \ - a0 = 0; \ - if ((pa-thisrun)&1) \ - SETVAL(0); \ - SETVAL(lastx - a0); \ - } else if (a0 > lastx) { \ - SETVAL(lastx); \ - SETVAL(0); \ - } \ - } \ -} while (0) - -/* - * Decode a line of 1D-encoded data. - * - * The line expanders are written as macros so that they can be reused - * but still have direct access to the local variables of the "calling" - * function. - * - * Note that unlike the original version we have to explicitly test for - * a0 >= lastx after each black/white run is decoded. This is because - * the original code depended on the input data being zero-padded to - * insure the decoder recognized an EOL before running out of data. - */ -#define EXPAND1D(eoflab) do { \ - for (;;) { \ - for (;;) { \ - LOOKUP16(12, TIFFFaxWhiteTable, eof1d); \ - switch (TabEnt->State) { \ - case S_EOL: \ - EOLcnt = 1; \ - goto done1d; \ - case S_TermW: \ - SETVAL(TabEnt->Param); \ - goto doneWhite1d; \ - case S_MakeUpW: \ - case S_MakeUp: \ - a0 += TabEnt->Param; \ - RunLength += TabEnt->Param; \ - break; \ - default: \ - unexpected("WhiteTable", a0); \ - goto done1d; \ - } \ - } \ - doneWhite1d: \ - if (a0 >= lastx) \ - goto done1d; \ - for (;;) { \ - LOOKUP16(13, TIFFFaxBlackTable, eof1d); \ - switch (TabEnt->State) { \ - case S_EOL: \ - EOLcnt = 1; \ - goto done1d; \ - case S_TermB: \ - SETVAL(TabEnt->Param); \ - goto doneBlack1d; \ - case S_MakeUpB: \ - case S_MakeUp: \ - a0 += TabEnt->Param; \ - RunLength += TabEnt->Param; \ - break; \ - default: \ - unexpected("BlackTable", a0); \ - goto done1d; \ - } \ - } \ - doneBlack1d: \ - if (a0 >= lastx) \ - goto done1d; \ - } \ -eof1d: \ - prematureEOF(a0); \ - CLEANUP_RUNS(); \ - goto eoflab; \ -done1d: \ - CLEANUP_RUNS(); \ -} while (0) - -/* - * Update the value of b1 using the array - * of runs for the reference line. - */ -#define CHECK_b1 do { \ - if (pa != thisrun) while (b1 <= a0 && b1 < lastx) { \ - b1 += pb[0] + pb[1]; \ - pb += 2; \ - } \ -} while (0) - -/* - * Expand a row of 2D-encoded data. - */ -#define EXPAND2D(eoflab) do { \ - while (a0 < lastx) { \ - LOOKUP8(7, TIFFFaxMainTable, eof2d); \ - switch (TabEnt->State) { \ - case S_Pass: \ - CHECK_b1; \ - b1 += *pb++; \ - RunLength += b1 - a0; \ - a0 = b1; \ - b1 += *pb++; \ - break; \ - case S_Horiz: \ - if ((pa-thisrun)&1) { \ - for (;;) { /* black first */ \ - LOOKUP16(13, TIFFFaxBlackTable, eof2d); \ - switch (TabEnt->State) { \ - case S_TermB: \ - SETVAL(TabEnt->Param); \ - goto doneWhite2da; \ - case S_MakeUpB: \ - case S_MakeUp: \ - a0 += TabEnt->Param; \ - RunLength += TabEnt->Param; \ - break; \ - default: \ - goto badBlack2d; \ - } \ - } \ - doneWhite2da:; \ - for (;;) { /* then white */ \ - LOOKUP16(12, TIFFFaxWhiteTable, eof2d); \ - switch (TabEnt->State) { \ - case S_TermW: \ - SETVAL(TabEnt->Param); \ - goto doneBlack2da; \ - case S_MakeUpW: \ - case S_MakeUp: \ - a0 += TabEnt->Param; \ - RunLength += TabEnt->Param; \ - break; \ - default: \ - goto badWhite2d; \ - } \ - } \ - doneBlack2da:; \ - } else { \ - for (;;) { /* white first */ \ - LOOKUP16(12, TIFFFaxWhiteTable, eof2d); \ - switch (TabEnt->State) { \ - case S_TermW: \ - SETVAL(TabEnt->Param); \ - goto doneWhite2db; \ - case S_MakeUpW: \ - case S_MakeUp: \ - a0 += TabEnt->Param; \ - RunLength += TabEnt->Param; \ - break; \ - default: \ - goto badWhite2d; \ - } \ - } \ - doneWhite2db:; \ - for (;;) { /* then black */ \ - LOOKUP16(13, TIFFFaxBlackTable, eof2d); \ - switch (TabEnt->State) { \ - case S_TermB: \ - SETVAL(TabEnt->Param); \ - goto doneBlack2db; \ - case S_MakeUpB: \ - case S_MakeUp: \ - a0 += TabEnt->Param; \ - RunLength += TabEnt->Param; \ - break; \ - default: \ - goto badBlack2d; \ - } \ - } \ - doneBlack2db:; \ - } \ - CHECK_b1; \ - break; \ - case S_V0: \ - CHECK_b1; \ - SETVAL(b1 - a0); \ - b1 += *pb++; \ - break; \ - case S_VR: \ - CHECK_b1; \ - SETVAL(b1 - a0 + TabEnt->Param); \ - b1 += *pb++; \ - break; \ - case S_VL: \ - CHECK_b1; \ - SETVAL(b1 - a0 - TabEnt->Param); \ - b1 -= *--pb; \ - break; \ - case S_Ext: \ - *pa++ = lastx - a0; \ - extension(a0); \ - goto eol2d; \ - case S_EOL: \ - *pa++ = lastx - a0; \ - NeedBits8(5,eof2d); \ - if (GetBits(5)) \ - unexpected("EOL", a0); \ - EOLcnt = 1; \ - goto eol2d; \ - default: \ - badMain2d: \ - unexpected("MainTable", a0); \ - goto eol2d; \ - badBlack2d: \ - unexpected("BlackTable", a0); \ - goto eol2d; \ - badWhite2d: \ - unexpected("WhiteTable", a0); \ - goto eol2d; \ - eof2d: \ - prematureEOF(a0); \ - CLEANUP_RUNS(); \ - goto eoflab; \ - } \ - } \ - if (RunLength) { \ - if (RunLength + a0 < lastx) { \ - /* expect a final V0 */ \ - NeedBits8(1,eof2d); \ - if (!GetBits(1)) \ - goto badMain2d; \ - ClrBits(1); \ - } \ - SETVAL(0); \ - } \ -eol2d: \ - CLEANUP_RUNS(); \ -} while (0) -#endif /* _FAX3_ */ diff --git a/Utilities/CAI/cai_dll/inc/tif_predict.h b/Utilities/CAI/cai_dll/inc/tif_predict.h deleted file mode 100755 index 52ce8cba5ad209bc4cdf67f58f9819352806d070..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/tif_predict.h +++ /dev/null @@ -1,61 +0,0 @@ -/* $Header: tif_predict.h,v 1.1 01/01/15 15:24:36 cmf Exp $ */ - -/* - * Copyright (c) 1995-1997 Sam Leffler - * Copyright (c) 1995-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _TIFFPREDICT_ -#define _TIFFPREDICT_ -/* - * ``Library-private'' Support for the Predictor Tag - */ - -/* - * Codecs that want to support the Predictor tag must place - * this structure first in their private state block so that - * the predictor code can cast tif_data to find its state. - */ -typedef struct { - int predictor; /* predictor tag value */ - int stride; /* sample stride over data */ - tsize_t rowsize; /* tile/strip row size */ - - TIFFPostMethod pfunc; /* horizontal differencer/accumulator */ - TIFFCodeMethod coderow; /* parent codec encode/decode row */ - TIFFCodeMethod codestrip; /* parent codec encode/decode strip */ - TIFFCodeMethod codetile; /* parent codec encode/decode tile */ - TIFFVGetMethod vgetparent; /* super-class method */ - TIFFVSetMethod vsetparent; /* super-class method */ - TIFFPrintMethod printdir; /* super-class method */ - TIFFBoolMethod setupdecode; /* super-class method */ - TIFFBoolMethod setupencode; /* super-class method */ -} TIFFPredictorState; - -#if defined(__cplusplus) -extern "C" { -#endif -extern int TIFFPredictorInit(TIFF*); -#if defined(__cplusplus) -} -#endif -#endif /* _TIFFPREDICT_ */ diff --git a/Utilities/CAI/cai_dll/inc/tiff.h b/Utilities/CAI/cai_dll/inc/tiff.h deleted file mode 100755 index f4e08027c614ca1158a45ced31ffc2bced39d52e..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/tiff.h +++ /dev/null @@ -1,440 +0,0 @@ -/* $Header: tiff.h,v 1.3 01/01/15 15:24:31 cmf Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _TIFF_ -#define _TIFF_ -/* - * Tag Image File Format (TIFF) - * - * Based on Rev 6.0 from: - * Developer's Desk - * Aldus Corporation - * 411 First Ave. South - * Suite 200 - * Seattle, WA 98104 - * 206-622-5500 - */ -#define TIFF_VERSION 42 - -#define TIFF_BIGENDIAN 0x4d4d -#define TIFF_LITTLEENDIAN 0x4949 - -#ifndef _TIFF_DATA_TYPEDEFS_ -#define _TIFF_DATA_TYPEDEFS_ -/* - * Intrinsic data types required by the file format: - * - * 8-bit quantities int8TIFF/uint8TIFF - * 16-bit quantities int16TIFF/uint16TIFF - * 32-bit quantities int32TIFF/uint32TIFF - * strings unsigned char* - */ -/*#ifdef __STDC__ -typedef signed char int8TIFF;*/ /* NB: non-ANSI compilers may not grok */ -/*#else -typedef char int8TIFF; -#endif Modif Regine*/ -typedef char int8TIFF; -typedef unsigned char uint8TIFF; -typedef short int16TIFF; -typedef unsigned short uint16TIFF; /* sizeof (uint16TIFF) must == 2 */ -#if defined(__alpha) ||defined(__LP64__)||defined(__sparcv9) || (defined(_MIPS_SZLONG) && _MIPS_SZLONG == 64) -typedef int int32TIFF; -typedef unsigned int uint32TIFF; /* sizeof (uint32TIFF) must == 4 */ -#else -typedef long int32TIFF; -typedef unsigned long uint32TIFF; /* sizeof (uint32TIFF) must == 4 */ -#endif -#endif /* _TIFF_DATA_TYPEDEFS_ */ - -/* For TIFFReassignTagToIgnore */ -enum TIFFIgnoreSense /* IGNORE tag table */ -{ - TIS_STORE, - TIS_EXTRACT, - TIS_EMPTY -}; - -typedef struct { - uint16TIFF tiff_magic; /* magic number (defines byte order) */ - uint16TIFF tiff_version; /* TIFF version number */ - uint32TIFF tiff_diroff; /* byte offset to first directory */ -} TIFFHeader; - -/* - * TIFF Image File Directories are comprised of - * a table of field descriptors of the form shown - * below. The table is sorted in ascending order - * by tag. The values associated with each entry - * are disjoint and may appear anywhere in the file - * (so long as they are placed on a word boundary). - * - * If the value is 4 bytes or less, then it is placed - * in the offset field to save space. If the value - * is less than 4 bytes, it is left-justified in the - * offset field. - */ -typedef struct { - uint16TIFF tdir_tag; /* see below */ - uint16TIFF tdir_type; /* data type; see below */ - uint32TIFF tdir_count; /* number of items; length in spec */ - uint32TIFF tdir_offset; /* byte offset to field data */ -} TIFFDirEntry; - -/* - * NB: In the comments below, - * - items marked with a + are obsoleted by revision 5.0, - * - items marked with a ! are introduced in revision 6.0. - * - items marked with a % are introduced post revision 6.0. - * - items marked with a $ are obsoleted by revision 6.0. - */ - -/* - * Tag data type information. - * - * Note: RATIONALs are the ratio of two 32-bit integer values. - */ -typedef enum { - TIFF_NOTYPE = 0, /* placeholder */ - TIFF_BYTE = 1, /* 8-bit unsigned integer */ - TIFF_ASCII = 2, /* 8-bit bytes w/ last byte null */ - TIFF_SHORT = 3, /* 16-bit unsigned integer */ - TIFF_LONG = 4, /* 32-bit unsigned integer */ - TIFF_RATIONAL = 5, /* 64-bit unsigned fraction */ - TIFF_SBYTE = 6, /* !8-bit signed integer */ - TIFF_UNDEFINED = 7, /* !8-bit untyped data */ - TIFF_SSHORT = 8, /* !16-bit signed integer */ - TIFF_SLONG = 9, /* !32-bit signed integer */ - TIFF_SRATIONAL = 10, /* !64-bit signed fraction */ - TIFF_FLOAT = 11, /* !32-bit IEEE floating point */ - TIFF_DOUBLE = 12 /* !64-bit IEEE floating point */ -} TIFFDataType; - -/* - * TIFF Tag Definitions. - */ -#define TIFFTAG_SUBFILETYPE 254 /* subfile data descriptor */ -#define FILETYPE_REDUCEDIMAGE 0x1 /* reduced resolution version */ -#define FILETYPE_PAGE 0x2 /* one page of many */ -#define FILETYPE_MASK 0x4 /* transparency mask */ -#define TIFFTAG_OSUBFILETYPE 255 /* +kind of data in subfile */ -#define OFILETYPE_IMAGE 1 /* full resolution image data */ -#define OFILETYPE_REDUCEDIMAGE 2 /* reduced size image data */ -#define OFILETYPE_PAGE 3 /* one page of many */ -#define TIFFTAG_IMAGEWIDTH 256 /* image width in pixels */ -#define TIFFTAG_IMAGELENGTH 257 /* image height in pixels */ -#define TIFFTAG_BITSPERSAMPLE 258 /* bits per channel (sample) */ -#define TIFFTAG_COMPRESSION 259 /* data compression technique */ -#define COMPRESSION_NONE 1 /* dump mode */ -#define COMPRESSION_CCITTRLE 2 /* CCITT modified Huffman RLE */ -#define COMPRESSION_CCITTFAX3 3 /* CCITT Group 3 fax encoding */ -#define COMPRESSION_CCITTFAX4 4 /* CCITT Group 4 fax encoding */ -#define COMPRESSION_LZW 5 /* Lempel-Ziv & Welch */ -#define COMPRESSION_OJPEG 6 /* !6.0 JPEG */ -#define COMPRESSION_JPEG 7 /* %JPEG DCT compression */ -#define COMPRESSION_NEXT 32766 /* NeXT 2-bit RLE */ -#define COMPRESSION_CCITTRLEW 32771 /* #1 w/ word alignment */ -#define COMPRESSION_PACKBITS 32773 /* Macintosh RLE */ -#define COMPRESSION_THUNDERSCAN 32809 /* ThunderScan RLE */ -/* codes 32895-32898 are reserved for ANSI IT8 TIFF/IT <dkelly@etsinc.com) */ -#define COMPRESSION_IT8CTPAD 32895 /* IT8 CT w/padding */ -#define COMPRESSION_IT8LW 32896 /* IT8 Linework RLE */ -#define COMPRESSION_IT8MP 32897 /* IT8 Monochrome picture */ -#define COMPRESSION_IT8BL 32898 /* IT8 Binary line art */ -/* compression codes 32908-32911 are reserved for Pixar */ -#define COMPRESSION_PIXARFILM 32908 /* Pixar companded 10bit LZW */ -#define COMPRESSION_PIXARLOG 32909 /* Pixar companded 11bit ZIP */ -#define COMPRESSION_DEFLATE 32946 /* Deflate compression */ -#define COMPRESSION_ADOBE_DEFLATE 8 /* Deflate compression, as recognized by Adobe */ -/* compression code 32947 is reserved for Oceana Matrix <dev@oceana.com> */ -#define COMPRESSION_DCS 32947 /* Kodak DCS encoding */ -#define COMPRESSION_JBIG 34661 /* ISO JBIG */ -#define COMPRESSION_SGILOG 34676 /* SGI Log Luminance RLE */ -#define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */ -#define TIFFTAG_PHOTOMETRIC 262 /* photometric interpretation */ -#define PHOTOMETRIC_MINISWHITE 0 /* min value is white */ -#define PHOTOMETRIC_MINISBLACK 1 /* min value is black */ -#define PHOTOMETRIC_RGB 2 /* RGB color model */ -#define PHOTOMETRIC_PALETTE 3 /* color map indexed */ -#define PHOTOMETRIC_MASK 4 /* $holdout mask */ -#define PHOTOMETRIC_SEPARATED 5 /* !color separations */ -#define PHOTOMETRIC_YCBCR 6 /* !CCIR 601 */ -#define PHOTOMETRIC_CIELAB 8 /* !1976 CIE L*a*b* */ -#define PHOTOMETRIC_LOGL 32844 /* CIE Log2(L) */ -#define PHOTOMETRIC_LOGLUV 32845 /* CIE Log2(L) (u',v') */ -#define TIFFTAG_THRESHHOLDING 263 /* +thresholding used on data */ -#define THRESHHOLD_BILEVEL 1 /* b&w art scan */ -#define THRESHHOLD_HALFTONE 2 /* or dithered scan */ -#define THRESHHOLD_ERRORDIFFUSE 3 /* usually floyd-steinberg */ -#define TIFFTAG_CELLWIDTH 264 /* +dithering matrix width */ -#define TIFFTAG_CELLLENGTH 265 /* +dithering matrix height */ -#define TIFFTAG_FILLORDER 266 /* data order within a byte */ -#define FILLORDER_MSB2LSB 1 /* most significant -> least */ -#define FILLORDER_LSB2MSB 2 /* least significant -> most */ -#define TIFFTAG_DOCUMENTNAME 269 /* name of doc. image is from */ -#define TIFFTAG_IMAGEDESCRIPTION 270 /* info about image */ -#define TIFFTAG_MAKE 271 /* scanner manufacturer name */ -#define TIFFTAG_MODEL 272 /* scanner model name/number */ -#define TIFFTAG_STRIPOFFSETS 273 /* offsets to data strips */ -#define TIFFTAG_ORIENTATION 274 /* +image orientation */ -#define ORIENTATION_TOPLEFT 1 /* row 0 top, col 0 lhs */ -#define ORIENTATION_TOPRIGHT 2 /* row 0 top, col 0 rhs */ -#define ORIENTATION_BOTRIGHT 3 /* row 0 bottom, col 0 rhs */ -#define ORIENTATION_BOTLEFT 4 /* row 0 bottom, col 0 lhs */ -#define ORIENTATION_LEFTTOP 5 /* row 0 lhs, col 0 top */ -#define ORIENTATION_RIGHTTOP 6 /* row 0 rhs, col 0 top */ -#define ORIENTATION_RIGHTBOT 7 /* row 0 rhs, col 0 bottom */ -#define ORIENTATION_LEFTBOT 8 /* row 0 lhs, col 0 bottom */ -#define TIFFTAG_SAMPLESPERPIXEL 277 /* samples per pixel */ -#define TIFFTAG_ROWSPERSTRIP 278 /* rows per strip of data */ -#define TIFFTAG_STRIPBYTECOUNTS 279 /* bytes counts for strips */ -#define TIFFTAG_MINSAMPLEVALUE 280 /* +minimum sample value */ -#define TIFFTAG_MAXSAMPLEVALUE 281 /* +maximum sample value */ -#define TIFFTAG_XRESOLUTION 282 /* pixels/resolution in x */ -#define TIFFTAG_YRESOLUTION 283 /* pixels/resolution in y */ -#define TIFFTAG_PLANARCONFIG 284 /* storage organization */ -#define PLANARCONFIG_CONTIG 1 /* single image plane */ -#define PLANARCONFIG_SEPARATE 2 /* separate planes of data */ -#define TIFFTAG_PAGENAME 285 /* page name image is from */ -#define TIFFTAG_XPOSITION 286 /* x page offset of image lhs */ -#define TIFFTAG_YPOSITION 287 /* y page offset of image lhs */ -#define TIFFTAG_FREEOFFSETS 288 /* +byte offset to free block */ -#define TIFFTAG_FREEBYTECOUNTS 289 /* +sizes of free blocks */ -#define TIFFTAG_GRAYRESPONSEUNIT 290 /* $gray scale curve accuracy */ -#define GRAYRESPONSEUNIT_10S 1 /* tenths of a unit */ -#define GRAYRESPONSEUNIT_100S 2 /* hundredths of a unit */ -#define GRAYRESPONSEUNIT_1000S 3 /* thousandths of a unit */ -#define GRAYRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ -#define GRAYRESPONSEUNIT_100000S 5 /* hundred-thousandths */ -#define TIFFTAG_GRAYRESPONSECURVE 291 /* $gray scale response curve */ -#define TIFFTAG_GROUP3OPTIONS 292 /* 32 flag bits */ -#define GROUP3OPT_2DENCODING 0x1 /* 2-dimensional coding */ -#define GROUP3OPT_UNCOMPRESSED 0x2 /* data not compressed */ -#define GROUP3OPT_FILLBITS 0x4 /* fill to byte boundary */ -#define TIFFTAG_GROUP4OPTIONS 293 /* 32 flag bits */ -#define GROUP4OPT_UNCOMPRESSED 0x2 /* data not compressed */ -#define TIFFTAG_RESOLUTIONUNIT 296 /* units of resolutions */ -#define RESUNIT_NONE 1 /* no meaningful units */ -#define RESUNIT_INCH 2 /* english */ -#define RESUNIT_CENTIMETER 3 /* metric */ -#define TIFFTAG_PAGENUMBER 297 /* page numbers of multi-page */ -#define TIFFTAG_COLORRESPONSEUNIT 300 /* $color curve accuracy */ -#define COLORRESPONSEUNIT_10S 1 /* tenths of a unit */ -#define COLORRESPONSEUNIT_100S 2 /* hundredths of a unit */ -#define COLORRESPONSEUNIT_1000S 3 /* thousandths of a unit */ -#define COLORRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ -#define COLORRESPONSEUNIT_100000S 5 /* hundred-thousandths */ -#define TIFFTAG_TRANSFERFUNCTION 301 /* !colorimetry info */ -#define TIFFTAG_SOFTWARE 305 /* name & release */ -#define TIFFTAG_DATETIME 306 /* creation date and time */ -#define TIFFTAG_ARTIST 315 /* creator of image */ -#define TIFFTAG_HOSTCOMPUTER 316 /* machine where created */ -#define TIFFTAG_PREDICTOR 317 /* prediction scheme w/ LZW */ -#define TIFFTAG_WHITEPOINT 318 /* image white point */ -#define TIFFTAG_PRIMARYCHROMATICITIES 319 /* !primary chromaticities */ -#define TIFFTAG_COLORMAP 320 /* RGB map for pallette image */ -#define TIFFTAG_HALFTONEHINTS 321 /* !highlight+shadow info */ -#define TIFFTAG_TILEWIDTH 322 /* !rows/data tile */ -#define TIFFTAG_TILELENGTH 323 /* !cols/data tile */ -#define TIFFTAG_TILEOFFSETS 324 /* !offsets to data tiles */ -#define TIFFTAG_TILEBYTECOUNTS 325 /* !byte counts for tiles */ -#define TIFFTAG_BADFAXLINES 326 /* lines w/ wrong pixel count */ -#define TIFFTAG_CLEANFAXDATA 327 /* regenerated line info */ -#define CLEANFAXDATA_CLEAN 0 /* no errors detected */ -#define CLEANFAXDATA_REGENERATED 1 /* receiver regenerated lines */ -#define CLEANFAXDATA_UNCLEAN 2 /* uncorrected errors exist */ -#define TIFFTAG_CONSECUTIVEBADFAXLINES 328 /* max consecutive bad lines */ -#define TIFFTAG_SUBIFD 330 /* subimage descriptors */ -#define TIFFTAG_INKSET 332 /* !inks in separated image */ -#define INKSET_CMYK 1 /* !cyan-magenta-yellow-black */ -#define TIFFTAG_INKNAMES 333 /* !ascii names of inks */ -#define TIFFTAG_NUMBEROFINKS 334 /* !number of inks */ -#define TIFFTAG_DOTRANGE 336 /* !0% and 100% dot codes */ -#define TIFFTAG_TARGETPRINTER 337 /* !separation target */ -#define TIFFTAG_EXTRASAMPLES 338 /* !info about extra samples */ -#define EXTRASAMPLE_UNSPECIFIED 0 /* !unspecified data */ -#define EXTRASAMPLE_ASSOCALPHA 1 /* !associated alpha data */ -#define EXTRASAMPLE_UNASSALPHA 2 /* !unassociated alpha data */ -#define TIFFTAG_SAMPLEFORMAT 339 /* !data sample format */ -#define SAMPLEFORMAT_UINT 1 /* !unsigned integer data */ -#define SAMPLEFORMAT_INT 2 /* !signed integer data */ -#define SAMPLEFORMAT_IEEEFP 3 /* !IEEE floating point data */ -#define SAMPLEFORMAT_VOID 4 /* !untyped data */ -#define TIFFTAG_SMINSAMPLEVALUE 340 /* !variable MinSampleValue */ -#define TIFFTAG_SMAXSAMPLEVALUE 341 /* !variable MaxSampleValue */ -#define TIFFTAG_JPEGTABLES 347 /* %JPEG table stream */ -/* - * Tags 512-521 are obsoleted by Technical Note #2 - * which specifies a revised JPEG-in-TIFF scheme. - */ -#define TIFFTAG_JPEGPROC 512 /* !JPEG processing algorithm */ -#define JPEGPROC_BASELINE 1 /* !baseline sequential */ -#define JPEGPROC_LOSSLESS 14 /* !Huffman coded lossless */ -#define TIFFTAG_JPEGIFOFFSET 513 /* !pointer to SOI marker */ -#define TIFFTAG_JPEGIFBYTECOUNT 514 /* !JFIF stream length */ -#define TIFFTAG_JPEGRESTARTINTERVAL 515 /* !restart interval length */ -#define TIFFTAG_JPEGLOSSLESSPREDICTORS 517 /* !lossless proc predictor */ -#define TIFFTAG_JPEGPOINTTRANSFORM 518 /* !lossless point transform */ -#define TIFFTAG_JPEGQTABLES 519 /* !Q matrice offsets */ -#define TIFFTAG_JPEGDCTABLES 520 /* !DCT table offsets */ -#define TIFFTAG_JPEGACTABLES 521 /* !AC coefficient offsets */ -#define TIFFTAG_YCBCRCOEFFICIENTS 529 /* !RGB -> YCbCr transform */ -#define TIFFTAG_YCBCRSUBSAMPLING 530 /* !YCbCr subsampling factors */ -#define TIFFTAG_YCBCRPOSITIONING 531 /* !subsample positioning */ -#define YCBCRPOSITION_CENTERED 1 /* !as in PostScript Level 2 */ -#define YCBCRPOSITION_COSITED 2 /* !as in CCIR 601-1 */ -#define TIFFTAG_REFERENCEBLACKWHITE 532 /* !colorimetry info */ -/* tags 32952-32956 are private tags registered to Island Graphics */ -#define TIFFTAG_REFPTS 32953 /* image reference points */ -#define TIFFTAG_REGIONTACKPOINT 32954 /* region-xform tack point */ -#define TIFFTAG_REGIONWARPCORNERS 32955 /* warp quadrilateral */ -#define TIFFTAG_REGIONAFFINE 32956 /* affine transformation mat */ -/* tags 32995-32999 are private tags registered to SGI */ -#define TIFFTAG_MATTEING 32995 /* $use ExtraSamples */ -#define TIFFTAG_DATATYPE 32996 /* $use SampleFormat */ -#define TIFFTAG_IMAGEDEPTH 32997 /* z depth of image */ -#define TIFFTAG_TILEDEPTH 32998 /* z depth/data tile */ -/* tags 33300-33309 are private tags registered to Pixar */ -/* - * TIFFTAG_PIXAR_IMAGEFULLWIDTH and TIFFTAG_PIXAR_IMAGEFULLLENGTH - * are set when an image has been cropped out of a larger image. - * They reflect the size of the original uncropped image. - * The TIFFTAG_XPOSITION and TIFFTAG_YPOSITION can be used - * to determine the position of the smaller image in the larger one. - */ -#define TIFFTAG_PIXAR_IMAGEFULLWIDTH 33300 /* full image size in x */ -#define TIFFTAG_PIXAR_IMAGEFULLLENGTH 33301 /* full image size in y */ - /* Tags 33302-33306 are used to identify special image modes and data - * used by Pixar's texture formats. - */ -#define TIFFTAG_PIXAR_TEXTUREFORMAT 33302 /* texture map format */ -#define TIFFTAG_PIXAR_WRAPMODES 33303 /* s & t wrap modes */ -#define TIFFTAG_PIXAR_FOVCOT 33304 /* cotan(fov) for env. maps */ -#define TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN 33305 -#define TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA 33306 -/* tag 33405 is a private tag registered to Eastman Kodak */ -#define TIFFTAG_WRITERSERIALNUMBER 33405 /* device serial number */ -/* tag 33432 is listed in the 6.0 spec w/ unknown ownership */ -#define TIFFTAG_COPYRIGHT 33432 /* copyright string */ -/* IPTC TAG from RichTIFF specifications */ -#define TIFFTAG_RICHTIFFIPTC 33723 -/* 34016-34029 are reserved for ANSI IT8 TIFF/IT <dkelly@etsinc.com) */ -#define TIFFTAG_IT8SITE 34016 /* site name */ -#define TIFFTAG_IT8COLORSEQUENCE 34017 /* color seq. [RGB,CMYK,etc] */ -#define TIFFTAG_IT8HEADER 34018 /* DDES Header */ -#define TIFFTAG_IT8RASTERPADDING 34019 /* raster scanline padding */ -#define TIFFTAG_IT8BITSPERRUNLENGTH 34020 /* # of bits in short run */ -#define TIFFTAG_IT8BITSPEREXTENDEDRUNLENGTH 34021/* # of bits in long run */ -#define TIFFTAG_IT8COLORTABLE 34022 /* LW colortable */ -#define TIFFTAG_IT8IMAGECOLORINDICATOR 34023 /* BP/BL image color switch */ -#define TIFFTAG_IT8BKGCOLORINDICATOR 34024 /* BP/BL bg color switch */ -#define TIFFTAG_IT8IMAGECOLORVALUE 34025 /* BP/BL image color value */ -#define TIFFTAG_IT8BKGCOLORVALUE 34026 /* BP/BL bg color value */ -#define TIFFTAG_IT8PIXELINTENSITYRANGE 34027 /* MP pixel intensity value */ -#define TIFFTAG_IT8TRANSPARENCYINDICATOR 34028 /* HC transparency switch */ -#define TIFFTAG_IT8COLORCHARACTERIZATION 34029 /* color character. table */ -/* tags 34232-34236 are private tags registered to Texas Instruments */ -#define TIFFTAG_FRAMECOUNT 34232 /* Sequence Frame Count */ -/* tag 34750 is a private tag registered to Adobe? */ -#define TIFFTAG_ICCPROFILE 34675 /* ICC profile data */ -/* tag 34377 is private tag registered to Adobe for PhotoShop */ -#define TIFFTAG_PHOTOSHOP 34377 -/* tag 34750 is a private tag registered to Pixel Magic */ -#define TIFFTAG_JBIGOPTIONS 34750 /* JBIG options */ -/* tags 34908-34914 are private tags registered to SGI */ -#define TIFFTAG_FAXRECVPARAMS 34908 /* encoded Class 2 ses. parms */ -#define TIFFTAG_FAXSUBADDRESS 34909 /* received SubAddr string */ -#define TIFFTAG_FAXRECVTIME 34910 /* receive time (secs) */ -/* tags 37439-37443 are registered to SGI <gregl@sgi.com> */ -#define TIFFTAG_STONITS 37439 /* Sample value to Nits */ -/* tag 34929 is a private tag registered to FedEx */ -#define TIFFTAG_FEDEX_EDR 34929 /* unknown use */ -/* tag 65535 is an undefined tag used by Eastman Kodak */ -#define TIFFTAG_DCSHUESHIFTVALUES 65535 /* hue shift correction data */ - -/* - * The following are ``pseudo tags'' that can be - * used to control codec-specific functionality. - * These tags are not written to file. Note that - * these values start at 0xffff+1 so that they'll - * never collide with Aldus-assigned tags. - * - * If you want your private pseudo tags ``registered'' - * (i.e. added to this file), send mail to sam@sgi.com - * with the appropriate C definitions to add. - */ -#define TIFFTAG_FAXMODE 65536 /* Group 3/4 format control */ -#define FAXMODE_CLASSIC 0x0000 /* default, include RTC */ -#define FAXMODE_NORTC 0x0001 /* no RTC at end of data */ -#define FAXMODE_NOEOL 0x0002 /* no EOL code at end of row */ -#define FAXMODE_BYTEALIGN 0x0004 /* byte align row */ -#define FAXMODE_WORDALIGN 0x0008 /* word align row */ -#define FAXMODE_CLASSF FAXMODE_NORTC /* TIFF Class F */ -#define TIFFTAG_JPEGQUALITY 65537 /* Compression quality level */ -/* Note: quality level is on the IJG 0-100 scale. Default value is 75 */ -#define TIFFTAG_JPEGCOLORMODE 65538 /* Auto RGB<=>YCbCr convert? */ -#define JPEGCOLORMODE_RAW 0x0000 /* no conversion (default) */ -#define JPEGCOLORMODE_RGB 0x0001 /* do auto conversion */ -#define TIFFTAG_JPEGTABLESMODE 65539 /* What to put in JPEGTables */ -#define JPEGTABLESMODE_QUANT 0x0001 /* include quantization tbls */ -#define JPEGTABLESMODE_HUFF 0x0002 /* include Huffman tbls */ -/* Note: default is JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF */ -#define TIFFTAG_FAXFILLFUNC 65540 /* G3/G4 fill function */ -#define TIFFTAG_PIXARLOGDATAFMT 65549 /* PixarLogCodec I/O data sz */ -#define PIXARLOGDATAFMT_8BIT 0 /* regular u_char samples */ -#define PIXARLOGDATAFMT_8BITABGR 1 /* ABGR-order u_chars */ -#define PIXARLOGDATAFMT_11BITLOG 2 /* 11-bit log-encoded (raw) */ -#define PIXARLOGDATAFMT_12BITPICIO 3 /* as per PICIO (1.0==2048) */ -#define PIXARLOGDATAFMT_16BIT 4 /* signed short samples */ -#define PIXARLOGDATAFMT_FLOAT 5 /* IEEE float samples */ -/* 65550-65556 are allocated to Oceana Matrix <dev@oceana.com> */ -#define TIFFTAG_DCSIMAGERTYPE 65550 /* imager model & filter */ -#define DCSIMAGERMODEL_M3 0 /* M3 chip (1280 x 1024) */ -#define DCSIMAGERMODEL_M5 1 /* M5 chip (1536 x 1024) */ -#define DCSIMAGERMODEL_M6 2 /* M6 chip (3072 x 2048) */ -#define DCSIMAGERFILTER_IR 0 /* infrared filter */ -#define DCSIMAGERFILTER_MONO 1 /* monochrome filter */ -#define DCSIMAGERFILTER_CFA 2 /* color filter array */ -#define DCSIMAGERFILTER_OTHER 3 /* other filter */ -#define TIFFTAG_DCSINTERPMODE 65551 /* interpolation mode */ -#define DCSINTERPMODE_NORMAL 0x0 /* whole image, default */ -#define DCSINTERPMODE_PREVIEW 0x1 /* preview of image (384x256) */ -#define TIFFTAG_DCSBALANCEARRAY 65552 /* color balance values */ -#define TIFFTAG_DCSCORRECTMATRIX 65553 /* color correction values */ -#define TIFFTAG_DCSGAMMA 65554 /* gamma value */ -#define TIFFTAG_DCSTOESHOULDERPTS 65555 /* toe & shoulder points */ -#define TIFFTAG_DCSCALIBRATIONFD 65556 /* calibration file desc */ -/* Note: quality level is on the ZLIB 1-9 scale. Default value is -1 */ -#define TIFFTAG_ZIPQUALITY 65557 /* compression quality level */ -#define TIFFTAG_PIXARLOGQUALITY 65558 /* PixarLog uses same scale */ -/* 65559 is allocated to Oceana Matrix <dev@oceana.com> */ -#define TIFFTAG_DCSCLIPRECTANGLE 65559 /* area of image to acquire */ -#define TIFFTAG_SGILOGDATAFMT 65560 /* SGILog user data format */ -#define SGILOGDATAFMT_FLOAT 0 /* IEEE float samples */ -#define SGILOGDATAFMT_16BIT 1 /* 16-bit samples */ -#define SGILOGDATAFMT_RAW 2 /* uninterpreted data */ -#define SGILOGDATAFMT_8BIT 3 /* 8-bit RGB monitor values */ -#endif /* _TIFF_ */ diff --git a/Utilities/CAI/cai_dll/inc/tiffcomp.h b/Utilities/CAI/cai_dll/inc/tiffcomp.h deleted file mode 100755 index bd2d86d3c33d616d38ca5cdb5e92d8ae442b7d09..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/tiffcomp.h +++ /dev/null @@ -1,214 +0,0 @@ -/* $Header: tiffcomp.h,v 1.3 01/01/15 15:24:32 cmf Exp $ */ - -/* - * Copyright (c) 1990-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _COMPAT_ -#define _COMPAT_ -/* - * This file contains a hodgepodge of definitions and - * declarations that are needed to provide compatibility - * between the native system and the base implementation - * that the library assumes. - * - * NB: This file is a mess. - */ - -/* - * Setup basic type definitions and function declaratations. - */ - -/* - * Simplify Acorn RISC OS identifier (to avoid confusion with Acorn RISC iX - * and with defunct Unix Risc OS) - * No need to specify __arm - hey, Acorn might port the OS, no problem here! - */ -#ifdef __acornriscos -#undef __acornriscos -#endif -#if defined(__acorn) && defined(__riscos) -#define __acornriscos -#endif - -#if defined(__MWERKS__) || defined(THINK_C) -#include <unix.h> -#include <math.h> -#endif - -#include <stdio.h> - -#if defined(__PPCC__) || defined(__SC__) || defined(__MRC__) -#include <types.h> -#elif !defined(__MWERKS__) && !defined(THINK_C) && !defined(__acornriscos) && !defined(applec) -#include <sys/types.h> -#endif - -#if defined(VMS) -#include <file.h> -#include <unixio.h> -#elif !defined(__acornriscos) -#include <fcntl.h> -#endif - -/* - * This maze of checks controls defines or not the - * target system has BSD-style typdedefs declared in - * an include file and/or whether or not to include - * <unistd.h> to get the SEEK_* definitions. Some - * additional includes are also done to pull in the - * appropriate definitions we're looking for. - */ -#if defined(__MWERKS__) || defined(THINK_C) || defined(__PPCC__) || defined(__SC__) || defined(__MRC__) -#include <stdlib.h> -#define BSDTYPES -#define HAVE_UNISTD_H 0 -#elif defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows) -#define BSDTYPES -#elif defined(OS2_16) || defined(OS2_32) -#define BSDTYPES -#elif defined(__acornriscos) -#include <stdlib.h> -#define BSDTYPES -#define HAVE_UNISTD_H 0 -#elif defined(VMS) -#define HAVE_UNISTD_H 0 -#else -#define HAVE_UNISTD_H 1 -#endif - -/* - * The library uses the ANSI C/POSIX SEEK_* - * definitions that should be defined in unistd.h - * (except on system where they are in stdio.h and - * there is no unistd.h). - */ -#if !defined(SEEK_SET) && HAVE_UNISTD_H -#include <unistd.h> -#endif - -/* - * The library uses memset, memcpy, and memcmp. - * ANSI C and System V define these in string.h. - */ -#include <string.h> - -/* - * The BSD typedefs are used throughout the library. - * If your system doesn't have them in <sys/types.h>, - * then define BSDTYPES in your Makefile. - */ -#if defined(BSDTYPES) -typedef unsigned char u_char; -typedef unsigned short u_short; -typedef unsigned int u_int; -typedef unsigned long u_long; -#endif - -/* - * dblparam_t is the type that a double precision - * floating point value will have on the parameter - * stack (when coerced by the compiler). - */ -/* Note: on MacPowerPC "extended" is undefined. So only use it for 68K-Macs */ -#if defined(__SC__) || defined(THINK_C) -typedef extended dblparam_t; -#else -typedef double dblparam_t; -#endif - -/* - * If your compiler supports inline functions, then - * set INLINE appropriately to get the known hotspots - * in the library expanded inline. - */ -#if defined(__GNUC__) -#if defined(__STRICT_ANSI__) -#define INLINE __inline__ -#else -#define INLINE inline -#endif -#else /* !__GNUC__ */ -#define INLINE -#endif - -/* - * GLOBALDATA is a macro that is used to define global variables - * private to the library. We use this indirection to hide - * brain-damage in VAXC (and GCC) under VAX/VMS. In these - * environments the macro places the variable in a non-shareable - * program section, which ought to be done by default (sigh!) - * - * Apparently DEC are aware of the problem as this behaviour is the - * default under VMS on AXP. - * - * The GNU C variant is untested. - */ -#if defined(VAX) && defined(VMS) -#if defined(VAXC) -#define GLOBALDATA(TYPE,NAME) extern noshare TYPE NAME -#endif -#if defined(__GNUC__) -#define GLOBALDATA(TYPE,NAME) extern TYPE NAME \ - asm("_$$PsectAttributes_NOSHR$$" #NAME) -#endif -#else /* !VAX/VMS */ -#define GLOBALDATA(TYPE,NAME) extern TYPE NAME -#endif - -#if defined(__acornriscos) -/* - * osfcn.h is part of C++Lib on Acorn C/C++, and as such can't be used - * on C alone. For that reason, the relevant functions are - * implemented in tif_acorn.c, and the elements from the header - * file are included here. - */ -#if defined(__cplusplus) -#include <osfcn.h> -#else -#define O_RDONLY 0 -#define O_WRONLY 1 -#define O_RDWR 2 -#define O_APPEND 8 -#define O_CREAT 0x200 -#define O_TRUNC 0x400 -typedef long off_t; -extern int open(const char *name, int flags, int mode); -extern int close(int fd); -extern int write(int fd, const char *buf, int nbytes); -extern int read(int fd, char *buf, int nbytes); -extern off_t lseek(int fd, off_t offset, int whence); -extern int creat(const char *path, int mode); -#endif /* __cplusplus */ -#endif /* __acornriscos */ - -/* Bit and byte order, the default is MSB to LSB */ -#ifdef VMS -#undef HOST_FILLORDER -#undef HOST_BIGENDIAN -#define HOST_FILLORDER FILLORDER_LSB2MSB -#define HOST_BIGENDIAN 0 -#endif - - -#endif /* _COMPAT_ */ diff --git a/Utilities/CAI/cai_dll/inc/tiffconf.h b/Utilities/CAI/cai_dll/inc/tiffconf.h deleted file mode 100755 index b7f75a26a75d6429878e270e2181b0acaec4cfec..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/tiffconf.h +++ /dev/null @@ -1,143 +0,0 @@ -/* $Header: tiffconf.h,v 1.3 01/01/15 15:24:32 cmf Exp $ */ -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _TIFFCONF_ -#define _TIFFCONF_ -/* - * Library Configuration Definitions. - * - * This file defines the default configuration for the library. - * If the target system does not have make or a way to specify - * #defines on the command line, this file can be edited to - * configure the library. Otherwise, one can override portability - * and configuration-related definitions from a Makefile or command - * line by defining FEATURE_SUPPORT and COMPRESSION_SUPPORT (see below). - */ - -/* - * General portability-related defines: - * - * HAVE_IEEEFP define as 0 or 1 according to the floating point - * format suported by the machine - * BSDTYPES define this if your system does NOT define the - * usual 4BSD typedefs u_int et. al. - * HAVE_MMAP enable support for memory mapping read-only files; - * this is typically deduced by the configure script - * HOST_FILLORDER native cpu bit order: one of FILLORDER_MSB2LSB - * or FILLODER_LSB2MSB; this is typically set by the - * configure script - * HOST_BIGENDIAN native cpu byte order: 1 if big-endian (Motorola) - * or 0 if little-endian (Intel); this may be used - * in codecs to optimize code - * USE_64BIT_API set to 1 if tif_unix.c should use lseek64(), - * fstat64() and stat64 allowing 2-4GB files. - */ -#ifndef HAVE_IEEEFP -#define HAVE_IEEEFP 1 -#endif -#ifndef HOST_FILLORDER -#define HOST_FILLORDER FILLORDER_MSB2LSB -#endif -#ifndef HOST_BIGENDIAN -#define HOST_BIGENDIAN 1 -#endif - -#ifndef USE_64BIT_API -# define USE_64BIT_API 0 -#endif - -#ifndef FEATURE_SUPPORT -/* - * Feature support definitions: - * - * COLORIMETRY_SUPPORT enable support for 6.0 colorimetry tags - * YCBCR_SUPPORT enable support for 6.0 YCbCr tags - * CMYK_SUPPORT enable support for 6.0 CMYK tags - * ICC_SUPPORT enable support for ICC profile tag - * PHOTOSHOP_SUPPORT enable support for PHOTOSHOP resource tag - * IPTC_SUPPORT enable support for RichTIFF IPTC tag - */ -#define COLORIMETRY_SUPPORT -#define YCBCR_SUPPORT -#define CMYK_SUPPORT -#define ICC_SUPPORT -#define PHOTOSHOP_SUPPORT -#define IPTC_SUPPORT -#endif /* FEATURE_SUPPORT */ - -#ifndef COMPRESSION_SUPPORT -/* - * Compression support defines: - * - * CCITT_SUPPORT enable support for CCITT Group 3 & 4 algorithms - * PACKBITS_SUPPORT enable support for Macintosh PackBits algorithm - * LZW_SUPPORT enable support for LZW algorithm - * THUNDER_SUPPORT enable support for ThunderScan 4-bit RLE algorithm - * NEXT_SUPPORT enable support for NeXT 2-bit RLE algorithm - * OJPEG_SUPPORT enable support for 6.0-style JPEG DCT algorithms - * (no builtin support, only a codec hook) - * JPEG_SUPPORT enable support for post-6.0-style JPEG DCT algorithms - * (requires freely available IJG software, see tif_jpeg.c) - * ZIP_SUPPORT enable support for Deflate algorithm - * (requires freely available zlib software, see tif_zip.c) - * PIXARLOG_SUPPORT enable support for Pixar log-format algorithm - * LOGLUV_SUPPORT enable support for LogLuv high dynamic range encoding - */ -#define CCITT_SUPPORT -#define PACKBITS_SUPPORT -#define LZW_SUPPORT -#define THUNDER_SUPPORT -#define NEXT_SUPPORT -#define LOGLUV_SUPPORT -#endif /* COMPRESSION_SUPPORT */ - -/* - * If JPEG compression is enabled then we must also include - * support for the colorimetry and YCbCr-related tags. - */ -#ifdef JPEG_SUPPORT -#ifndef YCBCR_SUPPORT -#define YCBCR_SUPPORT -#endif -#ifndef COLORIMETRY_SUPPORT -#define COLORIMETRY_SUPPORT -#endif -#endif /* JPEG_SUPPORT */ - -/* - * ``Orthogonal Features'' - * - * STRIPCHOP_DEFAULT default handling of strip chopping support (whether - * or not to convert single-strip uncompressed images - * to mutiple strips of ~8Kb--to reduce memory use) - * SUBIFD_SUPPORT enable support for SubIFD tag (thumbnails and such) - */ -#ifndef STRIPCHOP_DEFAULT -#define STRIPCHOP_DEFAULT TIFF_STRIPCHOP /* default is to enable */ -#endif -#ifndef SUBIFD_SUPPORT -#define SUBIFD_SUPPORT 1 /* enable SubIFD tag (330) support */ -#endif -#endif /* _TIFFCONF_ */ diff --git a/Utilities/CAI/cai_dll/inc/tiffio.h b/Utilities/CAI/cai_dll/inc/tiffio.h deleted file mode 100755 index 50e063ba294046bc964b33f27cc22d242d775110..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/tiffio.h +++ /dev/null @@ -1,334 +0,0 @@ -/* $Header: tiffio.h,v 1.3 01/01/15 15:24:33 cmf Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _TIFFIO_ -#define _TIFFIO_ - -/* - * TIFF I/O Library Definitions. - */ -#include "tiff.h" - -/* - * This define can be used in code that requires - * compilation-related definitions specific to a - * version or versions of the library. Runtime - * version checking should be done based on the - * string returned by TIFFGetVersion. - */ -#define TIFFLIB_VERSION 19970127 /* January 27, 1997 */ - -/* - * TIFF is defined as an incomplete type to hide the - * library's internal data structures from clients. - */ -typedef struct tiff TIFF; - -/* - * The following typedefs define the intrinsic size of - * data types used in the *exported* interfaces. These - * definitions depend on the proper definition of types - * in tiff.h. Note also that the varargs interface used - * to pass tag types and values uses the types defined in - * tiff.h directly. - * - * NB: ttag_t is unsigned int and not unsigned short because - * ANSI C requires that the type before the ellipsis be a - * promoted type (i.e. one of int, unsigned int, pointer, - * or double) and because we defined pseudo-tags that are - * outside the range of legal Aldus-assigned tags. - * NB: tsize_t is int32TIFF and not uint32TIFF because some functions - * return -1. - * NB: toff_t is not off_t for many reasons; TIFFs max out at - * 32-bit file offsets being the most important, and to ensure - * that it is unsigned, rather than signed. - */ -typedef uint32TIFF ttag_t; /* directory tag */ -typedef uint16TIFF tdir_t; /* directory index */ -typedef uint16TIFF tsample_t; /* sample number */ -typedef uint32TIFF tstrip_t; /* strip number */ -typedef uint32TIFF ttile_t; /* tile number */ -typedef int32TIFF tsize_t; /* i/o size in bytes */ -typedef void* tdata_t; /* image data ref */ -typedef uint32TIFF toff_t; /* file offset */ - -#if !defined(__WIN32__) && (defined(_WIN32) || defined(WIN32)) -#define __WIN32__ -#endif - -/* MODIF PC NT */ -#undef _WINDOWS -#undef __WIN32__ -#undef _Windows - - -#if defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows) -#include <windows.h> -#ifdef __WIN32__ -DECLARE_HANDLE(thandle_t); /* Win32 file handle */ -#else -typedef HFILE thandle_t; /* client data handle */ -#endif -#else -typedef void* thandle_t; /* client data handle */ -#endif - -#ifndef NULL -#define NULL 0 -#endif - -/* - * Flags to pass to TIFFPrintDirectory to control - * printing of data structures that are potentially - * very large. Bit-or these flags to enable printing - * multiple items. - */ -#define TIFFPRINT_NONE 0x0 /* no extra info */ -#define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */ -#define TIFFPRINT_CURVES 0x2 /* color/gray response curves */ -#define TIFFPRINT_COLORMAP 0x4 /* colormap */ -#define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */ -#define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */ -#define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */ - -/* - * RGBA-style image support. - */ -typedef unsigned char TIFFRGBValue; /* 8-bit samples */ -typedef struct _TIFFRGBAImage TIFFRGBAImage; -/* - * The image reading and conversion routines invoke - * ``put routines'' to copy/image/whatever tiles of - * raw image data. A default set of routines are - * provided to convert/copy raw image data to 8-bit - * packed ABGR format rasters. Applications can supply - * alternate routines that unpack the data into a - * different format or, for example, unpack the data - * and draw the unpacked raster on the display. - */ -typedef void (*tileContigRoutine) - (TIFFRGBAImage*, uint32TIFF*, uint32TIFF, uint32TIFF, uint32TIFF, uint32TIFF, int32TIFF, int32TIFF, - unsigned char*); -typedef void (*tileSeparateRoutine) - (TIFFRGBAImage*, uint32TIFF*, uint32TIFF, uint32TIFF, uint32TIFF, uint32TIFF, int32TIFF, int32TIFF, - unsigned char*, unsigned char*, unsigned char*, unsigned char*); -/* - * RGBA-reader state. - */ -typedef struct { /* YCbCr->RGB support */ - TIFFRGBValue* clamptab; /* range clamping table */ - int* Cr_r_tab; - int* Cb_b_tab; - int32TIFF* Cr_g_tab; - int32TIFF* Cb_g_tab; - float coeffs[3]; /* cached for repeated use */ -} TIFFYCbCrToRGB; - -struct _TIFFRGBAImage { - TIFF* tif; /* image handle */ - int stoponerr; /* stop on read error */ - int isContig; /* data is packed/separate */ - int alpha; /* type of alpha data present */ - uint32TIFF width; /* image width */ - uint32TIFF height; /* image height */ - uint16TIFF bitspersample; /* image bits/sample */ - uint16TIFF samplesperpixel; /* image samples/pixel */ - uint16TIFF orientation; /* image orientation */ - uint16TIFF photometric; /* image photometric interp */ - uint16TIFF* redcmap; /* colormap pallete */ - uint16TIFF* greencmap; - uint16TIFF* bluecmap; - /* get image data routine */ - int (*get)(TIFFRGBAImage*, uint32TIFF*, uint32TIFF, uint32TIFF); - union { - void (*any)(TIFFRGBAImage*); - tileContigRoutine contig; - tileSeparateRoutine separate; - } put; /* put decoded strip/tile */ - TIFFRGBValue* Map; /* sample mapping array */ - uint32TIFF** BWmap; /* black&white map */ - uint32TIFF** PALmap; /* palette image map */ - TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */ - - int row_offset; - int col_offset; -}; - -/* - * Macros for extracting components from the - * packed ABGR form returned by TIFFReadRGBAImage. - */ -#define TIFFGetR(abgr) ((abgr) & 0xff) -#define TIFFGetG(abgr) (((abgr) >> 8) & 0xff) -#define TIFFGetB(abgr) (((abgr) >> 16) & 0xff) -#define TIFFGetA(abgr) (((abgr) >> 24) & 0xff) - -/* - * A CODEC is a software package that implements decoding, - * encoding, or decoding+encoding of a compression algorithm. - * The library provides a collection of builtin codecs. - * More codecs may be registered through calls to the library - * and/or the builtin implementations may be overridden. - */ -typedef int (*TIFFInitMethod)(TIFF*, int); -typedef struct { - char* name; - uint16TIFF scheme; - TIFFInitMethod init; -} TIFFCodec; - -#include <stdio.h> -#include <stdarg.h> - -#if defined(__cplusplus) -extern "C" { -#endif -typedef void (*TIFFErrorHandler)(const char*, const char*, va_list); -typedef tsize_t (*TIFFReadWriteProc)(thandle_t, tdata_t, tsize_t); -typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int); -typedef int (*TIFFCloseProc)(thandle_t); -typedef toff_t (*TIFFSizeProc)(thandle_t); -typedef int (*TIFFMapFileProc)(thandle_t, tdata_t*, toff_t*); -typedef void (*TIFFUnmapFileProc)(thandle_t, tdata_t, toff_t); -typedef void (*TIFFExtendProc)(TIFF*); - -extern const char* TIFFGetVersion(void); - -extern const TIFFCodec* TIFFFindCODEC(uint16TIFF); -extern TIFFCodec* TIFFRegisterCODEC(uint16TIFF, const char*, TIFFInitMethod); -extern void TIFFUnRegisterCODEC(TIFFCodec*); - -extern tdata_t _TIFFmalloc(tsize_t); -extern tdata_t _TIFFrealloc(tdata_t, tsize_t); -extern void _TIFFmemset(tdata_t, int, tsize_t); -extern void _TIFFmemcpy(tdata_t, const tdata_t, tsize_t); -extern int _TIFFmemcmp(const tdata_t, const tdata_t, tsize_t); -extern void _TIFFfree(tdata_t); - -extern void TIFFClose(TIFF*); -extern int TIFFFlush(TIFF*); -extern int TIFFFlushData(TIFF*); -extern int TIFFGetField(TIFF*, ttag_t, ...); -extern int TIFFVGetField(TIFF*, ttag_t, va_list); -extern int TIFFGetFieldDefaulted(TIFF*, ttag_t, ...); -extern int TIFFVGetFieldDefaulted(TIFF*, ttag_t, va_list); -extern int TIFFReadDirectory(TIFF*); -extern tsize_t TIFFScanlineSize(TIFF*); -extern tsize_t TIFFRasterScanlineSize(TIFF*); -extern tsize_t TIFFStripSize(TIFF*); -extern tsize_t TIFFVStripSize(TIFF*, uint32TIFF); -extern tsize_t TIFFTileRowSize(TIFF*); -extern tsize_t TIFFTileSize(TIFF*); -extern tsize_t TIFFVTileSize(TIFF*, uint32TIFF); -extern uint32TIFF TIFFDefaultStripSize(TIFF*, uint32TIFF); -extern void TIFFDefaultTileSize(TIFF*, uint32TIFF*, uint32TIFF*); -extern int TIFFFileno(TIFF*); -extern int TIFFGetMode(TIFF*); -extern int TIFFIsTiled(TIFF*); -extern int TIFFIsByteSwapped(TIFF*); -extern int TIFFIsUpSampled(TIFF*); -extern int TIFFIsMSB2LSB(TIFF*); -extern uint32TIFF TIFFCurrentRow(TIFF*); -extern tdir_t TIFFCurrentDirectory(TIFF*); -extern tdir_t TIFFNumberOfDirectories(TIFF*); -extern uint32TIFF TIFFCurrentDirOffset(TIFF*); -extern tstrip_t TIFFCurrentStrip(TIFF*); -extern ttile_t TIFFCurrentTile(TIFF*); -extern int TIFFReadBufferSetup(TIFF*, tdata_t, tsize_t); -extern int TIFFWriteBufferSetup(TIFF*, tdata_t, tsize_t); -extern int TIFFWriteCheck(TIFF*, int, const char *); -extern int TIFFCreateDirectory(TIFF*); -extern int TIFFLastDirectory(TIFF*); -extern int TIFFSetDirectory(TIFF*, tdir_t); -extern int TIFFSetSubDirectory(TIFF*, uint32TIFF); -extern int TIFFUnlinkDirectory(TIFF*, tdir_t); -extern int TIFFSetField(TIFF*, ttag_t, ...); -extern int TIFFVSetField(TIFF*, ttag_t, va_list); -extern int TIFFWriteDirectory(TIFF *); -extern int TIFFReassignTagToIgnore(enum TIFFIgnoreSense, int); - -#if defined(c_plusplus) || defined(__cplusplus) -extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0); -extern int TIFFReadScanline(TIFF*, tdata_t, uint32TIFF, tsample_t = 0); -extern int TIFFWriteScanline(TIFF*, tdata_t, uint32TIFF, tsample_t = 0); -extern int TIFFReadRGBAImage(TIFF*, uint32TIFF, uint32TIFF, uint32TIFF*, int = 0); -#else -extern void TIFFPrintDirectory(TIFF*, FILE*, long); -extern int TIFFReadScanline(TIFF*, tdata_t, uint32TIFF, tsample_t); -extern int TIFFWriteScanline(TIFF*, tdata_t, uint32TIFF, tsample_t); -extern int TIFFReadRGBAImage(TIFF*, uint32TIFF, uint32TIFF, uint32TIFF*, int); -#endif - -extern int TIFFReadRGBAStrip(TIFF*, tstrip_t, uint32TIFF * ); -extern int TIFFReadRGBATile(TIFF*, uint32TIFF, uint32TIFF, uint32TIFF * ); -extern int TIFFRGBAImageOK(TIFF*, char [1024]); -extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]); -extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32TIFF*, uint32TIFF, uint32TIFF); -extern void TIFFRGBAImageEnd(TIFFRGBAImage*); -extern TIFF* TIFFOpen(const char*, const char*); -extern TIFF* TIFFFdOpen(int, const char*, const char*); -extern TIFF* TIFFClientOpen(const char*, const char*, - thandle_t, - TIFFReadWriteProc, TIFFReadWriteProc, - TIFFSeekProc, TIFFCloseProc, - TIFFSizeProc, - TIFFMapFileProc, TIFFUnmapFileProc); -extern const char* TIFFFileName(TIFF*); -extern void TIFFError(const char*, const char*, ...); -extern void TIFFWarning(const char*, const char*, ...); -extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler); -extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler); -extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc); -extern ttile_t TIFFComputeTile(TIFF*, uint32TIFF, uint32TIFF, uint32TIFF, tsample_t); -extern int TIFFCheckTile(TIFF*, uint32TIFF, uint32TIFF, uint32TIFF, tsample_t); -extern ttile_t TIFFNumberOfTiles(TIFF*); -extern tsize_t TIFFReadTile(TIFF*, - tdata_t, uint32TIFF, uint32TIFF, uint32TIFF, tsample_t); -extern tsize_t TIFFWriteTile(TIFF*, - tdata_t, uint32TIFF, uint32TIFF, uint32TIFF, tsample_t); -extern tstrip_t TIFFComputeStrip(TIFF*, uint32TIFF, tsample_t); -extern tstrip_t TIFFNumberOfStrips(TIFF*); -extern tsize_t TIFFReadEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t); -extern tsize_t TIFFReadRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t); -extern tsize_t TIFFReadEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t); -extern tsize_t TIFFReadRawTile(TIFF*, ttile_t, tdata_t, tsize_t); -extern tsize_t TIFFWriteEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t); -extern tsize_t TIFFWriteRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t); -extern tsize_t TIFFWriteEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t); -extern tsize_t TIFFWriteRawTile(TIFF*, ttile_t, tdata_t, tsize_t); -extern void TIFFSetWriteOffset(TIFF*, toff_t); -extern void TIFFSwabShort(uint16TIFF*); -extern void TIFFSwabLong(uint32TIFF*); -extern void TIFFSwabDouble(double*); -extern void TIFFSwabArrayOfShort(uint16TIFF*, unsigned long); -extern void TIFFSwabArrayOfLong(uint32TIFF*, unsigned long); -extern void TIFFSwabArrayOfDouble(double*, unsigned long); -extern void TIFFReverseBits(unsigned char *, unsigned long); -extern const unsigned char* TIFFGetBitRevTable(int); -#if defined(__cplusplus) -} -#endif -#endif /* _TIFFIO_ */ diff --git a/Utilities/CAI/cai_dll/inc/tiffiop.h b/Utilities/CAI/cai_dll/inc/tiffiop.h deleted file mode 100755 index e86fff4debb77446cb176c2b07352c22f840d641..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/tiffiop.h +++ /dev/null @@ -1,279 +0,0 @@ -/* $Header: tiffiop.h,v 1.3 01/01/15 15:24:34 cmf Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _TIFFIOP_ -#define _TIFFIOP_ -/* - * ``Library-private'' definitions. - */ -/* - * UNIX systems should run the configure script to generate - * a port.h file that reflects the system capabilities. - * Doing this obviates all the dreck done in tiffcomp.h. - */ -#if defined(unix) || defined(__unix) -#include "port.h" -#include "tiffconf.h" -#else -#include "tiffconf.h" -#include "tiffcomp.h" -#endif -#include "tiffio.h" -#include "tif_dir.h" - -#ifndef TRUE -#define TRUE 1 -#define FALSE 0 -#endif - -/* - * Typedefs for ``method pointers'' used internally. - */ -typedef unsigned char tidataval_t; /* internal image data value type */ -typedef tidataval_t* tidata_t; /* reference to internal image data */ - -typedef void (*TIFFVoidMethod)(TIFF*); -typedef int (*TIFFBoolMethod)(TIFF*); -typedef int (*TIFFPreMethod)(TIFF*, tsample_t); -typedef int (*TIFFCodeMethod)(TIFF*, tidata_t, tsize_t, tsample_t); -typedef int (*TIFFSeekMethod)(TIFF*, uint32); -typedef void (*TIFFPostMethod)(TIFF*, tidata_t, tsize_t); -typedef int (*TIFFVSetMethod)(TIFF*, ttag_t, va_list); -typedef int (*TIFFVGetMethod)(TIFF*, ttag_t, va_list); -typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long); -typedef uint32 (*TIFFStripMethod)(TIFF*, uint32); -typedef void (*TIFFTileMethod)(TIFF*, uint32*, uint32*); - -struct tiff { - char* tif_name; /* name of open file */ - int tif_fd; /* open file descriptor */ - int tif_mode; /* open mode (O_*) */ - uint32 tif_flags; -#define TIFF_FILLORDER 0x0003 /* natural bit fill order for machine */ -#define TIFF_DIRTYHEADER 0x0004 /* header must be written on close */ -#define TIFF_DIRTYDIRECT 0x0008 /* current directory must be written */ -#define TIFF_BUFFERSETUP 0x0010 /* data buffers setup */ -#define TIFF_CODERSETUP 0x0020 /* encoder/decoder setup done */ -#define TIFF_BEENWRITING 0x0040 /* written 1+ scanlines to file */ -#define TIFF_SWAB 0x0080 /* byte swap file information */ -#define TIFF_NOBITREV 0x0100 /* inhibit bit reversal logic */ -#define TIFF_MYBUFFER 0x0200 /* my raw data buffer; free on close */ -#define TIFF_ISTILED 0x0400 /* file is tile, not strip- based */ -#define TIFF_MAPPED 0x0800 /* file is mapped into memory */ -#define TIFF_POSTENCODE 0x1000 /* need call to postencode routine */ -#define TIFF_INSUBIFD 0x2000 /* currently writing a subifd */ -#define TIFF_UPSAMPLED 0x4000 /* library is doing data up-sampling */ -#define TIFF_STRIPCHOP 0x8000 /* enable strip chopping support */ - toff_t tif_diroff; /* file offset of current directory */ - toff_t tif_nextdiroff; /* file offset of following directory */ - TIFFDirectory tif_dir; /* internal rep of current directory */ - TIFFHeader tif_header; /* file's header block */ - tidata_t tif_clientdir; /* client TIFF directory */ - const int* tif_typeshift; /* data type shift counts */ - const long* tif_typemask; /* data type masks */ - uint32 tif_row; /* current scanline */ - tdir_t tif_curdir; /* current directory (index) */ - tstrip_t tif_curstrip; /* current strip for read/write */ - toff_t tif_curoff; /* current offset for read/write */ - toff_t tif_dataoff; /* current offset for writing dir */ -#if SUBIFD_SUPPORT - uint16 tif_nsubifd; /* remaining subifds to write */ - toff_t tif_subifdoff; /* offset for patching SubIFD link */ -#endif -/* tiling support */ - uint32 tif_col; /* current column (offset by row too) */ - ttile_t tif_curtile; /* current tile for read/write */ - tsize_t tif_tilesize; /* # of bytes in a tile */ -/* compression scheme hooks */ - TIFFBoolMethod tif_setupdecode;/* called once before predecode */ - TIFFPreMethod tif_predecode; /* pre- row/strip/tile decoding */ - TIFFBoolMethod tif_setupencode;/* called once before preencode */ - TIFFPreMethod tif_preencode; /* pre- row/strip/tile encoding */ - TIFFBoolMethod tif_postencode; /* post- row/strip/tile encoding */ - TIFFCodeMethod tif_decoderow; /* scanline decoding routine */ - TIFFCodeMethod tif_encoderow; /* scanline encoding routine */ - TIFFCodeMethod tif_decodestrip;/* strip decoding routine */ - TIFFCodeMethod tif_encodestrip;/* strip encoding routine */ - TIFFCodeMethod tif_decodetile; /* tile decoding routine */ - TIFFCodeMethod tif_encodetile; /* tile encoding routine */ - TIFFVoidMethod tif_close; /* cleanup-on-close routine */ - TIFFSeekMethod tif_seek; /* position within a strip routine */ - TIFFVoidMethod tif_cleanup; /* cleanup state routine */ - TIFFStripMethod tif_defstripsize;/* calculate/constrain strip size */ - TIFFTileMethod tif_deftilesize;/* calculate/constrain tile size */ - tidata_t tif_data; /* compression scheme private data */ -/* input/output buffering */ - tsize_t tif_scanlinesize;/* # of bytes in a scanline */ - tsize_t tif_scanlineskew;/* scanline skew for reading strips */ - tidata_t tif_rawdata; /* raw data buffer */ - tsize_t tif_rawdatasize;/* # of bytes in raw data buffer */ - tidata_t tif_rawcp; /* current spot in raw buffer */ - tsize_t tif_rawcc; /* bytes unread from raw buffer */ -/* memory-mapped file support */ - tidata_t tif_base; /* base of mapped file */ - toff_t tif_size; /* size of mapped file region (bytes) */ - TIFFMapFileProc tif_mapproc; /* map file method */ - TIFFUnmapFileProc tif_unmapproc;/* unmap file method */ -/* input/output callback methods */ - thandle_t tif_clientdata; /* callback parameter */ - TIFFReadWriteProc tif_readproc; /* read method */ - TIFFReadWriteProc tif_writeproc;/* write method */ - TIFFSeekProc tif_seekproc; /* lseek method */ - TIFFCloseProc tif_closeproc; /* close method */ - TIFFSizeProc tif_sizeproc; /* filesize method */ -/* post-decoding support */ - TIFFPostMethod tif_postdecode; /* post decoding routine */ -/* tag support */ - TIFFFieldInfo** tif_fieldinfo; /* sorted table of registered tags */ - int tif_nfields; /* # entries in registered tag table */ - TIFFVSetMethod tif_vsetfield; /* tag set routine */ - TIFFVGetMethod tif_vgetfield; /* tag get routine */ - TIFFPrintMethod tif_printdir; /* directory print routine */ -}; - -#define isPseudoTag(t) (t > 0xffff) /* is tag value normal or pseudo */ - -#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0) -#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0) -#define isFillOrder(tif, o) (((tif)->tif_flags & (o)) != 0) -#define isUpSampled(tif) (((tif)->tif_flags & TIFF_UPSAMPLED) != 0) -#define TIFFReadFile(tif, buf, size) \ - ((*(tif)->tif_readproc)((tif)->tif_clientdata,buf,size)) -#define TIFFWriteFile(tif, buf, size) \ - ((*(tif)->tif_writeproc)((tif)->tif_clientdata,buf,size)) -#define TIFFSeekFile(tif, off, whence) \ - ((*(tif)->tif_seekproc)((tif)->tif_clientdata,(toff_t)(off),whence)) -#define TIFFCloseFile(tif) \ - ((*(tif)->tif_closeproc)((tif)->tif_clientdata)) -#define TIFFGetFileSize(tif) \ - ((*(tif)->tif_sizeproc)((tif)->tif_clientdata)) -#define TIFFMapFileContents(tif, paddr, psize) \ - ((*(tif)->tif_mapproc)((tif)->tif_clientdata,paddr,psize)) -#define TIFFUnmapFileContents(tif, addr, size) \ - ((*(tif)->tif_unmapproc)((tif)->tif_clientdata,addr,size)) - -/* - * Default Read/Seek/Write definitions. - */ -#ifndef ReadOK -#define ReadOK(tif, buf, size) \ - (TIFFReadFile(tif, (tdata_t) buf, (tsize_t)(size)) == (tsize_t)(size)) -#endif -#ifndef SeekOK -#define SeekOK(tif, off) \ - (TIFFSeekFile(tif, (toff_t) off, SEEK_SET) == (toff_t) off) -#endif -#ifndef WriteOK -#define WriteOK(tif, buf, size) \ - (TIFFWriteFile(tif, (tdata_t) buf, (tsize_t) size) == (tsize_t) size) -#endif - -/* NB: the uint32 casts are to silence certain ANSI-C compilers */ -#define TIFFhowmany(x, y) ((((uint32)(x))+(((uint32)(y))-1))/((uint32)(y))) -#define TIFFroundup(x, y) (TIFFhowmany(x,y)*((uint32)(y))) - -#if defined(__cplusplus) -extern "C" { -#endif -extern int _TIFFgetMode(const char*, const char*); -extern int _TIFFNoRowEncode(TIFF*, tidata_t, tsize_t, tsample_t); -extern int _TIFFNoStripEncode(TIFF*, tidata_t, tsize_t, tsample_t); -extern int _TIFFNoTileEncode(TIFF*, tidata_t, tsize_t, tsample_t); -extern int _TIFFNoRowDecode(TIFF*, tidata_t, tsize_t, tsample_t); -extern int _TIFFNoStripDecode(TIFF*, tidata_t, tsize_t, tsample_t); -extern int _TIFFNoTileDecode(TIFF*, tidata_t, tsize_t, tsample_t); -extern void _TIFFNoPostDecode(TIFF*, tidata_t, tsize_t); -extern int _TIFFNoPreCode (TIFF*, tsample_t); -extern int _TIFFNoSeek(TIFF*, uint32); -extern void _TIFFSwab16BitData(TIFF*, tidata_t, tsize_t); -extern void _TIFFSwab32BitData(TIFF*, tidata_t, tsize_t); -extern void _TIFFSwab64BitData(TIFF*, tidata_t, tsize_t); -extern int TIFFFlushData1(TIFF*); -extern void TIFFFreeDirectory(TIFF*); -extern int TIFFDefaultDirectory(TIFF*); -extern int TIFFSetCompressionScheme(TIFF*, int); -extern int TIFFSetDefaultCompressionState(TIFF*); -extern uint32 _TIFFDefaultStripSize(TIFF*, uint32); -extern void _TIFFDefaultTileSize(TIFF*, uint32*, uint32*); - -extern void _TIFFsetByteArray(void**, void*, long); -extern void _TIFFsetString(char**, char*); -extern void _TIFFsetShortArray(uint16**, uint16*, long); -extern void _TIFFsetLongArray(uint32**, uint32*, long); -extern void _TIFFsetFloatArray(float**, float*, long); -extern void _TIFFsetDoubleArray(double**, double*, long); - -extern void _TIFFprintAscii(FILE*, const char*); -extern void _TIFFprintAsciiTag(FILE*, const char*, const char*); - -GLOBALDATA(TIFFErrorHandler,_TIFFwarningHandler); -GLOBALDATA(TIFFErrorHandler,_TIFFerrorHandler); - -extern int TIFFInitDumpMode(TIFF*, int); -#ifdef PACKBITS_SUPPORT -extern int TIFFInitPackBits(TIFF*, int); -#endif -#ifdef CCITT_SUPPORT -extern int TIFFInitCCITTRLE(TIFF*, int), TIFFInitCCITTRLEW(TIFF*, int); -extern int TIFFInitCCITTFax3(TIFF*, int), TIFFInitCCITTFax4(TIFF*, int); -#endif -#ifdef THUNDER_SUPPORT -extern int TIFFInitThunderScan(TIFF*, int); -#endif -#ifdef NEXT_SUPPORT -extern int TIFFInitNeXT(TIFF*, int); -#endif -#ifdef LZW_SUPPORT -extern int TIFFInitLZW(TIFF*, int); -#endif -#ifdef OJPEG_SUPPORT -extern int TIFFInitOJPEG(TIFF*, int); -#endif -#ifdef JPEG_SUPPORT -extern int TIFFInitJPEG(TIFF*, int); -#endif -#ifdef JBIG_SUPPORT -extern int TIFFInitJBIG(TIFF*, int); -#endif -#ifdef ZIP_SUPPORT -extern int TIFFInitZIP(TIFF*, int); -#endif -#ifdef PIXARLOG_SUPPORT -extern int TIFFInitPixarLog(TIFF*, int); -#endif -#ifdef LOGLUV_SUPPORT -extern int TIFFInitSGILog(TIFF*, int); -#endif -#ifdef VMS -extern const TIFFCodec _TIFFBuiltinCODECS[]; -#else -extern TIFFCodec _TIFFBuiltinCODECS[]; -#endif - -#if defined(__cplusplus) -} -#endif -#endif /* _TIFFIOP_ */ diff --git a/Utilities/CAI/cai_dll/inc/uvcode.h b/Utilities/CAI/cai_dll/inc/uvcode.h deleted file mode 100755 index 8d96e445837c1843d19a34301cec1e0c08b02e5a..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/uvcode.h +++ /dev/null @@ -1,173 +0,0 @@ -/* Version 1.0 generated April 7, 1997 by Greg Ward Larson, SGI */ -#define UV_SQSIZ (float)0.003500 -#define UV_NDIVS 16289 -#define UV_VSTART (float)0.016940 -#define UV_NVS 163 -static struct { - float ustart; - short nus, ncum; -} uv_row[UV_NVS] = { - (float)0.247663, 4, 0, - (float)0.243779, 6, 4, - (float)0.241684, 7, 10, - (float)0.237874, 9, 17, - (float)0.235906, 10, 26, - (float)0.232153, 12, 36, - (float)0.228352, 14, 48, - (float)0.226259, 15, 62, - (float)0.222371, 17, 77, - (float)0.220410, 18, 94, - (float)0.214710, 21, 112, - (float)0.212714, 22, 133, - (float)0.210721, 23, 155, - (float)0.204976, 26, 178, - (float)0.202986, 27, 204, - (float)0.199245, 29, 231, - (float)0.195525, 31, 260, - (float)0.193560, 32, 291, - (float)0.189878, 34, 323, - (float)0.186216, 36, 357, - (float)0.186216, 36, 393, - (float)0.182592, 38, 429, - (float)0.179003, 40, 467, - (float)0.175466, 42, 507, - (float)0.172001, 44, 549, - (float)0.172001, 44, 593, - (float)0.168612, 46, 637, - (float)0.168612, 46, 683, - (float)0.163575, 49, 729, - (float)0.158642, 52, 778, - (float)0.158642, 52, 830, - (float)0.158642, 52, 882, - (float)0.153815, 55, 934, - (float)0.153815, 55, 989, - (float)0.149097, 58, 1044, - (float)0.149097, 58, 1102, - (float)0.142746, 62, 1160, - (float)0.142746, 62, 1222, - (float)0.142746, 62, 1284, - (float)0.138270, 65, 1346, - (float)0.138270, 65, 1411, - (float)0.138270, 65, 1476, - (float)0.132166, 69, 1541, - (float)0.132166, 69, 1610, - (float)0.126204, 73, 1679, - (float)0.126204, 73, 1752, - (float)0.126204, 73, 1825, - (float)0.120381, 77, 1898, - (float)0.120381, 77, 1975, - (float)0.120381, 77, 2052, - (float)0.120381, 77, 2129, - (float)0.112962, 82, 2206, - (float)0.112962, 82, 2288, - (float)0.112962, 82, 2370, - (float)0.107450, 86, 2452, - (float)0.107450, 86, 2538, - (float)0.107450, 86, 2624, - (float)0.107450, 86, 2710, - (float)0.100343, 91, 2796, - (float)0.100343, 91, 2887, - (float)0.100343, 91, 2978, - (float)0.095126, 95, 3069, - (float)0.095126, 95, 3164, - (float)0.095126, 95, 3259, - (float)0.095126, 95, 3354, - (float)0.088276, 100, 3449, - (float)0.088276, 100, 3549, - (float)0.088276, 100, 3649, - (float)0.088276, 100, 3749, - (float)0.081523, 105, 3849, - (float)0.081523, 105, 3954, - (float)0.081523, 105, 4059, - (float)0.081523, 105, 4164, - (float)0.074861, 110, 4269, - (float)0.074861, 110, 4379, - (float)0.074861, 110, 4489, - (float)0.074861, 110, 4599, - (float)0.068290, 115, 4709, - (float)0.068290, 115, 4824, - (float)0.068290, 115, 4939, - (float)0.068290, 115, 5054, - (float)0.063573, 119, 5169, - (float)0.063573, 119, 5288, - (float)0.063573, 119, 5407, - (float)0.063573, 119, 5526, - (float)0.057219, 124, 5645, - (float)0.057219, 124, 5769, - (float)0.057219, 124, 5893, - (float)0.057219, 124, 6017, - (float)0.050985, 129, 6141, - (float)0.050985, 129, 6270, - (float)0.050985, 129, 6399, - (float)0.050985, 129, 6528, - (float)0.050985, 129, 6657, - (float)0.044859, 134, 6786, - (float)0.044859, 134, 6920, - (float)0.044859, 134, 7054, - (float)0.044859, 134, 7188, - (float)0.040571, 138, 7322, - (float)0.040571, 138, 7460, - (float)0.040571, 138, 7598, - (float)0.040571, 138, 7736, - (float)0.036339, 142, 7874, - (float)0.036339, 142, 8016, - (float)0.036339, 142, 8158, - (float)0.036339, 142, 8300, - (float)0.032139, 146, 8442, - (float)0.032139, 146, 8588, - (float)0.032139, 146, 8734, - (float)0.032139, 146, 8880, - (float)0.027947, 150, 9026, - (float)0.027947, 150, 9176, - (float)0.027947, 150, 9326, - (float)0.023739, 154, 9476, - (float)0.023739, 154, 9630, - (float)0.023739, 154, 9784, - (float)0.023739, 154, 9938, - (float)0.019504, 158, 10092, - (float)0.019504, 158, 10250, - (float)0.019504, 158, 10408, - (float)0.016976, 161, 10566, - (float)0.016976, 161, 10727, - (float)0.016976, 161, 10888, - (float)0.016976, 161, 11049, - (float)0.012639, 165, 11210, - (float)0.012639, 165, 11375, - (float)0.012639, 165, 11540, - (float)0.009991, 168, 11705, - (float)0.009991, 168, 11873, - (float)0.009991, 168, 12041, - (float)0.009016, 170, 12209, - (float)0.009016, 170, 12379, - (float)0.009016, 170, 12549, - (float)0.006217, 173, 12719, - (float)0.006217, 173, 12892, - (float)0.005097, 175, 13065, - (float)0.005097, 175, 13240, - (float)0.005097, 175, 13415, - (float)0.003909, 177, 13590, - (float)0.003909, 177, 13767, - (float)0.002340, 177, 13944, - (float)0.002389, 170, 14121, - (float)0.001068, 164, 14291, - (float)0.001653, 157, 14455, - (float)0.000717, 150, 14612, - (float)0.001614, 143, 14762, - (float)0.000270, 136, 14905, - (float)0.000484, 129, 15041, - (float)0.001103, 123, 15170, - (float)0.001242, 115, 15293, - (float)0.001188, 109, 15408, - (float)0.001011, 103, 15517, - (float)0.000709, 97, 15620, - (float)0.000301, 89, 15717, - (float)0.002416, 82, 15806, - (float)0.003251, 76, 15888, - (float)0.003246, 69, 15964, - (float)0.004141, 62, 16033, - (float)0.005963, 55, 16095, - (float)0.008839, 47, 16150, - (float)0.010490, 40, 16197, - (float)0.016994, 31, 16237, - (float)0.023659, 21, 16268, -}; diff --git a/Utilities/CAI/cai_dll/inc/version.h b/Utilities/CAI/cai_dll/inc/version.h deleted file mode 100755 index 0638b1f3c65888205978032e89ddf6084f394d7b..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/inc/version.h +++ /dev/null @@ -1 +0,0 @@ -#define VERSION "LIBTIFF, Version 3.5.5\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." diff --git a/Utilities/CAI/cai_dll/lib/hd421md.lib b/Utilities/CAI/cai_dll/lib/hd421md.lib deleted file mode 100755 index 3f0bcc8cd247270dd944014eb35894be8ce016f2..0000000000000000000000000000000000000000 Binary files a/Utilities/CAI/cai_dll/lib/hd421md.lib and /dev/null differ diff --git a/Utilities/CAI/cai_dll/lib/hm421md.lib b/Utilities/CAI/cai_dll/lib/hm421md.lib deleted file mode 100755 index 4e336528d4e156577125a55f270e97857c68ebeb..0000000000000000000000000000000000000000 Binary files a/Utilities/CAI/cai_dll/lib/hm421md.lib and /dev/null differ diff --git a/Utilities/CAI/cai_dll/lib/libjpeg.lib b/Utilities/CAI/cai_dll/lib/libjpeg.lib deleted file mode 100755 index 63cedb3a355ab1071cbb44606931753f4a5023de..0000000000000000000000000000000000000000 Binary files a/Utilities/CAI/cai_dll/lib/libjpeg.lib and /dev/null differ diff --git a/Utilities/CAI/cai_dll/lib/tiff.lib b/Utilities/CAI/cai_dll/lib/tiff.lib deleted file mode 100755 index 9ea4ec10a02a06d6670b58f1a30624226a662fb7..0000000000000000000000000000000000000000 Binary files a/Utilities/CAI/cai_dll/lib/tiff.lib and /dev/null differ diff --git a/Utilities/CAI/cai_dll/lib/unix2win.lib b/Utilities/CAI/cai_dll/lib/unix2win.lib deleted file mode 100755 index 5a7f5551b2e943a26b1bb48d3c622096dda94ce1..0000000000000000000000000000000000000000 Binary files a/Utilities/CAI/cai_dll/lib/unix2win.lib and /dev/null differ diff --git a/Utilities/CAI/cai_dll/src/CMakeLists.txt b/Utilities/CAI/cai_dll/src/CMakeLists.txt deleted file mode 100755 index 3a6e63d003fc19e4f4e0261ffa3f8b6cdd5c97e1..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/src/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -# Sources of non-templated classes. - -SET(CAI_SRCS - cai_fonctions.c - cai_bsq.c - cai_bip.c - cai_inria.c - cai_onera.c - cai_bil.c - cai_lum.c - cai_gessimu.c - cai_grilles.c - cai_tiff.c - cai_jpeg.c - cai_rasterfile.c - cai_DonAux.c - cai_radar.c - cai_spot.c - cai_bandeau.c - ) - -ADD_LIBRARY(cai ${CAI_SRCS}) - -INSTALL_TARGETS(/lib/otb cai ) -INSTALL_FILES(/include/otb/Utilities/CAI "(\\.h)$") diff --git a/Utilities/CAI/cai_dll/src/cai_DonAux.c b/Utilities/CAI/cai_dll/src/cai_DonAux.c deleted file mode 100755 index 1bd123f3df410f1c6c824bdd53665bdd637f2817..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/src/cai_DonAux.c +++ /dev/null @@ -1,3873 +0,0 @@ -/*****************************************************************************/ -/* */ -/* PROJET: COUCHE ACCES IMAGE */ -/* */ -/* */ -/* NOM DU MODULE : CAI_DONAUX.c */ -/* */ -/* DATE DE CREATION: Janvier 95 */ -/* AUTEUR: jl PASCAL m RAYNAL (CISI) */ -/* */ -/* ROLE: ce module est charge de toutes les operations de lecture/ecriture */ -/* sur les fichiers de donnees auxiliaires. */ -/* il permet en outre de creer un nouveau fichier,ou de detruire un */ -/* fichier existant */ -/* */ -/* */ -/* */ -/* LANGAGE: C */ -/* VERSION: V1 */ -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : DM : modifications pour compatibilite HP64bits */ -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : prototypage des fonctions */ -/*****************************************************************************/ -/*---------------------------------------------------------------------------*/ -/* Inclusion des fichiers STANDARDS (.h) */ -/*---------------------------------------------------------------------------*/ -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <malloc.h> -#include <limits.h> -#include <ctype.h> -#include <unistd.h> -#include <errno.h> -#include <sys/uio.h> - -/*---------------------------------------------------------------------------*/ -/* Inclusion des fichiers de CONSTANTES (.cct) */ -/*---------------------------------------------------------------------------*/ -#define _CAI_IMAGE -#define IN_CAI_DA - -#include "cai_image.h" - -/*----------------------------------------------------------------------------*/ -/* Variable pour la gestion en configuration */ -/*----------------------------------------------------------------------------*/ -static char *rcs_id="$Header: cai_DonAux.c,v 1.10 01/01/15 15:24:40 cmf Exp $"; - -/*---------------------------------------------------------------------------*/ -/* Inclusion des fichiers de TYPES (.cty) */ -/*---------------------------------------------------------------------------*/ - -/*---------------------------------------------------------------------------*/ -/* Inclusion des AUTRES fichiers */ -/*---------------------------------------------------------------------------*/ - -/*---------------------------------------------------------------------------*/ -/* Definition des CONSTANTES propres */ -/*---------------------------------------------------------------------------*/ -#define maxi(a,b) ((a) > (b) ? (a) : (b)) -#define mini(a,b) ((a) > (b) ? (b) : (a)) -/*---------------------------------------------------------------------------*/ -/* Definition des TYPES propres */ -/*---------------------------------------------------------------------------*/ -typedef enum { CAI_DEBUT = 0 , CAI_ETAT31 = 1 } CAI_ETAT3; -typedef enum { CAI_INFERIEUR = 0 , CAI_SUPERIEUR = 1 , CAI_FIN = 2 , CAI_AUTRES = 3 } CAI_EVT3; -typedef enum { CAI_DEBUTDEC = 0 , CAI_ETAT11 = 1 , CAI_ETAT12 = 2 , CAI_ETAT13 = 3 , - CAI_ETAT14 = 4 , CAI_FINDEC = 5 , CAI_BLOCVIDE=6 , CAI_ERR11 = 11 , CAI_ERR13 =13} CAI_ETAT1; -typedef enum { CAI_PAR_OUV = 0 , CAI_PAR_FERM = 1 , CAI_DONNEE = 2 , CAI_INF = 3 , - CAI_BLANC = 4 } CAI_EVT1; -typedef enum { CAI_DEBUTYPE = 0 , CAI_ETAT21 = 1 , CAI_ETAT22 = 2 , CAI_ETAT23 = 3 , - CAI_ENTIER = 4 , CAI_ASC = 5 , CAI_REEL = 6 , CAI_ERR21 = 11 } CAI_ETAT2; -typedef enum { CAI_POINT = 0 , CAI_GUILL = 1 , CAI_ESPACE = 2 , CAI_CHIFFRE = 3 , - CAI_SIGNE = 4 , CAI_AUTRE = 5 } CAI_EVT2; - - - -/*---------------------------------------------------------------------------*/ -/* Declaration des OPERATIONS INTERNES (static) */ -/*---------------------------------------------------------------------------*/ -static CAI_OK_KO cai_lirecleDA(CAI_FILE_DA *fd,long ad_deb,char * mot_cle, - long *ad_suiv,long * ad_deb_mcc); - static CAI_OK_KO cai_liredonneeDA(CAI_FILE_DA *fd,long ad_deb, void **don_lue, - CAI_TYPE *type_lu,int *nb_lig_lu, - int *nb_col_lu, long *taille_cell_lu ); - static CAI_OK_KO cai_deplaceficDA(CAI_FILE_DA *fd ,long debut,long deplacement); - static CAI_OK_KO cai_lireficDA(CAI_FILE_DA *fd,long ad_deb,char *buff); - static CAI_OK_KO cai_ecrireficDA(CAI_FILE_DA *fd,long ad_deb, - long taille, char **buff ); - static CAI_OK_KO cai_decodedonDA(long taille_buf, char buff[],long ad_deb, - CAI_TYPE *type_lu,int *nb_lig_lu,int *nb_elt_lu, - int *nb_elt_alloc,long *taille_cell_lu, - void **don_lue, CAI_ETAT1 *etat1,long *ad_fin_dec); - static CAI_OK_KO cai_analyseDA(char car, CAI_EVT1 *evt2); - static CAI_OK_KO cai_typeDA(char car, CAI_EVT2 *evt2); - static CAI_OK_KO cai_recherchecleDA(long taille_buf,char *buff, - long ad_deb,char *mot_cle,long *ad_suiv); - static CAI_OK_KO cai_mot_cleDA(char car, CAI_EVT3 *evt3); - static CAI_OK_KO cai_ecritDA_buf(CAI_FILE_DA *fd,char *mot_cle, - CAI_TYPE type,int nb_lig,int nb_col, - long taille_cell, void *donnee, - int indic_ecrit,char **da_ascii); - - -/*---------------------------------------------------------------------------*/ -/* Definition des RESSOURCES IMPORTEES (extern) */ -/*---------------------------------------------------------------------------*/ - -/*---------------------------------------------------------------------------*/ -/* Definition des RESSOURCES EXPORTEES */ -/*---------------------------------------------------------------------------*/ - - - -/*---------------------------------------------------------------------------*/ -/* Definition des RESSOURCES PROPRES (static) */ -/*---------------------------------------------------------------------------*/ - -static int autom1[6][5]={{ 1,11,11, 6, 0}, - { 2,11,11,13, 1}, - {11, 4, 3,13, 2}, - {11, 4, 3,13, 3}, - { 2, 5,11,13, 4}}; - -static int autom2[4][6]={{ 3, 2,11, 1, 1,11}, - { 3,11, 4, 1,11,11}, - { 2, 5, 2, 2, 2, 2}, - { 3,11, 6, 3, 3, 3}}; - -static int autom3[2][4]={{ 1, 0, -1, 0}, - { -25, 2, -24, 1}}; - -/*****************************************************************************/ -/*****************************************************************************/ -/* */ -/* Definition des OPERATIONS EXTERNES */ -/* */ -/*****************************************************************************/ -/*****************************************************************************/ - -/*****************************************************************************/ -/* */ -/* OPERATION: cai_openDA */ -/* */ -/* ROLE: Cette operation externe est charge d'ouvrir le fichier de donnees */ -/* auxiliaires .Elle retourne une structure de type CAI_FILE_DA qui permet */ -/* par la suite de manipuler le contenu du fichier . */ -/* mode d'ouverture CAI_ECRITURE ou CAI_LECTURE */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL: */ -/* */ -/* */ -/* VERSION: */ -/* CODES RETOUR: CAI_OK ou CAI_KO */ -/* " erreur a l'ouverture du fichier %s " */ -/* " erreur d'allocation memoire " */ -/*****************************************************************************/ -CAI_FILE_DA *cai_openDA(char *nom_fichier, char *type_image, - int nb_can,CAI_MODE_OUVERTURE mode_ouv) -{ -int flags; /* flag utilise pour la fonction open */ -int mode; /* valeur du umask utilise pou la fonction open */ -int fd; /* descripteur du fichier ouvert */ -CAI_FILE_DA *donaux; /* structure descriptive du fichier de donnees auxiliaires */ -CAI_CHAINE fichier_da; /*fichier de donnees auxiliaires */ -int i; /* indice de boucle */ -int canal; /* flag indiquant si je suis en mono ou en multispectral */ -int trouve; /* flag indiquant si le format a ete reconnu */ -/*---------------------------------------------------------------------------*/ -/* DEBUT DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -donaux = NULL; -strcpy(fichier_da,nom_fichier); -/*-- on concatene a la fin le CAI_SUF_FORMAT en fonction du format de l'image traitee --*/ -if (nb_can ==1 ) - { -/*--- cas monospectral ---*/ - canal=0; - } -else - { -/*--- cas multispectral ---*/ - canal=1; - } - -/* reconnaissance du format */ -trouve=0; -for( i = 0 ; i< CAI_NB_FORMAT ; i++) - { - - if(strcmp(type_image,CAI_NOM_FORMAT[i]) == 0 ) - { - strcat(fichier_da,CAI_SUF_FORMAT[canal][i]); - trouve=1; - } - } -if (trouve == 0) - { - sprintf(CAI_ERREUR,"Erreur: format de l'image non reconnu ( %s )",type_image); - goto ERREUR; - } - -/*-- on concatene a la fin du nom de fichier le CAI_SUF_FORMAT des donnees auxiliaires --*/ -strcat(fichier_da,CAI_SUFFIXE_DA); - -/*CD allocation dynamique de la structure de donnees auxiliaires */ -donaux = (CAI_FILE_DA *)malloc(sizeof(CAI_FILE_DA)); -if (donaux == NULL) - { - sprintf(CAI_ERREUR,"Erreur d'allocation a l'ouverture du fichier de donnees auxiliaires %s",fichier_da); - goto ERREUR; - } - -/*CD en fonction du mode d'ouverture , ouverture du fichier */ -if (mode_ouv == CAI_LECTURE) - { - flags = O_RDONLY; - fd = open(fichier_da,flags); - } -else - { - flags = O_RDWR|O_CREAT; - mode = PERMS; - fd = open(fichier_da,flags,mode); - } -/*CD si erreur on sort avec messsage " erreur a l'ouverture */ -if (fd == -1) - { - sprintf(CAI_ERREUR,"Erreur a l'ouverture du fichier de donnees auxiliaires %s",fichier_da); - if (donaux != NULL) - { - free(donaux); - donaux = NULL; - - } - - goto ERREUR; - } -else - { -/*CD initialisations des pointeurs de la structure CAI_FILE_DA */ -/*CD ( buffers de lecture , liste de mots cles , longueurs ...) */ - strcpy(donaux->nom_fichier,fichier_da); - donaux->descr = fd; - donaux->buffer=NULL; - donaux->taille_buffer = CAI_TAILLE_BUFFER; - donaux->taille_buffer_lu=0; - donaux->num_buffer=-1; - donaux->liste_mot_cle=NULL; - donaux->ad_mot_cle=NULL; - donaux->ad_donnee=NULL; - donaux->nb_mot_cle=-1; - donaux->ad_dern_mot_cle=-1; -/*CD allocation dynamique du buffer */ - donaux->buffer = (char *)malloc(CAI_TAILLE_BUFFER + 1); - if (donaux->buffer == NULL) - { - sprintf(CAI_ERREUR,"Erreur d'allocation a l'ouverture du fichier de donnees auxiliaires %s",fichier_da); - if (donaux != NULL) - { - free(donaux); - donaux = NULL; - - } - - goto ERREUR; - } - - } -/*---------------------------------------------------------------------------*/ -/*CD fin de l'operation en cas nominal */ -/*---------------------------------------------------------------------------*/ -return(donaux); -/*---------------------------------------------------------------------------*/ -/*CD fin de l'operation en cas d'erreur */ -/*---------------------------------------------------------------------------*/ -ERREUR: - return(NULL); -/*---------------------------------------------------------------------------*/ -/* FIN DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -} -/*****************************************************************************/ -/* */ -/* OPERATION: cai_closeDA */ -/* */ -/* ROLE: Cette operation externe est chargee de fermer le fichier de donnees */ -/* auxiliaires precedenment ouvert ( operation cai_openDA ) */ -/* la zone memoire reservee lors des operations precedentes dans la structure*/ -/* CAI_FILE_DA */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL: */ -/* */ -/* VERSION: */ -/* CODES RETOUR: CAI_OK ou CAI_KO */ -/* " erreur a la fermeture du fichier %s " */ -/*****************************************************************************/ -CAI_OK_KO cai_closeDA(CAI_FILE_DA *fd) - -{ -CAI_OK_KO retour; /* code retour appel fonction */ -/*---------------------------------------------------------------------------*/ -/* DEBUT DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -retour = CAI_OK; - -if (fd ==NULL) - { - retour = CAI_ERREUR_OUV; - sprintf(CAI_ERREUR,"Erreur a la fermeture d'un fichier de donnees auxiliaires "); - goto ERREUR; - } -close(fd->descr); -/*CD fermeture du fichier */ -/* desallocation des buffer alloues */ -/*CD si le pointeurs de la structure CAI_FILE_DA sont <> NULL */ -/*CD la memoire allouee est liberee */ -if (fd->buffer != NULL) - { - free(fd->buffer); - fd->buffer = NULL; - } -if (fd->liste_mot_cle != NULL) - { - free(fd->liste_mot_cle); - fd->liste_mot_cle = NULL; - } -if (fd->ad_mot_cle != NULL) - { - free(fd->ad_mot_cle); - fd->ad_mot_cle= NULL; - } -if (fd->ad_donnee != NULL) - { - free(fd->ad_donnee); - fd->ad_donnee = NULL; - } - -free(fd); -fd = NULL; -/*---------------------------------------------------------------------------*/ -/*CD fin de l'operation en cas nominal */ -/*---------------------------------------------------------------------------*/ -return(retour); -/*---------------------------------------------------------------------------*/ -/*CD fin de l'operation en cas degrade */ -/*---------------------------------------------------------------------------*/ -ERREUR: - -return(retour); -/*---------------------------------------------------------------------------*/ -/* FIN DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -} -/*****************************************************************************/ -/* */ -/* OPERATION: cai_removeDA */ -/* */ -/* ROLE: Cette operation externe est charge de detruire un fichier de donnees*/ -/* auxiliaires. */ -/* */ -/* */ -/* CONTEXTE D'APPEL: */ -/* */ -/* VERSION: */ -/* CODES RETOUR: CAI_OK ou CAI_KO */ -/* " erreur a la destrucution du fichier %s " */ -/*****************************************************************************/ -CAI_OK_KO cai_removeDA(char *nom_fichier,char *type_image,int nb_can) - -{ -int cr; /* code retour */ -CAI_CHAINE fichier_da; /*fichier de donnees auxiliaires */ -int i; /* indice de boucle */ -int canal; /* flag indiquant si je suis en mono ou en multispectral */ -int trouve; /* flag indiquant si le format a ete reconnu */ -/*---------------------------------------------------------------------------*/ -/* DEBUT DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -strcpy(fichier_da,nom_fichier); -/*-- on concatene a la fin le CAI_SUF_FORMAT en fonction du format de l'image traitee --*/ -if (nb_can ==1 ) - { -/*--- cas monospectral ---*/ - canal=0; - } -else - { -/*--- cas multispectral ---*/ - canal=1; - } - -/* reconnaissance du format */ -trouve=0; -for( i = 0 ; i< CAI_NB_FORMAT ; i++) - { - if(strcmp(type_image,CAI_NOM_FORMAT[i]) == 0 ) - { - strcat(fichier_da,CAI_SUF_FORMAT[canal][i]); - trouve=1; - } - } -if (trouve == 0) - { - sprintf(CAI_ERREUR,"Erreur: format de l'image non reconnu ( %s )",type_image); - goto ERREUR; - } - -/*-- on concatene a la fin du nom de fichier le CAI_SUF_FORMAT des donnees auxiliaires --*/ -strcat(fichier_da,CAI_SUFFIXE_DA); -cr=remove(fichier_da); -if (cr != 0) - { - sprintf(CAI_ERREUR,"destruction du fichier de donnees auxiliaires %s impossible",fichier_da); - goto ERREUR; - } -return(CAI_OK); -ERREUR: -return(CAI_KO); -/*---------------------------------------------------------------------------*/ -/* FIN DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -} -/*****************************************************************************/ -/* */ -/* OPERATION: cai_modifieDA */ -/* */ -/* ROLE: Cette operation modifie le contenu d'une donnee auxiliaire issue du*/ -/* fichier de DA. */ -/* Toutes les autres donnees sont conservees dans le fichier .Si le mot */ -/* cle n'est pas trouve, une erreur est detectee. */ -/* NB : le fichier doit au prealable avoir ete ouvert en mode CAI_ECRITURE */ -/* */ -/* */ -/* CONTEXTE D'APPEL: */ -/* */ -/* VERSION: */ -/* CODES RETOUR: CAI_OK ou CAI_KO */ -/* "erreur fichier ouvert en mode lecture " */ -/*****************************************************************************/ -CAI_OK_KO cai_modifieDA(CAI_FILE_DA *fd,char *mot_cle, - CAI_TYPE type,int nb_lig,int nb_col, - long taille_cell,void *donnee) -{ -int i; /* indice de boucle */ -int indic; /* indicateur de recherche du mot cle a modifier */ -long p1; /* pointeur sur le mot cle a modifier */ -long p2; /* pointeur sur le mot cle suivant */ -int num_mot_cle; /* numero du mot cle a modifier */ -CAI_OK_KO cr; /* code retour */ -off_t offset; -off_t offreel; -long taille_init; /* taille en octets de la donnee a modifier */ -long taille_fin; /* taille en octets de la donnee a modifier */ -int indic_ecrit; /* indicateur d'ecriture dans un fichier */ -char * da_ascii; /* pointeur sur la donnee formatee a ecrire */ -long deplacement; /* valeur du trou a faire dans le fichier */ -/*---------------------------------------------------------------------------*/ -/* DEBUT DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -da_ascii=NULL; -/*CD on verifie au prealable que le fichier est effectivement ouvert */ -/*CD SINON on sort en erreur */ -if ( fd ==NULL ) - { - cr = CAI_ERREUR_OUV; - sprintf(CAI_ERREUR,"Erreur ouverture du fichier de donnees auxiliaires"); - goto ERREUR; - } -/*---------------------------------------------------------------------------*/ -/*CD on appelle alors l'operation de liste de tous les mots cles */ -/*---------------------------------------------------------------------------*/ -/*CD si la liste n'existe pas */ -if (fd->nb_mot_cle == -1) - { - cr=cai_listeDA(fd); - if (cr != CAI_OK ) - { - goto ERREUR; - } - } - -i=0; -indic=CAI_NON_TROUVE; - -/*---------------------------------------------------------------------------*/ -/*CD recherche du mot cle */ -/*---------------------------------------------------------------------------*/ -while (indic == CAI_NON_TROUVE && i < fd->nb_mot_cle) - { - if (strncmp(mot_cle,(char *)(fd->liste_mot_cle + i),CAI_TAILLE_MAX_CLEDA) == 0 ) - { - indic = CAI_TROUVE; - num_mot_cle=i; - } - i++; - } -/*---------------------------------------------------------------------------*/ -/*CD SI le mot cle n'existe pas */ -/*---------------------------------------------------------------------------*/ -if (indic == CAI_NON_TROUVE) - { -/*CD ALORS on sort en erreur */ - cr=CAI_MC_INCONNU; - sprintf(CAI_ERREUR,"Erreur : le mot cle %s n'existe pas dans le fichier",mot_cle); - goto ERREUR; - } -else - { -/*---------------------------------------------------------------------------*/ -/*CD SINON on recupere le pointeur sur le mot cle dans le fichier (p1) */ -/*---------------------------------------------------------------------------*/ - p1 = *(fd->ad_mot_cle + num_mot_cle); -/*---------------------------------------------------------------------------*/ -/*CD ainsi que le pointeur sur le mot cle suivant (p2) */ -/*---------------------------------------------------------------------------*/ -/*CD SI le mot cle a modifier est le dernier mot cle */ - if ( num_mot_cle == fd->nb_mot_cle -1) - { -/*CD on se positionne sur la fin du fichier ( rewind ) */ - offset=0; - offreel=lseek(fd->descr,offset,SEEK_END); -/*CD SI erreur on sort "erreur lors d'un lseek du fichier de DA " */ - if ( offreel == -1) - { - cr=CAI_PB_LSEEK; - sprintf(CAI_ERREUR,"erreur lors du lseek sur le fichier %s",fd->nom_fichier); - goto ERREUR; - } - offreel=lseek(fd->descr,offset,SEEK_CUR); -/*CD SI erreur on sort "erreur lors d'un lseek du fichier de DA " */ - if ( offreel == -1) - { - cr=CAI_PB_LSEEK; - sprintf(CAI_ERREUR,"erreur lors du lseek sur le fichier %s",fd->nom_fichier); - goto ERREUR; - } - p2=offreel; - } - else -/*CD SINON */ - { - p2= *(fd->ad_mot_cle + num_mot_cle+1); - } -/*CD FIN SI le mot cle a modifier est le dernier mot cle */ -/*---------------------------------------------------------------------------*/ -/*CD la taille de la donnee a modifier est p2 - p1 octets ti */ -/*---------------------------------------------------------------------------*/ - taille_init = p2 - p1; -/*---------------------------------------------------------------------------*/ -/*CD on formate dans une chaine de caracteres la donnee a ecrire */ -/*CD (operation interne)( terminee par un \0) */ -/*---------------------------------------------------------------------------*/ - indic_ecrit=0; - cr=cai_ecritDA_buf(fd, /* [E] file descriptor du fichier de DA */ - mot_cle, /* [E] mot cle associe aux donnees auxiliaires */ - type, /* [E] type des donnees a ecrire */ - nb_lig, /* [E] nombre de lignes du tableau a ecrire */ - nb_col, /* [E] nombre de colonnes du tableau a ecrire */ - taille_cell, /* [E] taille maxi en octets d'un element */ - /* (significatif si type = ascii) */ - donnee, /* [E] pointeur sur la zone memoire a ecrire */ - indic_ecrit, /* [E] indicateur si ecriture du buffer dans */ - /* le fichier (=1) sinon (=0) */ - &da_ascii /* buffer de la DA en ascii (sous forme */ - /* de x fois CAI_TAILLE_MAX_LIGDA caracteres) */ - ); - if (cr != CAI_OK) - { - goto ERREUR; - } -/*CD la taille de la donnee a ecrire est la taille de la chaine tf*/ - taille_fin=(long)strlen(da_ascii); -/*---------------------------------------------------------------------------*/ -/*CD on cree alors un trou dans le fichier de DA de taille tf-ti */ -/*CD en commencant a l'adresse p2 ( operation interne ) */ -/*---------------------------------------------------------------------------*/ - deplacement= taille_fin -taille_init; - cr=cai_deplaceficDA( - fd , /* [E] file descripteur du fichier ouvert en lecture ecriture */ - p2, /* [E] adresse de debut de la zone a deplacer */ - deplacement/* [E] valeur deplacement <0 on racourcit le fichier */ - /* valeur deplacement >0 on allonge le fichier */ - ); - if (cr != CAI_OK) - { - goto ERREUR; - } - -/*---------------------------------------------------------------------------*/ -/*CD on ecrit alors la donnee a ecrire a partir de l'adresse p1 */ -/*CD (operation interne qui ecrit directement la chaine ) */ -/*CD de caracteres precedente) */ -/*---------------------------------------------------------------------------*/ - cr=cai_ecrireficDA( - fd, /* [E] structure decrivant le fichier de donnees auxiliaires */ - p1, /* [E] adresse dans le fichier ou ecrire le buffer */ - taille_fin, /* [E] taille de la chaine ascii a ecrire */ - &da_ascii /* [E] chaine a ecrire*/ - ); - if (cr != CAI_OK) - { - goto ERREUR; - } -/*CD liberation de la chaine de caracteres allouee */ - if ( da_ascii != NULL) - { - free(da_ascii); - da_ascii = NULL; - } - } -/*CD FINSI le mot cle existe */ -/*---------------------------------------------------------------------------*/ -/*CD on met a jour la structure CAI_FILE_DA ( buffer , liste ...) */ -/*---------------------------------------------------------------------------*/ -fd->num_buffer=-1; -fd->nb_mot_cle=-1; -if (fd->liste_mot_cle != NULL) - { - free(fd->liste_mot_cle); - fd->liste_mot_cle=NULL; - } -if (fd->ad_mot_cle != NULL) - { - free(fd->ad_mot_cle); - fd->ad_mot_cle= NULL; - } -if (fd->ad_donnee != NULL) - { - free(fd->ad_donnee); - fd->ad_donnee= NULL; - } -fd->ad_dern_mot_cle=-1; -/*---------------------------------------------------------------------------*/ -/*CD fin de l'operation en cas nominal */ -/*---------------------------------------------------------------------------*/ -return(CAI_OK); -/*---------------------------------------------------------------------------*/ -/*CD fin de l'operation en cas d'erreur */ -/*---------------------------------------------------------------------------*/ -ERREUR: -if (da_ascii != NULL) - { - free(da_ascii); - da_ascii=NULL; - } -/*---------------------------------------------------------------------------*/ -/*CD on met a jour la structure CAI_FILE_DA ( buffer , liste ...) */ -/*---------------------------------------------------------------------------*/ -fd->num_buffer=-1; -fd->nb_mot_cle=-1; -if (fd->liste_mot_cle != NULL) - { - free(fd->liste_mot_cle); - fd->liste_mot_cle = NULL; - } -if (fd->ad_mot_cle != NULL) - { - free(fd->ad_mot_cle); - fd->ad_mot_cle=NULL; - } -if (fd->ad_donnee != NULL) - { - free(fd->ad_donnee); - fd->ad_donnee=NULL; - } -fd->ad_dern_mot_cle=-1; -return(cr); -/*---------------------------------------------------------------------------*/ -/* FIN DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -} -/*****************************************************************************/ -/* */ -/* OPERATION: cai_detruitDA */ -/* */ -/* ROLE: Cette operation detruit le contenu d'une donnee auxiliaire issue du*/ -/* fichier de DA. */ -/* Toutes les autres donnees sont conservees dans le fichier . */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL: */ -/* */ -/* VERSION: */ -/* CODES RETOUR: CAI_OK ou CAI_KO */ -/* "erreur fichier ouvert en mode lecture " */ -/*****************************************************************************/ -CAI_OK_KO cai_detruitDA(CAI_FILE_DA *fd,char *mot_cle) - -{ -int i; /* indice de boucle */ -int indic; /* indicateur de recherche du mot cle a modifier */ -long p1; /* pointeur sur le mot cle a modifier */ -long p2; /* pointeur sur le mot cle suivant */ -int num_mot_cle; /* numero du mot cle a modifier */ -CAI_OK_KO cr; /* code retour */ -off_t offset; -off_t offreel; -long taille_init; /* taille en octets de la donnee a modifier */ -long deplacement; /* valeur du trou a faire dans le fichier */ -/*---------------------------------------------------------------------------*/ -/* DEBUT DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -/*CD on verifie au prealable que le fichier est effectivement ouvert */ -/*CD SINON on sort en erreur */ -if ( fd ==NULL ) - - { - cr = CAI_ERREUR_OUV; - sprintf(CAI_ERREUR,"Erreur ouverture du fichier de donnees auxiliaires"); - goto ERREUR; - } -/*---------------------------------------------------------------------------*/ -/*CD on appelle alors l'operation de liste de tous les mots cles */ -/*---------------------------------------------------------------------------*/ -/*CD si la liste n'existe pas */ -if (fd->nb_mot_cle == -1) - { - cr=cai_listeDA(fd); - if (cr != CAI_OK ) - { - goto ERREUR; - } - } - -i=0; -indic=CAI_NON_TROUVE; -/*---------------------------------------------------------------------------*/ -/*CD recherche du mot cle */ -/*---------------------------------------------------------------------------*/ -while (indic == CAI_NON_TROUVE && i < fd->nb_mot_cle) - { - if (strncmp(mot_cle,(char *)(fd->liste_mot_cle + i),CAI_TAILLE_MAX_CLEDA) == 0 ) - { - indic = CAI_TROUVE; - num_mot_cle=i; - } - i++; - } -/*---------------------------------------------------------------------------*/ -/*CD SI le mot cle n'existe pas */ -/*---------------------------------------------------------------------------*/ -if (indic == CAI_NON_TROUVE) - { -/*CD ALORS on sort en erreur */ - cr=CAI_MC_INCONNU; - sprintf(CAI_ERREUR,"Erreur : le mot cle %s n'existe pas dans le fichier",mot_cle); - goto ERREUR; - } -else - { -/*---------------------------------------------------------------------------*/ -/*CD SINON on recupere le pointeur sur le mot cle dans le fichier (p1) */ -/*---------------------------------------------------------------------------*/ - p1 = *(fd->ad_mot_cle + num_mot_cle); -/*---------------------------------------------------------------------------*/ -/*CD ainsi que le pointeur sur le mot cle suivant (p2) */ -/*---------------------------------------------------------------------------*/ -/*CD SI le mot cle a detruire est le dernier mot cle */ - if ( num_mot_cle == fd->nb_mot_cle -1) - { -/*CD on se positionne sur la fin du fichier ( rewind ) */ - offset=0; - offreel=lseek(fd->descr,offset,SEEK_END); -/*CD SI erreur on sort "erreur lors d'un lseek du fichier de DA " */ - if ( offreel == -1) - { - cr=CAI_PB_LSEEK; - sprintf(CAI_ERREUR,"erreur lors du lseek sur le fichier %s",fd->nom_fichier); - goto ERREUR; - } - offreel=lseek(fd->descr,offset,SEEK_CUR); -/*CD SI erreur on sort "erreur lors d'un lseek du fichier de DA " */ - if ( offreel == -1) - { - cr=CAI_PB_LSEEK; - sprintf(CAI_ERREUR,"erreur lors du lseek sur le fichier %s",fd->nom_fichier); - goto ERREUR; - } - p2=offreel; - } - else -/*CD SINON */ - { - p2= *(fd->ad_mot_cle + num_mot_cle+1); - } -/*CD FIN SI le mot cle a detruire est le dernier mot cle */ -/*---------------------------------------------------------------------------*/ -/*CD la taille de la donnee a detruire est p2 - p1 octets ti */ -/*CD on cree alors un trou dans le fichier de DA de taille ti(<0) */ -/*CD en commencant a l'adresse p2 ( operation interne ) */ -/*---------------------------------------------------------------------------*/ - taille_init = p2 - p1; - deplacement= -taille_init; - cr=cai_deplaceficDA( - fd , /* [E] file descripteur du fichier ouvert en lecture ecriture */ - p2, /* [E] adresse de debut de la zone a deplacer */ - deplacement/* [E] valeur deplacement <0 on racourcit le fichier */ - /* valeur deplacement >0 on allonge le fichier */ - ); - if (cr != CAI_OK) - { - goto ERREUR; - } - - } -/*CD FINSI le mot cle existe */ -/*---------------------------------------------------------------------------*/ -/*CD on met a jour la structure CAI_FILE_DA ( buffer , liste ...) */ -/*---------------------------------------------------------------------------*/ -fd->num_buffer=-1; -fd->nb_mot_cle=-1; -if (fd->liste_mot_cle != NULL) - { - free(fd->liste_mot_cle); - fd->liste_mot_cle=NULL; - } -if (fd->ad_mot_cle != NULL) - { - free(fd->ad_mot_cle); - fd->ad_mot_cle=NULL; - } -if (fd->ad_donnee != NULL) - { - free(fd->ad_donnee); - fd->ad_donnee=NULL; - } -fd->ad_dern_mot_cle=-1; -/*---------------------------------------------------------------------------*/ -/*CD fin de l'operation en cas nominal */ -/*---------------------------------------------------------------------------*/ -fd->num_buffer=-1; -fd->nb_mot_cle=-1; -if (fd->liste_mot_cle != NULL) - { - free(fd->liste_mot_cle); - fd->liste_mot_cle=NULL; - - } -if (fd->ad_mot_cle != NULL) - { - free(fd->ad_mot_cle); - fd->ad_mot_cle=NULL; - - } -if (fd->ad_donnee != NULL) - { - free(fd->ad_donnee); - fd->ad_donnee=NULL; - - } -fd->ad_dern_mot_cle=-1; -return(CAI_OK); -/*---------------------------------------------------------------------------*/ -/*CD fin de l'operation en cas d'erreur */ -/*---------------------------------------------------------------------------*/ -ERREUR: -return(cr); -/*---------------------------------------------------------------------------*/ -/* FIN DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -} -/*****************************************************************************/ -/* */ -/* OPERATION: cai_caractDA */ -/* */ -/* ROLE: cette operation externe est chargee de trouver le type et la taille*/ -/* d'une donnee auxiliaire lue dans un fichier precedenment ouvert. */ -/* Il s'agit donc apres localisation du mot cle de lire le type de la donne*/ -/* puis de compter le nombres de cellules de ce type dans la ligne. */ -/* Dans le cas d'une donnee de type CAI_ASCII la taille maxi de la cellule est */ -/* aussi indiquee a l'appelant. */ -/* */ -/* */ -/* CONTEXTE D'APPEL: */ -/* cette operation doit etre appele apres ouverture prealable du fichier */ -/* de donnees auxiliaires. */ -/* */ -/* VERSION: */ -/* CODES RETOUR: CAI_OK ou CAI_KO */ -/* si CAI_KO l'erreur peut etre affiche via la variable globale CAI_ERREUR */ -/* " fichier de donnees auxiliaires %s non ouvert" */ -/* " mot cle non present dans le fichier de donnees auxiliaires %s" */ -/* " aucun mot cle dans le fichier %s" */ -/* " taille du mot cle lue %s superieure a la limite %d ou egale a 0" */ -/* " erreur a la lecture du fichier de donnees auxiliaires %s" */ -/* " parenthese ouvrante non detectee (mot cle %s ) */ -/* " parenthese fermante non detectee (mot cle %s ) */ -/* " nombre de niveaux de parentheses superieur a 2 ( mot cle %s ) */ -/* " % dimension du tableau non constante (mot cle %s) */ -/* " % dimension du tableau = 0 (mot cle %s) */ -/* " type de la donnee lue %s non reconnue (mot cle %s) */ -/* " erreur lors du decodage de la donnee lue %s" (mot cle) */ -/*****************************************************************************/ -CAI_OK_KO cai_lirecaractDA(CAI_FILE_DA *fd,char *mot_cle, - CAI_TYPE *type,int *nb_lig,int *nb_col, - long *taille_cell) -{ -CAI_MOT_CLE mot_cle_lu; /* mot cle courant lu dans le fichier */ -int indic_mot_cle; /* indicateur de recherche du mot cle */ -int num_mot_cle; /* numero du mot cle recherche */ -long ad_mot_cle; /* adresse du debut du mot cle courant */ -long ad_donnee; /* adresse de la donnee apres le mot cle trouve */ -long adresse_deb; /* adresse de debut de recherche du mot cle */ -CAI_OK_KO cr; /* code retour des operations */ -void *don_lue; /* donnees lue en interne par l'operation cai_liredonneeDA */ -int i; /* indice de boucle */ -/*---------------------------------------------------------------------------*/ -/* DEBUT DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -/*CD initialisations */ -indic_mot_cle = CAI_NON_TROUVE; -num_mot_cle=0; -i=0; -ad_donnee=0; -cr=CAI_OK; -don_lue=NULL; - -/*CD on verifie au prealable que le fichier est effectivement ouvert */ -/*CD SINON on sort en erreur */ -if ( fd ==NULL ) - - { - cr = CAI_ERREUR_OUV; - sprintf(CAI_ERREUR,"Erreur ouverture du fichier de donnees auxiliaires"); - goto ERREUR; - } - -/*CD SI la liste des mots cles est en memoire */ -if ( fd->nb_mot_cle != -1 ) - { -/*---------------------------------------------------------------------------*/ -/*CD ALORS on scrute cette liste jusqu'a trouver le mot cle */ -/*---------------------------------------------------------------------------*/ - while (i< fd->nb_mot_cle && indic_mot_cle == CAI_NON_TROUVE ) - { - if ( strncmp(mot_cle,(char *)(fd->liste_mot_cle + i),CAI_TAILLE_MAX_CLEDA) == 0 ) - { - indic_mot_cle = CAI_TROUVE; - num_mot_cle = i; -/*CD on recupere alors le pointeur sur la zone fichier apres ce mot cle */ - ad_donnee=*(fd->ad_donnee + i); - strcpy(mot_cle_lu,(char *)(fd->liste_mot_cle +i)); - ad_mot_cle=*(fd->ad_mot_cle + i); - } - i++; - } - } -else - { -/*CD SINON */ -/*CD on se positionne au debut du fichier ( adresse_deb = 0) */ - adresse_deb = 0; -/*---------------------------------------------------------------------------*/ -/*CD on cherche le premier mot cle a partir de cette adresse (operation interne basee sur un automate) */ -/*---------------------------------------------------------------------------*/ - cr = cai_lirecleDA(fd, /* [E] file descriptor du fichier a lire */ - adresse_deb, /* [E] adresse de debut de recherche */ - mot_cle_lu, /* [S] mot cle suivant lu ( termine par \0)*/ - &ad_donnee, /* [S] adresse du premier caractere suivant le mot cle */ - &ad_mot_cle /* [S] adresse du premier caractere du mot cle */ - ); -/*CD si erreur on sort */ - if (cr != CAI_OK && cr != CAI_EOF) { - goto ERREUR; - } -/*CD si aucun mot cle trouve on sort en erreur "aucun mot cle dans le fichier" */ - if (cr == CAI_EOF) - { - sprintf(CAI_ERREUR,"Erreur fichier sans mot cle( %s) ",fd->nom_fichier); - goto ERREUR; - } -/*CD TANT QUE mot_cle non trouve & pas erreur */ - while ( cr == CAI_OK && indic_mot_cle == CAI_NON_TROUVE ) - { -/*CD si le mot cle est egal au mot cle demande alors mot_cle trouve */ - if ( strcmp(mot_cle,mot_cle_lu) == 0) - { - indic_mot_cle = CAI_TROUVE; - } - else - { - adresse_deb = ad_donnee; -/*---------------------------------------------------------------------------*/ -/*CD si mot_cle non trouve on cherche le mot cle suivant (operation interne basee sur un automate) */ -/*CD cette operation necessite : un pointeur sur la zone fichier ou l'on recherche le mot cle suivant */ -/*CD cette operation ramene : le mot cle suivant et le pointeur sur la zone fichier apres ce mot cle */ -/*---------------------------------------------------------------------------*/ - cr = cai_lirecleDA(fd, /* [E] file descriptor du fichier a lire */ - adresse_deb, /* [E] adresse de debut de recherche */ - mot_cle_lu, /* [S] mot cle suivant lu (termine par \0)*/ - &ad_donnee, /* [S] adresse du premier caractere suivant le mot cle */ - &ad_mot_cle/* [S] adresse du premier caractere du mot cle */ - ); - } -/*CD FIN TANT QUE pas erreur & mot_cle non trouve */ - } - } -/*CD FINSI */ -if (cr != CAI_OK && cr != CAI_EOF) - { - goto ERREUR; - } -/*CD SI fin de fichier on sort en erreur "mot cle non present */ -if ( indic_mot_cle == CAI_NON_TROUVE ) - { - sprintf(CAI_ERREUR,"Mot cle :%s non trouve dans le fichier :%s",mot_cle,fd->nom_fichier); - goto ERREUR; - } -/*CD on sauvegarde alors dans la structure fd les info sur le dernier mot cle */ -strcpy(fd->dernier_mot_cle,mot_cle_lu); -fd->ad_dern_mot_cle = ad_mot_cle; -fd->ad_dern_donnee = ad_donnee; -/*---------------------------------------------------------------------------*/ -/*CD a partir du mot cle trouve on analyse syntaxiquement la ligne jusqu'au prochain mot cle */ -/*CD (operation interne effectuant le decodage et donnant : le type de donnee , le nombres de lignes */ -/*CD le nombre de colonnes , la taille maxi d'un element , un pointeur sur le tableau lu */ -/*CD ( ce tableau a ete alloue dynamiquement par cette operation) */ -/*---------------------------------------------------------------------------*/ -cr=cai_liredonneeDA( - fd, /* [E] file descriptor du fichier a lire */ - ad_donnee, /* [E] adresse de debut de recherche */ - &don_lue, /* [S] donnee lue */ - type, /* [S] type de la donnee lue (CAI_ENTIER4,CAI_REEL8,CAI_ASCII,CAI_BLOC)*/ - nb_lig, /* [S] nombre de lignes du tableau lu */ - nb_col, /* [S] nombre de colonnes du tableau lu */ - taille_cell/* [S] taille maxi en octet d'un element du tableau lu ( significatif - pourla donnee CAI_ASCII )*/ - ); - -/*CD si erreur de decodage on sort en erreur */ -if (cr != CAI_OK ) { - if (cr == CAI_EOF ){ - sprintf(CAI_ERREUR,"erreur fichier de DA incomplet (mot cle %s)",mot_cle); - } - goto ERREUR; - } -/*CD liberation place memoire alloue par l'operation interne precedente */ -if (don_lue != NULL) - { - free(don_lue); - don_lue=NULL; - } -/*---------------------------------------------------------------------------*/ -/*CD fin de l'operation en cas nominal */ -/*---------------------------------------------------------------------------*/ -return(CAI_OK); -/*---------------------------------------------------------------------------*/ -/*CD fin de l'operation en cas d'erreur */ -/*---------------------------------------------------------------------------*/ -ERREUR: -/*CD liberation place memoire alloue par l'operation interne precedente */ -if (don_lue != NULL) - { - free(don_lue); - don_lue=NULL; - } -return(cr); - -/*---------------------------------------------------------------------------*/ -/* FIN DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -} -/*****************************************************************************/ -/* */ -/* OPERATION: cai_lireDA */ -/* */ -/* ROLE: Cette operation externe est chargee de lire une donne associee a un*/ -/* mot cle dans le fichier de donnees auxiliaires precedenment ouvert. */ -/* Il s'agit donc apres localisation du mot cle de lire la donnee et */ -/* toutes les informations associees(nb_lig,nb_col,taille_cell). */ -/* On verifie alors la coherence entre les informations lues et celles*/ -/* issues des arguments donnes par l'appelant. */ -/* Si les 3 informations sont coherentes la donnee est recopiee dans */ -/* la zone memoire reservee par l'appelant. */ -/* */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL: */ -/* cette operation doit etre appele apres ouverture prealable du fichier */ -/* de donnees auxiliaires. */ -/* pour une souplesse d'utilisation maximum il est utilise d'appeler au */ -/* prealable l'operation cai_lirecaractDA puis de reserver la place memoire */ -/* necessaire */ -/* */ -/* VERSION: */ -/* CODES RETOUR: CAI_OK ou CAI_KO */ -/* si CAI_KO l'erreur peut etre affiche via la variable globale CAI_ERREUR */ -/* " fichier de donnees auxiliaires %s non ouvert" */ -/* " mot cle non present dans le fichier de donnees auxiliaires %s" */ -/* " aucun mot cle dans le fichier %s" */ -/* " taille du mot cle lue %s superieure a la limite %d ou egale a 0" */ -/* " erreur a la lecture du fichier de donnees auxiliaires %s" */ -/* " parenthese ouvrante non detectee (mot cle %s ) */ -/* " parenthese fermante non detectee (mot cle %s ) */ -/* " nombre de niveaux de parentheses superieur a 2 ( mot cle %s ) */ -/* " % dimension du tableau non constante (mot cle %s) */ -/* " % dimension du tableau = 0 (mot cle %s) */ -/* " type de la donnee lue %s non reconnue (mot cle %s) */ -/* " erreur lors du decodage de la donnee lue %s" (mot cle %s) */ -/* " incoherence entre nblig lue (%d) et nblig specifiee (%d) (mot cle %s) */ -/* " incoherence entre nbcol lue (%d) et nbcol specifiee (%d) (mot cle %s) */ -/* " incoherence entre taille_cell lue (%d) et taille_cell specifiee (%d) */ -/* (mot cle %s) */ -/*****************************************************************************/ -CAI_OK_KO cai_lireDA(CAI_FILE_DA *fd,char *mot_cle, - CAI_TYPE *type,int *nb_lig,int *nb_col, - long *taille_cell,void *donnee) -{ -int i; /* indice de boucle */ -int j; /* indice de boucle */ -CAI_MOT_CLE mot_cle_lu; /* mot cle courant lu dans le fichier */ -int indic_mot_cle; /* indicateur de recherche du mot cle */ -int num_mot_cle; /* numero du mot cle recherche */ -long ad_mot_cle; /* adresse du debut du mot cle courant */ -long ad_donnee; /* adresse de la donnee apres le mot cle trouve */ -long adresse_deb; /* adresse de debut de recherche du mot cle */ -CAI_OK_KO cr; /* code retour des operations */ -void *don_lue; /* donnees lue en interne par l'operation cai_liredonneeDA */ -char *don_asc; /* donnee ascii lue */ -long int *don_ent; /* donnee entiere lue */ -double *don_ree; /* donnee reelle lue */ -CAI_TYPE type_lu; /* type de la donnee lue CAI_ENTIER4 ou CAI_REEL8 ou CAI_BLOC*/ -int nb_lig_lu; /* nombre de lignes lues */ -int nb_col_lu; /* nombre de colonnes lues */ -long taille_cell_lu;/* taille de la cellule CAI_ASCII maxi lue */ -char *donnee_a; /* donnee ascii lue */ -long int *donnee_li; /* donnee entiere a renseigner*/ -double *donnee_d; /* donnee reelle a renseigner*/ -float *donnee_f; /* donnee reelle a renseigner*/ -double reel; /* variable de travail */ -long int entier; /* variable de travail */ -/*---------------------------------------------------------------------------*/ -/* DEBUT DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -/*CD initialisations */ -indic_mot_cle = CAI_NON_TROUVE; -num_mot_cle=0; -i=0; -j=0; -ad_donnee=0; - -cr=CAI_OK; -don_lue=NULL; -nb_lig_lu=0; -nb_col_lu=0; -type_lu= CAI_INCONNU; -taille_cell_lu=0; -/*CD on verifie que le type fait partie des types reconnus */ -if ( *type != CAI_ENTIER4 && *type != CAI_REEL4 && *type != CAI_REEL8 && *type != CAI_ASCII && *type !=CAI_BLOC) - { - cr = CAI_ERR_TYP; - sprintf(CAI_ERREUR,"type :%d non reconnu ( 1:CAI_ENTIER4 2:CAI_REEL4 3:CAI_REEL8 4:CAI_ASCII 5:CAI_BLOC)",*type); - goto ERREUR; - } -/*CD on verifie au prealable que le fichier est effectivement ouvert */ -/*CD SINON on sort en erreur */ -if ( fd ==NULL ) - - { - cr = CAI_ERREUR_OUV; - sprintf(CAI_ERREUR,"Erreur ouverture du fichier de donnees auxiliaires"); - goto ERREUR; - } - -/*---------------------------------------------------------------------------*/ -/*CD SI le dernier mot cle lu dans CAI_FILE_DA n'existe pas ou n'est pas egal au mot cle recherche */ -/*---------------------------------------------------------------------------*/ -if (fd->ad_dern_mot_cle == -1 || strncmp(mot_cle,fd->dernier_mot_cle,CAI_TAILLE_MAX_CLEDA) != 0 ) - { -/*CD SI la liste des mots cles est en memoire */ - if ( fd->nb_mot_cle != -1 ) - { -/*---------------------------------------------------------------------------*/ -/*CD ALORS on scrute cette liste jusqu'a trouver le mot cle */ -/*---------------------------------------------------------------------------*/ - while (i< fd->nb_mot_cle && indic_mot_cle == CAI_NON_TROUVE ) - { - if ( strncmp(mot_cle,(char *)(fd->liste_mot_cle +i),CAI_TAILLE_MAX_CLEDA) == 0 ) - { - indic_mot_cle = CAI_TROUVE; - num_mot_cle = i; -/*CD on recupere alors le pointeur sur la zone fichier apres ce mot cle */ - ad_donnee=*(fd->ad_donnee + i); - strcpy(mot_cle_lu,(char *)(fd->liste_mot_cle +i)); - ad_mot_cle=*(fd->ad_mot_cle + i); - } - i++; - } - } - else - { -/*CD SINON */ -/*CD on se positionne au debut du fichier ( adresse_deb = 0)*/ - adresse_deb = 0; -/*---------------------------------------------------------------------------*/ -/*CD on cherche le premier mot cle a partir de cette adresse (operation interne basee sur un automate) */ -/*---------------------------------------------------------------------------*/ - cr = cai_lirecleDA(fd, /* [E] file descriptor du fichier a lire */ - adresse_deb, /* [E] adresse de debut de recherche */ - mot_cle_lu, /* [S] mot cle suivant lu ( termine par \0)*/ - &ad_donnee, /* [S] adresse du premier caractere suivant le mot cle */ - &ad_mot_cle /* [S] adresse du premier caractere du mot cle */ - ); -/*CD si erreur on sort */ - if (cr != CAI_OK && cr != CAI_EOF) { - goto ERREUR; - } -/*CD si aucun mot cle trouve on sort en erreur "aucun mot cle dans le fichier" */ - if ( cr == CAI_EOF) - { - sprintf(CAI_ERREUR,"Erreur fichier sans mot cle( %s)",fd->nom_fichier); - goto ERREUR; - } -/*CD TANT QUE mot_cle non trouve & pas erreur */ - while (cr == CAI_OK && indic_mot_cle == CAI_NON_TROUVE ) - { -/*CD si le mot cle est egal au mot cle demande alors mot_cle trouve */ - if ( strcmp(mot_cle,mot_cle_lu) == 0) - { - indic_mot_cle = CAI_TROUVE; - } - else - { - adresse_deb = ad_donnee; -/*---------------------------------------------------------------------------*/ -/*CD si mot_cle non trouve on cherche le mot cle suivant (operation interne basee sur un automate) */ -/*CD cette operation necessite : un pointeur sur la zone fichier ou l'on recherche le mot cle suivant */ -/*CD cette operation ramene : le mot cle suivant et le pointeur sur la zone fichier apres ce mot cle */ -/*---------------------------------------------------------------------------*/ - cr = cai_lirecleDA(fd, /* [E] file descriptor du fichier a lire */ - adresse_deb, /* [E] adresse de debut de recherche */ - mot_cle_lu, /* [S] mot cle suivant lu (termine par \0)*/ - &ad_donnee, /* [S] adresse du premier caractere suivant le mot cle */ - &ad_mot_cle/* [S] adresse du premier caractere du mot cle */ - ); - } -/*CD FIN TANT QUE pas erreur & mot_cle non trouve */ - } -/*CD FIN SI LISTE MOT CLE presente en memoire*/ - } -/*CD FIN SI le dernier mot cle lu dans CAI_FILE_DA n'existe pas ou n'est pas egal au mot cle recherche */ - if (cr != CAI_OK && cr != CAI_EOF) - { - goto ERREUR; - } -/*CD SI fin de fichier on sort en erreur "mot cle non present */ - if ( indic_mot_cle == CAI_NON_TROUVE ) - { - sprintf(CAI_ERREUR,"Mot cle :%s non trouve dans le fichier :%s",mot_cle,fd->nom_fichier); - goto ERREUR; - } -/*CD on sauvegarde alors dans la structure fd les info sur le dernier mot cle */ - strcpy(fd->dernier_mot_cle,mot_cle_lu); - fd->ad_dern_mot_cle = ad_mot_cle; - fd->ad_dern_donnee = ad_donnee; - } - -/*CD SINON */ -else - { - indic_mot_cle = CAI_TROUVE; - ad_donnee = fd->ad_dern_donnee; - ad_mot_cle= fd ->ad_dern_mot_cle; - strcpy(mot_cle_lu,fd->dernier_mot_cle); - } - - -/*---------------------------------------------------------------------------------------*/ -/*CD a partir du mot cle trouve on analyse syntaxiquement la ligne jusqu'au prochain mot cle */ -/*CD (operation interne effectuant le decodage et donnant : le type de donnee (entier ou reel ou CAI_ASCII),*/ -/*CD le nombres de lignes */ -/*CD le nombre de colonnes , la taille maxi d'un element , un pointeur sur le tableau lu */ -/*CD ( ce tableau a ete alloue dynamiquement par cette operation) */ -/*---------------------------------------------------------------------------------------*/ -cr=cai_liredonneeDA( - fd, /* [E] file descriptor du fichier a lire */ - ad_donnee, /* [E] adresse de debut de recherche */ - &don_lue, /* [S] donnee lue */ - &type_lu, /* [S] type de la donnee lue (CAI_ENTIER4,CAI_REEL8,CAI_ASCII,CAI_BLOC)*/ - &nb_lig_lu, /* [S] nombre de lignes du tableau lu */ - &nb_col_lu, /* [S] nombre de colonnes du tableau lu */ - &taille_cell_lu/* [S] taille maxi en octet d'un element du tableau lu ( significatif - pourla donnee CAI_ASCII )*/ - ); -/*CD si erreur de decodage on sort en erreur */ -if (cr != CAI_OK ) { - if (cr == CAI_EOF){ - sprintf(CAI_ERREUR,"erreur fichier de DA incomplet (mot cle %s)",mot_cle); - } - goto ERREUR; - } - - -/*---------------------------------------------------------------------------------------*/ -/*CD on effectue les controles de coherence : */ -/*CD type_lu = type ( entier reel ou CAI_ASCII)*/ -/*CD nblig_lu = nblig */ -/*CD nbcol_lu = nb_col */ -/*CD taille_cell_lu <= taille_cell */ -/*CD SI difference on sort en erreur "incoherence entre " */ -/*CD NB : une lecture en reel4 de reel ecrit en reel8 n'est pas une erreur */ -/*---------------------------------------------------------------------------------------*/ - - -/*---------------------------------------------------------------------------------------*/ -/* donnee de type entiere */ -/*---------------------------------------------------------------------------------------*/ -if ( type_lu == CAI_ENTIER4) - { - if (*type != CAI_ENTIER4) - { - cr = CAI_KO; - sprintf(CAI_ERREUR,"type lu (%d) incoherent avec le type specifie ( %d) ",type_lu,*type); - goto ERREUR; - } - if (nb_lig_lu != *nb_lig || nb_col_lu != *nb_col) - { - cr = CAI_KO; - sprintf(CAI_ERREUR,"dim lue incoherente avec la dimension specifiee"); - goto ERREUR; - } -/*CD le pointeur sur le tableau alloue par l'appelant est caste au type donne par l'appelant */ -/*CD le pointeur sur le tableau alloue par l'operation de decodage est caste au type_lu */ - don_ent = (long int *)don_lue; - donnee_li = (long int *)donnee; - i=0; -/*CD TANT QUE lig <= nblig_lu et non erreur */ - while ( i < nb_lig_lu && cr ==CAI_OK) - { - j=0; -/*CD TANT QUE col <= nbcol_lu et non erreur */ - while ( j < nb_col_lu && cr ==CAI_OK) - { - entier = *(don_ent + i*nb_col_lu + j); - *(donnee_li +i*nb_col_lu + j) = entier; - j++; - } -/*CD FIN TANT QUE col <= nbcol_lu et non erreur */ - i++; - } -/*CD FIN TANT QUE lig <= nblig_lu et non erreur */ - if (cr != CAI_OK ) - { - goto ERREUR; - } - } - -/*---------------------------------------------------------------------------------------*/ -/* donnee de type reelle */ -/*---------------------------------------------------------------------------------------*/ -if ( type_lu == CAI_REEL8) - { - if (*type != CAI_REEL4 && *type != CAI_REEL8) - { - cr=CAI_KO; - sprintf(CAI_ERREUR,"type lu (%d) incoherent avec le type specifie ( %d)",type_lu,*type); - goto ERREUR; - } - if (nb_lig_lu != *nb_lig || nb_col_lu != *nb_col) - { - cr=CAI_KO; - sprintf(CAI_ERREUR,"dim lue incoherente avec la dimension specifiee "); - goto ERREUR; - } -/*CD le pointeur sur le tableau alloue par l'appelant est caste au type donne par l'appelant */ -/*CD le pointeur sur le tableau alloue par l'operation de decodage est caste au type_lu */ - don_ree = (double *)don_lue; - donnee_f = (float *)donnee; - donnee_d = (double *)donnee; - i=0; -/*CD TANT QUE lig <= nblig_lu et non erreur */ - while ( i < nb_lig_lu) - { - j=0; -/*CD TANT QUE col <= nbcol_lu et non erreur */ - while ( j < nb_col_lu) - { - reel = *(don_ree + i*nb_col_lu + j); - if (*type == CAI_REEL4) - { - *(donnee_f + i*nb_col_lu + j) = reel; - } - else - { - *(donnee_d + i*nb_col_lu + j) = reel; - } - j++; - } -/*CD FIN TANT QUE col <= nbcol_lu et non erreur */ - i++; - } -/*CD FIN TANT QUE lig <= nblig_lu et non erreur */ - } - - -/*---------------------------------------------------------------------------------------*/ -/* donnee de type CAI_ASCII */ -/*---------------------------------------------------------------------------------------*/ -if (type_lu == CAI_ASCII ) - { - if (*type != CAI_ASCII ) - { - cr=CAI_KO; - sprintf(CAI_ERREUR,"type lu (%d) incoherent avec le type specifie ( %d)",type_lu,*type); - goto ERREUR; - } - if (nb_lig_lu != *nb_lig || nb_col_lu != *nb_col) - { - cr=CAI_KO; - sprintf(CAI_ERREUR,"dim lue incoherente avec la dimension specifiee "); - goto ERREUR; - } - if (taille_cell_lu > *taille_cell) - { - cr=CAI_KO; - sprintf(CAI_ERREUR,"longueur max des donnees CAI_ASCII lues (%d) incoherente avec la taille specifie (%d)" - ,taille_cell_lu,*taille_cell); - goto ERREUR; - } -/*CD le pointeur sur le tableau alloue par l'appelant est caste au type donne par l'appelant */ -/*CD le pointeur sur le tableau alloue par l'operation de decodage est caste au type_lu */ - don_asc = (char *)don_lue; - donnee_a = (char *)donnee; - i=0; - j=0; -/*CD TANT QUE lig <= nblig_lu et non erreur */ - while ( i < nb_lig_lu) - { - j=0; -/*CD TANT QUE col <= nbcol_lu et non erreur */ - while ( j < nb_col_lu) - { - strcpy(donnee_a + (i*nb_col_lu + j)* (*taille_cell),don_asc + (i*nb_col_lu + j)*CAI_TAILLE_MAX_ASCII); - j++; - } -/*CD FIN TANT QUE col <= nbcol_lu et non erreur */ - i++; - } -/*CD FIN TANT QUE lig <= nblig_lu et non erreur */ - } -/*CD liberation place memoire alloue par l'operation interne precedente */ -if (don_lue != NULL) - { - free(don_lue); - don_lue=NULL; - } -/*---------------------------------------------------------------------------------------*/ -/* donnee de type CAI_BLOC */ -/*---------------------------------------------------------------------------------------*/ -if (type_lu == CAI_BLOC) - { - if (*type != CAI_BLOC ) - { - sprintf(CAI_ERREUR,"type lu (%d) incoherent avec le type specifie ( %d)",type_lu,*type); - goto ERREUR; - } - } -/*---------------------------------------------------------------------------*/ -/*CD fin de l'operation en cas nominal */ -/*---------------------------------------------------------------------------*/ -return(CAI_OK); -/*---------------------------------------------------------------------------*/ -/*CD fin de l'operation en cas d'erreur */ -/*---------------------------------------------------------------------------*/ -ERREUR: -/*CD liberation place memoire alloue par l'operation interne precedente */ -if (don_lue != NULL) - { - free(don_lue); - don_lue=NULL; - } -return(cr); -/*---------------------------------------------------------------------------*/ -/* FIN DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -} - -/********************************************************************************/ -/* */ -/* OPERATION: cai_listeDA */ -/* */ -/* ROLE: Cette operation recherche la liste des mots cles presents dans un */ -/* fichier de Donnees Auxiliaires */ -/* */ -/* ATTENTION : cette fonction s'alloue de l'espace memoire qu'il conviendra de */ -/* liberer a la fin du traitement */ -/* */ -/* CONTEXTE D'APPEL: */ -/* */ -/* VERSION: */ -/* CODE RETOUR : CAI_OK ou CAI_KO */ -/* " taille d'un mot cle lu superieure a la limite " */ -/* " erreur a la lecture du fichier de donnees auxiliaires " */ -/********************************************************************************/ -CAI_OK_KO cai_listeDA(CAI_FILE_DA *fd) - -{ -long adr_deb; /* adresse dans le fichier de DA */ -long ad_suiv; /* adresse du premier caractere suivant un mot cle */ -long ad_deb_mcc; /* adresse du premier caractere des donnees du mot cle */ -long *ad; /* adresse pour copie */ -int nb_mot_cle; /* nombre de mots cle trouves dans le fichier */ -size_t taille; /* taille du buffer a allouer */ -CAI_OK_KO retour; /* code retour appel fonctions */ -CAI_MOT_CLE mot_cle; /* mot cle trouve*/ -char *adr_copie; /* adresse pour copie de mots cle */ -int nb_bloc; /* nombre de realloc realises +1 */ -off_t offset; -off_t offreel; - - -/*---------------------------------------------------------------------------*/ -/* DEBUT DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -/*------------------------------------------------------------------------------*/ -/*CD initialisation a zero du nombre de mots cle trouves */ -/*------------------------------------------------------------------------------*/ -nb_mot_cle = 0; -nb_bloc = 1; - -/*------------------------------------------------------------------------------*/ -/*CD on verifie au prealable que le fichier est effectivement ouvert */ -/*CD SINON on sort en erreur */ -/*------------------------------------------------------------------------------*/ -if ( fd == NULL ) - { - retour = CAI_ERREUR_OUV; - sprintf(CAI_ERREUR,"Dans listeDA, fichier de donnees auxiliaires non ouvert"); - goto ERREUR; - } - -/*------------------------------------------------------------------------------*/ -/*CD Positionnement en debut de fichier */ -/*------------------------------------------------------------------------------*/ -/*CD on se positionne sur le debut du fichier ( rewind ) */ -offset=0; -offreel=lseek(fd->descr,offset,SEEK_SET); - - -/*------------------------------------------------------------------------------*/ -/*CD Allocation d'un espace memoire contenant la liste des mots cles trouves */ -/*CD Allocation d'espaces memoire contenant les adresses des mots cles */ -/*CD et les adresses des donnees associees a chaque mot cle */ -/*CD (il faut essayer d'allouer un maximum de place representative afin */ -/*CD d'eviter un trop grand nombre de realloc) */ -/*------------------------------------------------------------------------------*/ -taille = CAI_TAILLE_MAX_CLEDA * CAI_NB_MAX_CLE; -fd->liste_mot_cle = (CAI_MOT_CLE *)malloc (taille); -if (fd->liste_mot_cle == NULL) - { - retour = CAI_ERR_ALLOC; - sprintf (CAI_ERREUR," erreur allocation memoire pour liste mots cle "); - goto ERREUR; - } - -taille = CAI_NB_MAX_CLE * sizeof(int); -fd->ad_mot_cle = (long *)malloc (taille); -if (fd->ad_mot_cle == NULL) - { - retour = CAI_ERR_ALLOC; - sprintf (CAI_ERREUR," erreur allocation memoire pour adresse mots cle "); - goto ERREUR; - } - -taille = CAI_NB_MAX_CLE * sizeof(int); -fd->ad_donnee = (long *)malloc (taille); -if (fd->ad_donnee == NULL) - { - retour = CAI_ERR_ALLOC; - sprintf (CAI_ERREUR," erreur allocation memoire pour adresse donnees d'un mots cle "); - goto ERREUR; - } - -/*------------------------------------------------------------------------------*/ -/*CD Adr_deb = adresse debut de fichier */ -/*------------------------------------------------------------------------------*/ -adr_deb = 0; - -/*------------------------------------------------------------------------------*/ -/*CD Recherche du premier mot cle du fichier(cai_lirecleDA) */ -/*CD Si erreur de recherche, sortie en erreur */ -/*------------------------------------------------------------------------------*/ -retour = cai_lirecleDA (fd, /* structure du fichier a lire */ - adr_deb, /* adresse du debut de recherche dans le fichier */ - mot_cle, /* mot cle trouve */ - &ad_suiv, /* adresse dans le fichier du premier caractere suivant le mot cle */ - &ad_deb_mcc) ; /* adresse dans le fichier du premier caractere du mot cle */ - -if (retour != CAI_OK && retour != CAI_EOF) - { - retour = CAI_ERREUR_RECHERCHE_MOT; - sprintf (CAI_ERREUR," erreur recherche du premier mot cle "); - goto ERREUR; - } - -/*------------------------------------------------------------------------------*/ -/*CD TANT QUE il existe des mots cles dans le fichier */ -/*------------------------------------------------------------------------------*/ -while (retour != CAI_EOF) - { -/*------------------------------------------------------------------------------*/ -/*CD si la liste des mots cle est saturee alors reallocation du double de */ -/*CD place pour les mots cle et les adresse de ces mots */ -/*------------------------------------------------------------------------------*/ - if (nb_mot_cle == (CAI_NB_MAX_CLE * nb_bloc)) - { - nb_bloc = nb_bloc + 1; - - taille = CAI_TAILLE_MAX_CLEDA * CAI_NB_MAX_CLE * nb_bloc; - fd->liste_mot_cle = (CAI_MOT_CLE *)realloc (fd->liste_mot_cle, taille); - if (fd->liste_mot_cle == NULL) - { - retour = CAI_ERR_ALLOC; - sprintf (CAI_ERREUR," erreur re-allocation memoire pour liste mots cle - bloc %d ", nb_bloc); - goto ERREUR; - } - - taille = CAI_NB_MAX_CLE * sizeof(int) * nb_bloc; - fd->ad_mot_cle = (long *)realloc (fd->ad_mot_cle, taille); - if (fd->ad_mot_cle == NULL) - { - retour = CAI_ERR_ALLOC; - sprintf (CAI_ERREUR," erreur re-allocation memoire pour adresse mots cle - bloc %d ", nb_bloc); - goto ERREUR; - } - - taille = CAI_NB_MAX_CLE * sizeof(int) * nb_bloc; - fd->ad_donnee = (long *)realloc (fd->ad_donnee, taille); - if (fd->ad_donnee == NULL) - { - retour = CAI_ERR_ALLOC; - sprintf (CAI_ERREUR," erreur re-allocation memoire pour donnees d un mots cle - bloc %d", nb_bloc); - goto ERREUR; - } - } - -/*------------------------------------------------------------------------------*/ -/*CD sauvegarde du mot cle trouve dans liste_mot_cle */ -/*------------------------------------------------------------------------------*/ - adr_copie =(char *)(fd->liste_mot_cle + nb_mot_cle); - strncpy (adr_copie, mot_cle, CAI_TAILLE_MAX_CLEDA); - -/*------------------------------------------------------------------------------*/ -/*CD sauvegarde de l'adresse dans le fichier du mot cle trouve tab_adresse */ -/*CD et de l'adresse du premier caractere des donnees associees au mot cle */ -/*------------------------------------------------------------------------------*/ - ad = (long *)(fd->ad_mot_cle + nb_mot_cle); - *ad = ad_deb_mcc; - ad = (long *)(fd->ad_donnee + nb_mot_cle); - *ad = ad_suiv; - -/*------------------------------------------------------------------------------*/ -/*CD incrementation du nombre de mots cle trouves */ -/*------------------------------------------------------------------------------*/ - nb_mot_cle = nb_mot_cle + 1; - -/*------------------------------------------------------------------------------*/ -/*CD recherche du mot cle suivant dans le fichier (cai_lirecleDA) */ -/*------------------------------------------------------------------------------*/ - adr_deb = ad_suiv; - retour = cai_lirecleDA (fd, /* structure du fichier a lire */ - adr_deb, /* adresse du debut de recherche dans le fichier */ - mot_cle, /* mot cle trouve */ - &ad_suiv, /* adresse dans le fichier du premier caractere suivant le mot cle */ - &ad_deb_mcc); /* adresse dans le fichier du premier caractere du mot cle */ - if (retour != CAI_OK && retour != CAI_EOF) - { - retour = CAI_ERREUR_RECHERCHE_MOT; - sprintf (CAI_ERREUR," erreur recherche d un mot cle "); - goto ERREUR; - } - - } /*CD FIN TANT QUE (plus de mots cle) */ - -/*------------------------------------------------------------------------------*/ -/* CD Sauvegarde du nombre de mots cle trouves */ -/*------------------------------------------------------------------------------*/ -fd->nb_mot_cle = nb_mot_cle; - - -/*---------------------------------------------------------------------------*/ -/* Fin du traitement nominal */ -/*---------------------------------------------------------------------------*/ -retour = CAI_OK; -return (retour); - -/*---------------------------------------------------------------------------*/ -/* traitement degrade : */ -/*---------------------------------------------------------------------------*/ -ERREUR : - -if (fd != NULL) - { -if (fd->liste_mot_cle != NULL) - { - free(fd->liste_mot_cle); - fd->liste_mot_cle=NULL; - - } -if (fd->ad_mot_cle != NULL) - { - free(fd->ad_mot_cle); - fd->ad_mot_cle=NULL; - - } -if (fd->ad_donnee != NULL) - { - free(fd->ad_donnee); - fd->ad_donnee=NULL; - } - - - fd->nb_mot_cle = -1; - } -return (retour); -/*---------------------------------------------------------------------------*/ -/* FIN DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -} -/********************************************************************************/ -/* */ -/* OPERATION: cai_ajoute DA */ -/* */ -/* ROLE: Cette operation ajoute a la fin du fichier de DA une donnee */ -/* auxiliaire */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL: */ -/* Cette operation doit etre appelee apres ouverture prealable du fichier */ -/* de Donnees Auxiliaires */ -/* */ -/* VERSION: */ -/* */ -/* CODE RETOUR : CAI_OK ou CAI_KO */ -/*Si CAI_KO, l'erreur peut etre affichee via la variable globale CAI_ERREUR */ -/* " fichier de donnees auxiliaires %s non ouvert " */ -/* " erreur de positionnement en fin de fichier " */ -/* " erreur d'ecriture dans le fichier " */ -/********************************************************************************/ -CAI_OK_KO cai_ajouteDA(CAI_FILE_DA *fd,char *mot_cle, - CAI_TYPE type,int nb_lig,int nb_col, - long taille_cell,void *donnee) -{ -CAI_OK_KO retour; /* code retour des fonctions */ -int i; /* indice de boucle */ -int indic_ecrit; /* indic ecritur DA ds fichier(=1 si ecriture = 0 sinon)*/ -char * da_ascii; /* buffer de la DA en ascii (sous forme */ - /* de x fois CAI_TAILLE_MAX_LIGDA caracteres) */ -int indic_mot_cle; /* indicateur de recherche du mot cle */ - - - -/*---------------------------------------------------------------------------*/ -/* DEBUT DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ - da_ascii=NULL; -/*------------------------------------------------------------------------------*/ -/*CD on verifie au prealable que le fichier est effectivement ouvert */ -/*CD SINON on sort en erreur */ -/*------------------------------------------------------------------------------*/ - -if ( fd == NULL ) - { - retour = CAI_ERREUR_OUV; - sprintf(CAI_ERREUR,"Dans ajouteDA, fichier de donnees auxiliaires non ouvert"); - goto ERREUR; - } -/*------------------------------------------------------------------------------*/ -/*CD on verifie que le type fait partie des types reconnus */ -/*------------------------------------------------------------------------------*/ - -if ( type != CAI_ENTIER4 && type != CAI_REEL4 && type != CAI_REEL8 && type != CAI_ASCII & type !=CAI_BLOC) - { - retour = CAI_ERR_TYP; - sprintf(CAI_ERREUR,"type :%d non reconnu ( 1:CAI_ENTIER4 2:CAI_REEL4 3:CAI_REEL8 4:CAI_ASCII 5:CAI_BLOC )",type); - goto ERREUR; - } -/*------------------------------------------------------------------------------*/ -/*CD on verifie que la DA n'existe pas deja (cai_listeDA) */ -/*------------------------------------------------------------------------------*/ -if (fd->nb_mot_cle <= 0) - { - retour = cai_listeDA (fd); - if (retour != CAI_OK) goto ERREUR; - } -indic_mot_cle = CAI_NON_TROUVE; -i = 0; -while (i< fd->nb_mot_cle && indic_mot_cle == CAI_NON_TROUVE ) - { - if ( strncmp(mot_cle,(char *)(fd->liste_mot_cle +i), CAI_TAILLE_MAX_CLEDA) == 0 ) - indic_mot_cle = CAI_TROUVE; - i = i + 1; - } - -if (indic_mot_cle == CAI_TROUVE) - { - retour = CAI_MOT_DEJA_EXISTE; - sprintf(CAI_ERREUR,"Dans ajouteDA, mot cle %s deja existant ",mot_cle); - goto ERREUR; - } - -/*------------------------------------------------------------------------------*/ -/*CD On ecrit la DA dans un buffer intermediaire et dans le fichier */ -/*------------------------------------------------------------------------------*/ - -indic_ecrit = 1; - -retour = cai_ecritDA_buf( - fd, /* [E] file descriptor du fichier de DA */ - mot_cle, /* [E] mot cle associe aux donnees auxiliaires */ - type, /* [E] type des donnees a ecrire */ - nb_lig, /* [E] nombre de lignes du tableau a ecrire */ - nb_col, /* [E] nombre de colonnes du tableau a ecrire */ - taille_cell, /* [E] taille maxi en octets d'un element */ - /* (significatif si type = ascii) */ - donnee, /* [E] pointeur sur la zone memoire a ecrire */ - indic_ecrit, /* [E] indicateur si ecriture du buffer dans */ - /* le fichier (=1) sinon (=0) */ - &da_ascii); /* [S] buffer de la DA en ascii (sous forme */ - /* de x fois CAI_TAILLE_MAX_LIGDA caracteres) */ - -if (retour != CAI_OK) goto ERREUR; - - -/*---------------------------------------------------------------------------*/ -/* Fin du traitement nominal */ -/*---------------------------------------------------------------------------*/ -if (da_ascii != NULL) -{ - free(da_ascii); - } -retour = CAI_OK; -return (retour); - -/*---------------------------------------------------------------------------*/ -/* traitement degrade : */ -/*---------------------------------------------------------------------------*/ -ERREUR : -if (da_ascii != NULL) -{ - free(da_ascii); -} -return (retour); - -/*---------------------------------------------------------------------------*/ -/* FIN DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -} - -/*****************************************************************************/ -/* */ -/* Definition des OPERATIONS INTERNES */ -/* */ -/*****************************************************************************/ -/*****************************************************************************/ - -/*****************************************************************************/ -/* */ -/* OPERATION: cai_lirecleDA() */ -/* */ -/* ROLE: cette operation interne recherche le mot cle suivant detecte */ -/* apres une "adresse dans le fichier ". */ -/* cette operation retourne le mot cle suivant s'il existe ainsi qu'une adresse*/ -/* sur le premier caractere suivant ce mot cle */ -/* NB : la notion d'adresse ici est relative au fichier :c.a.d */ -/* 1er octet du fichier = adresse 0 */ -/* 2eme octet du fichier = adresse 1 ... */ -/* */ -/* */ -/* CONTEXTE D'APPEL: */ -/* */ -/* VERSION: */ -/* CODE RETOUR : CAI_OK ou CAI_KO */ -/* " mot cle non present dans le fichier de donnees auxiliaires %s" */ -/* " taille du mot cle lue %s superieure a la limite %d ou egale a 0" */ -/* " erreur a la lecture du fichier de donnees auxiliaires %s" */ -/*****************************************************************************/ -static CAI_OK_KO cai_lirecleDA(CAI_FILE_DA *fd,long ad_deb,char * mot_cle, - long *ad_suiv,long * ad_deb_mcc) -{ -CAI_OK_KO cr; /* code retour */ -long num; /* numero du buffer courant */ -long ad_deb_buff; /* adresse de debut du buffer */ -long ad_deb_rel; /* adresse de debut de recherche relative au buffer courant */ -long ad_suivante; /* adresse du premier caractere suivant le mot cle courant */ -long taille_buff_courant; /* taille du buffer lu */ -char *buff_courant; /* buffer courant */ -CAI_MOT_CLE mot_cle_courant;/* mot cle courant */ -off_t offset; -off_t offreel; -long nb_buffer; /* nombre de buffer dans le fichier */ -/*---------------------------------------------------------------------------*/ -/* DEBUT DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -/*CD dans CAI_FILE_DA on prevoit un indicateur qui vaut -1 si aucun buffer */ -/*CD n'a pas deja ete lu et qui vaut sinon le numero du buffer lu dans le fichier */ -/*CD on prevoit aussi la taille du buffer lu ainsi que l'allocation statique du buffer */ -/*CD et le decalage entre 2 buffer consecutifs ( fixe a taille_buff/2) */ -/*CD initialisations */ -cr=CAI_OK; - -/*---------------------------------------------------------------------------*/ -/*CD on recherche alors le nombre de buffer dans le fichier */ -/*---------------------------------------------------------------------------*/ -/*CD on se positionne sur la fin du fichier ( rewind ) */ -offset=0; -offreel=lseek(fd->descr,offset,SEEK_END); -/*CD SI erreur on sort "erreur lors d'un lseek du fichier de DA " */ -if ( offreel == -1) - { - cr=CAI_PB_LSEEK; - sprintf(CAI_ERREUR,"erreur lors du lseek sur le fichier %s",fd->nom_fichier); - goto ERREUR; - } -offreel=lseek(fd->descr,offset,SEEK_CUR); -/*CD SI erreur on sort "erreur lors d'un lseek du fichier de DA " */ -if ( offreel == -1) - { - cr=CAI_PB_LSEEK; - sprintf(CAI_ERREUR,"erreur lors du lseek sur le fichier %s",fd->nom_fichier); - goto ERREUR; - } -if ( offreel < ad_deb) - { - cr=CAI_ERR_ADRESSE; - sprintf(CAI_ERREUR,"erreur adresse de recherche en dehors du fichier (%d)",ad_deb); - goto ERREUR; - } - -nb_buffer = (offreel / (fd->taille_buffer/2) ) + 1; - -/*---------------------------------------------------------------------------*/ -/*CD on commence par calculer le premier buffer a lire par : num = 2 * ad_deb/(fd->taille buffer) */ -/*---------------------------------------------------------------------------*/ -num= (ad_deb/(fd->taille_buffer/2)); -ad_deb_buff = num * (fd->taille_buffer /2); - -/*CD SI indicateur != num */ -if ( num != fd->num_buffer) - { -/*---------------------------------------------------------------------------*/ -/*CD lecture du buffer num a partir de l'adresse num*fd->taille_buffer/2 et de taille*/ -/*CD fd->taille_buffer*2 (operation interne ) */ -/*---------------------------------------------------------------------------*/ - cr=cai_lireficDA( - fd, /* [E] structure decrivant le fichier de donnees auxiliaires */ - ad_deb_buff, /* [E] adresse du premier octet a lire */ - fd->buffer /* [E/S] buffer a remplir */ - ); -/*CD SI erreur on sort */ - if (cr != CAI_OK) - { - goto ERREUR; - } -/* initialisation du numero de buffer */ - fd->num_buffer=num; - buff_courant = fd->buffer; - taille_buff_courant = fd->taille_buffer_lu; - } -else - { -/*CD SINON tab = fd ->ad_buffer */ - buff_courant = fd->buffer; - taille_buff_courant = fd->taille_buffer_lu; - } - -ad_deb_rel = ad_deb - ad_deb_buff; -/*---------------------------------------------------------------------------*/ -/*CD TANT QUE mot_cle non trouve et non EOF */ -/*---------------------------------------------------------------------------*/ -cr=CAI_KO; -while ( cr !=CAI_OK && taille_buff_courant > 0 && cr != CAI_EOF && cr != CAI_PAS_MC) - { -/*---------------------------------------------------------------------------*/ -/*CD recherche du mot cle dans le buffer buff on retourne le mot cle,sa longueur et */ -/*CD l'adresse dans le tableau du caractere suivant le mot cle (operation interne ) */ -/*CD NB: attention au cas ou le mot cle peut etre coupe */ -/*---------------------------------------------------------------------------*/ - cr=cai_recherchecleDA( - taille_buff_courant,/* [E] taille du buffer a scanner en octets */ - buff_courant, /* [E] buffer a scanner */ - ad_deb_rel, /* [E] adresse a partir de laquelle il faut scanner le buffer */ - mot_cle_courant, /* [S] mot cle suivant lu */ - &ad_suivante /* [S] adresse du premier caractere suivant le mot cle */ - ); -/*CD si erreur on sort */ - if (cr != CAI_OK && cr != CAI_EOF && cr != CAI_PAS_MC) - { - goto ERREUR; - } - -/*CD Si mot_cle non trouve et non EOF on incremente le numero de buffer */ - if ( (cr == CAI_EOF||cr == CAI_PAS_MC) && num+1< nb_buffer) - { -/* calcul de l'adresse de debut de recherche */ - ad_deb_rel=0; -/*---------------------------------------------------------------------------*/ -/*CD lecture du buffer num a partir de l'adresse num*fd->taille_buffer/2 et de taille */ -/*CD fd->taille_buffer*2 (operation interne ) */ -/*---------------------------------------------------------------------------*/ - num=num+1; - ad_deb_buff = num * (fd->taille_buffer /2); - cr=cai_lireficDA( - fd, /* [E] structure decrivant le fichier de donnees auxiliaires */ - ad_deb_buff, /* [E] adresse du premier octet a lire */ - fd->buffer /* [E/S] buffer a remplir */ - ); -/*CD SI erreur on sort */ - if (cr != CAI_OK) - { - goto ERREUR; - } -/* initialisation du numero de buffer */ - fd->num_buffer=num; -/*CD on met a jour les variables locales */ - buff_courant = fd->buffer; - taille_buff_courant = fd->taille_buffer_lu; - cr=CAI_KO; - } - } -/*---------------------------------------------------------------------------*/ -/*CD FIN TANT QUE mot_cle non trouve */ -/*---------------------------------------------------------------------------*/ - -/*---------------------------------------------------------------------------*/ -/*CD SI mot_cle trouve */ -/*---------------------------------------------------------------------------*/ -if (cr == CAI_OK) - { -/*CD le mot cle est recopie dans l'argument de sortie */ - strcpy(mot_cle,mot_cle_courant); -/*CD l'adresse dans le tableau du caractere suivant le mot cle est convertie en */ -/*CD adresse absolue dans le fichier ad_suiv = num*fd->taille_buff/2 + (ad_suiv-ad_deb)*/ - *ad_suiv = (num * fd->taille_buffer/2) + ad_suivante; -/*CD l'adresse dans le tableau du premier caractere du mot cle est convertie en */ -/*CD adresse absolue dans le fichier ad_deb_mc = ad_suiv -long */ - *ad_deb_mcc=*ad_suiv -strlen(mot_cle) - 2; - } -/*---------------------------------------------------------------------------*/ -/*CD SI EOF plus de mot cle */ -/*---------------------------------------------------------------------------*/ -if (cr == CAI_PAS_MC) - { - goto ERREUR; - } -if (taille_buff_courant ==0 || cr == CAI_EOF) - { - cr=CAI_EOF; - goto ERREUR; - } -/*---------------------------------------------------------------------------*/ -/*CD fin de l'operation en cas nominal */ -/*---------------------------------------------------------------------------*/ -return(CAI_OK); -/*---------------------------------------------------------------------------*/ -/*CD fin de l'operation en cas d'erreur */ -/*---------------------------------------------------------------------------*/ -ERREUR: -return(cr); -/*---------------------------------------------------------------------------*/ -/* FIN DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -} -/*****************************************************************************/ -/* */ -/* OPERATION: cai_liredonneeDA */ -/* */ -/* ROLE: Cette operation interne analyse syntaxiquement les donnees stockees */ -/* apres un mot cle jusqu'au prochain mot_cle du fichier ou EOF. */ -/* Elle permet donc de determiner le type , la taille de la donnee . */ -/* ( ENTIER REEL OU CAI_ASCII) ( 2 dim maxi ) */ -/* Elle s'alloue de plus la place necessaire au stockage de cette donnees. */ -/* pour les donnees CAI_ASCII , le stockage se fait de maniere contigue en */ -/* memoire dans un tableau de cellules de taille fixe (taille_max). */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL: */ -/* */ -/* VERSION: */ -/* CODE RETOUR : CAI_OK ou CAI_KO */ -/* " erreur a la lecture du fichier de donnees auxiliaires %s" */ -/* " parenthese ouvrante non detectee (mot cle %s ) */ -/* " parenthese fermante non detectee (mot cle %s ) */ -/* " nombre de niveaux de parentheses superieur a 2 ( mot cle %s ) */ -/* " % dimension du tableau non constante (mot cle %s) */ -/* " % dimension du tableau = 0 (mot cle %s) */ -/* " type de la donnee lue %s non reconnue (mot cle %s) */ -/* " erreur lors du decodage de la donnee lue %s" (mot cle %s) */ -/*****************************************************************************/ -static CAI_OK_KO cai_liredonneeDA(CAI_FILE_DA *fd,long ad_deb, void **don_lue, - CAI_TYPE *type_lu,int *nb_lig_lu, - int *nb_col_lu, long *taille_cell_lu ) -{ -CAI_OK_KO cr; /* code retour */ -long num; /* numero du buffer courant */ -long ad_deb_buff; /* adresse de debut du buffer */ -long ad_deb_rel; /* adresse de debut de recherche relative au buffer courant */ -long taille_buff_courant; /* taille du buffer lu */ -char *buff_courant; /* buffer courant */ -off_t offset; -off_t offreel; -long nb_buffer; /* nombre de buffer dans le fichier */ -int nb_lig; /* nombre de lignes */ -int nb_elt; /* nombre d'elements */ -long taille_maxi; /* taille maxi d'une donnee ascii */ -CAI_ETAT1 etat1; /* etat de l'automate de decodage */ -CAI_TYPE type; /* type de la donnee */ -int nb_elt_alloues; /* nombre d'elements alloues */ -long ad_fin_decodage; /* adresse de fin du decodage effectif du buffer */ -/*---------------------------------------------------------------------------*/ -/* DEBUT DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -/* dans CAI_FILE_DA on prevoit un indicateur qui vaut zero si aucun buffer */ -/* n'a pas deja ete lu et qui vaut sinon le numero du buffer lu dans le fichier */ -/* on prevoit aussi la taille du buffer lu ainsi que l'allocation statique du buffer */ -/* et le decalage entre 2 buffer consecutifs ( fixe a taille_buff/2) */ -/*CD initialisations */ -cr=CAI_OK; -nb_lig = 1; -nb_elt = 0; -taille_maxi = 0; -etat1 = CAI_DEBUTDEC; -type=CAI_INCONNU; -nb_elt_alloues=0; - -/*CD on recherche alors le nombre de buffer dans le fichier */ -/*CD on se positionne sur la fin du fichier ( rewind ) */ -offset=0; -offreel=lseek(fd->descr,offset,SEEK_END); -/*CD SI erreur on sort "erreur lors d'un lseek du fichier de DA " */ -if ( offreel == -1) - { - cr=CAI_PB_LSEEK; - sprintf(CAI_ERREUR,"erreur lors du lseek sur le fichier %s",fd->nom_fichier); - goto ERREUR; - } -offreel=lseek(fd->descr,offset,SEEK_CUR); -/*CD SI erreur on sort "erreur lors d'un lseek du fichier de DA " */ -if ( offreel == -1) - { - cr=CAI_PB_LSEEK; - sprintf(CAI_ERREUR,"erreur lors du lseek sur le fichier %s",fd->nom_fichier); - goto ERREUR; - - } -if ( offreel <= ad_deb) - { - cr=CAI_ERR_ADRESSE; - sprintf(CAI_ERREUR,"erreur adresse de recherche en dehors du fichier (%d)",ad_deb); - goto ERREUR; - } - -nb_buffer = (offreel / (fd->taille_buffer/2) ) + 1; - -/*CD on commence par calculer le premier buffer a lire par : num = 2 * ad_deb/(fd->taille buffer) */ -num= (ad_deb/(fd->taille_buffer/2)); -ad_deb_buff = num * (fd->taille_buffer /2); - -/*CD SI indicateur != num */ -if ( num != fd->num_buffer) - { -/*CD lecture du buffer num a partir de l'adresse num*fd->taille_buffer/2 et de taille*/ -/*CD fd->taille_buffer*2 (operation interne ) */ - cr=cai_lireficDA( - fd, /* [E] structure decrivant le fichier de donnees auxiliaires */ - ad_deb_buff, /* [E] adresse du premier octet a lire */ - fd->buffer /* [E/S] buffer a remplir */ - ); -/*CD SI erreur on sort */ - if (cr != CAI_OK) - { - goto ERREUR; - } -/* initialisation du numero de buffer */ - fd->num_buffer=num; - buff_courant = fd->buffer; - taille_buff_courant = fd->taille_buffer_lu; - } -else - { -/*CD SINON tab = fd ->ad_buffer */ - buff_courant = fd->buffer; - taille_buff_courant = fd->taille_buffer_lu; - } - -/*CD calcul de l'adresse relative du debut de la recherche dans le buffer */ -/*CD ad_deb_buff = ad_deb - num* fd->taille buffer/2 */ -ad_deb_rel = ad_deb - ad_deb_buff; - - -/*CD TANT QUE statut <> lu et non EOF */ -while ( etat1 != CAI_FINDEC && cr != CAI_EOF && taille_buff_courant > 0) - { -/*CD lecture de la donnee dans le buffer buff on retourne le tableau des donnees qui*/ -/*CD ont ete lues (tableau eventuellement incomplet) , la taille du tableau lu */ -/*CD , le type , la dimension1 , le nb elt , la taille maxi , si incomplet le */ -/*CD statut de l'automate est retourne (operation interne) */ -/*CD NB: attention au cas ou la donnee peut etre coupe */ - cr=cai_decodedonDA( - taille_buff_courant, /* [E] taille du buffer a scanner en octets */ - buff_courant, /* [E] buffer a scanner */ - ad_deb_rel, /* [E] adresse a partir de laquelle il faut scanner le buffer */ - &type, /* [E/S] type de la donnee lue (=CAI_INCONNU lors du premier appel) */ - /* CAI_ENTIER4 CAI_REEL8 CAI_ASCII EN SORTIE */ - &nb_lig, /* [E/S] nombre de lignes du tableau lu ( = 0 lors du premier appel) */ - &nb_elt, /* [E/S] nombre d'elements du tableau lu ( = 0 lors du premier appel) */ - &nb_elt_alloues, /* [E/S] nombre d'elements du tableau lu ( = 0 lors du premier appel)*/ - &taille_maxi,/*[E/S] taill max en octet d'un elt du tab lu (=0 lors du premier appel*/ - /* significatif exclusivement pour des donnees CAI_ASCII */ - don_lue, /* [E/S] donnee lue */ - &etat1, /* [E/S] etat de l'auto ( = DEBUT_DECODAGE lors du premier appel )*/ - &ad_fin_decodage /* [E/S] adresse de fin du decodage effectif du buffer */ - ); - - -/*CD si erreur on sort */ - if (cr != CAI_OK && cr != CAI_EOF) - { - goto ERREUR; - } - -/*CD Si mot_cle non trouve et non EOF on incremente le numero de buffer */ - if ( cr == CAI_EOF && num+1< nb_buffer) - { -/*---------------------------------------------------------------------------*/ -/*CD lecture du buffer num a partir de l'adresse num*fd->taille_buffer/2 et de taille */ -/*CD fd->taille_buffer*2 (operation interne ) */ -/*---------------------------------------------------------------------------*/ - num=num+1; - ad_deb_buff = num * (fd->taille_buffer /2); - cr=cai_lireficDA( - fd, /* [E] structure decrivant le fichier de donnees auxiliaires */ - ad_deb_buff, /* [E] adresse du premier octet a lire */ - fd->buffer /* [E/S] buffer a remplir */ - ); -/*CD SI erreur on sort */ - if (cr != CAI_OK) - { - goto ERREUR; - } -/* initialisation du numero de buffer */ - fd->num_buffer=num; -/*CD on met a jour les variables locales */ - buff_courant = fd->buffer; - taille_buff_courant = fd->taille_buffer_lu; -/*CD calcul de l'adresse relative du debut de la recherche dans le buffer */ -/*CD ad_deb_buff = ad_deb_buff(donnee par l'operation precedente) - */ -/*CD fd->taille buffer/2 ( decalage entre 2 buffers) */ - ad_deb_rel = ad_fin_decodage - (fd->taille_buffer/2); - } - } -/*CD FIN TANT QUE statut <> lu et non EOF */ - -/*CD si statut <> lu et EOF on sort en erreur "erreur fichier de DA incomplet (mot cle %s) */ -if ( etat1 != CAI_FINDEC && etat1 != CAI_DEBUTDEC && (cr == CAI_EOF || taille_buff_courant == 0) ) - { - cr == CAI_EOF; - goto ERREUR; - } -else - { - if (etat1 == CAI_DEBUTDEC && (cr == CAI_EOF || taille_buff_courant == 0) ) - { - type=CAI_BLOC; - } - } -/*---------------------------------------------------------------------------*/ -/*CD fin de l'operation en cas nominal */ -/*---------------------------------------------------------------------------*/ -*nb_lig_lu=nb_lig; -*nb_col_lu= nb_elt/nb_lig; -*type_lu = type; -*taille_cell_lu=taille_maxi; -return(CAI_OK); -/*---------------------------------------------------------------------------*/ -/*CD fin de l'operation en cas d'erreur */ -/*---------------------------------------------------------------------------*/ -ERREUR: -*nb_lig_lu=nb_lig; -*nb_col_lu= nb_elt/nb_lig; -*type_lu = type; -*taille_cell_lu=taille_maxi; -return(cr); -/*---------------------------------------------------------------------------*/ -/* FIN DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -} -/*****************************************************************************/ -/* */ -/* OPERATION: cai_deplaceficDA */ -/* */ -/* ROLE: Cette operation interne cree un trou ou compacte un fichier de DA. */ -/* precedenment ouvert en lecture ecriture . */ -/* ex1 : avant [+++++++++++++++++++++++++++] */ -/* |--> deplacement */ -/* V */ -/* ad_deb */ -/* apres [+++++++++++++ ++++++++++++++] */ -/* |--> deplacement */ -/* V */ -/* ad_deb */ -/* ex2 : avant [+++++++++++++++++++++++++++] */ -/* deplacement<--| */ -/* V */ -/* ad_deb */ -/* apres [++++++++++++++++++++++++] */ -/* | */ -/* V */ -/* ad_deb */ -/* NB: on lit et on ecrit des buffers de taille fd->taille_buffer */ -/* */ -/* */ -/* CONTEXTE D'APPEL: */ -/* */ -/* VERSION: */ -/*****************************************************************************/ -static CAI_OK_KO cai_deplaceficDA(CAI_FILE_DA *fd ,long debut,long deplacement) - -{ -CAI_OK_KO fin_fichier_avant_transfert; /* fin fichier origine */ -long nb_octets_a_transferer; /* nombre total d'octets a transferer */ -long nb_octets_transferes; /* nombre total d'octets transferes */ -long nb_octets_a_lire; /* longueur courante du buffer a lire */ -long nb_octets_lus; /* longueur du buffer lu */ -long adresse_debut_buffer; /* adresse debut courante a lire */ -CAI_OK_KO retour; -off_t cr; /* code retour des fonctions appelees */ -long cr2; -/*---------------------------------------------------------------------------*/ -/* DEBUT DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -retour =lseek(fd->descr,0L,SEEK_END); -if ( retour == -1) - { - sprintf(CAI_ERREUR,"erreur lors d'un lseek sur le fichier de DA"); - retour=CAI_PB_LSEEK ; - goto ERREUR; /* pb lseek */ - } -fin_fichier_avant_transfert=retour; -if ( debut < 0) { - sprintf(CAI_ERREUR,"erreur debut de la zone a deplacer negative (%d)",debut); - retour=CAI_DEB_NEG; - goto ERREUR; /* debut negatif */ - } -if ( debut > fin_fichier_avant_transfert) { - sprintf(CAI_ERREUR,"erreur debut de la zone a deplacer en dehors du fichier ",debut); - retour=CAI_FIN_DEP; - goto ERREUR; /* pb debut en dehors du fichier */ - } -if ( debut + deplacement < 0) { - sprintf(CAI_ERREUR,"pb de tassement: deplacement de la zone impossible "); - retour=CAI_ECRASEMENT; - goto ERREUR; /* pb tassement du fichier en tete */ - } -nb_octets_transferes=0; -nb_octets_a_transferer=fin_fichier_avant_transfert - debut; - -if ( deplacement >= 0) - { - adresse_debut_buffer=maxi(debut,fin_fichier_avant_transfert - fd->taille_buffer); - } -else - { - adresse_debut_buffer=debut; - } - -/*CD TANT QUE tous les octets n'ont pas ete transferes */ -while (nb_octets_transferes < nb_octets_a_transferer) - { - nb_octets_a_lire = mini(fd->taille_buffer, nb_octets_a_transferer - nb_octets_transferes); - cr = lseek(fd->descr,adresse_debut_buffer,SEEK_SET); - if( cr != adresse_debut_buffer) - { - sprintf(CAI_ERREUR,"erreur lors d'un lseek sur le fichier de DA"); - retour=CAI_PB_LSEEK; - goto ERREUR; - } - nb_octets_lus = read(fd->descr,fd->buffer,nb_octets_a_lire); - if (nb_octets_lus != nb_octets_a_lire) - { - sprintf(CAI_ERREUR,"erreur de lecture dans le fichier de DA"); - retour=CAI_PB_READ; - goto ERREUR; - } - cr= lseek(fd->descr,adresse_debut_buffer+deplacement,SEEK_SET); - - if ( cr != (adresse_debut_buffer + deplacement)) - { - sprintf(CAI_ERREUR,"erreur lors d'un lseek sur le fichier de DA"); - retour=CAI_PB_LSEEK; - goto ERREUR; - } - cr2=write(fd->descr,fd->buffer,nb_octets_lus); - if ( cr2 != nb_octets_lus ) - { - sprintf(CAI_ERREUR,"erreur d'ecriture dans le fichier de DA"); - retour=CAI_PB_WRITE; - goto ERREUR; - } - nb_octets_transferes = nb_octets_transferes + nb_octets_lus; - if ( deplacement >= 0) - { - adresse_debut_buffer=maxi( adresse_debut_buffer - fd->taille_buffer,debut); - } - else - { - adresse_debut_buffer=mini( adresse_debut_buffer + fd->taille_buffer,fin_fichier_avant_transfert); - } - } -/*CD FIN TANT QUE tous les octets n'ont pas ete transferes */ -if (deplacement < 0 ) - { - retour=ftruncate(fd->descr,(size_t)(fin_fichier_avant_transfert+deplacement)); - if (retour != 0) - { - sprintf(CAI_ERREUR,"erreur lors d'un ftruncate sur le fichier de DA"); - retour=CAI_PB_FTRUNC; - goto ERREUR; - } - } -/*---------------------------------------------------------------------------*/ -/*CD fin de l'operation en cas nominal */ -/*---------------------------------------------------------------------------*/ -return(CAI_OK); -/*---------------------------------------------------------------------------*/ -/*CD fin de l'operation en cas d'erreur */ -/*---------------------------------------------------------------------------*/ -ERREUR: -return(retour); -/*---------------------------------------------------------------------------*/ -/* FIN DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -} -/*****************************************************************************/ -/* */ -/* OPERATION: cai_lireficDA */ -/* */ -/* ROLE: Cette operation interne lit dans le fichier de DA un buffer a partir*/ -/* d'une adresse specifiee par l'utilisateur d'un nombre d'octets specifie*/ -/* par l'utilisateur . */ -/* ( utilisation de lseek , read ) */ -/* ( buffer probable de 4096 octets) */ -/* */ -/* */ -/* CONTEXTE D'APPEL: */ -/* */ -/* VERSION: */ -/* CODE RETOUR : CAI_OK ou CAI_KO */ -/* " erreur lors du rewind sur le fichier de DA " */ -/* " erreur lors du fseek sur le fichier de DA ( ad_deb =%d) " */ -/* " erreur a la lecture du fichier de donnees auxiliaires %s" */ -/*****************************************************************************/ -static CAI_OK_KO cai_lireficDA(CAI_FILE_DA *fd,long ad_deb,char *buff) - -{ -off_t offset; /* offset dans le fichier de donnees auxiliaires */ -off_t offreel; /* offset reel obtenu apres lseek */ -long nb_lus; /* nombres d'octets lus */ -CAI_OK_KO cr; /* code retour */ -/*---------------------------------------------------------------------------*/ -/* DEBUT DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -cr=CAI_OK; -/*CD on se positionne sur le debut du fichier ( rewind ) */ -offset=0; -offreel=lseek(fd->descr,offset,SEEK_SET); -/*CD SI erreur on sort "erreur lors du rewind du fichier de DA " */ -if ( offreel == -1) - { - cr=CAI_PB_LSEEK; - sprintf(CAI_ERREUR,"erreur lors du rewind du fichier %s",fd->nom_fichier); - goto ERREUR; - } -/*CD on se deplace de ad_deb octets dans le fichier (fseek) */ -offset=ad_deb; -offreel=lseek(fd->descr,offset,SEEK_SET); -/*CD SI erreur on sort " erreur lors du lseek du fichier de DA (ad_deb=%d)" */ -if ( offreel == -1) - { - cr=CAI_PB_LSEEK; - sprintf(CAI_ERREUR,"erreur lors du lseek sur le fichier %s",fd->nom_fichier); - goto ERREUR; - } -/*CD SI erreur on sort "erreur lors du fseek du fichier de DA " */ -/*CD on lit le buffer ( read ) */ -nb_lus=read(fd->descr,buff,fd->taille_buffer); -if (nb_lus == -1) - { - sprintf(CAI_ERREUR,"erreur lors du read sur le fichier %s",fd->nom_fichier); - cr=CAI_PB_READ; - goto ERREUR; - } -*(buff + nb_lus)= '\0'; -/*CD SI taille_ecrite <> taille buff on sort " erreur a l'ecriture du fichier de donnee ..." */ -if ( nb_lus != fd->taille_buffer) - { - fd->taille_buffer_lu=nb_lus; - } -else - { - fd->taille_buffer_lu=fd->taille_buffer; - } -/*---------------------------------------------------------------------------*/ -/*CD fin de l'operation en cas nominal */ -/*---------------------------------------------------------------------------*/ -return(CAI_OK); -/*---------------------------------------------------------------------------*/ -/*CD fin de l'operation en cas d'erreur */ -/*---------------------------------------------------------------------------*/ -ERREUR: -return(cr); -/*---------------------------------------------------------------------------*/ -/* FIN DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -} -/*****************************************************************************/ -/* */ -/* OPERATION: cai_ecrireficDA */ -/* */ -/* ROLE: Cette operation interne ecrit dans un fichier de DA temporaire un buffer a partir*/ -/* d'une adresse specifiee par l'utilisateur d'un nombre d'octets specifie*/ -/* par l'utilisateur . */ -/* ( utilisation de rewind , fseek , write ) */ -/* ( buffer probable de 4096 octets) */ -/* */ -/* */ -/* CONTEXTE D'APPEL: */ -/* */ -/* VERSION: */ -/* CODE RETOUR : CAI_OK ou CAI_KO */ -/* " erreur lors du rewind sur le fichier de DA " */ -/* " erreur lors du fseek sur le fichier de DA ( ad_deb =%d) " */ -/* " erreur a l'ecriture du fichier de donnees auxiliaires %s" */ -/*****************************************************************************/ -static CAI_OK_KO cai_ecrireficDA(CAI_FILE_DA *fd,long ad_deb, - long taille, char **buff ) - -{ -off_t offset; /* offset dans le fichier de donnees auxiliaires */ -off_t offreel; /* offset reel obtenu apres lseek */ -long nb_ecrits; /* nombres d'octets ecrit */ -CAI_OK_KO cr; /* code retour */ -/*---------------------------------------------------------------------------*/ -/* DEBUT DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -cr=CAI_OK; -/*CD on se positionne sur le debut du fichier ( lseek ) */ -offset=0; -offreel=lseek(fd->descr,offset,SEEK_SET); -/*CD SI erreur on sort "erreur lors du rewind du fichier de DA " */ -if ( offreel == -1) - { - cr=CAI_PB_LSEEK; - sprintf(CAI_ERREUR,"erreur lors du lseek sur le fichier %s",fd->nom_fichier); - goto ERREUR; - } -/*CD on se deplace de ad_deb octets dans le fichier (fseek) */ -offset=ad_deb; -offreel=lseek(fd->descr,offset,SEEK_SET); -/*CD SI erreur on sort " erreur lors du lseek du fichier de DA (ad_deb=%d)" */ -if ( offreel == -1) - { - cr=CAI_PB_LSEEK; - sprintf(CAI_ERREUR,"erreur lors du lseek sur le fichier %s",fd->nom_fichier); - goto ERREUR; - } -/*CD on ecrit le buffer ( write ) */ -nb_ecrits=write(fd->descr,*buff,taille); -/*CD SI taille_ecrite <> taille buff on sort " erreur a l'ecriture du fichier de donnee ..." */ -if ( nb_ecrits != taille) - { - sprintf(CAI_ERREUR,"erreur lors du write sur le fichier %s",fd->nom_fichier); - cr=CAI_PB_WRITE; - goto ERREUR; - } -/*---------------------------------------------------------------------------*/ -/*CD fin de l'operation en cas nominal */ -/*---------------------------------------------------------------------------*/ -return(CAI_OK); -/*---------------------------------------------------------------------------*/ -/*CD fin de l'operation en cas d'erreur */ -/*---------------------------------------------------------------------------*/ -ERREUR: -return(cr); -/*---------------------------------------------------------------------------*/ -/* FIN DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -} -/*****************************************************************************/ -/* */ -/* OPERATION: cai_decodedonDA */ -/* */ -/* ROLE: Cette operation interne decode une donnee sous la forme */ -/* ENTIER: (( 1 2 24 ) ( 4 5 6 )) ou REEL: ((1. 2. 24.) (4. 5. 6.)) */ -/* ASCII: (( "1" "2" "24" ) ( "4" "5" "6" )) */ -/* BLOC ( donnee vide ) */ -/* cette operation commence par rechercher la premiere donnee pour determiner*/ -/* le type de donnee puis decode chaque donnee , alloue la place necessaire */ -/* et parcourt ainsi tout le buffer */ -/* NB: Si la donnee est coupee on rend a l'appelant le statut "en cours" */ -/* ainsi qu'un pointeur sur le caractere suivant la derniere donnee lus et */ -/* l'etat de l'automate . */ -/* la place est alloue par cette operation mais l'appelant se charge de la */ -/* liberer si besoin. */ -/* */ -/* */ -/* ETAT = ( DEBUT DECODAGE <=> ATTENTE (( 0 */ -/* ATTENTE ( 1 */ -/* ATTENTE DONNEE 2 */ -/* ATTENTE DONNEE ou ) 3 */ -/* ATTENTE ) ou ( 4 */ -/* FIN decodage 5 */ -/* BLOC 6 */ -/* ERREUR parenthese 11 */ -/* ERREUR fin de donne prematuree 13 */ -/* CARACTERE = ( */ -/* ) */ -/* AUTRE */ -/* < */ -/* BLANC ou TAB ou \N */ -/* etat: CARACTERE ( ) AUTRE < BLANC ou TAB ou \n */ -/* 0 1 11 11 6 0 */ -/* 1 2 11 11 13 1 */ -/* 2 11 4 3 13 2 */ -/* 3 11 4 3 13 3 */ -/* 4 2 5 11 13 4 */ -/* */ -/* dans les etats 2 et 3 si l'evenement = AUTRE on passe a un nouvel */ -/* automate ( remarque :si 2 dimensions on passe de l'etat 4 a l'etat 2 */ -/* */ -/* ETAT1 = Debut decodage donnee 0 */ -/* attente point(reel) ou blanc (entier) 1 */ -/* attente " 2 */ -/* attente BLANC ou TAB ou \n 3 */ -/* ENTIER 4 */ -/* chaine de caracteres 5 */ -/* REEL 6 */ -/* erreur donnee 11 */ -/* CARACTERE1 = . */ -/* " */ -/* BLANC ou TAB ou \n */ -/* CHIFFRE */ -/* SIGNE */ -/* AUTRE */ -/* */ -/* etat :caractere1 . " BLANC ou TAB ou \n ou ) CHIFFRE SIGNE AUTRE*/ -/* 0 3 2 11 1 1 11 */ -/* 1 3 11 4 1 11 11 */ -/* 2 2 5 2 2 2 2 */ -/* 3 3 11 6 3 3 3 */ -/* CONTEXTE D'APPEL: */ -/* */ -/* VERSION: */ -/* CODE RETOUR : CAI_OK ou CAI_KO */ -/* "ERREUR donnee non presente ( mot cle %s)" */ -/* "erreur parenthese ( mot cle %s)" */ -/* "erreur fin de donnee prematuree ( mot cle %s) */ -/* "erreur type de donne non reconnu" */ -/* "erreur de decodage de la donne (mot cle %s) " */ -/*****************************************************************************/ -static CAI_OK_KO cai_decodedonDA(long taille_buf, char buff[],long ad_deb, - CAI_TYPE *type_lu,int *nb_lig_lu,int *nb_elt_lu, - int *nb_elt_alloc,long *taille_cell_lu, - void **don_lue, CAI_ETAT1 *etat1,long *ad_fin_dec) -{ -long indice; /* indice de parcourt du buffer */ -CAI_TYPE type; /* type de la donnee decodee */ -int nb_lig; /* nombre de lignes de la donnee */ -int nb_elt; /* nombre d'elements de la donnee */ -long taille_max; /* taille max d'une cellule CAI_ASCII */ -int cr; /* code retour de la fonction */ -CAI_OK_KO code; /* code retour */ -char car; /* caractere courant traite */ -CAI_ETAT1 etat1_prec; /* etat precedent de niveau 1 */ -CAI_EVT1 evt1; /* evenement de niveau 1 detectee */ -CAI_ETAT2 etat2; /* etat de niveau 2 ( determination du type ) */ -CAI_EVT2 evt2; /* evenement de niveau2 */ -long ad_deb_do; /* adresse de debut de la donnee courante */ -long int *entier; /* pointeur sur donnees entieres */ -double *reel; /* pointeur sur donnees reelles */ -char *asc; /* pointeur sur donnees ascii */ -int nb_elt_alloues;/* nombres d'elements alloues */ -long taille; /* taille d'une donnee a decoder */ -int nb_col; /* nombre de colonnes */ -/*---------------------------------------------------------------------------*/ -/* DEBUT DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -/* initialisations */ - -cr=CAI_OK; -indice=ad_deb; -type= *type_lu; -nb_lig= *nb_lig_lu; -nb_elt= *nb_elt_lu; -taille_max = *taille_cell_lu; -nb_elt_alloues= *nb_elt_alloc; -taille=0; -if (type == CAI_ASCII) - { - asc=(char *) *don_lue; - } -else - { - if (type == CAI_REEL8) - { - reel=(double *) *don_lue; - } - else - { - if (type == CAI_ENTIER4) - { - entier=(long int *) *don_lue; - } - else - { - asc = (char *)malloc(CAI_TAILLE_MAX_ASCII); - if (asc == NULL ) - { - sprintf(CAI_ERREUR,"Erreur d'allocation lors de la lecture de la donnees"); - cr=CAI_ERR_ALLOC; - goto ERREUR; - } - reel=(double *)asc; - entier=(long int *)asc; - } - } - } - -/*---------------------------------------------------------------------------*/ -/* TANT QUE non erreur et non fin decodage et indice < taille buffer */ -/*---------------------------------------------------------------------------*/ -while( *etat1 >= 0 && *etat1 != CAI_FINDEC && indice < taille_buf) - { -/* car = buff[indice] */ -/* etat1_prec=etat1 */ - car = buff[indice]; - etat1_prec=*etat1; -/*---------------------------------------------------------------------------*/ -/* fonction interne testant ( ) < BLANC ou TAB ou n AUTRE */ -/*---------------------------------------------------------------------------*/ - code=cai_analyseDA( - car, /* [E] caractere a tester */ - &evt1 /* [S] evenement detecte */ - ); - -/* etat1 = automate1[etat1][evt1] */ - *etat1 = autom1[*etat1][evt1]; -/* si erreur on affiche le messsage associe et on sort */ - if (*etat1 > 10) - { - switch (*etat1) { - case CAI_ERR11:cr = CAI_ERR_FORME_FIC; - sprintf(CAI_ERREUR,"erreur: forme donnee non coherente"); - break; - case CAI_ERR13:cr = CAI_ERR_FIN_DO; - sprintf(CAI_ERREUR,"erreur: fin de donnee prematuree"); - break; - default:cr = CAI_KO; - sprintf(CAI_ERREUR,"erreur automate1 non reconnue"); - break; - } - goto ERREUR; - } -/* si etat1= 2 et etat1_prec=4 */ -/* dim2 = dim2 + 1 */ - if ( *etat1 == CAI_ETAT12 && etat1_prec == CAI_ETAT14) - { - nb_lig=nb_lig + 1; - } -/* sauvegarde ad_deb_do */ - ad_deb_do=indice+1; - if ( *etat1 == CAI_BLOCVIDE ) - { - type=CAI_BLOC; - nb_lig=1; - nb_elt=0; - *etat1 = CAI_FINDEC; - } -/* SI (etat1=3) */ - if ( *etat1 == CAI_ETAT13) - { -/* initialisation etat2 */ - etat2= CAI_DEBUTYPE; -/* sauvegarde ad_deb_do */ - ad_deb_do=indice; -/*---------------------------------------------------------------------------*/ -/* TANT QUE etat2 non REEL et non ENTIER et non ASCII et indice < taille buffer */ -/*---------------------------------------------------------------------------*/ - while ( etat2 != CAI_REEL && etat2 != CAI_ENTIER && etat2 != CAI_ASC && indice <taille_buf ) - { -/*---------------------------------------------------------------------------*/ -/* fonction interne testant . " CHIFFRE SIGNE BLANC AUTRE */ -/*---------------------------------------------------------------------------*/ - code=cai_typeDA( - car, /* [E] caractere a tester */ - &evt2 /* [S] evenement detecte */ - ); -/* etat2 = automate2[etat2][evt2] */ - etat2=autom2[etat2][evt2]; -/* si erreur on affiche le messsage associe et on sort */ - if (etat2 > 10) - { - switch (etat2) { - case CAI_ERR21:cr = CAI_ERR_TYP; - sprintf(CAI_ERREUR,"erreur: type de donnee non coherente"); - break; - default:cr = CAI_KO; - sprintf(CAI_ERREUR,"erreur automate2 non reconnue"); - break; - } - goto ERREUR; - } -/* l'indice est incremente */ - indice ++; - car = buff[indice]; - } -/*---------------------------------------------------------------------------*/ -/* FIN TANT QUE non erreur et non REEL et non ENTIER et non ASCII */ -/*---------------------------------------------------------------------------*/ - -/* SI on arrive en fin de buffer sans avoir decode la donnee */ - if ( indice == taille_buf && (etat2 != CAI_REEL || etat2 != CAI_ENTIER || etat2 != CAI_ASC)) - { - cr= CAI_EOF; - } - else - { - if (etat2 == CAI_ASC || type == CAI_ASCII ) - { - if (etat2 != CAI_ASC || (type != CAI_ASCII && type != CAI_INCONNU)) - { - sprintf(CAI_ERREUR,"Erreur: melange de type dans une meme donnee"); - cr=CAI_ERR_ASCII; - goto ERREUR; - } - type=CAI_ASCII; -/*---------------------------------------------------------------------------*/ -/* si CAI_ASCII allocation et decodage entre ad_deb+1 et ad_fin -1 */ -/* ( verification que la taille est inferieure a la taille max CAI_ASCII) */ -/*---------------------------------------------------------------------------*/ - taille= (indice) - (ad_deb_do) -2 + 1; - if (taille >= CAI_TAILLE_MAX_ASCII) - { - sprintf(CAI_ERREUR,"donnee ascii de taille sup a CAI_TAILLE_MAX_ASCII (%d)",taille); - cr=CAI_ERR_ASCII; - goto ERREUR; - } -/* allocation de CAI_NB_ALLOC element reel entier et ASCII */ -/* par un realloc d'un ascii ( taille max) et sscanf(%s) */ - if (nb_elt_alloues <= nb_elt) - { - asc = (char *)realloc(asc,CAI_TAILLE_MAX_ASCII*(CAI_NB_ALLOC + nb_elt_alloues)); - if (asc != NULL ) - { - nb_elt_alloues = CAI_NB_ALLOC + nb_elt_alloues; - } - else - { - sprintf(CAI_ERREUR,"Erreur d'allocation lors de la lecture de la donnees"); - cr=CAI_ERR_ALLOC; - goto ERREUR; - } - } - - strncpy(asc + (nb_elt*CAI_TAILLE_MAX_ASCII),buff+ad_deb_do+1,taille-1); - *(asc + (nb_elt)*CAI_TAILLE_MAX_ASCII +taille -1 )='\0'; -/* taille_max = sup (taille_max,taille) */ - taille_max=maxi(taille,taille_max); - -/* nbelt = nbelt + 1 */ - nb_elt=nb_elt +1; - } - else - { - indice--; -/*---------------------------------------------------------------------------*/ -/* si REEL allocation et decodage entre ad_deb et ad_fin-1 */ -/* par un realloc d'un reel et sscanf(%lf) */ -/*---------------------------------------------------------------------------*/ - if (etat2 == CAI_REEL || type == CAI_REEL8) - { - if (etat2 != CAI_REEL || (type != CAI_REEL8 && type != CAI_INCONNU)) - { - sprintf(CAI_ERREUR,"Erreur: melange de types dans une meme donnee"); - cr=CAI_ERR_REEL; - goto ERREUR; - } - type = CAI_REEL8; -/* allocation de CAI_NB_ALLOC element reel */ - if (nb_elt_alloues <= nb_elt) - { - reel=(double *)realloc(reel,sizeof(double)*(CAI_NB_ALLOC + nb_elt_alloues)); - if (reel != NULL ) - { - nb_elt_alloues = CAI_NB_ALLOC + nb_elt_alloues; - } - else - { - sprintf(CAI_ERREUR,"Erreur d'allocation lors de la lecture de la donnees"); - cr=CAI_ERR_ALLOC; - goto ERREUR; - } - } - code=sscanf(buff+ad_deb_do," %lf",reel+nb_elt); - if (code != 1) - { - sprintf(CAI_ERREUR,"Erreur de decodage de la donnee reelle (element %d)",nb_elt); - cr=CAI_ERR_REEL; - goto ERREUR; - } - } - else - { - if (etat2 != CAI_ENTIER || (type != CAI_ENTIER4 && type != CAI_INCONNU)) - { - sprintf(CAI_ERREUR,"Erreur: melange de type dans une meme donnee"); - cr=CAI_ERR_ENTIER; - goto ERREUR; - } - type = CAI_ENTIER4; -/*---------------------------------------------------------------------------*/ -/* si ENTIER allocation et decodage entre ad_deb et ad_fin -1 */ -/* par un realloc d'un entier4 et sscanf(%d) */ -/* allocation de CAI_NB_ALLOC element entier */ -/*---------------------------------------------------------------------------*/ - if (nb_elt_alloues <= nb_elt) - { - entier=(long int *)realloc(entier,sizeof(long int)*(CAI_NB_ALLOC+nb_elt_alloues)); - if (entier != NULL ) - { - nb_elt_alloues = CAI_NB_ALLOC + nb_elt_alloues; - } - else - { - sprintf(CAI_ERREUR,"Erreur d'allocation lors de la lecture de la donnees"); - cr=CAI_ERR_ALLOC; - goto ERREUR; - } - } - code =sscanf(buff+ad_deb_do," %ld", - entier+nb_elt); - if (code != 1) - { - sprintf(CAI_ERREUR,"Erreur de decodage de la donnee entier(element %d)",nb_elt); - cr=CAI_ERR_ENTIER; - goto ERREUR; - } - } -/* nbelt = nbelt + 1 */ - nb_elt=nb_elt +1; - } -/* FIN SI on arrive en fin de buffer sans avoir decode la donnee */ -/* on se positionne sur le dernier caractere de la donnee */ - indice--; - } - *etat1 = CAI_ETAT12; -/* FIN SI (etat1=3) */ - } -/*---------------------------------------------------------------------------*/ -/* FIN SI */ -/*---------------------------------------------------------------------------*/ -/* l'indice est incremente */ - indice++; - } -/*---------------------------------------------------------------------------*/ -/* FIN TANT QUE non erreur et non fin decodage et indice < taille buffer */ -/*---------------------------------------------------------------------------*/ -if (indice == taille_buf) - { - cr=CAI_EOF; - } -if (*etat1 == CAI_FINDEC) - { -/* nb_col = nbelt nb_lig */ - nb_col = (nb_elt/nb_lig); -/* SI nb_lig . nb_col <> nbelt alors erreur dans le nombre d'elements d'une ligne*/ - if ( (nb_lig * nb_col) != nb_elt) - { - sprintf(CAI_ERREUR,"Nombre d'elements decodes incoherent (nb_elt:%d nb_lig:%d)",nb_elt,nb_lig); - cr=CAI_ERR_DIM; - goto ERREUR; - } - } -/*---------------------------------------------------------------------------*/ -/* nb_elt_lu = nb_elt */ -/* nb_lig_lu = dim2 */ -/* etat1 = etat1 */ -/* type_lu = type */ -/* taille_cell_lu= CAI_REEL8 ou CAI_ENTIER4 ou CAI_ASCII( taille max ) */ -/* ad_fin_dec= ad_fin ( pour lecture du prochain buffer si besoin) */ -/*---------------------------------------------------------------------------*/ -*type_lu=type; -*nb_lig_lu=nb_lig; -*nb_elt_lu=nb_elt; -*taille_cell_lu=taille_max; -*ad_fin_dec=ad_deb_do; -*nb_elt_alloc=nb_elt_alloues; -if (type == CAI_ASCII) - { - *don_lue=(void *)asc; - } -else - { - if (type == CAI_REEL8) - { - *don_lue=(void *)reel; - } - else - { - *don_lue=(void *)entier; - } - } -/*---------------------------------------------------------------------------*/ -/*CD fin de l'operation en cas nominal */ -/*---------------------------------------------------------------------------*/ -return(cr); -/*---------------------------------------------------------------------------*/ -/*CD fin de l'operation en cas d'erreur */ -/*---------------------------------------------------------------------------*/ -ERREUR: -/* affectation pour pouvoir liberer la place allouee ( par l'appelant )*/ -if (type == CAI_ASCII) - { - *don_lue=(void *)asc; - } -else - { - if (type == CAI_REEL8) - { - *don_lue=(void *)reel; - } - else - { - *don_lue=(void *)entier; - } - } -return(cr); -/*---------------------------------------------------------------------------*/ -/* FIN DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -} -/*****************************************************************************/ -/* */ -/* OPERATION: cai_analyseDA */ -/* */ -/* ROLE: Cette operation interne est un automate qui teste les caracteres */ -/* ( , ) , AUTRE , < , BLANC ou TAB ou \N */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL: */ -/* */ -/* VERSION: */ -/* CODE RETOUR : CAI_OK ou CAI_KO */ -/*****************************************************************************/ -static CAI_OK_KO cai_analyseDA(char car, CAI_EVT1 *evt1) - -{ -/*---------------------------------------------------------------------------*/ -/* DEBUT DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -/*CD si char = '(' evt1 = 0 */ -if (car == '(' ) - { - *evt1 = CAI_PAR_OUV; - } -else - { -/*CD sinon si char = ')' evt1 = 1 */ - if (car == ')' ) - { - *evt1 = CAI_PAR_FERM; - } - else - { -/*CD sinon si char = '<' evt1 = 3 */ - if (car == '<' ) - { - *evt1=CAI_INF; - } - else - { -/*CD sinon si char = BLANC ou TAB ou n evt1= 4 */ - if (car==' ' || car==' ' || car=='\n') - { - *evt1=CAI_BLANC; - } - else - { -/*CD sinon evt1 = 2 */ - *evt1=CAI_DONNEE; - } -/*CD fin si */ - } -/*CD fin si */ - } -/*CD fin si */ - } -/*CD fin si */ - return(CAI_OK); -/*---------------------------------------------------------------------------*/ -/* FIN DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -} -/*****************************************************************************/ -/* */ -/* OPERATION: cai_typeDA */ -/* */ -/* ROLE: Cette operation interne est un automate qui teste les caracteres */ -/* . , " , BLANC ou TAB ou \n ou ), CHIFFRE , SIGNE , AUTRE */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL: */ -/* */ -/* VERSION: */ -/* CODE RETOUR : CAI_OK ou CAI_KO */ -/*****************************************************************************/ -static CAI_OK_KO cai_typeDA(char car, CAI_EVT2 *evt2) - -{ -/*---------------------------------------------------------------------------*/ -/* DEBUT DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -/*CD si char = '.' evt1 = 0 */ -if (car == '.' ) - { - *evt2=CAI_POINT; - } -else - { -/*CD sinon si char = '"' evt1 = 1 */ - if (car=='"' ) - { - *evt2=CAI_GUILL; - } - else - { -/*CD sinon si char = BLANC ou TAB ou \n ou ) evt1 = 2 */ - if (car==' ' || car==' ' || car=='\n' || car==')' ) - { - *evt2=CAI_ESPACE; - } -else - { -/*CD sinon si char = CHIFFRE (isdigit) evt1= 3 */ - if ( isdigit(car) != 0) - { - *evt2=CAI_CHIFFRE; - } - else - { -/*CD sinon si char = SIGNE evt1= 4 */ - if ( car == '+' || car =='-') - { - *evt2=CAI_SIGNE; - } - else - { -/*CD sinon evt1= 5 */ - *evt2=CAI_AUTRE; - } - } -/*CD fin si */ - } -/*CD fin si */ - } -/*CD fin si */ - } -/*CD fin si */ - - return(CAI_OK); - -/*---------------------------------------------------------------------------*/ -/* FIN DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -} -/********************************************************************************/ -/* */ -/* OPERATION: cai_recherchecleDA */ -/* */ -/* ROLE: Cette operation interne recherche un mot cle dans le buffer buff. */ -/* (de taille specifiee dans CAI_FILE_DA). on retourne le mot cle, sa longueur */ -/* et l'adresse dans le tableau du caractere suivant le mot cle . */ -/* NB: attention au cas ou le mot cle est coupe on renvoie un statut */ -/* "non trouve" comme si rien n'avait pu etre detecte */ -/* */ -/* ETAT = ( DEBUT DECODAGE <=> ATTENTE < 0 */ -/* ATTENTE > 1 */ -/* FIN DECODAGE 2 | */ -/* ERREUR Syntaxe (<...<) CAI_ERR_CROCHET | status de */ -/* ERREUR Donnee non presente CAI_EOF| retour */ -/* ERREUR fin de donnee prematuree CAI_PAS_MC | */ -/* */ -/* CARACTERE = < > AUTRE FIN_FICHIER */ -/* */ -/* Etat : CARACTERE < > AUTRE FIN_FICHIER */ -/* 0 1 0 0 -1 */ -/* 1 -25 2 1 -24 */ -/* */ -/* */ -/* CONTEXTE D'APPEL: */ -/* */ -/* VERSION: */ -/* */ -/********************************************************************************/ -static CAI_OK_KO cai_recherchecleDA(long taille_buf,char *buff, - long ad_deb,char *mot_cle,long *ad_suiv) - -{ -long retour; /* code retour */ -char * indice; /* indice de parcourt du buffer */ -int nb_car; /* nombre de caracteres du mot cle */ -char *ad; /* adresse d'un caractere */ -long adr_deb_mot; /* adresse debut de mot cle */ -CAI_ETAT3 etat; /* etat de niveau 3 */ -CAI_EVT3 evt3; /* evenement de niveau 3 */ -char c; /* caractere courant traite */ -/*---------------------------------------------------------------------------*/ -/* DEBUT DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -/*CD Initialisation : On se positionne a l'adresse a partir de laquelle il */ -/*CD faut scanner le buffer */ -/*CD On recherche le premier caractere < (strchr) */ -/*------------------------------------------------------------------------------*/ - -indice =(char *) strchr ((char *)(buff+ad_deb), '<'); - -/*CD Si le code retour de strchr est NULL (< non trouve), erreur rencontree, */ -if (indice == NULL) - { - retour = CAI_EOF; - sprintf(CAI_ERREUR,"erreur: pas de mots cle a partir de l adresse %d", ad_deb); - goto ERREUR; - } - -/*------------------------------------------------------------------------------*/ -/*CD On sauvegarde l'adresse relative de debut du mot cle */ -/*------------------------------------------------------------------------------*/ -adr_deb_mot = (long)(indice - buff) + 1; - -/*------------------------------------------------------------------------------*/ -/*CD On utilise un automate pour analyser les caracteres (en les comptant) ; */ -/*CD on sort de l'analyse avec : 2 fin decodage ok */ -/*CD -1 erreur syntaxe ( < < ) */ -/*CD -3 On n'a pas assez de donnees pour */ -/*CD analyser integralement le mot cle */ -/*------------------------------------------------------------------------------*/ -etat = 0; -nb_car = 0; - -while (etat != 2 && etat != CAI_PAS_MC && etat != CAI_ERR_CROCHET) - { - ad = (char *)(indice + nb_car); - c = *ad; - nb_car = nb_car + 1; - retour =cai_mot_cleDA(c, /* [E] caractere a tester */ - &evt3); /* [S] evenement detecte */ - etat = autom3 [etat] [evt3]; - } -nb_car = nb_car -2; - -/*CD si etat erreur : envoi message */ -if (etat == CAI_PAS_MC) - { - retour = CAI_PAS_MC; - sprintf (CAI_ERREUR,"le mot cle n'est pas inclu entierement dans le buffer"); - goto ERREUR; - } -if (etat == CAI_ERR_CROCHET ) - { - retour = CAI_ERR_CROCHET; - sprintf (CAI_ERREUR,"2 crochets ouvrant < < ont ete detecte dans le mot cle"); - goto ERREUR; - } - -/*CD si mot cle trop long, erreur */ -if (nb_car > CAI_TAILLE_MAX_CLEDA) - { - retour = CAI_CLE_TROP_LONG; - sprintf (CAI_ERREUR,"le mot cle est trop long"); - goto ERREUR; - } - -/*CD si decodage ok et si le mot cle n'est pas trop long, */ -if (etat ==2 ) - { -/*CD sauvegarde du mot cle, de sa longueur, et de l'adresse du premier */ -/*CD caractere suivant le mot cle */ - memcpy (mot_cle,(indice + 1), nb_car); - *(mot_cle + nb_car) = '\0'; - *ad_suiv = adr_deb_mot + nb_car + 1; - } - -/*---------------------------------------------------------------------------*/ -/* Fin du traitement nominal */ -/*---------------------------------------------------------------------------*/ -retour = CAI_OK; -return (retour); - -/*---------------------------------------------------------------------------*/ -/* traitement degrade : */ -/*---------------------------------------------------------------------------*/ -ERREUR : -return (retour); - -/*---------------------------------------------------------------------------*/ -/* FIN DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -} -/*****************************************************************************/ -/* */ -/* OPERATION: cai_decodeautom3DA */ -/* */ -/* ROLE: Cette operation interne est un automate qui teste les caracteres */ -/* < > fin_buffer blanc (' ' '\n') autre */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL: */ -/* */ -/* VERSION: */ -/* CODE RETOUR : CAI_OK ou CAI_KO */ -/*****************************************************************************/ -static CAI_OK_KO cai_mot_cleDA(char car, CAI_EVT3 *evt3) - -{ -/*---------------------------------------------------------------------------*/ -/* DEBUT DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -/*CD si char = ' ' ou \n evt3 = ESPACE */ -/*CD si char = '<' evt3 = INFERIEUR */ -/*CD si char = '>' evt3 = SUPERIEUR */ -/*CD si char = \0 evt3 = FIN */ -/*CD sinon evt3 = AUTRES */ - -switch (car) - { - case (' ') : - *evt3 = CAI_ESPACE; - break; - case ('\n') : - *evt3 = CAI_ESPACE; - break; - - case '<' : - *evt3 = CAI_INFERIEUR; - break; - case '>' : - *evt3 = CAI_SUPERIEUR; - break; - case '\0' : - *evt3 = CAI_FIN; - break; - - default: - *evt3 = CAI_AUTRES; - break; - } -return (CAI_OK); -/*---------------------------------------------------------------------------*/ -/* FIN DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -} -/*****************************************************************************/ -/* */ -/* OPERATION: cai_ecritDA_buf */ -/* */ -/* ROLE: Cette operation ecrit une DA dans un buffer */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL: */ -/* Cette operation doit etre appelee apres ouverture prealable fichier */ -/* de Donnees Auxiliaires */ -/* */ -/* VERSION: */ -/* */ -/* CODE RETOUR : CAI_OK ou CAI_KO */ -/* si CAI_KO, l'erreur peut etre affichee via la variable globale CAI_ERREUR*/ -/* " fichier de donnees auxiliaires %s non ouvert " */ -/* " erreur de positionnement en fin de fichier " */ -/* " erreur d'ecriture dans le fichier " */ -/*****************************************************************************/ -static CAI_OK_KO cai_ecritDA_buf(CAI_FILE_DA *fd,char *mot_cle, - CAI_TYPE type,int nb_lig,int nb_col, - long taille_cell, void *donnee, - int indic_ecrit,char **da_ascii) -{ -CAI_OK_KO retour; /* code retour des fonctions */ -char don_ascii[CAI_TAILLE_MAX_LIGDA];/* buffer contenant une donnee en ascii */ -char * pt_don; /* pointeur sur don_ascii utilise pour l'ascii */ -char * pt_ascii; /* pointe sur da_ascii a l'emplacement du premier caractere libre*/ -int lig; /* indice de boucle sur les lignes */ -int col; /* indice de boucle sur les colonnes */ -char * pt_deb_lig; /* pointe sur da_ascii a l'adresse de debut de derniere ligne */ -int nb_bloc; /* nombre de blocs de CAI_TAILLE_BUFFER alloues pour da_ascii */ -long *dbentier; /* pointeur sur variable entiere double */ -float *reel; /* pointeur sur variable reelle simple precision */ -double *dbreel; /* pointeur sur variable double precision */ -long longueur; /* longueur significative d'un buffer */ -long sauv_diff_deb; /* difference d'adresse entre derniere ligne du buffer et debut du buffer */ -long sauv_diff_cour; /* difference d'adresse entre premier element libre du buffer et debut du buffer */ -char * tempo; - -/*---------------------------------------------------------------------------*/ -/* DEBUT DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -/*CD initialisation des types */ -dbentier = (long *) donnee; -reel = (float *) donnee; -dbreel = (double *) donnee; -/*------------------------------------------------------------------------------*/ -/*CD Allocation d'un espace memoire pour le buffer d'ecriture de la donnee */ -/*CD auxiliaire */ -/*CD (il faut essayer d'allouer un maximum de place representative afin */ -/*CD d'eviter un trop grand nombre de realloc) */ -/*------------------------------------------------------------------------------*/ -*da_ascii = NULL; -*da_ascii = (char *)malloc (CAI_TAILLE_BUFFER); -if (*da_ascii== NULL) - { - retour = CAI_ERR_ALLOC; - sprintf (CAI_ERREUR," erreur allocation memoire pour DA ascii "); - goto ERREUR; - } - nb_bloc = 1; - -/*------------------------------------------------------------------------------*/ -/*CD On ecrit dans le buffer, avec la syntaxe desiree le mot cle suivi d'un \n */ -/*------------------------------------------------------------------------------*/ -sprintf (*da_ascii, "<%s>\n", mot_cle); -pt_ascii = *da_ascii + strlen (*da_ascii); -pt_deb_lig = pt_ascii; - -/*------------------------------------------------------------------------------*/ -/*CD Initialisation d'une ligne de caracteres ascii, si des donnees sont */ -/*CD a ecrire */ -/*------------------------------------------------------------------------------*/ - -if ((nb_lig != 0 && nb_col != 0 ) || type == CAI_BLOC) - { - if (type == CAI_BLOC) - { - nb_lig=0; - } - else - { - *pt_deb_lig = '('; - pt_ascii = pt_ascii + 1; - } - } -/*------------------------------------------------------------------------------*/ -/*CD POUR chaque ligne des donnees */ -/*------------------------------------------------------------------------------*/ -for (lig=0; lig < nb_lig; lig++) - { - -/*------------------------------------------------------------------------------*/ -/*CD Initialisation ( pour chaque ligne */ -/*------------------------------------------------------------------------------*/ - strcpy (pt_ascii ,"( "); - pt_ascii = pt_ascii + 2; - -/*------------------------------------------------------------------------------*/ -/*CD POUR chaque colonne de donnees */ -/*------------------------------------------------------------------------------*/ - for (col=0; col < nb_col; col++) - { - -/*------------------------------------------------------------------------------*/ -/*CD Suivant le type des donnees (entier double, */ -/*CD reel simple ou double, ascii), on ecrit dans le buffer */ -/*CD DON_ASCII dans un format donne (%d, %f, %lf, %s) la donnee */ -/*CD suivie d'un blanc */ -/*------------------------------------------------------------------------------*/ - - switch (type) - { - case CAI_ENTIER4: - sprintf(don_ascii, "%d ", - *(dbentier+(nb_col*lig + col)) ); - break; - case CAI_REEL4: - sprintf(don_ascii, "%#.6g ", *(reel+(nb_col*lig + col))); - break; - case CAI_REEL8: - sprintf(don_ascii, "%#.14g ", *(dbreel+(nb_col*lig + col))); - break; - case CAI_ASCII: - pt_don = don_ascii; - sprintf(pt_don, "\""); - pt_don = pt_don + 1; - tempo=((char *)donnee+(nb_col*lig + col)*taille_cell); - longueur = strlen (tempo); - memcpy (pt_don, tempo, longueur); - pt_don = pt_don + longueur; - sprintf(pt_don,"\" \0"); - break; - default: - retour = CAI_ERREUR_ENCODE; - sprintf (CAI_ERREUR," erreur ecriture en ascii de donnee "); - goto ERREUR; - } - -/*--------------------------------------------------------------------------------------*/ -/*CD On determine la longueur significative de ce buffer DON_ASCII (sans \0) */ -/*--------------------------------------------------------------------------------------*/ - longueur = strlen (don_ascii); - -/*--------------------------------------------------------------------------------------*/ -/*CD SI cette longueur + taille significative de da_ascii + \n))\n\0 est */ -/*CD superieure a la taille allouee pour da_ascii, on se realloue */ -/*CD de la place */ -/*--------------------------------------------------------------------------------------*/ - if ( (longueur+5 + (long) pt_ascii - (long)&(**da_ascii)) > (CAI_TAILLE_BUFFER*nb_bloc) ) - { - nb_bloc = nb_bloc + 1; - - sauv_diff_deb = (long) pt_deb_lig - (long)&(**da_ascii); - sauv_diff_cour = (long) pt_ascii - (long)&(**da_ascii); - - *da_ascii = (char *)realloc (*da_ascii, (CAI_TAILLE_BUFFER*nb_bloc)); - if (*da_ascii== NULL) - { - retour = CAI_ERR_ALLOC; - sprintf (CAI_ERREUR, - " erreur re-allocation memoire pour DA ascii-bloc %d ", - nb_bloc); - goto ERREUR; - } - - pt_deb_lig = *da_ascii + sauv_diff_deb; - pt_ascii = *da_ascii + sauv_diff_cour; - } - -/*--------------------------------------------------------------------------------------------------------------*/ -/*CD SI avec cette longueur + taille de ligne est superieure a CAI_TAILLE_MAX_LIGDA caracteres */ -/*CD A l'adresse courante on ecrit \n dans le buffer da_ascii */ -/*--------------------------------------------------------------------------------------------------------------*/ - if ( (longueur + (long)pt_ascii - (long)pt_deb_lig) >= CAI_TAILLE_MAX_LIGDA) - { - *pt_ascii = '\n'; - pt_ascii = pt_ascii + 1; - pt_deb_lig = pt_ascii; - - } - -/*------------------------------------------------------------------------------*/ -/*CD On recopie les donnees significatives de DON_ASCII dans le */ -/*CD buffer da_ascii a l'adresse pointeur */ -/*------------------------------------------------------------------------------*/ - strcpy (pt_ascii, don_ascii); - pt_ascii = pt_ascii + longueur; - } /*CD FIN POUR (col) */ - -/*------------------------------------------------------------------------------*/ -/*CD Initialisation ) apres les donnees de la ligne */ -/*CD SI longueur de la ligne < CAI_TAILLE_MAX_LIGDA alors */ -/*CD on ecrit \n */ -/*CD SINON */ -/*CD on ecrit \n)\n */ -/*------------------------------------------------------------------------------*/ - if (lig != (nb_lig-1)) - { - if ((pt_ascii - pt_deb_lig + 2) < (CAI_TAILLE_MAX_LIGDA) ) - { - strcpy (pt_ascii ,")\n"); - pt_ascii = pt_ascii + 2; - pt_deb_lig = pt_ascii; - } - else - { - strcpy (pt_ascii ,"\n)\n"); - pt_ascii = pt_ascii + 3; - pt_deb_lig = pt_ascii; - } - } - else /*CD on traite le cas de la derniere ligne */ - { - if ((pt_ascii - pt_deb_lig + 3) < (CAI_TAILLE_MAX_LIGDA) ) - { - strcpy (pt_ascii ,"))\n"); - pt_ascii = pt_ascii + 3; - pt_deb_lig = pt_ascii; - } - else - { - if ((pt_ascii - pt_deb_lig + 2) < (CAI_TAILLE_MAX_LIGDA) ) - { - strcpy (pt_ascii ,")\n)\n"); - pt_ascii = pt_ascii + 4; - pt_deb_lig = pt_ascii; - } - else - { - strcpy (pt_ascii ,"\n))\n"); - pt_ascii = pt_ascii + 4; - pt_deb_lig = pt_ascii; - } - } - - } - - - -} /*CD FIN POUR (lig) */ - -/*------------------------------------------------------------------------------*/ -/*CD On ecrit \0 en fin de buffer */ -/*------------------------------------------------------------------------------*/ -*pt_ascii='\0'; - -/*------------------------------------------------------------------------------*/ -/*CD Si l'utilisateur le desire on ecrit en fin de fichier le buffer */ -/*------------------------------------------------------------------------------*/ -if (indic_ecrit == 1) - { -/*CD On se positionne a la fin du fichier de DA. */ - retour = lseek(fd->descr, 0L, SEEK_END); - if (retour == -1) - { - retour = CAI_PB_LSEEK; - sprintf(CAI_ERREUR,"Dans ajouteDA, erreur positionnement en fin de fichier"); - goto ERREUR; - } - -/*CD On ecrit le buffer dans le fichier */ - longueur = (long) strlen(*da_ascii); - write (fd->descr, *da_ascii, longueur); - - } /* fin ecriture fichier */ - -/*------------------------------------------------------------------------------*/ -/*CD re-initialisations des pointeurs de la structure CAI_FILE_DA */ -/*CD ( buffers de lecture , liste de mots cles , longueurs ...) */ -/*------------------------------------------------------------------------------*/ -if (indic_ecrit == 1) { - fd->num_buffer=-1; - fd->nb_mot_cle=-1; - if (fd->liste_mot_cle != NULL) - { - free(fd->liste_mot_cle); - fd->liste_mot_cle=NULL; - - } - if (fd->ad_mot_cle != NULL) - { - free(fd->ad_mot_cle); - fd->ad_mot_cle=NULL; - - } - if (fd->ad_donnee != NULL) - { - free(fd->ad_donnee); - fd->ad_donnee=NULL; - } - -} - - -/*---------------------------------------------------------------------------*/ -/* Fin du traitement nominal */ -/*---------------------------------------------------------------------------*/ -retour = CAI_OK; -return (retour); - -/*---------------------------------------------------------------------------*/ -/* traitement degrade : */ -/*---------------------------------------------------------------------------*/ -ERREUR : - fd->num_buffer=-1; - fd->nb_mot_cle=-1; - if (fd->liste_mot_cle != NULL) - { - free(fd->liste_mot_cle); - fd->liste_mot_cle=NULL; - - } - if (fd->ad_mot_cle != NULL) - { - free(fd->ad_mot_cle); - fd->ad_mot_cle=NULL; - - } - if (fd->ad_donnee != NULL) - { - free(fd->ad_donnee); - fd->ad_donnee=NULL; - } - -return (retour); - -/*---------------------------------------------------------------------------*/ -/* FIN DE L'OPERATION */ -/*---------------------------------------------------------------------------*/ -} -/*****************************************************************************/ -/* */ -/* OPERATION: cai_lecture_colormap */ -/* */ -/* ROLE: lecture de la colormap dans les DA */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL: */ -/* */ -/* VERSION: */ -/* */ -/* CODE RETOUR : CAI_OK ou CAI_KO */ -/* si CAI_KO, l'erreur peut etre affichee via la variable globale CAI_ERREUR*/ -/* */ -/*****************************************************************************/ - CAI_OK_KO cai_lecture_colormap(CAI_IMAGE *fdima) - -{ - CAI_MODE_OUVERTURE mode; /* mode de lecture du fichier de DA */ - char mot_cle[9]; /* mot cle associe aux donnees colormap */ - CAI_TYPE type; /* type des donnees a lire */ - int nb_lig; /* nombre de lignes du tableau a lire */ - int nb_col; /* nombre de colonnes du tableau a lire */ - long taille_cell; /* taille maxi en octets d'un element */ - /* (significatif si type = ascii) */ - CAI_OK_KO icr; /* compte-rendu de la fonction */ - CAI_FILE_DA *fd; /* Descripteur du fichier DA */ - char fic_DA[1024]; /* nom fichier de donnees auxillaires */ - - strcpy(fic_DA,fdima->NOM_IMAGE); - -/*** Ouverture du fichier de donnees auxilliaires ***/ - - mode = CAI_LECTURE; - fd=cai_openDA(fic_DA,fdima->TYPE_IMAGE,fdima->NB_CANAUX,mode); - if (fd == NULL) - { - /*--- il n'y a pas de donnees Colormap ---*/ - fdima->COLORMAP=0; - - } - else - { -/*** Recherche des caracteristiques des donnees Colormap ***/ - - strcpy(mot_cle,"COLORMAP"); - mot_cle[8]='\0'; - icr=cai_lirecaractDA(fd,mot_cle,&type,&nb_lig,&nb_col,&taille_cell); - if (icr != CAI_OK) - /*--- il n'y a pas de donnees Colormap ---*/ - fdima->COLORMAP=0; - else - { -/*** Lecture des donnees de Colormap ***/ - - fdima->TABCOLOR = (int *) malloc(sizeof(int)*768); - icr = cai_lireDA(fd,mot_cle,&type,&nb_lig,&nb_col, - &taille_cell,fdima->TABCOLOR); - if (icr == CAI_KO) - goto ERREUR; - fdima->COLORMAP = nb_col*nb_lig; - } - -/*** Fermeture du fichier de Donnees Auxilliaires ***/ - icr = cai_closeDA(fd); - } - return (CAI_OK); - -ERREUR: - return(CAI_KO); -} -/* - Fin de l'operation cai_lecture_colormap -*/ -/*****************************************************************************/ -/* */ -/* OPERATION: cai_ecriture_colormap */ -/* */ -/* ROLE: ecriture de la colormap dans les DA */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL: */ -/* */ -/* VERSION: */ -/* */ -/* CODE RETOUR : CAI_OK ou CAI_KO */ -/* si CAI_KO, l'erreur peut etre affichee via la variable globale CAI_ERREUR*/ -/* */ -/*****************************************************************************/ - CAI_OK_KO cai_ecriture_colormap(CAI_IMAGE *fdima) - - -{ - CAI_MODE_OUVERTURE mode; /* mode de lecture du fichier de DA */ - char mot_cle[13]; /* mot cle associe aux donnees colormap */ - CAI_TYPE type; /* type des donnees a ecrire */ - int nb_lig; /* nombre de lignes du tableau a ecrire */ - int nb_col; /* nombre de colonnes du tableau a ecrire */ - CAI_OK_KO icr; /* compte-rendu de la fonction */ - CAI_FILE_DA *fd; /* Descripteur du fichier DA */ - int Infos[3]; /* infos colormap pour attribution R V B */ - int taille_cell; - char fic_DA[1024]; - - strcpy(fic_DA,fdima->NOM_IMAGE); - -/*** Ouverture du fichier de donnees auxilliaires ***/ - - mode = CAI_ECRITURE; - - fd=cai_openDA(fic_DA,fdima->TYPE_IMAGE,fdima->NB_CANAUX,mode); - if (fd == NULL) - goto ERREUR; - else - { -/*** Initialisation et ecriture du champ infos colormap ***/ - - strcpy(mot_cle,"COLORMAPINFO"); - mot_cle[12]='\0'; - nb_lig=1; - nb_col=3; - type = CAI_ENTIER4; - taille_cell= sizeof (int); - Infos[0]=1; - Infos[1]=1; - Infos[2]=1; - icr = cai_ajouteDA(fd,mot_cle,type,nb_lig, - nb_col,taille_cell,Infos); - if (icr == CAI_KO) - goto ERREUR; - - -/*** Initialisation des caracteristiques des donnees Colormap ***/ - - strcpy(mot_cle,"COLORMAP"); - mot_cle[8]='\0'; - nb_lig=3; - nb_col=256; - type = CAI_ENTIER4; - taille_cell= sizeof (int); - -/*** Ecriture des donnees de Colormap ***/ - - icr = cai_ajouteDA(fd,mot_cle,type,nb_lig, - nb_col,taille_cell,fdima->TABCOLOR); - if (icr == CAI_KO) - goto ERREUR; - -/*** Fermeture du fichier de Donnees Auxilliaires ***/ - icr = cai_closeDA(fd); - } - return (CAI_OK); - -ERREUR: - return(CAI_KO); -} -/* - Fin de l'operation cai_ecriture_colormap -*/ - diff --git a/Utilities/CAI/cai_dll/src/cai_arcinfo.c b/Utilities/CAI/cai_dll/src/cai_arcinfo.c deleted file mode 100755 index 0f33a0b6eae49e2b89919c7d8f150710db66ed5f..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/src/cai_arcinfo.c +++ /dev/null @@ -1,1402 +0,0 @@ -/*****************************************************************************/ -/* */ -/* PROJET : COUCHE ACCES IMAGE */ -/* ------- */ -/* */ -/* MODULE : cai_arcinfo.c */ -/* ------- */ -/* */ -/* ROLE : Ce module rassemble toutes les fonctions d'acces aux images */ -/* ------- stockees au format arcinfo version 7.4 et superieure */ -/* */ -/* AUTEUR : R.CHAISEMARTIN (CISI) */ -/* ------- */ -/* */ -/* DATE DE CREATION : fevrier 1995 */ -/* ----------------- */ -/* */ -/* LANGAGE : C */ -/* -------- */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -/*---------------------------------------------------------------------------*/ -/* Inclusion des fichiers STANDARDS (.h) */ -/*---------------------------------------------------------------------------*/ - - -# include <stdio.h> -# include <string.h> -# include <sys/types.h> -#include <dirent.h> -# include <sys/stat.h> -# include <fcntl.h> - -#define _CAI_IMAGE -# include "cai_image.h" - - -/*----------------------------------------------------------------------------*/ -/* Variable pour la gestion en configuration */ -/*----------------------------------------------------------------------------*/ -static char *rcs_id="$Header: cai_arcinfo.c,v 1.5 00/11/29 11:02:59 cmf Exp $"; - - -extern char *getenv(); - -static void invert_oct(); - -/*****************************************************************************/ -/*****************************************************************************/ -/* */ -/* Definition des OPERATIONS EXTERNES */ -/* */ -/*****************************************************************************/ -/*****************************************************************************/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_liste_ima_arcinfo */ -/* ---------- */ -/* */ -/* ROLE : fonction de listage des images au format arcinfo */ -/* ------ */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : int cai_liste_ima_arcinfo(repert,tab_ima) */ -/* ----------------- */ -/* */ -/* repert (E) (char *) : repertoire a explorer */ -/* tab_ima (S) (char ***) : pointeur sur tableau des images listees */ -/* alloue par la fonction,il doit etre */ -/* LIBERE PAR L'APPELANT */ -/* */ -/* cai_liste_ima_arcinfo (S) (int) : = -1 repertoire inexistant */ /* = > 0 nombre d'images listees */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -int cai_liste_ima_arcinfo (repert, - tab_ima) - -char *repert; -char ***tab_ima; - -{ - DIR *dirp; /* pointeur sur structure ouverture repertoire */ - struct dirent *dp; /* structure resultat de la fonction readdir */ - char *pch0,*pch1; /* pointeurs sur chaine de caracteres */ - char *pch2,*pch3; /* pointeurs sur chaine de caracteres */ - char car; /* variable de travail */ - int nb_ima; /* nombre d'images arcinfo identifiees */ - int i; /* indice de boucle */ - - -/*........................................ - INITIALISATION et ouverture du repertoire choisi - .........................................*/ - nb_ima=0; - - dirp=opendir(repert); - - if(dirp!=NULL) - { -/*...................................... - - premiere passe pour comptabiliser les images du format donne - - - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE ARCINFO - (EXTENSION =.lan ou .gis) - ..........................................*/ - - while((dp=readdir(dirp))!=NULL) - { - - car='.'; - pch0=strrchr(dp->d_name,car); - if (pch0 != NULL) - { - car='g'; - pch1=strrchr(dp->d_name,car); - if ((pch1 != NULL)&&(pch1==pch0+1)) - { - car='i'; - pch2=strrchr(dp->d_name,car); - if ((pch2 != NULL)&&(pch2==pch1+1)) - { - car='s'; - pch3=strrchr(dp->d_name,car); - if ((pch3 != NULL)&&(pch3==pch2+1)) - { - *pch0='\0'; - *pch1=' '; - *pch2=' '; - *pch3=' '; - nb_ima=nb_ima+1; - } - } - } - else - { - car='l'; - pch1=strrchr(dp->d_name,car); - if ((pch1 != NULL)&&(pch1==pch0+1)) - { - car='a'; - pch2=strrchr(dp->d_name,car); - if ((pch2 != NULL)&&(pch2==pch1+1)) - { - car='n'; - pch3=strrchr(dp->d_name,car); - if ((pch3 != NULL)&&(pch3==pch2+1)) - { - *pch0='\0'; - *pch1=' '; - *pch2=' '; - *pch3=' '; - nb_ima=nb_ima+1; - } - } - } - } - } - } - - (void)closedir(dirp); -/*..................................... - ALLOCATION DU TABLEAU CONTENANT LA LISTE DES IMAGES DU FORMAT ARCINFO - ......................................*/ - *tab_ima = (char **) calloc(nb_ima,sizeof(char *)); - for (i=0;i<nb_ima;i=i+1) - (*tab_ima)[i]=(char *)calloc(1,100); - -/*...................................... - - deuxieme passe pour constituer la liste des images du format donne - - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE ARCINFO - (EXTENSION =.lan ou .gis) - SI C`EST LE CAS,STOCKAGE DANS LA LISTE - ..........................................*/ - dirp=opendir(repert); - - nb_ima=0; - - while((dp=readdir(dirp))!=NULL) - { - - car='.'; - pch0=strrchr(dp->d_name,car); - if (pch0 != NULL) - { - car='g'; - pch1=strrchr(dp->d_name,car); - if ((pch1 != NULL)&&(pch1==pch0+1)) - { - car='i'; - pch2=strrchr(dp->d_name,car); - if ((pch2 != NULL)&&(pch2==pch1+1)) - { - car='s'; - pch3=strrchr(dp->d_name,car); - if ((pch3 != NULL)&&(pch3==pch2+1)) - { - *pch0='\0'; - *pch1=' '; - *pch2=' '; - *pch3=' '; - strcpy((*tab_ima)[nb_ima],dp->d_name); - nb_ima=nb_ima+1; - } - } - } - else - { - car='l'; - pch1=strrchr(dp->d_name,car); - if ((pch1 != NULL)&&(pch1==pch0+1)) - { - car='a'; - pch2=strrchr(dp->d_name,car); - if ((pch2 != NULL)&&(pch2==pch1+1)) - { - car='n'; - pch3=strrchr(dp->d_name,car); - if ((pch3 != NULL)&&(pch3==pch2+1)) - { - *pch0='\0'; - *pch1=' '; - *pch2=' '; - *pch3=' '; - strcpy((*tab_ima)[nb_ima],dp->d_name); - nb_ima=nb_ima+1; - } - } - } - } - } - } - - (void)closedir(dirp); - - } - else - { - /* Erreur : Repertoire inexistant */ - nb_ima=-1; - } - - return(nb_ima); - -} -/* Fin de l'operation cai_liste_ima_arcinfo -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_lecture_arcinfo */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture d'une image au format arcinfo */ -/* ----- et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_lecture_arcinfo(nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_lecture_arcinfo (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ /* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_IMAGE *cai_ouvre_lecture_arcinfo(repert, - nom_image, - nb_can, - nboct_pix, - nb_col, - nb_lig) - -char *repert; -char *nom_image; -int *nb_can; -int *nboct_pix; -int *nb_col; -int *nb_lig; -{ - FILE *fic_in; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - int iret; /* indicateur de retour ok ou pas */ - char nom_fic[1024]; /* nom du fichier en-tete */ - short ncan; /* nombre de canaux dans le fichier en-tete */ - char *deb,*deb1; /* pointeurs sur chaine de caracteres */ - char car[5]; /* indice du canal traite */ - char entete[6]; /* HEADER ou HEAD74 lu dans l'entete */ - int i,num; /* indices */ - short ipack; /* variables de travail */ - int lg,col; /* variables de travail */ - - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - *nb_can=0; - - *nb_lig=0; - - *nb_col=0; - - *nboct_pix=0; - - iret=1; - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); -/*................................................. - Constituion du nom du fichier entete - .................................................*/ - nom_fic[0]='\0'; - if (strlen(repert)!= 0) - { - sscanf(repert,"%s",nom_fic); - strcat(nom_fic,"/"); - strcat(nom_fic,nom_image); - strcat(nom_fic,".lan"); - nom_fic[strlen(repert)+1+strlen(nom_image)+4]='\0'; - } - else - { - sscanf(nom_image,"%s",nom_fic); - strcat(nom_fic,".lan"); - nom_fic[strlen(nom_image)+4]='\0'; - } - -/*........................ - Ouverture du fichier entete avec l'extension .lan - ..........................................*/ - fic_in=fopen(nom_fic,"r"); - if (fic_in==NULL) - { -/*...................................................... - Test sur l'existence du fichier avec l'extension .gis - .......................................................*/ - - strncpy(&nom_fic[strlen(nom_fic)-4],".gis",4); - - fic_in = fopen(nom_fic,"r"); - if (fic_in == NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur ouverture fichier entete ARCINFO"); - } - } - if (iret!=0) - { - - - /*------------------------------------------- - Verification de l'entete - -------------------------------------------*/ - fread(entete,6,1,fic_in); - if (strncmp(entete,"HEAD74",6)!=0) - { - iret = 0; - strcpy(CAI_ERREUR,"Version autre que 7.4 non traitee"); - goto ERREUR; - } - - - - /*------------------------------------------- - recuperation du nombre d'octets par pixel - -------------------------------------------*/ - fread(&ipack,2,1,fic_in); - lg=sizeof(ipack)-1; - invert_oct(&ipack,lg); - if (ipack == 0) - *nboct_pix = 1; - else if (ipack == 2) - *nboct_pix = 2; - else - { - iret = 0; - strcpy(CAI_ERREUR,"Erreur : les donnees image doivent etre codees sur 8 ou 16 octets"); - goto ERREUR; - - } - - /*------------------------------------------- - recuperation du nombre de canaux - -------------------------------------------*/ - fread(&ncan,2,1,fic_in); - lg=sizeof(ncan)-1; - invert_oct(&ncan,lg); - *nb_can = (int) ncan; - - /*------------------------------------------- - positionnement sur le nombre de colonnes - -------------------------------------------*/ - fseek(fic_in,6,1); - - /*------------------------------------------- - recuperation du nombre de colonnes - -------------------------------------------*/ - fread(nb_col,4,1,fic_in); - lg = sizeof(*nb_col)-1; - invert_oct(nb_col,lg); - col=*nb_col; - - /*------------------------------------------- - recuperation du nombre de lignes - -------------------------------------------*/ - fread(nb_lig,4,1,fic_in); - lg = sizeof(*nb_lig)-1; - invert_oct(nb_lig,lg); - - /*------------------------------------------- - Fermeture du fichier - -------------------------------------------*/ - fclose(fic_in); - } - if (iret !=0) - { -/*....................................... - INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL - .....................................................*/ - if (*nb_can == 1) - strcpy(car,".gis"); - else - strcpy(car,".lan"); - - deb = image1->NOM_FIC_CAN; - deb1= image1->NOM_UTIL_CAN; - - for (i=0;i<*nb_can;i=i+1) - { - num=open(nom_fic,O_RDONLY,0); - if (num!= -1) - { - sscanf(nom_image,"%s",deb); - strcat(deb,car); - deb=deb+100; - sscanf(nom_image,"%s",deb1); - strcat(deb1,car); - deb1=deb1+100; - image1->ACCES_CANAL_INT[i]=num; - image1->POS_OCTET[i]=128+(i*col*(*nboct_pix)); - } - - } - } - - if (iret == 0) - { - return (NULL); - } - else - { - image1->NB_BITS_PIX=*nboct_pix; - return(image1); - } -ERREUR: - - return (NULL); - -} -/* - Fin de l'operation cai_ouvre_lecture_arcinfo -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_creation_arcinfo */ -/* ---------- */ -/* */ -/* ROLE : fonction de creation et d'ouverture en ecriture d'une image */ -/* ----- au format arcinfo et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_creation_arcinfo(nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig, */ -/* label) */ -/* */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* nb_can (E) (int ) : nombre de canaux de l'image */ -/* nboct_pix (E) (int ) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (E) (int ) : nombre de lignes de l'image */ -/* nb_col (E) (int ) : nombre de colonnes de l'image */ -/* label (E) (char *) : commentaire lie a l'image */ -/* */ -/* cai_ouvre_creation_arcinfo (S) (CAI_IMAGE *) : =NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_IMAGE *cai_ouvre_creation_arcinfo(repert, - nom_image, - nb_can, - nboct_pix, - nb_col, - nb_lig, - label) - -char *repert; -char *nom_image; -int *nb_can; -int *nboct_pix; -int *nb_col; -int *nb_lig; -char *label; -{ - FILE *fic; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - char nom_fic[1024]; /* nom du fichier en-tete */ - int retour; /* retour de fonction */ - int i,num; /* indice */ - struct stat buf_stat; /* structure decrivant status de fichier */ - - short ipack; /* indicateur de pack type des donnees */ - short short_tempo; /* short utilise pour inversion d'octets */ - int int_tempo; /* entier utilise pour inversion d'octets */ - int lg; /* longueur de l'entier - 1 */ - int taille; /* longueur de l'entete a ecrire */ - unsigned char *buff; /* permet d'ecrire l'entete fichier arcinfo */ - - - - - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); - ipack = 0; - -/*................................................. - Constitution du nom du fichier et verification qu'il - n'existe pas deja - pour un canal ,l'extension est .gis, sinon .lan - .................................................*/ - nom_fic[0]='\0'; - if (strlen(repert)!= 0) - { - sscanf(repert,"%s",nom_fic); - strcat(nom_fic,"/"); - strcat(nom_fic,nom_image); - if (*nb_can == 1) - strcat(nom_fic,".gis"); - else - strcat(nom_fic,".lan"); - nom_fic[strlen(repert)+1+strlen(nom_image)+4]='\0'; - } - else - { - sscanf(nom_image,"%s",nom_fic); - if (*nb_can == 1) - strcat(nom_fic,".gis"); - else - strcat(nom_fic,".lan"); - nom_fic[strlen(nom_image)+4]='\0'; - } - - - retour = stat ( nom_fic , &buf_stat ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "L'image %s ARCINFO existe \n" , nom_image ); - goto ERREUR; - } - - -/*...................................................... - Ouverture du fichier en ecriture - Ecriture de l'entete - ..........................................................*/ - fic = fopen(nom_fic,"w"); - if (fic == NULL) - { - sprintf(CAI_ERREUR,"Erreur: Creation fichier %s impossible\n",nom_fic); - goto ERREUR; - } - taille=128 + (*nb_can)*(*nb_col)*(*nboct_pix)*(*nb_lig) ; - - buff = (unsigned char *) malloc(taille); - if ( fic == NULL ) - { - strcpy ( CAI_ERREUR , "Erreur : probleme d'allocation \n" ); - unlink(nom_fic); - goto ERREUR; - } - - memcpy ( buff , "HEAD74" , 6 ); - if ( *nboct_pix == 1 ) - ipack = 0; - else if ( *nboct_pix == 2 ) - ipack = 2; - memcpy ( &buff[6] , &ipack , 2 ); - - short_tempo = (short) (*nb_can); - lg = sizeof(short_tempo)-1; - invert_oct(&short_tempo,lg); - memcpy ( &buff[8] , &short_tempo , 2 ); - - for ( i = 10 ; i < 16 ; i++ ) - { - buff[i] = 0; - } - - int_tempo = *nb_col; - lg = sizeof(int_tempo)-1; - invert_oct(&int_tempo,lg); - memcpy ( &buff[16] , &int_tempo , 4 ); - - int_tempo = *nb_lig; - lg = sizeof(int_tempo)-1; - invert_oct(&int_tempo,lg); - memcpy ( &buff[20] , &int_tempo , 4 ); - - for ( i=24 ; i<taille ; i++ ) - { - buff[i] = 0; - } - - retour = fwrite ( buff , taille ,1 , fic); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "Erreur : ecriture impossible dans fichier %s\n" ,nom_fic ); - unlink(nom_fic); - goto ERREUR; - } - - free (buff ); - fclose(fic); - -/*........................................... - Ouverture du fichier pour ecriture radiometrie - ...............................................*/ - num = open(nom_fic,O_RDWR,0); - if (num == -1) - { - sprintf(CAI_ERREUR,"Erreur: Creation %s impossible\n",nom_fic); - goto ERREUR; - } - for (i=0;i<*nb_can;i=i+1) - { - image1->ACCES_CANAL_INT[i]=num; - image1->POS_OCTET[i]=128; - } - - return (image1); - -ERREUR : - return(NULL); -} - -/* - Fin de l'operation cai_ouvre_creation_arcinfo -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_lecture_canal_arcinfo */ -/* ---------- */ -/* */ -/* ROLE : fonction de lecture d'un canal d'une image Arcinfo */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_lecture_canal_arcinfo(image1, canal, */ /* ------------------ premiere_ligne, */ -/* premiere_colonne, */ -/* nombre_lignes_lire , */ -/* nombre_colonnes_lire, */ -/* pas_ligne ,pas_colonne, */ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a lire */ -/* premiere_ligne (E) (int) : premiere ligne a lire dans l'image */ -/* premiere _colonne (E) (int) : premiere colonne a lire dans l'image */ -/* nombre_lignes_lire (E) (int) : nombre de lignes a lire */ -/* nombre_colonnes_lire (E) (int) : nombre de colonnes a lire */ -/* pas_ligne (E) (int) : pas en ligne */ -/* pas_colonne (E) (int) : pas en colonne */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels lus alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_lecture_canal_arcinfo (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_OK_KO cai_lecture_canal_arcinfo(image1 , - canal , - premiere_ligne , - premiere_colonne, - nombre_lignes_lire , - nombre_colonnes_lire, - pas_ligne , - pas_colonne, - data_image ) -CAI_IMAGE *image1; -int *canal ; -int *premiere_ligne ; -int *premiere_colonne ; -int *nombre_lignes_lire ; -int *nombre_colonnes_lire; -int *pas_ligne ; -int *pas_colonne; -unsigned char *data_image; - -{ - - int num,i,j,k,n; /* variables de travail */ - int pt_oct; /* position courante dans le fichier image */ - int no_oct; /* numero du premier octet a lire */ - int iret; /* indicateur d'erreur */ - int lig; /* indice de boucle sur les lignes */ - int oct_pix; /* nb octets par pixels */ - long nb_oct; /* nb oct =1er octet a lire - position courante */ - long oct_lig; /* nb oct. par ligne en considerant taille pixel */ - unsigned char *buf_lec; /* buffer lecture d'une ligne */ - unsigned char *deb,*pch; /* pointeur chaine pour transfert buffer sortie */ - - -/*........................... - Initialisations diverses - ..........................*/ - iret=CAI_OK; - num=image1->ACCES_CANAL_INT[*canal-1]; - oct_pix=image1->NBOCT_PIX; - oct_lig=oct_pix*image1->NB_COL; - -/*.............................................. - allocation de memoire pour lire une ligne image - ............................................. */ - - buf_lec = (unsigned char *) malloc(oct_lig); - if (buf_lec == NULL) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Probleme allocation memoire"); - } - else - { -/*.................... - Initialisation - ......................*/ - lig=*premiere_ligne; - i=1; - pch=data_image; - -/*..................... - Pour chaque ligne a lire - .......................................*/ - while ((i <= *nombre_lignes_lire)&&(iret==CAI_OK)) - { -/*............................................ - Recherche de la position courante dans le fichier - ............................................*/ - pt_oct=lseek(num,0L,1); - -/*................................ - Calcul du numero du 1er octet a lire - ....................................*/ - - no_oct=image1->POS_OCTET[*canal-1]+ - (lig-1)*image1->NB_COL*oct_pix*image1->NB_CANAUX; - - -/*.................................. - Saut d'octets pour etre positionne sur la ligne a lire - .......................................*/ - nb_oct=(long)(no_oct-pt_oct); - lseek(num,nb_oct,1); - -/*........................................... - lecture d'une ligne image - ................................................*/ - n=read(num,buf_lec,oct_lig); - - if (n<=0) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Erreur lecture donnee image ARCINFO"); - } - else - { -/*...................................... - Sauvegarde des donnees lues entenant compte du pas - d'echantillonnage en colonne - ........................................*/ - deb=buf_lec+(*premiere_colonne-1)*oct_pix; - j=1; - while (j <= *nombre_colonnes_lire) - { - for (k=0;k<oct_pix;k=k+1) - { - *(pch+k)=*(deb+k); - } - j=j+1; - pch=pch+oct_pix; - deb=deb+(*pas_colonne*oct_pix); - } - - } - i=i+1; - lig=lig+(*pas_ligne); - - } - - free(buf_lec); - } - return(iret); -} -/* - Fin de l'operation cai_lecture_canal_arcinfo -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ecriture_canal_arcinfo */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ecriture d'un canal d'une image arcinfo */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ecriture_canal_arcinfo(image1, canal, */ /* ------------------ premiere_ligne, */ -/* nombre_lignes_ecrire, */ -/* nombre_colonnes_ecrire,*/ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a ecrire */ -/* premiere_ligne (E) (int) : premiere ligne a ecrire ds l'image */ -/* nombre_lignes_ecrire (E) (int) : nombre de lignes a ecrire */ -/* nombre_colonnes_ecrire(E) (int) : nombre de lignes a ecrire */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels ecris alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_ecriture_canal_arcinfo (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_OK_KO cai_ecriture_canal_arcinfo (image1 , - canal , - premiere_ligne , - nombre_lignes_ecrire , - nombre_colonnes_ecrire, - data_image ) -CAI_IMAGE *image1; -int *canal ; -int *premiere_ligne ; -int *nombre_lignes_ecrire ; -int *nombre_colonnes_ecrire; -unsigned char *data_image; - -{ -long position_first_lig; /* position de la 1ere ligne a ecrire */ -long position_courante; /* position courante dans le fichier */ -long deplacement; /* deplacement a effectuer */ -int i_ligne; /* compteur de lignes */ -unsigned char *buff_lig; /* tableau contenant une ligne a ecrire */ -int cr_write; /* code retour de write */ -int num; /* descripteur de fichier */ -int nboct_pix; /* nombre d'octets par pixel */ -int nb_canaux; /* nombre de canaux de l'image totale */ - -/* ................ - Initialisations - .................*/ - -i_ligne = 0; -num = image1->ACCES_CANAL_INT[*canal-1]; -nboct_pix = image1->NBOCT_PIX; -nb_canaux = image1->NB_CANAUX; -position_first_lig = 0; -position_courante = 0; -deplacement = 0; - -/********************************************************/ -/* Calcul de la position de la premiere ligne a ecrire */ -/********************************************************/ - -position_first_lig = (long) ( image1->POS_OCTET[*canal-1] + - ((*canal) - 1) * (*nombre_colonnes_ecrire) * nboct_pix - + (*premiere_ligne - 1) * (*nombre_colonnes_ecrire) * nboct_pix * nb_canaux ); - - -/********************************************************/ -/* Recuperation de la position courante */ -/********************************************************/ - -position_courante = lseek ( num , 0L , 1 ); - - -/********************************************************/ -/* Calcul du deplacement jusqu'a la 1ere ligne a ecrire */ -/********************************************************/ - -deplacement = position_first_lig - position_courante; - - -/********************************************************/ -/* TANT QUE il y a des lignes a ecrire */ -/********************************************************/ -while (i_ligne < (*nombre_lignes_ecrire)) -{ - -/********************************************************/ -/* extraction de la ligne du tableau */ -/********************************************************/ - - buff_lig = data_image + (*nombre_colonnes_ecrire) * nboct_pix * i_ligne; - -/********************************************************/ -/* deplacement jusqu'a la ligne a ecrire */ -/********************************************************/ - - lseek ( num , deplacement , 1 ); - -/********************************************************/ -/* ecriture de la ligne */ -/********************************************************/ - - cr_write = write ( num , buff_lig , (*nombre_colonnes_ecrire)*nboct_pix ); - if ( cr_write != (*nombre_colonnes_ecrire)*nboct_pix ) - { - strcpy ( CAI_ERREUR , "Erreur ecriture canal image arcinfo\n" ); - goto ERREUR; - } - -/********************************************************/ -/* mise a jour du deplacement jusqu'a la ligne */ -/* suivante */ -/********************************************************/ - - deplacement = ( nb_canaux - 1 ) * (*nombre_colonnes_ecrire)*nboct_pix; - -/********************************************************/ -/* incrementation du nombre de lignes */ -/********************************************************/ - - i_ligne++; - -/********************************************************/ -/* FIN TANT QUE */ -/********************************************************/ -} - - -return (CAI_OK); - -ERREUR : - -return (CAI_KO); - - -} -/* - Fin de l'operation cai_ecriture_canal_arcinfo -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ferme_arcinfo */ -/* ---------- */ -/* */ -/* ROLE : fonction de fermeture d'une image au format arcinfo et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ferme_arcinfo(image1) */ /* ------------------ */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* */ -/* cai_ferme_arcinfo (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_OK_KO cai_ferme_arcinfo (image1) - -CAI_IMAGE *image1; - -{ - - int iret; /* code retour de l'operation */ - int i_can; /* indice du canal a fermer */ - int num; /* descripteur du fichier a fermer */ - - iret=CAI_OK; -/*............................................. - Fermeture du fichier qui contient tous les canaux - .............................................*/ - num=image1->ACCES_CANAL_INT[0]; - close(num); - - - return (iret); -} - -/* - Fin de l'operation cai_ferme_arcinfo -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_dest_ima_arcinfo */ -/* ---------- */ -/* */ -/* ROLE : fonction de destruction d'une image stocke en arcinfo et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_dest_ima_arcinfo(format,nom_ima) */ /* ------------------ */ -/* format (E) (char *) : format de l'image a detruire */ -/* nom_image (E) (char *) : nom de l'image a detruire avec repertoire */ -/* */ -/* cai_dest_ima_arcinfo (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - - -CAI_OK_KO cai_dest_ima_arcinfo ( repertoire , - nom_ima ) - -char *repertoire; /* repertoire de stockage de l'image */ -char *nom_ima; /* nom de l'image */ - -{ -char nom_fic_ima[1024]; /* nom du fichier entete a detruire */ -char nom_ima_complet[1024]; /* repertoire + nom de l'image */ -int cr_stat; /* code retour de fonction status de fichier */ -struct stat buf_stat; /* structure decrivant status de fichier */ - - -/************************************************/ -/* Constitution du nom du fichier */ -/************************************************/ -if (strlen(repertoire) != 0) -{ - strcpy ( nom_ima_complet , repertoire ); - strcat ( nom_ima_complet, "/" ); - strcat ( nom_ima_complet , nom_ima ); -} -else -{ - strcpy ( nom_ima_complet , nom_ima ); -} - strcpy(nom_fic_ima , nom_ima_complet); - strcat ( nom_fic_ima , ".gis" ); - nom_fic_ima[strlen(nom_ima_complet)+4]='\0'; - -/* le nombre de canaux etant inconnu, on construit */ -/* d'abord le nom d'un fichier image avec un seul */ -/* canal et on teste son existence; si un tel */ -/* fichier n'existe pas, on construit le nom d'un */ -/* fichier image avec plusieurs canaux */ - -cr_stat = stat ( nom_fic_ima , &buf_stat ); -if ( cr_stat != 0 ) -{ - strncpy ( &nom_fic_ima[strlen(nom_fic_ima)-4] , ".lan" , 4 ); - cr_stat = stat ( nom_fic_ima , &buf_stat ); - if ( cr_stat == 0 ) - unlink ( nom_fic_ima ); -} -else -{ - unlink ( nom_fic_ima ); -} - - -return (CAI_OK); - -} -/* - Fin de l'operation cai_dest_ima_arcinfo -*/ - -/*****************************************************************************/ -/*****************************************************************************/ -/* */ -/* Definition des OPERATIONS INTERNES */ -/* */ -/*****************************************************************************/ -/*****************************************************************************/ - -/*****************************************************************************/ -/* */ -/* OPERATION : invert_oct */ -/* ---------- */ -/* */ -/* ROLE : Inversion des octets poids forts,poids faibles */ -/* ------ */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : void invert_oct(s,nboct) */ -/* ----------------- */ -/* */ -/* s (E/S) (char *) : chaine a inverser */ -/* nboct (E) (int) : longueur de la chaine */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -static void invert_oct ( s , nboct ) -char *s; -int nboct; -{ - int c; - char *t; - - for ( t=s+nboct ; s<t ; s++,t-- ) - { - c=*s; - *s=*t; - *t=c; - } -} -/* Fin de l'operation invert_oct */ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_modifie_arcinfo */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture d'une image au format arcinfo */ -/* ----- et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_modifie_arcinfo(nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_modifie_arcinfo (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ /* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_IMAGE *cai_ouvre_modifie_arcinfo(repert, - nom_image, - nb_can, - nboct_pix, - nb_col, - nb_lig) - -char *repert; -char *nom_image; -int *nb_can; -int *nboct_pix; -int *nb_col; -int *nb_lig; -{ - FILE *fic_in; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - int iret; /* indicateur de retour ok ou pas */ - char nom_fic[1024]; /* nom du fichier en-tete */ - short ncan; /* nombre de canaux dans le fichier en-tete */ - char *deb,*deb1; /* pointeurs sur chaine de caracteres */ - char car[5]; /* indice du canal traite */ - char entete[6]; /* HEADER ou HEAD74 lu dans l'entete */ - int i,num; /* indices */ - short ipack; /* variables de travail */ - int lg,col; /* variables de travail */ - - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - *nb_can=0; - - *nb_lig=0; - - *nb_col=0; - - *nboct_pix=0; - - iret=1; - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); -/*................................................. - Constituion du nom du fichier entete - .................................................*/ - nom_fic[0]='\0'; - if (strlen(repert)!= 0) - { - sscanf(repert,"%s",nom_fic); - strcat(nom_fic,"/"); - strcat(nom_fic,nom_image); - strcat(nom_fic,".lan"); - nom_fic[strlen(repert)+1+strlen(nom_image)+4]='\0'; - } - else - { - sscanf(nom_image,"%s",nom_fic); - strcat(nom_fic,".lan"); - nom_fic[strlen(nom_image)+4]='\0'; - } - -/*........................ - Ouverture du fichier entete avec l'extension .lan - ..........................................*/ - fic_in=fopen(nom_fic,"r"); - if (fic_in==NULL) - { -/*...................................................... - Test sur l'existence du fichier avec l'extension .gis - .......................................................*/ - - strncpy(&nom_fic[strlen(nom_fic)-4],".gis",4); - - fic_in = fopen(nom_fic,"r"); - if (fic_in == NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur ouverture fichier entete ARCINFO"); - } - } - if (iret!=0) - { - - - /*------------------------------------------- - Verification de l'entete - -------------------------------------------*/ - fread(entete,6,1,fic_in); - if (strncmp(entete,"HEAD74",6)!=0) - { - iret = 0; - strcpy(CAI_ERREUR,"Version autre que 7.4 non traitee"); - goto ERREUR; - } - - - - /*------------------------------------------- - recuperation du nombre d'octets par pixel - -------------------------------------------*/ - fread(&ipack,2,1,fic_in); - lg=sizeof(ipack)-1; - invert_oct(&ipack,lg); - if (ipack == 0) - *nboct_pix = 1; - else if (ipack == 2) - *nboct_pix = 2; - else - { - iret = 0; - strcpy(CAI_ERREUR, - "Erreur : les donnees image doivent etre codees sur 8 ou 16 octets"); - goto ERREUR; - - } - - /*------------------------------------------- - recuperation du nombre de canaux - -------------------------------------------*/ - fread(&ncan,2,1,fic_in); - lg=sizeof(ncan)-1; - invert_oct(&ncan,lg); - *nb_can = (int) ncan; - - /*------------------------------------------- - positionnement sur le nombre de colonnes - -------------------------------------------*/ - fseek(fic_in,6,1); - - /*------------------------------------------- - recuperation du nombre de colonnes - -------------------------------------------*/ - fread(nb_col,4,1,fic_in); - lg = sizeof(*nb_col)-1; - invert_oct(nb_col,lg); - col=*nb_col; - - /*------------------------------------------- - recuperation du nombre de lignes - -------------------------------------------*/ - fread(nb_lig,4,1,fic_in); - lg = sizeof(*nb_lig)-1; - invert_oct(nb_lig,lg); - - /*------------------------------------------- - Fermeture du fichier - -------------------------------------------*/ - fclose(fic_in); - } - if (iret !=0) - { -/*....................................... - INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL - .....................................................*/ - if (*nb_can == 1) - strcpy(car,".gis"); - else - strcpy(car,".lan"); - - deb = image1->NOM_FIC_CAN; - deb1= image1->NOM_UTIL_CAN; - - for (i=0;i<*nb_can;i=i+1) - { - num=open(nom_fic,O_RDWR,0); - if (num!= -1) - { - sscanf(nom_image,"%s",deb); - strcat(deb,car); - deb=deb+100; - sscanf(nom_image,"%s",deb1); - strcat(deb1,car); - deb1=deb1+100; - image1->ACCES_CANAL_INT[i]=num; - image1->POS_OCTET[i]=128+(i*col*(*nboct_pix)); - } - - } - } - - if (iret == 0) - { - return (NULL); - } - else - { - image1->NB_BITS_PIX=*nboct_pix; - return(image1); - } -ERREUR: - - return (NULL); - -} -/* - Fin de l'operation cai_ouvre_modifie_arcinfo -*/ diff --git a/Utilities/CAI/cai_dll/src/cai_atg2.c b/Utilities/CAI/cai_dll/src/cai_atg2.c deleted file mode 100755 index f73661a1b307daa34c10e39633fe2e06137ad7cb..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/src/cai_atg2.c +++ /dev/null @@ -1,2170 +0,0 @@ -/*****************************************************************************/ -/* */ -/* PROJET : COUCHE ACCES IMAGE */ -/* ------- */ -/* */ -/* MODULE : cai_atg2.c */ -/* ------- */ -/* */ -/* ROLE : Ce module rassemble toutes les fonctions d'acces aux images */ -/* ------- stockees au format atg2 */ -/* */ -/* AUTEUR : R.CHAISEMARTIN (CISI) */ -/* ------- */ -/* */ -/* DATE DE CREATION : fevrier 1995 */ -/* ----------------- */ -/* */ -/* LANGAGE : C */ -/* -------- */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -/*---------------------------------------------------------------------------*/ -/* Inclusion des fichiers STANDARDS (.h) */ -/*---------------------------------------------------------------------------*/ - - -# include <stdio.h> -# include <string.h> -# include <sys/types.h> -#include <dirent.h> -# include <sys/stat.h> -# include <fcntl.h> - -#define _CAI_IMAGE -# include "cai_image.h" - -/*----------------------------------------------------------------------------*/ -/* Variable pour la gestion en configuration */ -/*----------------------------------------------------------------------------*/ -static char *rcs_id="$Header: cai_atg2.c,v 1.5 98/10/19 10:29:06 cmf Exp $"; - - -extern char *getenv(); - -/*****************************************************************************/ -/*****************************************************************************/ -/* */ -/* Definition des OPERATIONS EXTERNES */ -/* */ -/*****************************************************************************/ -/*****************************************************************************/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_liste_ima_atg2 */ -/* ---------- */ -/* */ -/* ROLE : fonction de listage des images au format atg2 */ -/* ------ */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : int cai_liste_ima_atg2(repert,tab_ima) */ -/* ----------------- */ -/* */ -/* repert (E) (char *) : repertoire a explorer */ -/* tab_ima (S) (char ***) : pointeur sur tableau des images listees*/ -/* alloue par la fonction,il doit etre */ -/* LIBERE PAR L'APPELANT */ -/* */ -/* cai_liste_ima_atg2 (S) (int) : = -1 repertoire inexistant */ /* = > 0 nombre d'images listees */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -int cai_liste_ima_atg2(repert, - tab_ima) - -char *repert; -char ***tab_ima; - -{ - DIR *dirp; /* pointeur sur structure ouverture repertoire */ - -struct dirent *dp; /* structure resultat de la fonction readdir */ -struct dirent *cr_readdir; /* structure resultat de la fonction readdir */ - - int nb_ima; /* nombre d'images atg2 identifiees */ - DIR *ptr_sub_dir; /* pointeur sur struct. ouverture repert. ima */ - char *str_sub_dir; /* repertoire image atg2 a ouvrir */ - int cr_stat; /* compte-rendu de la fonction stat */ - struct stat buf_stat; /* structure retour de la fonction stat */ - - int i; /* indice de boucle */ - - - - -/*........................................ - INITIALISATION et ouverture du repertoire choisi - .........................................*/ - nb_ima=0; - dirp=opendir(repert); - - if(dirp!=NULL) - { - -/*...................................... - premiere passe pour comptabiliser les images du format donne - - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UN REPERTOIRE - SI C'EST LE CAS : - OUVERTURE DU REPERTOIRE - VERIFICATION QU'IL CONTIENT UN FICHIER D'EXTENSION .gen - ..........................................*/ - - while((dp=readdir(dirp))!=NULL) - { - - /* ne se traite pas lui-meme ni le repertoire pere */ - if ((strcmp(dp->d_name,".")==0) || (strcmp(dp->d_name,"..")==0)) - continue; - - /* construction du nom complet de l'objet */ - str_sub_dir = (char *) malloc(strlen(repert)+1+strlen(dp->d_name)+1); - if (str_sub_dir == NULL) - { - /* Erreur : probleme d'allocation memoire */ - nb_ima=-3; - return(nb_ima); - } - - strcpy(str_sub_dir,repert); - strcat(str_sub_dir,"/"); - strcat(str_sub_dir,dp->d_name); - str_sub_dir[strlen(repert)+1+strlen(dp->d_name)]='\0'; - - /* on verifie que l'objet est un repertoire */ - cr_stat = stat(str_sub_dir,&buf_stat); - - if ((cr_stat == -1) || ((buf_stat.st_mode & S_IFMT) != S_IFDIR)) - { - - /* acces impossible a l'objet ou l'objet n'est pas un repertoire */ - free(str_sub_dir); - continue; - } - - /* on verifie que l'objet est un repertoire ATG2 */ - /* c'est a dire contenant un fichier ".gen" */ - - ptr_sub_dir = opendir(str_sub_dir); - if(ptr_sub_dir!=NULL) - { - while ((cr_readdir=readdir(ptr_sub_dir)) != NULL) - { - - if (strcmp(".gen",cr_readdir->d_name) == 0) - { - /* c'est un repertoire ATG2 */ - nb_ima=nb_ima+1; - } - } - closedir(ptr_sub_dir); - } - else - { - - /* acces impossible a l'objet */ - free(str_sub_dir); - continue; - - } - - free(str_sub_dir); - } - closedir(dirp); - -/*..................................... - ALLOCATION DU TABLEAU CONTENANT LA LISTE DES IMAGES DU FORMAT ATG2 - ......................................*/ - *tab_ima = (char **) calloc(nb_ima,sizeof(char *)); - for (i=0;i<nb_ima;i=i+1) - (*tab_ima)[i]=(char *)calloc(1,100); - -/*...................................... - - deuxieme passe pour constituer la liste des images du format donne - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UN REPERTOIRE - SI C'EST LE CAS : - OUVERTURE DU REPERTOIRE - VERIFICATION QU'IL CONTIENT UN FICHIER D'EXTENSION .gen - SI C'EST LE CAS STOCKAGE DE L'IMAGE DANS LA LISTE DES IMAGES ATG2 - ..........................................*/ - dirp=opendir(repert); - - nb_ima=0; - while((dp=readdir(dirp))!=NULL) - { - /* ne se traite pas lui-meme ni le repertoire pere */ - if ((strcmp(dp->d_name,".")==0) || (strcmp(dp->d_name,"..")==0)) - continue; - - /* construction du nom complet de l'objet */ - str_sub_dir = (char *) malloc(strlen(repert)+1+strlen(dp->d_name)+1); - if (str_sub_dir == NULL) - { - /* Erreur : probleme d'allocation memoire */ - nb_ima=-3; - return(nb_ima); - } - - strcpy(str_sub_dir,repert); - strcat(str_sub_dir,"/"); - strcat(str_sub_dir,dp->d_name); - str_sub_dir[strlen(repert)+1+strlen(dp->d_name)]='\0'; - - /* on verifie que l'objet est un repertoire */ - cr_stat = stat(str_sub_dir,&buf_stat); - if ((cr_stat == -1) || ((buf_stat.st_mode & S_IFMT) != S_IFDIR)) - { - - /* acces impossible a l'objet ou l'objet n'est pas un repertoire */ - free(str_sub_dir); - continue; - } - - /* on verifie que l'objet est un repertoire ATG2 */ - /* c'est a dire contenant un fichier ".gen" */ - - ptr_sub_dir = opendir(str_sub_dir); - if(ptr_sub_dir!=NULL) - { - while ((cr_readdir=readdir(ptr_sub_dir)) != NULL) - { - if (strcmp(".gen",cr_readdir->d_name) == 0) - { - /* c'est un repertoire ATG2 */ - strcpy((*tab_ima)[nb_ima],dp->d_name); - nb_ima=nb_ima+1; - } - } - closedir(ptr_sub_dir); - - } - else - { - - /* acces impossible a l'objet */ - free(str_sub_dir); - continue; - - } - - free(str_sub_dir); - } - closedir(dirp); - - } - else - { - /* Erreur : Repertoire inexistant */ - nb_ima=-1; - } - - return(nb_ima); - -} -/* Fin de l'operation cai_liste_ima_atg2 -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_lecture_atg2 */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture d'une image au format atg2 */ -/* ----- et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_lecture_atg2(nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_lecture_atg2 (S) (CAI_IMAGE *) : =NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ /* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -typedef struct { - char rty[80]; - char rid[80]; - char prt[8]; - char nam[80]; - int str; - double lod; - double lad; - char uniloa[8]; - char mbu[8]; - int cov; - int fec; - int poc; - int lic; - int alc; - int sgc; - int zna; - double psp; - char imr[4]; - int arv; - int brv; - double lso; - double pso; - char txt[80]; - int nul; - int nus; - int nll; - int nls; - int nfl; - int nfc; - int pnc; - int pnl; - int cod; - int rod; - int por; - int pcb; - int pvb; - char bad[80]; - char tif[2]; - char fmt[8]; - char pty[2]; - int ofs; - double mpl; - double mpc; - int rol[100]; - int roc[100]; -} Fsro_format_data; - - -CAI_IMAGE *cai_ouvre_lecture_atg2(repert, - nom_image, - nb_can, - nboct_pix, - nb_col, - nb_lig) - -char *repert; -char *nom_image; -int *nb_can; -int *nboct_pix; -int *nb_col; -int *nb_lig; -{ - int fic; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - int iret; /* indicateur de retour ok ou pas */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char *deb,*deb1; /* pointeurs sur chaine de caracteres */ - char car[2]; /* indce du canal traite */ - int num,k,n; /* indice */ - Fsro_format_data fsro; /* structure decrivant l'entete atg2 */ - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - - *nb_lig=0; - *nb_col=0; - *nboct_pix=0; - *nb_can=0; - - iret=1; - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); - -/*................................................. - Constitution du nom du fichier entete - .................................................*/ - nom_fic[0]='\0'; - if (strlen(repert)!= 0) - { - sscanf(repert,"%s",nom_fic); - strcat(nom_fic,"/"); - strcat(nom_fic,nom_image); - strcat(nom_fic,"/"); - strcat(nom_fic,".gen"); - nom_fic[strlen(repert)+1+strlen(nom_image)+5]='\0'; - } - else - { - sscanf(nom_image,"%s",nom_fic); - strcat(nom_fic,"/"); - strcat(nom_fic,".gen"); - nom_fic[strlen(nom_image)+5]='\0'; - } -/*........................ - Ouverture du fichier entete - ..........................................*/ - num=open(nom_fic,O_RDONLY,0); - - if (num == -1) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur ouverture fichier entete ATG2"); - } - else - { - -/*.................................... - Lecture du fichier entete - ............................................*/ - - n=read( num , &fsro , sizeof(Fsro_format_data)); - if ( n <= 0 ) - { - sprintf(CAI_ERREUR,"Erreur lecture entete ATG2 %s\n",nom_fic), - iret=0; - return (NULL); - } - -/*......................................... - Fermeture du fichier entete ATG2 - ..........................................*/ - close ( num ); - -/*......................................... - Recuperation du nombre d'octets par pixel . - ....................................................*/ - if (fsro.pvb>16) - { - iret=0; - sprintf(CAI_ERREUR,"Taille du pixel non traitable %d\n",fsro.pvb); - return (NULL); - } - else - { - if ((fsro.pvb%8)==0) - *nboct_pix=fsro.pvb/8; - else - *nboct_pix=fsro.pvb/8+1; - image1->NB_BITS_PIX = fsro.pvb; - } - -/*......................................... - Recuperation de la taille d'un pave en lignes - ....................................................*/ - image1->LIGNES_PAVE=fsro.pnl; -/*......................................... - Recuperation de la taille d'un pave en colonnes - ....................................................*/ - image1->COLONNES_PAVE=fsro.pnc; - -/*......................................... - Calcul du nombre de lignes : taille du pave*nombre de pave en ligne - ....................................................*/ - *nb_lig=fsro.nfl*image1->LIGNES_PAVE; -/*......................................... - Calcul du nombre de colonnes: taille pave*nombre pave en colonnes - ....................................................*/ - *nb_col=fsro.nfc*image1->COLONNES_PAVE; -/*......................................................... - Recuperation du nombre de canaux en fonction du nom des fichiers .gds - 1 - test sur l'existence du fichier PAN.gds monochrome - ...........................................................*/ - nom_fic[0]='\0'; - if (strlen(repert)!= 0) - { - sscanf(repert,"%s",nom_fic); - strcat(nom_fic,"/"); - strcat(nom_fic,nom_image); - strcat(nom_fic,"/PAN.gds"); - nom_fic[strlen(repert)+1+strlen(nom_image)+8]='\0'; - } - else - { - sscanf(nom_image,"%s",nom_fic); - strcat(nom_fic,"/PAN.gds"); - nom_fic[strlen(nom_image)+8]='\0'; - } - num=open(nom_fic,O_RDONLY,0); - if (num<=0) - { - -/* 2 - test sur l'existence du fichier XS1.gds monochrome - ...........................................................*/ - - nom_fic[0]='\0'; - if (strlen(repert)!= 0) - { - sscanf(repert,"%s",nom_fic); - strcat(nom_fic,"/"); - strcat(nom_fic,nom_image); - strcat(nom_fic,"/XS1.gds"); - nom_fic[strlen(repert)+1+strlen(nom_image)+8]='\0'; - } - else - { - sscanf(nom_image,"%s",nom_fic); - strcat(nom_fic,"/XS1.gds"); - nom_fic[strlen(nom_image)+8]='\0'; - } - - fic=open(nom_fic,O_RDONLY,0); - if (fic<=0) - { - iret=0; - sprintf(CAI_ERREUR,"Erreur nombre de canaux incorrect ATG2\n"); - return (NULL); - } - else - { - close(fic); - *nb_can=3; - } - } - else - { - close(num); - *nb_can=1; - } - - } - if (iret !=0) - { -/*....................................... - INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL et ouverture - de ces fichiers - .....................................................*/ - - deb = image1->NOM_FIC_CAN; - deb1= image1->NOM_UTIL_CAN; - - if (*nb_can==1) - { - sscanf(nom_image,"%s",deb); - strcat(deb,"/PAN.gds"); - sscanf(nom_image,"%s",deb1); - strcat(deb1,"/PAN.gds"); - nom_fic[0]='\0'; - if (strlen(repert)!=0) - { - sscanf(repert,"%s",nom_fic); - strcat(nom_fic,"/"); - strcat(nom_fic,nom_image); - strcat(nom_fic,"/PAN"); - strcat(nom_fic,car); - strcat(nom_fic,".gds"); - nom_fic[strlen(repert)+1+strlen(nom_image)+8]='\0'; - } - else - { - sscanf(nom_image,"%s",nom_fic); - strcat(nom_fic,"/PAN"); - strcat(nom_fic,car); - strcat(nom_fic,".gds"); - nom_fic[strlen(nom_image)+8]='\0'; - } - fic=open(nom_fic,O_RDONLY,0); - image1->ACCES_CANAL_INT[0]=fic; - image1->POS_OCTET[0]=0; - - - } - else - { - - k=1; - while((k<=*nb_can)&&(k<CAI_NB_MAX_CAN)) - { - sprintf(car,"%d",k); - sscanf(nom_image,"%s",deb); - strcat(deb,"/XS"); - strcat(deb,car); - strcat(deb,".gds"); - deb=deb+100; - sscanf(nom_image,"%s",deb1); - strcat(deb1,".XS"); - strcat(deb1,car); - strcat(deb1,".gds"); - deb1=deb1+100; - nom_fic[0]='\0'; - if (strlen(repert)!=0) - { - sscanf(repert,"%s",nom_fic); - strcat(nom_fic,"/"); - strcat(nom_fic,nom_image); - strcat(nom_fic,"/XS"); - strcat(nom_fic,car); - strcat(nom_fic,".gds"); - nom_fic[strlen(repert)+1+strlen(nom_image)+8]='\0'; - } - else - { - sscanf(nom_image,"%s",nom_fic); - strcat(nom_fic,"/XS"); - strcat(nom_fic,car); - strcat(nom_fic,".gds"); - nom_fic[strlen(nom_image)+8]='\0'; - } - fic=open(nom_fic,O_RDONLY,0); - if (fic != -1) - { - image1->ACCES_CANAL_INT[k-1]=fic; - image1->POS_OCTET[k-1]=0; - k=k+1; - } - else - { - iret=0; - strcpy(CAI_ERREUR,"incoherence au niveau du nb fichiers canaux"); - return(NULL); - } - } - } - - return (image1); - } - else - { - return(NULL); - } - -} - -/* - Fin de l'operation cai_ouvre_lecture_atg2 -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_creation_atg2 */ -/* ---------- */ -/* */ -/* ROLE : fonction de creation et d'ouverture en ecriture d'une image */ -/* ----- au format atg2 et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_creation_atg2 (nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig, */ -/* label) */ -/* */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* nb_can (E) (int ) : nombre de canaux de l'image */ -/* nboct_pix (E) (int ) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (E) (int ) : nombre de lignes de l'image */ -/* nb_col (E) (int ) : nombre de colonnes de l'image */ -/* label (E) (char *) : commentaire lie a l'image */ -/* */ -/* cai_ouvre_creation_atg2 (S) (CAI_IMAGE *) : =NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_IMAGE *cai_ouvre_creation_atg2(repert, - nom_image, - nb_can, - nboct_pix, - nb_col, - nb_lig, - label) - -char *repert; -char *nom_image; -int *nb_can; -int *nboct_pix; -int *nb_col; -int *nb_lig; -char *label; -{ - int fic; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char repertoire_ima[1024]; /* nom du fichier en-tete */ - char nom_fic_canal[1024]; /* nom fichier canal dont on teste existence*/ - int retour; /* retour de fonction */ - char car[3]; /* indice du canal traite */ - int i,num,can; /* indice */ - struct stat buf_stat; /* structure decrivant status de fichier */ - Fsro_format_data fsro; /* structure informations format image */ - - char nom_fic_tim[1024]; /* nom de fichier de travail */ - char nom_fic_his[1024]; /* nom de fichier de travail */ - char nom_fic_bid[1024]; /* nom de fichier de travail */ - char **tab_nom_tim; /* tableau contenant les Tile index Maps */ - char **tab_nom_his; /* tableau contenant les histogrammes */ - char **tab_nom_bid; /* tableau contenant les caracteristiques des - plans */ - FILE *ptr_file_tim; /* flot de fichier tim */ - FILE *ptr_file_his; /* flot de fichier his */ - FILE *ptr_file_bid; /* flot de fichier bid */ - unsigned char *ptr_buff_tim; /* pointeur sur buffer tim */ - int offset; /* offset a ecrire dans fichier tim */ - - char str_cmd[100]; /* chaine de commande pour appels systeme */ - int nb_blocs_ns; /* nombre de blocs N/S */ - int nb_blocs_we; /* nombre de blocs W/E */ - - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); - -/*************************************************/ -/* Construction du nom de la sous-directory */ -/* d'accueil des fichiers */ -/*************************************************/ - if (strlen(repert)!= 0) - { - strcpy ( repertoire_ima , repert ); - strcat ( repertoire_ima , "/" ); - strcat ( repertoire_ima , nom_image ); - repertoire_ima[strlen(repert)+1+strlen(nom_image)]='\0'; - } - else - { - strcpy ( repertoire_ima , nom_image ); - repertoire_ima[strlen(nom_image)]='\0'; - } - -/*************************************************/ -/* verification que cette sous-directory */ -/* n'existe pas deja */ -/*************************************************/ - -retour = stat ( repertoire_ima , &buf_stat ); -if (( retour != -1 ) && ( (buf_stat.st_mode & S_IFMT) == S_IFDIR )) -{ - sprintf ( CAI_ERREUR , "L'image %s atg2 existe \n" , nom_image ); - goto ERREUR; - } - -/*************************************************/ -/* Creation de la sous-directory d'accueil des */ -/* fichiers */ -/*************************************************/ - -sprintf(str_cmd,"mkdir %s",repertoire_ima); -system(str_cmd); - -/*************************************************/ -/* Creation du fichier caracteristiques : .gen */ -/*************************************************/ -nom_fic[0]='\0'; -strcpy ( nom_fic, repertoire_ima ); -strcat ( nom_fic, "/.gen" ); -nom_fic[strlen(repertoire_ima)+5]='\0'; -fic = creat ( nom_fic,PERMS); -if ( fic == -1 ) -{ - sprintf ( CAI_ERREUR , "Erreur : creation fichier %s impossible\n",nom_fic ); - goto ERREUR; -} - - -/*************************************************/ -/* ecriture de l'enregistrement d'entete */ -/*************************************************/ - -memset(&fsro,'\0',sizeof(Fsro_format_data)); - -/* Record in field */ - -for (i=0;i<80;i++) - fsro.rty[i]='\0'; -strcpy(fsro.rty,"GIN"); -for (i=0;i<80;i++) - fsro.rid[i]='\0'; -strcpy(fsro.rid,"1"); - -/* Data set id field */ - -for (i=0;i<8;i++) - fsro.prt[i]='\0'; -strcpy(fsro.prt,"IMAGE"); -for (i=0;i<80;i++) - fsro.nam[i]='\0'; -strcpy(fsro.nam,nom_image); - -/* General information field */ - -fsro.str = 3; -fsro.lod = 0.0; -fsro.lad = 0.0; -for (i=0;i<8;i++) - fsro.uniloa[i]='\0'; -strcpy(fsro.uniloa,""); -for (i=0;i<8;i++) - fsro.mbu[i]='\0'; -strcpy(fsro.mbu,""); -fsro.cov = 0; -fsro.fec = 0; -fsro.poc = 0; -fsro.lic = 0; -fsro.alc = 0; -fsro.sgc = 0; -fsro.zna = 0; -fsro.psp = 0.0; -for (i=0;i<4;i++) - fsro.imr[i]='\0'; -strcpy(fsro.imr,"no"); -fsro.arv = 0; -fsro.brv = 0; -fsro.lso = 0.0; -fsro.pso = 0.0; -for (i=0;i<80;i++) -fsro.txt[i]='\0'; -strcpy(fsro.txt,""); - -/* Data set parameters fields */ - -fsro.nul = 0; -fsro.nus = 0; -fsro.nll = 0; -fsro.nls = 0; -/* nombre de blocs N/S */ -if ( (*nb_lig) % 256 == 0 ) - fsro.nfl = (*nb_lig) / 256; -else - fsro.nfl = (*nb_lig) / 256 + 1; -/* nombre de blocs W/E */ -if ( (*nb_col) % 256 == 0 ) - fsro.nfc = (*nb_col) / 256; -else - fsro.nfc = (*nb_col) / 256 + 1; -/* taille des blocs */ -fsro.pnc = 256; -fsro.pnl = 256; -fsro.cod = 0; -fsro.rod = 1; -fsro.por = 0; -fsro.pcb = 0; -fsro.pvb = (*nboct_pix)*8; -for (i=0;i<80;i++) - fsro.bad[i]='\0'; -strcpy(fsro.bad,nom_image); -for (i=0;i<2;i++) - fsro.tif[i]='\0'; -/* nombre de blocs W/S */ -strcpy(fsro.tif,"y"); - -/* Non Digest fiel - Specific ATG2/MULTISCOPE */ - -for (i=0;i<8;i++) - fsro.fmt[i]='\0'; -strcpy(fsro.fmt,"gds"); -for (i=0;i<2;i++) - fsro.pty[i]='\0'; -strcpy(fsro.pty,"S "); -fsro.ofs = 0; -fsro.mpl = 0.0; -fsro.mpc = 0.0; -for (i=0;i<100;i++) - fsro.rol[i]=0; -for (i=0;i<100;i++) - fsro.roc[i]=0; -retour = write ( fic , &fsro , sizeof(Fsro_format_data)); -if ( retour != sizeof(Fsro_format_data) ) -{ - sprintf ( CAI_ERREUR , "Erreur : ecriture impossible dans fichier %s\n", - nom_fic ); - close(fic); - unlink(nom_fic); - goto ERREUR; -} - -close ( fic ); - -/*************************************************/ -/* Creation des fichiers : */ -/* - Tile index Map */ -/* - Histo */ -/* - Caracterisitiques du plan */ -/*************************************************/ - -tab_nom_tim = (char **) malloc ( (*nb_can) * sizeof(char *) ); -tab_nom_his = (char **) malloc ( (*nb_can) * sizeof(char *) ); -tab_nom_bid = (char **) malloc ( (*nb_can) * sizeof(char *) ); - -for (can=0; can<*nb_can; can=can+1 ) -{ - strcpy ( nom_fic_tim , repertoire_ima ); - strcpy ( nom_fic_his , repertoire_ima ); - strcpy ( nom_fic_bid , repertoire_ima ); - if (*nb_can == 1) - { - strcat ( nom_fic_tim , "/PAN.tim" ); - nom_fic_tim[strlen(repertoire_ima)+8]='\0'; - strcat ( nom_fic_his , "/PAN.his" ); - nom_fic_his[strlen(repertoire_ima)+8]='\0'; - strcat ( nom_fic_bid , "/PAN.bid" ); - nom_fic_bid[strlen(repertoire_ima)+8]='\0'; - } - else - { - strcat ( nom_fic_tim , "/XS" ); - sprintf ( car , "%d" , can+1 ); - strcat ( nom_fic_tim , car ); - strcat ( nom_fic_tim , ".tim" ); - nom_fic_tim[strlen(repertoire_ima)+3+strlen(car)+4]='\0'; - strcat ( nom_fic_his , "/XS" ); - sprintf ( car , "%d" ,can+1 ); - strcat ( nom_fic_his , car ); - strcat ( nom_fic_his , ".his" ); - nom_fic_his[strlen(repertoire_ima)+3+strlen(car)+4]='\0'; - strcat ( nom_fic_bid , "/XS" ); - sprintf ( car , "%d" , can+1 ); - strcat ( nom_fic_bid , car ); - strcat ( nom_fic_bid , ".bid" ); - nom_fic_bid[strlen(repertoire_ima)+3+strlen(car)+4]='\0'; - } - - tab_nom_tim[can] = (char *) malloc ( strlen(nom_fic_tim) + 1 ); - strcpy ( tab_nom_tim[can] , nom_fic_tim ); - tab_nom_his[can] = (char *) malloc ( strlen(nom_fic_his) + 1 ); - strcpy ( tab_nom_his[can] , nom_fic_his ); - tab_nom_bid[can] = (char *) malloc ( strlen(nom_fic_bid) + 1 ); - strcpy ( tab_nom_bid[can] , nom_fic_bid ); - } - -/* calcul du nombre de blocs */ - -/* Blocs N/S */ -if ( (*nb_lig) % 256 == 0 ) - nb_blocs_ns = (*nb_lig) / 256; -else - nb_blocs_ns = (*nb_lig) / 256 + 1; -/* Blocs W/E */ -if ( (*nb_col) % (256/(*nboct_pix)) == 0 ) - nb_blocs_we = (*nb_col) / (256/(*nboct_pix)); -else - nb_blocs_we = (*nb_col) / (256/(*nboct_pix)) + 1; - -ptr_buff_tim = (unsigned char *) malloc ( nb_blocs_ns*nb_blocs_we*sizeof(int) ); -if ( ptr_buff_tim == NULL ) -{ - sprintf ( CAI_ERREUR , "Erreur : probleme d'allocation \n" ); - unlink(nom_fic); - free ( ptr_buff_tim ); - free ( tab_nom_tim ); - free ( tab_nom_his ); - free ( tab_nom_bid ); - goto ERREUR; -} -for ( can = 0 ; can < (*nb_can) ; can++ ) -{ - ptr_file_tim = fopen ( tab_nom_tim[can] ,"w"); - ptr_file_his = fopen ( tab_nom_his[can] ,"w"); - ptr_file_bid = fopen ( tab_nom_bid[can] ,"w"); - if ((ptr_file_tim == NULL) || (ptr_file_his == NULL) || (ptr_file_bid == NULL)) - { - sprintf (CAI_ERREUR,"Erreur : creation fichier %s impossible\n",tab_nom_tim[can] ); - unlink(nom_fic); - for(i=0;i<can;i++) - { - unlink(tab_nom_tim[i]); - unlink(tab_nom_his[i]); - unlink(tab_nom_bid[i]); - } - - free ( ptr_buff_tim ); - free ( tab_nom_tim ); - free ( tab_nom_his ); - free ( tab_nom_bid ); - goto ERREUR; - } - - for ( i = 0 ; i < nb_blocs_ns*nb_blocs_we ; i++ ) - { - offset = 256*256*i + 1; - memcpy(&ptr_buff_tim[i*4],&offset,4); - } - retour = fwrite ( ptr_buff_tim , nb_blocs_ns*nb_blocs_we , sizeof(int) , ptr_file_tim ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR ,"Erreur : ecriture impossible dans %s\n ",tab_nom_tim[can] ); - unlink(nom_fic); - for(i=0;i<=can;i++) - { - unlink(tab_nom_tim[i]); - unlink(tab_nom_his[i]); - unlink(tab_nom_bid[i]); - } - free ( ptr_buff_tim ); - free ( tab_nom_tim ); - free ( tab_nom_his ); - free ( tab_nom_bid ); - goto ERREUR; - } - - fclose ( ptr_file_tim ); - fclose ( ptr_file_his ); - fclose ( ptr_file_bid ); -} - - -/*************************************************/ -/* Constitution du nom des fichiers a ecrire */ -/* et insertion dans les tableaux */ -/*************************************************/ - - -for (can=0; can<*nb_can; can ++ ) -{ - nom_fic_canal[0]='\0'; - strcpy ( nom_fic_canal , repertoire_ima ); - if (*nb_can == 1) - { - strcat ( nom_fic_canal , "/PAN.gds" ); - nom_fic_canal[strlen(repertoire_ima)+8]='\0'; - } - else - { - strcat ( nom_fic_canal , "/XS" ); - sprintf ( car , "%d" , can+1 ); - strcat ( nom_fic_canal , car ); - strcat ( nom_fic_canal , ".gds" ); - nom_fic_canal[strlen(repertoire_ima)+3+strlen(car)+4]='\0'; - } - - num = creat(nom_fic_canal,PERMS); - if (num == -1) - { - sprintf(CAI_ERREUR,"Erreur: Creation %s impossible\n",nom_fic_canal); - unlink(nom_fic); - for(i=0;i<=can;i++) - { - unlink(tab_nom_tim[i]); - unlink(tab_nom_his[i]); - unlink(tab_nom_bid[i]); - } - - goto ERREUR; - } - image1->ACCES_CANAL_INT[can]=num; - image1->POS_OCTET[can]=0; - } - - - -free ( ptr_buff_tim ); -free ( tab_nom_tim ); -free ( tab_nom_his ); -free ( tab_nom_bid ); - -return (image1); - -ERREUR : - return(NULL); -} - - -/* - Fin de l'operation cai_ouvre_creation_atg2 -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_lecture_canal_atg2 */ -/* ---------- */ -/* */ -/* ROLE : fonction de lecture d'un canal d'une image atg2 */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_lecture_canal_atg2(image1, canal, */ /* ------------------ premiere_ligne, */ -/* premiere_colonne, */ -/* nombre_lignes_lire , */ -/* nombre_colonnes_lire, */ -/* pas_ligne ,pas_colonne, */ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a lire */ -/* premiere_ligne (E) (int) : premiere ligne a lire dans l'image */ -/* premiere _colonne (E) (int) : premiere colonne a lire dans l'image */ -/* nombre_lignes_lire (E) (int) : nombre de lignes a lire */ -/* nombre_colonnes_lire (E) (int) : nombre de colonnes a lire */ -/* pas_ligne (E) (int) : pas en ligne */ -/* pas_colonne (E) (int) : pas en colonne */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels lus alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_lecture_canal_atg2 (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - - -CAI_OK_KO cai_lecture_canal_atg2(image1 , - canal , - premiere_ligne , - premiere_colonne, - nombre_lignes_lire , - nombre_colonnes_lire, - pas_ligne , - pas_colonne, - data_image ) -CAI_IMAGE *image1; -int *canal ; -int *premiere_ligne ; -int *premiere_colonne ; -int *nombre_lignes_lire ; -int *nombre_colonnes_lire; -int *pas_ligne ; -int *pas_colonne; -unsigned char *data_image; - -{ - - int num,i,j,k,n,l,p; /* variables de travail */ - int pt_oct; /* position courante dans le fichier image */ - int no_oct; /* numero du premier octet a lire */ - int iret; /* indicateur d'erreur */ - int lig; /* indice de boucle sur les lignes */ - int oct_pix; /* nb octets par pixels */ - long nb_oct; /* nb oct =1er octet a lire - position courante */ - unsigned char *buf_lec; /* buffer lecture d'un pave */ - unsigned char *buffer; /* buffer lecture de taille_pave lignes completes*/ - unsigned char *deb,*pch; /* pointeur chaine pour transfert buffer sortie */ - long nb_oct_pave; /* taille du pave en octets */ - unsigned char *ind_lec; /* pointeur de travai pour transfert pave */ - unsigned char *ind_tab; /* pointeur de travai pour transfert pave */ - int pave; /* nombre de paves colonnes dans une ligne */ - int nbcol_tot; /* nb pave*taille colonnes du pave */ - int taille; /* nbcol_tot*taille lignes pave */ - int bloc; /* indice de boucle sur les paves */ - int nolig; /* indice de boucle sur les lignes */ - int numlig; /* numero de la ligne reconstituee */ - - -/*......................... - Initialisations - ........................*/ - iret=CAI_OK; - num=image1->ACCES_CANAL_INT[*canal-1]; - oct_pix=image1->NBOCT_PIX; - nb_oct_pave=oct_pix*image1->LIGNES_PAVE*image1->COLONNES_PAVE; - lig=*premiere_ligne; - i=0; - pch=data_image; - -/*.............................................. - allocation de memoire pour lire une ligne image - ............................................. */ - pave=image1->NB_COL/image1->COLONNES_PAVE; - if ((image1->NB_COL%image1->COLONNES_PAVE)!=0) - { - pave=pave+1; - } - nbcol_tot=pave*image1->COLONNES_PAVE; - taille=nbcol_tot*image1->LIGNES_PAVE*oct_pix; - - buf_lec = (unsigned char *) malloc(nb_oct_pave); - if (buf_lec == NULL) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Probleme d'allocation memoire"); - return(iret); - } - else - { - buffer = (unsigned char *) malloc(taille); - if (buffer == NULL) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Probleme d'allocation memoire"); - free(buf_lec); - return(iret); - } - } - - -/*..................... - Pour chaque ligne a lire - .......................................*/ - while ((i < (*nombre_lignes_lire))&&(iret==CAI_OK)) - { -/*............................................ - Recherche de la position courante dans le fichier - ............................................*/ - pt_oct=lseek(num,0L,1); - -/*................................ - Calcul du numero du 1er octet a lire - ....................................*/ - nolig=((lig-1)/image1->LIGNES_PAVE)*image1->LIGNES_PAVE; - no_oct=image1->POS_OCTET[*canal-1]+(nolig*nbcol_tot*oct_pix); - -/*.................................. - Saut d'octets pour etre positionne sur la ligne a lire - .......................................*/ - nb_oct=(long)(no_oct-pt_oct); - lseek(num,nb_oct,1); - -/*........................................... - lecture de image1->LIGNES_PAVE lignes completes de nolig+1 - a nolig+image1->LIGNES_PAVE - ................................................*/ - for (bloc=1;bloc<=pave;bloc=bloc+1) - { -/* lecture d'un bloc de nb_oct_pave octets consecutifs */ - n=read(num,buf_lec,nb_oct_pave); - if (n<=0) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Erreur lecture donnee image atg2"); - } - else - { -/* stockage du pave dans le tableau de image1->LIGNES_PAVE lignes - completes */ - ind_tab=buffer+(bloc-1)*image1->COLONNES_PAVE*oct_pix; - ind_lec=buf_lec; - - for (l=1;l<=image1->LIGNES_PAVE;l=l+1) - { - for (p=1;p<=image1->COLONNES_PAVE*oct_pix;p=p+1) - { - *ind_tab=*ind_lec; - ind_tab=ind_tab+1; - ind_lec=ind_lec+1; - } - ind_tab=ind_tab+(nbcol_tot-image1->COLONNES_PAVE)*oct_pix; - } - } - } - -/*...................................... - Sauvegarde des donnees lues entenant compte du pas - d'echantillonnage en colonne - ........................................*/ - - if (iret == CAI_OK) - { - numlig=lig-nolig; - deb=buffer+(numlig-1)*nbcol_tot*oct_pix+ - ((*premiere_colonne)-1)*oct_pix; - - while ((numlig<=image1->LIGNES_PAVE)&&(i<(*nombre_lignes_lire))) - { - j=1; - while (j<=(*nombre_colonnes_lire)) - { - for (k=0;k<oct_pix;k=k+1) - { - *(pch+k)=*(deb+k); - } - j=j+1; - pch=pch+oct_pix; - deb=deb+((*pas_colonne)*oct_pix); - } - numlig=numlig+(*pas_ligne); - deb=buffer+((numlig-1)*nbcol_tot*oct_pix)+ - ((*premiere_colonne)-1)*oct_pix; - lig=lig+(*pas_ligne); - i=i+1; - } - } - } - free(buffer); - free(buf_lec); - - return(iret); - -} - -/* - Fin de l'operation cai_lecture_canal_atg2 -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ecriture_canal_atg2 */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ecriture d'un canal d'une image atg2 */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ecriture_canal_atg2 (image1, canal, */ /* ------------------ premiere_ligne, */ -/* nombre_lignes_ecrire, */ -/* nombre_colonnes_ecrire, */ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a ecrire */ -/* premiere_ligne (E) (int) : premiere ligne a ecrire ds l'image */ -/* nombre_lignes_ecrire (E) (int) : nombre de lignes a ecrire */ -/* nombre_colonnes_ecrire(E) (int) : nombre de lignes a ecrire */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels ecris alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_ecriture_canal_atg2 (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_OK_KO cai_ecriture_canal_atg2(image1 , - canal , - premiere_ligne , - nombre_lignes_ecrire , - nombre_colonnes_ecrire, - data_image ) -CAI_IMAGE *image1; -int *canal ; -int *premiere_ligne ; -int *nombre_lignes_ecrire ; -int *nombre_colonnes_ecrire; -unsigned char *data_image; - -{ -int nb_colon_correc; /* nombre de colonnes multiple de 256 */ -int nb_blocs; /* nombre de paquets de 256 pixels */ -int i_bloc; /* compteur de blocs */ -int nb_last_pix; /* nb initial de pixels dans le dernier bloc */ -int nb_blocs_prec_first_lig;/* nb de blocs avant 1ere ligne a ecrire */ -int nb_blocs_prec_lig; /* nb de blocs avant ligne courante */ -int pos_first_lig_ds_bloc; /* position 1ere ligne a ecrire dans son bloc */ -int pos_lig_ds_bloc; /* position ligne courante dans son bloc */ -long position_first_oct; /* position du 1er octet a ecrire */ -long position_courante; /* position courante dans le fichier */ -long deplacement; /* deplacement a effectuer */ -long depla_bl; /* deplacement a effectuer */ -int i_ligne; /* compteur de lignes */ -unsigned char *buff_lig; /* tableau contenant une ligne a ecrire */ -unsigned char *buff_bloc; /* tableau contenant un bloc a ecrire */ -int taille_wr; /* nombre d'elements du buffer a ecrire */ -int cr_write; /* code retour de write */ -unsigned char *completion; /* caractere completant les blocs */ -int num; /* descripteur de fichier */ -int nboct_pix; /* nombre d'octets par pixel */ -unsigned char *pch; /* pointeur chaine servant au transfert */ -int i; /* indice de boucle */ - - - -/* initialisations */ - -i_ligne = 0; -num = image1->ACCES_CANAL_INT[*canal-1]; -nboct_pix = image1->NBOCT_PIX; - - - -/********************************************************/ -/* Calcul du nombre de colonnes multiple de 256 de */ -/* l'image a ecrire */ -/********************************************************/ - -if ( (*nombre_colonnes_ecrire) % 256 == 0 ) - nb_colon_correc = (*nombre_colonnes_ecrire); -else - nb_colon_correc = (*nombre_colonnes_ecrire) - ((*nombre_colonnes_ecrire)%256) + 256; - -/********************************************************/ -/* Calcul du nombre de blocs complets de 256 pixels */ -/* sur une meme ligne (eventuellement completes par 0) */ -/********************************************************/ - -nb_blocs = nb_colon_correc / 256; - - -/********************************************************/ -/* Calcul du nombre de pixels presents initialement */ -/* dans le dernier bloc d'une ligne */ -/********************************************************/ - -nb_last_pix = 256 - ( nb_colon_correc - (*nombre_colonnes_ecrire) ); - - -/********************************************************/ -/* Calcul du nombre de blocs de 256 lignes precedant la */ -/* premiere ligne a ecrire */ -/* Calcul de la position de la premiere ligne a ecrire */ -/* au sein d'un bloc de 256 lignes */ -/********************************************************/ - -if ( *premiere_ligne <= 256 ) -{ - nb_blocs_prec_first_lig = 0; - pos_first_lig_ds_bloc = *premiere_ligne; -} -else if ( (*premiere_ligne - 1) % 256 == 0 ) -{ - nb_blocs_prec_first_lig = (*premiere_ligne - 1) / 256; - pos_first_lig_ds_bloc = 1; -} -else -{ - nb_blocs_prec_first_lig = - ( (*premiere_ligne- 1 ) - (*premiere_ligne - 1)%256 ) / 256; - pos_first_lig_ds_bloc = 1 + (*premiere_ligne - 1)%256; -} - - - -/********************************************************/ -/* Initialisations */ -/********************************************************/ - -pos_lig_ds_bloc = pos_first_lig_ds_bloc; -nb_blocs_prec_lig = nb_blocs_prec_first_lig; - - -/********************************************************/ -/* POUR chacune des lignes a ecrire */ -/********************************************************/ -for ( i_ligne = 0 ; i_ligne < *nombre_lignes_ecrire ; i_ligne++ ) -{ -/********************************************************/ -/* calcul de la position du premier octet de la */ -/* ligne a ecrire */ -/********************************************************/ - - position_first_oct = (long) ( image1->POS_OCTET[*canal-1] - + 256 * nboct_pix * (pos_lig_ds_bloc - 1) - + 256 * nb_blocs_prec_lig * nb_colon_correc * nboct_pix ); - -/********************************************************/ -/* recuperation de la position courante */ -/********************************************************/ - - position_courante = lseek ( num , 0L , 1 ); - -/********************************************************/ -/* deplacement jusqu'au premier octet a ecrire */ -/********************************************************/ - - deplacement = position_first_oct - position_courante; - lseek ( num , deplacement , 1 ); - -/********************************************************/ -/* extraction de la ligne du tableau */ -/********************************************************/ - - buff_lig = data_image +(*nombre_colonnes_ecrire) * nboct_pix * i_ligne; - -/********************************************************/ -/* initialisation du decalage de 255*256 pixels */ -/********************************************************/ - - depla_bl = 0; - -/********************************************************/ -/* POUR chacun des blocs de 256 pixels */ -/********************************************************/ - for ( i_bloc = 0 ; i_bloc < nb_blocs ; i_bloc++ ) - { -/********************************************************/ -/* deplacement */ -/********************************************************/ - - lseek ( num , depla_bl , 1 ); - -/********************************************************/ -/* extraction d'un bloc de la ligne */ -/********************************************************/ - - buff_bloc = buff_lig + i_bloc * 256 * nboct_pix; - -/********************************************************/ -/* determination du nombre d'octets a */ -/* ecrire */ -/********************************************************/ - if ( i_bloc == nb_blocs - 1 ) - { - taille_wr = nb_last_pix*nboct_pix; - } - else - { - taille_wr = 256 * nboct_pix; - } - -/********************************************************/ -/* ecriture dans le fichier */ -/********************************************************/ - cr_write = write ( num , buff_bloc , taille_wr ); - if ( cr_write != taille_wr ) - { - strcpy ( CAI_ERREUR , "Erreur ecriture canal image atg2\n" ); - goto ERREUR; - } - -/********************************************************/ -/* completion eventuelle du dernier bloc */ -/********************************************************/ - - if ((i_bloc == nb_blocs - 1) && ((256 - nb_last_pix) > 0)) - { - taille_wr = (256 - nb_last_pix)*nboct_pix; - completion=(unsigned char *) malloc(taille_wr); - pch=completion; - for (i=0;i<taille_wr;i=i+1) - { - *pch='\0'; - pch=pch+1; - } - cr_write = write ( num , completion , taille_wr ); - if ( cr_write != taille_wr ) - { - - strcpy ( CAI_ERREUR , "Erreur ecriture canal image atg2\n" ); - goto ERREUR; - } - free(completion); - } - -/********************************************************/ -/* mise a jour du decalage de 255*256 pixels*/ -/********************************************************/ - - depla_bl = 255*256*nboct_pix; - -/********************************************************/ -/* FIN POUR */ -/********************************************************/ - } - -/********************************************************/ -/* mise a jour de la position de la ligne dans le */ -/* bloc, et du nombre de blocs precedant la ligne */ -/********************************************************/ - - if ( pos_lig_ds_bloc == 256 ) - { - pos_lig_ds_bloc = 1; - nb_blocs_prec_lig++; - } - else - pos_lig_ds_bloc++; - -/********************************************************/ -/* FIN POUR */ -/********************************************************/ -} - - -return (CAI_OK); - -ERREUR : - -return (CAI_KO); - - -} -/* - Fin de l'operation cai_ecriture_canal_atg2 -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ferme_atg2 */ -/* ---------- */ -/* */ -/* ROLE : fonction de fermeture d'une image au format atg2 et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ferme_atg2(image1) */ /* ------------------ */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* */ -/* cai_ferme_atg2 (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_OK_KO cai_ferme_atg2 (image1) - -CAI_IMAGE *image1; - -{ - - int iret; /* code retour de l'operation */ - int i_can; /* indice du canal a fermer */ - int num; /* descripteur du fichier a fermer */ - - iret=CAI_OK; -/*............................................. - Fermeture des fichiers image - .............................................*/ - for (i_can=0;i_can<image1->NB_CANAUX;i_can=i_can+1) - { - num=image1->ACCES_CANAL_INT[i_can]; - close(num); - } - - - return (iret); -} - -/* - Fin de l'operation cai_ferme_atg2 -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_dest_ima_atg2 */ -/* ---------- */ -/* */ -/* ROLE : fonction de destruction d'une image stocke en atg2 et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_dest_ima_atg2(format,nom_ima) */ /* ------------------ */ -/* format (E) (char *) : format de l'image a detruire */ -/* nom_image (E) (char *) : nom de l'image a detruire avec repertoire */ -/* */ -/* cai_dest_ima_atg2 (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_OK_KO cai_dest_ima_atg2 ( repertoire , - nom_ima ) - -char *repertoire; /* repertoire de stockage de l'image */ -char *nom_ima; /* nom de l'image */ - -{ -int iret ; /* code retour fonction de fermeture */ -int i_can; /* compteur de canaux */ -char nom_fic_courant[1024]; /* nom du fichier entete a detruire */ -char repertoire_ima[1024]; /* repertoire + nom de l'image */ -char str_num_fic[6]; /* chaine numero du canal */ -int numero_fic; /* numero du fichier canal */ -char str_cmd[100]; /* chaine de commande pour appels systeme */ - -int cr_stat; /* code retour de fonction status de fichier */ -struct stat buf_stat; /* structure decrivant status de fichier */ - -CAI_IMAGE *image1; /* structure ouverture image */ -int nb_can; /* nombre de canaux de l'image */ -int nboct_pix; /* nombre d'octets par pixel image */ -int nb_col; /* nombre de colonnes de l'image */ -int nb_lig; /* nombre de lignes de l'image */ - -/*************************************************/ -/* Construction du nom de la sous-directory */ -/* qui contient l'image ATG2 */ -/*************************************************/ -if (strlen(repertoire) != 0) -{ - strcpy ( repertoire_ima , repertoire ); - strcat ( repertoire_ima, "/" ); - strcat ( repertoire_ima , nom_ima ); - repertoire_ima[strlen(repertoire)+1+strlen(nom_ima)]='\0'; -} -else -{ - strcpy ( repertoire_ima , nom_ima ); - repertoire_ima[strlen(nom_ima)]='\0'; -} - -/************************************************/ -/* Extraction des caracteristiques de l'image */ -/* du fichier entete par l'appel a la fonction */ -/* cai_ouvre_lecture_atg2 */ -/************************************************/ - - image1 = cai_ouvre_lecture_atg2 ( repertoire,nom_ima, &nb_can ,&nboct_pix , - &nb_col , &nb_lig ); - if ( image1 == NULL) goto ERREUR; - - image1->NB_CANAUX=nb_can; - image1->NB_COL=nb_col; - image1->NB_LIG=nb_lig; - image1->NBOCT_PIX=nboct_pix; - - iret=cai_ferme_atg2(image1); - - - -/************************************************/ -/* Verification de l'existence de la sous- */ -/* directory */ -/************************************************/ - -cr_stat = stat ( repertoire_ima , &buf_stat ); -if ( cr_stat == -1 ) -{ - sprintf ( CAI_ERREUR , - "Erreur : acces impossible a %s\n" , repertoire_ima ); - goto ERREUR; -} -if ( (buf_stat.st_mode & S_IFMT) != S_IFDIR ) -{ - sprintf ( CAI_ERREUR , - "Erreur : %s n'est pas un repertoire\n" , repertoire_ima ); - goto ERREUR; -} - -/************************************************/ -/* Constitution du nom des fichiers et */ -/* destruction */ -/************************************************/ - -strcpy ( nom_fic_courant , repertoire_ima ); -strcat ( nom_fic_courant , "/.gen" ); -nom_fic_courant[strlen(repertoire_ima)+5]='\0'; -cr_stat = stat ( nom_fic_courant , &buf_stat ); -if ( cr_stat == 0 ) - unlink ( nom_fic_courant ); - -if ( nb_can == 1 ) -{ - strcpy ( nom_fic_courant , repertoire_ima ); - strcat ( nom_fic_courant , "/PAN.bid" ); - nom_fic_courant[strlen(repertoire_ima)+8]='\0'; - cr_stat = stat ( nom_fic_courant , &buf_stat ); - if ( cr_stat == 0 ) - unlink ( nom_fic_courant ); - - strcpy ( nom_fic_courant , repertoire_ima ); - strcat ( nom_fic_courant , "/PAN.his" ); - nom_fic_courant[strlen(repertoire_ima)+8]='\0'; - cr_stat = stat ( nom_fic_courant , &buf_stat ); - if ( cr_stat == 0 ) - unlink ( nom_fic_courant ); - - strcpy ( nom_fic_courant , repertoire_ima ); - strcat ( nom_fic_courant , "/PAN.gds" ); - nom_fic_courant[strlen(repertoire_ima)+8]='\0'; - cr_stat = stat ( nom_fic_courant , &buf_stat ); - if ( cr_stat == 0 ) - unlink ( nom_fic_courant ); - - strcpy ( nom_fic_courant , repertoire_ima ); - strcat ( nom_fic_courant , "/PAN.tim" ); - nom_fic_courant[strlen(repertoire_ima)+8]='\0'; - cr_stat = stat ( nom_fic_courant , &buf_stat ); - if ( cr_stat == 0 ) - unlink ( nom_fic_courant ); -} -else -{ - i_can=1; - numero_fic=1; - while ( (i_can<=nb_can) && (numero_fic<10000) ) - { - strcpy ( nom_fic_courant , repertoire_ima ); - strcat ( nom_fic_courant , "/XS" ); - sprintf ( str_num_fic , "%d" , numero_fic ); - strcat ( nom_fic_courant , str_num_fic ); - strcat ( nom_fic_courant , ".bid" ); -nom_fic_courant[strlen(repertoire_ima)+3+strlen(str_num_fic)+4]='\0'; - cr_stat = stat ( nom_fic_courant , &buf_stat ); - if ( cr_stat == 0 ) - unlink ( nom_fic_courant ); - - strcpy ( nom_fic_courant , repertoire_ima ); - strcat ( nom_fic_courant , "/XS" ); - sprintf ( str_num_fic , "%d" , numero_fic ); - strcat ( nom_fic_courant , str_num_fic ); - strcat ( nom_fic_courant , ".his" ); - nom_fic_courant[strlen(repertoire_ima)+3+strlen(str_num_fic)+4]='\0'; - cr_stat = stat ( nom_fic_courant , &buf_stat ); - if ( cr_stat == 0 ) - unlink ( nom_fic_courant ); - - strcpy ( nom_fic_courant , repertoire_ima ); - strcat ( nom_fic_courant , "/XS" ); - sprintf ( str_num_fic , "%d" , numero_fic ); - strcat ( nom_fic_courant , str_num_fic ); - strcat ( nom_fic_courant , ".gds" ); - nom_fic_courant[strlen(repertoire_ima)+3+strlen(str_num_fic)+4]='\0'; - cr_stat = stat ( nom_fic_courant , &buf_stat ); - if ( cr_stat == 0 ) - unlink ( nom_fic_courant ); - - strcpy ( nom_fic_courant , repertoire_ima ); - strcat ( nom_fic_courant , "/XS" ); - sprintf ( str_num_fic , "%d" , numero_fic ); - strcat ( nom_fic_courant , str_num_fic ); - strcat ( nom_fic_courant , ".tim" ); - nom_fic_courant[strlen(repertoire_ima)+3+strlen(str_num_fic)+4]='\0'; - cr_stat = stat ( nom_fic_courant , &buf_stat ); - if ( cr_stat == 0 ) - unlink ( nom_fic_courant ); - - i_can++; - numero_fic++; - } - - -} - -sprintf(str_cmd,"rmdir %s",repertoire_ima); -system(str_cmd); - -return (CAI_OK); - -ERREUR : - -return (CAI_KO); - - -} -/* - Fin de l'operation cai_dest_ima_atg2 -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_modifie_atg2 */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture ecriture d'une image au format */ -/* ----- atg2 et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_modifie_atg2(nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_modifie_atg2 (S) (CAI_IMAGE *) : =NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ /* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_IMAGE *cai_ouvre_modifie_atg2(repert, - nom_image, - nb_can, - nboct_pix, - nb_col, - nb_lig) - -char *repert; -char *nom_image; -int *nb_can; -int *nboct_pix; -int *nb_col; -int *nb_lig; - -{ - int fic; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - int iret; /* indicateur de retour ok ou pas */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char *deb,*deb1; /* pointeurs sur chaine de caracteres */ - char car[2]; /* indce du canal traite */ - int num,k,n; /* indice */ - Fsro_format_data fsro; /* structure decrivant l'entete atg2 */ - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - - *nb_lig=0; - *nb_col=0; - *nboct_pix=0; - *nb_can=0; - - iret=1; - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); - -/*................................................. - Constitution du nom du fichier entete - .................................................*/ - nom_fic[0]='\0'; - if (strlen(repert)!= 0) - { - sscanf(repert,"%s",nom_fic); - strcat(nom_fic,"/"); - strcat(nom_fic,nom_image); - strcat(nom_fic,"/"); - strcat(nom_fic,".gen"); - nom_fic[strlen(repert)+1+strlen(nom_image)+5]='\0'; - } - else - { - sscanf(nom_image,"%s",nom_fic); - strcat(nom_fic,"/"); - strcat(nom_fic,".gen"); - nom_fic[strlen(nom_image)+5]='\0'; - } -/*........................ - Ouverture du fichier entete - ..........................................*/ - num=open(nom_fic,O_RDONLY,0); - - if (num == -1) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur ouverture fichier entete ATG2"); - } - else - { - -/*.................................... - Lecture du fichier entete - ............................................*/ - - n=read( num , &fsro , sizeof(Fsro_format_data)); - if ( n <= 0 ) - { - sprintf(CAI_ERREUR,"Erreur lecture entete ATG2 %s\n",nom_fic), - iret=0; - return (NULL); - } - -/*......................................... - Fermeture du fichier entete ATG2 - ..........................................*/ - close ( num ); - -/*......................................... - Recuperation du nombre d'octets par pixel . - ....................................................*/ - if (fsro.pvb>16) - { - iret=0; - sprintf(CAI_ERREUR,"Taille du pixel non traitable %d\n",fsro.pvb); - return (NULL); - } - else - { - if ((fsro.pvb%8)==0) - *nboct_pix=fsro.pvb/8; - else - *nboct_pix=fsro.pvb/8+1; - image1->NB_BITS_PIX = fsro.pvb; - } - -/*......................................... - Recuperation de la taille d'un pave en lignes - ....................................................*/ - image1->LIGNES_PAVE=fsro.pnl; -/*......................................... - Recuperation de la taille d'un pave en colonnes - ....................................................*/ - image1->COLONNES_PAVE=fsro.pnc; - -/*......................................... - Calcul du nombre de lignes : taille du pave*nombre de pave en ligne - ....................................................*/ - *nb_lig=fsro.nfl*image1->LIGNES_PAVE; -/*......................................... - Calcul du nombre de colonnes: taille pave*nombre pave en colonnes - ....................................................*/ - *nb_col=fsro.nfc*image1->COLONNES_PAVE; -/*......................................................... - Recuperation du nombre de canaux en fonction du nom des fichiers .gds - 1 - test sur l'existence du fichier PAN.gds monochrome - ...........................................................*/ - nom_fic[0]='\0'; - if (strlen(repert)!= 0) - { - sscanf(repert,"%s",nom_fic); - strcat(nom_fic,"/"); - strcat(nom_fic,nom_image); - strcat(nom_fic,"/PAN.gds"); - nom_fic[strlen(repert)+1+strlen(nom_image)+8]='\0'; - } - else - { - sscanf(nom_image,"%s",nom_fic); - strcat(nom_fic,"/PAN.gds"); - nom_fic[strlen(nom_image)+8]='\0'; - } - num=open(nom_fic,O_RDONLY,0); - if (num<=0) - { - -/* 2 - test sur l'existence du fichier XS1.gds monochrome - ...........................................................*/ - - nom_fic[0]='\0'; - if (strlen(repert)!= 0) - { - sscanf(repert,"%s",nom_fic); - strcat(nom_fic,"/"); - strcat(nom_fic,nom_image); - strcat(nom_fic,"/XS1.gds"); - nom_fic[strlen(repert)+1+strlen(nom_image)+8]='\0'; - } - else - { - sscanf(nom_image,"%s",nom_fic); - strcat(nom_fic,"/XS1.gds"); - nom_fic[strlen(nom_image)+8]='\0'; - } - - fic=open(nom_fic,O_RDONLY,0); - if (fic<=0) - { - iret=0; - sprintf(CAI_ERREUR,"Erreur nombre de canaux incorrect ATG2\n"); - return (NULL); - } - else - { - close(fic); - *nb_can=3; - } - } - else - { - close(num); - *nb_can=1; - } - - } - if (iret !=0) - { -/*....................................... - INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL et ouverture - de ces fichiers - .....................................................*/ - - deb = image1->NOM_FIC_CAN; - deb1= image1->NOM_UTIL_CAN; - - if (*nb_can==1) - { - sscanf(nom_image,"%s",deb); - strcat(deb,"/PAN.gds"); - sscanf(nom_image,"%s",deb1); - strcat(deb1,"/PAN.gds"); - nom_fic[0]='\0'; - if (strlen(repert)!=0) - { - sscanf(repert,"%s",nom_fic); - strcat(nom_fic,"/"); - strcat(nom_fic,nom_image); - strcat(nom_fic,"/PAN"); - strcat(nom_fic,car); - strcat(nom_fic,".gds"); - nom_fic[strlen(repert)+1+strlen(nom_image)+8]='\0'; - } - else - { - sscanf(nom_image,"%s",nom_fic); - strcat(nom_fic,"/PAN"); - strcat(nom_fic,car); - strcat(nom_fic,".gds"); - nom_fic[strlen(nom_image)+8]='\0'; - } - fic=open(nom_fic,O_RDWR,0); - image1->ACCES_CANAL_INT[0]=fic; - image1->POS_OCTET[0]=0; - - - } - else - { - - k=1; - while((k<=*nb_can)&&(k<CAI_NB_MAX_CAN)) - { - sprintf(car,"%d",k); - sscanf(nom_image,"%s",deb); - strcat(deb,"/XS"); - strcat(deb,car); - strcat(deb,".gds"); - deb=deb+100; - sscanf(nom_image,"%s",deb1); - strcat(deb1,".XS"); - strcat(deb1,car); - strcat(deb1,".gds"); - deb1=deb1+100; - nom_fic[0]='\0'; - if (strlen(repert)!=0) - { - sscanf(repert,"%s",nom_fic); - strcat(nom_fic,"/"); - strcat(nom_fic,nom_image); - strcat(nom_fic,"/XS"); - strcat(nom_fic,car); - strcat(nom_fic,".gds"); - nom_fic[strlen(repert)+1+strlen(nom_image)+8]='\0'; - } - else - { - sscanf(nom_image,"%s",nom_fic); - strcat(nom_fic,"/XS"); - strcat(nom_fic,car); - strcat(nom_fic,".gds"); - nom_fic[strlen(nom_image)+8]='\0'; - } - fic=open(nom_fic,O_RDWR,0); - if (fic != -1) - { - image1->ACCES_CANAL_INT[k-1]=fic; - image1->POS_OCTET[k-1]=0; - k=k+1; - } - else - { - iret=0; - strcpy(CAI_ERREUR,"incoherence au niveau du nb fichiers canaux"); - return(NULL); - } - } - } - - return (image1); - } - else - { - return(NULL); - } - -} -/* - Fin de l'operation cai_ouvre_modifie_atg2 -*/ diff --git a/Utilities/CAI/cai_dll/src/cai_bandeau.c b/Utilities/CAI/cai_dll/src/cai_bandeau.c deleted file mode 100755 index d059d4f9216a14a090435274ca9de8d0691d7cd1..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/src/cai_bandeau.c +++ /dev/null @@ -1,730 +0,0 @@ -/*****************************************************************************/ -/* */ -/* PROJET : COUCHE ACCES IMAGE */ -/* ------- */ -/* */ -/* MODULE : cai_bandeau.c */ -/* ------- */ -/* */ -/* ROLE : Ce module rassemble toutes les fonctions d'acces aux images */ -/* ------- stockees au format bandeau */ -/* */ -/* AUTEUR : R.CHAISEMARTIN (CISI) */ -/* ------- */ -/* */ -/* DATE DE CREATION : novembre 2005 */ -/* ----------------- */ -/* */ -/* LANGAGE : C */ -/* -------- */ -/* */ -/* VERSION : V5.3 */ -/* -------- */ -/* */ -/*****************************************************************************/ -/* MOD : VERSION : 5.3 : Prise en compte du format bandeau dans CAI */ -/* */ -/*****************************************************************************/ - -/*---------------------------------------------------------------------------*/ -/* Inclusion des fichiers STANDARDS (.h) */ -/*---------------------------------------------------------------------------*/ - - -# include <stdio.h> -# include <string.h> -# include <stdlib.h> -# include <sys/types.h> -# include <unistd.h> -# include <dirent.h> -# include <sys/stat.h> -# include <fcntl.h> -#include <errno.h> - -#define _CAI_IMAGE -#define IN_CAI_BANDEAU - -# include "cai_image.h" - -/*----------------------------------------------------------------------------*/ -/* Variable pour la gestion en configuration */ -/*----------------------------------------------------------------------------*/ -static char *rcs_id="$Header$"; - -extern char *getenv(); - - -/*****************************************************************************/ -/*****************************************************************************/ -/* */ -/* Definition des OPERATIONS EXTERNES */ -/* */ -/*****************************************************************************/ -/*****************************************************************************/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_liste_ima_bandeau */ -/* ---------- */ -/* */ -/* ROLE : fonction de listage des images au format bandeau */ -/* ------ */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : int cai_liste_ima_bandeau(repert,tab_ima) */ -/* ----------------- */ -/* */ -/* repert (E) (char *) : repertoire a explorer */ -/* tab_ima (S) (char ***) : pointeur sur tableau des images listees */ -/* alloue par la fonction,il doit etre */ -/* LIBERE PAR L'APPELANT */ -/* */ -/* cai_liste_ima_bandeau (S) (long int) : = -1 repertoiren inexistant */ /* = > 0 nombre d'images listees */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -long int cai_liste_ima_bandeau (char *repert, - char ***tab_ima) - -{ - - DIR *dirp; /* pointeur sur structure ouverture repertoire */ - - struct dirent *dp; /* structure resultat de la fonction readdir */ - - char *pch0,*pch1; /* pointeurs sur chaine de caracteres */ - char *pch2,*pch3; /* pointeurs sur chaine de caracteres */ - char car[6]; /* variable de travail */ - int nb_ima; /* nombre d'images bandeau identifiees */ - int i; /* indice de boucle */ - long int diff,Long; - -/*........................................ - INITIALISATION et ouverture du repertoire choisi - .........................................*/ - nb_ima=0; - dirp=opendir(repert); - - if(dirp!=NULL) - { - - -/*...................................... - - premiere passe pour comptabiliser les images du format donne - - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE BANDEAU_CNES - (EXTENSION =.band) - ..........................................*/ - while((dp=readdir(dirp))!=NULL) - { - sprintf(car,".band"); - pch0=strstr(dp->d_name,car); - if (pch0 != NULL) - { - *pch0='\0'; - nb_ima=nb_ima+1; - } -/*****************************************************************************/ -/* MOD : VERSION : 4.4 : DM : prise en compte des extensions en majuscule */ -/*****************************************************************************/ - else - { - sprintf(car,".BAND"); - pch1=strstr(dp->d_name,car); - if (pch1 != NULL) - { - *pch1='\0'; - nb_ima=nb_ima+1; - } - } - } - - (void)closedir(dirp); - if (nb_ima ==0) goto FIN; - -/*..................................... - ALLOCATION DU TABLEAU CONTENANT LA LISTE DES IMAGES DU FORMAT BANDEAU - ......................................*/ - *tab_ima = (char **) calloc(nb_ima,sizeof(char *)); - for (i=0;i<nb_ima;i=i+1) - (*tab_ima)[i]=(char *)calloc(1,100); - -/*...................................... - - deuxieme passe pour constituer la liste des images du format donne - - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE BANDEAU_CNES - (EXTENSION =.band) - SI C`EST LE CAS,STOCKAGE DANS LA LISTE - ..........................................*/ - dirp=opendir(repert); - - nb_ima=0; - while((dp=readdir(dirp))!=NULL) - { - sprintf(car,".band"); - pch0=strstr(dp->d_name,car); - if (pch0 != NULL) - { - *pch0='\0'; - strcpy((*tab_ima)[nb_ima],dp->d_name); - nb_ima=nb_ima+1; - } -/*****************************************************************************/ -/* MOD : VERSION : 4.4 : DM : prise en compte des extensions en majuscule */ -/*****************************************************************************/ - else - { - sprintf(car,".BAND"); - pch1=strstr(dp->d_name,car); - if (pch1 != NULL) - { - *pch1='\0'; - strcpy((*tab_ima)[nb_ima],dp->d_name); - nb_ima=nb_ima+1; - } - } - } - - (void)closedir(dirp); - - - } - else - { - /* repertoire inexistant */ - nb_ima=-1; - } - -FIN: - return(nb_ima); - -} - -/* Fin de l'operation cai_liste_ima_bandeau -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_lecture_bandeau */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture d'une image au format bandeau */ -/* ----- et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_lecture_bandeau (nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_lecture_bandeau (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ -CAI_IMAGE *cai_ouvre_lecture_bandeau(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) -{ - CAI_IMAGE *image1,*image2; /* pointeur su descripteur de fichier image */ - int NbBandeaux; /* nombre de bandeaux */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char label[80]; /* contient un enregistrement du fichier */ - int retour; /* retour de la fonction comparaison chaines*/ - FILE *fic_in; /* pointeur sur descripteur de fichier */ - char format[20]; /* Format de stockage de chaque bandeau */ - int nbcan, nboctpix; - int nbcol,nblig; - int ific,num,ind; - CH50 tab_ima[20]; - - - /*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - *nb_can=0; - *nb_lig=0; - *nb_col=0; - *nboct_pix=0; - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); - if (image1==NULL) - { - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_lecture"); - goto ERREUR; - } - -/*................................................. - Constitution du nom du fichier entete - .................................................*/ - nom_fic[0]='\0'; - if ((long int)strlen(repert)== 0) - sprintf(repert,"./"); - sprintf(nom_fic,"%s/%s.band",repert,nom_image); - sprintf(image1->NOM_IMAGE,"%s/%s",repert,nom_image); - - /*........................ - Ouverture du fichier entete - ..........................................*/ - fic_in=NULL; - fic_in=fopen(nom_fic,"r"); - if (fic_in==NULL) - { -/* verification si extension en majuscule */ - nom_fic[0]='\0'; - sprintf(nom_fic,"%s/%s.BAND",repert,nom_image); - fic_in=fopen(nom_fic,"r"); - if (fic_in==NULL) - { - strcpy(CAI_ERREUR,"Erreur ouverture fichier entete BANDEAU-CNES"); - goto ERREUR; - } - } - -/*.................................... - Decodage du nombre de BANDEAU - ............................................*/ - fscanf(fic_in,"%s %d\n",label,&NbBandeaux); - retour=strncmp(label,"BANDEAU",7); - if (retour!=0) - { - sprintf(CAI_ERREUR, - "Informations incoherentes ligne BANDEAU dans %s", - nom_fic); - goto ERREUR; - } -/*.................................... - Decodage du nombre du format - ............................................*/ - fscanf(fic_in,"%s\n",format); - -/*.................................... - Recuperation du nom de chaque bandeau - ............................................*/ - for (ific=0;ific<NbBandeaux;ific++) - { - fscanf(fic_in,"%s %d\n",label,&num); - strcpy(tab_ima[num-1],label); - } - -/*.................................. - Fermeture du fichier - ......................................*/ - if (fic_in!=NULL) - { - fclose(fic_in); - fic_in=NULL; - } - -/*.................................... - Ouverture de chaque bandeau - ............................................*/ - for (ific=0;ific<NbBandeaux;ific++) - { - sprintf(nom_fic,"%s/%s",repert,tab_ima[ific]); - image2 = cai_ouvre_lecture_image(nom_fic, format,&nbcan, - &nboctpix,&nbcol,&nblig); - if (image2 == NULL) - { - sprintf(CAI_ERREUR,"Erreur ouverture du bandeau %s \n",nom_fic); - goto ERREUR; - } - *nb_can = nbcan; - *nboct_pix = nboctpix; - *nb_col = nbcol; - *nb_lig = (*nb_lig) + nblig; - image1->POS_OCTET[ific]=0; - - FBANDEAU[ific] = image2; - - } -/*.................................. - Initialisation du type de codage, indicateur d'inversion des octets, - nombre d'octets par pixel, - ........................................................*/ - sprintf(image1->COD_PIX,image2->COD_PIX); - image1->NB_BITS_PIX = image2->NB_BITS_PIX; - image1->NBOCT_PIX = image2->NBOCT_PIX; - image1->INV_OCTETS = image2->INV_OCTETS; - -/*.................................. - On stocke l'information "nombre de bandeaux" dans ACCES_CANAL_INT - qui n'est pas utilisé par ailleurs - ........................................................*/ - image1->ACCES_CANAL_INT[0] = NbBandeaux; - - return(image1); - -ERREUR: - if (fic_in!=NULL) - { - fclose(fic_in); - fic_in=NULL; - } - return (NULL); -} - -/* - Fin de l'operation cai_ouvre_lecture_bandeau -*/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_lecture_canal_bandeau */ -/* ---------- */ -/* */ -/* ROLE : fonction de lecture d'un canal d'une image bandeau */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_lecture_canal_bandeau(image1, canal, */ -/* ------------------ premiere_ligne, */ -/* premiere_colonne, */ -/* nombre_lignes_lire , */ -/* nombre_colonnes_lire, */ -/* pas_ligne ,pas_colonne, */ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (lint): numero du canal a lire */ -/* premiere_ligne (E) (int) : premiere ligne a lire dans l'image */ -/* premiere _colonne (E) (int) : premiere colonne a lire dans l'image */ -/* nombre_lignes_lire (E) (int) : nombre de lignes a lire */ -/* nombre_colonnes_lire (E) (int) : nombre de colonnes a lire */ -/* pas_ligne (E) (int) : pas en ligne */ -/* pas_colonne (E) (int) : pas en colonne */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels lus alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_lecture_canal_bandeau (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ -CAI_OK_KO cai_lecture_canal_bandeau(CAI_IMAGE *image1 , - int *canal , - int *premiere_ligne , - int *premiere_colonne, - int *nombre_lignes_lire , - int *nombre_colonnes_lire, - int *pas_ligne , - int *pas_colonne, - unsigned char *data_image ) - -{ - int NbBandeaux; /* Nombre de bandeaux constituant l'image */ - int iret; /* indicateur d'erreur */ - long int oct_pix; /* nb octets par pixels */ - long int oct_lig; /* nb oct. par ligne en considerant taille pixel */ - int lig,ilig; /* indice de boucle sur les lignes */ - int ific; /* boucle sur le nombre de bandeaux */ - CAI_IMAGE *image2; /* pointeur sur descripteur de fichier image */ - int BandDeb,Tot; /* indicateur du bandeau de la premiere ligne */ - int BandFin,Fin; /* indicateur du bandeau de la derniere ligne */ - unsigned char *buf_lec; /* buffer lecture d'une ligne */ - unsigned char *pch; /* pointeur chaine pour transfert buffer sortie */ - int Un; - -/*........................... - Initialisations diverses - ..........................*/ - NbBandeaux = image1->ACCES_CANAL_INT[0]; - iret=CAI_OK; - oct_pix=image1->NBOCT_PIX; - oct_lig=(*nombre_colonnes_lire)*oct_pix; - lig=*premiere_ligne; - ilig=1; - Un=1; - pch = data_image; - -/*.............................................. - allocation de memoire pour lire une ligne image complete - ............................................. */ - buf_lec = (unsigned char *) calloc(oct_lig,sizeof(unsigned char)); - if (buf_lec == NULL) - { - strcpy(CAI_ERREUR,"Probleme allocation memoire"); - goto ERREUR; - } - -/*.................... - Recherche du bandeau dans lequel se trouve la premiere ligne à lire - ............................................. */ - BandDeb = -1; - ific=0; - Tot = 1; - while ((BandDeb == -1) && (ific<NbBandeaux)) - { - if (ific != 0) lig = lig - image2->NB_LIG; - image2 = FBANDEAU[ific]; - Tot = Tot + image2->NB_LIG; - if ((*premiere_ligne) < Tot) BandDeb=ific; - ific = ific+1; - } - if (BandDeb == -1) - { - strcpy(CAI_ERREUR,"Recherche du premier bandeau"); - goto ERREUR; - } -/*.................... - Recherche du bandeau dans lequel se trouve la derniere ligne à lire - ............................................. */ - BandFin = -1; - ific=0; - Fin = (*premiere_ligne)+(*nombre_lignes_lire)-1; - Tot = 0; - while ((BandFin == -1) && (ific<NbBandeaux)) - { - image2 = FBANDEAU[ific]; - Tot = Tot + image2->NB_LIG; - if (Fin <= Tot) BandFin=ific; - ific = ific+1; - } - if (BandFin == -1) - { - strcpy(CAI_ERREUR,"Recherche du dernier bandeau"); - goto ERREUR; - } - - ific = BandDeb; - image2 = FBANDEAU[ific]; - if (BandDeb == BandFin) - { - iret = cai_lecture_canal(image2,*canal, - lig,*premiere_colonne, - *nombre_lignes_lire,*nombre_colonnes_lire, - *pas_ligne,*pas_colonne,data_image); - if (iret != CAI_OK) - goto ERREUR; - } - else - { - while (ilig <= (*nombre_lignes_lire)) - { - iret = cai_lecture_canal(image2,*canal,lig,*premiere_colonne,Un, - *nombre_colonnes_lire,*pas_ligne, - *pas_colonne,buf_lec); - if (iret != CAI_OK) - goto ERREUR; - - memcpy ( pch, buf_lec , oct_lig ); - pch = pch+oct_lig; - ilig=ilig+1; - lig=lig+(*pas_ligne); - if (lig > image2->NB_LIG) - { - lig = lig - image2->NB_LIG; - ific=ific+1; - if (ific<NbBandeaux) - image2 = FBANDEAU[ific]; - } - } - } - - return(CAI_OK); - -ERREUR: - return(CAI_KO); - } -/* - Fin de l'operation cai_lecture_canal_bandeau -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ferme_bandeau */ -/* ---------- */ -/* */ -/* ROLE : fonction de fermeture d'une image au format bandeau et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ferme_bandeau(image1) */ -/* ------------------ */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* */ -/* cai_ferme_bandeau (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_OK_KO cai_ferme_bandeau (CAI_IMAGE *image1) - -{ - int iret,retour; /* code retour de l'operation */ - int ific; /* indice du bandeau a fermer */ - int NbBandeaux; /* Nombre de bandeaux constituant l'image */ - CAI_IMAGE *image2; /* pointeur sur descripteur de fichier image */ - - - NbBandeaux = image1->ACCES_CANAL_INT[0]; - retour=CAI_OK; - -/*............................................. - Fermeture de tous les bandeaux - .............................................*/ - - for (ific=0;ific<NbBandeaux;ific++) - { - image2 = FBANDEAU[ific]; - iret = cai_ferme_image(image2); - if (iret != CAI_OK) retour=CAI_KO; - } - - return (retour); -} - -/* - Fin de l'operation cai_ferme_bandeau -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_dest_ima_bandeau */ -/* ---------- */ -/* */ -/* ROLE : fonction de destruction d'une image stocke en bandeau et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_dest_ima_bandeau(repertoire,nom_ima) */ -/* ------------------ */ -/* repertoire (E) (char *) : repertoire de l'image a detruire */ -/* nom_image (E) (char *) : nom de l'image a detruire avec repertoire */ -/* */ -/* cai_dest_ima_bandeau (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_OK_KO cai_dest_ima_bandeau ( char *repertoire , - char *nom_ima ) -{ - CAI_IMAGE *image1,*image2; /* pointeur su descripteur de fichier image */ - int NbBandeaux; /* nombre de bandeaux */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char label[80]; /* contient un enregistrement du fichier */ - int retour; /* retour de la fonction comparaison chaines*/ - FILE *fic_in; /* pointeur sur descripteur de fichier */ - char format[20]; /* Format de stockage de chaque bandeau */ - CH50 tab_ima[20]; - int num,ific; -/*................................................. - Constitution du nom du fichier entete - .................................................*/ - nom_fic[0]='\0'; - if ((long int)strlen(repertoire)== 0) - sprintf(repertoire,"./"); - sprintf(nom_fic,"%s/%s.band",repertoire,nom_ima); - - /*........................ - Ouverture du fichier entete - ..........................................*/ - fic_in=NULL; - fic_in=fopen(nom_fic,"r"); - if (fic_in==NULL) - { -/* verification si extension en majuscule */ - nom_fic[0]='\0'; - sprintf(nom_fic,"%s/%s.BAND",repertoire,nom_ima); - fic_in=fopen(nom_fic,"r"); - if (fic_in==NULL) - { - strcpy(CAI_ERREUR,"Erreur ouverture fichier entete BANDEAU-CNES"); - goto ERREUR; - } - } -/*.................................... - Decodage du nombre de BANDEAU - ............................................*/ - fscanf(fic_in,"%s %d\n",label,&NbBandeaux); - retour=strncmp(label,"BANDEAU",7); - if (retour!=0) - { - sprintf(CAI_ERREUR, - "Informations incoherentes ligne BANDEAU dans %s", - nom_fic); - goto ERREUR; - } -/*.................................... - Decodage du nombre du format - ............................................*/ - fscanf(fic_in,"%s\n",format); - -/*.................................... - Recuperation du nom de chaque bandeau - ............................................*/ - for (ific=0;ific<NbBandeaux;ific++) - { - fscanf(fic_in,"%s %d\n",label,&num); - strcpy(tab_ima[num-1],label); - } - -/*.................................. - Fermeture du fichier et destruction du fichier d'entete - ......................................*/ - if (fic_in!=NULL) - { - fclose(fic_in); - fic_in=NULL; - unlink ( nom_fic ); - - } - -/*.................................... - destruction de chaque bandeau - ............................................*/ - for (ific=0;ific<NbBandeaux;ific++) - { - sprintf(nom_fic,"%s/%s",repertoire,tab_ima[ific]); - retour = cai_destruction_image(format,nom_fic); - - } - - return(CAI_OK); - -ERREUR: - return(CAI_KO); - -} - -/* - Fin de l'operation cai_dest_ima_bandeau -*/ - - diff --git a/Utilities/CAI/cai_dll/src/cai_bil.c b/Utilities/CAI/cai_dll/src/cai_bil.c deleted file mode 100755 index 672c3de0b9e79d5e4474563f0f65f941b03e237a..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/src/cai_bil.c +++ /dev/null @@ -1,1810 +0,0 @@ -/*****************************************************************************/ -/* */ -/* PROJET : COUCHE ACCES IMAGE */ -/* ------- */ -/* */ -/* MODULE : cai_bil.c */ -/* ------- */ -/* */ -/* ROLE : Ce module rassemble toutes les fonctions d'acces aux images */ -/* ------- stockees au format bil */ -/* */ -/* AUTEUR : R.CHAISEMARTIN (CISI) */ -/* ------- */ -/* */ -/* DATE DE CREATION : Septembre 97 */ -/* ----------------- */ -/* */ -/* LANGAGE : C */ -/* -------- */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ -/* MOD : VERSION : 3.3 : DM : optimisation des acces */ -/*****************************************************************************/ -/* MOD : VERSION : 4.1 : FA : Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : FA : anomalie a la lecture d'images codees sur plus */ -/* de 1 octet */ -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : DM : modifications pour compatibilite HP64bits */ -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : prise en compte des extensions en majuscule */ -/*****************************************************************************/ -/* MOD : VERSION : 4.4 : FA : prise en compte des extensions en majuscule */ -/*****************************************************************************/ -/* MOD : VERSION : 4.5 : FA : test sur fclose pour PC/LINUX */ -/*****************************************************************************/ -/* MOD : VERSION : 4.6 : FA : pb ouverture en modification et ecriture */ -/* Modification pour compatibilite ouverture en modification */ -/*****************************************************************************/ -/* MOD : VERSION : 5.0 : FA : pb lecture ligne d'une image 24000x24000 */ -/* EN 64bits, modification de int en long int */ -/*****************************************************************************/ -/* MOD : VERSION : 5.1 : DM : Maj du tag TYPE lorsque l'image est codée */ -/* en reel et que l'utilisateur le precise dans le param "label" */ -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : prise en compte des I2,I4,UI2,UI4 et R8 */ -/* en lecture et ecriture */ -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : prise en compte de l'information INTEL ou IEEE*/ -/* en lecture et ecriture dans l'entete .hd */ -/*****************************************************************************/ - -/*---------------------------------------------------------------------------*/ -/* Inclusion des fichiers STANDARDS (.h) */ -/*---------------------------------------------------------------------------*/ - - -# include <stdio.h> -# include <string.h> -# include <stdlib.h> -# include <unistd.h> -# include <sys/types.h> -#include <dirent.h> -# include <sys/stat.h> -# include <fcntl.h> - -#define _CAI_IMAGE -#define IN_CAI_BIL - -# include "cai_image.h" - -/*----------------------------------------------------------------------------*/ -/* Variable pour la gestion en configuration */ -/*----------------------------------------------------------------------------*/ -static char *rcs_id="$Header: cai_bil.c,v 1.10 01/05/31 10:47:22 cmf Exp $"; - - -extern char *getenv(); - -/*****************************************************************************/ -/*****************************************************************************/ -/* */ -/* Definition des OPERATIONS EXTERNES */ -/* */ -/*****************************************************************************/ -/*****************************************************************************/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_liste_ima_bil */ -/* ---------- */ -/* */ -/* ROLE : fonction de listage des images au format bil */ -/* ------ */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : int cai_liste_ima_bil(repert,tab_ima) */ -/* ----------------- */ -/* */ -/* repert (E) (char *) : repertoire a explorer */ -/* tab_ima (S) (char ***) : pointeur sur tableau des images listees */ -/* alloue par la fonction,il doit etre */ -/* LIBERE PAR L'APPELANT */ -/* */ -/* cai_liste_ima_bil (S) (int) : = -1 repertoire inexistant */ /* = > 0 nombre d'images listees */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -long int cai_liste_ima_bil (char *repert, - char ***tab_ima) - -{ - DIR *dirp; /* pointeur sur structure ouverture repertoire */ - struct dirent *dp; /* structure resultat de la fonction readdir */ - char *pch0,*pch1; /* pointeurs sur chaine de caracteres */ - char car; /* variable de travail */ - int nb_ima; /* nombre d'images bil identifiees */ - long int i; /* indice de boucle */ - long int ll,dif; /* variables de travail */ - char blanc; /* caractere blanc */ - - -/*........................................ - INITIALISATION et ouverture du repertoire choisi - .........................................*/ - nb_ima=0; - blanc=' '; - dirp=opendir(repert); - - if(dirp!=NULL) - { -/*...................................... - - premiere passe pour comptabiliser les images du format donne - - - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE BIL - (EXTENSION =.bil) - ..........................................*/ - - while((dp=readdir(dirp))!=NULL) - { - pch0=strstr(dp->d_name,".bil"); - if (pch0 != NULL) - { - ll = strlen(dp->d_name); - dif = (long int)(dp->d_name-pch0); - dif=labs(dif); - pch1=pch0+4; - if (((ll-4)==dif)||((*pch1)==blanc)) - nb_ima=nb_ima+1; - - } -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : prise en compte des extensions en majuscule */ -/*****************************************************************************/ - else - { - pch0=strstr(dp->d_name,".BIL"); - if (pch0 != NULL) - { - ll = strlen(dp->d_name); - dif = (long int)(dp->d_name-pch0); - dif=labs(dif); - pch1=pch0+4; - if (((ll-4)==dif)||((*pch1)==blanc)) - nb_ima=nb_ima+1; - } - } - - } - - closedir(dirp); -/*..................................... - ALLOCATION DU TABLEAU CONTENANT LA LISTE DES IMAGES DU FORMAT BIL - ......................................*/ - *tab_ima = (char **) calloc(nb_ima,sizeof(char *)); - for (i=0;i<nb_ima;i=i+1) - (*tab_ima)[i]=(char *)calloc(1,100); - -/*...................................... - - deuxieme passe pour constituer la liste des images du format donne - - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE BIL - (EXTENSION =.lan ou .gis) - SI C`EST LE CAS,STOCKAGE DANS LA LISTE - ..........................................*/ - dirp=opendir(repert); - - nb_ima=0; - - while((dp=readdir(dirp))!=NULL) - { - pch0=strstr(dp->d_name,".bil"); - if (pch0 != NULL) - { - ll = strlen(dp->d_name); - dif = (long)(dp->d_name-pch0); - dif=labs(dif); - pch1=pch0+4; - if (((ll-4)==dif)||((*pch1)==blanc)) - { - *pch0='\0'; - strcpy((*tab_ima)[nb_ima],dp->d_name); - nb_ima=nb_ima+1; - } - - } -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : prise en compte des extensions en majuscule */ -/*****************************************************************************/ - else - { - pch0=strstr(dp->d_name,".BIL"); - if (pch0 != NULL) - { - ll = strlen(dp->d_name); - dif = (long int)(dp->d_name-pch0); - dif=labs(dif); - pch1=pch0+4; - if (((ll-4)==dif)||((*pch1)==blanc)) - nb_ima=nb_ima+1; - } - } - } - - closedir(dirp); - - } - else - { - /* Erreur : Repertoire inexistant */ - nb_ima=-1; - } - - return(nb_ima); - -} -/* Fin de l'operation cai_liste_ima_bil -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_lecture_bil */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture d'une image au format bil */ -/* ----- et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_lecture_bil(nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_lecture_bil (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ /* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_IMAGE *cai_ouvre_lecture_bil(char *repert, - char * nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) - -{ - FILE *fic_in; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - int iret; /* indicateur de retour ok ou pas */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char nom_fic_canal[1024]; /* nom fichier canal dont on teste existence*/ - char label[80]; /* contient un enregistrement du fichier */ - int nbbit; /* nb de bits par pixel du fichier en-tete */ - int retour; /* retour de la fonction comparaison chaines*/ - char *deb,*deb1,*pch0; /* pointeurs sur chaine de caracteres */ - int i,num; /* indice */ - int nbplan; /* nombre de canaux dans le fichier en-tete */ - char COD_PIX[80]; /* type de codage du pixel (optionnel) */ - struct stat buf_stat; /* structure decrivant status de fichier */ - char *type_machine; /* ordre rangement octets machine de travail*/ - int cmp; /* retour de comparaison de chaine */ - int reconnaissance_type; - - /*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - *nb_can=0; - - *nb_lig=0; - - *nb_col=0; - - *nboct_pix=0; - - iret=1; - pch0=NULL; - reconnaissance_type = -1; - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); - - /*.................................. - determination ordre de rangement - des octets sur machine de travail - ......................................*/ - type_machine = cai_test_pFpf(); - -/*****************************************************************************/ -/* MOD : VERSION : 4.1: FA :Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_lecture"); - } - else - { -/*................................................. - Constitution du nom du fichier entete - .................................................*/ - nom_fic[0]='\0'; - if((long int)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s.bil_hd",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.bil_hd",nom_image); - } - -/*........................ - Ouverture du fichier entete - ..........................................*/ - fic_in=NULL; - fic_in=fopen(nom_fic,"r"); - if (fic_in==NULL) - { -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : prise en compte des extensions en majuscule */ -/*****************************************************************************/ - nom_fic[0]='\0'; - if((long int)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s.BIL_HD",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.BIL_HD",nom_image); - } - fic_in=fopen(nom_fic,"r"); - if (fic_in==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur ouverture fichier entete BIL-CNES"); - } - } - if (iret !=0) - { -/*.................................... - Decodage du commentaire - ......................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"COMMENT",7); - if (retour!=0) - { - strcpy(CAI_ERREUR,"Informations incoherentes ligne COMMENT"); - iret=0; - } - else - { - fgets(image1->COMMENT,80,fic_in); - - - /*........................................ - Decodage du nombre de canaux - .........................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"CHANNELS",8); - if (retour!=0) - { - strcpy(CAI_ERREUR,"Informations incoherentes ligne CHANNELS"); - iret=0; - } - else - { - fscanf(fic_in,"%d\n",&nbplan); - *nb_can=nbplan; - -/*....................................... - Decodage du nombre de lignes - ........................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"LINES",5); - if (retour!=0) - { - strcpy(CAI_ERREUR,"Informations incoherentes ligne LINES"); - iret=0; - } - else - { - fscanf(fic_in,"%d\n",nb_lig); - - -/*....................................... - Decodage du nombre de colonnes - ........................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"COLUMNS",7); - if (retour!=0) - { - strcpy(CAI_ERREUR,"Informations incoherentes ligne COLUMNS"); - iret=0; - } - else - { - - fscanf(fic_in,"%d\n",nb_col); - -/*....................................... - Decodage du nombre de bits par pixel - ........................................*/ - fgets(label,80,fic_in); - retour=strncmp(label,"BITS PER PIXEL",14); - if (retour!=0) - { - strcpy(CAI_ERREUR,"Informations incoherentes ligne BITS "); - iret=0; - } - else - { - fscanf(fic_in,"%d\n",&nbbit); - -/*........................................................ - Decodage du type de codage du pixel (optionnel) - ........................................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"TYPE",4); - if (retour==0) - { - fscanf(fic_in,"%s\n",COD_PIX); - retour=1; - } - else - sprintf(COD_PIX,"UND"); - - pch0=cai_En_majuscule( COD_PIX ); - -/* Verification si type de codage reconnu */ - reconnaissance_type = cai_istyp_connu(pch0); -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : prise en compte de l'information INTEL ou IEEE*/ -/* en lecture et ecriture dans l'entete .hd */ -/*****************************************************************************/ - if (retour !=0) fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"SENSCODAGE",10); - if (retour!=0) - { -/* Si absent, pas d'inversion */ - image1->INV_OCTETS =0; - sprintf(image1->SENS_COD,type_machine); - } - else - { - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"IEEE",4); - if (retour==0) - sprintf(image1->SENS_COD,"BE"); - else - sprintf(image1->SENS_COD,"LE"); - cmp = strncmp(type_machine,image1->SENS_COD,2); - if (cmp!=0) - image1->INV_OCTETS =1; - else - image1->INV_OCTETS =0; - } - - } - } - } - } - } - } -/*.................................. - Fermeture du fichier - ......................................*/ - if (fic_in !=NULL) fclose(fic_in); - - if (iret !=0) - { -/*.................................. - Initialisation du nombre d'octets par pixel - ........................................................*/ - if ((nbbit%8)==0) - *nboct_pix=(int)(nbbit/8); - else - *nboct_pix=(int)((nbbit/8)+1); - - if (reconnaissance_type != -1) - { - sprintf(image1->COD_PIX,"%s",COD_PIX); - } - else - { - sprintf(image1->COD_PIX,"UND"); - - if (*nboct_pix==1) - sprintf(image1->COD_PIX,"OCT"); - else if (*nboct_pix==2) - sprintf(image1->COD_PIX,"I2"); - else if (*nboct_pix==4) - { - retour=strncmp(COD_PIX,"I4",2); - if (retour==0) - sprintf(image1->COD_PIX,"I4"); - else - { - retour=strncmp(COD_PIX,"R4",2); - if (retour==0) - sprintf(image1->COD_PIX,"R4"); - } - } - else if (*nboct_pix==8) - { - sprintf(image1->COD_PIX,"R8"); - } - } - -/*....................................... - INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL - .....................................................*/ - - nom_fic[0]='\0'; - nom_fic_canal[0]='\0'; - - if((long int)strlen(repert)!=0) - { - sprintf(nom_fic_canal,"%s/%s.bil",repert,nom_image); - } - else - { - sprintf(nom_fic_canal,"%s.bil",nom_image); - } -/*****************************************************************************/ -/* MOD : VERSION : 4.4 : FA : prise en compte des extensions en majuscule */ -/*****************************************************************************/ - retour = stat ( nom_fic_canal , &buf_stat ); - if ( retour != 0 ) - { - if((long int)strlen(repert)!=0) - { - sprintf(nom_fic_canal,"%s/%s.BIL",repert,nom_image); - } - else - { - sprintf(nom_fic_canal,"%s.BIL",nom_image); - } - } - deb = image1->NOM_FIC_CAN; - deb1= image1->NOM_UTIL_CAN; - num=open(nom_fic_canal,O_RDONLY|O_BINARY,0); - if (num!= -1) - { - - for (i=0;i<*nb_can;i=i+1) - { - sscanf(nom_image,"%s",deb); - deb=deb+100; - sscanf(nom_image,"%s",deb1); - deb1=deb1+100; - image1->ACCES_CANAL_INT[i]=num; - image1->POS_OCTET[i]=(*nb_col)*i*(*nboct_pix); - } - } - else - iret=0; - } - } - if (iret == 0) - { - return (NULL); - } - else - { - return(image1); - } - -} -/* - Fin de l'operation cai_ouvre_lecture_bil -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_creation_bil */ -/* ---------- */ -/* */ -/* ROLE : fonction de creation et d'ouverture en ecriture d'une image */ -/* ----- au format bil et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_creation_bil(nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig, */ -/* label) */ -/* */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* nb_can (E) (int ) : nombre de canaux de l'image */ -/* nboct_pix (E) (int ) : nombre d'octets par pixels */ -/* nb_lig (E) (int ) : nombre de lignes de l'image */ -/* nb_col (E) (int ) : nombre de colonnes de l'image */ -/* label (E) (char *) : commentaire lie a l'image */ -/* */ -/* cai_ouvre_creation_bil (S) (CAI_IMAGE *) : =NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_IMAGE *cai_ouvre_creation_bil(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig, - char *label) - -{ - FILE *fic; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char nom_fic_canal[1024]; /* nom fichier canal dont on teste existence*/ - int retour; /* retour de fonction */ - char car[4]; /* indice du canal traite */ - int i,num,Coher; /* indice */ - struct stat buf_stat; /* structure decrivant status de fichier */ - char *type_machine; /* ordre rangement octets machine de travail*/ - int reconnaissance_type; - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); -/*****************************************************************************/ -/* MOD : VERSION : 4.1: FA:Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_creation"); - goto ERREUR; - } -/*.................................. - determination ordre de rangement - des octets sur machine de travail - ......................................*/ - type_machine = cai_test_pFpf(); - -/*................................................. - Constitution du nom du fichier entete et verification qu'il - n'existe pas deja - .................................................*/ - - nom_fic[0]='\0'; - if((long int)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s.bil_hd",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.bil_hd",nom_image); - } - - retour = stat ( nom_fic , &buf_stat ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "L'image %s BIL existe \n" , nom_image ); - goto ERREUR; - } - -/*............................................................... - constitution du nom de fichier correspondant a la radiometrie de l'image - Verification qu'il n'existe pas deja - Ouverture du fichier en ecriture - .................................................................*/ - - nom_fic_canal[0]='\0'; - sscanf(nom_fic,"%s",nom_fic_canal); - nom_fic_canal[strlen(nom_fic_canal)-3]='\0'; - retour = stat ( nom_fic_canal , &buf_stat ); - - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "L'image %s BIL existe \n" , nom_image ); - goto ERREUR; - } - - num = open(nom_fic_canal,O_RDWR|O_CREAT|O_BINARY,PERMS); - if (num == -1) - { - - sprintf(CAI_ERREUR,"Erreur: Creation %s impossible\n",nom_fic_canal); - goto ERREUR; - } - - for (i=0;i<*nb_can;i=i+1) - { - image1->ACCES_CANAL_INT[i]=num; -/*****************************************************************************/ -/* MOD : VERSION : 4.6 : FA : pb ouverture en modification et ecriture */ -/* Modification pour compatibilite ouverture en modification */ -/*****************************************************************************/ - - image1->POS_OCTET[i]=(*nb_col)*i*(*nboct_pix); - } - -/*...................................................... - Ouverture du fichier entete en ecriture - Ecriture du contenu - ..........................................................*/ - fic = fopen(nom_fic,"w"); - if (fic == NULL) - { - sprintf(CAI_ERREUR,"Erreur: Creation fichier %s impossible\n",nom_fic); - goto ERREUR; - } - - retour=fprintf ( fic , "COMMENT\n"); - if (retour == 0) - { - sprintf(CAI_ERREUR,"Erreur: Ecriture %s impossible\n",nom_fic); - goto ERREUR; - } - - fprintf ( fic , "%s\n" , label ); - fprintf ( fic , "CHANNELS\n" ); - fprintf ( fic , "%3d\n" , *nb_can ); - fprintf ( fic , "LINES\n" ); - fprintf ( fic , "%5d\n" , *nb_lig ); - fprintf ( fic , "COLUMNS\n" ); - fprintf ( fic , "%5d\n" , *nb_col ); - fprintf ( fic , "BITS PER PIXEL\n" ); - fprintf ( fic , "%2d\n" , (*nboct_pix)*8 ); - fprintf ( fic , "TYPE\n"); -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : Maj du tag TYPE lorsque l'utilisateur le */ -/* precise dans le param "label" */ -/*****************************************************************************/ -/* Verification si type de codage reconnu dans le label */ - reconnaissance_type = cai_istyp_connu(label); - if (reconnaissance_type == -1) - { - if (*nboct_pix==1) - sprintf ( image1->COD_PIX , "OCT" ); - else if (*nboct_pix==2) - sprintf ( image1->COD_PIX , "I2" ); - else if (*nboct_pix==4) - { -/*****************************************************************************/ -/* MOD : VERSION : 5.1 : DM : Maj du tag TYPE lorsque l'image est codée */ -/* en reel et que l'utilisateur le precise dans le param "label" */ -/*****************************************************************************/ - if ((strcasecmp(label,"R4") == 0)|| - (strcasecmp(label,"FLOAT")== 0)|| - (strcasecmp(label,"REEL") == 0)) - sprintf ( image1->COD_PIX , "R4" ); - else - sprintf ( image1->COD_PIX , "I4" ); - } - else - sprintf ( image1->COD_PIX , "UND" ); - fprintf ( fic , "%s\n",image1->COD_PIX ); - } - else - { -/* Verification de coherence entre le nb d'octets par pixel et le type donne */ - Coher=1; - if(*nboct_pix == 1) - if (reconnaissance_type > 1) Coher=0; - else if(*nboct_pix == 2) - if ((reconnaissance_type != 2) || (reconnaissance_type != 3)) Coher=0; - else if(*nboct_pix == 4) - if ((reconnaissance_type <4) || (reconnaissance_type > 6)) Coher=0; - else if(*nboct_pix == 8) - if (reconnaissance_type != 7) Coher=0; - else - Coher = 0; - if (Coher == 0) - { - sprintf(CAI_ERREUR,"incoherence entre TYPE et Nb bits par pixels\n"); - goto ERREUR; - } - else - { - sprintf ( image1->COD_PIX , "%s" ,label); - fprintf ( fic , "%s\n", label ); - } - } - fprintf ( fic , "SENSCODAGE\n" ); - retour=strncmp(type_machine,"BE",2); - sprintf(image1->SENS_COD,"%s",type_machine); - if (retour == 0) - fprintf ( fic , "IEEE\n" ); - else - fprintf ( fic , "INTEL\n" ); - - -/*************************************************/ -/* Fermeture du fichier */ -/*************************************************/ - - if (fic!=NULL) fclose ( fic ); - return (image1); - -ERREUR : - - if (fic !=NULL) cai_dest_ima_bil ( repert , nom_image ); - return(NULL); - - } - -/* - Fin de l'operation cai_ouvre_creation_bil -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_lecture_canal_bil */ -/* ---------- */ -/* */ -/* ROLE : fonction de lecture d'un canal d'une image BIL */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_lecture_canal_bil(image1, canal, */ /* ------------------ premiere_ligne, */ -/* premiere_colonne, */ -/* nombre_lignes_lire , */ -/* nombre_colonnes_lire, */ -/* pas_ligne ,pas_colonne, */ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a lire */ -/* premiere_ligne (E) (int) : premiere ligne a lire dans l'image */ -/* premiere _colonne (E) (int) : premiere colonne a lire dans l'image */ -/* nombre_lignes_lire (E) (int) : nombre de lignes a lire */ -/* nombre_colonnes_lire (E) (int) : nombre de colonnes a lire */ -/* pas_ligne (E) (int) : pas en ligne */ -/* pas_colonne (E) (int) : pas en colonne */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels lus alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_lecture_canal_bil (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_OK_KO cai_lecture_canal_bil(CAI_IMAGE *image1 , - int *canal , - int *premiere_ligne , - int *premiere_colonne, - int *nombre_lignes_lire , - int *nombre_colonnes_lire, - int *pas_ligne , - int *pas_colonne, - unsigned char *data_image ) - -{ -/*****************************************************************************/ -/* MOD : VERSION : 5.0 : FA : pb lecture ligne d'une image 24000x24000 */ -/* EN 64bits, modification de int no_oct en long int no_oct */ -/*****************************************************************************/ - int num,i,j,k ; /* variables de travail */ - long pt_oct,n; /* position courante dans le fichier image */ - long no_oct; /* numero du premier octet a lire */ - int iret; /* indicateur d'erreur */ - int lig; /* indice de boucle sur les lignes */ - int oct_pix; /* nb octets par pixels */ - long nb_oct; /* nb oct =1er octet a lire - position courante */ - long oct_lig; /* nb oct. par ligne en considerant taille pixel */ - unsigned char *buf_lec; /* buffer lecture d'une ligne */ - unsigned char *deb,*pch; /* pointeur chaine pour transfert buffer sortie */ - unsigned char *data_image2;/* pointeur donnees image pour inversion octets */ - int taille_image,Nb; /* taille en octets de l'image */ - -/*........................... - Initialisations diverses - ..........................*/ - iret=CAI_OK; - num=image1->ACCES_CANAL_INT[*canal-1]; - oct_pix=image1->NBOCT_PIX; - oct_lig=oct_pix*image1->NB_COL; - -/*.............................................. - allocation de memoire pour lire une ligne image - ............................................. */ - - buf_lec = (unsigned char *) calloc(oct_lig,sizeof(unsigned char)); - if (buf_lec == NULL) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Probleme allocation memoire"); - } - else - { -/*.................... - Initialisation - ......................*/ - lig=*premiere_ligne; - i=1; - pch=data_image; - -/*..................... - Pour chaque ligne a lire - .......................................*/ - while ((i <= *nombre_lignes_lire)&&(iret==CAI_OK)) - { -/*............................................ - Recherche de la position courante dans le fichier - ............................................*/ - pt_oct=lseek(num,0L,1); - -/*................................ - Calcul du numero du 1er octet a lire - ....................................*/ - - no_oct=(long)image1->POS_OCTET[*canal-1]+ - ((long)(lig-1)*(long)image1->NB_COL* - (long)oct_pix*(long)image1->NB_CANAUX); - - -/*.................................. - Saut d'octets pour etre positionne sur la ligne a lire - .......................................*/ - nb_oct=(long)(no_oct-pt_oct); - lseek(num,nb_oct,1); - -/*........................................... - lecture d'une ligne image - ................................................*/ - n=read(num,buf_lec,oct_lig); - - if (n<=0) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Erreur lecture donnee image BIL"); - } - else - { -/*...................................... - Sauvegarde des donnees lues entenant compte du pas - d'echantillonnage en colonne - ........................................*/ - deb=buf_lec+(*premiere_colonne-1)*oct_pix; - j=1; - while (j <= *nombre_colonnes_lire) - { -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : FA : anomalie a la lecture d'images codees sur plus */ -/* de 1 octet */ -/*****************************************************************************/ - for (k=0;k<oct_pix;k=k+1) - { - *(pch+k)=*(deb+k); - } - j=j+1; - pch=pch+oct_pix; - deb=deb+(*pas_colonne*oct_pix); - } - - } - i=i+1; - lig=lig+(*pas_ligne); - - } - - free(buf_lec); - } -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : prise en compte de l'information INTEL ou IEEE*/ -/* en lecture et ecriture dans l'entete .hd */ -/*****************************************************************************/ - - if ( (iret!= CAI_KO) && (image1->INV_OCTETS==1) && (oct_pix!=1) ) - { - taille_image = (*nombre_lignes_lire)*oct_pix*(*nombre_colonnes_lire); - data_image2 = NULL; - data_image2 = (unsigned char *) calloc(taille_image, - sizeof(unsigned char)); - if (data_image2 == NULL) - { - strcpy(CAI_ERREUR,"Erreur allocation memoire cai_lecture_canal"); - iret=CAI_KO; - } - else - { - /*modification ordre selon nb octets par pixel*/ - swab( (void*)(data_image), (void*)(data_image2), taille_image); - - if (oct_pix!=2) - { - Nb = taille_image/2; - cai_inverser_tableau(data_image, data_image2,Nb); - } - else - for (i=0; i<taille_image;i++) - { - /*stockage dans data_image*/ - data_image[i] = data_image2[i]; - } - - if (data_image2!= NULL) free(data_image2); - } - } - - return(iret); -} -/* - Fin de l'operation cai_lecture_canal_bil -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ecriture_canal_bil */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ecriture d'un canal d'une image bil */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ecriture_canal_bil(image1, canal, */ /* ------------------ premiere_ligne, */ -/* nombre_lignes_ecrire, */ -/* nombre_colonnes_ecrire,*/ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a ecrire */ -/* premiere_ligne (E) (int) : premiere ligne a ecrire ds l'image */ -/* nombre_lignes_ecrire (E) (int) : nombre de lignes a ecrire */ -/* nombre_colonnes_ecrire(E) (int) : nombre de lignes a ecrire */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels ecris alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_ecriture_canal_bil (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_OK_KO cai_ecriture_canal_bil (CAI_IMAGE *image1 , - int *canal , - int *premiere_ligne , - int *nombre_lignes_ecrire , - int *nombre_colonnes_ecrire, - unsigned char *data_image ) - -{ -long position_first_lig; /* position de la 1ere ligne a ecrire */ -long position_courante; /* position courante dans le fichier */ -long deplacement; /* deplacement a effectuer */ -int i_ligne; /* compteur de lignes */ -unsigned char *buff_lig; /* tableau contenant une ligne a ecrire */ -long cr_write; /* code retour de write */ -int num; /* descripteur de fichier */ -int nboct_pix; /* nombre d'octets par pixel */ -int nb_canaux; /* nombre de canaux de l'image totale */ - -/* ................ - Initialisations - .................*/ - -i_ligne = 0; -num = image1->ACCES_CANAL_INT[*canal-1]; -nboct_pix = image1->NBOCT_PIX; -nb_canaux = image1->NB_CANAUX; -position_first_lig = 0; -position_courante = 0; -deplacement = 0; - -/********************************************************/ -/* Calcul de la position de la premiere ligne a ecrire */ -/********************************************************/ -/*****************************************************************************/ -/* MOD : VERSION : 4.6 : FA : pb ouverture en modification et ecriture */ -/* Modification pour compatibilite ouverture en modification */ -/*****************************************************************************/ -position_first_lig = (long) ( image1->POS_OCTET[*canal-1] + - (*premiere_ligne - 1) * (*nombre_colonnes_ecrire) * nboct_pix * nb_canaux ); - - -/********************************************************/ -/* Recuperation de la position courante */ -/********************************************************/ - -position_courante = lseek ( num , 0L , 1 ); - - -/********************************************************/ -/* Calcul du deplacement jusqu'a la 1ere ligne a ecrire */ -/********************************************************/ - -deplacement = position_first_lig - position_courante; - - -/********************************************************/ -/* TANT QUE il y a des lignes a ecrire */ -/********************************************************/ -while (i_ligne < (*nombre_lignes_ecrire)) -{ - -/********************************************************/ -/* extraction de la ligne du tableau */ -/********************************************************/ - - buff_lig = data_image + (*nombre_colonnes_ecrire) * nboct_pix * i_ligne; - -/********************************************************/ -/* deplacement jusqu'a la ligne a ecrire */ -/********************************************************/ - - lseek ( num , deplacement , 1 ); - -/********************************************************/ -/* ecriture de la ligne */ -/********************************************************/ - - cr_write = write ( num , buff_lig,(*nombre_colonnes_ecrire)*nboct_pix ); - if ( cr_write != (*nombre_colonnes_ecrire)*nboct_pix ) - { - strcpy ( CAI_ERREUR , "Erreur ecriture canal image bil\n" ); - goto ERREUR; - } - -/********************************************************/ -/* mise a jour du deplacement jusqu'a la ligne */ -/* suivante */ -/********************************************************/ - - deplacement = ( nb_canaux - 1 ) * (*nombre_colonnes_ecrire)*nboct_pix; - -/********************************************************/ -/* incrementation du nombre de lignes */ -/********************************************************/ - - i_ligne++; - -/********************************************************/ -/* FIN TANT QUE */ -/********************************************************/ -} - - -return (CAI_OK); - -ERREUR : - -return (CAI_KO); - - -} -/* - Fin de l'operation cai_ecriture_canal_bil -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ferme_bil */ -/* ---------- */ -/* */ -/* ROLE : fonction de fermeture d'une image au format bil et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ferme_bil(image1) */ /* ------------------ */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* */ -/* cai_ferme_bil (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_OK_KO cai_ferme_bil (CAI_IMAGE *image1) - - -{ - - int iret; /* code retour de l'operation */ - int i_can; /* indice du canal a fermer */ - int num; /* descripteur du fichier a fermer */ - - iret=CAI_OK; -/*............................................. - Fermeture du fichier qui contient tous les canaux - .............................................*/ - num=image1->ACCES_CANAL_INT[0]; - if (num>0) close(num); - - - return (iret); -} - -/* - Fin de l'operation cai_ferme_bil -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_dest_ima_bil */ -/* ---------- */ -/* */ -/* ROLE : fonction de destruction d'une image stocke en bil et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_dest_ima_bil(repertoire,nom_ima) */ /* ------------------ */ -/* repertoire (E) (char *) : repertoire de l'image a detruire */ -/* nom_image (E) (char *) : nom de l'image a detruire avec repertoire */ -/* */ -/* cai_dest_ima_bil (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - - -CAI_OK_KO cai_dest_ima_bil ( char *repertoire , - char *nom_ima ) - - -{ -int i_can; /* compteur de canaux */ -int iret; /* code retour fonction fermetrue lecture */ -char str_num_canal[3]; /* suffixe numero du canal */ -char nom_fic_entete[1024]; /* nom du fichier entete a detruire */ -char nom_ima_complet[1024]; /* repertoire + nom de l'image */ -char nom_fic_canal[1024]; /* nom du fichier canal a detruire */ - -int cr_stat; /* code retour de fonction status de fichier */ -struct stat buf_stat; /* structure decrivant status de fichier */ - -CAI_IMAGE *image1; /* structure ouverture image */ -int nb_can; /* nombre de canaux de l'image */ -int nboct_pix; /* nombre d'octets par pixel image */ -int nb_col; /* nombre de colonnes de l'image */ -int nb_lig; /* nombre de lignes de l'image */ - -/************************************************/ -/* Constitution du nom du fichier d'entete */ -/************************************************/ - -if ((long)strlen(repertoire)!= 0) -{ - sprintf ( nom_ima_complet ,"%s/%s", repertoire ,nom_ima); -} -else -{ - strcpy ( nom_ima_complet , nom_ima); -} - sprintf(nom_fic_entete ,"%s.bil_hd", nom_ima_complet); - -/************************************************/ -/* Destruction du fichier d'entete */ -/************************************************/ - -cr_stat = stat ( nom_fic_entete , &buf_stat ); -if ( cr_stat == 0 ) - unlink ( nom_fic_entete ); -else -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : prise en compte des extensions en majuscule */ -/*****************************************************************************/ -{ - sprintf(nom_fic_entete ,"%s.BIL_HD", nom_ima_complet); - cr_stat = stat ( nom_fic_entete , &buf_stat ); - if ( cr_stat == 0 ) - unlink ( nom_fic_entete ); - -} - -/************************************************/ -/* Destruction du fichier radiometrie */ -/************************************************/ -sprintf(nom_fic_entete ,"%s.bil", nom_ima_complet); -cr_stat = stat ( nom_fic_entete , &buf_stat ); -if ( cr_stat == 0 ) - unlink ( nom_fic_entete ); -else -{ -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : prise en compte des extensions en majuscule */ -/*****************************************************************************/ - - sprintf(nom_fic_entete ,"%s.BIL", nom_ima_complet); - cr_stat = stat ( nom_fic_entete , &buf_stat ); - if ( cr_stat == 0 ) - unlink ( nom_fic_entete ); - -} - - -return (CAI_OK); - -} -/* - Fin de l'operation cai_dest_ima_bil -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_modif_nbbitspix_bil */ -/* ---------- */ -/* */ -/* ROLE : permet de modifier le nombre de bits significatifs par pixel */ -/* ----- dans l'entete de fichier (.hd) */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_modif_nbbitspix_bil(image1,NbBitsPix) */ /* ------------------ */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* NbBitsPix (E) (int) : nb de bits significatifs par pixel */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_OK_KO cai_modif_nbbitspix_bil(CAI_IMAGE *image1,int NbBitsPix) - -{ - int Can; /* indice de boucle sur les canaux */ - char fichierE[1024]; /* fichier a traiter */ - char Command[1024]; /* Commande a envoyer au systeme */ - FILE *fic; /* pointeur descripteur fichier */ - int pt_oct; /* position courante ds le fichier */ - int *Ref; /* Reference du SDS des fichiers */ - char label[80]; /* contient un enregist fichier */ - char repert[1024]; /* repertoire de stockage image */ - char image[1024]; /* nom de l'image a ouvrir */ - char car; /* variable de travail */ - int icr,tempo; /* code retour fonction */ - CAI_CHAINE *NomIma; - int retour; - - -/* Ouverture du fichier d'entete */ - - fichierE[0]='\0'; - sprintf(fichierE,"%s.bil_hd",image1->NOM_IMAGE); - fic = fopen(fichierE,"w"); - if (fic == NULL) - { -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : prise en compte des extensions en majuscule */ -/*****************************************************************************/ - fichierE[0]='\0'; - sprintf(fichierE,"%s.BIL_HD",image1->NOM_IMAGE); - fic = fopen(fichierE,"w"); - if (fic == NULL) - { - - sprintf(CAI_ERREUR, - "Erreur: Modification fichier %s impossible\n",fichierE); - goto ERREUR; - } - } - -/* Modification du fichier d'entete */ - rewind(fic); - fprintf ( fic , "COMMENT\n"); - fprintf ( fic , "%s\n" ,image1->COMMENT); - fprintf ( fic , "CHANNELS\n" ); - fprintf ( fic , "%3d\n" , image1->NB_CANAUX); - fprintf ( fic , "LINES\n" ); - fprintf ( fic , "%5d\n" , image1->NB_LIG); - fprintf ( fic , "COLUMNS\n" ); - fprintf ( fic , "%5d\n" , image1->NB_COL ); - fprintf ( fic , "BITS PER PIXEL\n" ); - fprintf ( fic , "%2d\n" , NbBitsPix ); - fprintf ( fic , "TYPE\n"); - fprintf ( fic , "%s\n",image1->COD_PIX ); - fprintf ( fic, "SENSCODAGE\n"); - retour=strncmp((char *)image1->SENS_COD,"BE",2); - if (retour == 0) - fprintf ( fic , "IEEE\n" ); - else - fprintf ( fic , "INTEL\n" ); - - fclose ( fic ); - - return(CAI_OK); - -ERREUR : - return(CAI_KO); -} -/* - Fin de l'operation cai_modif_nbbitspix_bil -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_modifie_bil */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lec-ecr d'une image au format bil */ -/* ----- et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_modifie_bil(nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_modifie_bil (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ /* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_IMAGE *cai_ouvre_modifie_bil(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) -{ - FILE *fic_in; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - int iret; /* indicateur de retour ok ou pas */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char nom_fic_canal[1024]; /* nom fichier canal dont on teste existence*/ - char label[80]; /* contient un enregistrement du fichier */ - int nbbit; /* nb de bits par pixel du fichier en-tete */ - int retour; /* retour de la fonction comparaison chaines*/ - char *deb,*deb1,*pch0; /* pointeurs sur chaine de caracteres */ - int i,num; /* indice */ - int nbplan; /* nombre de canaux dans le fichier en-tete */ - char COD_PIX[80]; /* type de codage du pixel (optionnel) */ - struct stat buf_stat; /* structure decrivant status de fichier */ - char *type_machine; /* ordre rangement octets machine de travail*/ - int cmp; /* retour de comparaison de chaine */ - int reconnaissance_type; - - /*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - *nb_can=0; - - *nb_lig=0; - - *nb_col=0; - - *nboct_pix=0; - - iret=1; - pch0=NULL; - reconnaissance_type = -1; - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); - - /*.................................. - determination ordre de rangement - des octets sur machine de travail - ......................................*/ - type_machine = cai_test_pFpf(); - -/*****************************************************************************/ -/* MOD : VERSION : 4.1: FA :Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_modifie"); - } - else - { -/*................................................. - Constitution du nom du fichier entete - .................................................*/ - nom_fic[0]='\0'; - if((long int)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s.bil_hd",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.bil_hd",nom_image); - } - -/*........................ - Ouverture du fichier entete - ..........................................*/ - fic_in=NULL; - fic_in=fopen(nom_fic,"r"); - if (fic_in==NULL) - { -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : prise en compte des extensions en majuscule */ -/*****************************************************************************/ - nom_fic[0]='\0'; - if((long int)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s.BIL_HD",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.BIL_HD",nom_image); - } - fic_in=fopen(nom_fic,"r"); - if (fic_in==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur ouverture fichier entete BIL-CNES"); - } - } - if (iret !=0) - { -/*.................................... - Decodage du commentaire - ......................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"COMMENT",7); - if (retour!=0) - { - strcpy(CAI_ERREUR,"Informations incoherentes ligne COMMENT"); - iret=0; - } - else - { - fgets(image1->COMMENT,80,fic_in); - - - /*........................................ - Decodage du nombre de canaux - .........................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"CHANNELS",8); - if (retour!=0) - { - strcpy(CAI_ERREUR,"Informations incoherentes ligne CHANNELS"); - iret=0; - } - else - { - fscanf(fic_in,"%d\n",&nbplan); - *nb_can=nbplan; - -/*....................................... - Decodage du nombre de lignes - ........................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"LINES",5); - if (retour!=0) - { - strcpy(CAI_ERREUR,"Informations incoherentes ligne LINES"); - iret=0; - } - else - { - fscanf(fic_in,"%d\n",nb_lig); - - -/*....................................... - Decodage du nombre de colonnes - ........................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"COLUMNS",7); - if (retour!=0) - { - strcpy(CAI_ERREUR,"Informations incoherentes ligne COLUMNS"); - iret=0; - } - else - { - - fscanf(fic_in,"%d\n",nb_col); - -/*....................................... - Decodage du nombre de bits par pixel - ........................................*/ - fgets(label,80,fic_in); - retour=strncmp(label,"BITS PER PIXEL",14); - if (retour!=0) - { - strcpy(CAI_ERREUR,"Informations incoherentes ligne BITS "); - iret=0; - } - else - { - fscanf(fic_in,"%d\n",&nbbit); - -/*........................................................ - Decodage du type de codage du pixel (optionnel) - ........................................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"TYPE",4); - if (retour==0) - { - fscanf(fic_in,"%s\n",COD_PIX); - retour=1; - } - else - sprintf(COD_PIX,"UND"); - - pch0=cai_En_majuscule( COD_PIX ); - -/* Verification si type de codage reconnu */ - reconnaissance_type = cai_istyp_connu(pch0); -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : prise en compte de l'information INTEL ou IEEE*/ -/* en lecture et ecriture dans l'entete .hd */ -/*****************************************************************************/ - if (retour !=0) fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"SENSCODAGE",10); - if (retour!=0) - { -/* Si absent, pas d'inversion */ - image1->INV_OCTETS =0; - sprintf(image1->SENS_COD,type_machine); - } - else - { - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"IEEE",4); - if (retour==0) - sprintf(image1->SENS_COD,"BE"); - else - sprintf(image1->SENS_COD,"LE"); - cmp = strncmp(type_machine,image1->SENS_COD,2); - if (cmp!=0) - image1->INV_OCTETS =1; - else - image1->INV_OCTETS =0; - } - - } - } - } - } - } - } -/*.................................. - Fermeture du fichier - ......................................*/ - if (fic_in !=NULL) fclose(fic_in); - - if (iret !=0) - { -/*.................................. - Initialisation du nombre d'octets par pixel - ........................................................*/ - if ((nbbit%8)==0) - *nboct_pix=(int)(nbbit/8); - else - *nboct_pix=(int)((nbbit/8)+1); - - if (reconnaissance_type != -1) - { - sprintf(image1->COD_PIX,"%s",COD_PIX); - } - else - { - sprintf(image1->COD_PIX,"UND"); - - if (*nboct_pix==1) - sprintf(image1->COD_PIX,"OCT"); - else if (*nboct_pix==2) - sprintf(image1->COD_PIX,"I2"); - else if (*nboct_pix==4) - { - retour=strncmp(COD_PIX,"I4",2); - if (retour==0) - sprintf(image1->COD_PIX,"I4"); - else - { - retour=strncmp(COD_PIX,"R4",2); - if (retour==0) - sprintf(image1->COD_PIX,"R4"); - } - } - else if (*nboct_pix==8) - { - sprintf(image1->COD_PIX,"R8"); - } - } - -/*....................................... - INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL - .....................................................*/ - - nom_fic[0]='\0'; - nom_fic_canal[0]='\0'; - - if((long int)strlen(repert)!=0) - { - sprintf(nom_fic_canal,"%s/%s.bil",repert,nom_image); - } - else - { - sprintf(nom_fic_canal,"%s.bil",nom_image); - } -/*****************************************************************************/ -/* MOD : VERSION : 4.4 : FA : prise en compte des extensions en majuscule */ -/*****************************************************************************/ - retour = stat ( nom_fic_canal , &buf_stat ); - if ( retour != 0 ) - { - if((long int)strlen(repert)!=0) - { - sprintf(nom_fic_canal,"%s/%s.BIL",repert,nom_image); - } - else - { - sprintf(nom_fic_canal,"%s.BIL",nom_image); - } - } - deb = image1->NOM_FIC_CAN; - deb1= image1->NOM_UTIL_CAN; - num=open(nom_fic_canal,O_RDWR|O_BINARY,0); - if (num!= -1) - { - - for (i=0;i<*nb_can;i=i+1) - { - sscanf(nom_image,"%s",deb); - deb=deb+100; - sscanf(nom_image,"%s",deb1); - deb1=deb1+100; - image1->ACCES_CANAL_INT[i]=num; - image1->POS_OCTET[i]=(*nb_col)*i*(*nboct_pix); - } - } - else - iret=0; - } - } - if (iret == 0) - { - return (NULL); - } - else - { - return(image1); - } - -} - -/* - Fin de l'operation cai_ouvre_modifie_bil -*/ diff --git a/Utilities/CAI/cai_dll/src/cai_bip.c b/Utilities/CAI/cai_dll/src/cai_bip.c deleted file mode 100755 index 6d7c52008956945a8f733b922209e5a386a0af95..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/src/cai_bip.c +++ /dev/null @@ -1,1807 +0,0 @@ -/*****************************************************************************/ -/* */ -/* PROJET : COUCHE ACCES IMAGE */ -/* ------- */ -/* */ -/* MODULE : cai_bip.c */ -/* ------- */ -/* */ -/* ROLE : Ce module rassemble toutes les fonctions d'acces aux images */ -/* ------- stockees au format bip */ -/* */ -/* AUTEUR : R.CHAISEMARTIN (CISI) */ -/* ------- */ -/* */ -/* DATE DE CREATION : Mai 1996 */ -/* ----------------- */ -/* */ -/* LANGAGE : C */ -/* -------- */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ -/* MOD : VERSION : 3.3 : DM : optimisation des acces */ -/*****************************************************************************/ -/* MOD : VERSION : 4.1 : FA:Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : FA : modifications pour compatibilite HP64bits */ -/*****************************************************************************/ -/* MOD : VERSION : 4.4 : DM : prise en compte des extensions en majuscule */ -/*****************************************************************************/ -/* MOD : VERSION : 4.5 : FA : test sur fclose pour PC/LINUX */ -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : prise en compte des I2,I4,UI2,UI4 et R8 */ -/* en lecture et ecriture */ -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : prise en compte de l'information INTEL ou IEEE*/ -/* en lecture et ecriture dans l'entete .hd */ -/*****************************************************************************/ - -/*---------------------------------------------------------------------------*/ -/* Inclusion des fichiers STANDARDS (.h) */ -/*---------------------------------------------------------------------------*/ - - -# include <stdio.h> -# include <string.h> -# include <stdlib.h> -# include <unistd.h> -# include <sys/types.h> -#include <dirent.h> -# include <sys/stat.h> -# include <fcntl.h> -#include <errno.h> - -#define _CAI_IMAGE -#define IN_CAI_BIP - -# include "cai_image.h" - -/*----------------------------------------------------------------------------*/ -/* Variable pour la gestion en configuration */ -/*----------------------------------------------------------------------------*/ -static char *rcs_id="$Header: cai_bip.c,v 1.11 01/05/31 10:46:56 cmf Exp $"; - - -extern char *getenv(); - - -/*****************************************************************************/ -/*****************************************************************************/ -/* */ -/* Definition des OPERATIONS EXTERNES */ -/* */ -/*****************************************************************************/ -/*****************************************************************************/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_liste_ima_bip */ -/* ---------- */ -/* */ -/* ROLE : fonction de listage des images au format bip */ -/* ------ */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : int cai_liste_ima_bip(repert,tab_ima) */ -/* ----------------- */ -/* */ -/* repert (E) (char *) : repertoire a explorer */ -/* tab_ima (S) (char ***) : pointeur sur tableau des images listees */ -/* alloue par la fonction,il doit etre */ -/* LIBERE PAR L'APPELANT */ -/* */ -/* cai_liste_ima_bip (S) (int) : = -1 repertoire inexistant */ /* = > 0 nombre d'images listees */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -long int cai_liste_ima_bip (char *repert, - char ***tab_ima) - -{ - - DIR *dirp; /* pointeur sur structure ouverture repertoire */ - struct dirent *dp; /* structure resultat de la fonction readdir */ - char *pch0,*pch1; /* pointeurs sur chaine de caracteres */ - int nb_ima; /* nombre d'images bip identifiees */ - int i; /* indice de boucle */ - long int ll,dif; /* variables de travail */ - char blanc; /* caractere blanc */ - - -/*........................................ - INITIALISATION et ouverture du repertoire choisi - .........................................*/ - nb_ima=0; - dirp=opendir(repert); - blanc = ' '; - - if(dirp!=NULL) - { - - -/*...................................... - - premiere passe pour comptabiliser les images du format donne - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE BIP_CNES - (EXTENSION =.bip) - ..........................................*/ - while((dp=readdir(dirp))!=NULL) - { - pch0=strstr(dp->d_name,".bip"); - if (pch0 != NULL) - { - ll = (long int)strlen(dp->d_name); - dif = (long int)(dp->d_name-pch0); - dif=labs(dif); - pch1=pch0+4; - if (((ll-4)==dif)||((*pch1)==blanc)) - nb_ima=nb_ima+1; - - } -/*****************************************************************************/ -/* MOD : VERSION : 4.4 : DM : prise en compte des extensions en majuscule */ -/*****************************************************************************/ - else - { - pch0=strstr(dp->d_name,".BIP"); - if (pch0 != NULL) - { - ll = strlen(dp->d_name); - dif = (long int)(dp->d_name-pch0); - dif=labs(dif); - pch1=pch0+4; - if (((ll-4)==dif)||((*pch1)==blanc)) - nb_ima=nb_ima+1; - } - } - - } - - (void)closedir(dirp); - -/*..................................... - ALLOCATION DU TABLEAU CONTENANT LA LISTE DES IMAGES DU FORMAT BIP - ......................................*/ - *tab_ima = (char **) calloc(nb_ima,sizeof(char *)); - for (i=0;i<nb_ima;i=i+1) - (*tab_ima)[i]=(char *)calloc(1,100); - -/*...................................... - - deuxieme passe pour constituer la liste des images du format donne - - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE BIP_CNES - (EXTENSION =.bip) - SI C`EST LE CAS,STOCKAGE DANS LA LISTE - ..........................................*/ - dirp=opendir(repert); - - nb_ima=0; - while((dp=readdir(dirp))!=NULL) - { - pch0=strstr(dp->d_name,".bip"); - if (pch0 != NULL) - { - ll = (long int)strlen(dp->d_name); - dif = (long int)(dp->d_name-pch0); - dif=labs(dif); - pch1=pch0+4; - if (((ll-4)==dif)||((*pch1)==blanc)) - { - *pch0='\0'; - strcpy((*tab_ima)[nb_ima],dp->d_name); - nb_ima=nb_ima+1; - } - - } -/*****************************************************************************/ -/* MOD : VERSION : 4.4 : DM : prise en compte des extensions en majuscule */ -/*****************************************************************************/ - else - { - pch0=strstr(dp->d_name,".BIP"); - if (pch0 != NULL) - { - ll = strlen(dp->d_name); - dif = (long int)(dp->d_name-pch0); - dif=labs(dif); - pch1=pch0+4; - if (((ll-4)==dif)||((*pch1)==blanc)) - nb_ima=nb_ima+1; - } - } - - } - - (void)closedir(dirp); - - - } - else - { - /* repertoire inexistant */ - nb_ima=-1; - } - return(nb_ima); - -} - -/* Fin de l'operation cai_liste_ima_bip -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_lecture_bip */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture d'une image au format bip */ -/* ----- et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_lecture_bip (nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_lecture_bip (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ /* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_IMAGE *cai_ouvre_lecture_bip(char *repert, - char * nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) -{ - FILE *fic_in; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - int iret; /* indicateur de retour ok ou pas */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char nom_fic_canal[1024]; /* nom fichier canal dont on teste existence*/ - char label[80]; /* contient un enregistrement du fichier */ - int nbbit; /* nb de bits par pixel du fichier en-tete */ - int retour; /* retour de la fonction comparaison chaines*/ - char *deb,*deb1,*pch0; /* pointeurs sur chaine de caracteres */ - int i,num; /* indice */ - int nbplan; /* nombre de canaux dans le fichier en-tete */ - char COD_PIX[80]; /* type de codage du pixel (optionnel) */ - struct stat buf_stat; /* structure decrivant status de fichier */ - char *type_machine; /* ordre rangement octets machine de travail*/ - int cmp; /* retour de comparaison de chaine */ - int reconnaissance_type; - - /*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - *nb_can=0; - - *nb_lig=0; - - *nb_col=0; - - *nboct_pix=0; - - iret=1; - - /*.................................. - determination ordre de rangement - des octets sur machine de travail - ......................................*/ - type_machine = cai_test_pFpf(); - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); -/*****************************************************************************/ -/* MOD : VERSION : 4.1: FA Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_lecture"); - } - else - { - -/*................................................. - Constitution du nom du fichier entete - .................................................*/ - nom_fic[0]='\0'; - if ((long int)strlen(repert)!= 0) - { - sprintf(nom_fic,"%s/%s.bip_hd",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.bip_hd",nom_image); - } - -/*........................ - Ouverture du fichier entete - ..........................................*/ - fic_in=NULL; - fic_in=fopen(nom_fic,"r"); - if (fic_in==NULL) - { -/*****************************************************************************/ -/* MOD : VERSION : 4.4 : DM : prise en compte des extensions en majuscule */ -/*****************************************************************************/ - nom_fic[0]='\0'; - if((long int)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s.BIP_HD",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.BIP_HD",nom_image); - } - fic_in=fopen(nom_fic,"r"); - if (fic_in==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur ouverture fichier entete BIP-CNES"); - } - } - if (iret !=0) - { -/*.................................... - Decodage du commentaire - ......................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"COMMENT",7); - if (retour!=0) - { - strcpy(CAI_ERREUR,"Informations incoherentes ligne COMMENT"); - iret=0; - } - else - { - fgets(image1->COMMENT,80,fic_in); - - - /*........................................ - Decodage du nombre de canaux - .........................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"CHANNELS",8); - if (retour!=0) - { - strcpy(CAI_ERREUR,"Informations incoherentes ligne CHANNELS"); - iret=0; - } - else - { - fscanf(fic_in,"%d\n",&nbplan); - *nb_can=nbplan; - -/*....................................... - Decodage du nombre de lignes - ........................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"LINES",5); - if (retour!=0) - { - strcpy(CAI_ERREUR,"Informations incoherentes ligne LINES"); - iret=0; - } - else - { - fscanf(fic_in,"%d\n",nb_lig); - - -/*....................................... - Decodage du nombre de colonnes - ........................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"COLUMNS",7); - if (retour!=0) - { - strcpy(CAI_ERREUR,"Informations incoherentes ligne COLUMNS"); - iret=0; - } - else - { - - fscanf(fic_in,"%d\n",nb_col); - -/*....................................... - Decodage du nombre de bits par pixel - ........................................*/ - fgets(label,80,fic_in); - retour=strncmp(label,"BITS PER PIXEL",14); - if (retour!=0) - { - strcpy(CAI_ERREUR,"Informations incoherentes ligne BITS "); - iret=0; - } - else - { - fscanf(fic_in,"%d\n",&nbbit); - -/*........................................................ - Decodage du type de codage du pixel (optionnel) - ........................................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"TYPE",4); - if (retour==0) - { - fscanf(fic_in,"%s\n",COD_PIX); - retour=1; - } - else - sprintf(COD_PIX,"UND"); - pch0=cai_En_majuscule( COD_PIX ); - -/* Verification si type de codage reconnu */ - reconnaissance_type = cai_istyp_connu(pch0); -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : prise en compte de l'information INTEL ou IEEE*/ -/* en lecture et ecriture dans l'entete .hd */ -/*****************************************************************************/ - if (retour !=0) fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"SENSCODAGE",10); - if (retour!=0) - { -/* Si absent, pas d'inversion */ - image1->INV_OCTETS =0; - sprintf((char *)image1->SENS_COD,type_machine); - } - else - { - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"IEEE",4); - if (retour==0) - sprintf((char *)image1->SENS_COD,"BE"); - else - sprintf((char *)image1->SENS_COD,"LE"); - cmp = strncmp(type_machine,image1->SENS_COD,2); - if (cmp!=0) - image1->INV_OCTETS =1; - else - image1->INV_OCTETS =0; - } - } - } - } - } - } - } -/*.................................. - Fermeture du fichier - ......................................*/ - if (fic_in !=NULL) fclose(fic_in); - - if (iret !=0) - { -/*.................................. - Initialisation du nombre d'octets par pixel - ........................................................*/ - if ((nbbit%8)==0) - *nboct_pix=(int)(nbbit/8); - else - *nboct_pix=(int)((nbbit/8)+1); - image1->NB_BITS_PIX=nbbit; - - if (reconnaissance_type != -1) - { - sprintf(image1->COD_PIX,"%s",COD_PIX); - } - else - { - sprintf(image1->COD_PIX,"UND"); - - if (*nboct_pix==1) - sprintf(image1->COD_PIX,"OCT"); - else if (*nboct_pix==2) - sprintf(image1->COD_PIX,"I2"); - else if (*nboct_pix==4) - { - retour=strncmp(COD_PIX,"I4",2); - if (retour==0) - sprintf(image1->COD_PIX,"I4"); - else - { - retour=strncmp(COD_PIX,"R4",2); - if (retour==0) - sprintf(image1->COD_PIX,"R4"); - } - } - else if (*nboct_pix==8) - { - sprintf(image1->COD_PIX,"R8"); - } - } - -/*....................................... - INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL - .....................................................*/ - - nom_fic[0]='\0'; - nom_fic_canal[0]='\0'; - - if ((long int)strlen(repert)!= 0) - { - sprintf(nom_fic_canal,"%s/%s.bip",repert,nom_image); - } - else - { - sprintf(nom_fic_canal,"%s.bip",nom_image); - } -/*****************************************************************************/ -/* MOD : VERSION : 4.4 : FA : prise en compte des extensions en majuscule */ -/*****************************************************************************/ - retour = stat ( nom_fic_canal , &buf_stat ); - if ( retour != 0 ) - { - if((long int)strlen(repert)!=0) - { - sprintf(nom_fic_canal,"%s/%s.BIP",repert,nom_image); - } - else - { - sprintf(nom_fic_canal,"%s.BIP",nom_image); - } - } - - deb = image1->NOM_FIC_CAN; - deb1= image1->NOM_UTIL_CAN; - num=open(nom_fic_canal,O_RDONLY|O_BINARY,0); - if (num!= -1) - { - - for (i=0;i<*nb_can;i=i+1) - { - sscanf(nom_image,"%s",deb); - deb=deb+100; - sscanf(nom_image,"%s",deb1); - deb1=deb1+100; - image1->ACCES_CANAL_INT[i]=num; - image1->POS_OCTET[i]=0; - } - } - else - iret=0; - } - } - if (iret == 0) - { - return (NULL); - } - else - { - return(image1); - } - -} - -/* - Fin de l'operation cai_ouvre_lecture_bip -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_creation_bip */ -/* ---------- */ -/* */ -/* ROLE : fonction de creation et d'ouverture en ecriture d'une image */ -/* ----- au format bip et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_creation_bip (nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig, */ -/* label) */ -/* */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* nb_can (E) (int ) : nombre de canaux de l'image */ -/* nboct_pix (E) (int ) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (E) (int ) : nombre de lignes de l'image */ -/* nb_col (E) (int ) : nombre de colonnes de l'image */ -/* label (E) (char *) : commentaire lie a l'image */ -/* */ -/* cai_ouvre_creation_bip (S) (CAI_IMAGE *) : =NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_IMAGE *cai_ouvre_creation_bip(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig, - char *label) -{ - FILE *fic; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char nom_fic_canal[1024]; /* nom fichier canal dont on teste existence*/ - int retour; /* retour de fonction */ - int i,num,Coher; /* indice */ - struct stat buf_stat; /* structure decrivant status de fichier */ - char *type_machine; /* ordre rangement octets machine de travail*/ - int reconnaissance_type; - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); -/*****************************************************************************/ -/* MOD : VERSION : 4.1: FA Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_creation"); - goto ERREUR; - } - -/*.................................. - determination ordre de rangement - des octets sur machine de travail - ......................................*/ - type_machine = cai_test_pFpf(); - -/*................................................. - Constitution du nom du fichier entete et verification qu'il - n'existe pas deja - .................................................*/ - - nom_fic[0]='\0'; - if ((long int)strlen(repert)!= 0) - { - sprintf(nom_fic,"%s/%s.bip_hd",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.bip_hd",nom_image); - } - - retour = stat ( nom_fic , &buf_stat ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "L'image %s BIP existe \n" , nom_image ); - goto ERREUR; - } - -/*............................................................... - constitution du nom de fichier correspondant a la radiometrie de l'image - Verification qu'il n'existe pas deja - Ouverture du fichier en ecriture - .................................................................*/ - - nom_fic_canal[0]='\0'; - sscanf(nom_fic,"%s",nom_fic_canal); - nom_fic_canal[strlen(nom_fic_canal)-3]='\0'; - retour = stat ( nom_fic_canal , &buf_stat ); - - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "L'image %s BIP existe \n" , nom_image ); - goto ERREUR; - } - - num = open(nom_fic_canal,O_RDWR|O_CREAT|O_BINARY,PERMS); - if (num == -1) - { - - sprintf(CAI_ERREUR,"Erreur: Creation %s impossible\n",nom_fic_canal); - goto ERREUR; - } - - for (i=0;i<*nb_can;i=i+1) - { - image1->ACCES_CANAL_INT[i]=num; - image1->POS_OCTET[i]=0; - } - -/*...................................................... - Ouverture du fichier entete en ecriture - Ecriture du contenu - ..........................................................*/ - fic = fopen(nom_fic,"w"); - if (fic == NULL) - { - sprintf(CAI_ERREUR,"Erreur: Creation fichier %s impossible\n",nom_fic); - goto ERREUR; - } - - retour=fprintf ( fic , "COMMENT\n"); - if (retour == 0) - { - sprintf(CAI_ERREUR,"Erreur: Ecriture %s impossible\n",nom_fic); - goto ERREUR; - } - - fprintf ( fic , "%s\n" , label ); - fprintf ( fic , "CHANNELS\n" ); - fprintf ( fic , "%3d\n" , *nb_can ); - fprintf ( fic , "LINES\n" ); - fprintf ( fic , "%5d\n" , *nb_lig ); - fprintf ( fic , "COLUMNS\n" ); - fprintf ( fic , "%5d\n" , *nb_col ); - fprintf ( fic , "BITS PER PIXEL\n" ); - fprintf ( fic , "%2d\n" , (*nboct_pix)*8 ); - fprintf ( fic , "TYPE\n"); -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : Maj du tag TYPE lorsque l'utilisateur le */ -/* precise dans le param "label" */ -/*****************************************************************************/ -/* Verification si type de codage reconnu dans le label */ - reconnaissance_type = cai_istyp_connu(label); - if (reconnaissance_type == -1) - { - if (*nboct_pix==1) - sprintf ( image1->COD_PIX , "OCT" ); - else if (*nboct_pix==2) - sprintf ( image1->COD_PIX , "I2" ); - else if (*nboct_pix==4) - { -/*****************************************************************************/ -/* MOD : VERSION : 5.1 : DM : Maj du tag TYPE lorsque l'image est codée */ -/* en reel et que l'utilisateur le precise dans le param "label" */ -/*****************************************************************************/ - if ((strcasecmp(label,"R4") == 0)|| - (strcasecmp(label,"FLOAT")== 0)|| - (strcasecmp(label,"REEL") == 0)) - sprintf ( image1->COD_PIX , "R4" ); - else - sprintf ( image1->COD_PIX , "I4" ); - } - else if (*nboct_pix==8) - sprintf ( image1->COD_PIX , "R8" ); - else - sprintf ( image1->COD_PIX , "UND" ); - fprintf ( fic , "%s\n",image1->COD_PIX ); - } - else - { -/* Verification de coherence entre le nb d'octets par pixel et le type donne */ - Coher=1; - if(*nboct_pix == 1) - if (reconnaissance_type > 1) Coher=0; - else if(*nboct_pix == 2) - if ((reconnaissance_type != 2) || (reconnaissance_type != 3)) Coher=0; - else if(*nboct_pix == 4) - if ((reconnaissance_type <4) || (reconnaissance_type > 6)) Coher=0; - else if(*nboct_pix == 8) - if (reconnaissance_type != 7) Coher=0; - else - Coher = 0; - if (Coher == 0) - { - sprintf(CAI_ERREUR,"incoherence entre TYPE et Nb bits par pixels\n"); - goto ERREUR; - } - else - { - sprintf ( image1->COD_PIX , "%s" ,label); - fprintf ( fic , "%s\n", label ); - } - } - fprintf ( fic , "SENSCODAGE\n" ); - retour=strncmp(type_machine,"BE",2); - sprintf((char *)image1->SENS_COD,"%s",type_machine); - if (retour == 0) - fprintf ( fic , "IEEE\n" ); - else - fprintf ( fic , "INTEL\n" ); - -/*************************************************/ -/* Fermeture du fichier */ -/*************************************************/ - - fclose ( fic ); - return (image1); - -ERREUR : - - if (fic !=NULL) cai_dest_ima_bip ( repert , nom_image ); - return(NULL); -} - -/* - Fin de l'operation cai_ouvre_creation_bip -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_lecture_canal_bip */ -/* ---------- */ -/* */ -/* ROLE : fonction de lecture d'un canal d'une image bip */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_lecture_canal_bip(image1, canal, */ /* ------------------ premiere_ligne, */ -/* premiere_colonne, */ -/* nombre_lignes_lire , */ -/* nombre_colonnes_lire, */ -/* pas_ligne ,pas_colonne, */ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a lire */ -/* premiere_ligne (E) (int) : premiere ligne a lire dans l'image */ -/* premiere _colonne (E) (int) : premiere colonne a lire dans l'image */ -/* nombre_lignes_lire (E) (int) : nombre de lignes a lire */ -/* nombre_colonnes_lire (E) (int) : nombre de colonnes a lire */ -/* pas_ligne (E) (int) : pas en ligne */ -/* pas_colonne (E) (int) : pas en colonne */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels lus alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_lecture_canal_bip (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - - -CAI_OK_KO cai_lecture_canal_bip(CAI_IMAGE *image1 , - int *canal , - int *premiere_ligne , - int *premiere_colonne, - int *nombre_lignes_lire , - int *nombre_colonnes_lire, - int *pas_ligne , - int *pas_colonne, - unsigned char *data_image ) -{ - - int num,i,j,k; /* variables de travail */ - long pt_oct; /* position courante dans le fichier image */ - long no_oct; /* numero du premier octet a lire */ - int iret; /* indicateur d'erreur */ - int lig; /* indice de boucle sur les lignes */ - int oct_pix; /* nb octets par pixels */ - long nb_oct; /* nb oct =1er octet a lire - position courante */ - int oct_lig; /* nb oct. par ligne en considerant taille pixel */ - int nbcan; /* nombre de canaux de l'image */ - unsigned char *buf_lec; /* buffer lecture d'une ligne */ - unsigned char *deb,*pch; /* pointeur chaine pour transfert buffer sortie */ - unsigned char *data_image2;/* pointeur donnees image pour inversion octets */ - int taille_image,Nb; /* taille en octets de l'image */ - long n; - -/*........................... - Initialisations diverses - ..........................*/ - - iret=CAI_OK; - num=image1->ACCES_CANAL_INT[(*canal)-1]; - oct_pix=image1->NBOCT_PIX; - nbcan = image1->NB_CANAUX; - oct_lig=oct_pix*nbcan*(image1->NB_COL); -/*.............................................. - allocation de memoire pour lire une ligne image - ............................................. */ - buf_lec = (unsigned char *) malloc(oct_lig); - if (buf_lec == NULL) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Probleme allocation memoire"); - } - else - { -/*.................... - Initialisation - ......................*/ - lig=*premiere_ligne; - i=1; - pch=data_image; - /*..................... - Pour chaque ligne a lire - .......................................*/ - while ((i <= (*nombre_lignes_lire))&&(iret==CAI_OK)) - { - -/*............................................ - Recherche de la position courante dans le fichier - ............................................*/ - pt_oct=(long int)lseek(num,0L,1); - -/*................................ - Calcul du numero du 1er octet a lire - ....................................*/ - no_oct=image1->POS_OCTET[(*canal)-1]+ - ((lig-1)*oct_lig); -/*.................................. - Saut d'octets pour etre positionne sur la ligne a lire - .......................................*/ - nb_oct=(long int)(no_oct-pt_oct); - lseek(num,nb_oct,1); - -/*........................................... - lecture d'une ligne image - ................................................*/ - n=read(num,buf_lec,oct_lig); - if (n<=0) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Erreur lecture donnee image BIP"); - } - else - { -/*...................................... - Sauvegarde des donnees lues entenant compte du pas - d'echantillonnage en colonne - ........................................*/ - deb=buf_lec+((*premiere_colonne)-1)*oct_pix*nbcan+ - ((*canal-1)*oct_pix); - j=1; - while (j <= (*nombre_colonnes_lire)) - { - - for (k=0;k<oct_pix;k=k+1) - { - *(pch+k)=*(deb+k); - } - pch=pch+oct_pix; - j=j+1; - deb=deb+((*pas_colonne)*oct_pix*nbcan); - } - - } - i=i+1; - lig=lig+(*pas_ligne); - - } - - free(buf_lec); - } - -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : prise en compte de l'information INTEL ou IEEE*/ -/* en lecture et ecriture dans l'entete .hd */ -/*****************************************************************************/ - - if ( (iret!= CAI_KO) && (image1->INV_OCTETS==1) && (oct_pix!=1) ) - { - taille_image = (*nombre_lignes_lire)*oct_pix*(*nombre_colonnes_lire); - data_image2 = NULL; - data_image2 = (unsigned char *) calloc(taille_image, - sizeof(unsigned char)); - if (data_image2 == NULL) - { - strcpy(CAI_ERREUR,"Erreur allocation memoire cai_lecture_canal"); - iret=CAI_KO; - } - else - { - /*modification ordre selon nb octets par pixel*/ - swab( (void*)(data_image), (void*)(data_image2), taille_image); - - if (oct_pix!=2) - { - Nb = taille_image/2; - cai_inverser_tableau(data_image, data_image2,Nb); - } - else - for (i=0; i<taille_image;i++) - { - /*stockage dans data_image*/ - data_image[i] = data_image2[i]; - } - - if (data_image2!= NULL) free(data_image2); - } - } - - return(iret); - } -/* - Fin de l'operation cai_lecture_canal_bip -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ecriture_canal_bip */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ecriture d'un canal d'une image bip */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ecriture_canal_bip(image1, canal, */ /* ------------------ premiere_ligne, */ -/* nombre_lignes_ecrire, */ -/* nombre_colonnes_ecrire,*/ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a ecrire */ -/* premiere_ligne (E) (int) : premiere ligne a ecrire ds l'image */ -/* nombre_lignes_ecrire (E) (int) : nombre de lignes a ecrire */ -/* nombre_colonnes_ecrire(E) (int) : nombre de lignes a ecrire */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels ecris alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_ecriture_canal_bip (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_OK_KO cai_ecriture_canal_bip (CAI_IMAGE *image1 , - int *canal , - int *premiere_ligne , - int *nombre_lignes_ecrire , - int *nombre_colonnes_ecrire, - unsigned char *data_image ) - -{ - -long position_first_lig; /* position de la 1ere ligne a ecrire */ -long position_courante; /* position courante dans le fichier */ -long deplacement; /* deplacement a effectuer */ -int i_ligne; /* compteur de lignes */ -unsigned char *buff_lig; /* tableau contenant une ligne a ecrire */ -long cr_write; /* code retour de write */ -int num; /* descripteur de fichier */ -int nboct_pix; /* nombre d'octets par pixel */ -int nbcan; /* nombre de canaux de l'image */ -int nboctet; /* nombre d'octets d'une ligne multi */ -unsigned char *deb,*pch; /* pointeur sur chaine pour transfert */ -int i,j,k; /* indice de boucle sur les colonnes */ -long cr_read; /* code retour de la fonction read */ - -/* initialisations */ - -i_ligne = 0; -num = image1->ACCES_CANAL_INT[*canal-1]; -nboct_pix = image1->NBOCT_PIX; -nbcan = image1->NB_CANAUX; -nboctet = (*nombre_colonnes_ecrire)*nbcan*nboct_pix; - -/********************************************************/ -/* Calcul de la position de la premiere ligne a ecrire */ -/********************************************************/ - -position_first_lig =(long) ( image1->POS_OCTET[(*canal)-1]+ - (( *premiere_ligne - 1) *nboctet)); - - -/********************************************************/ -/* Recuperation de la position courante */ -/********************************************************/ - -position_courante = lseek ( num , 0L , 1 ); - - -/********************************************************/ -/* Deplacement jusqu'a la premiere ligne a ecrire */ -/********************************************************/ - -deplacement = position_first_lig - position_courante; -lseek ( num , deplacement , 1 ); - -buff_lig=(unsigned char *)(calloc(nboctet,sizeof(unsigned char))); -if (buff_lig == NULL) -{ - strcpy(CAI_ERREUR,"Probleme d'allocation memoire ecriture"); - goto ERREUR; - } - -pch=data_image; - - -/********************************************************/ -/* TANT QUE il y a des lignes a ecrire */ -/********************************************************/ -while (i_ligne < (*nombre_lignes_ecrire)) -{ - cr_read=read(num,buff_lig,nboctet); - if (cr_read <0) - { - strcpy ( CAI_ERREUR , "Erreur ecriture canal image BIP\n" ); - goto ERREUR; - } - else - { - if (cr_read==0) - { - for (i=0;i<nboctet;i++) - *(buff_lig+i)=0; - deplacement=0; - } - else - deplacement= - nboctet; - } -/************************************************************************/ -/* Redeplacement jusqu'au premier pixel de la premiere ligne a ecrire*/ -/************************************************************************/ - lseek ( num , deplacement , 1 ); - -/*************************************************************************/ -/* chargement de la ligne entrelacant les pixels par rapport aux canaux*/ -/*************************************************************************/ - - deb=buff_lig+((*canal)-1)*nboct_pix; - for (j=0;j<(*nombre_colonnes_ecrire);j=j+1) - { - for (k=0;k<nboct_pix;k=k+1) - { - *(deb+k)=*(pch+k); - } - - pch=pch+nboct_pix; - deb=deb + (nboct_pix*nbcan); - } -/********************************************************/ -/* ecriture de la ligne */ -/********************************************************/ - cr_write = write ( num , buff_lig , nboctet ); - - if ( cr_write != nboctet ) - { - strcpy ( CAI_ERREUR , "Erreur ecriture canal image BIP\n" ); - goto ERREUR; - } -/********************************************************/ -/* incrementation du nombre de lignes */ -/********************************************************/ - - i_ligne++; - -/********************************************************/ -/* FIN TANT QUE */ -/********************************************************/ - -} -free(buff_lig); - -return (CAI_OK); - -ERREUR : - -free(buff_lig); -return (CAI_KO); - - -} - -/* - Fin de l'operation cai_ecriture_canal_bip -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ferme_bip */ -/* ---------- */ -/* */ -/* ROLE : fonction de fermeture d'une image au format bip et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ferme_bip(image1) */ /* ------------------ */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* */ -/* cai_ferme_bip (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_OK_KO cai_ferme_bip (CAI_IMAGE *image1) - -{ - int iret; /* code retour de l'operation */ - int i_can; /* indice du canal a fermer */ - int num; /* descripteur du fichier a fermer */ - - iret=CAI_OK; -/*............................................. - Fermeture de tous les canaux - .............................................*/ - for (i_can=0;i_can<image1->NB_CANAUX;i_can=i_can+1) - { - - num=image1->ACCES_CANAL_INT[i_can]; - if (num>0) close(num); - } - - - return (iret); -} - -/* - Fin de l'operation cai_ferme_bip -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_dest_ima_bip */ -/* ---------- */ -/* */ -/* ROLE : fonction de destruction d'une image stocke en bip et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_dest_ima_bip(repertoire,nom_ima) */ /* ------------------ */ -/* repertoire (E) (char *) : repertoire de l'image a detruire */ -/* nom_image (E) (char *) : nom de l'image a detruire avec repertoire */ -/* */ -/* cai_dest_ima_bip (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - - -CAI_OK_KO cai_dest_ima_bip ( char *repertoire , - char *nom_ima ) - -{ - -char nom_fic_entete[1024]; /* nom du fichier entete a detruire */ -char nom_ima_complet[1024]; /* repertoire + nom de l'image */ - -int cr_stat; /* code retour de fonction status de fichier */ -struct stat buf_stat; /* structure decrivant status de fichier */ - -/************************************************/ -/* Constitution du nom du fichier d'entete */ -/************************************************/ - -if ((long int)strlen(repertoire)!= 0) -{ - - sprintf ( nom_ima_complet ,"%s/%s", repertoire ,nom_ima); -} -else -{ - strcpy ( nom_ima_complet , nom_ima); -} - sprintf(nom_fic_entete ,"%s.bip_hd", nom_ima_complet); - -/************************************************/ -/* Destruction du fichier d'entete */ -/************************************************/ - -cr_stat = stat ( nom_fic_entete , &buf_stat ); -if ( cr_stat == 0 ) - unlink ( nom_fic_entete ); - -else -/*****************************************************************************/ -/* MOD : VERSION : 4.4 : DM : prise en compte des extensions en majuscule */ -/*****************************************************************************/ -{ - sprintf(nom_fic_entete ,"%s.BIP_HD", nom_ima_complet); - cr_stat = stat ( nom_fic_entete , &buf_stat ); - if ( cr_stat == 0 ) - unlink ( nom_fic_entete ); - -} - -/************************************************/ -/* Destruction du fichier radiometrie */ -/************************************************/ - sprintf(nom_fic_entete ,"%s.bip", nom_ima_complet); - cr_stat = stat ( nom_fic_entete , &buf_stat ); - if ( cr_stat == 0 ) - unlink ( nom_fic_entete ); - else - { -/*****************************************************************************/ -/* MOD : VERSION : 4.4 : DM : prise en compte des extensions en majuscule */ -/*****************************************************************************/ - - sprintf(nom_fic_entete ,"%s.BIP", nom_ima_complet); - cr_stat = stat ( nom_fic_entete , &buf_stat ); - if ( cr_stat == 0 ) - unlink ( nom_fic_entete ); - -} - - - -return (CAI_OK); - -} -/* - Fin de l'operation cai_dest_ima_bip -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_modif_nbbitspix_bip */ -/* ---------- */ -/* */ -/* ROLE : permet de modifier le nombre de bits significatifs par pixel */ -/* ----- dans l'entete de fichier (.hd) */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_modif_nbbitspix_bip(image1,NbBitsPix) */ /* ------------------ */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* NbBitsPix (E) (int) : nb de bits significatifs par pixel */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_OK_KO cai_modif_nbbitspix_bip(CAI_IMAGE *image1,int NbBitsPix) - -{ - int Can; /* indice de boucle sur les canaux */ - char fichierE[1024]; /* fichier a traiter */ - char Command[1024]; /* Commande a envoyer au systeme */ - FILE *fic; /* pointeur descripteur fichier */ - int pt_oct; /* position courante ds le fichier */ - int *Ref; /* Reference du SDS des fichiers */ - char label[80]; /* contient un enregist fichier */ - char repert[1024]; /* repertoire de stockage image */ - char image[1024]; /* nom de l'image a ouvrir */ - char car; /* variable de travail */ - int icr,tempo,retour; /* code retour fonction */ - CAI_CHAINE *NomIma; - - -/* Ouverture du fichier d'entete */ - - fichierE[0]='\0'; - sprintf(fichierE,"%s.bip_hd",image1->NOM_IMAGE); - fic = fopen(fichierE,"w"); - if (fic == NULL) - { -/*****************************************************************************/ -/* MOD : VERSION : 4.4 : DM : prise en compte des extensions en majuscule */ -/*****************************************************************************/ - fichierE[0]='\0'; - sprintf(fichierE,"%s.BIP_HD",image1->NOM_IMAGE); - fic = fopen(fichierE,"w"); - if (fic == NULL) - { - sprintf(CAI_ERREUR, - "Erreur: Modification fichier %s impossible\n",fichierE); - goto ERREUR; - } - } - -/* Modification du fichier d'entete */ - rewind(fic); - fprintf ( fic , "COMMENT\n"); - fprintf ( fic , "%s\n" ,image1->COMMENT); - fprintf ( fic , "CHANNELS\n" ); - fprintf ( fic , "%3d\n" , image1->NB_CANAUX); - fprintf ( fic , "LINES\n" ); - fprintf ( fic , "%5d\n" , image1->NB_LIG); - fprintf ( fic , "COLUMNS\n" ); - fprintf ( fic , "%5d\n" , image1->NB_COL ); - fprintf ( fic , "BITS PER PIXEL\n" ); - fprintf ( fic , "%2d\n" , NbBitsPix ); - fprintf ( fic , "TYPE\n"); - fprintf ( fic , "%s\n",image1->COD_PIX ); - fprintf ( fic, "SENSCODAGE\n"); - retour=strncmp((char *)image1->SENS_COD,"BE",2); - if (retour == 0) - fprintf ( fic , "IEEE\n" ); - else - fprintf ( fic , "INTEL\n" ); - - - fclose ( fic ); - - return(CAI_OK); - -ERREUR : - return(CAI_KO); -} -/* - Fin de l'operation cai_modif_nbbitspix_bip -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_modifie_bip */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture/ecriture d'une image au format */ -/* ----- bip et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_modifie_bip (nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_modifie_bip (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ /* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_IMAGE *cai_ouvre_modifie_bip(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) -{ - FILE *fic_in; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - int iret; /* indicateur de retour ok ou pas */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char nom_fic_canal[1024]; /* nom fichier canal dont on teste existence*/ - char label[80]; /* contient un enregistrement du fichier */ - int nbbit; /* nb de bits par pixel du fichier en-tete */ - int retour; /* retour de la fonction comparaison chaines*/ - char *deb,*deb1,*pch0; /* pointeurs sur chaine de caracteres */ - int i,num; /* indice */ - int nbplan; /* nombre de canaux dans le fichier en-tete */ - char COD_PIX[80]; /* type de codage du pixel (optionnel) */ - struct stat buf_stat; /* structure decrivant status de fichier */ - char *type_machine; /* ordre rangement octets machine de travail*/ - int cmp; /* retour de comparaison de chaine */ - int reconnaissance_type; - - /*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - *nb_can=0; - - *nb_lig=0; - - *nb_col=0; - - *nboct_pix=0; - - iret=1; - - /*.................................. - determination ordre de rangement - des octets sur machine de travail - ......................................*/ - type_machine = cai_test_pFpf(); - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); -/*****************************************************************************/ -/* MOD : VERSION : 4.1: FA Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_modifie"); - } - else - { - -/*................................................. - Constitution du nom du fichier entete - .................................................*/ - nom_fic[0]='\0'; - if ((long int)strlen(repert)!= 0) - { - sprintf(nom_fic,"%s/%s.bip_hd",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.bip_hd",nom_image); - } - -/*........................ - Ouverture du fichier entete - ..........................................*/ - fic_in=NULL; - fic_in=fopen(nom_fic,"r"); - if (fic_in==NULL) - { -/*****************************************************************************/ -/* MOD : VERSION : 4.4 : DM : prise en compte des extensions en majuscule */ -/*****************************************************************************/ - nom_fic[0]='\0'; - if((long int)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s.BIP_HD",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.BIP_HD",nom_image); - } - fic_in=fopen(nom_fic,"r"); - if (fic_in==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur ouverture fichier entete BIP-CNES"); - } - } - if (iret !=0) - { -/*.................................... - Decodage du commentaire - ......................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"COMMENT",7); - if (retour!=0) - { - strcpy(CAI_ERREUR,"Informations incoherentes ligne COMMENT"); - iret=0; - } - else - { - fgets(image1->COMMENT,80,fic_in); - - - /*........................................ - Decodage du nombre de canaux - .........................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"CHANNELS",8); - if (retour!=0) - { - strcpy(CAI_ERREUR,"Informations incoherentes ligne CHANNELS"); - iret=0; - } - else - { - fscanf(fic_in,"%d\n",&nbplan); - *nb_can=nbplan; - -/*....................................... - Decodage du nombre de lignes - ........................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"LINES",5); - if (retour!=0) - { - strcpy(CAI_ERREUR,"Informations incoherentes ligne LINES"); - iret=0; - } - else - { - fscanf(fic_in,"%d\n",nb_lig); - - -/*....................................... - Decodage du nombre de colonnes - ........................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"COLUMNS",7); - if (retour!=0) - { - strcpy(CAI_ERREUR,"Informations incoherentes ligne COLUMNS"); - iret=0; - } - else - { - - fscanf(fic_in,"%d\n",nb_col); - -/*....................................... - Decodage du nombre de bits par pixel - ........................................*/ - fgets(label,80,fic_in); - retour=strncmp(label,"BITS PER PIXEL",14); - if (retour!=0) - { - strcpy(CAI_ERREUR,"Informations incoherentes ligne BITS "); - iret=0; - } - else - { - fscanf(fic_in,"%d\n",&nbbit); - -/*........................................................ - Decodage du type de codage du pixel (optionnel) - ........................................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"TYPE",4); - if (retour==0) - { - fscanf(fic_in,"%s\n",COD_PIX); - retour=1; - } - else - sprintf(COD_PIX,"UND"); - pch0=cai_En_majuscule( COD_PIX ); - -/* Verification si type de codage reconnu */ - reconnaissance_type = cai_istyp_connu(pch0); -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : prise en compte de l'information INTEL ou IEEE*/ -/* en lecture et ecriture dans l'entete .hd */ -/*****************************************************************************/ - if (retour !=0) fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"SENSCODAGE",10); - if (retour!=0) - { -/* Si absent, pas d'inversion */ - image1->INV_OCTETS =0; - sprintf((char *)image1->SENS_COD,type_machine); - } - else - { - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"IEEE",4); - if (retour==0) - sprintf((char *)image1->SENS_COD,"BE"); - else - sprintf((char *)image1->SENS_COD,"LE"); - cmp = strncmp(type_machine,image1->SENS_COD,2); - if (cmp!=0) - image1->INV_OCTETS =1; - else - image1->INV_OCTETS =0; - } - } - } - } - } - } - } -/*.................................. - Fermeture du fichier - ......................................*/ - if (fic_in !=NULL) fclose(fic_in); - - if (iret !=0) - { -/*.................................. - Initialisation du nombre d'octets par pixel - ........................................................*/ - if ((nbbit%8)==0) - *nboct_pix=(int)(nbbit/8); - else - *nboct_pix=(int)((nbbit/8)+1); - image1->NB_BITS_PIX=nbbit; - - if (reconnaissance_type != -1) - { - sprintf(image1->COD_PIX,"%s",COD_PIX); - } - else - { - sprintf(image1->COD_PIX,"UND"); - - if (*nboct_pix==1) - sprintf(image1->COD_PIX,"OCT"); - else if (*nboct_pix==2) - sprintf(image1->COD_PIX,"I2"); - else if (*nboct_pix==4) - { - retour=strncmp(COD_PIX,"I4",2); - if (retour==0) - sprintf(image1->COD_PIX,"I4"); - else - { - retour=strncmp(COD_PIX,"R4",2); - if (retour==0) - sprintf(image1->COD_PIX,"R4"); - } - } - else if (*nboct_pix==8) - { - sprintf(image1->COD_PIX,"R8"); - } - } - -/*....................................... - INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL - .....................................................*/ - - nom_fic[0]='\0'; - nom_fic_canal[0]='\0'; - - if ((long int)strlen(repert)!= 0) - { - sprintf(nom_fic_canal,"%s/%s.bip",repert,nom_image); - } - else - { - sprintf(nom_fic_canal,"%s.bip",nom_image); - } -/*****************************************************************************/ -/* MOD : VERSION : 4.4 : FA : prise en compte des extensions en majuscule */ -/*****************************************************************************/ - retour = stat ( nom_fic_canal , &buf_stat ); - if ( retour != 0 ) - { - if((long int)strlen(repert)!=0) - { - sprintf(nom_fic_canal,"%s/%s.BIP",repert,nom_image); - } - else - { - sprintf(nom_fic_canal,"%s.BIP",nom_image); - } - } - - deb = image1->NOM_FIC_CAN; - deb1= image1->NOM_UTIL_CAN; - num=open(nom_fic_canal,O_RDWR|O_BINARY,0); - if (num!= -1) - { - - for (i=0;i<*nb_can;i=i+1) - { - sscanf(nom_image,"%s",deb); - deb=deb+100; - sscanf(nom_image,"%s",deb1); - deb1=deb1+100; - image1->ACCES_CANAL_INT[i]=num; - image1->POS_OCTET[i]=0; - } - } - else - iret=0; - } - } - if (iret == 0) - { - return (NULL); - } - else - { - return(image1); - } - -} -/* - Fin de l'operation cai_ouvre_modifie_bip -*/ diff --git a/Utilities/CAI/cai_dll/src/cai_bsq.c b/Utilities/CAI/cai_dll/src/cai_bsq.c deleted file mode 100755 index ff5446f033203769686d4f373af9a2e1fc1e28d9..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/src/cai_bsq.c +++ /dev/null @@ -1,2009 +0,0 @@ -/*****************************************************************************/ -/* */ -/* PROJET : COUCHE ACCES IMAGE */ -/* ------- */ -/* */ -/* MODULE : cai_bsq.c */ -/* ------- */ -/* */ -/* ROLE : Ce module rassemble toutes les fonctions d'acces aux images */ -/* ------- stockees au format bsq */ -/* */ -/* AUTEUR : R.CHAISEMARTIN (CISI) */ -/* ------- */ -/* */ -/* DATE DE CREATION : fevrier 1995 */ -/* ----------------- */ -/* */ -/* LANGAGE : C */ -/* -------- */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ -/* MOD : VERSION : 3.3: DM : optimisation des acces */ -/*****************************************************************************/ -/* MOD : VERSION : 4.0: DM : traitement des images en double precision */ -/* en lecture, ecriture et modification */ -/*****************************************************************************/ -/* MOD : VERSION : 4.1 : FA:Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : FA : modifications pour compatibilite HP64bits */ -/*****************************************************************************/ -/* MOD : VERSION : 4.4 : DM : prise en compte des extensions en majuscule */ -/*****************************************************************************/ -/* MOD : VERSION : 4.5 : FA : test sur fclose pour PC/LINUX */ -/*****************************************************************************/ -/* MOD : VERSION : 5.1 : DM : Maj du tag TYPE lorsque l'image est codée */ -/* en reel et que l'utilisateur le precise dans le param "label" */ -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : prise en compte des I2,I4,UI2,UI4 et R8 */ -/* en lecture et ecriture */ -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : prise en compte de l'information INTEL ou IEEE*/ -/* en lecture et ecriture dans l'entete .hd */ -/*****************************************************************************/ - -/*---------------------------------------------------------------------------*/ -/* Inclusion des fichiers STANDARDS (.h) */ -/*---------------------------------------------------------------------------*/ - - -# include <stdio.h> -# include <string.h> -# include <stdlib.h> -# include <sys/types.h> -# include <unistd.h> -# include <dirent.h> -# include <sys/stat.h> -# include <fcntl.h> -#include <errno.h> - -#define _CAI_IMAGE -#define IN_CAI_BSQ - -# include "cai_image.h" - -/*----------------------------------------------------------------------------*/ -/* Variable pour la gestion en configuration */ -/*----------------------------------------------------------------------------*/ -static char *rcs_id="$Header: cai_bsq.c,v 1.12 01/05/31 10:46:59 cmf Exp $"; - -extern char *getenv(); - - -/*****************************************************************************/ -/*****************************************************************************/ -/* */ -/* Definition des OPERATIONS EXTERNES */ -/* */ -/*****************************************************************************/ -/*****************************************************************************/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_liste_ima_bsq */ -/* ---------- */ -/* */ -/* ROLE : fonction de listage des images au format bsq */ -/* ------ */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : int cai_liste_ima_bsq(repert,tab_ima) */ -/* ----------------- */ -/* */ -/* repert (E) (char *) : repertoire a explorer */ -/* tab_ima (S) (char ***) : pointeur sur tableau des images listees */ -/* alloue par la fonction,il doit etre */ -/* LIBERE PAR L'APPELANT */ -/* */ -/* cai_liste_ima_bsq (S) (long int) : = -1 repertoire inexistant */ /* = > 0 nombre d'images listees */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -long int cai_liste_ima_bsq (char *repert, - char ***tab_ima) - -{ - - DIR *dirp; /* pointeur sur structure ouverture repertoire */ - - struct dirent *dp; /* structure resultat de la fonction readdir */ - - char *pch0,*pch1; /* pointeurs sur chaine de caracteres */ - char *pch2,*pch3; /* pointeurs sur chaine de caracteres */ - char car; /* variable de travail */ - int nb_ima; /* nombre d'images bsq identifiees */ - int i; /* indice de boucle */ - long int diff,Long; - -/*........................................ - INITIALISATION et ouverture du repertoire choisi - .........................................*/ - nb_ima=0; - dirp=opendir(repert); - - if(dirp!=NULL) - { - - -/*...................................... - - premiere passe pour comptabiliser les images du format donne - - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE BSQ_CNES - (EXTENSION =.hd) - ..........................................*/ - while((dp=readdir(dirp))!=NULL) - { - pch3=dp->d_name; - Long=(long int)strlen(dp->d_name); - - car='.'; - pch0=strrchr(dp->d_name,car); - if (pch0 != NULL) - { - car='h'; - pch1=strrchr(dp->d_name,car); - if ((pch1 != NULL)&&(pch1==pch0+1)) - { - car='d'; - pch2=strrchr(dp->d_name,car); - if ((pch2 != NULL)&&(pch2==pch1+1)) - { - diff=(long int)(pch2-pch3+1); - if(Long==diff) - { - *pch0='\0'; - *pch1=' '; - *pch2=' '; - nb_ima=nb_ima+1; - } - } - } -/*****************************************************************************/ -/* MOD : VERSION : 4.4 : DM : prise en compte des extensions en majuscule */ -/*****************************************************************************/ - else - { - car='H'; - pch1=strrchr(dp->d_name,car); - if ((pch1 != NULL)&&(pch1==pch0+1)) - { - car='D'; - pch2=strrchr(dp->d_name,car); - if ((pch2 != NULL)&&(pch2==pch1+1)) - { - diff=(long int)(pch2-pch3+1); - if(Long==diff) - { - *pch0='\0'; - *pch1=' '; - *pch2=' '; - nb_ima=nb_ima+1; - } - } - } - } - } - } - (void)closedir(dirp); - -/*..................................... - ALLOCATION DU TABLEAU CONTENANT LA LISTE DES IMAGES DU FORMAT BSQ - ......................................*/ - *tab_ima = (char **) calloc(nb_ima,sizeof(char *)); - for (i=0;i<nb_ima;i=i+1) - (*tab_ima)[i]=(char *)calloc(1,100); - -/*...................................... - - deuxieme passe pour constituer la liste des images du format donne - - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE BSQ_CNES - (EXTENSION =.hd) - SI C`EST LE CAS,STOCKAGE DANS LA LISTE - ..........................................*/ - dirp=opendir(repert); - - nb_ima=0; - while((dp=readdir(dirp))!=NULL) - { - pch3=dp->d_name; - Long=(long int)strlen(dp->d_name); - - car='.'; - pch0=strrchr(dp->d_name,car); - if (pch0 != NULL) - { - car='h'; - pch1=strrchr(dp->d_name,car); - if ((pch1 != NULL)&&(pch1==pch0+1)) - { - car='d'; - pch2=strrchr(dp->d_name,car); - if ((pch2 != NULL)&&(pch2==pch1+1)) - { - diff=(long int)(pch2-pch3+1); - if(Long==diff) - { - *pch0='\0'; - *pch1=' '; - *pch2=' '; - strcpy((*tab_ima)[nb_ima],dp->d_name); - nb_ima=nb_ima+1; - } - } - } -/*****************************************************************************/ -/* MOD : VERSION : 4.4 : DM : prise en compte des extensions en majuscule */ -/*****************************************************************************/ - else - { - car='H'; - pch1=strrchr(dp->d_name,car); - if ((pch1 != NULL)&&(pch1==pch0+1)) - { - car='D'; - pch2=strrchr(dp->d_name,car); - if ((pch2 != NULL)&&(pch2==pch1+1)) - { - diff=(long int)(pch2-pch3+1); - if(Long==diff) - { - *pch0='\0'; - *pch1=' '; - *pch2=' '; - strcpy((*tab_ima)[nb_ima],dp->d_name); - nb_ima=nb_ima+1; - } - } - } - } - - } - } - - (void)closedir(dirp); - - - } - else - { - /* repertoire inexistant */ - nb_ima=-1; - } - return(nb_ima); - -} - -/* Fin de l'operation cai_liste_ima_bsq -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_lecture_bsq */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture d'une image au format bsq */ -/* ----- et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_lecture_bsq (nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_lecture_bsq (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ /* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_IMAGE *cai_ouvre_lecture_bsq(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) -{ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - long int iret; /* indicateur de retour ok ou pas */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char nom_fic_canal[1024]; /* nom fichier canal dont on teste existence*/ - char label[80]; /* contient un enregistrement du fichier */ - int nbplan; /* nombre de canaux dans le fichier en-tete */ - int nbbit; /* nb de bits par pixel du fichier en-tete */ - int retour; /* retour de la fonction comparaison chaines*/ - char *deb,*deb1,*pch0; /* pointeurs sur chaine de caracteres */ - char car[4]; /* indice du canal traite */ - int i,num,IndExtens; /* indice */ - char Extens[25]; /* Extension possible du fichier */ - char COD_PIX[5]; /* contient le type de codage du pixel */ - char *type_machine; /* ordre rangement octets machine de travail*/ - struct stat buf_stat; /* structure decrivant status de fichier */ - int cmp; /* retour de comparaison de chaine */ - int reconnaissance_type; - char CAN[2]; - FILE *fic_in; /* pointeur sur descripteur de fichier */ - - /*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - *nb_can=0; - - *nb_lig=0; - - *nb_col=0; - - *nboct_pix=0; - - iret=1; - IndExtens = 0; - pch0=NULL; - reconnaissance_type = -1; - - /*.................................. - determination ordre de rangement - des octets sur machine de travail - ......................................*/ - type_machine = cai_test_pFpf(); - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); - -/*****************************************************************************/ -/* MOD : VERSION : 4.1 : FA:Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_lecture"); - } - else - { -/*................................................. - Constitution du nom du fichier entete - .................................................*/ - - pch0 = strstr(nom_image,"."); - if (pch0 != NULL) - { - *pch0 = '\0'; - pch0=pch0 + 1; - sprintf(Extens,"%s",pch0); - if (strcmp(Extens,"hd")!=0) - IndExtens=1; - } - nom_fic[0]='\0'; - if ((long int)strlen(repert)!= 0) - { - sprintf(nom_fic,"%s/%s.hd",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.hd",nom_image); - } - sprintf(image1->NOM_IMAGE,"%s/%s",repert,nom_image); -/*........................ - Ouverture du fichier entete - ..........................................*/ - fic_in=NULL; - fic_in=fopen(nom_fic,"r"); - if (fic_in==NULL) - { -/*****************************************************************************/ -/* MOD : VERSION : 4.4 : DM : prise en compte des extensions en majuscule */ -/*****************************************************************************/ - nom_fic[0]='\0'; - if((long int)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s.HD",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.HD",nom_image); - } - sprintf(image1->NOM_IMAGE,"%s/%s",repert,nom_image); - fic_in=fopen(nom_fic,"r"); - if (fic_in==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur ouverture fichier entete BSQ-CNES"); - } - } - if (iret !=0) - { -/*.................................... - Decodage des informations TYPE - ............................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"TYPE",4); - if (retour!=0) - { - sprintf(CAI_ERREUR, - "Informations incoherentes ligne TYPE dans %s", - nom_fic); - iret=0; - } - else - { - fscanf(fic_in,"%s\n",COD_PIX); - pch0=cai_En_majuscule( COD_PIX ); - -/* Verification si type de codage reconnu */ - reconnaissance_type = cai_istyp_connu(pch0); - -/*.................................. - Decodage du label - ......................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"LABEL",5); - if (retour!=0) - { - sprintf(CAI_ERREUR, - "Informations incoherentes ligne LABEL dans %s", - nom_fic); - - iret=0; - } - else - { - fgets(image1->COMMENT,80,fic_in); - image1->COMMENT[strlen(image1->COMMENT)-1]='\0'; - - /*........................................ - Decodage du nombre de canaux - .........................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"CHANNELS",8); - if (retour!=0) - { - sprintf(CAI_ERREUR, - "Informations incoherentes ligne CHANNELS dans %s", - nom_fic); - - iret=0; - } - else - { - fscanf(fic_in,"%d\n",&nbplan); - -/*....................................... - Decodage du nombre de lignes - ........................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"LINES",5); - if (retour!=0) - { - sprintf(CAI_ERREUR, - "Informations incoherentes ligne LINES dans %s", - nom_fic); - - iret=0; - } - else - { - fscanf(fic_in,"%d\n",nb_lig); - - -/*....................................... - Decodage du nombre de colonnes - ........................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"COLUMNS",7); - if (retour!=0) - { - sprintf(CAI_ERREUR, - "Informations incoherentes ligne COLUMNS dans %s", - nom_fic); - - iret=0; - } - else - { - - fscanf(fic_in,"%d\n",nb_col); - -/*....................................... - Decodage du nombre de bits par pixel - ........................................*/ - fgets(label,80,fic_in); - retour=strncmp(label,"BITS PER PIXEL",14); - if (retour!=0) - { - sprintf(CAI_ERREUR, - "Informations incoherentes ligne BITS dans %s", - nom_fic); - - iret=0; - } - else - { - fscanf(fic_in,"%d\n",&nbbit); - image1->NB_BITS_PIX = nbbit; - -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : prise en compte de l'information INTEL ou IEEE*/ -/* en lecture et ecriture dans l'entete .hd */ -/*****************************************************************************/ -/*.................................. - Decodage du sens de codage si présent - ......................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"SENSCODAGE",10); - if (retour!=0) - { -/* Si absent, pas d'inversion */ - image1->INV_OCTETS =0; - sprintf(image1->SENS_COD,type_machine); - } - else - { - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"IEEE",4); - if (retour==0) - sprintf(image1->SENS_COD,"BE"); - else - sprintf(image1->SENS_COD,"LE"); - cmp = strncmp(type_machine,image1->SENS_COD,2); - if (cmp!=0) - { - image1->INV_OCTETS =1; - } - else - { - image1->INV_OCTETS =0; - } - } - } - } - } - } - } - - } -/*.................................. - Fermeture du fichier - ......................................*/ - if (fic_in!=NULL) - { - fclose(fic_in); - fic_in=NULL; - } - } - - if (iret !=0) - { -/*.................................. - Initialisation du nombre d'octets par pixel - ........................................................*/ - if ((nbbit%8)==0) - *nboct_pix=(int)(nbbit/8); - else - *nboct_pix=(int)((nbbit/8)+1); - - if (reconnaissance_type != -1) - { - sprintf(image1->COD_PIX,"%s",COD_PIX); - } - else - { - sprintf(image1->COD_PIX,"UND"); - - if (*nboct_pix==1) - sprintf(image1->COD_PIX,"OCT"); - else if (*nboct_pix==2) - sprintf(image1->COD_PIX,"I2"); - else if (*nboct_pix==4) - { - retour=strncmp(COD_PIX,"I4",2); - if (retour==0) - sprintf(image1->COD_PIX,"I4"); - else - { - retour=strncmp(COD_PIX,"R4",2); - if (retour==0) - sprintf(image1->COD_PIX,"R4"); - } - } - else if (*nboct_pix==8) - { - sprintf(image1->COD_PIX,"R8"); - } - } -/*....................................... - INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL - .....................................................*/ - deb = image1->NOM_FIC_CAN; - deb1= image1->NOM_UTIL_CAN; - if ((nbplan==1)&&(IndExtens==1)) - { -/* Verification de l'existence du fichier demande et ouverture */ - nom_fic[0]='\0'; - if ((long int)strlen(repert)!= 0) - sprintf(nom_fic,"%s/%s.%s",repert,nom_image,Extens); - else - sprintf(nom_fic,"%s.%s",nom_image,Extens); - nom_fic_canal[0]='\0'; - sscanf(nom_fic,"%s",nom_fic_canal); - num=open(nom_fic_canal,O_RDONLY|O_BINARY,0); - if (num!= -1) - { - sprintf(deb,"%s.%s",nom_image,Extens); - deb=deb+100; - sprintf(deb1,"%s.%s",nom_image,Extens); - deb1=deb1+100; - } - image1->ACCES_CANAL_INT[*nb_can]=num; - image1->POS_OCTET[*nb_can]=0; - - *nb_can=*nb_can+1; - } - else - { -/*................................................... - recherche du nombre de canaux de l'image si pas d'extension donnee - ..........................................................*/ - nom_fic[0]='\0'; - if ((long int)strlen(repert)!= 0) - { - sprintf(nom_fic,"%s/%s.c",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.c",nom_image); - } - /*****************************************************************************/ -/* MOD : VERSION : 4.4 : FA : prise en compte des extensions en majuscule */ -/*****************************************************************************/ - sprintf(nom_fic_canal,"%s1",nom_fic); - retour = stat ( nom_fic_canal , &buf_stat ); - if ( retour != 0 ) - { - sprintf(CAN,"C"); - if ((long int)strlen(repert)!= 0) - { - sprintf(nom_fic,"%s/%s.C",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.C",nom_image); - } - - } - else - sprintf(CAN,"c"); - for (i=1;i<CAI_NB_MAX_CAN;i=i+1) - { - nom_fic_canal[0]='\0'; - sprintf(nom_fic_canal,"%s%d",nom_fic,i); - num=open(nom_fic_canal,O_RDONLY|O_BINARY,0); - if (num!= -1) - { - if (*nb_can<CAI_NB_MAX_CAN) - { - sscanf(nom_image,"%s",deb); - strcat(deb,CAN); - sprintf(car,"%d",(*nb_can)+1); - strcat(deb,car); - deb=deb+100; - sscanf(nom_image,"%s",deb1); - strcat(deb1,CAN); - strcat(deb1,car); - deb1=deb1+100; - } - image1->ACCES_CANAL_INT[*nb_can]=num; - image1->POS_OCTET[*nb_can]=0; - - *nb_can=*nb_can+1; - } - } - if (*nb_can!=nbplan) - { - sprintf(CAI_ERREUR, - "incoherence au niveau du nombre de fichiers canaux dans %s", - nom_fic); - - iret=0; - } - } - } - } - if (iret == 0) - return (NULL); - else - return(image1); -} - -/* - Fin de l'operation cai_ouvre_lecture_bsq -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_creation_bsq */ -/* ---------- */ -/* */ -/* ROLE : fonction de creation et d'ouverture en ecriture d'une image */ -/* ----- au format bsq et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_creation_bsq (nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig, */ -/* label) */ -/* */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* nb_can (E) (int ) : nombre de canaux de l'image */ -/* nboct_pix (E) (int ) : nombre d'octets par pixels */ -/* nb_lig (E) (int ) : nombre de lignes de l'image */ -/* nb_col (E) (int ) : nombre de colonnes de l'image */ -/* label (E) (char *) : commentaire lie a l'image */ -/* */ -/* cai_ouvre_creation_bsq (S) (CAI_IMAGE *) : =NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_IMAGE *cai_ouvre_creation_bsq(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig, - char *label) - -{ - FILE *fic; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char nom_fic_canal[1024]; /* nom fichier canal dont on teste existence*/ - int retour; /* retour de fonction */ - char car[4]; /* indice du canal traite */ - int i,num; /* indice */ - struct stat buf_stat; /* structure decrivant status de fichier */ - char *type_machine; /* ordre rangement octets machine de travail*/ - int reconnaissance_type; - - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); -/*****************************************************************************/ -/* MOD : VERSION : 4.1 : FA:Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_creation"); - goto ERREUR; - } - -/*.................................. - determination ordre de rangement - des octets sur machine de travail - ......................................*/ - type_machine = cai_test_pFpf(); - -/*................................................. - Constitution du nom du fichier entete et verification qu'il - n'existe pas deja - .................................................*/ - - nom_fic[0]='\0'; - if ((long int)strlen(repert)!= 0) - { - sprintf(nom_fic,"%s/%s.hd",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.hd",nom_image); - } - - retour = stat ( nom_fic , &buf_stat ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "L'image %s BSQ existe \n" , nom_image ); - goto ERREUR; - } - sprintf(image1->NOM_IMAGE,"%s/%s",repert,nom_image); -/*............................................................... - Pour chaque canal de l'image,constitution du nom de fichier correspondant - Verification qu'il n'existe pas deja - Ouverture du fichier en ecriture - .................................................................*/ - - for (i=0;i<*nb_can;i=i+1) - { - nom_fic_canal[0]='\0'; - sprintf(car,"%d",i+1); - if (i+1<10) - car[1]='\0'; - else - { - if (i+1<100) - car[2]='\0'; - else - car[3]='\0'; - } - - if ((long int)strlen(repert)!= 0) - { - sprintf(nom_fic_canal,"%s/%s.c%s",repert,nom_image,car); - } - else - { - sprintf(nom_fic_canal,"%s.c%s",nom_image,car); - } - - retour = stat ( nom_fic_canal , &buf_stat ); - - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "L'image %s BSQ existe \n" , nom_image ); - goto ERREUR; - } - num = open(nom_fic_canal,O_RDWR|O_CREAT|O_BINARY,PERMS); - if (num == -1) - { - - sprintf(CAI_ERREUR,"Erreur: Creation %s impossible\n",nom_fic_canal); - goto ERREUR; - } - image1->ACCES_CANAL_INT[i]=num; - image1->POS_OCTET[i]=0; - } - -/*...................................................... - Ouverture du fichier entete en ecriture - Ecriture du contenu - ..........................................................*/ - fic = fopen(nom_fic,"w"); - if (fic == NULL) - { - sprintf(CAI_ERREUR,"Erreur: Creation fichier %s impossible\n",nom_fic); - goto ERREUR; - } - - retour=fprintf ( fic , "TYPE\n"); - if (retour == 0) - { - sprintf(CAI_ERREUR,"Erreur: Ecriture %s impossible\n",nom_fic); - goto ERREUR; - } -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : Maj du tag TYPE lorsque l'utilisateur le */ -/* precise dans le param "label" */ -/*****************************************************************************/ -/* Verification si type de codage reconnu dans le label */ - reconnaissance_type = cai_istyp_connu(label); - if (reconnaissance_type == -1) - { - if (*nboct_pix==1) - sprintf ( image1->COD_PIX , "OCT" ); - else if (*nboct_pix==2) - sprintf ( image1->COD_PIX , "I2" ); - else if (*nboct_pix==4) - { -/*****************************************************************************/ -/* MOD : VERSION : 5.1 : DM : Maj du tag TYPE lorsque l'image est codée */ -/* en reel et que l'utilisateur le precise dans le param "label" */ -/*****************************************************************************/ - if ((strcasecmp(label,"R4") == 0)|| - (strcasecmp(label,"FLOAT")== 0)|| - (strcasecmp(label,"REEL") == 0)) - sprintf ( image1->COD_PIX , "R4" ); - else - sprintf ( image1->COD_PIX , "I4" ); - } - else - sprintf ( image1->COD_PIX , "UND" ); - fprintf ( fic , "%s\n",image1->COD_PIX ); - } - else - { - sprintf ( image1->COD_PIX , "%s" ,label); - fprintf ( fic , "%s\n", label ); - } - fprintf ( fic , "LABEL\n" ); - fprintf ( fic , "%s\n" , label ); - fprintf ( fic , "CHANNELS\n" ); - fprintf ( fic , "%3d\n" , *nb_can ); - fprintf ( fic , "LINES\n" ); - fprintf ( fic , "%5d\n" , *nb_lig ); - fprintf ( fic , "COLUMNS\n" ); - fprintf ( fic , "%5d\n" , *nb_col ); - fprintf ( fic , "BITS PER PIXEL\n" ); - fprintf ( fic , "%2d\n" , (*nboct_pix)*8 ); - fprintf ( fic , "SENSCODAGE\n" ); - retour=strncmp(type_machine,"BE",2); - sprintf(image1->SENS_COD,"%s",type_machine); - if (retour == 0) - fprintf ( fic , "IEEE\n" ); - else - fprintf ( fic , "INTEL\n" ); - -/*************************************************/ -/* Fermeture du fichier */ -/*************************************************/ - - fclose ( fic ); - return (image1); - -ERREUR : - return(NULL); -} - -/* - Fin de l'operation cai_ouvre_creation_bsq -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_lecture_canal_bsq */ -/* ---------- */ -/* */ -/* ROLE : fonction de lecture d'un canal d'une image bsq */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_lecture_canal_bsq(image1, canal, */ /* ------------------ premiere_ligne, */ -/* premiere_colonne, */ -/* nombre_lignes_lire , */ -/* nombre_colonnes_lire, */ -/* pas_ligne ,pas_colonne, */ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (lint): numero du canal a lire */ -/* premiere_ligne (E) (int) : premiere ligne a lire dans l'image */ -/* premiere _colonne (E) (int) : premiere colonne a lire dans l'image */ -/* nombre_lignes_lire (E) (int) : nombre de lignes a lire */ -/* nombre_colonnes_lire (E) (int) : nombre de colonnes a lire */ -/* pas_ligne (E) (int) : pas en ligne */ -/* pas_colonne (E) (int) : pas en colonne */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels lus alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_lecture_canal_bsq (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ -CAI_OK_KO cai_lecture_canal_bsq(CAI_IMAGE *image1 , - int *canal , - int *premiere_ligne , - int *premiere_colonne, - int *nombre_lignes_lire , - int *nombre_colonnes_lire, - int *pas_ligne , - int *pas_colonne, - unsigned char *data_image ) - -{ - - int num,i,j,k; /* variables de travail */ - long int pt_oct; /* position courante dans le fichier image */ - long int no_oct; /* numero du premier octet a lire */ - int iret; /* indicateur d'erreur */ - long int lig; /* indice de boucle sur les lignes */ - long int oct_pix; /* nb octets par pixels */ - long int nb_oct; /* nb oct =1er octet a lire - position courante */ - long int oct_lig; /* nb oct. par ligne en considerant taille pixel */ - unsigned char *buf_lec; /* buffer lecture d'une ligne */ - unsigned char *deb,*pch; /* pointeur chaine pour transfert buffer sortie */ - unsigned char *data_image2;/* pointeur donnees image pour inversion octets */ - int taille_image,Nb; /* taille en octets de l'image */ - long int n; -/*........................... - Initialisations diverses - ..........................*/ - - iret=CAI_OK; - num=(int)image1->ACCES_CANAL_INT[(*canal)-1]; - oct_pix=image1->NBOCT_PIX; - oct_lig=oct_pix*(image1->NB_COL); - -/*.......................................*/ -/* verification si lecture image entiere */ -/*.......................................*/ - if ((*nombre_lignes_lire==image1->NB_LIG)&&(*nombre_colonnes_lire==image1->NB_COL) - &&(*pas_ligne==1)&&(*pas_colonne==1)) - { - oct_lig=oct_pix*(image1->NB_COL)*(image1->NB_LIG); - - /* positionnement en debut de fichier */ - pt_oct=lseek(num,0L,0); - - /* lecture du canal complet */ - n=read(num,data_image,oct_lig); - if (n<=0) - { - iret=CAI_KO; - sprintf(CAI_ERREUR,"Erreur lecture donnee image BSQ dans %s", - image1->NOM_IMAGE); - - } - else - iret=CAI_OK; - } - else - { -/*.............................................. - allocation de memoire pour lire une ligne image - ............................................. */ - buf_lec = (unsigned char *) malloc(oct_lig); - if (buf_lec == NULL) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Probleme allocation memoire"); - } - else - { -/*.................... - Initialisation - ......................*/ - lig=*premiere_ligne; - i=1; - pch=data_image; - /*..................... - Pour chaque ligne a lire - .......................................*/ - while ((i <= (*nombre_lignes_lire))&&(iret==CAI_OK)) - { - -/*............................................ - Recherche de la position courante dans le fichier - ............................................*/ - pt_oct=lseek(num,0L,1); - -/*................................ - Calcul du numero du 1er octet a lire - ....................................*/ - no_oct=image1->POS_OCTET[(*canal)-1]+((lig-1)*oct_lig); - -/*.................................. - Saut d'octets pour etre positionne sur la ligne a lire - .......................................*/ - nb_oct=(long)(no_oct-pt_oct); - lseek(num,nb_oct,1); - -/*........................................... - lecture d'une ligne image - ................................................*/ - n=read(num,buf_lec,oct_lig); - if (n<=0) - { - iret=CAI_KO; - sprintf(CAI_ERREUR,"Erreur lecture donnee image BSQ %s", - image1->NOM_IMAGE); - - } - else - { -/*...................................... - Sauvegarde des donnees lues entenant compte du pas - d'echantillonnage en colonne - ........................................*/ - deb=buf_lec+((*premiere_colonne)-1)*oct_pix; - j=1; - while (j <= (*nombre_colonnes_lire)) - { - - for (k=0;k<oct_pix;k=k+1) - { - *(pch+k)=*(deb+k); - } - pch=pch+oct_pix; - j=j+1; - deb=deb+((*pas_colonne)*oct_pix); - } - - } - i=i+1; - lig=lig+(*pas_ligne); - - } - - free(buf_lec); - } - } -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : prise en compte de l'information INTEL ou IEEE*/ -/* en lecture et ecriture dans l'entete .hd */ -/*****************************************************************************/ - - if ( (iret!= CAI_KO) && (image1->INV_OCTETS==1) && (oct_pix!=1) ) - { - taille_image = (*nombre_lignes_lire)*oct_pix*(*nombre_colonnes_lire); - data_image2 = NULL; - data_image2 = (unsigned char *) calloc(taille_image, - sizeof(unsigned char)); - if (data_image2 == NULL) - { - strcpy(CAI_ERREUR,"Erreur allocation memoire cai_lecture_canal"); - iret=CAI_KO; - } - else - { - /*modification ordre selon nb octets par pixel*/ - swab( (void*)(data_image), (void*)(data_image2), taille_image); - - if (oct_pix!=2) - { - Nb = taille_image/2; - cai_inverser_tableau(data_image, data_image2,Nb); - } - else - for (i=0; i<taille_image;i++) - { - /*stockage dans data_image*/ - data_image[i] = data_image2[i]; - } - - if (data_image2!= NULL) free(data_image2); - } - } - - return(iret); - } -/* - Fin de l'operation cai_lecture_canal_bsq -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ecriture_canal_bsq */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ecriture d'un canal d'une image bsq */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ecriture_canal_bsq(image1, canal, */ -/* ------------------ premiere_ligne, */ -/* nombre_lignes_ecrire, */ -/* nombre_colonnes_ecrire,*/ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (long int) : numero du canal a ecrire */ -/* premiere_ligne (E) (long int) : 1ere ligne a ecrire ds l'image */ -/* nombre_lignes_ecrire (E) (long int) : nombre de lignes a ecrire */ -/* nombre_colonnes_ecrire(E) (long int) : nombre de lignes a ecrire */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels ecris alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_ecriture_canal_bsq (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_OK_KO cai_ecriture_canal_bsq (CAI_IMAGE *image1 , - int *canal , - int *premiere_ligne , - int *nombre_lignes_ecrire , - int *nombre_colonnes_ecrire, - unsigned char *data_image ) - -{ - - long int position_first_lig; /* position de la 1ere ligne a ecrire */ - long int position_courante; /* position courante dans le fichier */ - long int deplacement; /* deplacement a effectuer */ - int i_ligne; /* compteur de lignes */ - unsigned char *buff_lig; /* tableau contenant une ligne a ecrire */ - long int cr_write; /* code retour de write */ - int num; /* descripteur de fichier */ - int nboct_pix; /* nombre d'octets par pixel */ - int tot_pix; /* nb de pixels total a ecrire */ - -/* initialisations */ - -i_ligne = 0; -num = image1->ACCES_CANAL_INT[*canal-1]; -nboct_pix = image1->NBOCT_PIX; - -/*.......................................*/ -/* verification si ecriture image entiere */ -/*.......................................*/ - if ((*nombre_lignes_ecrire==image1->NB_LIG)&& - (*nombre_colonnes_ecrire==image1->NB_COL)) - { - tot_pix=nboct_pix*(image1->NB_COL)*(image1->NB_LIG); - - /* positionnement en debut de fichier */ - position_first_lig=lseek(num,0L,0); - - /* ecriture du canal complet */ - cr_write = write ( num , data_image,tot_pix); - if (cr_write != tot_pix) - { - sprintf(CAI_ERREUR,"Erreur ecriture donnee image BSQ %s", - image1->NOM_IMAGE); - - goto ERREUR; - } - } - else - { - -/********************************************************/ -/* Calcul de la position de la premiere ligne a ecrire */ -/********************************************************/ - -position_first_lig =(long int) ( image1->POS_OCTET[*canal-1]+ - (( *premiere_ligne - 1) * (*nombre_colonnes_ecrire) - * nboct_pix)); - - -/********************************************************/ -/* Recuperation de la position courante */ -/********************************************************/ - -position_courante = lseek ( num , 0L , 1 ); - - -/********************************************************/ -/* Deplacement jusqu'a la premiere ligne a ecrire */ -/********************************************************/ - -deplacement = position_first_lig - position_courante; -lseek ( num , deplacement , 1 ); - -/********************************************************/ -/* TANT QUE il y a des lignes a ecrire */ -/********************************************************/ -while (i_ligne < (*nombre_lignes_ecrire)) -{ - -/********************************************************/ -/* extraction de la ligne du tableau */ -/********************************************************/ - - buff_lig = data_image + (*nombre_colonnes_ecrire) * nboct_pix * i_ligne; - -/********************************************************/ -/* ecriture de la ligne */ -/********************************************************/ - - cr_write = write ( num , buff_lig , - (*nombre_colonnes_ecrire) * nboct_pix ); - if ( cr_write != (*nombre_colonnes_ecrire)*nboct_pix ) - { - sprintf( CAI_ERREUR , "Erreur ecriture canal image bsq_cnes %s", - image1->NOM_IMAGE); - - goto ERREUR; - } - -/********************************************************/ -/* incrementation du nombre de lignes */ -/********************************************************/ - - i_ligne++; -/********************************************************/ -/* FIN TANT QUE */ -/********************************************************/ - } -} - - -return (CAI_OK); - -ERREUR : - -return (CAI_KO); - - -} - -/* - Fin de l'operation cai_ecriture_canal_bsq -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ferme_bsq */ -/* ---------- */ -/* */ -/* ROLE : fonction de fermeture d'une image au format bsq et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ferme_bsq(image1) */ /* ------------------ */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* */ -/* cai_ferme_bsq (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_OK_KO cai_ferme_bsq (CAI_IMAGE *image1) - -{ - int iret; /* code retour de l'operation */ - int i_can; /* indice du canal a fermer */ - int num; /* descripteur du fichier a fermer */ - - iret=CAI_OK; -/*............................................. - Fermeture de tous les canaux - .............................................*/ - for (i_can=0;i_can<image1->NB_CANAUX;i_can=i_can+1) - { - - num=image1->ACCES_CANAL_INT[i_can]; - if (num>0) close(num); - } - - return (iret); -} - -/* - Fin de l'operation cai_ferme_bsq -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_dest_ima_bsq */ -/* ---------- */ -/* */ -/* ROLE : fonction de destruction d'une image stocke en bsq et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_dest_ima_bsq(repertoire,nom_ima) */ /* ------------------ */ -/* repertoire (E) (char *) : repertoire de l'image a detruire */ -/* nom_image (E) (char *) : nom de l'image a detruire avec repertoire */ -/* */ -/* cai_dest_ima_bsq (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - - -CAI_OK_KO cai_dest_ima_bsq ( char *repertoire , - char *nom_ima ) - -{ -int i_can; /* compteur de canaux */ -long int iret; /* code retour fonction fermetrue lecture */ -char str_num_canal[3]; /* suffixe numero du canal */ -char nom_fic_entete[1024]; /* nom du fichier entete a detruire */ -char nom_ima_complet[1024]; /* repertoire + nom de l'image */ -char nom_fic_canal[1024]; /* nom du fichier canal a detruire */ - -long int cr_stat; /* code retour de fonction status de fichier */ -struct stat buf_stat; /* structure decrivant status de fichier */ - -CAI_IMAGE *image1; /* structure ouverture image */ -int nb_can; /* nombre de canaux de l'image */ -int nboct_pix; /* nombre d'octets par pixel image */ -int nb_col; /* nombre de colonnes de l'image */ -int nb_lig; /* nombre de lignes de l'image */ - -/************************************************/ -/* Constitution du nom du fichier d'entete */ -/************************************************/ -if ((long int)strlen(repertoire)!= 0) -{ - sprintf(nom_ima_complet,"%s/%s",repertoire,nom_ima); -} -else -{ - sprintf(nom_ima_complet,"%s",nom_ima); -} - sprintf(nom_fic_entete ,"%s.hd", nom_ima_complet); -/************************************************/ -/* Extraction des caracteristiques de l'image */ -/* du fichier entete par l'appel a la fonction */ -/* cai_ouvre_lecture_bsq */ -/************************************************/ - - image1 = cai_ouvre_lecture_bsq ( repertoire,nom_ima, &nb_can ,&nboct_pix , - &nb_col , &nb_lig ); - if ( image1 == NULL) goto ERREUR; - - image1->NB_CANAUX=nb_can; - image1->NB_COL=nb_col; - image1->NB_LIG=nb_lig; - image1->NBOCT_PIX=nboct_pix; - - iret=cai_ferme_bsq(image1); - -/************************************************/ -/* Destruction du fichier d'entete */ -/************************************************/ - -cr_stat = stat ( nom_fic_entete , &buf_stat ); -if ( cr_stat == 0 ) - unlink ( nom_fic_entete ); - - -/************************************************/ -/* Constitution un a un des noms des fichiers */ -/* canaux et destruction */ -/************************************************/ - -for ( i_can = 0 ; i_can < nb_can ; i_can++ ) -{ - sprintf(nom_fic_canal,"%s.c%d",nom_ima_complet,i_can+1); - cr_stat = stat ( nom_fic_canal , &buf_stat ); - if ( cr_stat == 0 ) - unlink ( nom_fic_canal ); - sprintf(nom_fic_canal,"%s.C%d",nom_ima_complet,i_can+1); - cr_stat = stat ( nom_fic_canal , &buf_stat ); - if ( cr_stat == 0 ) - unlink ( nom_fic_canal ); -} - - -return (CAI_OK); - -ERREUR : - -return (CAI_KO); - - -} -/* - Fin de l'operation cai_dest_ima_bsq -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_modif_nbbitspix_bsq */ -/* ---------- */ -/* */ -/* ROLE : permet de modifier le nombre de bits significatifs par pixel */ -/* ----- dans l'entete de fichier (.hd) */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_modif_nbbitspix_bsq(image1,NbBitsPix) */ /* ------------------ */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* NbBitsPix (E) (long int) : nb de bits significatifs par pixel */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_OK_KO cai_modif_nbbitspix_bsq(CAI_IMAGE *image1,int NbBitsPix) - -{ - char fichierE[1024]; /* fichier a traiter */ - FILE *fic; /* pointeur descripteur fichier */ - int retour; - - -/* Ouverture du fichier d'entete */ - - fichierE[0]='\0'; - sprintf(fichierE,"%s.hd",image1->NOM_IMAGE); - fic = fopen(fichierE,"w"); - if (fic == NULL) - { - sprintf(CAI_ERREUR, - "Erreur: Modification fichier %s impossible\n",fichierE); - goto ERREUR; - } - -/* Modification du fichier d'entete */ - rewind(fic); - fprintf ( fic , "TYPE\n"); - fprintf ( fic , "%s\n",image1->COD_PIX ); - fprintf ( fic , "LABEL\n" ); - fprintf ( fic , "%s\n" ,image1->COMMENT); - fprintf ( fic , "CHANNELS\n" ); - fprintf ( fic , "%3d\n" , image1->NB_CANAUX); - fprintf ( fic , "LINES\n" ); - fprintf ( fic , "%5d\n" , image1->NB_LIG); - fprintf ( fic , "COLUMNS\n" ); - fprintf ( fic , "%5d\n" , image1->NB_COL ); - fprintf ( fic , "BITS PER PIXEL\n" ); - fprintf ( fic , "%2d\n" , NbBitsPix ); - fprintf ( fic, "SENSCODAGE\n"); - retour=strncmp(image1->SENS_COD,"BE",2); - if (retour == 0) - fprintf ( fic , "IEEE\n" ); - else - fprintf ( fic , "INTEL\n" ); - - fclose ( fic ); - - return(CAI_OK); - -ERREUR : - return(CAI_KO); -} -/* - Fin de l'operation cai_modif_nbbitspix_bsq -*/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_modifie_bsq */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture-ecriture d'une image au format */ -/* ----- bsq et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_modifie_bsq (nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_modifie_bsq (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ /* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_IMAGE *cai_ouvre_modifie_bsq(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) - - -{ - FILE *fic_in; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - int iret; /* indicateur de retour ok ou pas */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char nom_fic_canal[1024]; /* nom fichier canal dont on teste existence*/ - char label[80]; /* contient un enregistrement du fichier */ - int nbplan; /* nombre de canaux dans le fichier en-tete */ - int nbbit; /* nb de bits par pixel du fichier en-tete */ - int retour; /* retour de la fonction comparaison chaines*/ - char *deb,*deb1,*pch0; /* pointeurs sur chaine de caracteres */ - char car[4]; /* indice du canal traite */ - int i,num,IndExtens; /* indice */ - char Extens[25]; /* Extension possible du fichier */ - struct stat buf_stat; /* structure decrivant status de fichier */ - char *type_machine; /* ordre rangement octets machine de travail*/ - int cmp; /* retour de comparaison de chaine */ - int reconnaissance_type; - char CAN[2]; - char COD_PIX[5]; - - /*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - *nb_can=0; - - *nb_lig=0; - - *nb_col=0; - - *nboct_pix=0; - - iret=1; - IndExtens = 0; - pch0=NULL; - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); - - - /*.................................. - determination ordre de rangement - des octets sur machine de travail - ......................................*/ - type_machine = cai_test_pFpf(); - -/*****************************************************************************/ -/* MOD : VERSION : 4.1 : FA:Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_modifie"); - } - else - { -/*................................................. - Constitution du nom du fichier entete - .................................................*/ - pch0 = strstr(nom_image,"."); - if (pch0 != NULL) - { - *pch0 = '\0'; - pch0=pch0 + 1; - sprintf(Extens,"%s",pch0); - if (strcmp(Extens,"hd")!=0) - IndExtens=1; - } - nom_fic[0]='\0'; - if ((long int)strlen(repert)!= 0) - { - sprintf(nom_fic,"%s/%s.hd",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.hd",nom_image); - } - sprintf(image1->NOM_IMAGE,"%s/%s",repert,nom_image); -/*........................ - Ouverture du fichier entete - ..........................................*/ - fic_in=NULL; - fic_in=fopen(nom_fic,"r"); - if (fic_in==NULL) - { - iret=0; - sprintf(CAI_ERREUR,"Erreur ouverture fichier entete BSQ-CNES %s", - nom_fic); - } - else - { -/*.................................... - Decodage des informations TYPE - ............................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"TYPE",4); - if (retour!=0) - { - sprintf(CAI_ERREUR, - "Informations incoherentes ligne TYPE dans %s", - nom_fic); - iret=0; - } - else - { - fscanf(fic_in,"%s\n",COD_PIX); - pch0=cai_En_majuscule( COD_PIX ); - -/* Verification si type de codage reconnu */ - reconnaissance_type = cai_istyp_connu(pch0); - -/*.................................. - Decodage du label - ......................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"LABEL",5); - if (retour!=0) - { - sprintf(CAI_ERREUR, - "Informations incoherentes ligne LABEL dans %s", - nom_fic); - iret=0; - } - else - { - fgets(image1->COMMENT,80,fic_in); - image1->COMMENT[strlen(image1->COMMENT)-1]='\0'; - - /*........................................ - Decodage du nombre de canaux - .........................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"CHANNELS",8); - if (retour!=0) - { - sprintf(CAI_ERREUR, - "Informations incoherentes ligne CHANNELS dans %s", - nom_fic); - - iret=0; - } - else - { - fscanf(fic_in,"%d\n",&nbplan); - -/*....................................... - Decodage du nombre de lignes - ........................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"LINES",5); - if (retour!=0) - { - sprintf(CAI_ERREUR, - "Informations incoherentes ligne LINES dans %s", - nom_fic); - iret=0; - } - else - { - fscanf(fic_in,"%d\n",nb_lig); - - -/*....................................... - Decodage du nombre de colonnes - ........................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"COLUMNS",7); - if (retour!=0) - { - sprintf(CAI_ERREUR, - "Informations incoherentes ligne COLUMNS dans %s", - nom_fic); - iret=0; - } - else - { - - fscanf(fic_in,"%d\n",nb_col); - -/*....................................... - Decodage du nombre de bits par pixel - ........................................*/ - fgets(label,80,fic_in); - retour=strncmp(label,"BITS PER PIXEL",14); - if (retour!=0) - { - sprintf(CAI_ERREUR, - "Informations incoherentes ligne BITS dans %s", - nom_fic); - iret=0; - } - else -{ - fscanf(fic_in,"%d\n",&nbbit); - image1->NB_BITS_PIX = nbbit; - -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : prise en compte de l'information INTEL ou IEEE*/ -/* en lecture et ecriture dans l'entete .hd */ -/*****************************************************************************/ -/*.................................. - Decodage du sens de codage si présent - ......................................*/ - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"SENSCODAGE",10); - if (retour!=0) - { -/* Si absent, pas d'inversion */ - image1->INV_OCTETS =0; - sprintf(image1->SENS_COD,type_machine); - } - else - { - fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"IEEE",4); - if (retour==0) - sprintf(image1->SENS_COD,"BE"); - else - sprintf(image1->SENS_COD,"LE"); - cmp = strncmp(type_machine,image1->SENS_COD,2); - if (cmp!=0) - { - image1->INV_OCTETS =1; - } - else - { - image1->INV_OCTETS =0; - } - } - } - } - } - } - } - - } -/*.................................. - Fermeture du fichier - ......................................*/ - if (fic_in !=NULL) - { - fclose(fic_in); - fic_in=NULL; - } - } - - if (iret !=0) - { -/*.................................. - Initialisation du nombre d'octets par pixel - ........................................................*/ - if ((nbbit%8)==0) - *nboct_pix=(int)(nbbit/8); - else - *nboct_pix=(int)((nbbit/8)+1); - - if (reconnaissance_type != -1) - sprintf(image1->COD_PIX,"%s",COD_PIX); - else - { - sprintf(image1->COD_PIX,"UND"); - - if (*nboct_pix==1) - sprintf(image1->COD_PIX,"OCT"); - else if (*nboct_pix==2) - sprintf(image1->COD_PIX,"I2"); - else if (*nboct_pix==4) - { - retour=strncmp(COD_PIX,"I4",2); - if (retour==0) - sprintf(image1->COD_PIX,"I4"); - else - { - retour=strncmp(COD_PIX,"R4",2); - if (retour==0) - sprintf(image1->COD_PIX,"R4"); - } - - } - else if (*nboct_pix==8) - sprintf(image1->COD_PIX,"R8"); - } - -/*....................................... - INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL - .....................................................*/ - deb = image1->NOM_FIC_CAN; - deb1= image1->NOM_UTIL_CAN; - if ((nbplan==1)&&(IndExtens==1)) - { -/* Verification de l'existence du fichier demande et ouverture */ - nom_fic[0]='\0'; - if ((long int)strlen(repert)!= 0) - sprintf(nom_fic,"%s/%s.%s",repert,nom_image,Extens); - else - sprintf(nom_fic,"%s.%s",nom_image,Extens); - nom_fic_canal[0]='\0'; - sscanf(nom_fic,"%s",nom_fic_canal); - num=open(nom_fic_canal,O_RDWR|O_BINARY,0); - if (num!= -1) - { - sprintf(deb,"%s.%s",nom_image,Extens); - deb=deb+100; - sprintf(deb1,"%s.%s",nom_image,Extens); - deb1=deb1+100; - } - image1->ACCES_CANAL_INT[*nb_can]=num; - image1->POS_OCTET[*nb_can]=0; - *nb_can = *nb_can + 1; - } - else - { -/*................................................... - recherche du nombre de canaux de l'image si pas d'extension donnee - ..........................................................*/ - nom_fic[0]='\0'; - if ((long int)strlen(repert)!= 0) - { - sprintf(nom_fic,"%s/%s.c",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.c",nom_image); - } - sprintf(nom_fic_canal,"%s1",nom_fic); - retour = stat ( nom_fic_canal , &buf_stat ); - if ( retour != 0 ) - { - sprintf(CAN,"C"); - if ((long int)strlen(repert)!= 0) - { - sprintf(nom_fic,"%s/%s.C",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.C",nom_image); - } - - } - else - sprintf(CAN,"c"); - - for (i=1;i<CAI_NB_MAX_CAN;i=i+1) - { - nom_fic_canal[0]='\0'; - sprintf(nom_fic_canal,"%s%d",nom_fic,i); - num=open(nom_fic_canal,O_RDWR|O_BINARY,0); - if (num!= -1) - { - if (*nb_can<CAI_NB_MAX_CAN) - { - sscanf(nom_image,"%s",deb); - strcat(deb,CAN); - sprintf(car,"%d",(*nb_can)+1); - strcat(deb,car); - deb=deb+100; - sscanf(nom_image,"%s",deb1); - strcat(deb1,CAN); - strcat(deb1,car); - deb1=deb1+100; - } - image1->ACCES_CANAL_INT[*nb_can]=num; - image1->POS_OCTET[*nb_can]=0; - - *nb_can=*nb_can+1; - } - } - if (*nb_can!=nbplan) - { - sprintf(CAI_ERREUR, - "incoherence au niveau du nombre de fichiers canaux dans %s", - nom_fic); - - iret=0; - } - } - } - } - if (iret == 0) - { - return (NULL); - } - else - { - return(image1); - } - -} - -/* - Fin de l'operation cai_ouvre_modifie_bsq -*/ diff --git a/Utilities/CAI/cai_dll/src/cai_fonctions.c b/Utilities/CAI/cai_dll/src/cai_fonctions.c deleted file mode 100755 index 3acec1167687456b81609d90f2562949f79f1455..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/src/cai_fonctions.c +++ /dev/null @@ -1,2499 +0,0 @@ -/*****************************************************************************/ -/* */ -/* PROJET : COUCHE ACCES IMAGE */ -/* ------- */ -/* */ -/* MODULE : cai_fonctions.c */ -/* ------- */ -/* */ -/* ROLE : contient l'interface entre l'utilisateur et la Couche Acces */ -/* ------- Image, avec les fonctionnalites de premier niveau */ -/* */ -/* AUTEUR : R.CHAISEMARTIN (CISI) */ -/* ------- */ -/* */ -/* DATE DE CREATION : fevrier 1995 */ -/* ----------------- */ -/* */ -/* LANGAGE : C */ -/* -------- */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ -/* MOD : VERSION : 2 : DM : optimisation */ -/*****************************************************************************/ -/* MOD : VERSION : 4.0 : DM : integration du format GESSIMU (sept 1999) */ -/* MOD : VERSION : 4.0 : DM : integration du format GRILLES (sept 1999) */ -/*****************************************************************************/ -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : FA : modifications pour compatibilite HP64bits */ -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : integration des formats SPOT1A4 et SPOT5 */ -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : modification lecture des repertoires pour PC */ -/*****************************************************************************/ -/* MOD : VERSION : 4.4 : DM : suppression du format multiscope, modif SPOT5 */ -/*****************************************************************************/ -/* MOD : VERSION : 4.6 : DM : integration du format RADAR_CNES */ -/*****************************************************************************/ -/* MOD : VERSION : 4.6 : FA : avertissement des formats non disponibles */ -/* en modification */ -/*****************************************************************************/ -/* MOD : VERSION : 4.8 : DM: Sous Cygwin separateur='/' ou '\' */ -/*****************************************************************************/ -/* MOD : VERSION : 5.3 : DM : prise en compte du format bandeau */ -/*****************************************************************************/ - - -/*---------------------------------------------------------------------------*/ -/* Inclusion des fichiers STANDARDS (.h) */ -/*---------------------------------------------------------------------------*/ -#include <stdio.h> -#include <sys/types.h> -#include <string.h> -#include <dirent.h> -#include <stdlib.h> - -#define _CAI_IMAGE -#define IN_CAI_FONC - -#include "cai_image.h" - - char IND_GRILLES; /* indicateur si image ou grille */ - char IND_SPOT; /* indicateur si SPOT1A4 (1),SPOT5BIL (B),SPOT5TIF(T) */ -/*----------------------------------------------------------------------------*/ -/* Variable pour la gestion en configuration */ -/*----------------------------------------------------------------------------*/ -static char *rcs_id="$Header: cai_fonctions.c,v 1.13 01/02/15 14:24:58 cmf Exp $"; - - -/*****************************************************************************/ -/*****************************************************************************/ -/* */ -/* Definition des OPERATIONS EXTERNES */ -/* */ -/*****************************************************************************/ -/*****************************************************************************/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_liste_format */ -/* ---------- */ -/* */ -/* ROLE : fonction de listage des formats reconnus par la Couche Image */ -/* ------ */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : int cai_liste_format(tab_format,tab_suffixe) */ -/* ----------------- */ -/* */ -/* tab_format[] (S) (char **) : pointeur sur tableau des formats connus*/ -/* alloue par la fonction,il doit etre */ -/* LIBERE PAR L'APPELANT */ -/* tab_suffixe[] (S) (char **) : pointeur sur le tableau des suffixes */ -/* des formats reconnus : 1 pour 1 canal */ -/* 2 pour plusieurs canaux */ -/* alloue par la fonction,il doit etre */ -/* LIBERE PAR L'APPELANT */ -/* */ -/* cai_liste_format(S) (long int) : nombre de formats reconnus par CAI */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -long int cai_liste_format(char ***tab_format,char **(tab_suffixe[2])) - -{ -long int nb; /* code retour de la fonction cai_liste_format */ -long int i,j; - -/*..................................... - ALLOCATION DU TABLEAU CONTENANT LA LISTE DES FORMATS DISPONIBLES - ET LA LISTE DES SUFFIXES CORRESPONDANT - ......................................*/ - nb=CAI_NB_FORMAT; - *tab_format = (char **) calloc(nb,sizeof(char *)); - tab_suffixe[0] = (char **) calloc(nb,sizeof(char *)); - tab_suffixe[1] = (char **) calloc(nb,sizeof(char *)); - - - - - for (i=0;i<nb;i++) - { - (*tab_format)[i]=(char *)calloc(1,20); - strcpy((*tab_format)[i],CAI_NOM_FORMAT[i]); - for (j=0;j<2;j++) - { - tab_suffixe[j][i]=(char *)calloc(1,8); - strcpy(tab_suffixe[j][i],CAI_SUF_FORMAT[j][i]); - } - - } -return(nb); - -} -/* Fin de l'operation cai_liste_format -*/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_liste_image */ -/* ---------- */ -/* */ -/* ROLE : fonction de listage des images d'un format donne */ -/* ------ */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : int cai_liste_image(repert,type_image,tab_ima) */ -/* ----------------- */ -/* */ -/* repert (E) (char *) : repertoire a explorer */ -/* type_image (E) (char *) : format des images a lister */ -/* tab_ima[] (S) (char **) : pointeur sur tableau des images listees*/ -/* alloue par la fonction,il doit etre */ -/* LIBERE PAR L'APPELANT */ -/* */ -/* cai_liste_image(S) (long int) : =-1 repertoire inexistant */ -/* =-2 format non pris en compte */ -/* =>0 nombre d'images listees */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -long int cai_liste_image(char *repert, - char *type_image, - char ***tab_ima) - - -{ - long int nb; /* code retour de la fonction cai_liste_image */ - long int (*comp) ( ); /* pointeur sur fonction */ - DIR *dirp; /* pointeur sur structure ouverture repertoire */ - -/*.................... - Initialisations - ..................*/ - nb=0; - CAI_ERREUR[0]='\0'; - IND_GRILLES = '\0'; - IND_SPOT = '\0'; -/*.............................................. - Verification existence repertoire demande - ...............................................*/ - dirp=opendir(repert); - if (dirp ==0) - { - /* repertoire demande inexistant */ - nb=-1; - sprintf(CAI_ERREUR,"repertoire %s inexistant \n",repert); - - } - else - { -/*.............................................. - Initialisation d'un pointeur sur fonction dependant du format des images - ................................................ */ - - if (strcasecmp(type_image,"INRIA") == 0) - { - comp = (cai_liste_ima_inria) ; - } - - else if (strcasecmp(type_image,"ONERA") == 0) - { - comp = (cai_liste_ima_onera) ; - } - - else if (strcasecmp(type_image,"BSQ") == 0) - { - comp = (cai_liste_ima_bsq) ; - } - - else if (strcasecmp(type_image,"BIP") == 0) - { - comp = (cai_liste_ima_bip) ; - } -#ifdef _HDF16 - else if (strncasecmp(type_image,"HDF",3) == 0) - { - comp = (cai_liste_ima_hdf16) ; - } -#endif - - else if (strcasecmp(type_image,"BIL") == 0) - { - comp = (cai_liste_ima_bil) ; - } - - else if (strcasecmp(type_image,"LUM") == 0) - { - comp = (cai_liste_ima_lum) ; - } - - else if (strcasecmp(type_image,"GESSIMU") == 0) - { - comp = (cai_liste_ima_gessimu) ; - } - - else if (strcasecmp(type_image,"GDB") == 0) - { - IND_GRILLES = 'B'; - comp = (cai_liste_ima_grilles) ; - } - - else if (strcasecmp(type_image,"GDR") == 0) - { - IND_GRILLES = 'R'; - comp = (cai_liste_ima_grilles) ; - } - - else if (strcasecmp(type_image,"TIFF") == 0) - { - comp = (cai_liste_ima_tiff) ; - } - - else if (strcasecmp(type_image,"RASTERFILE") == 0) - { - comp = (cai_liste_ima_sun_raster) ; - } - else if (strcasecmp(type_image,"JPEG") == 0) - { - comp = (cai_liste_ima_jpeg) ; - } - else if (strcasecmp(type_image,"SPOT1A4") == 0) - { - IND_SPOT = '1'; - comp = (cai_liste_ima_spot) ; - } - else if (strcasecmp(type_image,"SPOT5TIF") == 0) - { - IND_SPOT = 'T'; - comp = (cai_liste_ima_spot) ; - } - else if (strcasecmp(type_image,"SPOT5BIL") == 0) - { - IND_SPOT = 'B'; - comp = (cai_liste_ima_spot) ; - } - else if (strcasecmp(type_image,"RADAR") == 0) - { - comp = (cai_liste_ima_radar) ; - } - else if (strcasecmp(type_image,"BANDEAU") == 0) - { - comp = (cai_liste_ima_bandeau) ; - } - - else - { - - /* format non connu de la Couche Acces Image */ - nb = -2; - sprintf(CAI_ERREUR,"format %s non reconnu \n",type_image); - - } - - /*........................................... - Appel de la fonction pointee par comp avec la liste des parametres - suivants : - repertoire de stockage des images - pointeur sur tableau contenant la liste des images a lister - ......................................................................*/ - closedir(dirp); - if ( nb == 0 ) - { - if (IND_GRILLES == '\0') - { - if (IND_SPOT == '\0') - nb = (*comp)(repert,tab_ima); - else - nb = (*comp)(IND_SPOT,repert,tab_ima); - } - else - nb = (*comp)(IND_GRILLES,repert,tab_ima); - } - } - IND_GRILLES = '\0'; - IND_SPOT = '\0'; - return (nb); - -} -/* Fin de l'operation cai_liste_image -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_lecture_image */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture d'une image d'un format donne */ -/* ----- et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_lecture_image (nom_image, */ -/* ---------------- type_image, */ -/* nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* type_image (E) (char *) : format de l'image a ouvrir */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_lecture_image (S) (CAI_IMAGE *) : =NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ -/* */ -/* VERSION : V3 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_IMAGE *cai_ouvre_lecture_image (char *nom_image, - char *type_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) - -{ - - int nb; /* indicateur d'erreurs rencontres */ - CAI_IMAGE *image1; /* descripteur de fichier retour fonction */ - CAI_IMAGE *(*comp) ( ); /* pointeur sur fonction */ - char repert[1024]; /* repertoire de stockage de l'image */ - char image[1024]; /* nom de l'image a ouvrir en lecture */ - char format[20]; /* format de stockage de l'image a lire */ - long int i,ind; /* variables de travail */ - char *pch,*deb; /* pointeurs de travail */ - long int nb1,nb2; /* indice de longueur significative */ - char car; /* variable de travail */ - DIR *dirp; /* pointeur sur structure ouverture repertoire */ - CAI_OK_KO icr; /* Compte-rendu des fonctions DA */ - -/*...................... - Initialisations - .......................*/ - nb=1; - strcpy(format,type_image); - CAI_ERREUR[0]='\0'; - IND_GRILLES = '\0'; - IND_SPOT = '\0'; - -/*................................................... - Recherche du type de fichier si reconnaissance automatique demande - ...................................................*/ - if (strcasecmp(format,"AUTO")== 0) - { - for( i = 0 ; i< CAI_NB_EXTENSIONS ; i++) - { - if(strstr(nom_image,CAI_SUFFIXES[i]) != NULL ) - { - ind=CAI_NUMEROS[i]; - strcpy(format,CAI_NOM_FORMAT[ind]); - } - } - } - - -/*.............................................. - Initialisation d'un pointeur sur fonction dependant du format des images - ................................................ */ - - if (strcasecmp(format,"INRIA") == 0) - { - comp = (cai_ouvre_lecture_inria) ; - } - - else if (strcasecmp(format,"ONERA") == 0) - { - comp = (cai_ouvre_lecture_onera) ; - } - - else if (strcasecmp(format,"BSQ") == 0) - { - comp = (cai_ouvre_lecture_bsq) ; - } - - else if (strcasecmp(format,"BIP") == 0) - { - comp = (cai_ouvre_lecture_bip) ; - } -#ifdef _HDF16 - else if (strncasecmp(format,"HDF",3) == 0) - { - comp = (cai_ouvre_lecture_hdf16) ; - } -#endif - - else if (strcasecmp(format,"BIL") == 0) - { - comp = (cai_ouvre_lecture_bil) ; - } - - else if (strcasecmp(format,"LUM") == 0) - { - comp = (cai_ouvre_lecture_lum) ; - } - - else if (strcasecmp(format,"GESSIMU") == 0) - { - comp = (cai_ouvre_lecture_gessimu) ; - } - - else if (strcasecmp(format,"GDB") == 0) - { - IND_GRILLES = 'B'; - comp = (cai_ouvre_lecture_grilles) ; - } - - else if (strcasecmp(format,"GDR") == 0) - { - IND_GRILLES = 'R'; - comp = (cai_ouvre_lecture_grilles) ; - } - - else if (strcasecmp(format,"TIFF") == 0) - { - comp = (cai_ouvre_lecture_tiff) ; - } - - else if (strcasecmp(format,"RASTERFILE") == 0) - { - comp = (cai_ouvre_lecture_sun_raster) ; - } - else if (strcasecmp(format,"JPEG") == 0) - { - comp = (cai_ouvre_lecture_jpeg) ; - } - - else if (strcasecmp(type_image,"SPOT1A4") == 0) - { - IND_SPOT = '1'; - comp = (cai_ouvre_lecture_spot) ; - } - else if (strcasecmp(type_image,"SPOT5TIF") == 0) - { - IND_SPOT = 'T'; - comp = (cai_ouvre_lecture_spot) ; - } - else if (strcasecmp(type_image,"SPOT5BIL") == 0) - { - IND_SPOT = 'B'; - comp = (cai_ouvre_lecture_spot) ; - } - else if (strcasecmp(format,"RADAR") == 0) - { - comp = (cai_ouvre_lecture_radar) ; - } - else if (strcasecmp(format,"BANDEAU") == 0) - { - comp = (cai_ouvre_lecture_bandeau) ; - } - - else - { - - /* format non connu de la Couche Acces Image */ - nb = 0; - sprintf(CAI_ERREUR,"format %s non reconnu \n",format); - - } - /*............................................................... - Separation du repertoire de stockage de l'image et du nom propre - .................................................................*/ - if (nb == 1) - { - repert[0]='\0'; - image[0]='\0'; - car='/'; - -#ifdef _WIN - car='\\'; -#endif - pch=(char *)strrchr(nom_image,car); - if (pch == NULL) - { - /* le repertoire est celui courant */ - strcpy(repert,"./"); -#ifdef _WIN - strcpy(repert,".\\"); -#endif - sscanf(nom_image,"%s",image); -/*----------------------------------------------------------*/ -/* Modification septembre 98 demandee par H.Vadon */ -/* Afin de permettre d'utiliser une image monocanale en BSQ */ -/* avec l'extension libre sans .c1 forcement */ -/*----------------------------------------------------------*/ - if (strcasecmp(format,"BSQ") != 0) - { - car='.'; - pch=(char *)strrchr(image,car); - if (pch != NULL) - *pch='\0'; - } - } - else - { - - nb1=( long int)(pch)-( long int)(nom_image); - strncpy(repert,nom_image,nb1); - repert[nb1]='\0'; - deb=nom_image+nb1+1; - nb2=strlen(nom_image)-(nb1+1); - strncpy(image,deb,nb2); - image[nb2]='\0'; - -/*----------------------------------------------------------*/ -/* Modification septembre 98 demandee par H.Vadon */ -/* Afin de permettre d'utiliser une image monocanale en BSQ */ -/* avec l'extension libre sans .c1 forcement */ -/*----------------------------------------------------------*/ - if (strcasecmp(format,"BSQ") != 0) - { - car='.'; - pch=(char *)strrchr(image,car); - if (pch != NULL) - *pch='\0'; - } - - } - - } -/*.............................................. - Verification existence repertoire demande - ...............................................*/ - if ( nb == 1 ) - { - dirp=opendir(repert); - if (dirp ==(DIR *)NULL) - { - /* repertoire demande inexistant */ - nb=0; - sprintf(CAI_ERREUR,"repertoire %s inexistant \n",repert); - } - else - closedir(dirp); - - } - - /*........................................... - Appel de la fonction pointee par comp avec la liste des parametres - suivants : - repertoire de stockage de l'image - nom de l'image - nombre de canaux - nombre d'octets par pixels - nombre de colonnes - nombre de lignes - ......................................................................*/ - if ( nb == 1 ) - { - if (IND_GRILLES == '\0') - { - if (IND_SPOT == '\0') - image1 = (*comp)(repert,image,nb_can,nboct_pix,nb_col,nb_lig); - else - image1 = (*comp)(IND_SPOT,repert,image,nb_can,nboct_pix,nb_col, - nb_lig); - } - else - image1 = (*comp)(IND_GRILLES,repert,image,nb_can,nboct_pix,nb_col, - nb_lig); - IND_GRILLES = '\0'; - IND_SPOT = '\0'; - if (image1 != NULL) - { - strcpy(image1->TYPE_IMAGE,format); - strcpy(image1->NOM_IMAGE,nom_image); - image1->NB_CANAUX=*nb_can; - image1->NB_COL=*nb_col; - image1->NB_LIG=*nb_lig; - image1->NBOCT_PIX=*nboct_pix; - image1->MODE=CAI_LECTURE; - -/*** Traitement de la Colormap si format autre que TIFF et RASTERFILE ***/ - - if ((strcasecmp(format,"RASTERFILE") != 0)&&(strcasecmp(format,"TIFF") != 0)) - { - - icr = cai_lecture_colormap(image1); - - if ( icr == CAI_KO) - return (NULL); - else - return (image1); - } - else - { - return (image1); - } - } - else - return(NULL); - } - else - { - return (NULL); - } -} -/* - Fin de l'operation cai_ouvre_lecture_image.c -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_creation_image */ -/* ---------- */ -/* */ -/* ROLE : fonction de creation et d'ouverture en ecriture d'une image */ -/* ----- dans un format donne et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_creation_image (nom_image, */ -/* ---------------- type_image, */ -/* nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig, */ -/* label) */ -/* */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* type_image (E) (char *) : format de l'image a ouvrir */ -/* nb_can (E) (int ) : nombre de canaux de l'image */ -/* nboct_pix (E) (int ) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (E) (int ) : nombre de lignes de l'image */ -/* nb_col (E) (int ) : nombre de colonnes de l'image */ -/* label (E) (char *) : commentaire lie a l'image */ -/* */ -/* cai_ouvre_creation_image (S) (CAI_IMAGE *) : =NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ -/* */ -/* VERSION : V3 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_IMAGE *cai_ouvre_creation_image ( char *nom_image, - char *type_image, - int nb_can, - int nboct_pix, - int nb_col, - int nb_lig, - char *label) - -{ - - int nb; /* indicateur d'erreurs rencontres */ - CAI_IMAGE *image1; /* descripteur de fichier retour fonction */ - CAI_IMAGE *(*comp) ( ); /* pointeur sur fonction */ - char repert[1024]; /* repertoire de stockage de l'image */ - char image[1024]; /* nom de l'image a ouvrir en ecriture */ - char *pch,*deb; /* pointeurs de travail */ - long int nb1,nb2; /* indice de longueur significative */ - char car; /* variable de travail */ - DIR *dirp; /* pointeur sur structure ouverture repertoire */ - - -/*...................... - Initialisations - .......................*/ - - nb=1; - CAI_ERREUR[0]='\0'; - IND_GRILLES = '\0'; - IND_SPOT = '\0'; -/*................................................................ - Verification de la coherence des donnees en entree - .............................................................*/ - if (nb_can<=0) - { - sprintf(CAI_ERREUR,"Nombre du canal a ecrire incorrect"); - nb=0; - } - - if (nb_lig<=0) - { - sprintf(CAI_ERREUR,"Nombre de lignes a ecrire incorrect"); - nb=0; - - } - - if (nb_col<=0) - { - sprintf(CAI_ERREUR,"Nombre de colonnes a ecrire incorrect"); - nb=0; - } - - -/*.............................................. - Initialisation d'un pointeur sur fonction dependant du format des images - ................................................ */ - if (strcasecmp(type_image,"INRIA") == 0) - { - comp = (cai_ouvre_creation_inria) ; - } - - else if (strcasecmp(type_image,"ONERA") == 0) - { - comp = (cai_ouvre_creation_onera) ; - } - - else if (strcasecmp(type_image,"BSQ") == 0) - { - comp = (cai_ouvre_creation_bsq) ; - } - - else if (strcasecmp(type_image,"BIP") == 0) - { - comp = (cai_ouvre_creation_bip) ; - } - -#ifdef _HDF16 - - else if (strncasecmp(type_image,"HDF",3) == 0) - { - comp = (cai_ouvre_creation_hdf16) ; - } -#endif - - else if (strcasecmp(type_image,"BIL") == 0) - { - comp = (cai_ouvre_creation_bil) ; - } - - else if (strcasecmp(type_image,"LUM") == 0) - { - comp = (cai_ouvre_creation_lum) ; - } - - else if (strcasecmp(type_image,"GESSIMU") == 0) - { - comp = (cai_ouvre_creation_gessimu) ; - } - - else if (strcasecmp(type_image,"GDB") == 0) - { - IND_GRILLES = 'B'; - comp = (cai_ouvre_creation_grilles) ; - } - - else if (strcasecmp(type_image,"GDR") == 0) - { - IND_GRILLES = 'R'; - comp = (cai_ouvre_creation_grilles) ; - } - - else if (strcasecmp(type_image,"TIFF") == 0) - { - comp = (cai_ouvre_creation_tiff) ; - } - - else if (strcasecmp(type_image,"RASTERFILE") == 0) - { - comp = (cai_ouvre_creation_sun_raster) ; - } - else if (strcasecmp(type_image,"JPEG") == 0) - { - comp = (cai_ouvre_creation_jpeg) ; - } - else if (strcasecmp(type_image,"SPOT1A4") == 0) - { - IND_SPOT = '1'; - comp = (cai_ouvre_creation_spot) ; - } - else if (strcasecmp(type_image,"SPOT5TIF") == 0) - { - IND_SPOT = 'T'; - comp = (cai_ouvre_creation_spot) ; - } - else if (strcasecmp(type_image,"SPOT5BIL") == 0) - { - IND_SPOT = 'B'; - comp = (cai_ouvre_creation_spot) ; - } - else if (strcasecmp(type_image,"RADAR") == 0) - { - comp = (cai_ouvre_creation_radar) ; - } - else if (strcasecmp(type_image,"BANDEAU") == 0) - { - nb = 0; - sprintf(CAI_ERREUR,"Ecriture au format BANDEAU non prévue dans CAI \n"); - } - else - { - - /* format non connu de la Couche Acces Image */ - nb = 0; - sprintf(CAI_ERREUR,"format %s non reconnu \n",type_image); - - } - /*............................................................... - Separation du repertoire de stockage de l'image et du nom propre - .................................................................*/ - if (nb == 1) - { - repert[0]='\0'; - image[0]='\0'; - car = '/'; -#ifdef _WIN - car='\\'; -#endif - pch=(char *)strrchr(nom_image,car); - if (pch == NULL) - { - /* le repertoire est celui courant */ - strcpy(repert,"./"); -#ifdef _WIN - strcpy(repert,".\\"); -#endif - sscanf(nom_image,"%s",image); - } - else - { - - nb1=( long int)(pch)-(long int)(nom_image); - strncpy(repert,nom_image,nb1); - repert[nb1]='\0'; - deb=nom_image+nb1+1; - nb2=strlen(nom_image)-(nb1+1); - strncpy(image,deb,nb2); - image[nb2]='\0'; - car='.'; - pch=(char *)strrchr(image,car); - if (pch != NULL) - *pch='\0'; - } - - } -/*.............................................. - Verification existence repertoire demande - ...............................................*/ - if ( nb == 1 ) - { - dirp=opendir(repert); - if (dirp ==0) - { - /* repertoire demande inexistant */ - nb=0; - sprintf(CAI_ERREUR,"repertoire %s inexistant \n",repert); - } - else - { - closedir(dirp); - } - - - } - /*........................................... - Appel de la fonction pointee par comp avec la liste des parametres - suivants : - repertoire de stockage de l'image - nom de l'image - nombre de canaux - nombre d'octets par pixels - nombre de colonnes - nombre de lignes - label lie a l'image - ......................................................................*/ - if ( nb == 1 ) - { - if ((long int)strlen(label)==0) - strcpy(label,image); - if (IND_GRILLES == '\0') - { - if (IND_SPOT == '\0') - image1 = (*comp)(repert,image,&nb_can,&nboct_pix,&nb_col,&nb_lig,label); - else - image1 = (*comp)(IND_SPOT,repert,image,&nb_can,&nboct_pix, - &nb_col,&nb_lig,label); - } - else - image1 = (*comp)(IND_GRILLES,repert,image,&nb_can,&nboct_pix, - &nb_col,&nb_lig,label); - IND_GRILLES = '\0'; - IND_SPOT = '\0'; - if (image1 != NULL) - { - strcpy(image1->COMMENT,label); - strcpy(image1->TYPE_IMAGE,type_image); - strcpy(image1->NOM_IMAGE,nom_image); - image1->NB_CANAUX=nb_can; - image1->NB_COL=nb_col; - image1->NB_LIG=nb_lig; - image1->NBOCT_PIX=nboct_pix; - image1->MODE=CAI_ECRITURE; - - return (image1); - - } - else - return(NULL); - } - else - return (NULL); - -} -/* - Fin de l'operation cai_ouvre_creation_image.c -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_lecture_canal */ -/* ---------- */ -/* */ -/* ROLE : fonction de lecture d'un canal d'une image dans un format donne */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : int cai_lecture_canal(image1, canal, premiere_ligne, */ /* ------------------ premiere_colonne, */ -/* nombre_lignes_lire , */ -/* nombre_colonnes_lire, */ -/* pas_ligne ,pas_colonne, */ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* premiere_ligne (E) ( int) : premiere ligne a lire dans l'image */ -/* premiere _colonne (E) ( int) : premiere colonne a lire dans l'image */ -/* nombre_lignes_lire (E) ( int) : nombre de lignes a lire */ -/* nombre_colonnes_lire (E) ( int) : nombre de colonnes a lire */ -/* canal (E) ( int) : numero du canal a lire */ -/* pas_ligne (E) ( int) : pas en ligne */ -/* pas_colonne (E) ( int) : pas en colonne */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels lus alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_lecture_canal (S) (CAI_OK_KO) : = CAI_OK si correct */ -/* = CAI_KO si PB */ -/* */ -/* VERSION : V3 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_OK_KO cai_lecture_canal(CAI_IMAGE *image1 , - int canal , - int premiere_ligne , - int premiere_colonne, - int nombre_lignes_lire , - int nombre_colonnes_lire, - int pas_ligne , - int pas_colonne, - unsigned char *data_image ) - -{ - long int (*comp) ( ); /* pointeur sur fonction */ - char type_image[20]; /* format de stockage de l'image a lire */ - long int retour; /* indicateur d'erreur de l'operation */ - -/*...................... - Initialisations - .......................*/ - retour=CAI_OK; - strcpy( type_image,image1->TYPE_IMAGE); - CAI_ERREUR[0]='\0'; - IND_GRILLES = '\0'; - IND_SPOT = '\0'; -/*............................................................. - Verification de la coherence des donnees en entree - .............................................................*/ - if ((premiere_ligne<=0)||(premiere_ligne> image1->NB_LIG)) - { - sprintf(CAI_ERREUR,"Premiere ligne a lire incorrecte"); - retour=CAI_KO; - - } - - else if ((premiere_colonne<=0)||(premiere_colonne> image1->NB_COL)) - { - sprintf(CAI_ERREUR,"Premiere colonne a lire incorrecte"); - retour=CAI_KO; - } - - - else if ((canal<=0)||(canal> image1->NB_CANAUX)) - { - sprintf(CAI_ERREUR,"Numero du canal a lire incorrect"); - retour=CAI_KO; - } - - else if ((nombre_lignes_lire<=0)|| - ((nombre_lignes_lire + premiere_ligne -1) > image1->NB_LIG)) - { - sprintf(CAI_ERREUR,"Nombre de lignes a lire incorrect"); - retour=CAI_KO; - } - - else if ((nombre_colonnes_lire<=0)|| - ((nombre_colonnes_lire + premiere_colonne -1) > image1->NB_COL)) - { - sprintf(CAI_ERREUR,"Nombre de colonnes a lire incorrect"); - retour=CAI_KO; - } - if (retour == CAI_OK) - { - -/*.............................................. - Initialisation d'un pointeur sur fonction dependant du format des images - ................................................ */ - if (strcasecmp(type_image,"INRIA") == 0) - { - comp = (cai_lecture_canal_inria) ; - } - - else if (strcasecmp(type_image,"ONERA") == 0) - { - comp = (cai_lecture_canal_onera) ; - } - - else if (strcasecmp(type_image,"BSQ") == 0) - { - comp = (cai_lecture_canal_bsq) ; - } - - else if (strcasecmp(type_image,"BIP") == 0) - { - comp = (cai_lecture_canal_bip) ; - } - -#ifdef _HDF16 - else if (strncasecmp(type_image,"HDF",3) == 0) - { - comp = (cai_lecture_canal_hdf16) ; - } -#endif - - else if (strcasecmp(type_image,"BIL") == 0) - { - comp = (cai_lecture_canal_bil) ; - } - - else if (strcasecmp(type_image,"LUM") == 0) - { - comp = (cai_lecture_canal_lum) ; - } - - else if (strcasecmp(type_image,"GESSIMU") == 0) - { - comp = (cai_lecture_canal_gessimu) ; - } - - else if (strcasecmp(type_image,"GDB") == 0) - { - comp = (cai_lecture_canal_grilles) ; - } - - else if (strcasecmp(type_image,"GDR") == 0) - { - comp = (cai_lecture_canal_grilles) ; - } - - else if (strcasecmp(type_image,"TIFF") == 0) - { - comp = (cai_lecture_canal_tiff) ; - } - - else if (strcasecmp(type_image,"RASTERFILE") == 0) - { - comp = (cai_lecture_canal_sun_raster) ; - } - else if (strcasecmp(type_image,"JPEG") == 0) - { - comp = (cai_lecture_canal_jpeg) ; - } - else if (strcasecmp(type_image,"SPOT1A4") == 0) - { - comp = (cai_lecture_canal_spot) ; - } - else if (strcasecmp(type_image,"SPOT5TIF") == 0) - { - comp = (cai_lecture_canal_spot) ; - } - else if (strcasecmp(type_image,"SPOT5BIL") == 0) - { - comp = (cai_lecture_canal_spot) ; - } - else if (strcasecmp(type_image,"RADAR") == 0) - { - comp = (cai_lecture_canal_radar) ; - } - else if (strcasecmp(type_image,"BANDEAU") == 0) - { - comp = (cai_lecture_canal_bandeau) ; - } - else - { - - /* format non connu de la Couche Acces Image */ - retour = CAI_KO; - sprintf(CAI_ERREUR,"format %s non reconnu \n",type_image); - - - } - } - - /*........................................... - Appel de la fonction pointee par comp avec la liste des parametres - suivants : - - pointeur sur descripteur des fichiers - numero du canal a lire - premiere ligne a lire dans l'image - premiere colonne a lire dans l'image - nombre de lignes a lire - nombre de colonnes a lire - pas en ligne - pas en colonne - tableau des pixels lus - ......................................................................*/ - if ( retour == CAI_OK) - { - retour=(*comp)(image1 , - &canal , - &premiere_ligne , - &premiere_colonne , - &nombre_lignes_lire , - &nombre_colonnes_lire, - &pas_ligne , - &pas_colonne, - data_image) ; - return(retour); - } - else - { - return (CAI_KO); - } - -} -/* - Fin de l'operation cai_lecture_canal.c -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ecriture_canal */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ecriture d'un canal d'une image dans un format donne */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : int cai_ecriture_canal(image1, canal, premiere_ligne, */ /* ------------------ nombre_lignes_ecrire, */ -/* nombre_colonnes_ecrire, */ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) ( int) : numero du canal a ecrire */ -/* premiere_ligne (E) ( int) : premiere ligne a ecrire ds l'image */ -/* nombre_lignes_ecrire (E) ( int) : nombre de lignes a ecrire */ -/* nombre_colonnes_ecrire(E) ( int) : nombre de lignes a ecrire */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels a ecrire alloue */ -/* et libere par l'appelant */ -/* */ -/* cai_ecriture_canal (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V3 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_OK_KO cai_ecriture_canal (CAI_IMAGE *image1 , - int canal , - int premiere_ligne, - int nombre_lignes_ecrire , - int nombre_colonnes_ecrire, - unsigned char *data_image ) - - -{ - long int (*comp) ( ); /* pointeur sur fonction */ - char type_image[20]; /* format de stockage de l'image a ecrire */ - long int retour; /* indicateur d'erreur de l'operation */ - - -/*...................... - Initialisations - .......................*/ - - retour=CAI_OK; - type_image[0]='\0'; - strcpy( type_image,image1->TYPE_IMAGE); - CAI_ERREUR[0]='\0'; - - /*................................................................ - Verification de la coherence des donnees en entree - .............................................................*/ -/* sur la premiere ligne a ecrire */ - - if ((premiere_ligne<=0)||(premiere_ligne> image1->NB_LIG)) - { - sprintf(CAI_ERREUR,"Premiere ligne a ecrire incorrecte"); - retour=CAI_KO; - } - -/* sur le numero du canal a ecrire */ - - if ((canal<=0)||(canal> image1->NB_CANAUX)) - { - sprintf(CAI_ERREUR,"Numero du canal a ecrire incorrect"); - retour=CAI_KO; - - } - -/* sur le nombre de lignes a ecrire */ - if ((nombre_lignes_ecrire<=0)|| - ((nombre_lignes_ecrire + premiere_ligne-1) > image1->NB_LIG)) - { - sprintf(CAI_ERREUR,"Nombre de lignes a ecrire incorrect"); - retour=CAI_KO; - } - -/* sur le nombre de colonnes a ecrire */ - - - if ((nombre_colonnes_ecrire<=0)|| - (nombre_colonnes_ecrire > image1->NB_COL)) - { - sprintf(CAI_ERREUR,"Nombre de colonnes a ecrire incorrect"); - retour=CAI_KO; - } - - if (retour == CAI_OK) - { -/*.............................................. - Initialisation d'un pointeur sur fonction dependant du format des images - ................................................ */ - - if (strcasecmp(type_image,"INRIA") == 0) - { - comp = (cai_ecriture_canal_inria) ; - } - - else if (strcasecmp(type_image,"ONERA") == 0) - { - comp = (cai_ecriture_canal_onera) ; - } - - else if (strcasecmp(type_image,"BSQ") == 0) - { - comp = (cai_ecriture_canal_bsq) ; - } - - else if (strcasecmp(type_image,"BIP") == 0) - { - comp = (cai_ecriture_canal_bip) ; - } - -#ifdef _HDF16 - - else if (strncasecmp(type_image,"HDF",3) == 0) - { - comp = (cai_ecriture_canal_hdf16) ; - } -#endif - - else if (strcasecmp(type_image,"BIL") == 0) - { - comp = (cai_ecriture_canal_bil) ; - } - - else if (strcasecmp(type_image,"LUM") == 0) - { - comp = (cai_ecriture_canal_lum) ; - } - - else if (strcasecmp(type_image,"GESSIMU") == 0) - { - comp = (cai_ecriture_canal_gessimu) ; - } - - else if (strcasecmp(type_image,"GDB") == 0) - { - comp = (cai_ecriture_canal_grilles) ; - } - - else if (strcasecmp(type_image,"GDR") == 0) - { - comp = (cai_ecriture_canal_grilles) ; - } - - else if (strcasecmp(type_image,"TIFF") == 0) - { - comp = (cai_ecriture_canal_tiff) ; - } - - else if (strcasecmp(type_image,"RASTERFILE") == 0) - { - comp = (cai_ecriture_canal_sun_raster) ; - } - else if (strcasecmp(type_image,"JPEG") == 0) - { - comp = (cai_ecriture_canal_jpeg) ; - } - - else if (strcasecmp(type_image,"SPOT1A4") == 0) - { - comp = (cai_ecriture_canal_spot) ; - } - else if (strcasecmp(type_image,"SPOT5TIF") == 0) - { - comp = (cai_ecriture_canal_spot) ; - } - else if (strcasecmp(type_image,"SPOT5BIL") == 0) - { - comp = (cai_ecriture_canal_spot) ; - } - else if (strcasecmp(type_image,"RADAR") == 0) - { - comp = (cai_ecriture_canal_radar) ; - } - else if (strcasecmp(type_image,"BANDEAU") == 0) - { - retour = CAI_KO; - sprintf(CAI_ERREUR,"Ecriture au format BANDEAU non prévue dans CAI \n"); - } - else - { - - /* format non connu de la Couche Acces Image */ - retour = CAI_KO; - sprintf(CAI_ERREUR,"format %s non reconnu \n",type_image); - - - } - } - /*........................................... - Appel de la fonction pointee par comp avec la liste des parametres - suivants : - - pointeur sur descripteur des fichiers - numero du canal a ecrire - premiere ligne a ecrire dans l'image - nombre de lignes a ecrire - nombre de colonnes a ecrire - tableau des pixels a ecrire - ......................................................................*/ - if ( retour == CAI_OK) - { - retour=(*comp)(image1 , - &canal , - &premiere_ligne , - &nombre_lignes_ecrire , - &nombre_colonnes_ecrire, - data_image) ; - } - - return (retour); - -} -/* - Fin de l'operation cai_ecriture_canal.c -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ferme_image */ -/* ---------- */ -/* */ -/* ROLE : fonction de fermeture d'une image dans un format donne et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : int cai_ferme_image(image1) */ /* ------------------ */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* */ -/* cai_ferme_image (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V3 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_OK_KO cai_ferme_image (CAI_IMAGE *image1) - -{ - long int iret; /* indicateur retour fonction */ - long int (*comp)(); /* pointeur sur fonction */ - -/*...................... - Initialisations - .......................*/ - - iret=CAI_OK; - CAI_ERREUR[0]='\0'; - IND_GRILLES = '\0'; - IND_SPOT = '\0'; -/*.............................................. - Initialisation d'un pointeur sur fonction dependant du format des images - ................................................ */ - - if (strcasecmp(image1->TYPE_IMAGE,"INRIA") == 0) - { - comp = (cai_ferme_inria) ; - } - - else if (strcasecmp(image1->TYPE_IMAGE,"ONERA") == 0) - { - comp = (cai_ferme_onera) ; - } - else if (strcasecmp(image1->TYPE_IMAGE,"BSQ") == 0) - { - comp = (cai_ferme_bsq) ; - } - - else if (strcasecmp(image1->TYPE_IMAGE,"BIP") == 0) - { - comp = (cai_ferme_bip) ; - } - -#ifdef _HDF16 - - else if (strncasecmp(image1->TYPE_IMAGE,"HDF",3) == 0) - { - comp = (cai_ferme_hdf16) ; - } -#endif - - else if (strcasecmp(image1->TYPE_IMAGE,"BIL") == 0) - { - - comp = (cai_ferme_bil) ; - } - - else if (strcasecmp(image1->TYPE_IMAGE,"LUM") == 0) - { - - comp = (cai_ferme_lum) ; - } - - else if (strcasecmp(image1->TYPE_IMAGE,"GESSIMU") == 0) - { - comp = (cai_ferme_gessimu) ; - } - - else if (strcasecmp(image1->TYPE_IMAGE,"GDB") == 0) - { - IND_GRILLES = 'B'; - comp = (cai_ferme_grilles) ; - } - - else if (strcasecmp(image1->TYPE_IMAGE,"GDR") == 0) - { - IND_GRILLES = 'R'; - comp = (cai_ferme_grilles) ; - } - - - else if (strcasecmp(image1->TYPE_IMAGE,"TIFF") == 0) - { - comp = (cai_ferme_tiff) ; - } - - else if (strcasecmp(image1->TYPE_IMAGE,"RASTERFILE") == 0) - { - comp = (cai_ferme_sun_raster) ; - } - else if (strcasecmp(image1->TYPE_IMAGE,"JPEG") == 0) - { - comp = (cai_ferme_jpeg) ; - } - - else if (strcasecmp(image1->TYPE_IMAGE,"SPOT1A4") == 0) - { - IND_SPOT = '1'; - comp = (cai_ferme_spot) ; - } - else if (strcasecmp(image1->TYPE_IMAGE,"SPOT5TIF") == 0) - { - IND_SPOT = 'T'; - comp = (cai_ferme_spot) ; - } - else if (strcasecmp(image1->TYPE_IMAGE,"SPOT5BIL") == 0) - { - IND_SPOT = 'B'; - comp = (cai_ferme_spot) ; - } - - else if (strcasecmp(image1->TYPE_IMAGE,"RADAR") == 0) - { - - comp = (cai_ferme_radar) ; - } - - else if (strcasecmp(image1->TYPE_IMAGE,"BANDEAU") == 0) - { - - comp = (cai_ferme_bandeau) ; - } - - else - { - - /* format non connu de la Couche Acces Image */ - iret = CAI_KO; - sprintf(CAI_ERREUR,"format %s non reconnu \n",image1->TYPE_IMAGE); - - - } - - - /*........................................... - Appel de la fonction pointee par comp avec la liste des parametres - suivants : - pointeur sur descripteur des fichiers de l'image - ......................................................................*/ - - if (( iret == CAI_OK ) && (image1 != NULL)) - { -/*** Traitement de la Colormap ***/ - if ((image1->COLORMAP !=0)&& ( image1->MODE == CAI_ECRITURE)) - { - iret = cai_ecriture_colormap(image1); - } - - if (image1->COLORMAP !=0) - { - free(image1->TABCOLOR); - } - if (IND_GRILLES == '\0') - { - if (IND_SPOT == '\0') - iret = (*comp)(image1); - else - iret = (*comp)(IND_SPOT,image1); - } - else - iret = (*comp)(IND_GRILLES,image1); - } - free(image1); - - image1 = (CAI_IMAGE *)NULL; - - return (iret); -} -/* - Fin de l'operation cai_ferme_image.c -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_destruction_image */ -/* ---------- */ -/* */ -/* ROLE : fonction de destruction d'une image dans un format donne et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : int cai_destruction_image(format,nom_ima) */ -/* ------------------ */ -/* format (E) (char *) : format de l'image a detruire */ -/* nom_image (E) (char *) : nom de l'image a detruire avec repertoire */ -/* */ -/* cai_destruction_image (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V3 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_OK_KO cai_destruction_image (char *format , - char *nom_ima ) - - -{ - -long int (*ptr_dest_ima)(); /* ptr sur fctn de destruction d'une image */ -long int cr_cai; /* code retour de fonction appellee */ -long int i,ind; /* variables de travail */ -char repert[1024]; /* repertoire de stockage de l'image */ -char image[1024]; /* nom de l'image a detruire sans repert */ -char form[20]; /* format de l'image a detruire */ -char *pch,*deb; /* variables de travail */ -long int nb1,nb2; /* variables de travail */ -char car; /* variables de travail */ -/*................. - Initialisations - ................*/ - -cr_cai = CAI_OK; -strcpy(form,format); -CAI_ERREUR[0]='\0'; -IND_GRILLES = '\0'; -IND_SPOT = '\0'; -/*................................................... - Recherche du type de fichier si reconnaissance automatique demande - ...................................................*/ - - if (strcasecmp(form,"AUTO")== 0) - { - for( i = 0 ; i< CAI_NB_EXTENSIONS ; i++) - { - if(strstr(nom_ima,CAI_SUFFIXES[i]) != NULL ) - { - ind=CAI_NUMEROS[i]; - strcpy(form,CAI_NOM_FORMAT[ind]); - } - } - } - -/*.............................................. - Initialisation d'un pointeur sur fonction dependant du format des images - ................................................ */ - - if (strcasecmp(form,"INRIA") == 0) - { - ptr_dest_ima = (cai_dest_ima_inria) ; - } - - else if (strcasecmp(form,"ONERA") == 0) - { - ptr_dest_ima = (cai_dest_ima_onera) ; - } - - else if (strcasecmp(form,"BSQ") == 0) - { - ptr_dest_ima = (cai_dest_ima_bsq) ; - } - - else if (strcasecmp(form,"BIP") == 0) - { - ptr_dest_ima = (cai_dest_ima_bip) ; - } - -#ifdef _HDF16 - - else if (strncasecmp(form,"HDF",3) == 0) - { - ptr_dest_ima = (cai_dest_ima_hdf16) ; - } -#endif - - else if (strcasecmp(form,"BIL") == 0) - { - ptr_dest_ima = (cai_dest_ima_bil) ; - } - - else if (strcasecmp(form,"LUM") == 0) - { - ptr_dest_ima = (cai_dest_ima_lum) ; - } - - else if (strcasecmp(form,"GESSIMU") == 0) - { - ptr_dest_ima = (cai_dest_ima_gessimu) ; - } - - else if (strcasecmp(form,"GDB") == 0) - { - IND_GRILLES = 'B'; - ptr_dest_ima = (cai_dest_ima_grilles) ; - } - - else if (strcasecmp(form,"GDR") == 0) - { - IND_GRILLES = 'R'; - ptr_dest_ima = (cai_dest_ima_grilles) ; - } - - else if (strcasecmp(form,"TIFF") == 0) - { - ptr_dest_ima = (cai_dest_ima_tiff) ; - } - - else if (strcasecmp(form,"RASTERFILE") == 0) - { - ptr_dest_ima = (cai_dest_ima_sun_raster) ; - } - else if (strcasecmp(form,"JPEG") == 0) - { - ptr_dest_ima = (cai_dest_ima_jpeg) ; - } - else if (strcasecmp(form,"SPOT1A4") == 0) - { - IND_SPOT = '1'; - ptr_dest_ima = (cai_dest_ima_spot) ; - } - else if (strcasecmp(form,"SPOT5TIF") == 0) - { - IND_SPOT = 'T'; - ptr_dest_ima = (cai_dest_ima_spot) ; - } - else if (strcasecmp(form,"SPOT5BIL") == 0) - { - IND_SPOT = 'B'; - ptr_dest_ima = (cai_dest_ima_spot) ; - } - else if (strcasecmp(form,"RADAR") == 0) - { - ptr_dest_ima = (cai_dest_ima_radar) ; - } - else if (strcasecmp(form,"BANDEAU") == 0) - { - ptr_dest_ima = (cai_dest_ima_bandeau) ; - } - else - { - - /* format non connu de la Couche Acces Image */ - cr_cai = CAI_KO; - sprintf(CAI_ERREUR,"format %s non reconnu \n",form); - - } - /*............................................................... - Separation du repertoire de stockage de l'image et du nom propre - .................................................................*/ - if (cr_cai ==CAI_OK) - { - repert[0]='\0'; - image[0]='\0'; - car='/'; -#ifdef _WIN - car='\\'; -#endif - pch=(char *)strrchr(nom_ima,car); - if (pch == NULL) - { - /* le repertoire est celui courant */ - strcpy(repert,"./"); -#ifdef _WIN - strcpy(repert,".\\"); -#endif - sscanf(nom_ima,"%s",image); - car='.'; - pch=(char *)strrchr(image,car); - if (pch != NULL) - *pch='\0'; - - } - else - { - - nb1=(long int)(pch)-(long int)(nom_ima); - strncpy(repert,nom_ima,nb1); - repert[nb1]='\0'; - deb=nom_ima+nb1+1; - nb2=strlen(nom_ima)-(nb1+1); - strncpy(image,deb,nb2); - image[nb2]='\0'; - car='.'; - pch=(char *)strrchr(image,car); - if (pch != NULL) - *pch='\0'; - - } - - } - - -/****************************************************/ -/* appel de la fonction pointee par ptr_dest_ima */ -/* avec les parametres suivants : */ -/* - repertoire de stockage de l'image */ -/* - nom de l'image */ -/****************************************************/ - - if (cr_cai==CAI_OK) - { - if (IND_GRILLES == '\0') - { - if (IND_SPOT == '\0') - cr_cai = (*ptr_dest_ima)(repert, image); - else - cr_cai = (*ptr_dest_ima)(IND_SPOT,repert, image); - } - else - cr_cai = (*ptr_dest_ima)(IND_GRILLES,repert, image); - - } - return (cr_cai); -} -/* - Fin de l'operation cai_destruction_image.c -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_modif_nbbitspix */ -/* ---------- */ -/* */ -/* ROLE : fonction permetant de modifier le nombre de bits significatifs */ -/* ----- par pixel (uniquement pour les formats BSQ ,BIP,BIL et HDF) */ -/* */ -/* Remarque !! L'image doit deja etre ouverte */ -/* */ -/* */ -/* CONTEXTE D'APPEL : int cai_modif_nbbitspix(format,image1,NbBitsPix) */ /* ------------------ */ -/* format (E) (char *) : format de l'image a modifier */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* NbBitsPix (E) (long int) : nb de bits significatifs par pixel */ -/* */ -/* cai_modif_nbbitspix (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* = CAI_IMPOS si format autre que BSQ ou HDF16 */ -/* */ -/* VERSION : V3 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_OK_KO cai_modif_nbbitspix ( char *format , - CAI_IMAGE *image1,int NbBitsPix) - -{ - -long int cr_cai; /* code retour de fonction appellee */ -char form[20]; /* format de l'image a modifier */ -CAI_EXTENS *TabExtens; -/*................. - Initialisations - ................*/ - -TabExtens = NULL; -cr_cai = CAI_OK; -strcpy(form,format); -CAI_ERREUR[0]='\0'; - -/*.............................................. - Lancement de la fonction dependant du format des images - ................................................ */ - - if (strcasecmp(form,"BSQ") == 0) - { - cr_cai = cai_modif_nbbitspix_bsq(image1,NbBitsPix) ; - } - - -#ifdef _HDF16 - - else if (strncasecmp(form,"HDF",3) == 0) - { - image1->NB_BITS_PIX = NbBitsPix; - cr_cai = cai_rename_fichiers_hdf16(image1,TabExtens) ; - } -#endif - else if (strcasecmp(form,"BIP") == 0) - { - cr_cai = cai_modif_nbbitspix_bip(image1,NbBitsPix) ; - } - else if (strcasecmp(form,"BIL") == 0) - { - cr_cai = cai_modif_nbbitspix_bil(image1,NbBitsPix) ; - } - - else - { - - /* Fonction non prevue pour un autre format */ - cr_cai = CAI_IMPOS; - sprintf(CAI_ERREUR,"format %s : modification non prevue \n",form); - - } - - return (cr_cai); -} -/* Fin de l'operation cai_modif_nbbitspix -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_modifie_image */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture-ecriture d'une image d'un format*/ -/* ----- donne et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_modifie_image (nom_image, */ -/* ---------------- type_image, */ -/* nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* type_image (E) (char *) : format de l'image a ouvrir */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_modifie_image (S) (CAI_IMAGE *) : =NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ -/* */ -/* VERSION : V3 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_IMAGE *cai_ouvre_modifie_image (char *nom_image, - char *type_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) -{ - - int nb; /* indicateur d'erreurs rencontres */ - CAI_IMAGE *image1; /* descripteur de fichier retour fonction */ - CAI_IMAGE *(*comp) ( ); /* pointeur sur fonction */ - char repert[1024]; /* repertoire de stockage de l'image */ - char image[1024]; /* nom de l'image a ouvrir en lecture */ - char format[20]; /* format de stockage de l'image a lire */ - long int i,ind; /* variables de travail */ - char *pch,*deb; /* pointeurs de travail */ - long int nb1,nb2; /* indice de longueur significative */ - char car; /* variable de travail */ - DIR *dirp; /* pointeur sur structure ouverture repertoire */ - CAI_OK_KO icr; /* Compte-rendu des fonctions DA */ - - -/*...................... - Initialisations - .......................*/ - nb=1; - strcpy(format,type_image); - - CAI_ERREUR[0]='\0'; - IND_GRILLES = '\0'; - IND_SPOT = '\0'; - -/*................................................... - Recherche du type de fichier si reconnaissance automatique demande - ...................................................*/ - if (strcasecmp(format,"AUTO")== 0) - { - for( i = 0 ; i< CAI_NB_EXTENSIONS ; i++) - { - if(strstr(nom_image,CAI_SUFFIXES[i]) != NULL ) - { - ind=CAI_NUMEROS[i]; - strcpy(format,CAI_NOM_FORMAT[ind]); - } - } - } - -/*.............................................. - Initialisation d'un pointeur sur fonction dependant du format des images - ................................................ */ - - if (strcasecmp(format,"INRIA") == 0) - { - comp = (cai_ouvre_modifie_inria) ; - } - - else if (strcasecmp(format,"ONERA") == 0) - { - comp = (cai_ouvre_modifie_onera) ; - } - - else if (strcasecmp(format,"BSQ") == 0) - { - comp = (cai_ouvre_modifie_bsq) ; - } - - else if (strcasecmp(format,"BIP") == 0) - { - comp = (cai_ouvre_modifie_bip) ; - } -#ifdef _HDF16 - else if (strncasecmp(format,"HDF",3) == 0) - { - comp = (cai_ouvre_modifie_hdf16) ; - } -#endif - - else if (strcasecmp(format,"BIL") == 0) - { - comp = (cai_ouvre_modifie_bil) ; - } - - else if (strcasecmp(format,"LUM") == 0) - { - comp = (cai_ouvre_modifie_lum) ; - } - - else if (strcasecmp(format,"GESSIMU") == 0) - { - comp = (cai_ouvre_modifie_gessimu) ; - } - - else if (strcasecmp(format,"GDB") == 0) - { - IND_GRILLES = 'B'; - comp = (cai_ouvre_modifie_grilles) ; - } - - else if (strcasecmp(format,"GDR") == 0) - { - IND_GRILLES = 'R'; - comp = (cai_ouvre_modifie_grilles) ; - } - - else if (strcasecmp(format,"TIFF") == 0) - { -/* comp = (cai_ouvre_modifie_tiff) ; */ - nb = 0; - sprintf(CAI_ERREUR, - "fonction de modification non disponible pour TIFF"); - } - - else if (strcasecmp(format,"RASTERFILE") == 0) - { - comp = (cai_ouvre_modifie_sun_raster) ; - } - else if (strcasecmp(format,"JPEG") == 0) - { - nb = 0; - sprintf(CAI_ERREUR,"fonction de modification non disponible pour JPEG"); - } - else if (strcasecmp(type_image,"SPOT1A4") == 0) - { - IND_SPOT = '1'; - comp = (cai_ouvre_modifie_spot) ; - } - else if (strcasecmp(type_image,"SPOT5TIF") == 0) - { - IND_SPOT = 'T'; -/* comp = (cai_ouvre_modifie_spot) ;*/ - nb = 0; - sprintf(CAI_ERREUR, - "fonction de modification non disponible pour SPOT5TIF"); - - } - else if (strcasecmp(type_image,"SPOT5BIL") == 0) - { - IND_SPOT = 'B'; - comp = (cai_ouvre_modifie_spot) ; - } - else if (strcasecmp(format,"RADAR") == 0) - { - comp = (cai_ouvre_modifie_radar) ; - } - - else if (strcasecmp(type_image,"BANDEAU") == 0) - { - nb = 0; - sprintf(CAI_ERREUR, - "fonction de modification non disponible pour BANDEAU \n"); - } - - else - { - - /* format non connu de la Couche Acces Image */ - nb = 0; - sprintf(CAI_ERREUR,"format %s non reconnu \n",format); - - } - /*............................................................... - Separation du repertoire de stockage de l'image et du nom propre - .................................................................*/ - if (nb == 1) - { - repert[0]='\0'; - image[0]='\0'; - car='/'; -#ifdef _WIN - car='\\'; -#endif - pch=(char *)strrchr(nom_image,car); - if (pch == NULL) - { - /* le repertoire est celui courant */ - strcpy(repert,"./"); -#ifdef _WIN - strcpy(repert,".\\"); -#endif - sscanf(nom_image,"%s",image); - car='.'; - pch=(char *)strrchr(image,car); - if (pch != NULL) - *pch='\0'; - } - else - { - - nb1=(long int)(pch)-(long int)(nom_image); - strncpy(repert,nom_image,nb1); - repert[nb1]='\0'; - deb=nom_image+nb1+1; - nb2=strlen(nom_image)-(nb1+1); - strncpy(image,deb,nb2); - image[nb2]='\0'; - car='.'; - pch=(char *)strrchr(image,car); - if (pch != NULL) - *pch='\0'; - - } - - } -/*.............................................. - Verification existence repertoire demande - ...............................................*/ - if ( nb == 1 ) - { - dirp=opendir(repert); - if (dirp ==(DIR *)NULL) - { - /* repertoire demande inexistant */ - nb=0; - sprintf(CAI_ERREUR,"repertoire %s inexistant \n",repert); - } - else - closedir(dirp); - - } - - /*........................................... - Appel de la fonction pointee par comp avec la liste des parametres - suivants : - repertoire de stockage de l'image - nom de l'image - nombre de canaux - nombre d'octets par pixels - nombre de colonnes - nombre de lignes - ......................................................................*/ - if ( nb == 1 ) - { - if (IND_GRILLES == '\0') - { - if (IND_SPOT == '\0') - image1 = (*comp)(repert,image,nb_can,nboct_pix,nb_col,nb_lig); - else - image1 = (*comp)(IND_SPOT,repert,image,nb_can,nboct_pix,nb_col, - nb_lig); - } - else - image1 = (*comp)(IND_GRILLES,repert,image,nb_can,nboct_pix,nb_col, - nb_lig); - - if (image1 != NULL) - { - strcpy(image1->TYPE_IMAGE,format); - strcpy(image1->NOM_IMAGE,nom_image); - image1->NB_CANAUX=*nb_can; - image1->NB_COL=*nb_col; - image1->NB_LIG=*nb_lig; - image1->NBOCT_PIX=*nboct_pix; - image1->MODE=CAI_ECRITURE; - -/*** Traitement de la Colormap si format autre que TIFF et RASTERFILE ***/ - - if ((strcasecmp(format,"RASTERFILE") != 0)&&(strcasecmp(format,"TIFF") != 0)) - { - - icr = cai_lecture_colormap(image1); - - if ( icr == CAI_KO) - return (NULL); - else - return (image1); - } - else - { - return (image1); - } - } - else - return(NULL); - } - else - { - return (NULL); - } -} -/* Fin de l'operation cai_ouvre_modifie_image -*/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_test_pFpf */ -/* ---------- */ -/* */ -/* ROLE : fonction de test qui determine ordre des poids forts et faible */ -/* ----- pour lire correctement entete et image */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : char *cai_test_pFpf() */ -/* ---------------- */ -/* */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - char *cai_test_pFpf () - { - -/*variable contenant 3 caracteres*/ -/*-------------------------------*/ - -static char type_code[3]; - -/*codage sur 2 octets*/ -/*de la valeur 1*/ -/*-------------------*/ - -unsigned short a=1; - -/*test sur la valeur -/*de l'octet de gauche*/ -/*--------------------*/ - -if (*(char *) &a == 0) - { - strcpy(type_code, "BE"); /*affectation d'une chaine de caracteres*/ - } -if (*(char *) &a == 1) - { - strcpy(type_code, "LE"); /*affectation d'une chaine de caracteres*/ - } - -/*retourne le contenu de la variable*/ -/*comme il s'agit de tableau pas besoin du &*/ -/*------------------------------------------*/ -return(type_code); - -} -/* - Fin de l'operation cai_test_pFpf -*/ - - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_inverser_tableau */ -/* ---------- */ -/* */ -/* ROLE : fonction d'inversion des poids forts et faible */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : cai_inverser_tableau(sortie, entree,nb) */ -/* ---------------- */ -/* */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -void cai_inverser_tableau(short *BufL,short *BufE,int Nb) -{ - int pix; - for (pix=0;pix<Nb;pix=pix+2) - { - BufL[pix]=BufE[pix+1]; - BufL[pix+1]=BufE[pix]; - } -} -/* - Fin de l'operation cai_inverser_tableau -*/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_En_majuscule */ -/* ---------- */ -/* */ -/* ROLE : Cette fonction transforme la chaine de caracteres donnee en */ -/* ROLE : parametre en majuscule et renvoie le resultat */ -/* */ -/* CONTEXTE D'APPEL : */ -/* */ -/* RETOUR : chaine en majuscule */ -/* */ -/*****************************************************************************/ - -char* cai_En_majuscule( char *mot ) - -{ - char *retour; - int i = 0; - - /* allocation des pointeurs */ - - retour = (char*) NULL; - retour = (char*) calloc ( strlen ( mot ) + 1 , sizeof (char) ); - - if ( retour == NULL ) - { - return (char*)NULL; - } - /* Parcourir la chaine */ - - while ( mot[i] != '\0' ) - { - /* transformer en majuscule la lettre lue */ - retour[i] = toupper ( mot[i] ); - i++; - } - /* retourner le resultat */ - return retour; -} -/* - Fin de l'operation cai_En_majuscule -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_inverser_tableau_complet */ -/* ---------- */ -/* */ -/* ROLE : fonction d'inversion des poids forts et faible */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : cai_inverser_tableau_complet(tableau,nbpix,tailpix) */ -/* ---------------- */ -/* */ -/* tableau (E) (* uchar) : tableau à inverser */ -/* nbpix (E) (int) : nb de pixels du tableau */ -/* tailpix (E) (int) : nb d'octets d'un pixel */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -void cai_inverser_tableau_complet(unsigned char *tableau,int nbpix,int tailpix) -{ - int pix,ind,oct; - unsigned char *temp; - - - temp = (unsigned char *) calloc(tailpix,sizeof(unsigned char)); - - for (pix=0;pix<nbpix;pix=pix+1) - { - ind = pix*tailpix; - for (oct=0;oct<tailpix;oct++) - { - temp[oct] = tableau[ind + tailpix - oct -1 ]; - } - for (oct=0;oct<tailpix;oct++) - { - tableau[ind + oct ] = temp[oct]; - } - } -} -/* - Fin de l'operation cai_inverser_tableau_complet -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_En_minuscule */ -/* ---------- */ -/* */ -/* ROLE : Cette fonction transforme la chaine de caracteres donnee en */ -/* ROLE : parametre en minuscule et renvoie le resultat */ -/* */ -/* CONTEXTE D'APPEL : */ -/* */ -/* RETOUR : chaine en majuscule */ -/* */ -/*****************************************************************************/ - -char* cai_En_minuscule( char *mot ) -{ - char *retour; - int i = 0; - - /* allocation des pointeurs */ - - retour = (char*) NULL; - retour = (char*) calloc ( strlen ( mot ) + 1 , sizeof (char) ); - - if ( retour == NULL ) - { - return (char*)NULL; - } - /* Parcourir la chaine */ - - while ( mot[i] != '\0' ) - { - /* transformer en minuscule la lettre lue */ - retour[i] = tolower ( mot[i] ); - i++; - } - /* retourner le resultat */ - return retour; - } -/* - Fin de l'operation cai_En_minuscule -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_istyp_connu */ -/* ---------- */ -/* */ -/* ROLE : fonction de verification si pixels de type connu ou non */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : retour = cai_istyp_connu(type_code) */ -/* ---------------- */ -/* */ -/* type_code (E) (char *) : type de codage a verifier */ -/* retour (S) (int) : 1 si OK reconnu */ -/* -1 si non reconnu */ -/* */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ -int cai_istyp_connu(char *type_code) -{ - int ind; /* indice de boucle sur les types reconnus */ - int trouve,icr; /* indice pour la recherche */ - -/* Initialisations diverses */ - trouve = -1; - ind = 0; - while ((trouve==-1)&&(ind< CAI_NB_TYPE)) - { - icr=strncmp(type_code,CAI_TYPE_CONNU[ind],strlen(type_code)); - if (icr==0) - trouve=ind; - else - ind=ind+1; - } - - -/* sortie normale */ - return(trouve); -} -/* - Fin de l'operation cai_istyp_connu -*/ diff --git a/Utilities/CAI/cai_dll/src/cai_gessimu.c b/Utilities/CAI/cai_dll/src/cai_gessimu.c deleted file mode 100755 index 834a40b3a1dac92508cecaeaca5946b1adbb1b0b..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/src/cai_gessimu.c +++ /dev/null @@ -1,1233 +0,0 @@ -/*****************************************************************************/ -/* */ -/* PROJET : COUCHE ACCES IMAGE */ -/* ------- */ -/* */ -/* MODULE : cai_gessimu.c */ -/* ------- */ -/* */ -/* ROLE : Ce module rassemble toutes les fonctions d'acces aux images */ -/* ------- stockees au format gessimu (format Alcatel monocanal) */ -/* */ -/* AUTEUR : R.CHAISEMARTIN (CISI) */ -/* ------- */ -/* */ -/* DATE DE CREATION : Septembre 1999 */ -/* ----------------- */ -/* */ -/* LANGAGE : C */ -/* -------- */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ -/* MOD : VERSION : 4.1 : FA : Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : FA : verification que l'image est codee sur un seul */ -/*octet par pixel (contrainte du format) */ -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : DM : modifications pour compatibilite HP64bits */ -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : modifications fopen binaire pour PC/NT */ -/*****************************************************************************/ -/* MOD : VERSION : 4.4 : DM : modifications open binaire pour PC/NT */ -/*****************************************************************************/ -/* MOD : VERSION : 4.5 : FA : test sur fclose pour PC/LINUX */ -/*****************************************************************************/ - -/*---------------------------------------------------------------------------*/ -/* Inclusion des fichiers STANDARDS (.h) */ -/*---------------------------------------------------------------------------*/ - - -# include <stdio.h> -# include <string.h> -# include <unistd.h> -# include <stdlib.h> -# include <sys/types.h> -#include <dirent.h> -# include <sys/stat.h> -# include <fcntl.h> - -#define _CAI_IMAGE -#define IN_CAI_GESSIMU - -# include "cai_image.h" - -/*----------------------------------------------------------------------------*/ -/* Variable pour la gestion en configuration */ -/*----------------------------------------------------------------------------*/ -static char *rcs_id="$Header: cai_gessimu.c,v 1.6 01/05/31 10:47:35 cmf Exp $"; - - -extern char *getenv(); - -/*****************************************************************************/ -/*****************************************************************************/ -/* */ -/* Definition des OPERATIONS EXTERNES */ -/* */ -/*****************************************************************************/ -/*****************************************************************************/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_liste_ima_gessimu */ -/* ---------- */ -/* */ -/* ROLE : fonction de listage des images au format gessimu */ -/* ------ */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : int cai_liste_ima_gessimu(repert,tab_ima) */ -/* ----------------- */ -/* */ -/* repert (E) (char *) : repertoire a explorer */ -/* tab_ima (S) (char ***) : pointeur sur tableau des images listees */ -/* alloue par la fonction,il doit etre */ -/* LIBERE PAR L'APPELANT */ -/* */ -/* cai_liste_ima_gessimu (S) (int) : = -1 repertoire inexistant */ /* = > 0 nombre d'images listees */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -long int cai_liste_ima_gessimu (char *repert, - char ***tab_ima) - -{ - DIR *dirp; /* pointeur sur structure ouverture repertoire */ - struct dirent *dp; /* structure resultat de la fonction readdir */ - char *pch0,*pch1; /* pointeurs sur chaine de caracteres */ - char car; /* variable de travail */ - int nb_ima; /* nombre d'images gessimu identifiees */ - long int i; /* indice de boucle */ - long int ll,dif; /* variables de travail */ - char blanc; /* caractere blanc */ - - -/*........................................ - INITIALISATION et ouverture du repertoire choisi - .........................................*/ - nb_ima=0; - blanc=' '; - dirp=opendir(repert); - - if(dirp!=NULL) - { -/*...................................... - - premiere passe pour comptabiliser les images du format donne - - - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE GESSIMU - (EXTENSION =.pfe) - ..........................................*/ - - while((dp=readdir(dirp))!=NULL) - { - pch0=strstr(dp->d_name,".pfe"); - if (pch0 != NULL) - { - ll = strlen(dp->d_name); - dif = (long)(dp->d_name-pch0); - dif=labs(dif); - pch1=pch0+4; - if (((ll-4)==dif)||((*pch1)==blanc)) - nb_ima=nb_ima+1; - - } - - } - - (void)closedir(dirp); -/*..................................... - ALLOCATION DU TABLEAU CONTENANT LA LISTE DES IMAGES DU FORMAT GESSIMU - ......................................*/ - *tab_ima = (char **) calloc(nb_ima,sizeof(char *)); - for (i=0;i<nb_ima;i=i+1) - (*tab_ima)[i]=(char *)calloc(1,100); - -/*...................................... - - deuxieme passe pour constituer la liste des images du format donne - - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE GESSIMU - (EXTENSION =.pfe) - SI C`EST LE CAS,STOCKAGE DANS LA LISTE - ..........................................*/ - dirp=opendir(repert); - - nb_ima=0; - - while((dp=readdir(dirp))!=NULL) - { - pch0=strstr(dp->d_name,".pfe"); - if (pch0 != NULL) - { - ll = strlen(dp->d_name); - dif = (long)(dp->d_name-pch0); - dif=labs(dif); - pch1=pch0+4; - if (((ll-4)==dif)||((*pch1)==blanc)) - { - *pch0='\0'; - strcpy((*tab_ima)[nb_ima],dp->d_name); - nb_ima=nb_ima+1; - } - - } - } - - closedir(dirp); - - } - else - { - /* Erreur : Repertoire inexistant */ - nb_ima=-1; - } - - return(nb_ima); - -} -/* Fin de l'operation cai_liste_ima_gessimu -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_lecture_gessimu */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture d'une image au format gessimu */ -/* ----- */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_lecture_gessimu(nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_lecture_gessimu (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ /* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_IMAGE *cai_ouvre_lecture_gessimu(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) - -{ - FILE *fic_in; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - int iret; /* indicateur de retour ok ou pas */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char nom_fic_canal[1024]; /* nom fichier canal dont on teste existence*/ - int nbbit; /* nb de bits par pixel du fichier en-tete */ - int retour; /* retour de la fonction comparaison chaines*/ - int i,num; /* indice */ - char type_cod[5]; /* type de codage du pixel */ - int detec1,detecF; /* 1er et dernier detecteur dans l'entete */ - int Tail_lig; /* taille d'une ligne sur disque (multi 4) */ - - /*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - *nb_can=0; - - *nb_lig=0; - - *nb_col=0; - - *nboct_pix=0; - - iret=1; - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); -/*****************************************************************************/ -/* MOD : VERSION : 4.1 : FA:Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_lecture"); - } - else - { -/*................................................. - Constitution du nom du fichier entete - .................................................*/ - nom_fic[0]='\0'; - if ((long int)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s.pfe",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.pfe",nom_image); - } - -/*........................ - Ouverture du fichier entete - ..........................................*/ -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : modifications fopen binaire pour PC/NT */ -/*****************************************************************************/ - fic_in=NULL; - fic_in=fopen(nom_fic,"rb"); - if (fic_in==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur ouverture fichier entete GESSIMU"); - } - else - { -/*.................................... - positionnement sur le nombre de colonnes - .............................................*/ - fseek(fic_in,16,0); - -/*.................................. - recuperation du numero du premier detecteur - ...........................................*/ - fread(&detec1,4,1,fic_in); -/*.................................. - recuperation du dernier detecteur - ......................................*/ - fread(&detecF,4,1,fic_in); -/*.................................. - recuperation du nombre de lignes - ......................................*/ - fseek(fic_in,12,1); - fread(nb_lig,4,1,fic_in); -/*.................................. - calcul du nombre de colonne - ......................................*/ - *nb_col = detecF - detec1 ; -/*.................................. - initialisation du type de codage des pixels - ......................................*/ - image1->NB_BITS_PIX=8; - image1->NBOCT_PIX=1; - sprintf(image1->COD_PIX,"OCT"); - *nboct_pix = image1->NBOCT_PIX; - -/*.................................. - initialisation du nb de canaux (toujours monocanal) - ......................................................*/ - *nb_can = 1; - -/*.................................. - Calcul de la taille d'une ligne sur disque - ......................................................*/ - Tail_lig = (((*nb_col-1)/4)+1)*4; - - } -/*.................................. - Fermeture du fichier - ......................................*/ - if (fic_in!=NULL) fclose(fic_in); - - if (iret !=0) - { -/*....................................... - INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL - .....................................................*/ - - nom_fic[0]='\0'; - nom_fic_canal[0]='\0'; - - if ((long int)strlen(repert)!=0) - { - sprintf(nom_fic_canal,"%s/%s.pfe",repert,nom_image); - } - else - { - sprintf(nom_fic_canal,"%s.pfe",nom_image); - } - - num=open(nom_fic_canal,O_RDONLY|O_BINARY,0); - if (num!= -1) - { - - for (i=0;i<*nb_can;i=i+1) - { - sscanf(nom_image,"%s",image1->NOM_FIC_CAN); - sscanf(nom_image,"%s",image1->NOM_UTIL_CAN); - image1->ACCES_CANAL_INT[i]=num; - image1->POS_OCTET[i]=Tail_lig; - } - } - else - iret=0; - } - } - if (iret == 0) - { - return (NULL); - } - else - { - return(image1); - } - -} -/* - Fin de l'operation cai_ouvre_lecture_gessimu -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_creation_gessimu */ -/* ---------- */ -/* */ -/* ROLE : fonction de creation et d'ouverture en ecriture d'une image */ -/* ----- au format gessimu et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_creation_gessimu(nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig, */ -/* label) */ -/* */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* nb_can (E) (int ) : nombre de canaux de l'image */ -/* nboct_pix (E) (int ) : nombre d'octets par pixels (1 ) */ -/* nb_lig (E) (int ) : nombre de lignes de l'image */ -/* nb_col (E) (int ) : nombre de colonnes de l'image */ -/* label (E) (char *) : commentaire lie a l'image */ -/* */ -/* cai_ouvre_creation_gessimu (S) (CAI_IMAGE *) : =NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_IMAGE *cai_ouvre_creation_gessimu(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig, - char *label) - -{ - FILE *fic; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - char nom_fic[1024]; /* nom du fichier en-tete */ - long retour; /* retour de fonction */ - int i,num; /* indice */ - struct stat buf_stat; /* structure decrivant status de fichier */ - unsigned char *Header; /* entete du fichier gessimu */ - int taille_entete; /* taille de l'entete */ - int detec1,detecF; /* numero du 1er et dernier detecteur */ - double h_moyen; - -/*********************************************/ -/* Verification qu'un seul canal est demande */ -/*********************************************/ - if (*nb_can != 1) - { - image1 = NULL; - sprintf ( CAI_ERREUR , - "Une image GESSIMU ne peut contenir qu'un seul canal"); - goto ERREUR; - } -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : FA : verification que l'image est codee sur un seul */ -/*octet par pixel (contrainte du format) */ -/*****************************************************************************/ - if (*nboct_pix != 1) - { - image1 = NULL; - sprintf ( CAI_ERREUR , - "Une image GESSIMU ne peutetre codee que sur un seul octet par pixel"); - goto ERREUR; - } - - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); -/*****************************************************************************/ -/* MOD : VERSION : 4.1 : FA:Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_creation"); - goto ERREUR; - } - -/*................................................. - Constitution du nom du fichier entete et verification qu'il - n'existe pas deja - .................................................*/ - - nom_fic[0]='\0'; - if ((long int)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s.pfe",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.pfe",nom_image); - } - - retour = stat ( nom_fic , &buf_stat ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "L'image %s GESSIMU existe \n" , nom_image ); - goto ERREUR; - } - -/*...................................................... - Ouverture du fichier entete en ecriture - Ecriture du contenu - ..........................................................*/ -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : modifications fopen binaire pour PC/NT */ -/*****************************************************************************/ - - fic = fopen(nom_fic,"wb"); - if (fic == NULL) - { - sprintf(CAI_ERREUR,"Erreur: Creation fichier %s impossible\n",nom_fic); - goto ERREUR; - } - taille_entete = (((*nb_col-1)/4)+1)*4; - Header = (unsigned char *) calloc(taille_entete,sizeof( unsigned char)); - if (Header == NULL) - { - sprintf(CAI_ERREUR,"Erreur alloc: Creation fichier %s impossible\n", - nom_fic); - goto ERREUR; - } - -/*******************************************/ -/* ecriture du 1ER detecteur de l'image */ -/*******************************************/ - detec1 = 1; - memcpy(&Header[16],&detec1 , 4 ); - -/************************************************/ -/* ecriture du dernier detecteur de l'image */ -/************************************************/ - detecF = *nb_col; - memcpy(&Header[20],&detecF , 4 ); - -/*********************************************/ -/* ecriture du nombre de colonnes de l'image */ -/*********************************************/ - memcpy(&Header[24],nb_col , 4 ); - -/*********************************************/ -/* ecriture du nombre de lignes de l'image */ -/*********************************************/ - memcpy(&Header[36],nb_lig , 4 ); - -/***************************************************/ -/* ecriture de la taille d'une ligne multiple de 4 */ -/***************************************************/ - memcpy(&Header[40],&taille_entete , 4 ); - -/************************************************/ -/* ecriture du h_moyen (double 0) */ -/************************************************/ - h_moyen = 0.; - memcpy(&Header[44],&h_moyen , 8 ); - - retour = fwrite ( Header , taille_entete , 1 , fic ); - free(Header); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , - "Erreur : ecriture entete impossible dans fichier %s\n", - nom_fic ); - goto ERREUR; - } - -/*************************************************/ -/* Fermeture du fichier */ -/*************************************************/ - - fclose ( fic ); - - num = open(nom_fic,O_RDWR|O_BINARY,PERMS); - if (num == -1) - { - - sprintf(CAI_ERREUR,"Erreur: Creation %s impossible\n",nom_fic); - goto ERREUR; - } - - for (i=0;i<*nb_can;i=i+1) - { - image1->ACCES_CANAL_INT[i]=num; - image1->POS_OCTET[i]=taille_entete; - } - - return (image1); - -ERREUR : - return(NULL); -} - -/* - Fin de l'operation cai_ouvre_creation_gessimu -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_lecture_canal_gessimu */ -/* ---------- */ -/* */ -/* ROLE : fonction de lecture d'un canal d'une image GESSIMU */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_lecture_canal_gessimu(image1, canal, */ /* ------------------ premiere_ligne, */ -/* premiere_colonne, */ -/* nombre_lignes_lire , */ -/* nombre_colonnes_lire, */ -/* pas_ligne ,pas_colonne, */ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a lire */ -/* premiere_ligne (E) (int) : premiere ligne a lire dans l'image */ -/* premiere _colonne (E) (int) : premiere colonne a lire dans l'image */ -/* nombre_lignes_lire (E) (int) : nombre de lignes a lire */ -/* nombre_colonnes_lire (E) (int) : nombre de colonnes a lire */ -/* pas_ligne (E) (int) : pas en ligne */ -/* pas_colonne (E) (int) : pas en colonne */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels lus alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_lecture_canal_gessimu (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_OK_KO cai_lecture_canal_gessimu(CAI_IMAGE *image1 , - int *canal , - int *premiere_ligne , - int *premiere_colonne, - int *nombre_lignes_lire , - int *nombre_colonnes_lire, - int *pas_ligne , - int *pas_colonne, - unsigned char *data_image ) -{ - - int num,i,j,k,kk; /* variables de travail */ - long pt_oct,n; /* position courante dans le fichier image */ - int no_oct; /* numero du premier octet a lire */ - int iret; /* indicateur d'erreur */ - int lig; /* indice de boucle sur les lignes */ - int oct_pix; /* nb octets par pixels */ - long nb_oct; /* nb oct =1er octet a lire - position courante */ - unsigned char *buf_lec; /* buffer lecture d'une ligne */ - unsigned char *deb,*pch; /* pointeur chaine pour transfert buffer sortie */ - int Tail_lig; /* Taille physique d'une ligne sur disque */ - -/*********************************************/ -/* Verification qu'un seul canal est demande */ -/*********************************************/ - if (*canal != 1) - { - image1 = NULL; - sprintf ( CAI_ERREUR , - "Une image GESSIMU ne contient qu'un seul canal"); - iret=CAI_KO; - } - else - { -/*........................... - Initialisations diverses - ..........................*/ - iret=CAI_OK; - num=image1->ACCES_CANAL_INT[*canal-1]; - oct_pix=image1->NBOCT_PIX; - Tail_lig = (((image1->NB_COL-1)/4)+1)*4; - -/*.............................................. - allocation de memoire pour lire une ligne image - ............................................. */ - - buf_lec = (unsigned char *) calloc(Tail_lig,sizeof(unsigned char)); - if (buf_lec == NULL) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Probleme allocation memoire"); - } - else - { -/*.................... - Initialisation - ......................*/ - lig=*premiere_ligne; - i=1; - pch=data_image; - -/*..................... - Pour chaque ligne a lire - .......................................*/ - while ((i <= *nombre_lignes_lire)&&(iret==CAI_OK)) - { -/*............................................ - Recherche de la position courante dans le fichier - ............................................*/ - pt_oct=lseek(num,0L,1); - -/*................................ - Calcul du numero du 1er octet a lire - ....................................*/ - - no_oct=image1->POS_OCTET[*canal-1]+(lig-1)*Tail_lig; - - -/*.................................. - Saut d'octets pour etre positionne sur la ligne a lire - .......................................*/ - nb_oct=(long)(no_oct-pt_oct); - lseek(num,nb_oct,1); - -/*........................................... - lecture d'une ligne image - ................................................*/ - n=read(num,buf_lec,Tail_lig); - - if (n<=0) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Erreur lecture donnee image GESSIMU"); - } - else - { -/*...................................... - Sauvegarde des donnees lues entenant compte du pas - d'echantillonnage en colonne - ........................................*/ - deb=buf_lec+(*premiere_colonne-1)*oct_pix; - j=1; - while (j <= *nombre_colonnes_lire) - { - *pch=*deb; - j=j+1; - pch=pch+1; - deb=deb+(*pas_colonne); - } - - } - i=i+1; - lig=lig+(*pas_ligne); - } - - free(buf_lec); - } - } - return(iret); -} -/* - Fin de l'operation cai_lecture_canal_gessimu -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ecriture_canal_gessimu */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ecriture d'un canal d'une image gessimu */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ecriture_canal_gessimu(image1, canal, */ /* ------------------ premiere_ligne, */ -/* nombre_lignes_ecrire, */ -/* nombre_colonnes_ecrire,*/ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a ecrire */ -/* premiere_ligne (E) (int) : premiere ligne a ecrire ds l'image */ -/* nombre_lignes_ecrire (E) (int) : nombre de lignes a ecrire */ -/* nombre_colonnes_ecrire(E) (int) : nombre de colonnes a ecrire */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels ecris alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_ecriture_canal_gessimu (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_OK_KO cai_ecriture_canal_gessimu (CAI_IMAGE *image1 , - int *canal , - int *premiere_ligne , - int *nombre_lignes_ecrire , - int *nombre_colonnes_ecrire, - unsigned char *data_image ) -{ -long position_first_lig; /* position de la 1ere ligne a ecrire */ -long position_courante; /* position courante dans le fichier */ -long deplacement; /* deplacement a effectuer */ -unsigned char *buff_lig; /* pointeur de travail bandeau a ecrire */ -long cr_write; /* code retour de write */ -int num; /* descripteur de fichier */ -int nboct_pix; /* nombre d'octets par pixel */ -int nb_canaux; /* nombre de canaux de l'image totale */ -int nboct_ecrire; /* nb d'octets du bandeau a ecrire */ -int Tail_lig; /* taille en octet d'une ligne (mult 4) */ -int ind,i; /* variables de travail */ - -/*********************************************/ -/* Verification qu'un seul canal est demande */ -/*********************************************/ - if (*canal != 1) - { - image1 = NULL; - sprintf ( CAI_ERREUR , - "Une image GESSIMU ne contient qu'un seul canal"); - goto ERREUR; - } - -/* ................ - Initialisations - .................*/ - - num = image1->ACCES_CANAL_INT[*canal-1]; - nboct_pix = image1->NBOCT_PIX; - nb_canaux = 1; - position_first_lig = 0; - position_courante = 0; - deplacement = 0; - nboct_ecrire = 0; - Tail_lig = (((image1->NB_COL-1)/4)+1)*4; - buff_lig = NULL; - buff_lig = (unsigned char *) calloc(Tail_lig,sizeof(unsigned char)); - if (buff_lig == NULL) - { - strcpy(CAI_ERREUR,"Probleme allocation memoire"); - goto ERREUR; - } - /********************************************************/ -/* Calcul de la position de la premiere ligne a ecrire */ -/********************************************************/ - - position_first_lig = (long) ( image1->POS_OCTET[*canal-1] + - + (*premiere_ligne - 1) * Tail_lig); - -/********************************************************/ -/* Recuperation de la position courante */ -/********************************************************/ - - position_courante = lseek ( num , 0L , 1 ); - -/********************************************************/ -/* Calcul du deplacement jusqu'a la 1ere ligne a ecrire */ -/********************************************************/ - - deplacement = position_first_lig - position_courante; - -/*******************************************************/ -/* deplacement jusqu'a la premiere ligne a ecrire */ -/*******************************************************/ - - lseek ( num , deplacement , 1 ); - -/***********************************************/ -/* ecriture des lignes */ -/***********************************************/ - nboct_ecrire = *nombre_colonnes_ecrire; - ind = 0; - i = 0; - -/*..................... - Pour chaque ligne a lire - .............................*/ - while (i < *nombre_lignes_ecrire) - { - memcpy(buff_lig,&data_image[ind] , nboct_ecrire ); - - - cr_write = write ( num , buff_lig,Tail_lig); - - if ( cr_write != Tail_lig) - { - strcpy ( CAI_ERREUR , - "Erreur ecriture canal image gessimu\n" ); - goto ERREUR; - } - ind = ind + nboct_ecrire; - i = i + 1; - } -if (buff_lig != NULL) free(buff_lig); - -return (CAI_OK); - -ERREUR : - -if (buff_lig != NULL) free(buff_lig); -return (CAI_KO); - - -} -/* - Fin de l'operation cai_ecriture_canal_gessimu -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ferme_gessimu */ -/* ---------- */ -/* */ -/* ROLE : fonction de fermeture d'une image au format gessimu et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ferme_gessimu(image1) */ /* ------------------ */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* */ -/* cai_ferme_gessimu (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_OK_KO cai_ferme_gessimu (CAI_IMAGE *image1) - -{ - - int iret; /* code retour de l'operation */ - int i_can; /* indice du canal a fermer */ - int num; /* descripteur du fichier a fermer */ - - iret=CAI_OK; -/*............................................. - Fermeture du fichier qui contient tous les canaux - .............................................*/ - num=image1->ACCES_CANAL_INT[0]; - if (num>0) close(num); - - - return (iret); -} - -/* - Fin de l'operation cai_ferme_gessimu -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_dest_ima_gessimu */ -/* ---------- */ -/* */ -/* ROLE : fonction de destruction d'une image stocke en gessimu et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_dest_ima_gessimu(repertoire,nom_ima) */ /* ------------------ */ -/* repertoire (E) (char *) : repertoire de l'image a detruire */ -/* nom_image (E) (char *) : nom de l'image a detruire avec repertoire */ -/* */ -/* cai_dest_ima_gessimu (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - - -CAI_OK_KO cai_dest_ima_gessimu ( char *repertoire , - char *nom_ima ) - -{ -int i_can; /* compteur de canaux */ -int iret; /* code retour fonction fermetrue lecture */ -char str_num_canal[3]; /* suffixe numero du canal */ -char nom_fic_entete[1024]; /* nom du fichier entete a detruire */ -char nom_ima_complet[1024]; /* repertoire + nom de l'image */ -char nom_fic_canal[1024]; /* nom du fichier canal a detruire */ - -int cr_stat; /* code retour de fonction status de fichier */ -struct stat buf_stat; /* structure decrivant status de fichier */ - -CAI_IMAGE *image1; /* structure ouverture image */ -int nb_can; /* nombre de canaux de l'image */ -int nboct_pix; /* nombre d'octets par pixel image */ -int nb_col; /* nombre de colonnes de l'image */ -int nb_lig; /* nombre de lignes de l'image */ - -/************************************************/ -/* Constitution du nom du fichier d'entete */ -/************************************************/ - -if ((long)strlen(repertoire)!= 0) -{ - sprintf( nom_ima_complet, "%s/%s" ,repertoire,nom_ima); -} -else -{ - strcpy ( nom_ima_complet , nom_ima); -} - sprintf(nom_fic_entete ,"%s.pfe", nom_ima_complet); - -/************************************************/ -/* Destruction du fichier d'entete */ -/************************************************/ - -cr_stat = stat ( nom_fic_entete , &buf_stat ); -if ( cr_stat == 0 ) - unlink ( nom_fic_entete ); - - -return (CAI_OK); - -} -/* - Fin de l'operation cai_dest_ima_gessimu -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_modifie_gessimu */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture-ecriture d'une image au format */ -/* ----- gessimu et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_modifie_gessimu(nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels (1 ) */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_modifie_gessimu (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ /* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_IMAGE *cai_ouvre_modifie_gessimu(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) - -{ - FILE *fic_in; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - int iret; /* indicateur de retour ok ou pas */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char nom_fic_canal[1024]; /* nom fichier canal dont on teste existence*/ - int nbbit; /* nb de bits par pixel du fichier en-tete */ - int retour; /* retour de la fonction comparaison chaines*/ - int i,num; /* indice */ - char type_cod[5]; /* type de codage du pixel */ - int detec1,detecF; /* 1er et dernier detecteur dans l'entete */ - int Tail_lig; /* taille d'une ligne sur disque (multi 4) */ - - /*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - *nb_can=0; - - *nb_lig=0; - - *nb_col=0; - - *nboct_pix=0; - - iret=1; - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); -/*****************************************************************************/ -/* MOD : VERSION : 4.1 : FA:Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_modifie"); - } - else - { -/*................................................. - Constitution du nom du fichier entete - .................................................*/ - nom_fic[0]='\0'; - if ((long int)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s.pfe",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.pfe",nom_image); - } - -/*........................ - Ouverture du fichier entete - ..........................................*/ -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : modifications fopen binaire pour PC/NT */ -/*****************************************************************************/ - - fic_in=fopen(nom_fic,"rb"); - if (fic_in==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur ouverture fichier entete GESSIMU"); - } - else - { -/*.................................... - positionnement sur le nombre de colonnes - .............................................*/ - fseek(fic_in,16,0); -/*.................................. - recuperation du numero du premier detecteur - ...........................................*/ - fread(&detec1,4,1,fic_in); -/*.................................. - recuperation du dernier detecteur - ......................................*/ - fread(&detecF,4,1,fic_in); -/*.................................. - recuperation du nombre de lignes - ......................................*/ - fseek(fic_in,12,1); - fread(nb_lig,4,1,fic_in); -/*.................................. - calcul du nombre de colonne - ......................................*/ - *nb_col = detecF - detec1 ; -/*.................................. - initialisation du type de codage des pixels - ......................................*/ - image1->NB_BITS_PIX=8; - image1->NBOCT_PIX=1; - sprintf(image1->COD_PIX,"OCT"); - *nboct_pix = image1->NBOCT_PIX; - -/*.................................. - initialisation du nb de canaux (toujours monocanal) - ......................................................*/ - *nb_can = 1; - -/*.................................. - Calcul de la taille d'une ligne sur disque - ......................................................*/ - Tail_lig = (((*nb_col-1)/4)+1)*4; - - } -/*.................................. - Fermeture du fichier - ......................................*/ - if (fic_in!=NULL) fclose(fic_in); - - if (iret !=0) - { -/*....................................... - INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL - .....................................................*/ - - nom_fic[0]='\0'; - nom_fic_canal[0]='\0'; - - if ((long int)strlen(repert)!=0) - { - sprintf(nom_fic_canal,"%s/%s.pfe",repert,nom_image); - } - else - { - sprintf(nom_fic_canal,"%s.pfe",nom_image); - } - - num=open(nom_fic_canal,O_RDWR|O_BINARY,0); - if (num!= -1) - { - - for (i=0;i<*nb_can;i=i+1) - { - sscanf(nom_image,"%s",image1->NOM_FIC_CAN); - sscanf(nom_image,"%s",image1->NOM_UTIL_CAN); - image1->ACCES_CANAL_INT[i]=num; - image1->POS_OCTET[i]=Tail_lig; - } - } - else - iret=0; - } - } - if (iret == 0) - { - return (NULL); - } - else - { - return(image1); - } - -} -/* - Fin de l'operation cai_ouvre_modifie_gessimu -*/ - diff --git a/Utilities/CAI/cai_dll/src/cai_grilles.c b/Utilities/CAI/cai_dll/src/cai_grilles.c deleted file mode 100755 index 676b925c7bab74be3e84048fb93c5ecd84b6ee4f..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/src/cai_grilles.c +++ /dev/null @@ -1,1916 +0,0 @@ -/*****************************************************************************/ -/* */ -/* PROJET : COUCHE ACCES IMAGE */ -/* ------- */ -/* */ -/* MODULE : cai_grilles.c */ -/* ------- */ -/* */ -/* ROLE : Ce module rassemble toutes les fonctions d'acces aux images */ -/* ------- stockees au format gdb (Grille de Decalages Bruts) et au */ -/* format gdr (Grille de Decalages Restitues) */ -/* */ -/* AUTEUR : R.CHAISEMARTIN (CISI) */ -/* ------- */ -/* */ -/* DATE DE CREATION : Septembre 99 */ -/* ----------------- */ -/* */ -/* LANGAGE : C */ -/* -------- */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ -/* MOD : VERSION : 4.1 :FA:Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : DM : modifications indications Big ou Little Endian */ -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : DM : modifications pour compatibilite HP64bits */ -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM :fonctions de test machine et inversions */ -/* deviennent generiques */ -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : modifications fopen binaire pour PC/NT */ -/*****************************************************************************/ -/* MOD : VERSION : 4.4 : DM : modifications open binaire pour PC/NT */ -/*****************************************************************************/ -/* MOD : VERSION : 4.5 : FA : test sur fclose pour PC/LINUX */ -/*****************************************************************************/ - -/*---------------------------------------------------------------------------*/ -/* Inclusion des fichiers STANDARDS (.h) */ -/*---------------------------------------------------------------------------*/ - - -# include <stdio.h> -# include <string.h> -# include <stdlib.h> -# include <unistd.h> -# include <sys/types.h> -# include <dirent.h> -# include <sys/stat.h> -# include <fcntl.h> -# include <malloc.h> -# include <math.h> -# include <unistd.h> - -#define _CAI_IMAGE -#define IN_CAI_GRIL - -# include "cai_image.h" - -/*----------------------------------------------------------------------------*/ -/* Variable pour la gestion en configuration */ -/*----------------------------------------------------------------------------*/ -static char *rcs_id="$Header: cai_grilles.c,v 1.6 01/05/31 10:47:38 cmf Exp $"; - - -extern char *getenv(); - -/*****************************************************************************/ -/*****************************************************************************/ -/* */ -/* Definition des OPERATIONS EXTERNES */ -/* */ -/*****************************************************************************/ -/*****************************************************************************/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_liste_ima_grilles */ -/* ---------- */ -/* */ -/* ROLE : fonction de listage des images au format gdb */ -/* ------ */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : int cai_liste_ima_grilles(typ_grille,repert,tab_ima) */ -/* ----------------- */ -/* */ -/* typ_grille (E) (char) : type de grille B=Brute, R=rectifiee */ -/* repert (E) (char *) : repertoire a explorer */ -/* tab_ima (S) (char ***) : pointeur sur tableau des images listees */ -/* alloue par la fonction,il doit etre */ -/* LIBERE PAR L'APPELANT */ -/* */ -/* cai_liste_ima_grilles (S) (int) : = -1 repertoire inexistant */ -/* = > 0 nombre d'images listees */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -long int cai_liste_ima_grilles (char typ_grille,char *repert,char ***tab_ima) - -{ - DIR *dirp; /* pointeur sur structure ouverture repertoire */ - struct dirent *dp; /* structure resultat de la fonction readdir */ - char *pch0,*pch1; /* pointeurs sur chaine de caracteres */ - char car; /* variable de travail */ - int nb_ima; /* nombre d'images gdb identifiees */ - long int i; /* indice de boucle */ - long int ll,dif; /* variables de travail */ - char blanc; /* caractere blanc */ - char extens[5]; /* extension recherchee */ - -/*........................................ - INITIALISATION et ouverture du repertoire choisi - .........................................*/ - extens[0]='\0'; - if (typ_grille=='B') - strcpy(extens,".gdb"); - else - strcpy(extens,".gdr"); - nb_ima=0; - blanc=' '; - dirp=opendir(repert); - - if(dirp!=NULL) - { -/*...................................... - - premiere passe pour comptabiliser les images du format donne - - - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE GDB ou GDR - (EXTENSION =.gdb pour Brute ou .gdr pour Rectifiee) - ......................................................*/ - - while((dp=readdir(dirp))!=NULL) - { - pch0=strstr(dp->d_name,extens); - if (pch0 != NULL) - { - ll = strlen(dp->d_name); - dif = (long)(dp->d_name-pch0); - dif=labs(dif); - pch1=pch0+4; - if (((ll-4)==dif)||((*pch1)==blanc)) - nb_ima=nb_ima+1; - - } - - } - - closedir(dirp); -/*..................................... - ALLOCATION DU TABLEAU CONTENANT LA LISTE DES IMAGES DU FORMAT GDB ou GDR - .......................................................................*/ - *tab_ima = (char **) calloc(nb_ima,sizeof(char *)); - for (i=0;i<nb_ima;i=i+1) - (*tab_ima)[i]=(char *)calloc(1,100); - -/*...................................... - - deuxieme passe pour constituer la liste des images du format donne - - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE GDB ou GDR - (EXTENSION =.gdb ou .gdr) - SI C`EST LE CAS,STOCKAGE DANS LA LISTE - ..........................................*/ - dirp=opendir(repert); - - nb_ima=0; - - while((dp=readdir(dirp))!=NULL) - { - pch0=strstr(dp->d_name,extens); - if (pch0 != NULL) - { - ll = strlen(dp->d_name); - dif = (long)(dp->d_name-pch0); - dif=labs(dif); - pch1=pch0+4; - if (((ll-4)==dif)||((*pch1)==blanc)) - { - *pch0='\0'; - strcpy((*tab_ima)[nb_ima],dp->d_name); - nb_ima=nb_ima+1; - } - - } - } - - closedir(dirp); - - } - else - { - /* Erreur : Repertoire inexistant */ - nb_ima=-1; - } - - return(nb_ima); - -} -/* Fin de l'operation cai_liste_ima_grilles -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_lecture_grilles */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture d'une image format gdb ou gdr */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_lecture_grilles(typ_grille, */ -/* ---------------- nom_image, */ -/* nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* typ_grille (E) (char) : type de grille B=Brute, R=rectifiee */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_lecture_grilles (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_IMAGE *cai_ouvre_lecture_grilles(char typ_grille, - char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) -{ - FILE *fic_in; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - int iret; /* indicateur de retour ok ou pas */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char nom_fic_canal[1024]; /* nom fichier canal dont on teste existence */ - int nbbit; /* nb de bits par pixel du fichier en-tete */ - int retour; /* retour de la fonction comparaison chaines */ - int i,num; /* indice */ - char type_cod[5]; /* type de codage du pixel */ - int temp; /* zone temporaire de lecture */ - char extens[5]; /* extension recherchee */ - char type_image[3]; /* type code+ordre rangement octets dans entete*/ - char *type_machine; /* ordre rangement octets machine travail */ - char buf[59]; /* buffer contenant entete image */ - int v; /* comparaison type machine-type image */ - char *v1; /* comparaison type image avec chaine vide */ - int nb_col2, nb_lig2; /* variables intermediaires inversion octets */ - int temp2,nb; /* zone temporaire de lecture */ - - /*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - *nb_can=0; - - *nb_lig=0; - - *nb_col=0; - - *nboct_pix=0; - - iret=1; - - type_machine = (char *) calloc(3,sizeof(char)); - - if (type_machine == NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur allocation memoire dans cai_ouvre_lecture"); - } - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); - -/*****************************************************************************/ -/* MOD : VERSION : 4.1 :FA:Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur allocation memoire dans cai_ouvre_lecture"); - } - else - { - - extens[0]='\0'; - if (typ_grille =='B') - strcpy(extens,".gdb"); - else - strcpy(extens,".gdr"); - -/*................................................. - Constitution du nom du fichier entete - .................................................*/ - nom_fic[0]='\0'; - if ((long)strlen(repert)!= 0) - { - sprintf(nom_fic,"%s/%s%s",repert,nom_image,extens); - } - else - { - sprintf(nom_fic,"%s%s",nom_image,extens); - } - -/*........................ - Ouverture du fichier entete - ..........................................*/ -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : modifications fopen binaire pour PC/NT */ -/*****************************************************************************/ - fic_in=NULL; - fic_in=fopen(nom_fic,"rb"); - if (fic_in==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur ouverture fichier entete grille"); - } - else - { - - -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : DM : modifications indications Big ou Little Endian */ -/*****************************************************************************/ - -/*.................................. - recuperation infos completes format.gdb - ......................................*/ - - if (typ_grille =='B') - fread(buf,36,1,fic_in); - -/*.................................. - recuperation infos completes format.gdr - ......................................*/ - else fread(buf,56,1,fic_in); - -/*.................................. - recuperation du type de codage des pixels - ......................................*/ - memcpy(type_cod,&buf[8],4); - - if (strncmp(type_cod,"FLOA",4) ==0) - { - image1->NB_BITS_PIX=32; - image1->NBOCT_PIX=4; - sprintf(image1->COD_PIX,"R4"); - strcpy(type_image,"BE"); - sprintf(image1->TYPE_COD,"FLOA"); - } - - else if (strncmp(type_cod,"FLOL",4) ==0) - { - image1->NB_BITS_PIX=32; - image1->NBOCT_PIX=4; - sprintf(image1->COD_PIX,"R4"); - strcpy(type_image,"LE"); - sprintf(image1->TYPE_COD,"FLOL"); - } - - else - { - iret=0; - sprintf(CAI_ERREUR,"Type de codage GRILLE non reconnu : %s",type_cod); - } - - *nboct_pix = image1->NBOCT_PIX; - -/*.................................. - determination ordre de rangement - des octets sur machine de travail - ......................................*/ - - type_machine = cai_test_pFpf(); - - /*.................................. - determination des autres infos - en fonction inversion - ......................................*/ - - v = strncmp(type_machine,type_image,2); - v1 = strrchr(type_image,'E'); - -/*.................................. - recuperation du nombre de colonne - ......................................*/ - memcpy(nb_col,&buf[0],4); - -/*modification si (type_image et type_machine st differentes) */ -/*et si (type_image existe avec BE ou LE)*/ - nb=2; - if ( (v!=0) && (v1!=NULL) ) - { - swab( (void*)nb_col, (void*)&nb_col2,4 ); - cai_inverser_tableau((short *)nb_col, (short *)&nb_col2,nb); - } - -/*.................................. - recuperation du nombre de lignes - ......................................*/ - memcpy(nb_lig,&buf[4],4); - -/*modification si (type_image et type_machine st differentes) */ -/*et si (type_image existe avec BE ou LE)*/ - - if ( (v!=0) && (v1!=NULL) ) - { - swab( (void*)nb_lig, (void*)&nb_lig2,4 ); - cai_inverser_tableau((short *)nb_lig, (short *)&nb_lig2, nb); - } - -/*..................................................................... - recuperation du numero de ligne du 1er point de la matrice - .....................................................................*/ - - memcpy(&temp,&buf[12],4); - -/*modification si (type_image et type_machine st differentes) */ -/*et si (type_image existe avec BE ou LE)*/ - - if ( (v!=0) && (v1!=NULL) ) - { - swab( (void*)&temp, (void*)&temp2,4 ); - cai_inverser_tableau((short *)&temp, (short *)&temp2,nb); - } - - image1->NUM_LIG_DEB = temp; - -/*..................................................................... - recuperation du numero de colonne du 1er point de la matrice - .....................................................................*/ - - memcpy(&temp,&buf[16],4); - -/*modification si (type_image et type_machine st differentes) */ -/*et si (type_image existe avec BE ou LE)*/ - - if ( (v!=0) && (v1!=NULL) ) - { - swab( (void*)&temp, (void*)&temp2,4 ); - cai_inverser_tableau((short *)&temp, (short *)&temp2, nb); - } - - image1->NUM_COL_DEB = temp; - -/*..................................................................... - recuperation du pas de la grille le long des lignes - .....................................................................*/ - - memcpy(&temp,&buf[20],4); - -/*modification si (type_image et type_machine st differentes) */ -/*et si (type_image existe avec BE ou LE)*/ - - if ( (v!=0) && (v1!=NULL) ) - { - swab( (void*)&temp, (void*)&temp2,4 ); - cai_inverser_tableau((short *)&temp, (short *)&temp2,nb); - } - - image1->PAS_GRIL_LIG = temp; - -/*..................................................................... - recuperation du pas de la grille le long des colonnes - .....................................................................*/ - - memcpy(&temp,&buf[24],4); - -/*modification si (type_image et type_machine st differentes) */ -/*et si (type_image existe avec BE ou LE)*/ - - if ( (v!=0) && (v1!=NULL) ) - { - swab( (void*)&temp, (void*)&temp2,4 ); - cai_inverser_tableau((short *)&temp, (short *)&temp2,nb); - } - - image1->PAS_GRIL_COL = temp; - -/*..................................................................... - recuperation du decalage initial le long des lignes - .....................................................................*/ - - memcpy(&temp,&buf[28],4); - -/*modification si (type_image et type_machine st differentes) */ -/*et si (type_image existe avec BE ou LE)*/ - - if ( (v!=0) && (v1!=NULL) ) - { - swab( (void*)&temp, (void*)&temp2,4 ); - cai_inverser_tableau((short *)&temp, (short *)&temp2,nb); - } - - image1->DECAL_LIG = temp; - -/*..................................................................... - recuperation du decalage initial le long des colonnes - .....................................................................*/ - - memcpy(&temp,&buf[32],4); - -/*modification si (type_image et type_machine st differentes) */ -/*et si (type_image existe avec BE ou LE)*/ - - if ( (v!=0) && (v1!=NULL) ) - { - swab( (void*)&temp, (void*)&temp2,4 ); - cai_inverser_tableau((short *)&temp,(short *) &temp2,nb); - } - - image1->DECAL_COL = temp; - -/*..................................................................... - recuperation de la caracteristique de la grille si .gdr -.....................................................................*/ - if (typ_grille == 'R') - { - memcpy(image1->CAR_GRIL,&buf[36],20); - *nb_can = 2; - } - else - *nb_can = 3; - } - -/**************************/ -/* fin modifications */ -/**************************/ - -/*.................................. - Fermeture du fichier - ......................................*/ - if (fic_in != NULL) fclose(fic_in); - - if (iret !=0) - { -/*....................................... - INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL - .....................................................*/ - - - nom_fic_canal[0]='\0'; - - if ((long)strlen(repert)!= 0) - { - sprintf(nom_fic_canal,"%s/%s%s",repert,nom_image,extens); - } - else - { - sprintf(nom_fic_canal,"%s%s",nom_image,extens); - } - - num=open(nom_fic_canal,O_RDONLY|O_BINARY,0); - if (num!= -1) - { - - for (i=0;i<*nb_can;i=i+1) - { - sscanf(nom_image,"%s",image1->NOM_FIC_CAN); - sscanf(nom_image,"%s",image1->NOM_UTIL_CAN); - image1->ACCES_CANAL_INT[i]=num; - image1->POS_OCTET[i]=((i*(*nb_lig))+1)*(*nb_col)*image1->NBOCT_PIX; - } - - -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : DM : modifications indications Big ou Little Endian */ -/*****************************************************************************/ - - if ( (v!=0) && (v1!=NULL) ) - { - image1->INV_OCTETS =1; - } - else - { - image1->INV_OCTETS =0; - } - -/**************************/ -/* fin modifications */ -/**************************/ - - } - else - iret=0; - } - - } - if (iret == 0) - { - return (NULL); - } - else - { - return(image1); - } - -} -/* - Fin de l'operation cai_ouvre_lecture_grilles -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_creation_grilles */ -/* ---------- */ -/* */ -/* ROLE : fonction de creation et d'ouverture en ecriture d'une image */ -/* ----- au format gdb ou gdr (grilles brutes ou restituees) */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_creation_grilles(typ_grille, */ -/* ---------------- nom_image, */ -/* nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig, */ -/* label) */ -/* */ -/* typ_grille (E) (char) : type de grille B=Brute, R=rectifiee */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* nb_can (E) (int ) : nombre de canaux de l'image */ -/* nboct_pix (E) (int ) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (E) (int ) : nombre de lignes de l'image */ -/* nb_col (E) (int ) : nombre de colonnes de l'image */ -/* label (E) (char *) : commentaire lie a l'image */ -/* */ -/* cai_ouvre_creation_grilles (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_IMAGE *cai_ouvre_creation_grilles(char typ_grille,char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig, - char *label) - -{ - FILE *fic; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - char nom_fic[1024]; /* nom du fichier en-tete */ - long retour; /* retour de fonction */ - int i,num; /* indice */ - struct stat buf_stat; /* structure decrivant status de fichier */ - unsigned char *Header; /* entete du fichier gdb */ - int taille_entete; /* taille de l'entete */ - int temp; /* zone temporaire pour ecriture */ - char extens[5]; /* extension recherchee */ - int Min_nbcol; /* nombre de colonnes minimums */ - char *type_image; /* type code+ordre rangement des octets ds entete */ - - extens[0]='\0'; - if (typ_grille == 'B') - { - Min_nbcol = 9; - strcpy(extens,".gdb"); - -/******************************************************************/ -/* Verification que les trois plans sont demandes */ -/* -> plan1 : grille pour les decalages le long des lignes */ -/* -> plan2 : grille pour les decalages le long des colonnes */ -/* -> plan3 : grille pour les indices de confiance */ -/******************************************************************/ - if (*nb_can != 3) - { - image1 = NULL; - sprintf ( CAI_ERREUR , - "Une image GDB doit contenir trois plans"); - goto ERREUR; - } - } - else - { -/******************************************************************/ -/* Verification que les deux plans sont demandes */ -/* -> plan1 : grille pour les decalages le long des lignes */ -/* -> plan2 : grille pour les decalages le long des colonnes */ -/******************************************************************/ - if (*nb_can != 2) - { - image1 = NULL; - sprintf ( CAI_ERREUR , - "Une image GDR doit contenir deux plans"); - goto ERREUR; - } - strcpy(extens,".gdr"); - Min_nbcol = 14; - - } - -/**************************************************************/ -/* Verification que le nombre minimum de colonnes est demande */ -/**************************************************************/ - if ((*nb_col)< Min_nbcol) - { - image1 = NULL; - sprintf ( CAI_ERREUR , - "Une image doit contenir au moins %d colonnes",Min_nbcol); - goto ERREUR; - - } - taille_entete = (*nb_col)*(*nboct_pix); - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); - -/*****************************************************************************/ -/* MOD : VERSION : 4.1 :FA:Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_creation"); - goto ERREUR; - } - -/*................................................. - Constitution du nom du fichier entete et verification qu'il - n'existe pas deja - .................................................*/ - - nom_fic[0]='\0'; - if ((long)strlen(repert)!= 0) - { - sprintf(nom_fic,"%s/%s%s",repert,nom_image,extens); - } - else - { - sprintf(nom_fic,"%s%s",nom_image,extens); - } - - retour = stat ( nom_fic , &buf_stat ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "L'image %s GRILLE existe \n" , nom_image ); - goto ERREUR; - } - -/*...................................................... - Ouverture du fichier entete en ecriture - Ecriture du contenu - ..........................................................*/ -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : modifications fopen binaire pour PC/NT */ -/*****************************************************************************/ - fic = fopen(nom_fic,"wb"); - if (fic == NULL) - { - sprintf(CAI_ERREUR,"Erreur: Creation fichier %s impossible\n",nom_fic); - goto ERREUR; - } - Header = (unsigned char *) calloc(taille_entete,sizeof( unsigned char)); - if (Header == NULL) - { - sprintf(CAI_ERREUR,"Erreur alloc: Creation fichier %s impossible\n", - nom_fic); - goto ERREUR; - } - -/*********************************************/ -/* ecriture du nombre de colonnes de l'image */ -/*********************************************/ - memcpy(Header,nb_col , 4 ); - -/*******************************************/ -/* ecriture du nombre de lignes de l'image */ -/*******************************************/ - memcpy(&Header[4],nb_lig , 4 ); - -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : DM : modifications indications Big ou Little Endian */ -/*****************************************************************************/ - -/*****************************************/ -/* ecriture type de l'image dans la zone */ -/* reservee au type de codage */ -/*****************************************/ - - /*.................................... - test sur la machine de travail pour - typer image en LE ou BE - .....................................*/ - - type_image = cai_test_pFpf(); - - - -/**************************************/ -/* ecriture type de codage de l'image */ -/**************************************/ - if (*nboct_pix != 4) - { - sprintf ( CAI_ERREUR , - "Erreur : La grille foit etre codee en FLOAT\n"); - goto ERREUR; - } - - else if ( (*nboct_pix == 4) && (strncmp(type_image,"BE",2)==0) ) - { - memcpy(&Header[8],"FLOA" , 4 ); - image1->NBOCT_PIX=4; - sprintf(image1->TYPE_COD,"FLOA"); - } - - else if ( (*nboct_pix == 4) && (strncmp(type_image,"LE",2)==0) ) - { - memcpy(&Header[8],"FLOL" , 4 ); - image1->NBOCT_PIX=4; - sprintf(image1->TYPE_COD,"FLOL"); - } - - -/***********************/ -/* fin modifications */ -/***********************/ - - -/***************************************************************/ -/* ecriture de l'entete ainsi constituee dans le fichier */ -/***************************************************************/ - retour = fwrite ( Header , taille_entete , 1 , fic ); - free(Header); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , - "Erreur : ecriture entete impossible dans fichier %s\n", - nom_fic ); - goto ERREUR; - } - -/*************************************************/ -/* Fermeture du fichier */ -/*************************************************/ - - fclose ( fic ); - - num = open(nom_fic,O_RDWR|O_BINARY,PERMS); - if (num == -1) - { - - sprintf(CAI_ERREUR,"Erreur: Creation %s impossible\n",nom_fic); - goto ERREUR; - } - - for (i=0;i<*nb_can;i=i+1) - { - image1->ACCES_CANAL_INT[i]=num; - image1->POS_OCTET[i]=((i*(*nb_lig))+1)*(*nb_col)*image1->NBOCT_PIX; - } - return (image1); - -ERREUR : - return(NULL); -} - -/* - Fin de l'operation cai_ouvre_creation_grilles -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_lecture_canal_grilles */ -/* ---------- */ -/* */ -/* ROLE : fonction de lecture d'un canal d'une image GDB ou GDR */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_lecture_canal_grilles(image1, */ -/* ------------------ canal,premiere_ligne, */ -/* premiere_colonne, */ -/* nombre_lignes_lire , */ -/* nombre_colonnes_lire, */ -/* pas_ligne ,pas_colonne, */ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a lire */ -/* premiere_ligne (E) (int) : premiere ligne a lire dans l'image */ -/* premiere _colonne (E) (int) : premiere colonne a lire dans l'image */ -/* nombre_lignes_lire (E) (int) : nombre de lignes a lire */ -/* nombre_colonnes_lire (E) (int) : nombre de colonnes a lire */ -/* pas_ligne (E) (int) : pas en ligne */ -/* pas_colonne (E) (int) : pas en colonne */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels lus alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_lecture_canal_grilles (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_OK_KO cai_lecture_canal_grilles(CAI_IMAGE *image1 , - int *canal , - int *premiere_ligne , - int *premiere_colonne, - int *nombre_lignes_lire , - int *nombre_colonnes_lire, - int *pas_ligne , - int *pas_colonne, - unsigned char *data_image ) - -{ - - int num,i,j,k,kk; /* variables de travail */ - long pt_oct,n; /* position courante dans le fichier image */ - int no_oct; /* numero du premier octet a lire */ - int iret; /* indicateur d'erreur */ - int lig; /* indice de boucle sur les lignes */ - int oct_pix; /* nb octets par pixels */ - long nb_oct; /* nb oct =1er octet a lire - position courante */ - long oct_lig; /* nb oct. par ligne en considerant taille pixel */ - unsigned char *buf_lec; /* buffer lecture d'une ligne */ - unsigned char *deb,*pch; /* pointeur chaine pour transfert buffer sortie */ - unsigned char *data_image2;/* pointeur donnees image pour inversion octets */ - int taille_image; /* taille en octets de l'image */ - int Nb; - - -/*........................... - Initialisations diverses - ..........................*/ - iret=CAI_OK; - num=image1->ACCES_CANAL_INT[*canal-1]; - oct_pix=image1->NBOCT_PIX; - taille_image = (*nombre_lignes_lire)*oct_pix*(*nombre_colonnes_lire); - data_image2 = NULL; - data_image2 = (unsigned char *) calloc(taille_image,sizeof(unsigned char)); - - if (data_image2 == NULL) - { - strcpy(CAI_ERREUR,"Erreur allocation memoire dans cai_lecture_canal"); - iret=CAI_KO; - goto FIN; - } - -/*.............................................................*/ -/* verification si lecture non sous-echantillonnee par bandeau */ -/*.............................................................*/ - if ((*nombre_colonnes_lire==image1->NB_COL)&&(*premiere_colonne==1)&& - (*pas_ligne==1)&&(*pas_colonne==1)) - { - oct_lig=(*nombre_lignes_lire)*oct_pix*(image1->NB_COL); - pch=data_image; - -/*............................................ - Recherche de la position courante dans le fichier - ............................................*/ - pt_oct=lseek(num,0L,1); - -/*................................ - Calcul du numero du 1er octet a lire - ....................................*/ - lig=*premiere_ligne; - no_oct=image1->POS_OCTET[*canal-1]+ - (lig-1)*image1->NB_COL*oct_pix; - - -/*.................................. - Saut d'octets pour etre positionne sur la ligne a lire - .......................................*/ - nb_oct=(long)(no_oct-pt_oct); - lseek(num,nb_oct,1); - -/*........................................... - lecture des lignes completes - ................................................*/ - n=read(num,pch,oct_lig); - - if (n<=0) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Erreur lecture donnee image grille"); - goto FIN; - - } - - } - else - { - oct_lig=oct_pix*image1->NB_COL; - -/*.............................................. - allocation de memoire pour lire une ligne image - ............................................. */ - buf_lec=NULL; - buf_lec = (unsigned char *) calloc(oct_lig,sizeof(unsigned char)); - if (buf_lec == NULL) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Probleme allocation memoire"); - } - else - { -/*.................... - Initialisation - ......................*/ - lig=*premiere_ligne; - i=1; - pch=data_image; - -/*..................... - Pour chaque ligne a lire - .......................................*/ - while ((i <= *nombre_lignes_lire)&&(iret==CAI_OK)) - { -/*............................................ - Recherche de la position courante dans le fichier - ............................................*/ - pt_oct=lseek(num,0L,1); - -/*................................ - Calcul du numero du 1er octet a lire - ....................................*/ - - no_oct=image1->POS_OCTET[*canal-1]+ - (lig-1)*image1->NB_COL*oct_pix; - - -/*.................................. - Saut d'octets pour etre positionne sur la ligne a lire - .......................................*/ - nb_oct=(long)(no_oct-pt_oct); - lseek(num,nb_oct,1); - -/*........................................... - lecture d'une ligne image - ................................................*/ - n=read(num,buf_lec,oct_lig); - - if (n<=0) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Erreur lecture donnee image GRILLE"); - } - else - { -/*...................................... - Sauvegarde des donnees lues entenant compte du pas - d'echantillonnage en colonne - ........................................*/ - deb=buf_lec+(*premiere_colonne-1)*oct_pix; - j=1; - while (j <= *nombre_colonnes_lire) - { - for (k=0;k<oct_pix;k=k+1) - { - *(pch+k)=*(deb+k); - } - j=j+1; - pch=pch+oct_pix; - deb=deb+(*pas_colonne*oct_pix); - } - - } - i=i+1; - lig=lig+(*pas_ligne); - } - - free(buf_lec); - buf_lec=NULL; - } - } - -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : DM : modifications indications Big ou Little Endian */ -/*****************************************************************************/ - - Nb = taille_image/2; - - if ( (iret!= CAI_KO) && (image1->INV_OCTETS==1) ) - { - - /*modification ordre des 4 octets par pixel*/ - swab( (void*)(data_image), (void*)(data_image2), taille_image); - cai_inverser_tableau(data_image, data_image2,Nb); - } - -/*************************/ -/* fin modifications */ -/*************************/ - FIN: - if (data_image2!= NULL) free(data_image2); - return(iret); -} -/* - Fin de l'operation cai_lecture_canal_grilles -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ecriture_canal_grilles */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ecriture d'un canal d'une image gdb */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ecriture_canal_grilles(image1, canal, */ -/* ------------------ premiere_ligne, */ -/* nombre_lignes_ecrire, */ -/* nombre_colonnes_ecrire,*/ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a ecrire */ -/* premiere_ligne (E) (int) : premiere ligne a ecrire ds l'image */ -/* nombre_lignes_ecrire (E) (int) : nombre de lignes a ecrire */ -/* nombre_colonnes_ecrire(E) (int) : nombre de colonnes a ecrire */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels ecris alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_ecriture_canal_grilles (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_OK_KO cai_ecriture_canal_grilles (CAI_IMAGE *image1 , - int *canal , - int *premiere_ligne , - int *nombre_lignes_ecrire , - int *nombre_colonnes_ecrire, - unsigned char *data_image ) - -{ -long position_first_lig; /* position de la 1ere ligne a ecrire */ -long position_courante; /* position courante dans le fichier */ -long deplacement; /* deplacement a effectuer */ -unsigned char *buff_lig; /* pointeur de travail bandeau a ecrire */ -long cr_write; /* code retour de write */ -int num; /* descripteur de fichier */ -int nboct_pix; /* nombre d'octets par pixel */ -int nboct_ecrire; /* nb d'octets du bandeau a ecrire */ - - -/* ................ - Initialisations - .................*/ - - num = image1->ACCES_CANAL_INT[*canal-1]; - nboct_pix = image1->NBOCT_PIX; - position_first_lig = 0; - position_courante = 0; - deplacement = 0; - nboct_ecrire = 0; - -/********************************************************/ -/* Calcul de la position de la premiere ligne a ecrire */ -/********************************************************/ - - position_first_lig = (long) ( image1->POS_OCTET[*canal-1] + - + (*premiere_ligne - 1) * - (*nombre_colonnes_ecrire) * nboct_pix ); - - -/********************************************************/ -/* Recuperation de la position courante */ -/********************************************************/ - - position_courante = lseek ( num , 0L , 1 ); - - -/********************************************************/ -/* Calcul du deplacement jusqu'a la 1ere ligne a ecrire */ -/********************************************************/ - - deplacement = position_first_lig - position_courante; - -/*******************************************************/ -/* deplacement jusqu'a la premiere ligne a ecrire*/ -/*******************************************************/ - - lseek ( num , deplacement , 1 ); - -/***********************************************/ -/* poistion en debut de bandeau a ecrire */ -/***********************************************/ - - buff_lig = data_image; - -/********************************************************/ -/* ecriture des lignes */ -/********************************************************/ - nboct_ecrire = (*nombre_colonnes_ecrire)*nboct_pix* - (*nombre_lignes_ecrire); - - cr_write = write ( num , buff_lig,nboct_ecrire); - - if ( cr_write != nboct_ecrire) - { - strcpy ( CAI_ERREUR , "Erreur ecriture canal image grille\n" ); - goto ERREUR; - } - -return (CAI_OK); - -ERREUR : - -return (CAI_KO); - - -} -/* - Fin de l'operation cai_ecriture_canal_grilles -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ferme_grilles */ -/* ---------- */ -/* */ -/* ROLE : fonction de fermeture d'une image au format gdb ou gdr */ -/* ----- */ -/* Mise a Jour de l'entete si image ouverte en creation */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ferme_grilles(typ_grille,image1) */ -/* ------------------ */ -/* */ -/* typ_grille (E) (char) : type de grille B=Brute, R=rectifiee */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* */ -/* cai_ferme_grilles (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_OK_KO cai_ferme_grilles (char typ_grille,CAI_IMAGE *image1) - -{ - - int iret; /* code retour de l'operation */ - int i_can; /* indice du canal a fermer */ - int num; /* descripteur du fichier a fermer */ - unsigned char *Header; /* entete du fichier gdb */ - int taille_entete; /* taille de l'entete a mettre a jour */ - long pt_oct,tempi; /* position courante ds fichier image */ - int temp,i; /* variable temporaire */ - char *type_image; /* ordre rangement octets dans entete */ - - -/****************************/ -/* Initialisations diverses */ -/****************************/ -iret=CAI_OK; -num=image1->ACCES_CANAL_INT[0]; - -/*--------------------------------------------------*/ -/* Mise a jour de l'entete si ouverture en creation */ -/*--------------------------------------------------*/ - -if (image1->MODE == CAI_ECRITURE) -{ - taille_entete = 46; - Header = (unsigned char *) calloc(taille_entete,sizeof( unsigned char)); - if (Header == NULL) - { - sprintf(CAI_ERREUR, - "Erreur alloc: Mise a jour entete grille impossible\n"); - goto ERREUR; - } - - pt_oct=lseek(num,0L,0); - -/*******************************************************/ -/* ecriture nombre de colonnes */ -/*******************************************************/ - temp = image1->NB_COL; - memcpy(Header,&temp , 4 ); - -/*******************************************************/ -/* ecriture nombre de ligne */ -/*******************************************************/ - temp = image1->NB_LIG; - memcpy(&Header[4],&temp , 4 ); - -/*****************************************************************/ -/* ecriture du type de codage en fonctions de la taille du pixel */ -/* et du codage des Poids Forts, poids faibles */ -/*****************************************************************/ - memcpy(&Header[8],image1->TYPE_COD , 4 ); - - tempi = write ( num,Header , 12 ); - if ( tempi == 0 ) - { - sprintf ( CAI_ERREUR , - "Erreur : MAJ entete a la fermeture impossible ds fichier grille\n"); - goto ERREUR; - } -/***************************************************************/ -/* ecriture du numero de ligne du 1er point de la matrice */ -/***************************************************************/ - temp = image1->NUM_LIG_DEB; - memcpy(Header,&temp , 4 ); - - -/***************************************************************/ -/* ecriture du numero de ligne du 1er point de la matrice */ -/***************************************************************/ - temp = image1->NUM_COL_DEB; - memcpy(&Header[4],&temp , 4 ); - - -/***************************************************************/ -/* ecriture du pas de la grille le long des lignes */ -/***************************************************************/ - temp = image1->PAS_GRIL_LIG; - memcpy(&Header[8],&temp , 4 ); - - -/***************************************************************/ -/* ecriture du pas de la grille le long des colonnes */ -/***************************************************************/ - temp = image1->PAS_GRIL_COL; - memcpy(&Header[12],&temp , 4 ); - - -/***************************************************************/ -/* ecriture du decalage initial le long des lignes */ -/***************************************************************/ - temp = image1->DECAL_LIG; - memcpy(&Header[16],&temp , 4 ); - - -/***************************************************************/ -/* ecriture du decalage initial le long des colonnes */ -/***************************************************************/ - temp = image1->DECAL_COL; - memcpy(&Header[20],&temp , 4 ); - - -/******************************************************************/ -/* ecriture de la caracteristique de la grille si gdr (restituee) */ -/******************************************************************/ - - if (typ_grille == 'R') - { - memcpy(&Header[24],image1->CAR_GRIL, 20 ); - - } - -/***************************************************************/ -/* mise a jour de l'entete ainsi constituee dans le fichier */ -/***************************************************************/ - tempi = write ( num, Header , taille_entete ); - free(Header); - if ( tempi == 0 ) - { - sprintf ( CAI_ERREUR , - "Erreur : MAJ entete a la fermeture impossible ds fichier grille\n"); - goto ERREUR; - } - } -/*............................................. - Fermeture du fichier qui contient tous les canaux - .............................................*/ - if (num>0) close(num); - - return (iret); - -ERREUR: - return(CAI_KO); -} - -/* - Fin de l'operation cai_ferme_grilles -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_dest_ima_grilles */ -/* ---------- */ -/* */ -/* ROLE : fonction de destruction d'une image stocke en gdb ou gdr */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_dest_ima_grilles(typ_grille,repertoire, */ -/* ------------------ nom_ima) */ -/* */ -/* typ_grille (E) (char) : type de grille B=Brute, R=rectifiee */ -/* repertoire (E) (char *) : repertoire de l'image a detruire */ -/* nom_image (E) (char *) : nom de l'image a detruire avec repertoire */ -/* */ -/* cai_dest_ima_grilles (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_OK_KO cai_dest_ima_grilles ( char typ_grille,char *repertoire , - char *nom_ima ) -{ -int i_can; /* compteur de canaux */ -int iret; /* code retour fonction fermetrue lecture */ -char str_num_canal[3]; /* suffixe numero du canal */ -char nom_fic_entete[1024]; /* nom du fichier entete a detruire */ -char nom_ima_complet[1024]; /* repertoire + nom de l'image */ -char nom_fic_canal[1024]; /* nom du fichier canal a detruire */ - -int cr_stat; /* code retour de fonction status de fichier */ -struct stat buf_stat; /* structure decrivant status de fichier */ - -CAI_IMAGE *image1; /* structure ouverture image */ -int nb_can; /* nombre de canaux de l'image */ -int nboct_pix; /* nombre d'octets par pixel image */ -int nb_col; /* nombre de colonnes de l'image */ -int nb_lig; /* nombre de lignes de l'image */ -char extens[5]; /* extension recherchee */ - -/*........................................ - INITIALISATION et ouverture du repertoire choisi - .........................................*/ - extens[0]='\0'; - if (typ_grille=='B') - strcpy(extens,".gdb"); - else - strcpy(extens,".gdr"); - -/************************************************/ -/* Constitution du nom du fichier d'entete */ -/************************************************/ - -if ((long)strlen(repertoire)!=0) -{ - sprintf( nom_ima_complet, "%s/%s" ,repertoire,nom_ima); -} -else -{ - strcpy ( nom_ima_complet , nom_ima); -} - sprintf(nom_fic_entete ,"%s%s", nom_ima_complet,extens); - -/************************************************/ -/* Destruction du fichier d'entete */ -/************************************************/ - -cr_stat = stat ( nom_fic_entete , &buf_stat ); -if ( cr_stat == 0 ) - unlink ( nom_fic_entete ); - - -return (CAI_OK); - -} -/* - Fin de l'operation cai_dest_ima_grilles -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_modifie_grilles */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture-ecriture d'une image au format */ -/* ----- gdb et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_modifie_grilles(typ_grille, */ -/* ---------------- nom_image, */ -/* nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* typ_grille (E) (char) : type de grille B=Brute, R=restituee */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_modifie_grilles (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_IMAGE *cai_ouvre_modifie_grilles(char typ_grille,char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) -{ - FILE *fic_in; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - int iret; /* indicateur de retour ok ou pas */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char nom_fic_canal[1024]; /* nom fichier canal dont on teste existence */ - int nbbit; /* nb de bits par pixel du fichier en-tete */ - int retour; /* retour de la fonction comparaison chaines */ - int i,num; /* indice */ - char type_cod[5]; /* type de codage du pixel */ - int temp; /* zone temporaire de lecture */ - char extens[5]; - char type_image[3]; /* type code+ordre rangement octets dans entete*/ - char *type_machine; /* ordre rangement octets machine de travail */ - char buf[59]; /* buffer contenant entete image */ - int v; /* comparaison type machine-type image */ - char *v1; /* comparaison type image avec chaine vide */ - int nb_col2, nb_lig2; /* variables intermediaires inversion octets */ - int temp2,nb; /* zone temporaire de lecture */ - - /*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - nb=2; - *nb_can=0; - - *nb_lig=0; - - *nb_col=0; - - *nboct_pix=0; - - iret=1; - - - type_machine = (char *) calloc(3,sizeof(char)); - - if (type_machine == NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur allocation memoire dans cai_ouvre_modifie"); - } - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); - -/*****************************************************************************/ -/* MOD : VERSION : 4.1 :FA:Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_modifie"); - } - else - { - extens[0]='\0'; - if (typ_grille == 'B') - strcpy(extens,".gdb"); - else - strcpy(extens,".gdr"); - -/*................................................. - Constitution du nom du fichier entete - .................................................*/ - nom_fic[0]='\0'; - if ((long)strlen(repert)!= 0) - { - sprintf(nom_fic,"%s/%s%s",repert,nom_image,extens); - } - else - { - sprintf(nom_fic,"%s%s",nom_image,extens); - } - -/*........................ - Ouverture du fichier entete - ..........................................*/ -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : modifications fopen binaire pour PC/NT */ -/*****************************************************************************/ - fic_in=fopen(nom_fic,"rb"); - if (fic_in==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur ouverture fichier entete GRILLE"); - } - else - { - - -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : DM : modifications indications Big ou Little Endian */ -/*****************************************************************************/ - - /*.................................. - recuperation infos completes format.gdb - ......................................*/ - - if (typ_grille =='B') - fread(buf,36,1,fic_in); - -/*.................................. - recuperation infos completes format.gdr - ......................................*/ - else fread(buf,56,1,fic_in); - - -/*.................................. - recuperation du type de codage des pixels - ......................................*/ - memcpy(type_cod,&buf[8],4); - - if (strncmp(type_cod,"FLOA",4) ==0) - { - image1->NB_BITS_PIX=32; - image1->NBOCT_PIX=4; - sprintf(image1->COD_PIX,"R4"); - strcpy(type_image,"BE"); - sprintf(image1->TYPE_COD,"FLOA"); - } - - else if (strncmp(type_cod,"FLOL",4) ==0) - { - image1->NB_BITS_PIX=32; - image1->NBOCT_PIX=4; - sprintf(image1->COD_PIX,"R4"); - strcpy(type_image,"LE"); - sprintf(image1->TYPE_COD,"FLOL"); - } - - else - { - iret=0; - sprintf(CAI_ERREUR,"Type de codage GRILLE non reconnu : %s",type_cod); - } - - *nboct_pix = image1->NBOCT_PIX; - -/*.................................. - determination ordre de rangement - des octets sur machine de travail - ......................................*/ - - type_machine = cai_test_pFpf(); - - /*.................................. - determination des autres infos - en fonction inversion - ......................................*/ - - v = strncmp(type_machine,type_image,2); - v1 = strrchr(type_image,'E'); - -/*.................................. - recuperation du nombre de colonne - ......................................*/ - memcpy(nb_col,&buf[0],4); - -/*modification si (type_image et type_machine st differentes) */ -/*et si (type_image existe avec BE ou LE)*/ - - if ( (v!=0) && (v1!=NULL) ) - { - swab( (void*)nb_col, (void*)&nb_col2,4 ); - cai_inverser_tableau((short *)nb_col, (short *)&nb_col2,nb); - } - -/*.................................. - recuperation du nombre de lignes - ......................................*/ - memcpy(nb_lig,&buf[4],4); - -/*modification si (type_image et type_machine st differentes) */ -/*et si (type_image existe avec BE ou LE)*/ - - if ( (v!=0) && (v1!=NULL) ) - { - swab( (void*)nb_lig, (void*)&nb_lig2,4 ); - cai_inverser_tableau((short *)nb_lig, (short *)&nb_lig2,nb); - } -/*..................................................................... - recuperation du numero de ligne du 1er point de la matrice - .....................................................................*/ - - memcpy(&temp,&buf[12],4); - -/*modification si (type_image et type_machine st differentes) */ -/*et si (type_image existe avec BE ou LE)*/ - - if ( (v!=0) && (v1!=NULL) ) - { - swab( (void*)&temp, (void*)&temp2,4 ); - cai_inverser_tableau((short *)&temp,(short *) &temp2,nb); - } - - image1->NUM_LIG_DEB = temp; -/*..................................................................... - recuperation du numero de colonne du 1er point de la matrice - .....................................................................*/ - - memcpy(&temp,&buf[16],4); - -/*modification si (type_image et type_machine st differentes) */ -/*et si (type_image existe avec BE ou LE)*/ - - if ( (v!=0) && (v1!=NULL) ) - { - swab( (void*)&temp, (void*)&temp2,4 ); - cai_inverser_tableau((short *)&temp,(short *) &temp2,nb); - } - - image1->NUM_COL_DEB = temp; - -/*..................................................................... - recuperation du pas de la grille le long des lignes - .....................................................................*/ - - - memcpy(&temp,&buf[20],4); - -/*modification si (type_image et type_machine st differentes) */ -/*et si (type_image existe avec BE ou LE)*/ - - if ( (v!=0) && (v1!=NULL) ) - { - swab( (void*)&temp, (void*)&temp2,4 ); - cai_inverser_tableau((short *)&temp, (short *)&temp2,nb); - } - - image1->PAS_GRIL_LIG = temp; - -/*..................................................................... - recuperation du pas de la grille le long des colonnes - .....................................................................*/ - - - memcpy(&temp,&buf[24],4); - -/*modification si (type_image et type_machine st differentes) */ -/*et si (type_image existe avec BE ou LE)*/ - - if ( (v!=0) && (v1!=NULL) ) - { - swab( (void*)&temp, (void*)&temp2,4 ); - cai_inverser_tableau((short *)&temp,(short *) &temp2,nb); - } - - image1->PAS_GRIL_COL = temp; - -/*..................................................................... - recuperation du decalage initial le long des lignes - .....................................................................*/ - - - memcpy(&temp,&buf[28],4); - -/*modification si (type_image et type_machine st differentes) */ -/*et si (type_image existe avec BE ou LE)*/ - - if ( (v!=0) && (v1!=NULL) ) - { - swab( (void*)&temp, (void*)&temp2,4 ); - cai_inverser_tableau((short *)&temp, (short *)&temp2,nb); - } - - image1->DECAL_LIG = temp; - -/*..................................................................... - recuperation du decalage initial le long des colonnes - .....................................................................*/ - - memcpy(&temp,&buf[32],4); - -/*modification si (type_image et type_machine st differentes) */ -/*et si (type_image existe avec BE ou LE)*/ - - if ( (v!=0) && (v1!=NULL) ) - { - swab( (void*)&temp, (void*)&temp2,4 ); - cai_inverser_tableau((short *)&temp, (short *)&temp2,nb); - } - - image1->DECAL_COL = temp; - -/*..................................................................... - recuperation de la caracteristique de la grille si .gdr -.....................................................................*/ - if (typ_grille == 'R') - { - memcpy(image1->CAR_GRIL,&buf[36],20); - *nb_can = 2; - } - else - *nb_can = 3; - } - -/************************/ -/* fin modifications */ -/************************/ - - -/*.................................. - Fermeture du fichier - ......................................*/ - if (fic_in!=NULL) fclose(fic_in); - - if (iret !=0) - { -/*....................................... - INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL - .....................................................*/ - - nom_fic[0]='\0'; - nom_fic_canal[0]='\0'; - - if ((long)strlen(repert)!= 0) - { - sprintf(nom_fic_canal,"%s/%s%s",repert,nom_image,extens); - } - else - { - sprintf(nom_fic_canal,"%s%s",nom_image,extens); - } - - num=open(nom_fic_canal,O_RDWR|O_BINARY,0); - if (num!= -1) - { - - for (i=0;i<*nb_can;i=i+1) - { - sscanf(nom_image,"%s",image1->NOM_FIC_CAN); - sscanf(nom_image,"%s",image1->NOM_UTIL_CAN); - image1->ACCES_CANAL_INT[i]=num; - image1->POS_OCTET[i]=((i*(*nb_lig))+1)*(*nb_col)*image1->NBOCT_PIX; - } -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : DM : modifications indications Big ou Little Endian */ -/*****************************************************************************/ - - if ( (v!=0) && (v1!=NULL) ) - { - image1->INV_OCTETS =1; - } - else - { - image1->INV_OCTETS =0; - } - -/***********************/ -/* fin modifications */ -/***********************/ - } - else - iret=0; - } - } - if (iret == 0) - { - return (NULL); - } - else - { - return(image1); - } - -} -/* - Fin de l'operation cai_ouvre_modifie_grilles -*/ - - - diff --git a/Utilities/CAI/cai_dll/src/cai_hdf.c b/Utilities/CAI/cai_dll/src/cai_hdf.c deleted file mode 100755 index ae8bff03e6499fac66c41882859c9483e29fe829..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/src/cai_hdf.c +++ /dev/null @@ -1,1779 +0,0 @@ -/*****************************************************************************/ -/* */ -/* PROJET : COUCHE ACCES IMAGE */ -/* ------- */ -/* */ -/* MODULE : cai_hdf16.c */ -/* ------- */ -/* */ -/* ROLE : Ce module rassemble toutes les fonctions d'acces aux images */ -/* ------- stockees au format hdf */ -/* Seuls l'acces aux Scientific Data Set est possible, code en */ -/* 8bits non signes ou 16 bits non signes */ -/* */ -/* AUTEUR : R.CHAISEMARTIN (CISI) */ -/* ------- */ -/* */ -/* DATE DE CREATION : Octobre 1996 */ -/* ----------------- */ -/* */ -/* LANGAGE : C */ -/* -------- */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ -/* MOD : VERSION : 3.3 : DM : optimisation du sous-echantillonnage */ -/*****************************************************************************/ -/* MOD : VERSION : 4.0 : DM : possibilite de traiter des images en R4 et R8 */ -/* flottant simple et double precision */ -/*****************************************************************************/ -/* MOD : VERSION : 4.1 : FA : Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : DM : modifications pour compatibilite HP64bits */ -/*****************************************************************************/ -/* MOD : VERSION : 4.5 : FA : test sur fclose pour PC/LINUX */ -/*****************************************************************************/ -/* MOD : VERSION : 4.8 : FA : pb sur le sous-echantillonnage-prise en compte */ -/* du nombre d'octets par pixel pour ssech en lignes */ -/*****************************************************************************/ -/* MOD : VERSION : 5.0 : DM : Identification ds l'entete des SDS par le nom */ -/* ou par le numero indifferemment. */ -/*****************************************************************************/ -/* MOD : VERSION : 5.0 : DM : Prise en compte images codées I4 en lecture */ -/*****************************************************************************/ -/* MOD : VERSION : 5.0 : DM : Remplacer les appels systemes pour renommer un */ -/* fichier par la commande C rename */ -/*****************************************************************************/ -/* MOD : VERSION : 5.1 : DM : Prise en compte en lecture des images codées en*/ -/* 8, 16 et 32 bits signés */ -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : prise en compte des I2,I4,UI2,UI4 et R8 */ -/* en lecture et ecriture */ -/*****************************************************************************/ - - -/*---------------------------------------------------------------------------*/ -/* Inclusion des fichiers STANDARDS (.h) */ -/*---------------------------------------------------------------------------*/ -# include <stdio.h> -# include <string.h> -# include <unistd.h> -# include <sys/types.h> -# include <dirent.h> -# include <sys/stat.h> -# include <fcntl.h> -# include <errno.h> - -#define _CAI_IMAGE -#define IN_CAI_HDF - -# include "cai_image.h" -# include "hdf.h" -/*# include "mfhdf.h"*/ - -/*----------------------------------------------------------------------------*/ -/* Variable pour la gestion en configuration */ -/*----------------------------------------------------------------------------*/ -static char *rcs_id="$Header: cai_hdf.c,v 1.10 01/05/31 10:47:25 cmf Exp $"; - - -extern char *getenv(); - - -/*****************************************************************************/ -/*****************************************************************************/ -/* */ -/* Definition des OPERATIONS EXTERNES */ -/* */ -/*****************************************************************************/ -/*****************************************************************************/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_liste_ima_hdf16 */ -/* ---------- */ -/* */ -/* ROLE : fonction de listage des images au format hdf */ -/* ------ */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : int cai_liste_ima_hdf16(repert,tab_ima) */ -/* ----------------- */ -/* */ -/* repert (E) (char *) : repertoire a explorer */ -/* tab_ima (S) (char ***) : pointeur sur tableau des images listees */ -/* alloue par la fonction,il doit etre */ -/* LIBERE PAR L'APPELANT */ -/* */ -/* cai_liste_ima_hdf16 (S) (int) : = -1 repertoire inexistant */ /* = > 0 nombre d'images listees */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -long int cai_liste_ima_hdf16 (char *repert, - char ***tab_ima) - -{ - - DIR *dirp; /* pointeur sur structure ouverture repertoire */ - struct dirent *dp; /* structure resultat de la fonction readdir */ - char *pch0,*pch1; /* pointeurs sur chaine de caracteres */ - char car; /* variable de travail */ - int nb_ima; /* nombre d'images hdf identifiees */ - long int i; /* indice de boucle */ - long int ll,dif; /* variables de travail */ - char blanc; /* caractere blanc */ - -/*........................................ - INITIALISATION et ouverture du repertoire choisi - .........................................*/ - nb_ima=0; - dirp=opendir(repert); - blanc = ' '; - - if(dirp!=NULL) - { - - -/*...................................... - - premiere passe pour comptabiliser les images du format donne - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE HDF - (EXTENSION =.hdf) - ..........................................*/ - while((dp=readdir(dirp))!=NULL) - { - pch0=strstr(dp->d_name,".hdf"); - if (pch0 != NULL) - { - ll = (long int)strlen(dp->d_name); - dif = (long int)(dp->d_name-pch0); - dif=labs(dif); - pch1=pch0+4; - -/*****************************************************************************/ -/* MOD:VERSION:3.3:DM lecture de toutes les images dont l'extension commence */ -/* par .hdf. Cette modif permet de prendre en compte .hdf16 */ -/*****************************************************************************/ -/*ligne supprimee if (((ll-4)==dif)||((*pch1)==blanc)) */ - nb_ima=nb_ima+1; - - } - } - (void)closedir(dirp); - -/*..................................... - ALLOCATION DU TABLEAU CONTENANT LA LISTE DES IMAGES DU FORMAT HDF - ......................................*/ - *tab_ima = (char **) calloc(nb_ima,sizeof(char *)); - for (i=0;i<nb_ima;i=i+1) - (*tab_ima)[i]=(char *)calloc(1,100); - -/*...................................... - - deuxieme passe pour constituer la liste des images du format donne - - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE HDF - (EXTENSION =.hdf) - SI C`EST LE CAS,STOCKAGE DANS LA LISTE - ..........................................*/ - dirp=opendir(repert); - - nb_ima=0; - while((dp=readdir(dirp))!=NULL) - { - pch0=strstr(dp->d_name,".hdf"); - if (pch0 != NULL) - { - ll = strlen(dp->d_name); - dif = (long int)(dp->d_name-pch0); - dif=labs(dif); - pch1=pch0+4; -/*****************************************************************************/ -/* MOD:VERSION:3.3:DM lecture de toutes les images dont l'extension commence */ -/* par .hdf. Cette modif permet de prendre en compte .hdf16 */ -/*****************************************************************************/ - -/* ligne supprimee if (((ll-4)==dif)||((*pch1)==blanc)) - {*/ - *pch0='\0'; - strcpy((*tab_ima)[nb_ima],dp->d_name); - nb_ima=nb_ima+1; -/* ligne supprimee }*/ - - } - } - - (void)closedir(dirp); - - } - else - { - /* repertoire inexistant */ - nb_ima=-1; - } - return(nb_ima); - -} - -/* Fin de l'operation cai_liste_ima_hdf16 -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_lecture_hdf16 */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture d'une image au format hdf */ -/* ----- et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_lecture_hdf16 (nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_lecture_hdf16 (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ /* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_IMAGE *cai_ouvre_lecture_hdf16(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) -{ - FILE *fic_in; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char nom_fic_canal[1024]; /* nom fichier canal dont on teste existence*/ - char label[80]; /* contient un enregistrement du fichier */ - int nbbit; /* nb de bits par pixel du fichier en-tete */ - int retour,icr; /* retour de fonctions */ - char *deb,*deb1; /* pointeurs sur chaine de caracteres */ - int num; /* indice */ - int nbplan; /* nombre de canaux dans le fichier en-tete */ - int plan; /* indice de boucle sur les canaux */ - char nom_plan[100]; /* nom des fichiers plan */ - int Ref,lon,Alpha; - int sds_id,status,attribute,num_type,nb_dim; - char name[MAX_NC_NAME]; - int val_dim[MAX_VAR_DIMS]; - int nbdataset,nfileattribut,retn,nbits; - char refSDS[50], sdsname[50]; - int ind,isds; - int sds_trouve; - - /*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - *nb_can=0; - - *nb_lig=0; - - *nb_col=0; - - *nboct_pix=0; - - fic_in = NULL; - - nbplan=0; - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); -/*****************************************************************************/ -/* MOD : VERSION : 4.1: FA Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_lecture"); - goto ERREUR; - } -/*................................................. - Constitution du nom du fichier entete - .................................................*/ - nom_fic[0]='\0'; - if ((long int)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s.hdf",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.hdf",nom_image); - } - -/*........................ - Ouverture du fichier entete - ..........................................*/ - fic_in=NULL; - fic_in=fopen(nom_fic,"r"); - if (fic_in==NULL) - { -/*****************************************************************************/ -/* MOD:VERSION:3.3:DM on essaie avec .hdf16 comme extension (vieille version)*/ -/* Cette modif permet de prendre en compte .hdf16 du QIV */ -/*****************************************************************************/ - strcat(nom_fic,"16"); - fic_in=fopen(nom_fic,"r"); - if (fic_in==NULL) - { - strcpy(CAI_ERREUR,"Erreur ouverture fichier entete HDF"); - goto ERREUR; - } - } -/*................................................ - Pour chaque plan image lecture du nom du fichier correspondant - et de la position du SDS dans le fichier - ..................................................*/ - fgets(label,80,fic_in); - retour=strncmp(label,"PLANES_ID",9); - if (retour!=0) - { - strcpy(CAI_ERREUR, - "Informations incoherentes ligne PLANES_ID "); - goto ERREUR; - } - icr=2; - retour=1; - deb = image1->NOM_FIC_CAN; - deb1= image1->NOM_UTIL_CAN; - - while ((icr==2)&&(retour!=0)) - { - icr = fscanf(fic_in,"%s %s",nom_plan,refSDS); - if (icr==1) - { - Ref=0; - icr=2; - } - retour=strncmp(nom_plan,"NB_BITS_PIX",11); - if ((icr==2)&&(retour!=0)) - { - retour=strncmp(nom_plan,"COMMENT",7); - if ((icr==2)&&(retour!=0)) - { - -/*....................................... - INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL - .....................................................*/ - nom_fic[0]='\0'; - nom_fic_canal[0]='\0'; - - if ((long int)strlen(repert)!=0) - { - sprintf(nom_fic_canal,"%s/%s",repert,nom_plan); - } - else - { - sscanf(nom_plan,"%s",nom_fic_canal); - } -/*....................................... - test sur l'existence du fichier plan - et ouverture du fichier plan - .......................................*/ - num=SDstart(nom_fic_canal,DFACC_RDONLY); - if (num!= -1) - { - sscanf(nom_plan,"%s",deb); - deb=deb+100; - sscanf(nom_plan,"%s",deb1); - deb1=deb1+100; - image1->ACCES_CANAL_INT[nbplan]=num; - -/* Recuperation des informations generales */ -/*.................................................*/ - retn=SDfileinfo(num,&nbdataset,&nfileattribut); -/*****************************************************************************/ -/* MOD : VERSION : 5.0 : DM : Identification ds l'entete des SDS par le nom */ -/* ou par le numero indifferemment. */ -/*****************************************************************************/ -/* Verification si SDS identifie par son nom ou par son numero */ - lon=strlen(refSDS ); - Alpha=0; - for (ind=0;ind<lon;ind++) - { - if (isalpha(refSDS[ind])!=0) Alpha=Alpha+1; - } - if (Alpha !=0) - { -/* Identification par nom de SDS boucle sur les SDS */ -/* pour recuperer le numero de SDS */ - sds_trouve = 0; - isds =0; - while ((isds<nbdataset)&&(sds_trouve==0)) - { - sds_id = SDselect(num,isds); -/* Recuperation des infos du SDS */ - status = SDgetinfo(sds_id,sdsname, - &nb_dim,val_dim, - &num_type,&attribute); - - if ( strcmp ( sdsname, refSDS ) == 0 ) - { - /* recuperer le numero de SD correspondant et repartir sur la version - precedente*/ - Ref=isds; - sds_trouve = 1; - } - else - isds++; - - } - if (sds_trouve == 0) - { - sprintf( CAI_ERREUR ,"Nom de SDS non trouve %s\0",refSDS); - goto ERREUR; - } - } - else - { - Ref=atoi(refSDS); - -/* Selection du Scientific Data Set contenant les donnees */ -/*................................................................*/ - sds_id = SDselect(num,Ref); - status = SDgetinfo(sds_id,sdsname, - &nb_dim,val_dim, - &num_type,&attribute); - } -/*******************************************************/ -/* FIN MOD : VERSION : 5.0 : DM : Identification SDS */ -/*******************************************************/ - image1->POS_OCTET[nbplan]=sds_id; - -/* Verification que tous les plans ont la meme taille */ -/*...........................................................*/ - if (nbplan!=0) - { - if ((*nb_lig!=val_dim[0])||(*nb_col!=val_dim[1])) - { - sprintf( CAI_ERREUR ,"Plans de taille differentes !\0"); - goto ERREUR; - } - } - *nb_lig=val_dim[0]; - *nb_col=val_dim[1]; - nbbit= num_type; - - nbplan=nbplan+1; - - } - else - { - sprintf ( CAI_ERREUR , - "Le fichier plan %s HDF n'existe pas\n" , nom_fic_canal ); - goto ERREUR; - } - } - else - icr=99; - } - } -/*.................................... - Decodage du nombre d'octets par pixel - ......................................*/ - if ((retour==0)&&(icr!=99)) - { - if (icr==2) - image1->NB_BITS_PIX=Ref; - else - image1->NB_BITS_PIX=0; -/*.................................... - Decodage du commentaire - ......................................*/ - icr = fscanf(fic_in,"%s",label); - retour=strncmp(label,"COMMENT",7); - if (retour==0) - icr=99; - } - else - image1->NB_BITS_PIX=0; - - - -/*.................................... - Decodage du commentaire - ......................................*/ - if (icr==99) - icr = fscanf(fic_in,"%s",image1->COMMENT); - else - strcpy(image1->COMMENT,"Pas de commentaire\0"); - -/*...................................*/ -/* Initialisation du nombre de plans */ -/*...................................*/ - *nb_can=nbplan; - -/*.................................. - Initialisation du nombre d'octets par pixel - ........................................................*/ -/*****************************************************************************/ -/* MOD : VERSION : 5.1 : DM : Prise en compte en lecture des images codées en*/ -/* 8, 16 et 32 bits signes */ -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : prise en compte des I2,I4,UI2,UI4 et R8 */ -/* en lecture et ecriture */ -/*****************************************************************************/ - - if (nbbit==DFNT_INT8) - { - *nboct_pix=1; - if (image1->NB_BITS_PIX==0) - image1->NB_BITS_PIX=8; - sprintf(image1->COD_PIX,"OCT"); - } - else if (nbbit==DFNT_UINT8) - { - *nboct_pix=1; - if (image1->NB_BITS_PIX==0) - image1->NB_BITS_PIX=8; - sprintf(image1->COD_PIX,"UOCT"); - - } - else if (nbbit==DFNT_INT16) - { - *nboct_pix=2; - if (image1->NB_BITS_PIX==0) - image1->NB_BITS_PIX=16; - sprintf(image1->COD_PIX,"I2"); - } - else if (nbbit==DFNT_UINT16) - { - *nboct_pix=2; - if (image1->NB_BITS_PIX==0) image1->NB_BITS_PIX=16; - sprintf(image1->COD_PIX,"UI2"); - } - -/* MOD : 5.0 Prise en compte des images codées en I4 non signe*/ - else if (nbbit==DFNT_INT32) - { - *nboct_pix=4; - if (image1->NB_BITS_PIX==0) - image1->NB_BITS_PIX=32; - sprintf(image1->COD_PIX,"I4"); - } - else if (nbbit==DFNT_UINT32) - { - *nboct_pix=4; - if (image1->NB_BITS_PIX==0) - image1->NB_BITS_PIX=32; - sprintf(image1->COD_PIX,"UI4"); - } - else if (nbbit==DFNT_FLOAT) - { - *nboct_pix=4; - if (image1->NB_BITS_PIX==0) - image1->NB_BITS_PIX=32; - sprintf(image1->COD_PIX,"R4"); - - } - else if (nbbit==DFNT_DOUBLE) - { - *nboct_pix=8; - if (image1->NB_BITS_PIX==0) - image1->NB_BITS_PIX=64; - sprintf(image1->COD_PIX,"R8"); - - } - else - { - sprintf ( CAI_ERREUR , - "Type de donnees non supporte par la Couche Acces Image\n" ); - goto ERREUR; - } -/*.................................. - Fermeture du fichier - ......................................*/ - if (fic_in!=NULL) fclose(fic_in); - -/*...................... - sortie normale - ....................*/ - return(image1); - -ERREUR: - -/*...................... - sortie degradee - ....................*/ - if (fic_in!=NULL) fclose(fic_in); - for (plan=0;plan<nbplan;plan++) - { - num=image1->ACCES_CANAL_INT[plan]; - if (num!=-1) retn=SDend(num); - } - return (NULL); - -} - -/* - Fin de l'operation cai_ouvre_lecture_hdf16 -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_creation_hdf16 */ -/* ---------- */ -/* */ -/* ROLE : fonction de creation et d'ouverture en ecriture d'une image */ -/* ----- au format hdf et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_creation_hdf16 (nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig, */ -/* label) */ -/* */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* nb_can (E) (int ) : nombre de canaux de l'image */ -/* nboct_pix (E) (int ) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (E) (int ) : nombre de lignes de l'image */ -/* nb_col (E) (int ) : nombre de colonnes de l'image */ -/* label (E) (char *) : commentaire lie a l'image */ -/* */ -/* cai_ouvre_creation_hdf16 (S) (CAI_IMAGE *) : =NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_IMAGE *cai_ouvre_creation_hdf16(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int * nb_lig, - char *label) - -{ - FILE *fic; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char nom_fic_canal[1024]; /* nom fichier canal dont on teste existence*/ - int retour; /* retour de fonction */ - char car[4]; /* indice du canal traite */ - int num; /* indice */ - struct stat buf_stat; /* structure decrivant status de fichier */ - int plan; /* indice de boucle sur les canaux */ - char nom_plan[100]; /* nom des fichiers plan */ - int dims[2],rank,sds_id; - int nbbit,Ref,Coher; - char NomSDS[80]; - int reconnaissance_type; - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); -/*****************************************************************************/ -/* MOD : VERSION : 4.1: FA Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_creation"); - goto ERREUR; - } - - NomSDS[0]='\0'; - Ref=0; - -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : Maj du TYPE lorsque l'utilisateur le */ -/* precise dans le param "label" */ -/*****************************************************************************/ -/* Verification si type de codage reconnu dans le label */ - reconnaissance_type = cai_istyp_connu(label); - if (reconnaissance_type == -1) - { - if (*nboct_pix==1) - nbbit=DFNT_UINT8; - else if (*nboct_pix==2) - nbbit=DFNT_UINT16; - else if (*nboct_pix==4) - nbbit=DFNT_FLOAT; - else if (*nboct_pix==8) - nbbit=DFNT_DOUBLE; - } - else - { -/* Verification de coherence entre le nb d'octets par pixel et le type donne */ - Coher=1; - if(*nboct_pix == 1) - { - nbbit=DFNT_INT8; - if (reconnaissance_type > 1) Coher=0; - else if (reconnaissance_type ==1) nbbit=DFNT_UINT8; - } - else if(*nboct_pix == 2) - { - if (reconnaissance_type ==2 ) nbbit=DFNT_INT16; - else if (reconnaissance_type ==3 ) nbbit=DFNT_UINT16; - else Coher=0; - } - else if(*nboct_pix == 4) - { - if (reconnaissance_type ==4 ) nbbit=DFNT_INT32; - else if (reconnaissance_type ==5 ) nbbit=DFNT_UINT32; - else if (reconnaissance_type ==6 ) nbbit=DFNT_FLOAT; - else Coher=0; - } - else if(*nboct_pix == 8) - { - if (reconnaissance_type == 7) nbbit=DFNT_DOUBLE; - else Coher = 0; - } - else - Coher = 0; - if (Coher == 0) - { - sprintf(CAI_ERREUR,"incoherence entre TYPE et Nb bits par pixels\n"); - goto ERREUR; - } - } -/*................................................. - Constitution du nom du fichier entete et verification qu'il - n'existe pas deja - .................................................*/ - - nom_fic[0]='\0'; - if ((long int)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s.hdf",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.hdf",nom_image); - } - - retour = stat ( nom_fic , &buf_stat ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "L'image %s HDF existe \n" , nom_image ); - goto ERREUR; - } - -/*...................................................... - Ouverture du fichier entete en ecriture - Ecriture du contenu - ..........................................................*/ - fic = fopen(nom_fic,"w"); - if (fic == NULL) - { - sprintf(CAI_ERREUR,"Erreur: Creation fichier %s impossible\n",nom_fic); - goto ERREUR; - } - - fprintf ( fic , "PLANES_ID\n" ); -/*............................................................... - Pour chaque canal de l'image,constitution du nom de fichier correspondant - Verification qu'il n'existe pas deja - Ouverture du fichier en ecriture - .................................................................*/ - - for (plan=0;plan<*nb_can;plan++) - { - nom_plan[0]='\0'; - nom_fic_canal[0]='\0'; - sprintf(nom_plan,"%s.b%d",nom_image,plan); - fprintf ( fic , "%s %d\n" , nom_plan,Ref ); - if ((long int)strlen(repert)!=0) - { - sprintf(nom_fic_canal,"%s/%s",repert,nom_plan); - - } - else - { - sprintf(nom_fic_canal,"%s",nom_plan); - } - retour = stat ( nom_fic_canal , &buf_stat ); - - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "L'image %s HDF existe \n" , nom_fic_canal ); - goto ERREUR; - } -/* ouverture du fichier */ - num=SDstart(nom_fic_canal,DFACC_CREATE); - if (num == -1) - { - sprintf(CAI_ERREUR,"Erreur: Creation %s impossible\n",nom_fic_canal); - goto ERREUR; - } - image1->ACCES_CANAL_INT[plan]=num; - -/* ouverture et creation du SDS */ - rank=2; - dims[0]=*nb_lig; - dims[1]=*nb_col; - - if((long int)strlen(repert)!=0) - strcpy(NomSDS,label); - else - strcpy(NomSDS,"SDS1"); - - sds_id=SDcreate(num,NomSDS,nbbit,rank,dims); - - image1->POS_OCTET[plan]=sds_id; - } - retour=fprintf ( fic , "NB_BITS_PIX\n"); - retour=fprintf ( fic , "%d\n" , (*nboct_pix)*8 ); - - retour=fprintf ( fic , "COMMENT\n"); - retour=fprintf ( fic , "%s\n" , label ); - if (retour == 0) - { - sprintf(CAI_ERREUR,"Erreur: Ecriture %s impossible\n",nom_fic); - goto ERREUR; - } - -/*************************************************/ -/* Fermeture du fichier */ -/*************************************************/ - - fclose ( fic ); - return (image1); - -ERREUR : - return(NULL); -} - -/* - Fin de l'operation cai_ouvre_creation_hdf16 -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_lecture_canal_hdf16 */ -/* ---------- */ -/* */ -/* ROLE : fonction de lecture d'un canal d'une image hdf */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_lecture_canal_hdf16(image1, canal, */ /* ------------------ premiere_ligne, */ -/* premiere_colonne, */ -/* nombre_lignes_lire , */ -/* nombre_colonnes_lire, */ -/* pas_ligne ,pas_colonne, */ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a lire */ -/* premiere_ligne (E) (int) : premiere ligne a lire dans l'image */ -/* premiere _colonne (E) (int) : premiere colonne a lire dans l'image */ -/* nombre_lignes_lire (E) (int) : nombre de lignes a lire */ -/* nombre_colonnes_lire (E) (int) : nombre de colonnes a lire */ -/* pas_ligne (E) (int) : pas en ligne */ -/* pas_colonne (E) (int) : pas en colonne */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels lus alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_lecture_canal_hdf16 (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - - -CAI_OK_KO cai_lecture_canal_hdf16(CAI_IMAGE *image1 , - int *canal , - int *premiere_ligne , - int *premiere_colonne, - int *nombre_lignes_lire , - int *nombre_colonnes_lire, - int *pas_ligne , - int *pas_colonne, - unsigned char *data_image ) -{ - - int num,n,ilig,k,j; /* variables de travail */ - int iret; /* indicateur d'erreur */ - int edges[2],strides[2],start[2]; - unsigned char *buf,*deb,*pch; - int nboct; - -/*........................... - Initialisations diverses - ..........................*/ - - iret=CAI_OK; - num=image1->POS_OCTET[(*canal)-1]; - - if ((*pas_ligne==1)&&(*pas_colonne==1)) - { - start[0]=(*premiere_ligne)-1; - start[1]=(*premiere_colonne)-1; - edges[0]=*nombre_lignes_lire; - edges[1]=*nombre_colonnes_lire; - strides[0]=*pas_ligne; - strides[1]=*pas_colonne; - n= SDreaddata(num,start,strides,edges,(VOIDP *)data_image); - if (n<0) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Erreur lecture donnee image HDF"); - } - } - else - { - nboct = (*nombre_lignes_lire)*(*pas_ligne)* - (image1->NB_COL)*(image1->NBOCT_PIX); - buf = (unsigned char *) calloc(nboct,sizeof(unsigned char)); -/*........................................... - lecture des lignes images - ................................................*/ - - start[0]=(*premiere_ligne)-1; - start[1]=0; - edges[0]=(((*nombre_lignes_lire)-1)*(*pas_ligne))+1; - edges[1]=image1->NB_COL; - strides[0]=1; - strides[1]=1; - n= SDreaddata(num,start,strides,edges,(VOIDP *)buf); - if (n<0) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Erreur lecture donnee image HDF"); - } - pch=data_image; - -/*...................................... - Sauvegarde des donnees lues entenant compte du pas - d'echantillonnage en colonne - ........................................*/ - for (ilig=0;ilig<*nombre_lignes_lire;ilig++) - { -/*****************************************************************************/ -/* MOD : VERSION : 4.8 : FA : pb sur le sous-echantillonnage-prise en compte */ -/* du nombre d'octets par pixel pour ssech en lignes */ -/*****************************************************************************/ - - deb=buf+((ilig*(image1->NB_COL)*(*pas_ligne))+ - ((*premiere_colonne)-1))*image1->NBOCT_PIX; - j=1; - while (j <= (*nombre_colonnes_lire)) - { - for (k=0;k<image1->NBOCT_PIX;k=k+1) - { - *(pch+k)=*(deb+k); - } - pch=pch+image1->NBOCT_PIX; - j=j+1; - deb=deb+((*pas_colonne)*image1->NBOCT_PIX); - } - } - if (buf!=NULL) free(buf); - } - - return(iret); - } - -/* - Fin de l'operation cai_lecture_canal_hdf16 -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ecriture_canal_hdf16 */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ecriture d'un canal d'une image hdf */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ecriture_canal_hdf16(image1, canal, */ /* ------------------ premiere_ligne, */ -/* nombre_lignes_ecrire, */ -/* nombre_colonnes_ecrire,*/ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a ecrire */ -/* premiere_ligne (E) (int) : premiere ligne a ecrire ds l'image */ -/* nombre_lignes_ecrire (E) (int) : nombre de lignes a ecrire */ -/* nombre_colonnes_ecrire(E) (int) : nombre de lignes a ecrire */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels ecris alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_ecriture_canal_hdf16 (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_OK_KO cai_ecriture_canal_hdf16 (CAI_IMAGE *image1 , - int *canal , - int *premiere_ligne , - int *nombre_lignes_ecrire , - int *nombre_colonnes_ecrire, - unsigned char *data_image ) -{ - -int num,n; /* descripteur de fichier */ -int edges[2],strides[2],start[2]; - - -/* initialisations */ - - num = image1->POS_OCTET[*canal-1]; - start[0]=(*premiere_ligne)-1; - start[1]=0; - edges[0]=*nombre_lignes_ecrire; - edges[1]=*nombre_colonnes_ecrire; - n= SDwritedata(num,start,NULL,edges,(VOIDP *)data_image); - if (n<0) - { - strcpy(CAI_ERREUR,"Erreur lecture donnee image HDF"); - return (CAI_KO); - } - -return (CAI_OK); - -} - -/* - Fin de l'operation cai_ecriture_canal_hdf16 -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ferme_hdf16 */ -/* ---------- */ -/* */ -/* ROLE : fonction de fermeture d'une image au format hdf et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ferme_hdf16(image1) */ /* ------------------ */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* */ -/* cai_ferme_hdf16 (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_OK_KO cai_ferme_hdf16 (CAI_IMAGE *image1) - -{ - int iret; /* code retour de l'operation */ - int i_can; /* indice du canal a fermer */ - int num; /* descripteur du fichier a fermer */ - - iret=CAI_OK; -/*............................................. - Fermeture de tous les canaux - .............................................*/ - for (i_can=0;i_can<image1->NB_CANAUX;i_can=i_can+1) - { - num = image1->POS_OCTET[i_can]; - iret=SDendaccess(num); - num=image1->ACCES_CANAL_INT[i_can]; - iret=SDend(num); - } - return (iret); -} - -/* - Fin de l'operation cai_ferme_hdf16 -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_dest_ima_hdf16 */ -/* ---------- */ -/* */ -/* ROLE : fonction de destruction d'une image stocke en hdf et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_dest_ima_hdf16(format,nom_ima) */ /* ------------------ */ -/* format (E) (char *) : format de l'image a detruire */ -/* nom_image (E) (char *) : nom de l'image a detruire avec repertoire */ -/* */ -/* cai_dest_ima_hdf16 (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - - -CAI_OK_KO cai_dest_ima_hdf16 (char *repertoire , - char *nom_ima ) - -{ -int i_can; /* compteur de canaux */ -long iret; /* code retour fonction fermetrue lecture */ -char str_num_canal[3]; /* suffixe numero du canal */ -char nom_fic_entete[1024]; /* nom du fichier entete a detruire */ -char nom_ima_complet[1024]; /* repertoire + nom de l'image */ -char nom_fic_canal[1024]; /* nom du fichier canal a detruire */ -int cr_stat; /* code retour de fonction status de fichier */ -struct stat buf_stat; /* structure decrivant status de fichier */ -CAI_IMAGE *image1; /* structure ouverture image */ -int nb_can; /* nombre de canaux de l'image */ -int nboct_pix; /* nombre d'octets par pixel image */ -int nb_col; /* nombre de colonnes de l'image */ -int nb_lig; /* nombre de lignes de l'image */ -char ptr_nom_fic_can[100*CAI_NB_MAX_CAN]; /* nom fichier canal traite */ -char nom_fichier[1024]; /* nom du fichier entete a detruire */ -char chemin[1024]; /* repertoire + "/" */ -char *ptr,*deb; - -/************************************************/ -/* Constitution du nom du fichier d'entete */ -/************************************************/ -chemin[0]='\0'; -ptr_nom_fic_can[0]='\0'; - -if ((long int)strlen(repertoire)!=0) -{ - sprintf(nom_ima_complet,"%s/%s",repertoire,nom_ima); - sprintf ( chemin ,"%s/", repertoire ); -} -else -{ - strcpy ( nom_ima_complet , nom_ima); - strcpy ( chemin , "./"); -} - strcpy(nom_fic_entete , nom_ima_complet); - strcat ( nom_fic_entete , ".hdf\0" ); - -/************************************************/ -/* Extraction des caracteristiques de l'image */ -/* et noms des fichiers plans */ -/* du fichier entete par l'appel a la fonction */ -/* cai_ouvre_lecture_image */ -/************************************************/ - image1 = cai_ouvre_lecture_image ( nom_ima_complet,"HDF", &nb_can , - &nboct_pix ,&nb_col, &nb_lig ); - - if ( image1 == NULL) goto ERREUR; - - ptr = ptr_nom_fic_can; - deb = image1->NOM_FIC_CAN; - for ( i_can = 0 ; i_can < nb_can ; i_can++ ) - { - sscanf(deb,"%s",ptr); - deb=deb+100; - ptr=ptr+100; - } - - ptr = ptr_nom_fic_can; - - iret=cai_ferme_image(image1); - image1=NULL; -/************************************************/ -/* Destruction des fichiers radiometrie */ -/************************************************/ - - for ( i_can = 0 ; i_can < nb_can ; i_can++ ) - { - strncpy ( nom_fic_canal , ptr , 100 ); - nom_fic_canal[99] = '\0'; - strcpy ( nom_fichier , chemin ); - strcat ( nom_fichier, nom_fic_canal ); - nom_fichier[strlen(chemin)+strlen(nom_fic_canal)+1] = '\0'; - cr_stat = stat ( nom_fichier , &buf_stat ); - if ( cr_stat == 0 ) - unlink ( nom_fichier ); - ptr = ptr + 100; - } - - -/************************************************/ -/* Destruction du fichier d'entete */ -/************************************************/ -cr_stat = stat ( nom_fic_entete , &buf_stat ); -if ( cr_stat == 0 ) - unlink ( nom_fic_entete ); -else -{ -/*****************************************************************************/ -/* MOD:VERSION:3.3:DM on essaie avec .hdf16 comme extension (vieille version)*/ -/* Cette modif permet de prendre en compte .hdf16 du QIV */ -/*****************************************************************************/ - strcat(nom_fic_entete,"16"); - cr_stat = stat ( nom_fic_entete , &buf_stat ); - if ( cr_stat == 0 ) - unlink ( nom_fic_entete ); -} - -return (CAI_OK); -ERREUR: - return((CAI_OK_KO)NULL); -} -/* - Fin de l'operation cai_dest_ima_hdf16 -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_rename_fichiers_hdf16 */ -/* ---------- */ -/* */ -/* ROLE : permet de modifier l'extension des plans d'une image HDF */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_rename_fichiers_hdf16(image1,TabExtens) */ /* ------------------ */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* TabExtens (E) (CAI_EXTENS *) : tableau des nouvelles extensions */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_OK_KO cai_rename_fichiers_hdf16(CAI_IMAGE *image1,CAI_EXTENS *TabExtens) - -{ - int Can; /* indice de boucle sur les canaux */ - char fichierE[1024]; /* fichier a traiter */ - char fichierS[1024]; /* nouveau nom du fichier */ - FILE *fic; /* pointeur descripteur fichier */ - int pt_oct; /* position courante ds le fichier */ - int *Ref; /* Reference du SDS des fichiers */ - char label[80]; /* contient un enregist fichier */ - char repert[1024]; /* repertoire de stockage image */ - char image[1024]; /* nom de l'image a ouvrir */ - char *pch,*deb; /* pointeurs de travail */ - long nb1,nb2; /* indice de longueur significative*/ - char car; /* variable de travail */ - int icr,tempo; /* code retour fonction */ - CAI_CHAINE *NomIma; - -/* Separation du repertoire de stockage de l'image et du nom propre */ - - repert[0]='\0'; - image[0]='\0'; - car='/'; - pch=(char *)strrchr(image1->NOM_IMAGE,car); - if (pch == NULL) - { - /* le repertoire est celui courant */ - sscanf(image1->NOM_IMAGE,"%s",image); - car='.'; - pch=(char *)strrchr(image,car); - if (pch != NULL) - *pch='\0'; - } - else - { - - nb1=(long int)(pch)-(long int)(image1->NOM_IMAGE); - strncpy(repert,image1->NOM_IMAGE,nb1); - repert[nb1]='\0'; - deb=image1->NOM_IMAGE+nb1+1; - nb2=strlen(image1->NOM_IMAGE)-(nb1+1); - strncpy(image,deb,nb2); - image[nb2]='\0'; - car='.'; - pch=(char *)strrchr(image,car); - if (pch != NULL) - *pch='\0'; - - } - -/* Ouverture du fichier d'entete */ - - fichierE[0]='\0'; - sprintf(fichierE,"%s.hdf",image1->NOM_IMAGE); - fic = fopen(fichierE,"r+"); - if (fic == NULL) - { -/*****************************************************************************/ -/* MOD:VERSION:3.3:DM on essaie avec .hdf16 comme extension (vieille version)*/ -/* Cette modif permet de prendre en compte .hdf16 du QIV */ -/*****************************************************************************/ - strcat(fichierE,"16"); - fic = fopen(fichierE,"r+"); - if (fic == NULL) - { - - sprintf(CAI_ERREUR, - "Erreur: Modification fichier %s impossible\n",fichierE); - goto ERREUR; - } - } - -/* Lecture des references de chaque plan */ - - Ref = (int *) calloc(image1->NB_CANAUX,sizeof(int)); - fgets(label,80,fic); - icr=strncmp(label,"PLANES_ID",9); - if (icr!=0) - { - strcpy(CAI_ERREUR, - "Informations incoherentes ligne PLANES_ID "); - goto ERREUR; - } - -/*................................................*/ -/* Rename de chaque bande spectrale si necessaire */ -/*................................................*/ - NomIma = NULL; - NomIma = (CAI_CHAINE *)calloc(image1->NB_CANAUX,sizeof(CAI_CHAINE)); - if (NomIma == NULL) goto ERREUR; - for(Can=0;Can<image1->NB_CANAUX;Can++) - { - icr = fscanf(fic,"%s%d",label,&tempo); - if (icr==1) - Ref[Can]=0; - else - Ref[Can]=tempo; - if (TabExtens != NULL) - { - fichierE[0]='\0'; - fichierS[0]='\0'; - sprintf(fichierE,"%s/%s",repert,label); - sprintf(fichierS,"%s%s",image1->NOM_IMAGE,TabExtens[Can]); -/*****************************************************************************/ -/* MOD : VERSION : 5.0 : DM : Remplacer les appels systemes pour renommer un */ -/* fichier par la commande C rename */ -/*****************************************************************************/ - rename(fichierE,fichierS); - } - else - { - strcpy(NomIma[Can],label); - } - } - -/* Modification du fichier d'entete */ - rewind(fic); - fprintf ( fic , "PLANES_ID\n" ); - for(Can=0;Can<image1->NB_CANAUX;Can++) - { - tempo=Ref[Can]; - if (TabExtens != NULL) - fprintf ( fic , "%s%s %d\n",image,TabExtens[Can],tempo); - else - fprintf ( fic , "%s %d\n",NomIma[Can],tempo); - - - } - fprintf ( fic , "NB_BITS_PIX\n"); - fprintf ( fic , "%d\n" , image1->NB_BITS_PIX ); - - icr=fprintf ( fic , "COMMENT\n"); - icr=fprintf ( fic , "%s\n" , image1->COMMENT ); - - fclose ( fic ); - - if (NomIma != NULL) free(NomIma); - - return(CAI_OK); - -ERREUR : - return(CAI_KO); -} -/* - Fin de l'operation cai_rename_fichiers_hdf16 -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_modifie_hdf16 */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture-ecriture d'une image au format */ -/* ----- hdf et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_modifie_hdf16 (nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_modifie_hdf16 (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ /* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_IMAGE *cai_ouvre_modifie_hdf16(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) - -{ - FILE *fic_in; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char nom_fic_canal[1024]; /* nom fichier canal dont on teste existence*/ - char label[80]; /* contient un enregistrement du fichier */ - int nbbit; /* nb de bits par pixel du fichier en-tete */ - int retour,icr; /* retour de fonctions */ - char *deb,*deb1; /* pointeurs sur chaine de caracteres */ - int num; /* indice */ - int nbplan; /* nombre de canaux dans le fichier en-tete */ - int plan; /* indice de boucle sur les canaux */ - char nom_plan[100]; /* nom des fichiers plan */ - int Ref; - int sds_id,status,attribute,num_type,nb_dim; - char name[MAX_NC_NAME]; - int val_dim[MAX_VAR_DIMS]; - int nbdataset,nfileattribut,retn,nbits; - - /*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - *nb_can=0; - - *nb_lig=0; - - *nb_col=0; - - *nboct_pix=0; - - fic_in = NULL; - - nbplan=0; - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); -/*****************************************************************************/ -/* MOD : VERSION : 4.1: FA Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_modifie"); - goto ERREUR; - } - -/*................................................. - Constitution du nom du fichier entete - .................................................*/ - nom_fic[0]='\0'; - if ((long int)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s.hdf",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.hdf",nom_image); - } - -/*........................ - Ouverture du fichier entete - ..........................................*/ - fic_in=fopen(nom_fic,"r"); - if (fic_in==NULL) - { -/*****************************************************************************/ -/* MOD:VERSION:3.3:DM on essaie avec .hdf16 comme extension (vieille version)*/ -/* Cette modif permet de prendre en compte .hdf16 du QIV */ -/*****************************************************************************/ - strcat(nom_fic,"16"); - fic_in=fopen(nom_fic,"r"); - if (fic_in==NULL) - { - strcpy(CAI_ERREUR,"Erreur ouverture fichier entete HDF"); - goto ERREUR; - } - } - -/*................................................ - Pour chaque plan image lecture du nom du fichier correspondant - et de la position du SDS dans le fichier - ..................................................*/ - fgets(label,80,fic_in); - retour=strncmp(label,"PLANES_ID",9); - if (retour!=0) - { - strcpy(CAI_ERREUR, - "Informations incoherentes ligne PLANES_ID "); - goto ERREUR; - } - icr=2; - retour=1; - deb = image1->NOM_FIC_CAN; - deb1= image1->NOM_UTIL_CAN; - - while ((icr==2)&&(retour!=0)) - { - icr = fscanf(fic_in,"%s%d",nom_plan,&Ref); - if (icr==1) - { - Ref=0; - icr=2; - } - retour=strncmp(nom_plan,"NB_BITS_PIX",11); - if ((icr==2)&&(retour!=0)) - { - retour=strncmp(nom_plan,"COMMENT",7); - if ((icr==2)&&(retour!=0)) - { - -/*....................................... - INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL - .....................................................*/ - nom_fic[0]='\0'; - nom_fic_canal[0]='\0'; - - if ((long int)strlen(repert)!=0) - { - sprintf(nom_fic_canal,"%s/%s",repert,nom_plan); - } - else - { - sscanf(nom_plan,"%s",nom_fic_canal); - } -/*....................................... - test sur l'existence du fichier plan - et ouverture du fichier plan - .......................................*/ - num=SDstart(nom_fic_canal,DFACC_RDWR); - if (num!= -1) - { - sscanf(nom_plan,"%s",deb); - deb=deb+100; - sscanf(nom_plan,"%s",deb1); - deb1=deb1+100; - image1->ACCES_CANAL_INT[nbplan]=num; - -/* Recuperation des informations generales */ -/*.................................................*/ - retn=SDfileinfo(num,&nbdataset,&nfileattribut); - -/* Selection du Scientific Data Set contenant les donnees */ -/*................................................................*/ - sds_id = SDselect(num,Ref); - image1->POS_OCTET[nbplan]=sds_id; - -/* Recherche des attributs (taille, nb oct pix) */ -/*......................................................*/ - - status = SDgetinfo(sds_id,name,&nb_dim,val_dim, - &num_type,&attribute); - -/* Verification que tous les plans ont la meme taille */ -/*...........................................................*/ - if (nbplan!=0) - { - if ((*nb_lig!=val_dim[0])||(*nb_col!=val_dim[1])) - { - sprintf( CAI_ERREUR ,"Plans de taille differentes !\0"); - goto ERREUR; - } - } - *nb_lig=val_dim[0]; - *nb_col=val_dim[1]; - nbbit= num_type; - - nbplan=nbplan+1; - - } - else - { - sprintf ( CAI_ERREUR , - "Le fichier plan %s HDF n'existe pas\n" , nom_fic_canal ); - goto ERREUR; - } - } - else - icr=99; - } - } -/*.................................... - Decodage du nombre d'octets par pixel - ......................................*/ - if ((retour==0)&&(icr!=99)) - { - if (icr==2) - image1->NB_BITS_PIX=Ref; - else - image1->NB_BITS_PIX=0; -/*.................................... - Decodage du commentaire - ......................................*/ - icr = fscanf(fic_in,"%s",label); - retour=strncmp(label,"COMMENT",7); - if (retour==0) - icr=99; - } - else - image1->NB_BITS_PIX=0; - - - -/*.................................... - Decodage du commentaire - ......................................*/ - if (icr==99) - icr = fscanf(fic_in,"%s",image1->COMMENT); - else - strcpy(image1->COMMENT,"Pas de commentaire\0"); - -/*...................................*/ -/* Initialisation du nombre de plans */ -/*...................................*/ - *nb_can=nbplan; - -/*.................................. - Initialisation du nombre d'octets par pixel - ........................................................*/ -/* MOD : VERSION : 5.2 : DM : prise en compte des I2,I4,UI2,UI4 et R8 */ -/* en lecture et ecriture */ -/*****************************************************************************/ - - if (nbbit==DFNT_INT8) - { - *nboct_pix=1; - if (image1->NB_BITS_PIX==0) - image1->NB_BITS_PIX=8; - sprintf(image1->COD_PIX,"OCT"); - } - else if (nbbit==DFNT_UINT8) - { - *nboct_pix=1; - if (image1->NB_BITS_PIX==0) - image1->NB_BITS_PIX=8; - sprintf(image1->COD_PIX,"UOCT"); - - } - else if (nbbit==DFNT_INT16) - { - *nboct_pix=2; - if (image1->NB_BITS_PIX==0) - image1->NB_BITS_PIX=16; - sprintf(image1->COD_PIX,"I2"); - } - else if (nbbit==DFNT_UINT16) - { - *nboct_pix=2; - if (image1->NB_BITS_PIX==0) - image1->NB_BITS_PIX=16; - sprintf(image1->COD_PIX,"UI2"); - } - -/* MOD : 5.0 Prise en compte des images codées en I4 non signe*/ - else if (nbbit==DFNT_INT32) - { - *nboct_pix=4; - if (image1->NB_BITS_PIX==0) - image1->NB_BITS_PIX=32; - sprintf(image1->COD_PIX,"I4"); - } - else if (nbbit==DFNT_UINT32) - { - *nboct_pix=4; - if (image1->NB_BITS_PIX==0) - image1->NB_BITS_PIX=32; - sprintf(image1->COD_PIX,"UI4"); - } - else if (nbbit==DFNT_FLOAT) - { - *nboct_pix=4; - if (image1->NB_BITS_PIX==0) - image1->NB_BITS_PIX=32; - sprintf(image1->COD_PIX,"R4"); - - } - else if (nbbit==DFNT_DOUBLE) - { - *nboct_pix=8; - if (image1->NB_BITS_PIX==0) - image1->NB_BITS_PIX=64; - sprintf(image1->COD_PIX,"R8"); - - } - else - { - sprintf ( CAI_ERREUR , - "Type de donnees non supporte par la Couche Acces Image\n" ); - goto ERREUR; - } - - /*.................................. - Fermeture du fichier - ......................................*/ - if (fic_in!=NULL) fclose(fic_in); - -/*...................... - sortie normale - ....................*/ - return(image1); - -ERREUR: - -/*...................... - sortie degradee - ....................*/ - if (fic_in!=NULL) fclose(fic_in); - for (plan=0;plan<nbplan;plan++) - { - num=image1->ACCES_CANAL_INT[plan]; - if (num!=-1) retn=SDend(num); - } - return (NULL); - -} -/* - Fin de l'operation cai_ouvre_modifie_hdf16 -*/ - diff --git a/Utilities/CAI/cai_dll/src/cai_inria.c b/Utilities/CAI/cai_dll/src/cai_inria.c deleted file mode 100755 index 79e85bd2fc527e1d4131646d300ea12200a03f41..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/src/cai_inria.c +++ /dev/null @@ -1,1529 +0,0 @@ -/*****************************************************************************/ -/* */ -/* PROJET : COUCHE ACCES IMAGE */ -/* ------- */ -/* */ -/* MODULE : cai_inria.c */ -/* ------- */ -/* */ -/* ROLE : Ce module rassemble toutes les fonctions d'acces aux images */ -/* ------- stockees au format inria */ -/* */ -/* AUTEUR : R.CHAISEMARTIN (CISI) */ -/* ------- */ -/* */ -/* DATE DE CREATION : fevrier 1995 */ -/* ----------------- */ -/* */ -/* LANGAGE : C */ -/* -------- */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ -/* MOD : VERSION : 3.3 : DM:optimisation des acces */ -/*****************************************************************************/ -/* MOD : VERSION : 4.0 : DM: integration du module ouverture en modification*/ -/*****************************************************************************/ -/* MOD : VERSION : 4.1 :FA: Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : FA : verification que l'image est codee sur un ou 2 */ -/*octets par pixel (contrainte du format) */ -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : DM : modifications pour compatibilite HP64bits */ -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : modifications fopen binaire pour PC/NT */ -/*****************************************************************************/ -/* MOD : VERSION : 4.4 : DM : modifications open binaire pour PC/NT */ -/*****************************************************************************/ -/* MOD : VERSION : 4.5 : FA : test sur fclose pour PC/LINUX */ -/*****************************************************************************/ -/* MOD : VERSION : 4.6 : FA: Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : FA: Correction "PIXSIZE= %d bits\n" au lieu de */ -/* "PIXSIZE= bits\n" dans ouvre_creation */ -/*****************************************************************************/ - - -/*---------------------------------------------------------------------------*/ -/* Inclusion des fichiers STANDARDS (.h) */ -/*---------------------------------------------------------------------------*/ - - -# include <stdio.h> -# include <string.h> -# include <unistd.h> -# include <sys/types.h> -#include <dirent.h> -# include <sys/stat.h> -# include <fcntl.h> -# include <malloc.h> - -#define _CAI_IMAGE -#define IN_CAI_INRIA - -# include "cai_image.h" - -/*----------------------------------------------------------------------------*/ -/* Variable pour la gestion en configuration */ -/*----------------------------------------------------------------------------*/ -static char *rcs_id="$Header: cai_inria.c,v 1.13 01/05/31 10:47:04 cmf Exp $"; - -extern char *getenv(); - -/*****************************************************************************/ -/*****************************************************************************/ -/* */ -/* Definition des OPERATIONS EXTERNES */ -/* */ -/*****************************************************************************/ -/*****************************************************************************/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_liste_ima_inria */ -/* ---------- */ -/* */ -/* ROLE : fonction de listage des images au format inria */ -/* ------ */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : int cai_liste_ima_inria(repert,tab_ima) */ -/* ----------------- */ -/* */ -/* repert (E) (char *) : repertoire a explorer */ -/* tab_ima (S) (char ***) : pointeur sur tableau images listees */ -/* alloue par la fonction,il doit etre */ -/* LIBERE PAR L'APPELANT */ -/* */ -/* cai_liste_ima_inria (S) (int) : = -1 repertoire inexistant */ /* = > 0 nombre d'images listees */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - - -long int cai_liste_ima_inria(char *repert, - char ***tab_ima) - -{ - DIR *dirp; /* pointeur sur structure ouverture repertoire */ - -struct dirent *dp; /* structure resultat de la fonction readdir */ - char *pch0,*pch1; /* pointeurs sur chaine de caracteres */ - char *pch2; /* pointeurs sur chaine de caracteres */ - char car; /* variable de travail */ - int nb_ima; /* nombre d'images inria identifiees */ - int i; /* indice de boucle */ - char nom_prec[100]; /* contient le nom du dernier fichier inria vu */ - char pch3[100]; /* permet le transfert du nom de fichier trouve*/ - -/*........................................ - initialisation et ouverture du repertoire - .........................................*/ - - nb_ima=0; - - dirp=opendir(repert); - - if(dirp!=NULL) - { - - -/*...................................... - premiere passe pour comptabiliser les images du format donne - - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE INRIA - (EXTENSION =.xs) - ..........................................*/ - - strcpy(nom_prec,"11"); - - while((dp=readdir(dirp))!=NULL) - { - car='.'; - pch0=strrchr(dp->d_name,car); - if (pch0 != NULL) - { - car='x'; - pch1=strrchr(dp->d_name,car); - if ((pch1 != NULL)&&(pch1==pch0+1)) - { - car='s'; - pch2=strrchr(dp->d_name,car); - if ((pch2 != NULL)&&(pch2==pch1+1)) - { - *pch0='\0'; - *pch1=' '; - *pch2=' '; - pch2=pch2+1; - *pch2=' '; - pch2=pch2+1; - *pch2=' '; - pch2=pch2+1; - *pch2='\0'; - strcpy(pch3,dp->d_name); - i=strcmp(nom_prec,pch3); - if (i!=0) - { - strcpy(nom_prec,pch3); - nb_ima=nb_ima+1; - - } - } - - } - } - } - - (void)closedir(dirp); -/*..................................... - ALLOCATION DU TABLEAU CONTENANT LA LISTE DES IMAGES DU FORMAT INRIA - ......................................*/ - *tab_ima = (char **) calloc(nb_ima,sizeof(char *)); - for (i=0;i<nb_ima;i=i+1) - (*tab_ima)[i]=(char *)calloc(1,100); - -/*...................................... - - deuxieme passe pour constituer la liste des images du format donne - - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE INRIA - (EXTENSION =.xs) - SI C'EST LE CAS STOCKAGE DE L'IMAGE DANS LA LISTE DES IMAGES INRIA - ..........................................*/ - dirp=opendir(repert); - - nb_ima=0; - - strcpy(nom_prec,"11"); - - while((dp=readdir(dirp))!=NULL) - { - car='.'; - pch0=strrchr(dp->d_name,car); - if (pch0 != NULL) - { - car='x'; - pch1=strrchr(dp->d_name,car); - if ((pch1 != NULL)&&(pch1==pch0+1)) - { - car='s'; - pch2=strrchr(dp->d_name,car); - if ((pch2 != NULL)&&(pch2==pch1+1)) - { - *pch0='\0'; - *pch1=' '; - *pch2=' '; - pch2=pch2+1; - *pch2=' '; - pch2=pch2+1; - *pch2=' '; - pch2=pch2+1; - *pch2='\0'; - strcpy(pch3,dp->d_name); - i=strcmp(nom_prec,pch3); - if (i!=0) - { - strcpy(nom_prec,pch3); - strcpy((*tab_ima)[nb_ima],dp->d_name); - nb_ima=nb_ima+1; - - } - } - - } - } - } - (void)closedir(dirp); - - } - else - { - nb_ima=-1; - } - - return(nb_ima); - -} -/* Fin de l'operation cai_liste_ima_inria -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_lecture_inria */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture d'une image au format inria */ -/* ----- et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_lecture_inria (nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_lecture_inria (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ /* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_IMAGE *cai_ouvre_lecture_inria(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) -{ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - long iret,k,n; /* indicateur de retour ok ou pas */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char nom_fic_canal[1024]; /* nom du fichier canal a ouvrir */ - char *deb,*deb1; /* pointeurs sur chaine de caracteres */ - char car[3]; /* indice du canal traite */ - int i,num; /* indice */ - char *buf_lec ; /* buffer lecture entete inria */ - int nb_bits; /* nombre de bits par pixels */ - char str_no; /* variable de lecture */ - short int n1; /* variable de travail de lecture */ - - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - - *nb_lig=0; - *nb_col=0; - *nboct_pix=0; - *nb_can=0; - - iret=1; - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); -/*****************************************************************************/ -/* MOD : VERSION : 4.6: FA Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_lecture"); - } - else - { - -/*....................................... - INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL et ouverture - de ces fichiers - Recherche du nombre de canaux de l'image - .....................................................*/ - - deb = image1->NOM_FIC_CAN; - deb1= image1->NOM_UTIL_CAN; - - nom_fic[0]='\0'; - if ((long int)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s.xs",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.xs",nom_image); - } - - for (i=0;i<50;i=i+1) - { - nom_fic_canal[0]='\0'; - sscanf(nom_fic,"%s",nom_fic_canal); - sprintf(car,"%d",i); - strcat(nom_fic_canal,car); - num=open(nom_fic_canal,O_RDONLY|O_BINARY,0); - - if (num != -1) - { - - if (*nb_can<CAI_NB_MAX_CAN) - { - sscanf(nom_image,"%s",deb); - strcat(deb,".xs"); - strcat(deb,car); - deb=deb+100; - sscanf(nom_image,"%s",deb1); - strcat(deb1,".xs"); - strcat(deb1,car); - deb1=deb1+100; - image1->ACCES_CANAL_INT[*nb_can]=num; - *nb_can=*nb_can+1; - - - } - - } - } - if ((*nb_can) == 0) - { - iret = 0; - } - else - { -/*................................... - Lecture du fichier entete - ............................................*/ - - buf_lec=(char *) calloc(256,sizeof(char)); - if (buf_lec==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur allocation memoire dans cai_ouvre_lecture"); - } - else - { - - num=image1->ACCES_CANAL_INT[0]; - - k=read(num,buf_lec,256); - if (k!=256) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur lecture entete Inria"); - } - else - { -/*................................. - Decodage de l'enregistrement (nouveu format inria) - .........................................*/ - if (buf_lec[10]=='4') - { - - sscanf(&buf_lec[19],"%4d",nb_col); - sscanf(&buf_lec[29],"%4d",nb_lig); - sscanf(&buf_lec[78],"%2d",&nb_bits); - - /* le nombre recupere represente le nombre de */ - /* bits ou le nombre d'octets codant un pixel */ - /* cette information est transmise via le */ - /* parametre nboct_pix inutilise sur SUN */ - if ( (nb_bits==8) || (nb_bits==16) ) - *nboct_pix = nb_bits/8; - else if ( (nb_bits==1) || (nb_bits==2) ) - *nboct_pix = nb_bits; - image1->NB_BITS_PIX= nb_bits; - for (i=0;i<*nb_can;i=i+1) - { - image1->POS_OCTET[i]=1024; - } - } - else - { -/*................................. - Decodage de l'enregistrement (ancien format inria) - .........................................*/ - - lseek(num,0L,0); - n=read(num,(char*)&n1,2); - if (n<=0) - { - iret=0; - strcpy(CAI_ERREUR, - "Erreur lecture entete inria"); - } - *nb_col=(int)n1; - - n=read(num,(char*)&n1,2); - if (n<=0) - { - iret=0; - strcpy(CAI_ERREUR, - "Erreur lecture entete inria"); - } - *nb_lig=(int)n1; - - n=read(num,&str_no,1); - if (n<=0) - { - iret=0; - strcpy(CAI_ERREUR, - "Erreur lecture entete inria"); - } - nb_bits = (int)str_no; - - /* le nombre recupere represente le nombre de */ - /* bits ou le nombre d'octets codant un pixel */ - /* cette information est transmise via le */ - /* parametre nboct_pix inutilise sur SUN */ - if ( (nb_bits==8) || (nb_bits==16) ) - *nboct_pix = nb_bits/8; - else if ( (nb_bits==1) || (nb_bits==2) ) - *nboct_pix = nb_bits; - - for (i=0;i<*nb_can;i=i+1) - { - image1->POS_OCTET[i]=256; - } - } - if (*nboct_pix ==1) - sprintf(image1->COD_PIX,"OCT"); - else - sprintf(image1->COD_PIX,"I2"); - } - free(buf_lec); - } - } - } - if (iret == 0) - { - return (NULL); - } - else - { - return (image1); - } - -} - -/* - Fin de l'operation cai_ouvre_lecture_inria -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_creation_inria */ -/* ---------- */ -/* */ -/* ROLE : fonction de creation et d'ouverture en ecriture d'une image */ -/* ----- au format inria et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_creation_inria (nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig, */ -/* label) */ -/* */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* nb_can (E) (int ) : nombre de canaux de l'image */ -/* nboct_pix (E) (int ) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (E) (int ) : nombre de lignes de l'image */ -/* nb_col (E) (int ) : nombre de colonnes de l'image */ -/* label (E) (char *) : commentaire lie a l'image */ -/* */ -/* cai_ouvre_creation_inria (S) (CAI_IMAGE *) : =NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - - -CAI_IMAGE *cai_ouvre_creation_inria(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig, - char *label) - -{ - FILE *fic; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char nom_fic_canal[1024]; /* nom fichier canal dont on teste existence*/ - int retour; /* retour de fonction */ - char car[2]; /* indice du canal traite */ - int i,num; /* indice */ - struct stat buf_stat; /* structure decrivant status de fichier */ - int i_oct,remplissage; /* variables de travail */ - -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : FA : verification que l'image est codee sur un ou 2 */ -/*octets par pixel (contrainte du format) */ -/*****************************************************************************/ - if ((*nboct_pix != 1)&&(*nboct_pix != 2)) - { - image1 = NULL; - sprintf ( CAI_ERREUR , - "Une image INRIA ne peutetre codee que sur un ou 2 octets par pixel"); - goto ERREUR; - } - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - image1 = NULL; - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); -/*****************************************************************************/ -/* MOD : VERSION : 4.1 : FA:Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_creation"); - goto ERREUR; - } - -/*************************************************/ -/* constitution du nom des fichiers a ecrire */ -/* - si un canal : image.xs0 */ -/* - si +sieurs canaux : image.xsi avec i=1->99 */ -/* et insertion dans les tableaux */ -/*************************************************/ - -/*************************************************/ -/* SI l'image est panchromatique */ -/*************************************************/ - if (* nb_can == 1 ) - { -/*************************************************/ -/* constitution du nom du fichier avec */ -/* l'extension .xs0 verif existence */ -/*************************************************/ - - nom_fic_canal[0]='\0'; - if ((long int)strlen(repert)!=0) - { - sprintf(nom_fic_canal,"%s/%s.xs0",repert,nom_image); - } - else - { - sprintf(nom_fic_canal,"%s.xs0",nom_image); - } - - retour = stat ( nom_fic_canal , &buf_stat ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "L'image %s INRIA existe \n" , nom_image ); - goto ERREUR; - } - -/*************************************************/ -/* ecriture de l'entete dans le fichier */ -/* l'extension .xs0 */ -/*************************************************/ -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : modifications fopen binaire pour PC/NT */ -/*****************************************************************************/ - fic = fopen(nom_fic_canal,"wb"); - if (fic == NULL) - { - sprintf(CAI_ERREUR,"Erreur: Creation %s impossible\n",nom_fic_canal); - goto ERREUR; - } - retour= fprintf ( fic , "#INRIMAGE-4#{\n" ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "Erreur : ecriture impossible dans fichier %s\n", - nom_fic_canal ); - goto ERREUR; - } - - fprintf ( fic , "XDIM=%-4d\n" , *nb_col); - fprintf ( fic , "YDIM=%-4d\n" , *nb_lig ); - fprintf ( fic , "ZDIM=%-2d\n" , 1 ); - fprintf ( fic , "VDIM=%-2d\n" , 1 ); - fprintf ( fic , "TYPE=unsigned fixed\n" ); -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : FA: Correction "PIXSIZE= %d bits\n" au lieu de */ -/* "PIXSIZE= bits\n" dans ouvre_creation */ -/*****************************************************************************/ - - fprintf ( fic , "PIXSIZE= %d bits\n" , (*nboct_pix)*8 ); - if (*nboct_pix == 1) - { - fprintf ( fic , "SCALE=1**0\n" ); - remplissage = 916; - } - else - { - fprintf ( fic , "SCALE=2**16\n" ); - remplissage = 915; - } - fprintf ( fic , "CPU=sun\n" ); - for ( i_oct = 0 ; i_oct < remplissage ; i_oct++ ) - { - fprintf ( fic , "\n" ); - } - fprintf ( fic , "##}\n" ); - if (fic!=NULL) fclose(fic); - -/*************************************************/ -/* ouverture pour ecriture radiometrie */ -/*************************************************/ - - num = open(nom_fic_canal,O_RDWR|O_BINARY,0); - if (num == -1) - { - sprintf(CAI_ERREUR,"Erreur: Creation %s impossible\n",nom_fic_canal); - goto ERREUR; - } - image1->ACCES_CANAL_INT[0]=num; - image1->POS_OCTET[0]=1024; - } - -/*************************************************/ -/* SINON */ -/*************************************************/ - else - { -/*************************************************/ -/* POUR chacun des canaux */ -/*************************************************/ - for ( i= 0 ; i < *nb_can ; i=i+1) - { -/**************************************************/ -/* constitution du nom du fichier extension .xsi */ -/**************************************************/ - nom_fic[0]='\0'; - if ((long int)strlen(repert)!=0) - { - sprintf(nom_fic_canal,"%s/%s.xs%d",repert,nom_image,i+1); - } - else - { - sprintf(nom_fic_canal,"%s.xs%d",nom_image,i+1); - } - - retour = stat ( nom_fic_canal , &buf_stat ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "L'image %s INRIA existe \n" , nom_image ); - goto ERREUR; - } - -/*************************************************/ -/* ecriture de l'entete dans le fichier */ -/* l'extension .xsi+1 */ -/*************************************************/ -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : modifications fopen binaire pour PC/NT */ -/*****************************************************************************/ - fic = fopen(nom_fic_canal,"wb"); - if (fic == NULL) - { - sprintf(CAI_ERREUR,"Erreur: Creation %s impossible\n",nom_fic_canal); - goto ERREUR; - } - retour= fprintf ( fic , "#INRIMAGE-4#{\n" ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "Erreur : ecriture impossible dans fichier %s\n", - nom_fic_canal ); - goto ERREUR; - } - - fprintf ( fic , "XDIM=%-4d\n" , *nb_col); - fprintf ( fic , "YDIM=%-4d\n" , *nb_lig ); - fprintf ( fic , "ZDIM=%-2d\n" , 1 ); - fprintf ( fic , "VDIM=%-2d\n" , 1 ); - fprintf ( fic , "TYPE=unsigned fixed\n" ); - fprintf ( fic , "PIXSIZE=%d bits\n" , (*nboct_pix)*8 ); - if (*nboct_pix == 1) - { - fprintf ( fic , "SCALE=1**0\n" ); - remplissage = 916; - } - else - { - fprintf ( fic , "SCALE=2**16\n" ); - remplissage = 915; - } - fprintf ( fic , "CPU=sun\n" ); - for ( i_oct = 0 ; i_oct < remplissage ; i_oct++ ) - { - fprintf ( fic , "\n" ); - } - fprintf ( fic , "##}\n" ); - fclose(fic); - -/*************************************************/ -/* ouverture pour ecriture radiometrie */ -/*************************************************/ - num = open(nom_fic_canal,O_RDWR|O_BINARY,0); - if (num == -1) - { - sprintf(CAI_ERREUR,"Erreur: Creation %s impossible\n",nom_fic_canal); - goto ERREUR; - } - image1->ACCES_CANAL_INT[i]=num; - image1->POS_OCTET[i]=1024; - } - } - - return (image1); - -ERREUR : - if (image1 !=NULL) free(image1); - return(NULL); -} -/* - Fin de l'operation cai_ouvre_creation_inria -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_lecture_canal_inria */ -/* ---------- */ -/* */ -/* ROLE : fonction de lecture d'un canal d'une image inria */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_lecture_canal_inria(image1, canal, */ /* ------------------ premiere_ligne, */ -/* premiere_colonne, */ -/* nombre_lignes_lire , */ -/* nombre_colonnes_lire, */ -/* pas_ligne ,pas_colonne, */ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a lire */ -/* premiere_ligne (E) (int) : premiere ligne a lire dans l'image */ -/* premiere _colonne (E) (int) : premiere colonne a lire dans l'image */ -/* nombre_lignes_lire (E) (int) : nombre de lignes a lire */ -/* nombre_colonnes_lire (E) (int) : nombre de colonnes a lire */ -/* pas_ligne (E) (int) : pas en ligne */ -/* pas_colonne (E) (int) : pas en colonne */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels lus alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_lecture_canal_inria (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_OK_KO cai_lecture_canal_inria(CAI_IMAGE *image1 , - int *canal , - int *premiere_ligne , - int *premiere_colonne, - int *nombre_lignes_lire , - int *nombre_colonnes_lire, - int *pas_ligne , - int *pas_colonne, - unsigned char *data_image ) -{ - - int num,i,j; /* variables de travail */ - long pt_oct,n; /* position courante dans le fichier image */ - long no_oct; /* numero du premier octet a lire */ - long iret,k; /* indicateur d'erreur */ - int lig; /* indice de boucle sur les lignes */ - int oct_pix; /* nb octets par pixels */ - long nb_oct; /* nb oct =1er octet a lire - position courante */ - long oct_lig; /* nb oct. par ligne en considerant taille pixel */ - unsigned char *buf_lec; /* buffer lecture d'une ligne */ - unsigned char *deb,*pch; /* pointeur chaine pour transfert buffer sortie */ - - -/*........................... - Initialisations diverses - ..........................*/ - - iret=CAI_OK; - num=image1->ACCES_CANAL_INT[*canal-1]; - oct_pix=image1->NBOCT_PIX; - oct_lig=oct_pix*image1->NB_COL; - -/*.......................................*/ -/* verification si lecture image entiere */ -/*.......................................*/ - if ((*nombre_lignes_lire==image1->NB_LIG)&&(*nombre_colonnes_lire==image1->NB_COL) - &&(*pas_ligne==1)&&(*pas_colonne==1)) - { - oct_lig=oct_pix*(image1->NB_COL)*(image1->NB_LIG); - - /* positionnement en debut de fichier */ - pt_oct=(long int)lseek(num,0L,0); - - /* lecture du canal complet */ - n=read(num,data_image,oct_lig); - if (n<=0) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Erreur lecture donnee image INRIA"); - } - else - iret=CAI_OK; - } - else - { - -/*.............................................. - allocation de memoire pour lire une ligne image - ............................................. */ - - buf_lec = (unsigned char *) calloc(oct_lig,sizeof(unsigned char)); - if (buf_lec == NULL) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Probleme allocation memoire"); - } - else - { -/*.................... - Initialisation - ......................*/ - lig=*premiere_ligne; - i=1; - pch=data_image; - -/*..................... - Pour chaque ligne a lire - .......................................*/ - while ((i <= *nombre_lignes_lire)&&(iret==CAI_OK)) - { -/*............................................ - Recherche de la position courante dans le fichier - ............................................*/ - pt_oct=lseek(num,0L,1); - -/*................................ - Calcul du numero du 1er octet a lire - ....................................*/ - no_oct=image1->POS_OCTET[*canal-1]+((lig-1)*oct_lig); - -/*.................................. - Saut d'octets pour etre positionne sur la ligne a lire - .......................................*/ - nb_oct=(long)(no_oct-pt_oct); - lseek(num,nb_oct,1); - -/*........................................... - lecture d'une ligne image - ................................................*/ - n=read(num,buf_lec,oct_lig); - if (n<=0) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Erreur lecture donnee image INRIA"); - } - else - { -/*...................................... - Sauvegarde des donnees lues entenant compte du pas - d'echantillonnage en colonne - ........................................*/ - deb=buf_lec+((*premiere_colonne)-1)*oct_pix; - j=1; - while (j <= *nombre_colonnes_lire) - { - for (k=0;k<oct_pix;k=k+1) - { - *(pch+k)=*(deb+k); - } - j=j+1; - deb=deb+((*pas_colonne)*oct_pix); - pch=pch+oct_pix; - } - - } - i=i+1; - lig=lig+(*pas_ligne); - - } - - free(buf_lec); - } - } - - return(iret); -} - -/* - Fin de l'operation cai_lecture_canal_inria -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ecriture_canal_inria */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ecriture d'un canal d'une image inria */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ecriture_canal_inria(image1, canal, */ /* ------------------ premiere_ligne, */ -/* nombre_lignes_ecrire, */ -/* nombre_colonnes_ecrire,*/ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a ecrire */ -/* premiere_ligne (E) (int) : premiere ligne a ecrire ds l'image */ -/* nombre_lignes_ecrire (E) (int) : nombre de lignes a ecrire */ -/* nombre_colonnes_ecrire(E) (int) : nombre de lignes a ecrire */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels ecris alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_ecriture_canal_inria (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_OK_KO cai_ecriture_canal_inria (CAI_IMAGE *image1 , - int *canal , - int *premiere_ligne , - int *nombre_lignes_ecrire , - int *nombre_colonnes_ecrire, - unsigned char *data_image ) -{ -long position_first_lig; /* position de la 1ere ligne a ecrire */ -long position_courante; /* position courante dans le fichier */ -long deplacement; /* deplacement a effectuer */ -int i_ligne; /* compteur de lignes */ -unsigned char *buff_lig; /* tableau contenant une ligne a ecrire */ -long cr_write; /* code retour de write */ -int num; /* descripteur de fichier */ -int nboct_pix; /* nombre d'octets par pixel */ -int tot_pix; /* nb de pixels total a ecrire */ - -/* initialisations */ - -i_ligne = 0; -num = image1->ACCES_CANAL_INT[*canal-1]; -nboct_pix = image1->NBOCT_PIX; - -/*.......................................*/ -/* verification si ecriture image entiere */ -/*.......................................*/ - if ((*nombre_lignes_ecrire==image1->NB_LIG)&& - (*nombre_colonnes_ecrire==image1->NB_COL)) - { - tot_pix=nboct_pix*(image1->NB_COL)*(image1->NB_LIG); - - /* positionnement en debut de fichier */ - position_first_lig=lseek(num,0L,0); - - /* ecriture du canal complet */ - cr_write = write ( num , data_image,tot_pix); - if (cr_write != nboct_pix) - { - strcpy(CAI_ERREUR,"Erreur ecriture donnee image INRIA"); - goto ERREUR; - } - } - else - { - - -/********************************************************/ -/* Calcul de la position de la premiere ligne a ecrire */ -/********************************************************/ - -position_first_lig = - (long) ( image1->POS_OCTET[*canal-1] + - ((*premiere_ligne) - 1) *(*nombre_colonnes_ecrire) * nboct_pix ); - - -/********************************************************/ -/* Recuperation de la position courante */ -/********************************************************/ - -position_courante = lseek ( num , 0L , 1 ); - - -/********************************************************/ -/* Deplacement jusqu'a la premiere ligne a ecrire */ -/********************************************************/ - -deplacement = position_first_lig - position_courante; -lseek ( num , deplacement , 1 ); - - -/********************************************************/ -/* TANT QUE il y a des lignes a ecrire */ -/********************************************************/ -while (i_ligne < (*nombre_lignes_ecrire)) -{ - -/********************************************************/ -/* extraction de la ligne du tableau */ -/********************************************************/ - - buff_lig = data_image +(*nombre_colonnes_ecrire) * nboct_pix * i_ligne; - -/********************************************************/ -/* ecriture de la ligne */ -/********************************************************/ - - cr_write = write ( num , buff_lig ,(*nombre_colonnes_ecrire) * nboct_pix ); - if ( cr_write !=(*nombre_colonnes_ecrire) * nboct_pix ) - { - strcpy ( CAI_ERREUR , "Erreur ecriture canal image inria\n" ); - goto ERREUR; - } - -/********************************************************/ -/* incrementation du nombre de lignes */ -/********************************************************/ - - i_ligne++; - -/********************************************************/ -/* FIN TANT QUE */ -/********************************************************/ - } -} - - -return (CAI_OK); - -ERREUR : - -return (CAI_KO); - - -} - -/* - Fin de l'operation cai_ecriture_canal_inria -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ferme_inria */ -/* ---------- */ -/* */ -/* ROLE : fonction de fermeture d'une image au format inria et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ferme_inria(image1) */ /* ------------------ */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* */ -/* cai_ferme_inria (S) (CAI_OK_KO) : = CA_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - - -CAI_OK_KO cai_ferme_inria (CAI_IMAGE *image1) - - -{ - int iret; /* code retour de l'operation */ - int i_can; /* indice du canal a fermer */ - int num; /* descripteur du fichier a fermer */ - - - iret=CAI_OK; -/*............................................. - Fermeture des fichiers image - .............................................*/ - for (i_can=0;i_can<image1->NB_CANAUX;i_can=i_can+1) - { - num=image1->ACCES_CANAL_INT[i_can]; - if (num>0) close(num); - } - - return (iret); -} - - -/* - Fin de l'operation cai_ferme_inria -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_dest_ima_inria */ -/* ---------- */ -/* */ -/* ROLE : fonction de destruction d'une image stocke en inria et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_dest_ima_inria(format,nom_ima) */ /* ------------------ */ -/* format (E) (char *) : format de l'image a detruire */ -/* nom_image (E) (char *) : nom de l'image a detruire avec repertoire */ -/* */ -/* cai_dest_ima_inria (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - - -CAI_OK_KO cai_dest_ima_inria ( char *repertoire , - char *nom_ima ) - -{ -int i_can; /* compteur de canaux */ -long iret; /* code retour fonction fermetrue lecture */ -char str_num_canal[3]; /* suffixe numero du canal */ -char nom_fic[1024]; /* nom du fichier entete a detruire */ -char nom_ima_complet[1024]; /* repertoire + nom de l'image */ -char nom_fic_canal[1024]; /* nom du fichier canal a detruire */ - -int cr_stat; /* code retour de fonction status de fichier */ -struct stat buf_stat; /* structure decrivant status de fichier */ - -CAI_IMAGE *image1; /* structure ouverture image */ -int nb_can; /* nombre de canaux de l'image */ -int nboct_pix; /* nombre d'octets par pixel image */ -int nb_col; /* nombre de colonnes de l'image */ -int nb_lig; /* nombre de lignes de l'image */ - -/************************************************/ -/* Constitution du nom du fichier d'entete */ -/************************************************/ -if ((long int)strlen(repertoire)!= 0) -{ - sprintf ( nom_ima_complet, "%s/%s",repertoire,nom_ima ); - -} -else -{ - strcpy ( nom_ima_complet , nom_ima); -} -sprintf(nom_fic ,"%s.xs", nom_ima_complet); - -/************************************************/ -/* Extraction des caracteristiques de l'image */ -/* du fichier entete par l'appel a la fonction */ -/* cai_ouvre_lecture_inria */ -/************************************************/ - image1 = cai_ouvre_lecture_inria ( repertoire,nom_ima, &nb_can ,&nboct_pix , - &nb_col , &nb_lig ); - if ( image1 == NULL) goto ERREUR; - - image1->NB_CANAUX=nb_can; - image1->NB_COL=nb_col; - image1->NB_LIG=nb_lig; - image1->NBOCT_PIX=nboct_pix; - - iret=cai_ferme_inria(image1); - - image1 = NULL; - -/************************************************/ -/* Recherche de tous les fichiers au nom */ -/* de l'image comportant une extension */ -/*.xsi avec i = 0 -> nb_can et destruction */ -/************************************************/ - -for ( i_can = 0 ; i_can < nb_can+1 ; i_can++ ) -{ - nom_fic_canal[0] = '\0'; - sscanf ( nom_fic , "%s" , nom_fic_canal ); - sprintf ( str_num_canal , "%d" , i_can ); - strcat ( nom_fic_canal , str_num_canal ); - nom_fic_canal[strlen(nom_ima_complet)+3+strlen(str_num_canal)]='\0'; - - cr_stat = stat ( nom_fic_canal , &buf_stat ); - if ( cr_stat == 0 ) - { - /* le fichier existe => destruction */ - unlink ( nom_fic_canal ); - } -} - - - -return (CAI_OK); - -ERREUR : - -return (CAI_KO); - - -} -/* - Fin de l'operation cai_dest_ima_inria -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_modifie_inria */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture-ecriture d'une image au format */ -/* ----- inria et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_modifie_inria (nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_modifie_inria (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ /* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_IMAGE *cai_ouvre_modifie_inria(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) -{ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - int iret; /* indicateur de retour ok ou pas */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char nom_fic_canal[1024]; /* nom du fichier canal a ouvrir */ - char *deb,*deb1; /* pointeurs sur chaine de caracteres */ - char car[3]; /* indice du canal traite */ - int i,num; /* indice */ - char *buf_lec ; /* buffer lecture entete inria */ - int nb_bits; /* nombre de bits par pixels */ - char str_no; /* variable de lecture */ - short int n1; /* variable de travail de lecture */ - long k,n; - - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - - *nb_lig=0; - *nb_col=0; - *nboct_pix=0; - *nb_can=0; - - iret=1; - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); -/*****************************************************************************/ -/* MOD : VERSION : 4.1: FA Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur allocation memoire dans cai_ouvre_modifie"); - } - else - { -/*....................................... - INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL et ouverture - de ces fichiers - Recherche du nombre de canaux de l'image - .....................................................*/ - - deb = image1->NOM_FIC_CAN; - deb1= image1->NOM_UTIL_CAN; - - nom_fic[0]='\0'; - if ((long int)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s.xs",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.xs",nom_image); - } - - for (i=0;i<50;i=i+1) - { - nom_fic_canal[0]='\0'; - sscanf(nom_fic,"%s",nom_fic_canal); - sprintf(car,"%d",i); - strcat(nom_fic_canal,car); - num=open(nom_fic_canal,O_RDWR|O_BINARY,0); - - - if (num != -1) - { - - if (*nb_can<100) - { - sscanf(nom_image,"%s",deb); - strcat(deb,".xs"); - strcat(deb,car); - deb=deb+100; - - - sscanf(nom_image,"%s",deb1); - strcat(deb1,".xs"); - strcat(deb1,car); - deb1=deb1+100; - image1->ACCES_CANAL_INT[*nb_can]=num; - *nb_can=*nb_can+1; - } - - } - } - - if ((*nb_can) == 0) - { - iret = 0; - } - else - { -/*................................... - Lecture du fichier entete - ............................................*/ - - buf_lec=(char *) calloc(256,sizeof(char)); - if (buf_lec==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur allocation memoire dans cai_ouvre_modifie"); - } - else - { - - num=image1->ACCES_CANAL_INT[0]; - - k=read(num,buf_lec,256); - if (k!=256) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur lecture entete Inria"); - } - else - { - -/*................................. - Decodage de l'enregistrement (nouveu format inria) - .........................................*/ - if (buf_lec[10]=='4') - { - - sscanf(&buf_lec[19],"%4d",nb_col); - sscanf(&buf_lec[29],"%4d",nb_lig); - sscanf(&buf_lec[78],"%2d",&nb_bits); - - /* le nombre recupere represente le nombre de */ - /* bits ou le nombre d'octets codant un pixel */ - /* cette information est transmise via le */ - /* parametre nboct_pix inutilise sur SUN */ - if ( (nb_bits==8) || (nb_bits==16) ) - *nboct_pix = nb_bits/8; - else if ( (nb_bits==1) || (nb_bits==2) ) - *nboct_pix = nb_bits; - image1->NB_BITS_PIX= nb_bits; - for (i=0;i<*nb_can;i=i+1) - { - image1->POS_OCTET[i]=1024; - } - } - else - { -/*................................. - Decodage de l'enregistrement (ancien format inria) - .........................................*/ - - lseek(num,0L,0); - n=read(num,(char*)&n1,2); - if (n<=0) - { - iret=0; - strcpy(CAI_ERREUR, - "Erreur lecture entete inria"); - } - *nb_col=(int)n1; - - n=read(num,(char*)&n1,2); - if (n<=0) - { - iret=0; - strcpy(CAI_ERREUR, - "Erreur lecture entete inria"); - } - *nb_lig=(int)n1; - - n=read(num,&str_no,1); - if (n<=0) - { - iret=0; - strcpy(CAI_ERREUR, - "Erreur lecture entete inria"); - } - nb_bits = (int)str_no; - - /* le nombre recupere represente le nombre de */ - /* bits ou le nombre d'octets codant un pixel */ - /* cette information est transmise via le */ - /* parametre nboct_pix inutilise sur SUN */ - if ( (nb_bits==8) || (nb_bits==16) ) - *nboct_pix = nb_bits/8; - else if ( (nb_bits==1) || (nb_bits==2) ) - *nboct_pix = nb_bits; - - for (i=0;i<*nb_can;i=i+1) - { - image1->POS_OCTET[i]=256; - } - } - if (*nboct_pix ==1) - sprintf(image1->COD_PIX,"OCT"); - else - sprintf(image1->COD_PIX,"I2"); - } - free(buf_lec); - } - } - } - - if (iret == 0) - { - return (NULL); - } - else - { - return (image1); - } - -} -/* - Fin de l'operation cai_ouvre_modifie_inria -*/ - diff --git a/Utilities/CAI/cai_dll/src/cai_jpeg.c b/Utilities/CAI/cai_dll/src/cai_jpeg.c deleted file mode 100755 index ef2176cbd067a636d437f7f356a4faed9404657a..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/src/cai_jpeg.c +++ /dev/null @@ -1,1008 +0,0 @@ -/*****************************************************************************/ -/* */ -/* PROJET : COUCHE ACCES IMAGE */ -/* ------- */ -/* */ -/* MODULE : cai_jpeg.c */ -/* ------- */ -/* */ -/* ROLE : Ce module rassemble toutes les fonctions d'acces aux images */ -/* ------- stockees au format jpeg */ -/* */ -/* AUTEUR : R.CHAISEMARTIN (CISI) */ -/* ------- */ -/* */ -/* DATE DE CREATION : Octobre 1998 */ -/* ----------------- */ -/* */ -/* LANGAGE : C */ -/* -------- */ -/* */ -/* VERSION : V4.0 */ -/* -------- */ -/* */ -/*****************************************************************************/ -/* MOD : VERSION :2 : DM :optimisation */ -/*****************************************************************************/ -/* MOD : VERSION : 4.1 :FA:Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ -/* MOD : VERSION : 4.2 :FA:Verification que le nombre d'octets par pixel est */ -/* egal a 1 et le nombre de canaux est 1 ou 3. jpeg est un format de */ -/* restitution */ -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : DM : modifications pour compatibilite HP64bits */ -/*****************************************************************************/ -/* MOD : VERSION : 4.5 : FA : test sur fclose pour PC/LINUX */ -/*****************************************************************************/ -/* MOD : VERSION : 4.8 : FA : modifiation fermeture avant decompression */ -/*****************************************************************************/ - -/*---------------------------------------------------------------------------*/ -/* Inclusion des fichiers STANDARDS (.h) */ -/*---------------------------------------------------------------------------*/ - - -# include <stdio.h> -# include <string.h> -# include <stdlib.h> -# include <unistd.h> -# include <sys/types.h> -# include <dirent.h> -# include <sys/stat.h> -# include <fcntl.h> - -#define _CAI_IMAGE -#define IN_CAI_JPEG - -# include "cai_image.h" - -/*----------------------------------------------------------------------------*/ -/* Variable pour la gestion en configuration */ -/*----------------------------------------------------------------------------*/ -static char *rcs_id="$Header: cai_jpeg.c,v 1.4 01/05/31 10:47:32 cmf Exp $"; - - -extern char *getenv(); - - -/*****************************************************************************/ -/*****************************************************************************/ -/* */ -/* Definition des OPERATIONS EXTERNES */ -/* */ -/*****************************************************************************/ -/*****************************************************************************/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_liste_ima_jpeg */ -/* ---------- */ -/* */ -/* ROLE : fonction de listage des images au format jpeg */ -/* ------ */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : int cai_liste_ima_jpeg(repert,tab_ima) */ -/* ----------------- */ -/* */ -/* repert (E) (char *) : repertoire a explorer */ -/* tab_ima (S) (char ***) : pointeur sur tableau des images listees */ -/* alloue par la fonction,il doit etre */ -/* LIBERE PAR L'APPELANT */ -/* */ -/* cai_liste_ima_jpeg (S) (int) : = -1 repertoire inexistant */ /* = > 0 nombre d'images listees */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -long int cai_liste_ima_jpeg (char *repert, - char ***tab_ima) - - -{ - - DIR *dirp; /* pointeur sur structure ouverture repertoire */ - struct dirent *dp; /* structure resultat de la fonction readdir */ - char *pch0,*pch1; /* pointeurs sur chaine de caracteres */ - int nb_ima; /* nombre d'images jpeg identifiees */ - long int i; /* indice de boucle */ - long int ll,dif; /* variables de travail */ - char blanc; /* caractere blanc */ - - -/*........................................ - INITIALISATION et ouverture du repertoire choisi - .........................................*/ - nb_ima=0; - dirp=opendir(repert); - blanc = ' '; - - if(dirp!=NULL) - { - - -/*...................................... - - premiere passe pour comptabiliser les images du format donne - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE JPEG - (EXTENSION =.jpg) - ..........................................*/ - while((dp=readdir(dirp))!=NULL) - { - pch0=strstr(dp->d_name,".jpg"); - if (pch0 != NULL) - { - ll = strlen(dp->d_name); - dif = (long)(dp->d_name-pch0); - dif=labs(dif); - pch1=pch0+4; - if (((ll-4)==dif)||((*pch1)==blanc)) - nb_ima=nb_ima+1; - - } - } - - (void)closedir(dirp); - -/*..................................... - ALLOCATION DU TABLEAU CONTENANT LA LISTE DES IMAGES DU FORMAT JPEG - ......................................*/ - *tab_ima = (char **) calloc(nb_ima,sizeof(char *)); - for (i=0;i<nb_ima;i=i+1) - (*tab_ima)[i]=(char *)calloc(1,100); - -/*...................................... - - deuxieme passe pour constituer la liste des images du format donne - - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE JPEG - (EXTENSION =.jpeg) - SI C`EST LE CAS,STOCKAGE DANS LA LISTE - ..........................................*/ - dirp=opendir(repert); - - nb_ima=0; - while((dp=readdir(dirp))!=NULL) - { - pch0=strstr(dp->d_name,".jpg"); - if (pch0 != NULL) - { - ll = strlen(dp->d_name); - dif = (long)(dp->d_name-pch0); - dif=labs(dif); - pch1=pch0+4; - if (((ll-4)==dif)||((*pch1)==blanc)) - { - *pch0='\0'; - strcpy((*tab_ima)[nb_ima],dp->d_name); - nb_ima=nb_ima+1; - } - - } - } - - (void)closedir(dirp); - - - } - else - { - /* repertoire inexistant */ - nb_ima=-1; - } - return(nb_ima); - -} - -/* Fin de l'operation cai_liste_ima_jpeg -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_lecture_jpeg */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture d'une image au format jpeg */ -/* ----- et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_lecture_jpeg (nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_lecture_jpeg (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ /* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_IMAGE *cai_ouvre_lecture_jpeg(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) - -{ - FILE *fic_in; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - int iret; /* indicateur de retour ok ou pas */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char nom_fic_canal[1024]; /* nom fichier canal dont on teste existence*/ - char label[80]; /* contient un enregistrement du fichier */ - int nbbit; /* nb de bits par pixel du fichier en-tete */ - int retour; /* retour de la fonction comparaison chaines*/ - char *deb,*deb1; /* pointeurs sur chaine de caracteres */ - int i,num; /* indice */ - int nbplan; /* nombre de canaux dans le fichier en-tete */ - char COD_PIX[80]; /* type de codage du pixel (optionnel) */ - struct jpeg_decompress_struct *cinfo; - static struct jpeg_error_mgr jerr; - - - /*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - *nb_can=0; - - *nb_lig=0; - - *nb_col=0; - - *nboct_pix=0; - - iret=1; - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); - cinfo = (struct jpeg_decompress_struct *)calloc(1, - sizeof(struct jpeg_decompress_struct)); -/*****************************************************************************/ -/* MOD : VERSION : 4.1 :FA:Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if ((image1==NULL)||(cinfo==NULL)) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur allocation memoire dans cai_ouvre_lecture"); - } - else - { - -/*................................................. - Constitution du nom du fichier entete - .................................................*/ - nom_fic[0]='\0'; - if((long int)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s.jpg",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.jpg",nom_image); - } - -/*........................ - Ouverture du fichier entete - ..........................................*/ - fic_in=NULL; - fic_in=fopen(nom_fic,"rb"); - if (fic_in==NULL) - { - iret=0; - sprintf(CAI_ERREUR,"Erreur ouverture fichier entete JPEG %s",nom_fic); - free(cinfo); - cinfo = NULL; - image1->ACCES_CANAL_JPEG_LEC=cinfo; - } - else - { - cinfo->err=jpeg_std_error(&jerr); - jpeg_create_decompress(cinfo); - - jpeg_stdio_src(cinfo,fic_in); - (void) jpeg_read_header(cinfo,TRUE); - jpeg_start_decompress(cinfo); - - *nb_can = cinfo->num_components; - *nb_lig = cinfo->image_height; - *nb_col = cinfo->image_width; - *nboct_pix = 1; - sprintf(image1->COD_PIX,"OCT"); - image1->ACCES_CANAL_JPEG_LEC=cinfo; - image1->ACCES_FILE_JPEG=fic_in; - image1->POS_OCTET[0]=CAI_JPEG_LECTURE; - - } - -/*....................................... - INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL - .....................................................*/ - - nom_fic[0]='\0'; - nom_fic_canal[0]='\0'; - - if((long int)strlen(repert)!=0) - { - sprintf(nom_fic_canal,"%s/%s.jpg",repert,nom_image); - } - else - { - sprintf(nom_fic_canal,"%s.jpg",nom_image); - } - - deb = image1->NOM_FIC_CAN; - deb1= image1->NOM_UTIL_CAN; - for (i=0;i<*nb_can;i=i+1) - { - sscanf(nom_image,"%s",deb); - deb=deb+100; - sscanf(nom_image,"%s",deb1); - deb1=deb1+100; - image1->POS_OCTET[i]=0; - } - } - if (iret == 0) - { - return (NULL); - } - else - { - return(image1); - } - -} - -/* - Fin de l'operation cai_ouvre_lecture_jpeg -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_creation_jpeg */ -/* ---------- */ -/* */ -/* ROLE : fonction de creation et d'ouverture en ecriture d'une image */ -/* ----- au format jpeg et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_creation_jpeg (nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig, */ -/* label) */ -/* */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* nb_can (E) (int ) : nombre de canaux de l'image */ -/* nboct_pix (E) (int ) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (E) (int ) : nombre de lignes de l'image */ -/* nb_col (E) (int ) : nombre de colonnes de l'image */ -/* label (E) (char *) : commentaire lie a l'image */ -/* */ -/* cai_ouvre_creation_jpeg (S) (CAI_IMAGE *) : =NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_IMAGE *cai_ouvre_creation_jpeg(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig, - char *label) - -{ - FILE *fic; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char nom_fic_canal[1024]; /* nom fichier canal dont on teste existence*/ - int retour; /* retour de fonction */ - int i,nboctet; /* indice */ - struct stat buf_stat; /* structure decrivant status de fichier */ - struct jpeg_compress_struct *cinfo; - static struct jpeg_error_mgr jerr; -/*****************************************************************************/ -/* MOD : VERSION : 4.2 :FA:Verification que le nombre d'octets par pixel est */ -/* egal a 1 et le nombre de canaux est 1 ou 3. jpeg est un format de */ -/* restitution */ -/*****************************************************************************/ -/* Verification sur le nombre d'octets par pixel */ - - if (*nboct_pix !=1) - { - strcpy(CAI_ERREUR,"Erreur une image jpeg ne peut etre codee que sur un seul octet"); - goto ERREUR; - } - -/* Verification sur le nombre de canaux */ - if ((*nb_can !=1)&&(*nb_can !=3)) - { - strcpy(CAI_ERREUR,"Erreur une image jpeg a 1 ou 3 canaux exclusivement"); - goto ERREUR; - } - - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); -/*****************************************************************************/ -/* MOD : VERSION : 4.1 :FA:Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_creation"); - goto ERREUR; - } - -/*................................................. - Constitution du nom du fichier et verification qu'il - n'existe pas deja - .................................................*/ - - nom_fic[0]='\0'; - if((long int)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s.jpg",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.jpg",nom_image); - } - - retour = stat ( nom_fic , &buf_stat ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "L'image %s JPEG existe \n" , nom_image ); - goto ERREUR; - } - -/* allocation du tableau contenant l'image entiere */ - nboctet = (*nb_col)*(*nb_lig)*(*nb_can); - image1->image_JPEG = (JSAMPLE *) calloc(nboctet,sizeof(JSAMPLE)); - if (image1->image_JPEG==NULL) - { - sprintf(CAI_ERREUR,"Erreur allocation memoire image JPEG"); - goto ERREUR; - } - -/*............................................................... - Ouverture du fichier en ecriture avec allocation de la structure - .................................................................*/ - cinfo = (struct jpeg_compress_struct *)calloc(1, - sizeof(struct jpeg_compress_struct)); - if (cinfo==NULL) - { - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_creation"); - goto ERREUR; - } - - cinfo->err=jpeg_std_error(&jerr); -/* Now we can initialize the JPEG compression object. */ - jpeg_create_compress(cinfo); - - fic = fopen(nom_fic,"wb"); - if (fic == NULL) - { - sprintf(CAI_ERREUR,"Erreur: Creation fichier %s impossible\n",nom_fic); - goto ERREUR; - } - image1->ACCES_FILE_JPEG = fic;; - - jpeg_stdio_dest(cinfo, fic); - - /* set parameters for compression */ - - /* First we supply a description of the input image. - * Four fields of the cinfo struct must be filled in: - */ - cinfo->image_width = *nb_col; - cinfo->image_height = *nb_lig; - cinfo->input_components = *nb_can; /* # of color components per pixel */ - if (*nb_can==1) - cinfo->in_color_space = JCS_GRAYSCALE; - else - cinfo->in_color_space = JCS_RGB; /* colorspace of input image */ - - /* Now use the library's routine to set default compression parameters. - * (You must set at least cinfo.in_color_space before calling this, - * since the defaults depend on the source color space.) - */ - jpeg_set_defaults(cinfo); - - /* Now you can set any non-default parameters you wish to. - * Here we just illustrate the use of quality (quantization table) scaling: - */ - jpeg_set_quality(cinfo, 90, TRUE /* limit to baseline-JPEG values */); - - /* Start compressor */ - - /* TRUE ensures that we will write a complete interchange-JPEG file. - * Pass TRUE unless you are very sure of what you're doing. - */ - jpeg_start_compress(cinfo, TRUE); - - image1->ACCES_CANAL_JPEG_ECR = cinfo; - - image1->POS_OCTET[0]=CAI_JPEG_ECRITURE; - image1->NBOCT_PIX = 1; - - return (image1); - -ERREUR : - return(NULL); -} - -/* - Fin de l'operation cai_ouvre_creation_jpeg -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_lecture_canal_jpeg */ -/* ---------- */ -/* */ -/* ROLE : fonction de lecture d'un canal d'une image jpeg */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_lecture_canal_jpeg(image1, canal, */ /* ------------------ premiere_ligne, */ -/* premiere_colonne, */ -/* nombre_lignes_lire , */ -/* nombre_colonnes_lire, */ -/* pas_ligne ,pas_colonne, */ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a lire */ -/* premiere_ligne (E) (int) : premiere ligne a lire dans l'image */ -/* premiere _colonne (E) (int) : premiere colonne a lire dans l'image */ -/* nombre_lignes_lire (E) (int) : nombre de lignes a lire */ -/* nombre_colonnes_lire (E) (int) : nombre de colonnes a lire */ -/* pas_ligne (E) (int) : pas en ligne */ -/* pas_colonne (E) (int) : pas en colonne */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels lus alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_lecture_canal_jpeg (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - - -CAI_OK_KO cai_lecture_canal_jpeg(CAI_IMAGE *image1 , - int *canal , - int *premiere_ligne , - int *premiere_colonne, - int *nombre_lignes_lire , - int *nombre_colonnes_lire, - int *pas_ligne , - int *pas_colonne, - unsigned char *data_image ) -{ - JSAMPARRAY buffer; - struct jpeg_decompress_struct *cinfo; - static struct jpeg_error_mgr jerr; - int i,j,k,n; /* variables de travail */ - int pt_oct; /* position courante dans le fichier image */ - int no_oct; /* numero du premier octet a lire */ - int iret; /* indicateur d'erreur */ - int lig; /* indice de boucle sur les lignes */ - int oct_pix; /* nb octets par pixels */ - long nb_oct; /* nb oct =1er octet a lire - position courante */ - int oct_lig; /* nb oct. par ligne en considerant taille pixel */ - int nbcan; /* nombre de canaux de l'image */ - unsigned char *buf_lec; /* buffer lecture d'une ligne */ - unsigned char *deb,*pch; /* pointeur chaine pour transfert buffer sortie */ - FILE *infile; /* acces au fichier jpeg */ - - -/*........................... - Initialisations diverses - ..........................*/ - - iret=CAI_OK; - cinfo=image1->ACCES_CANAL_JPEG_LEC; - oct_pix=image1->NBOCT_PIX; - nbcan = image1->NB_CANAUX; - oct_lig=nbcan*(image1->NB_COL); - -if ((*premiere_ligne)-1 != cinfo->output_scanline) -{ - cinfo->output_scanline = cinfo->image_height; - jpeg_finish_decompress(cinfo); - jpeg_destroy_decompress(cinfo); - - infile = image1->ACCES_FILE_JPEG; - rewind(infile); - cinfo->err=jpeg_std_error(&jerr); - jpeg_create_decompress(cinfo); - jpeg_stdio_src(cinfo,infile); - (void) jpeg_read_header(cinfo,TRUE); - jpeg_start_decompress(cinfo); -} -/*.............................................. - allocation de memoire pour lire une ligne image - ............................................. */ - buffer = (*cinfo->mem->alloc_sarray)((j_common_ptr)cinfo, - JPOOL_IMAGE,oct_lig,1); - if (buffer == NULL) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Probleme allocation memoire JPEG"); - } - else - { -if ((*premiere_ligne)-1 != cinfo->output_scanline) -{ - - -/* positionnement jusqu'a la premiere ligne a lire */ - for (lig=0;lig <(*premiere_ligne)-1;lig++) - { - (void) jpeg_read_scanlines(cinfo,buffer,1); - - } -} -/* recuperation des lignes demandees */ - lig=(*premiere_ligne)-1; - i=1; - pch = data_image; - - while ((i <= (*nombre_lignes_lire))&&(iret==CAI_OK)) - { - cinfo->output_scanline = lig; - n = jpeg_read_scanlines(cinfo,buffer,1); - if (n<=0) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Erreur lecture donnee image JPEG"); - } - else - { -/*...................................... - Sauvegarde des donnees lues entenant compte du pas - d'echantillonnage en colonne - ........................................*/ - deb = *buffer; - deb=deb+((*premiere_colonne)-1)*nbcan+(*canal-1); - j=1; - while (j <= (*nombre_colonnes_lire)) - { - - *pch=*deb; - pch=pch+1; - j=j+1; - deb=deb+((*pas_colonne)*oct_pix*nbcan); - } - - i=i+1; - lig=lig+1; - j = 1; - while ((j < (*pas_ligne))&&(iret==CAI_OK) - &&(lig+1<(image1->NB_LIG))) - { - cinfo->output_scanline = lig; - n = jpeg_read_scanlines(cinfo,buffer,1); - - if (n<=0) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Erreur lecture donnee image JPEG"); - } - else - lig=lig+1; - j = j+1; - } - } - } - } - - return(iret); - } -/* - Fin de l'operation cai_lecture_canal_jpeg -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ecriture_canal_jpeg */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ecriture d'un canal d'une image jpeg */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ecriture_canal_jpeg(image1, canal, */ /* ------------------ premiere_ligne, */ -/* nombre_lignes_ecrire, */ -/* nombre_colonnes_ecrire,*/ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a ecrire */ -/* premiere_ligne (E) (int) : premiere ligne a ecrire ds l'image */ -/* nombre_lignes_ecrire (E) (int) : nombre de lignes a ecrire */ -/* nombre_colonnes_ecrire(E) (int) : nombre de lignes a ecrire */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels ecris alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_ecriture_canal_jpeg (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_OK_KO cai_ecriture_canal_jpeg (CAI_IMAGE *image1 , - int *canal , - int *premiere_ligne , - int *nombre_lignes_ecrire , - int *nombre_colonnes_ecrire, - unsigned char *data_image ) -{ -int i_ligne; /* compteur de lignes */ -int num; /* descripteur de fichier */ -int nboct_pix; /* nombre d'octets par pixel */ -int nbcan; /* nombre de canaux de l'image */ -int nboctet; /* nombre d'octets d'une ligne multi */ -int ires,ideb,col,indk; /* indice */ - -/* initialisations */ -i_ligne = 0; -nboct_pix = image1->NBOCT_PIX; -nbcan = image1->NB_CANAUX; -nboctet = (*nombre_colonnes_ecrire)*nbcan*(nboct_pix); - - -/********************************************************/ -/* TANT QUE il y a des lignes a ecrire */ -/********************************************************/ -ires = ( *premiere_ligne - 1) *nboctet+(*canal-1); -ideb = 0; -while (i_ligne < (*nombre_lignes_ecrire)) -{ - -/*************************************************************************/ -/* chargement de la ligne entrelacant les pixels par rapport aux canaux*/ -/*************************************************************************/ - for (col=0;col<(*nombre_colonnes_ecrire);col++) - { - for (indk=0;indk<nboct_pix;indk++) - { - image1->image_JPEG[ires] = data_image[ideb+indk]; - } - ires = ires + (nboct_pix*nbcan); - ideb = ideb + nboct_pix; - } -/********************************************************/ -/* incrementation du nombre de lignes */ -/********************************************************/ - - i_ligne++; - -/********************************************************/ -/* FIN TANT QUE */ -/********************************************************/ - -} - -return (CAI_OK); - -ERREUR : - -return (CAI_KO); - - -} - -/* - Fin de l'operation cai_ecriture_canal_jpeg -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ferme_jpeg */ -/* ---------- */ -/* */ -/* ROLE : fonction de fermeture d'une image au format jpeg et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ferme_jpeg(image1) */ /* ------------------ */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* */ -/* cai_ferme_jpeg (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_OK_KO cai_ferme_jpeg (CAI_IMAGE *image1) - - -{ - int iret; /* code retour de l'operation */ - FILE *infile; /* descripteur du fichier a fermer */ - struct jpeg_decompress_struct *cinfoL; /* structure du fichier a fermer */ - struct jpeg_compress_struct *cinfoE; /* structure du fichier a fermer */ - JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */ - int nboctet; /* nb d'octets par ligne */ - -/* initialisations */ -/*.................*/ - iret=CAI_OK; - -if (image1 !=NULL) -{ - nboctet = (image1->NB_COL)*(image1->NB_CANAUX); -/*............................................. - Fermeture differente si lecture ou ecriture d'images - .............................................*/ - if (image1->POS_OCTET[0]==CAI_JPEG_LECTURE) - { -/* Fermeture d'image simple pour une lecture avec liberation des */ -/* espaces memoires */ - cinfoL = image1->ACCES_CANAL_JPEG_LEC; - if (cinfoL != NULL) - { -/*****************************************************************************/ -/* MOD : VERSION : 4.8 : FA : modifiation fermeture avant decompression */ -/*****************************************************************************/ - cinfoL->output_scanline=image1->NB_LIG; - - jpeg_finish_decompress(cinfoL); - jpeg_destroy_decompress(cinfoL); - free(cinfoL); - cinfoL = NULL; - } - } - else - { -/* cas ecriture d'une image au format JPEG : avant de fermer l'image */ -/* ecriture compressee du tableau conteant l'image */ - cinfoE = image1->ACCES_CANAL_JPEG_ECR; - if (cinfoE != NULL) - { - - while (cinfoE->next_scanline < cinfoE->image_height) - { - /* jpeg_write_scanlines expects an array of pointers to scanlines. - * Here the array is only one element long, but you could pass - * more than one scanline at a time if that's more convenient. - */ - row_pointer[0] = - & (image1->image_JPEG[cinfoE->next_scanline * nboctet]); - (void) jpeg_write_scanlines(cinfoE, row_pointer, 1); - } - /* Finish compression */ - - jpeg_finish_compress(cinfoE); - - /* After finish_compress, we can close the output file. */ - - /* release JPEG compression object */ - - /* This is an important step since it will release a good */ - /* deal of memory. */ - jpeg_destroy_compress(cinfoE); - free(cinfoE); - cinfoL = NULL; - } - if (image1->image_JPEG != NULL) - { - free(image1->image_JPEG); - image1->image_JPEG = NULL; - } - } - - infile=image1->ACCES_FILE_JPEG; - if (infile!=NULL) fclose(infile); -} - return (iret); -} - -/* - Fin de l'operation cai_ferme_jpeg -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_dest_ima_jpeg */ -/* ---------- */ -/* */ -/* ROLE : fonction de destruction d'une image stocke en jpeg et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_dest_ima_jpeg(repertoire,nom_ima) */ /* ------------------ */ -/* repertoire (E) (char *) : repertoire de l'image a detruire */ -/* nom_image (E) (char *) : nom de l'image a detruire avec repertoire */ -/* */ -/* cai_dest_ima_jpeg (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - - -CAI_OK_KO cai_dest_ima_jpeg ( char *repertoire , - char *nom_ima ) - -{ -char nom_ima_complet[1024]; /* repertoire + nom de l'image */ - -int cr_stat; /* code retour de fonction status de fichier */ -struct stat buf_stat; /* structure decrivant status de fichier */ - -/************************************************/ -/* Constitution du nom du fichier d'entete */ -/************************************************/ - -if ((long)strlen(repertoire)!= 0) -{ - sprintf(nom_ima_complet,"%s/%s.jpg",repertoire,nom_ima); -} -else -{ - sprintf(nom_ima_complet,"./%s.jpg",nom_ima); -} - -/********************************/ -/* Destruction du fichier */ -/********************************/ - -cr_stat = stat ( nom_ima_complet , &buf_stat ); -if ( cr_stat == 0 ) - unlink ( nom_ima_complet ); - -return (CAI_OK); - -} -/* - Fin de l'operation cai_dest_ima_jpeg -*/ diff --git a/Utilities/CAI/cai_dll/src/cai_lum.c b/Utilities/CAI/cai_dll/src/cai_lum.c deleted file mode 100755 index 764e2103d5ccea97d56f0f446b2e245d42c18c66..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/src/cai_lum.c +++ /dev/null @@ -1,1765 +0,0 @@ -/*****************************************************************************/ -/* */ -/* PROJET : COUCHE ACCES IMAGE */ -/* ------- */ -/* */ -/* MODULE : cai_lum.c */ -/* ------- */ -/* */ -/* ROLE : Ce module rassemble toutes les fonctions d'acces aux images */ -/* ------- stockees au format lum */ -/* */ -/* AUTEUR : R.CHAISEMARTIN (CISI) */ -/* ------- */ -/* */ -/* DATE DE CREATION : Octobre 97 */ -/* ----------------- */ -/* */ -/* LANGAGE : C */ -/* -------- */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ -/* MOD : VERSION : 3.3 : DM:optimisation des acces */ -/*****************************************************************************/ -/* MOD : VERSION : 4.0 : DM:possibilite de lire des images en R4 */ -/*****************************************************************************/ -/* MOD : VERSION : 4.1 :FA:Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : DM : modifications indications Big ou Little Endian */ -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : DM : modifications pour compatibilite HP64bits */ -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM :fonctions de test machine et inversions */ -/* deviennent generiques */ -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : modifications fopen binaire pour PC/NT */ -/*****************************************************************************/ -/* MOD : VERSION : 4.4 : DM : modifications open binaire pour PC/NT */ -/*****************************************************************************/ -/* MOD : VERSION : 4.5 : FA : test sur fclose pour PC/LINUX */ -/*****************************************************************************/ -/* MOD : VERSION : 4.8 : DM : Lecture des images codées de 9 à 16 bits en */ -/* IEEE (BI) et INTEL (LI) */ -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : prise en compte des I4,UI2,UI4 et R8 */ -/* en lecture et ecriture en big et little endian */ -/*****************************************************************************/ - -/*---------------------------------------------------------------------------*/ -/* Inclusion des fichiers STANDARDS (.h) */ -/*---------------------------------------------------------------------------*/ - - -# include <stdio.h> -# include <string.h> -# include <sys/types.h> -# include <stdlib.h> -# include <unistd.h> -# include <dirent.h> -# include <sys/stat.h> -# include <fcntl.h> -# include <fcntl.h> -# include <malloc.h> -# include <math.h> -# include <unistd.h> - - - -#define _CAI_IMAGE -#define IN_CAI_LUM - -# include "cai_image.h" - -/*----------------------------------------------------------------------------*/ -/* Variable pour la gestion en configuration */ -/*----------------------------------------------------------------------------*/ -static char *rcs_id="$Header: cai_lum.c,v 1.11 01/05/31 10:47:29 cmf Exp $"; - - -extern char *getenv(); -int cai_recuptyp_lum(char *type_code, char *SensCode, int *nbbits, - char *cod_pix); - - -/*****************************************************************************/ -/*****************************************************************************/ -/* */ -/* Definition des OPERATIONS EXTERNES */ -/* */ -/*****************************************************************************/ -/*****************************************************************************/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_liste_ima_lum */ -/* ---------- */ -/* */ -/* ROLE : fonction de listage des images au format lum */ -/* ------ */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : int cai_liste_ima_lum(repert,tab_ima) */ -/* ----------------- */ -/* */ -/* repert (E) (char *) : repertoire a explorer */ -/* tab_ima (S) (char ***) : pointeur sur tableau des images listees */ -/* alloue par la fonction,il doit etre */ -/* LIBERE PAR L'APPELANT */ -/* */ -/* cai_liste_ima_lum (S) (int) : = -1 repertoire inexistant */ -/* = > 0 nombre d'images listees */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -long int cai_liste_ima_lum (char *repert, - char ***tab_ima) - - -{ - DIR *dirp; /* pointeur sur structure ouverture repertoire */ - struct dirent *dp; /* structure resultat de la fonction readdir */ - char *pch0,*pch1; /* pointeurs sur chaine de caracteres */ - char car; /* variable de travail */ - int nb_ima; /* nombre d'images lum identifiees */ - long int i; /* indice de boucle */ - long int ll,dif; /* variables de travail */ - char blanc; /* caractere blanc */ - - -/*........................................ - INITIALISATION et ouverture du repertoire choisi - .........................................*/ - nb_ima=0; - - dirp=opendir(repert); - - if(dirp!=NULL) - { -/*...................................... - - premiere passe pour comptabiliser les images du format donne - - - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE LUM - (EXTENSION =.lum) - ..........................................*/ - - while((dp=readdir(dirp))!=NULL) - { - pch0=strstr(dp->d_name,".lum"); - if (pch0 != NULL) - { - ll = strlen(dp->d_name); - dif = (long)(dp->d_name-pch0); - dif=labs(dif); - pch1=pch0+4; - if (((ll-4)==dif)||((*pch1)==blanc)) - nb_ima=nb_ima+1; - - } - - } - - closedir(dirp); -/*..................................... - ALLOCATION DU TABLEAU CONTENANT LA LISTE DES IMAGES DU FORMAT LUM - ......................................*/ - *tab_ima = (char **) calloc(nb_ima,sizeof(char *)); - for (i=0;i<nb_ima;i=i+1) - (*tab_ima)[i]=(char *)calloc(1,100); - -/*...................................... - - deuxieme passe pour constituer la liste des images du format donne - - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE LUM - (EXTENSION =.lum) - SI C`EST LE CAS,STOCKAGE DANS LA LISTE - ..........................................*/ - dirp=opendir(repert); - - nb_ima=0; - - while((dp=readdir(dirp))!=NULL) - { - pch0=strstr(dp->d_name,".lum"); - if (pch0 != NULL) - { - ll = strlen(dp->d_name); - dif = (long)(dp->d_name-pch0); - dif=labs(dif); - pch1=pch0+4; - if (((ll-4)==dif)||((*pch1)==blanc)) - { - *pch0='\0'; - strcpy((*tab_ima)[nb_ima],dp->d_name); - nb_ima=nb_ima+1; - } - - } - } - - closedir(dirp); - - } - else - { - /* Erreur : Repertoire inexistant */ - nb_ima=-1; - } - - return(nb_ima); - -} -/* Fin de l'operation cai_liste_ima_lum*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_lecture_lum */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture d'une image au format lum */ -/* ----- et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_lecture_lum(nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_lecture_lum (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ /* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : prise en compte des UOCT, I4,UI2,UI4 et R8 */ -/* en lecture et ecriture en big et little endian */ -/*****************************************************************************/ - -CAI_IMAGE *cai_ouvre_lecture_lum(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) -{ - FILE *fic_in; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - int iret,icr; /* indicateur de retour ok ou pas */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char nom_fic_canal[1024]; /* nom fichier canal dont on teste existence */ - int nbbits; /* nb de bits par pixel du fichier en-tete */ - int retour; /* retour de la fonction comparaison chaines */ - int i,num; /* indice */ - char *type_cod; /* type de codage du pixel */ - char cod_pix[5]; /* codage du pixel */ - char type_image[3]; /* type code+ordre rangement octets dans entete*/ - char *type_machine; /* ordre rangement octets machine travail */ - char buf[15]; /* buffer contenant entete image */ - int v; /* comparaison type machine-type image */ - char *v1; /* comparaison type image avec chaine vide */ - int nb_col2, nb_lig2,nb; /* variables intermediaires inversion octets */ - int taille; /* nb d'octets par pixel */ - - /*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - nb=2; - *nb_can=0; - - *nb_lig=0; - - *nb_col=0; - - *nboct_pix=0; - - - iret=1; - type_cod = NULL; - type_cod = (char *) calloc(5,sizeof(char)) ; - type_machine = NULL; - type_machine = (char *) calloc(3,sizeof(char)); - - if (type_machine == NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur allocation memoire dans cai_ouvre_lecture"); - } - - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); - -/*****************************************************************************/ -/* MOD : VERSION : 4.1 :FA:Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur allocation memoire dans cai_ouvre_lecture"); - } - else - { -/*................................................. - Constitution du nom du fichier entete - .................................................*/ - nom_fic[0]='\0'; - if ((long)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s.lum",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.lum",nom_image); - } - -/*........................ - Ouverture du fichier entete - ..........................................*/ -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : modifications fopen binaire pour PC/NT */ -/*****************************************************************************/ - fic_in=NULL; - fic_in=fopen(nom_fic,"rb"); - if (fic_in==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur ouverture fichier entete LUM"); - } - else - { - -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : DM : modifications indications Big ou Little Endian */ -/*****************************************************************************/ -/*.................................. - recuperation infos completes - ......................................*/ - fread(buf,12,1,fic_in); - -/*.................................. - recuperation du type de codage des pixels - et donc du type de l'image - ......................................*/ - memcpy(type_cod,&buf[8],4); - taille = cai_recuptyp_lum(type_cod,type_image,&nbbits,cod_pix); - if (taille != -1) - { - sprintf(image1->TYPE_COD,type_cod); - image1->NB_BITS_PIX=nbbits; - image1->NBOCT_PIX=taille; - sprintf(image1->COD_PIX,cod_pix); - *nboct_pix = image1->NBOCT_PIX; - *nb_can = 1; - } - else - { - iret=0; - sprintf(CAI_ERREUR,"Type de codage LUM non reconnu : %s",type_cod); - goto ERREUR; - } - - /*.................................. - determination ordre de rangement - des octets sur machine de travail - ......................................*/ - type_machine = cai_test_pFpf(); - - /*.................................. - determination des autres infos - en fonction inversion - ......................................*/ - - v = strncmp(type_machine,type_image,2); - v1 = strrchr(type_image,'E'); - -/*.................................. - recuperation du nombre de colonne - ......................................*/ - memcpy(nb_col,&buf[0],4); - -/*modification si (type_image et type_machine st differentes) */ -/*et si (type_image existe avec BE ou LE)*/ - - if ( (v!=0) && (v1!=NULL) ) - { - swab( (void*)nb_col, (void*)&nb_col2,4 ); - cai_inverser_tableau((short *)nb_col, (short *)&nb_col2,nb); - } -/*.................................. - recuperation du nombre de lignes - ......................................*/ - memcpy(nb_lig,&buf[4],4); - -/*modification si (type_image et type_machine st differentes) */ -/*et si (type_image existe avec BE ou LE)*/ - - if ( (v!=0) && (v1!=NULL) ) - { - swab( (void*)nb_lig, (void*)&nb_lig2,4 ); - cai_inverser_tableau((short *)nb_lig, (short *)&nb_lig2,nb); - } - -/**********************/ -/* fin modifications */ -/**********************/ - } - -/*.................................. - Fermeture du fichier - ......................................*/ - if (fic_in != NULL) fclose(fic_in); - - if (iret !=0) - { -/*....................................... - INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL - .....................................................*/ - - nom_fic[0]='\0'; - nom_fic_canal[0]='\0'; - - if ((long)strlen(repert)!=0) - { - sprintf(nom_fic_canal,"%s/%s.lum",repert,nom_image); - } - else - { - sprintf(nom_fic_canal,"%s.lum",nom_image); - } - - num=open(nom_fic_canal,O_RDONLY|O_BINARY,0); - if (num!= -1) - { - - for (i=0;i<*nb_can;i=i+1) - { - sscanf(nom_image,"%s",image1->NOM_FIC_CAN); - sscanf(nom_image,"%s",image1->NOM_UTIL_CAN); - image1->ACCES_CANAL_INT[i]=num; - image1->POS_OCTET[i]=(*nb_col)*image1->NBOCT_PIX; - } - -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : DM : modifications indications Big ou Little Endian */ -/*****************************************************************************/ - if ( (v!=0) && (v1!=NULL) ) - { - image1->INV_OCTETS =1; - } - else - { - image1->INV_OCTETS =0; - } - -/**************************/ -/* fin modifications */ -/**************************/ - } - else - iret=0; - } - } -// if (type_cod!=NULL) free(type_cod); -// if (type_machine!=NULL) free(type_machine); - -ERREUR: - - if (iret == 0) - { - return (NULL); - } - else - { - return(image1); - } -} -/* - Fin de l'operation cai_ouvre_lecture_lum -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_creation_lum */ -/* ---------- */ -/* */ -/* ROLE : fonction de creation et d'ouverture en ecriture d'une image */ -/* ----- au format lum et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_creation_lum(nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig, */ -/* label) */ -/* */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* nb_can (E) (int ) : nombre de canaux de l'image */ -/* nboct_pix (E) (int ) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (E) (int ) : nombre de lignes de l'image */ -/* nb_col (E) (int ) : nombre de colonnes de l'image */ -/* label (E) (char *) : commentaire lie a l'image */ -/* */ -/* cai_ouvre_creation_lum (S) (CAI_IMAGE *) : =NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_IMAGE *cai_ouvre_creation_lum(char *repert, - char * nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig, - char *label) - - -{ - FILE *fic; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - char nom_fic[1024]; /* nom du fichier en-tete */ - long retour; /* retour de fonction */ - int i,num; /* indice */ - struct stat buf_stat; /* structure decrivant status de fichier */ - unsigned char *Header; /* entete du fichier lum */ - int taille_entete; /* taille de l'entete */ - char *type_image; /* type_code+infos ordre des octets dans entete*/ - int reconnaissance_type; /* taille du pixel */ - - fic = NULL; - image1=NULL; - - -/*********************************************/ -/* Verification qu'un seul canal est demande */ -/*********************************************/ - if (*nb_can != 1) - { - image1 = NULL; - sprintf ( CAI_ERREUR , - "Une image LUM ne peut contenir qu'un seul canal"); - goto ERREUR; - } - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); -/*****************************************************************************/ -/* MOD : VERSION : 4.1 :FA:Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_creation"); - goto ERREUR; - } - -/*................................................. - Constitution du nom du fichier entete et verification qu'il - n'existe pas deja - .................................................*/ - - nom_fic[0]='\0'; - if ((long)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s.lum",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.lum",nom_image); - } - - retour = stat ( nom_fic , &buf_stat ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "L'image %s LUM existe \n" , nom_image ); - goto ERREUR; - } - -/*...................................................... - Ouverture du fichier entete en ecriture - Ecriture du contenu - ..........................................................*/ -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : modifications fopen binaire pour PC/NT */ -/*****************************************************************************/ - fic = NULL; - fic = fopen(nom_fic,"wb"); - if (fic == NULL) - { - sprintf(CAI_ERREUR,"Erreur: Creation fichier %s impossible\n",nom_fic); - goto ERREUR; - } - taille_entete = (*nb_col)*(*nboct_pix); - Header = (unsigned char *) calloc(taille_entete,sizeof( unsigned char)); - if (Header == NULL) - { - sprintf(CAI_ERREUR,"Erreur alloc: Creation fichier %s impossible\n", - nom_fic); - goto ERREUR; - } - -/*********************************************/ -/* ecriture du nombre de colonnes de l'image */ -/*********************************************/ - memcpy(Header,nb_col , 4 ); - -/*******************************************/ -/* ecriture du nombre de lignes de l'image */ -/*******************************************/ - memcpy(&Header[4],nb_lig , 4 ); - - -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : DM : modifications indications Big ou Little Endian */ -/*****************************************************************************/ - -/*******************************************/ -/* ecriture du type de l'image dans la zone*/ -/* reservee au type de codage */ -/*******************************************/ - - /*.................................... - test sur la machine de travail pour - typer image en LE ou BE - .....................................*/ - - type_image = cai_test_pFpf(); - - -/**************************************/ -/* ecriture type de codage de l'image */ -/**************************************/ -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : Maj du tag TYPE lorsque l'utilisateur le */ -/* precise dans le param "label" */ -/*****************************************************************************/ -/* Verification si type de codage reconnu dans le label */ - reconnaissance_type = cai_istyp_connu(label); - if (strncmp(type_image,"BE",2)==0) - { - if (*nboct_pix == 1) - { - if (reconnaissance_type < 1) - sprintf(image1->TYPE_COD,"08BI"); - else if (reconnaissance_type ==1) - sprintf(image1->TYPE_COD,"08BU"); - else - { - sprintf(CAI_ERREUR,"incoherence entre TYPE et Nb bits par pixels\n"); - goto ERREUR; - } - } - else if (*nboct_pix == 2) - { - if (reconnaissance_type ==3) - sprintf(image1->TYPE_COD,"16BU"); - else if ((reconnaissance_type == -1)|| (reconnaissance_type == 2)) - sprintf(image1->TYPE_COD,"16BI"); - else - { - sprintf(CAI_ERREUR,"incoherence entre TYPE et Nb bits par pixels\n"); - goto ERREUR; - } - } - else if (*nboct_pix == 4) - { - if (reconnaissance_type ==4) - sprintf(image1->TYPE_COD,"32BI"); - else if (reconnaissance_type ==5) - sprintf(image1->TYPE_COD,"32BU"); - else if ((reconnaissance_type == -1)|| (reconnaissance_type == 6)) - sprintf(image1->TYPE_COD,"FLOA"); - else - { - sprintf(CAI_ERREUR,"incoherence entre TYPE et Nb bits par pixels\n"); - goto ERREUR; - } - } - else if (*nboct_pix == 8) - { - if ((reconnaissance_type == -1)|| (reconnaissance_type ==7)) - sprintf(image1->TYPE_COD,"R8B "); - else - { - sprintf(CAI_ERREUR,"incoherence entre TYPE et Nbbits par pixels\n"); - goto ERREUR; - } - } - } - else - { - if (*nboct_pix == 1) - { - if (reconnaissance_type < 1) - sprintf(image1->TYPE_COD,"08LI"); - else if (reconnaissance_type ==1) - sprintf(image1->TYPE_COD,"08LU"); - else - { - sprintf(CAI_ERREUR,"incoherence entre TYPE et Nb bits par pixels\n"); - goto ERREUR; - } - } - else if (*nboct_pix == 2) - { - if (reconnaissance_type ==3) - sprintf(image1->TYPE_COD,"16LU"); - else if ((reconnaissance_type == -1)|| (reconnaissance_type == 2)) - sprintf(image1->TYPE_COD,"16LI"); - else - { - sprintf(CAI_ERREUR,"incoherence entre TYPE et Nb bits par pixels\n"); - goto ERREUR; - } - } - else if (*nboct_pix == 4) - { - if (reconnaissance_type ==4) - sprintf(image1->TYPE_COD,"32LI"); - else if (reconnaissance_type ==5) - sprintf(image1->TYPE_COD,"32LU"); - else if ((reconnaissance_type == -1)|| (reconnaissance_type == 6)) - sprintf(image1->TYPE_COD,"FLOL"); - else - { - sprintf(CAI_ERREUR,"incoherence entre TYPE et Nb bits par pixels\n"); - goto ERREUR; - } - } - else if (*nboct_pix == 8) - { - if ((reconnaissance_type == -1)|| (reconnaissance_type ==7)) - sprintf(image1->TYPE_COD,"R8L "); - else - { - sprintf(CAI_ERREUR,"incoherence entre TYPE et Nbbits par pixels\n"); - goto ERREUR; - } - } - - } - memcpy(&Header[8],image1->TYPE_COD , 4 ); - -/***********************/ -/* fin modifications */ -/***********************/ - - retour = fwrite ( Header , taille_entete , 1 , fic ); - free(Header); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , - "Erreur : ecriture entete impossible dans fichier %s\n", - nom_fic ); - goto ERREUR; - } - -/*************************************************/ -/* Fermeture du fichier */ -/*************************************************/ - - if (fic != NULL) fclose ( fic ); - - num = open(nom_fic,O_RDWR|O_BINARY,PERMS); - if (num == -1) - { - - sprintf(CAI_ERREUR,"Erreur: Creation %s impossible\n",nom_fic); - goto ERREUR; - } - - for (i=0;i<*nb_can;i=i+1) - { - image1->ACCES_CANAL_INT[i]=num; - image1->POS_OCTET[i]=taille_entete; - } - - return (image1); - -ERREUR : - - if (fic !=NULL) cai_dest_ima_lum ( repert , nom_image ); - return(NULL); -} - -/* - Fin de l'operation cai_ouvre_creation_lum -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_lecture_canal_lum */ -/* ---------- */ -/* */ -/* ROLE : fonction de lecture d'un canal d'une image LUM */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_lecture_canal_lum(image1, canal, */ -/* ------------------ premiere_ligne, */ -/* premiere_colonne, */ -/* nombre_lignes_lire , */ -/* nombre_colonnes_lire, */ -/* pas_ligne ,pas_colonne, */ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a lire */ -/* premiere_ligne (E) (int) : premiere ligne a lire dans l'image */ -/* premiere _colonne (E) (int) : premiere colonne a lire dans l'image */ -/* nombre_lignes_lire (E) (int) : nombre de lignes a lire */ -/* nombre_colonnes_lire (E) (int) : nombre de colonnes a lire */ -/* pas_ligne (E) (int) : pas en ligne */ -/* pas_colonne (E) (int) : pas en colonne */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels lus alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_lecture_canal_lum (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_OK_KO cai_lecture_canal_lum(CAI_IMAGE *image1 , - int *canal , - int * premiere_ligne , - int *premiere_colonne, - int *nombre_lignes_lire , - int *nombre_colonnes_lire, - int *pas_ligne , - int *pas_colonne, - unsigned char *data_image ) - -{ - - int num,i,j,k,kk; /* variables de travail */ - long pt_oct,n; /* position courante dans le fichier image */ - int no_oct; /* numero du premier octet a lire */ - int iret; /* indicateur d'erreur */ - int lig; /* indice de boucle sur les lignes */ - int oct_pix; /* nb octets par pixels */ - long nb_oct; /* nb oct =1er octet a lire - position courante */ - long oct_lig; /* nb oct. par ligne en considerant taille pixel */ - unsigned char *buf_lec; /* buffer lecture d'une ligne */ - unsigned char *deb,*pch; /* pointeur chaine pour transfert buffer sortie */ - unsigned char *data_image2;/* pointeur donnees image pour inversion octets */ - int taille_image,Nb; /* taille en octets de l'image */ - - -/*********************************************/ -/* Verification qu'un seul canal est demande */ -/*********************************************/ - if (*canal != 1) - { - image1 = NULL; - sprintf ( CAI_ERREUR , - "Une image LUM ne contient qu'un seul canal"); - iret=CAI_KO; - } - else - { -/*........................... - Initialisations diverses - ..........................*/ - iret=CAI_OK; - num=image1->ACCES_CANAL_INT[*canal-1]; - oct_pix=image1->NBOCT_PIX; - taille_image = (*nombre_lignes_lire)*oct_pix*(*nombre_colonnes_lire); - data_image2 = NULL; - data_image2 = (unsigned char *) calloc(taille_image,sizeof(unsigned char)); - - if (data_image2 == NULL) - { - strcpy(CAI_ERREUR,"Erreur allocation memoire dans cai_lecture_canal"); - iret=CAI_KO; - goto FIN; - } - - -/*.............................................................*/ -/* verification si lecture non sous-echantillonnee par bandeau */ -/*.............................................................*/ - if ((*nombre_colonnes_lire==image1->NB_COL)&&(*premiere_colonne==1)&& - (*pas_ligne==1)&&(*pas_colonne==1)) - { - oct_lig=(*nombre_lignes_lire)*oct_pix*(image1->NB_COL); - pch=data_image; - -/*............................................ - Recherche de la position courante dans le fichier - ............................................*/ - pt_oct=lseek(num,0L,1); - -/*................................ - Calcul du numero du 1er octet a lire - ....................................*/ - lig=*premiere_ligne; - no_oct=image1->POS_OCTET[*canal-1]+ - (lig-1)*image1->NB_COL*oct_pix; - - -/*.................................. - Saut d'octets pour etre positionne sur la ligne a lire - .......................................*/ - nb_oct=(long)(no_oct-pt_oct); - lseek(num,nb_oct,1); - -/*........................................... - lecture des lignes completes - ................................................*/ - n=read(num,pch,oct_lig); - - if (n<=0) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Erreur lecture donnee image LUM"); - goto FIN; - } - - } - else - { - oct_lig=oct_pix*image1->NB_COL; - -/*.............................................. - allocation de memoire pour lire une ligne image - ............................................. */ - buf_lec = NULL; - buf_lec = (unsigned char *) calloc(oct_lig,sizeof(unsigned char)); - if (buf_lec == NULL) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Probleme allocation memoire"); - } - else - { -/*.................... - Initialisation - ......................*/ - lig=*premiere_ligne; - i=1; - pch=data_image; - -/*..................... - Pour chaque ligne a lire - .......................................*/ - while ((i <= *nombre_lignes_lire)&&(iret==CAI_OK)) - { -/*............................................ - Recherche de la position courante dans le fichier - ............................................*/ - pt_oct=lseek(num,0L,1); - -/*................................ - Calcul du numero du 1er octet a lire - ....................................*/ - - no_oct=image1->POS_OCTET[*canal-1]+ - (lig-1)*image1->NB_COL*oct_pix; - - -/*.................................. - Saut d'octets pour etre positionne sur la ligne a lire - .......................................*/ - nb_oct=(long)(no_oct-pt_oct); - lseek(num,nb_oct,1); - -/*........................................... - lecture d'une ligne image - ................................................*/ - n=read(num,buf_lec,oct_lig); - - if (n<=0) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Erreur lecture donnee image LUM"); - } - else - { -/*...................................... - Sauvegarde des donnees lues entenant compte du pas - d'echantillonnage en colonne - ........................................*/ - deb=buf_lec+(*premiere_colonne-1)*oct_pix; - j=1; - while (j <= *nombre_colonnes_lire) - { - for (k=0;k<oct_pix;k=k+1) - { - *(pch+k)=*(deb+k); - } - j=j+1; - pch=pch+oct_pix; - deb=deb+(*pas_colonne*oct_pix); - } - - } - i=i+1; - lig=lig+(*pas_ligne); - } - - free(buf_lec); - buf_lec=NULL; - } - } - } - - -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : DM : modifications indications Big ou Little Endian */ -/*****************************************************************************/ - - - if ( (iret!= CAI_KO) && (image1->INV_OCTETS==1) && (oct_pix!=1) ) - { - - /*modification ordre selon nb octets par pixel*/ - swab( (void*)(data_image), (void*)(data_image2), taille_image); - - if (oct_pix!=2) - { - Nb = taille_image/2; - cai_inverser_tableau(data_image, data_image2,Nb); - } - else - for (i=0; i<taille_image;i++) - { - /*stockage dans data_image*/ - data_image[i] = data_image2[i]; - } - - } - -/*************************/ -/* fin modifications */ -/*************************/ - FIN: - if (data_image2!= NULL) free(data_image2); - - return(iret); -} - -/* - Fin de l'operation cai_lecture_canal_lum -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ecriture_canal_lum */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ecriture d'un canal d'une image lum */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ecriture_canal_lum(image1, canal, */ -/* ------------------ premiere_ligne, */ -/* nombre_lignes_ecrire, */ -/* nombre_colonnes_ecrire,*/ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a ecrire */ -/* premiere_ligne (E) (int) : premiere ligne a ecrire ds l'image */ -/* nombre_lignes_ecrire (E) (int) : nombre de lignes a ecrire */ -/* nombre_colonnes_ecrire(E) (int) : nombre de colonnes a ecrire */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels ecris alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_ecriture_canal_lum (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_OK_KO cai_ecriture_canal_lum (CAI_IMAGE *image1 , - int *canal , - int *premiere_ligne , - int *nombre_lignes_ecrire , - int *nombre_colonnes_ecrire, - unsigned char *data_image ) -{ -long position_first_lig; /* position de la 1ere ligne a ecrire */ -long position_courante; /* position courante dans le fichier */ -long deplacement; /* deplacement a effectuer */ -unsigned char *buff_lig; /* pointeur de travail bandeau a ecrire */ -long cr_write; /* code retour de write */ -int num; /* descripteur de fichier */ -int nboct_pix; /* nombre d'octets par pixel */ -int nb_canaux; /* nombre de canaux de l'image totale */ -int nboct_ecrire; /* nb d'octets du bandeau a ecrire */ - -/*********************************************/ -/* Verification qu'un seul canal est demande */ -/*********************************************/ - if (*canal != 1) - { - image1 = NULL; - sprintf ( CAI_ERREUR , - "Une image LUM ne contient qu'un seul canal"); - goto ERREUR; - } - -/* ................ - Initialisations - .................*/ - - num = image1->ACCES_CANAL_INT[*canal-1]; - nboct_pix = image1->NBOCT_PIX; - nb_canaux = 1; - position_first_lig = 0; - position_courante = 0; - deplacement = 0; - nboct_ecrire = 0; - -/********************************************************/ -/* Calcul de la position de la premiere ligne a ecrire */ -/********************************************************/ - - position_first_lig = (long) ( image1->POS_OCTET[*canal-1] + - + (*premiere_ligne - 1) * - (*nombre_colonnes_ecrire) * nboct_pix ); -/********************************************************/ -/* Recuperation de la position courante */ -/********************************************************/ - - position_courante = lseek ( num , 0L , 1 ); - -/********************************************************/ -/* Calcul du deplacement jusqu'a la 1ere ligne a ecrire */ -/********************************************************/ - - deplacement = position_first_lig - position_courante; - -/*******************************************************/ -/* deplacement jusqu'a la premiere ligne a ecrire*/ -/*******************************************************/ - - lseek ( num , deplacement , 1 ); - -/***********************************************/ -/* position en debut de bandeau a ecrire */ -/***********************************************/ - - buff_lig = data_image; - -/********************************************************/ -/* ecriture des lignes */ -/********************************************************/ - nboct_ecrire = (*nombre_colonnes_ecrire)*nboct_pix* - (*nombre_lignes_ecrire); - - cr_write = write ( num , buff_lig,nboct_ecrire); - - if ( cr_write != nboct_ecrire) - { - strcpy ( CAI_ERREUR , "Erreur ecriture canal image lum\n" ); - goto ERREUR; - } - -return (CAI_OK); - -ERREUR : - -return (CAI_KO); - - -} -/* - Fin de l'operation cai_ecriture_canal_lum -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ferme_lum */ -/* ---------- */ -/* */ -/* ROLE : fonction de fermeture d'une image au format lum et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ferme_lum(image1) */ -/* ------------------ */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* */ -/* cai_ferme_lum (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_OK_KO cai_ferme_lum (CAI_IMAGE *image1) - - -{ - - int iret; /* code retour de l'operation */ - int num; /* descripteur du fichier a fermer */ - unsigned char Header[12]; /* entete a MAJ si creation */ - int temp; /* variable temporaire */ - long pt_oct; /* position courante ds fichier image */ - long retour; - -/*--------------------------*/ -/* Initialisations diverses */ -/*--------------------------*/ - iret=CAI_OK; - num=image1->ACCES_CANAL_INT[0]; - -/*--------------------------------------------------*/ -/* Mise a jour de l'entete si ouverture en creation */ -/*--------------------------------------------------*/ -if (image1->MODE == CAI_ECRITURE) -{ - pt_oct=lseek(num,0L,0); - -/*******************************************************/ -/* ecriture nombre de colonnes */ -/*******************************************************/ - temp = image1->NB_COL; - memcpy(Header,&temp , 4 ); - -/*******************************************************/ -/* ecriture nombre de ligne */ -/*******************************************************/ - temp = image1->NB_LIG; - memcpy(&Header[4],&temp , 4 ); - -/*****************************************************************/ -/* ecriture du type de codage en fonctions de la taille du pixel */ -/* et du codage des Poids Forts, poids faibles */ -/*****************************************************************/ - memcpy(&Header[8],image1->TYPE_COD , 4 ); - - retour = write ( num,Header , 12 ); - if ( temp == 0 ) - { - sprintf ( CAI_ERREUR , - "Erreur : MAJ entete a la fermeture impossible ds fichier lum\n"); - goto ERREUR; - } - -} - -/*............................................. - Fermeture du fichier qui contient tous les canaux - .............................................*/ - if (num>0) close(num); - - return (iret); - -ERREUR: - return(CAI_KO); - -} - -/* - Fin de l'operation cai_ferme_lum -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_dest_ima_lum */ -/* ---------- */ -/* */ -/* ROLE : fonction de destruction d'une image stocke en lum et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_dest_ima_lum(repertoire,nom_ima) */ -/* ------------------ */ -/* repertoire (E) (char *) : repertoire de l'image a detruire */ -/* nom_image (E) (char *) : nom de l'image a detruire avec repertoire */ -/* */ -/* cai_dest_ima_lum (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - - -CAI_OK_KO cai_dest_ima_lum ( char *repertoire , - char *nom_ima ) - - -{ -int i_can; /* compteur de canaux */ -int iret; /* code retour fonction fermetrue lecture */ -char str_num_canal[3]; /* suffixe numero du canal */ -char nom_fic_entete[1024]; /* nom du fichier entete a detruire */ -char nom_ima_complet[1024]; /* repertoire + nom de l'image */ -char nom_fic_canal[1024]; /* nom du fichier canal a detruire */ - -int cr_stat; /* code retour de fonction status de fichier */ -struct stat buf_stat; /* structure decrivant status de fichier */ - -CAI_IMAGE *image1; /* structure ouverture image */ -int nb_can; /* nombre de canaux de l'image */ -int nboct_pix; /* nombre d'octets par pixel image */ -int nb_col; /* nombre de colonnes de l'image */ -int nb_lig; /* nombre de lignes de l'image */ - -/************************************************/ -/* Constitution du nom du fichier d'entete */ -/************************************************/ - -if ((long)strlen(repertoire)!= 0) -{ - sprintf( nom_ima_complet, "%s/%s" ,repertoire,nom_ima); -} -else -{ - strcpy ( nom_ima_complet , nom_ima); -} - sprintf(nom_fic_entete ,"%s.lum", nom_ima_complet); - -/************************************************/ -/* Destruction du fichier d'entete */ -/************************************************/ - -cr_stat = stat ( nom_fic_entete , &buf_stat ); -if ( cr_stat == 0 ) - unlink ( nom_fic_entete ); - - -return (CAI_OK); - -} -/* - Fin de l'operation cai_dest_ima_lum -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_modifie_lum */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture-ecriture d'une image au format */ -/* ----- lum et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_modifie_lum(nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_modifie_lum (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ /* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_IMAGE *cai_ouvre_modifie_lum(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) - - -{ - FILE *fic_in; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - int iret,icr; /* indicateur de retour ok ou pas */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char nom_fic_canal[1024]; /* nom fichier canal dont on teste existence */ - int nbbits; /* nb de bits par pixel du fichier en-tete */ - int retour; /* retour de la fonction comparaison chaines */ - int i,num; /* indice */ - char *type_cod; /* type de codage du pixel */ - char cod_pix[5]; /* codage du pixel */ - char type_image[3]; /* type code+ordre rangement octets dans entete*/ - char *type_machine; /* ordre rangement octets machine travail */ - char buf[15]; /* buffer contenant entete image */ - int v; /* comparaison type machine-type image */ - char *v1; /* comparaison type image avec chaine vide */ - int nb_col2, nb_lig2,nb; /* variables intermediaires inversion octets */ - int taille; /* nb d'octets par pixel */ - - - /*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - nb=2; - *nb_can=0; - - *nb_lig=0; - - *nb_col=0; - - *nboct_pix=0; - - iret=1; - - type_cod = NULL; - type_cod = (char *) calloc(5,sizeof(char)) ; - type_machine = NULL; - type_machine = (char *) calloc(3,sizeof(char)); - - if (type_machine == NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur allocation memoire dans cai_ouvre_lecture"); - } - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); - -/*****************************************************************************/ -/* MOD : VERSION : 4.1 :FA:Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_modifie"); - } - else - { - -/*................................................. - Constitution du nom du fichier entete - .................................................*/ - nom_fic[0]='\0'; - if ((long)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s.lum",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.lum",nom_image); - } - -/*........................ - Ouverture du fichier entete - ..........................................*/ -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : modifications fopen binaire pour PC/NT */ -/*****************************************************************************/ - fic_in=NULL; - fic_in=fopen(nom_fic,"rb"); - if (fic_in==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur ouverture fichier entete LUM"); - } - else - { - -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : DM : modifications indications Big ou Little Endian */ -/*****************************************************************************/ - /*.................................. - recuperation infos completes - ......................................*/ - fread(buf,12,1,fic_in); - - /*.................................. - recuperation du type de codage des pixels - et donc du type de l'image - ......................................*/ - memcpy(type_cod,&buf[8],4); - taille = cai_recuptyp_lum(type_cod,type_image,&nbbits,cod_pix); - - if (taille != -1) - { - sprintf(image1->TYPE_COD,type_cod); - image1->NB_BITS_PIX=nbbits; - image1->NBOCT_PIX=taille; - sprintf(image1->COD_PIX,cod_pix); - *nboct_pix = image1->NBOCT_PIX; - *nb_can = 1; - } - else - { - iret=0; - sprintf(CAI_ERREUR,"Type de codage LUM non reconnu : %s",type_cod); - goto ERREUR; - } - - /*.................................. - determination ordre de rangement - des octets sur machine de travail - ......................................*/ - - type_machine = cai_test_pFpf(); - - /*.................................. - determination des autres infos - en fonction inversion - ......................................*/ - - v = strncmp(type_machine,type_image,2); - v1 = strrchr(type_image,'E'); - -/*.................................. - recuperation du nombre de colonne - ......................................*/ - memcpy(nb_col,&buf[0],4); - -/*modification si (type_image et type_machine st differentes) */ -/*et si (type_image existe avec BE ou LE)*/ - - if ( (v!=0) && (v1!=NULL) ) - - { - swab( (void*)nb_col, (void*)&nb_col2,4 ); - cai_inverser_tableau((short *)nb_col, (short *)&nb_col2,nb); - } -/*.................................. - recuperation du nombre de lignes - ......................................*/ - memcpy(nb_lig,&buf[4],4); - -/*modification si (type_image et type_machine st differentes) */ -/*et si (type_image existe avec BE ou LE)*/ - - if ( (v!=0) && (v1!=NULL) ) - { - swab( (void*)nb_lig, (void*)&nb_lig2,4 ); - cai_inverser_tableau((short *)nb_lig, (short *)&nb_lig2,nb); - } - - -/************************/ -/* fin modifications */ -/************************/ - } - -/*.................................. - Fermeture du fichier - ......................................*/ - if (fic_in != NULL) fclose(fic_in); - - if (iret !=0) - { -/*....................................... - INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL - .....................................................*/ - - nom_fic[0]='\0'; - nom_fic_canal[0]='\0'; - - if ((long)strlen(repert)!=0) - { - sprintf(nom_fic_canal,"%s/%s.lum",repert,nom_image); - - } - else - { - sprintf(nom_fic_canal,"%s.lum",nom_image); - } - - num=open(nom_fic_canal,O_RDWR|O_BINARY,0); - if (num!= -1) - { - - for (i=0;i<*nb_can;i=i+1) - { - sscanf(nom_image,"%s",image1->NOM_FIC_CAN); - sscanf(nom_image,"%s",image1->NOM_UTIL_CAN); - image1->ACCES_CANAL_INT[i]=num; - image1->POS_OCTET[i]=(*nb_col)*image1->NBOCT_PIX; - } - -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : DM : modifications indications Big ou Little Endian */ -/*****************************************************************************/ - - if ( (v!=0) && (v1!=NULL) ) - { - image1->INV_OCTETS =1; - } - else - { - image1->INV_OCTETS =0; - } - -/***********************/ -/* fin modifications */ -/***********************/ - - } - else - iret=0; - } - } -ERREUR: - if (iret == 0) - { - return (NULL); - } - else - { - return(image1); - } - -} -/* - Fin de l'operation cai_ouvre_modifie_lum - -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_recuptyp_lum */ -/* ---------- */ -/* */ -/* ROLE : fonction de verification si pixels de type lum ou non */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : retour = cai_recuptyp_lum(type_code,SensCode,nbbits , */ -/* cod_pix) */ -/* ---------------- */ -/* */ -/* type_code (E) (char *) : type de codage a verifier */ -/* SensCode (S) (char *) : sens du codage BE ou LE */ -/* nbbits (S) (char *) : nombre de bits significatifs ds le pixel */ -/* cod_pix (S) (char *) : codage du pixel */ -/* retour (S) (int) : Taille du pixel en octet si OK reconnu */ -/* -1 si non reconnu */ -/* */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ -int cai_recuptyp_lum(char *type_code, char *SensCode, int *nbbits, - char *cod_pix) -{ - int ind; /* indice de boucle sur les types reconnus */ - int trouve,icr,taille; /* indice pour la recherche */ - int mod2; /* modulo2 */ - char* pch0; - -/* Initialisations diverses */ - trouve = -1; - taille = -1; - *nbbits=-1; - ind = 0; - pch0=NULL; - while ((trouve==-1)&&(ind< CAI_NB_LUM)) - { - pch0=strstr(type_code,CAI_LUM_TYP[ind]); - if (pch0!=NULL) - trouve=ind; - else - ind=ind+1; - } - if (trouve !=-1) - { - mod2=ind%2; - if (mod2==0) sprintf(SensCode,"BE"); - else sprintf(SensCode,"LE"); - - if (ind < 4) - { - icr=sscanf(type_code,"%d",nbbits); - if (icr ==0) *nbbits=-1 ; - else - { - trouve =(int)(*nbbits/8); - if ((*nbbits%8)!=0) taille =trouve+1; - else taille = trouve; - } - pch0 = strstr(type_code,"U"); - if (taille == 1) - { - if (pch0==NULL) sprintf(cod_pix,"OCT"); - else sprintf(cod_pix,"UOCT"); - } - else if (taille == 2) - { - if (pch0==NULL) sprintf(cod_pix,"I2"); - else sprintf(cod_pix,"UI2"); - } - else if (taille == 4) - { - if (pch0==NULL) sprintf(cod_pix,"I4"); - else sprintf(cod_pix,"UI4"); - } - else taille=-1; - } - else if ((ind ==4)||(ind==5) ) - { - taille=4; - *nbbits = 32; - sprintf(cod_pix,"R4"); - - } - else if ((ind ==6)||(ind==7) ) - { - taille=8; - *nbbits = 64; - sprintf(cod_pix,"R8"); - } - } - -/* sortie normale */ - return(taille); -} -/* - Fin de l'operation cai_recuptyp_lum -*/ - - - - - diff --git a/Utilities/CAI/cai_dll/src/cai_mapsat.c b/Utilities/CAI/cai_dll/src/cai_mapsat.c deleted file mode 100755 index f50fe9c5f856c32fef16b5535061ee09427fc38c..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/src/cai_mapsat.c +++ /dev/null @@ -1,1080 +0,0 @@ -/*****************************************************************************/ -/* */ -/* PROJET : COUCHE ACCES IMAGE */ -/* ------- */ -/* */ -/* MODULE : cai_mapsat.c */ -/* ------- */ -/* */ -/* ROLE : Ce module rassemble toutes les fonctions d'acces aux images */ -/* ------- stockees au format mapsat */ -/* */ -/* AUTEUR : R.CHAISEMARTIN (CISI) */ -/* ------- */ -/* */ -/* DATE DE CREATION : fevrier 1995 */ -/* ----------------- */ -/* */ -/* LANGAGE : C */ -/* -------- */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -/*---------------------------------------------------------------------------*/ -/* Inclusion des fichiers STANDARDS (.h) */ -/*---------------------------------------------------------------------------*/ - - -# include <stdio.h> -# include <string.h> -# include <sys/types.h> -# include <dirent.h> -# include <sys/stat.h> -# include <fcntl.h> - -#define _CAI_IMAGE -# include "cai_image.h" - -/*----------------------------------------------------------------------------*/ -/* Variable pour la gestion en configuration */ -/*----------------------------------------------------------------------------*/ -static char *rcs_id="$Header: cai_mapsat.c,v 1.4 98/07/21 14:54:07 cmf Exp $"; - -extern char *getenv(); - -/*****************************************************************************/ -/*****************************************************************************/ -/* */ -/* Definition des OPERATIONS EXTERNES */ -/* */ -/*****************************************************************************/ -/*****************************************************************************/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_liste_ima_mapsat */ -/* ---------- */ -/* */ -/* ROLE : fonction de listage des images au format mapsat */ -/* ------ */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : int cai_liste_ima_mapsat (repert,tab_ima) */ -/* ----------------- */ -/* */ -/* repert (E) (char *) : repertoire a explorer */ -/* tab_ima (S) (char ***) : pointeur sur tableau des images listees*/ -/* alloue par la fonction,il doit etre */ -/* LIBERE PAR L'APPELANT */ -/* */ -/* cai_liste_ima_mapsat (S) (int) : = -1 repertoire inexistant */ /* = > 0 nombre d'images listees */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - - -int cai_liste_ima_mapsat (repert, - tab_ima) - -char *repert; -char ***tab_ima; - -{ - DIR *dirp; /* pointeur sur structure ouverture repertoire */ - -struct dirent *dp; /* structure resultat de la fonction readdir */ - - char *pch0,*pch1; /* pointeurs sur chaine de caracteres */ - char *pch2; /* pointeurs sur chaine de caracteres */ - char car; /* variable de travail */ - int nb_ima; /* nombre d'images mapsat identifiees */ - int i; /* indice de boucle */ - - /*........................................ - INITIALISATION et ouverture du repertoire choisi - .........................................*/ - nb_ima=0; - dirp=opendir(repert); - - if(dirp!=NULL) - { - - -/*...................................... - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE MAPSAT - (EXTENSION =.im ou .it) - ..........................................*/ - - while((dp=readdir(dirp))!=NULL) - { - car='.'; - pch0=(char *)strrchr(dp->d_name,car); - if (pch0 != NULL) - { - car='i'; - pch1=(char *)strrchr(dp->d_name,car); - if ((pch1 != NULL)&&(pch1==pch0+1)) - { - car='m'; - pch2=(char *)strrchr(dp->d_name,car); - if ((pch2 != NULL)&&(pch2==pch1+1)) - { - *pch0='\0'; - *pch1=' '; - *pch2=' '; - pch2++; - if (*pch2 == '\0' ) - { - nb_ima=nb_ima+1; - } - } - else - { - car='t'; - pch2=(char *)strrchr(dp->d_name,car); - if ((pch2 != NULL)&&(pch2==pch1+1)) - { - *pch0='\0'; - *pch1=' '; - *pch2=' '; - pch2++; - *pch2='\0'; - nb_ima=nb_ima+1; - } - } - } - } - } - - (void)closedir(dirp); - -/*..................................... - ALLOCATION DU TABLEAU CONTENANT LA LISTE DES IMAGES DU FORMAT MAPSAT - ......................................*/ - *tab_ima = (char **) calloc(nb_ima,sizeof(char *)); - for (i=0;i<nb_ima;i=i+1) - (*tab_ima)[i]=(char *)calloc(1,100); - -/*...................................... - - deuxieme passe pour constituer la liste des images du format donne - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE MAPSAT - (EXTENSION =.im ou .it) - SI C'EST LE CAS STOCKAGE DE L'IMAGE DANS LA LISTE DES IMAGES MAPSAT - ..........................................*/ - dirp=opendir(repert); - - nb_ima=0; - while((dp=readdir(dirp))!=NULL) - { - car='.'; - pch0=(char *)strrchr(dp->d_name,car); - if (pch0 != NULL) - { - car='i'; - pch1=strrchr(dp->d_name,car); - if ((pch1 != NULL)&&(pch1==pch0+1)) - { - car='m'; - pch2=(char *)strrchr(dp->d_name,car); - if ((pch2 != NULL)&&(pch2==pch1+1)) - { - *pch0='\0'; - *pch1=' '; - *pch2=' '; - pch2++; - if (*pch2 == '\0' ) - { - strcpy((*tab_ima)[nb_ima],dp->d_name); - nb_ima=nb_ima+1; - } - } - else - { - car='t'; - pch2=(char *)strrchr(dp->d_name,car); - if ((pch2 != NULL)&&(pch2==pch1+1)) - { - *pch0='\0'; - *pch1=' '; - *pch2=' '; - pch2++; - *pch2='\0'; - strcpy((*tab_ima)[nb_ima],dp->d_name); - nb_ima=nb_ima+1; - } - } - } - } - } - - (void)closedir(dirp); - - } - else - { - /* Erreur:Repertoire inexistant */ - nb_ima=-1; - } - - return(nb_ima); - -} - -/* - Fin de l'operation cai_liste_ima_mapsat -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_lecture_mapsat */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture d'une image au format mapsat */ -/* ----- et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_lecture_mapsat (nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_lecture_mapsat (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ /* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_IMAGE *cai_ouvre_lecture_mapsat(repert, - nom_image, - nb_can, - nboct_pix, - nb_col, - nb_lig) - -char *repert; -char *nom_image; -int *nb_can; -int *nboct_pix; -int *nb_col; -int *nb_lig; -{ - FILE *fic_in; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - int iret; /* indicateur de retour ok ou pas */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char *deb,*deb1; /* pointeurs sur chaine de caracteres */ - char car[4]; /* indice du canal traite */ - int i,fic; /* indice */ - int RVB,MONO; /* indique le nombre de canaux */ - char type_inf[5]; /* type fichier lu dans l'entete */ - char label[64]; /* label lu dans l'entete */ - int lig,col; /* variables intermediaires */ - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - *nb_can=0; - *nb_lig=0; - *nb_col=0; - *nboct_pix=0; - iret=1; - RVB=3; - MONO=1; - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); -/*................................................. - Constitution du nom du fichier MAPSAT .it - et test sur son existence - .................................................*/ - nom_fic[0]='\0'; - if (strlen(repert)!=0) - { - sscanf(repert,"%s",nom_fic); - strcat(nom_fic,"/"); - strcat(nom_fic,nom_image); - strcat(nom_fic,".it"); - nom_fic[strlen(repert)+1+strlen(nom_image)+3]='\0'; - } - else - { - sscanf(nom_image,"%s",nom_fic); - strcat(nom_fic,".it"); - nom_fic[strlen(nom_image)+3]='\0'; - } - fic_in=fopen(nom_fic,"r"); - *nb_can=RVB; - strncpy(car,".it",3); - car[3]='\0'; - if (fic_in==NULL) - { -/*........................................................... - Test sur l'existence du fichier MAPSAT avec extension .im - ..........................................................*/ - nom_fic[0]='\0'; - if (strlen(repert)!=0) - { - sscanf(repert,"%s",nom_fic); - strcat(nom_fic,"/"); - strcat(nom_fic,nom_image); - strcat(nom_fic,".im"); - nom_fic[strlen(repert)+1+strlen(nom_image)+3]='\0'; - } - else - { - sscanf(nom_image,"%s",nom_fic); - strcat(nom_fic,".im"); - nom_fic[strlen(nom_image)+3]='\0'; - } - fic_in=fopen(nom_fic,"r"); - *nb_can=MONO; - car[0]='\0'; - strncpy(car,".im",3); - car[3]='\0'; - if (fic_in==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur Ouverture Fichier MAPSAT"); - return (NULL); - } - } -/*.......................................... - verification que le fichier est de type mapsat - ...................................................*/ - fread(type_inf,4,1,fic_in); -/*... - pour une image trichrome - ......*/ - if (*nb_can==RVB) - { - if (strncmp(type_inf,"ITRI",4) !=0) - { - iret=0; - strcpy(CAI_ERREUR,"l'image n'est pas au format MAPSAT"); - return (NULL); - } - } - -/*..... - pour une image monochrome - .....*/ - if (*nb_can==MONO) - { - if (strncmp(type_inf,"IMON",4) !=0) - { - iret=0; - strcpy(CAI_ERREUR,"l'image n'est pas au format MAPSAT"); - return (NULL); - } - } - -/*..... - positionnement sur les infos a recuperer - .....*/ - fread(label,64,1,fic_in); - fread(nb_lig,4,1,fic_in); - fread(nb_col,4,1,fic_in); - *nboct_pix=1; - image1->NB_BITS_PIX=8; - lig=*nb_lig; - col=*nb_col; -/*....................................... - INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL - .....................................................*/ - fclose (fic_in); - fic=open(nom_fic,O_RDONLY,0); - - deb = image1->NOM_FIC_CAN; - deb1= image1->NOM_UTIL_CAN; - - for (i=0;i<*nb_can;i=i+1) - { - sscanf(nom_image,"%s",deb); - strcat(deb,car); - deb=deb+100; - sscanf(nom_image,"%s",deb1); - strcat(deb1,car); - deb1=deb1+100; - image1->POS_OCTET[i]=col+(i*lig*col); - image1->ACCES_CANAL_INT[i]=fic; - - - } - - - return(image1); - -} - -/* - Fin de l'operation cai_ouvre_lecture_mapsat -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_creation_mapsat */ -/* ---------- */ -/* */ -/* ROLE : fonction de creation et d'ouverture en ecriture d'une image */ -/* ----- au format mapsat et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_creation_mapsat (nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig, */ -/* label) */ -/* */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* nb_can (E) (int ) : nombre de canaux de l'image */ -/* nboct_pix (E) (int ) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (E) (int ) : nombre de lignes de l'image */ -/* nb_col (E) (int ) : nombre de colonnes de l'image */ -/* label (E) (char *) : commentaire lie a l'image */ -/* */ -/* cai_ouvre_creation_mapsat (S) (CAI_IMAGE *) : =NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - - -CAI_IMAGE *cai_ouvre_creation_mapsat(repert, - nom_image, - nb_can, - nboct_pix, - nb_col, - nb_lig, - label) - -char *repert; -char *nom_image; -int *nb_can; -int *nboct_pix; -int *nb_col; -int *nb_lig; -char *label; -{ - FILE *fic; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - char nom_fic[1024]; /* nom du fichier en-tete */ - int retour; /* retour de fonction */ - int i,num; /* indice */ - struct stat buf_stat; /* structure decrivant status de fichier */ - unsigned char *ptr; /* pointeur sur buffer fichier */ - int taille_entete; /* taille de l'entete en octets */ - int pas_echantil; /* pas d'echantillonnage de l'image */ - int taille_buff_label; /* taille en octets du label a ecrire */ - char *buff_label; /* pointeur sur la chaine label a ecrire */ - - - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); - -/*................................................. - Constitution du nom du fichier entete et verification qu'il - n'existe pas deja .Il n'y a qu'un fichier .it si multispectral - .im si monospectral - .................................................*/ - nom_fic[0]='\0'; - if (strlen(repert)!=0) - { - sscanf(repert,"%s",nom_fic); - strcat(nom_fic,"/"); - strcat(nom_fic,nom_image); - if (*nb_can == 1) - strcat(nom_fic,".im"); - else - strcat(nom_fic,".it"); - nom_fic[strlen(repert)+1+strlen(nom_image)+3]='\0'; - } - else - { - sscanf(nom_image,"%s",nom_fic); - if (*nb_can == 1) - strcat(nom_fic,".im"); - else - strcat(nom_fic,".it"); - nom_fic[strlen(nom_image)+3]='\0'; - } - - - retour = stat ( nom_fic , &buf_stat ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "L'image %s MAPSAT existe \n" , nom_image ); - goto ERREUR; - } - -/*************************************************/ -/* determination de la taille de l'entete : */ -/* taille de l'entete = taille d'une ligne, soit */ -/* nb_col et au minimum 128 octets */ -/* ecriture de l'entete */ -/*************************************************/ - - taille_entete = ( *nb_col > 128 )? (*nb_col) : 128; - fic = fopen(nom_fic,"w"); - if (fic == NULL) - { - sprintf(CAI_ERREUR,"Erreur: Creation %s impossible\n",nom_fic); - goto ERREUR; - } - ptr = (unsigned char *) malloc ( taille_entete ); - if ( ptr == NULL ) - { - strcpy ( CAI_ERREUR , "Erreur : probleme d'allocation MAPSAT\n" ); - goto ERREUR; - } - if (*nb_can == 1) - { - memcpy ( ptr , "IMON" , 4 ); - } - else - { - memcpy ( ptr , "ITRI" , 4 ); - } - taille_buff_label = ((int)(strlen(label))+1 > 65 )? - (int)(strlen(label))+1 : 65; - buff_label = (char *) malloc ( taille_buff_label*sizeof(char *) ); - strcpy( buff_label , label ); - for ( i = strlen(label) ; i < 64 ; i++ ) - { - buff_label[i]=' '; - } - buff_label[64]='\0'; - - memcpy ( &ptr[4] , buff_label , 64 ); - memcpy ( &ptr[68] , nb_lig , 4 ); - memcpy ( &ptr[72] , nb_col , 4 ); - memcpy ( &ptr[76] , nb_can , 4 ); - pas_echantil = 0; - memcpy ( &ptr[80] , &pas_echantil , 4 ); - for ( i = 84 ; i < taille_entete - 1 ; i++ ) - { - ptr[i] = 0; - } - - retour = fwrite ( ptr , taille_entete , 1 , fic ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "Erreur : ecriture impossible dans fichier %s\n", - nom_fic ); - goto ERREUR; - } - - fclose ( fic ); - free (ptr); - -/*................................................. - Ouverture du fichier pour ecriture radiometrie - ...................................................*/ - num = open(nom_fic,O_RDWR,0); - if (num == -1) - { - sprintf(CAI_ERREUR,"Erreur: Creation %s impossible\n",nom_fic); - goto ERREUR; - } - for (i=0;i<*nb_can;i=i+1) - { - image1->ACCES_CANAL_INT[i]=num; - image1->POS_OCTET[i]=taille_entete; - } - - return (image1); - -ERREUR : - return(NULL); -} - /* - Fin de l'operation cai_ouvre_creation_mapsat -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_lecture_canal_mapsat */ -/* ---------- */ -/* */ -/* ROLE : fonction de lecture d'un canal d'une image mapsat */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_lecture_canal_mapsat(image1, canal, */ /* ------------------ premiere_ligne, */ -/* premiere_colonne, */ -/* nombre_lignes_lire , */ -/* nombre_colonnes_lire, */ -/* pas_ligne ,pas_colonne, */ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a lire */ -/* premiere_ligne (E) (int) : premiere ligne a lire dans l'image */ -/* premiere _colonne (E) (int) : premiere colonne a lire dans l'image */ -/* nombre_lignes_lire (E) (int) : nombre de lignes a lire */ -/* nombre_colonnes_lire (E) (int) : nombre de colonnes a lire */ -/* pas_ligne (E) (int) : pas en ligne */ -/* pas_colonne (E) (int) : pas en colonne */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels lus alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_lecture_canal_mapsat (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - CAI_OK_KO cai_lecture_canal_mapsat(image1 , - canal , - premiere_ligne , - premiere_colonne, - nombre_lignes_lire , - nombre_colonnes_lire, - pas_ligne , - pas_colonne, - data_image ) -CAI_IMAGE *image1; -int *canal ; -int *premiere_ligne ; -int *premiere_colonne ; -int *nombre_lignes_lire ; -int *nombre_colonnes_lire; -int *pas_ligne ; -int *pas_colonne; -unsigned char *data_image; - -{ - - int num,i,j,n; /* variables de travail */ - int pt_oct; /* position courante dans le fichier image */ - int no_oct; /* numero du premier octet a lire */ - int iret; /* indicateur d'erreur */ - int lig; /* indice de boucle sur les lignes */ - int oct_pix; /* nb octets par pixels */ - long nb_oct; /* nb oct =1er octet a lire - position courante */ - long oct_lig; /* nb oct. par ligne en considerant taille pixel */ - unsigned char *buf_lec; /* buffer lecture d'une ligne */ - unsigned char *deb,*pch; /* pointeur chaine pour transfert buffer sortie */ - -/*........................... - Initialisations diverses - ..........................*/ - iret=CAI_OK; - num=image1->ACCES_CANAL_INT[*canal-1]; - oct_pix=image1->NBOCT_PIX; - oct_lig=oct_pix*image1->NB_COL; - lig=*premiere_ligne; - i=1; - pch=data_image; - -/*.............................................. - allocation de memoire pour lire une ligne image - ............................................. */ - - buf_lec = (unsigned char *) malloc(oct_lig); - if (buf_lec == NULL) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Probleme allocation memoire"); - } - else - { - -/*..................... - Pour chaque ligne a lire - .......................................*/ - while ((i <= *nombre_lignes_lire)&&(iret==CAI_OK)) - { -/*............................................ - Recherche de la position courante dans le fichier - ............................................*/ - pt_oct=lseek(num,0L,1); - -/*................................ - Calcul du numero du 1er octet a lire - ....................................*/ - no_oct=image1->POS_OCTET[*canal-1]+(lig-1)*image1->NB_COL; - -/*.................................. - Saut d'octets pour etre positionne sur la ligne a lire - .......................................*/ - nb_oct=(long)(no_oct-pt_oct); - lseek(num,nb_oct,1); - -/*........................................... - lecture d'une ligne image - ................................................*/ - n=read(num,buf_lec,image1->NB_COL); - - if (n<=0) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Erreur lecture donnee image mapsat"); - } - else - { -/*...................................... - Sauvegarde des donnees lues entenant compte du pas - d'echantillonnage en colonne - ........................................*/ - deb=buf_lec+(*premiere_colonne)-1; - j=1; - while (j <= *nombre_colonnes_lire) - { - *pch=*deb; - pch=pch+1; - j=j+1; - deb=deb+(*pas_colonne); - } - - } - i=i+1; - lig=lig+(*pas_ligne); - - } - - free(buf_lec); - } - return(iret); -} - -/* - Fin de l'operation cai_lecture_canal_mapsat -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ecriture_canal_mapsat */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ecriture d'un canal d'une image mapsat */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ecriture_canal_mapsat (image1, canal, */ /* ------------------ premiere_ligne, */ -/* nombre_lignes_ecrire, */ -/* nombre_colonnes_ecrire,*/ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a ecrire */ -/* premiere_ligne (E) (int) : premiere ligne a ecrire ds l'image */ -/* nombre_lignes_ecrire (E) (int) : nombre de lignes a ecrire */ -/* nombre_colonnes_ecrire(E) (int) : nombre de lignes a ecrire */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels ecris alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_ecriture_canal_mapsat (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - - -CAI_OK_KO cai_ecriture_canal_mapsat (image1 , - canal , - premiere_ligne , - nombre_lignes_ecrire , - nombre_colonnes_ecrire, - data_image ) -CAI_IMAGE *image1; -int *canal ; -int *premiere_ligne ; -int *nombre_lignes_ecrire ; -int *nombre_colonnes_ecrire; -unsigned char *data_image; - -{ - -long position_first_lig; /* position de la 1ere ligne a ecrire */ -long position_courante; /* position courante dans le fichier */ -long deplacement; /* deplacement a effectuer */ -int i_ligne; /* compteur de lignes */ -unsigned char *buff_lig; /* tableau contenant une ligne a ecrire */ -int cr_write; /* code retour de write */ -int num; /* descripteur de fichier */ -int nboct_pix; /* nombre d'octets par pixel */ - -/*............... - Initialisations - ................*/ - -i_ligne = 0; -num = image1->ACCES_CANAL_INT[*canal-1]; -nboct_pix = image1->NBOCT_PIX; - - -/*************************************************/ -/* Les donnees doivent etre codees sur 8 bits */ -/*************************************************/ - -if ( nboct_pix != 1 ) -{ - strcpy ( CAI_ERREUR , "Erreur : les donnees doivent etre codees sur 8 bits\n"); - goto ERREUR; -} - - -/********************************************************/ -/* Calcul de la position de la premiere ligne a ecrire */ -/********************************************************/ - -position_first_lig = (long) ( image1->POS_OCTET[*canal-1] + - (*canal - 1) * image1->NB_LIG* (*nombre_colonnes_ecrire) - + ((*premiere_ligne) - 1) * (*nombre_colonnes_ecrire) ); - - -/********************************************************/ -/* Recuperation de la position courante */ -/********************************************************/ - -position_courante = lseek ( num , 0L , 1 ); - - -/********************************************************/ -/* Deplacement jusqu'a la premiere ligne a ecrire */ -/********************************************************/ - -deplacement = position_first_lig - position_courante; -lseek ( num , deplacement , 1 ); - - -/********************************************************/ -/* TANT QUE il y a des lignes a ecrire */ -/********************************************************/ -while (i_ligne < *nombre_lignes_ecrire) -{ - -/********************************************************/ -/* extraction de la ligne du tableau */ -/********************************************************/ - - buff_lig = data_image + (*nombre_colonnes_ecrire) * i_ligne; - -/********************************************************/ -/* ecriture de la ligne */ -/********************************************************/ - - cr_write = write ( num , buff_lig , (*nombre_colonnes_ecrire) ); - if ( cr_write != (*nombre_colonnes_ecrire) ) - { - strcpy ( CAI_ERREUR , "Erreur ecriture canal image mapsat\n" ); - goto ERREUR; - } - -/********************************************************/ -/* incrementation du nombre de lignes */ -/********************************************************/ - - i_ligne++; - -/********************************************************/ -/* FIN TANT QUE */ -/********************************************************/ -} - - -return (CAI_OK); - -ERREUR : - -return (CAI_KO); - - -} - -/* - Fin de l'operation cai_ecriture_canal_mapsat -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ferme_mapsat */ -/* ---------- */ -/* */ -/* ROLE : fonction de fermeture d'une image au format mapsat et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ferme_mapsat (image1) */ /* ------------------ */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* */ -/* cai_ferme_mapsat (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_OK_KO cai_ferme_mapsat (image1) - -CAI_IMAGE *image1; - -{ - int iret; /* code retour de l'operation */ - int num; /* descripteur du fichier a fermer */ - - iret=CAI_OK; -/*............................................. - Fermeture de tous les canaux qui sont tous contenus - dans un seul fichier .im ou .it suivant le nb de canaux - .............................................*/ - - - num=image1->ACCES_CANAL_INT[0]; - close(num); - - - return (iret); -} - -/* - Fin de l'operation cai_ferme_mapsat -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_dest_ima_mapsat */ -/* ---------- */ -/* */ -/* ROLE : fonction de destruction d'une image stocke en mapsat et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_dest_ima_mapsat (format,nom_ima) */ /* ------------------ */ -/* format (E) (char *) : format de l'image a detruire */ -/* nom_image (E) (char *) : nom de l'image a detruire avec repertoire */ -/* */ -/* cai_dest_ima_mapsat (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_OK_KO cai_dest_ima_mapsat ( repertoire , - nom_ima ) - -char *repertoire; /* repertoire de stockage de l'image */ -char *nom_ima; /* nom de l'image */ - -{ -int iret; /* code retour fonction fermetrue lecture */ -char nom_fic[1024]; /* nom du fichier entete a detruire */ -char nom_ima_complet[1024]; /* repertoire + nom de l'image */ - -CAI_IMAGE *image1; /* structure ouverture image */ -int nb_can; /* nombre de canaux de l'image */ -int nboct_pix; /* nombre d'octets par pixel image */ -int nb_col; /* nombre de colonnes de l'image */ -int nb_lig; /* nombre de lignes de l'image */ - -/************************************************/ -/* Constitution du nom du fichier */ -/************************************************/ -if (strlen(repertoire)!= 0) -{ - strcpy ( nom_ima_complet , repertoire ); - strcat ( nom_ima_complet, "/" ); - strcat ( nom_ima_complet , nom_ima ); -} -else -{ - strcpy ( nom_ima_complet , nom_ima); -} - -/************************************************/ -/* Extraction des caracteristiques de l'image */ -/* du fichier entete par l'appel a la fonction */ -/* cai_ouvre_lecture_mapsat */ -/************************************************/ - - image1 = cai_ouvre_lecture_mapsat (repertoire, nom_ima, &nb_can ,&nboct_pix , - &nb_col , &nb_lig); - if ( image1 == NULL) goto ERREUR; - - image1->NB_CANAUX=nb_can; - image1->NB_COL=nb_col; - image1->NB_LIG=nb_lig; - image1->NBOCT_PIX=nboct_pix; - - iret=cai_ferme_mapsat(image1); - -/************************************************/ -/* constitution du fichier + extension en */ -/* fonction du nombre de canaux */ -/************************************************/ - nom_fic[0]='\0'; - strcpy(nom_fic,nom_ima_complet); - if (nb_can == 1) - { - strcat ( nom_fic , ".im" ); - nom_fic[strlen(nom_ima_complet)+3]='\0'; - } - else - { - strcat ( nom_fic , ".it" ); - nom_fic[strlen(nom_ima_complet)+3]='\0'; - } - - -/************************************************/ -/* Destruction du fichier image */ -/************************************************/ - - unlink ( nom_fic ); - - - return (CAI_OK); - -ERREUR: - -return (CAI_KO); - - -} -/* - Fin de l'operation cai_dest_ima_mapsat -*/ diff --git a/Utilities/CAI/cai_dll/src/cai_multis.c b/Utilities/CAI/cai_dll/src/cai_multis.c deleted file mode 100755 index a9d80866ef50324892e79d1492355ef9217bbb6c..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/src/cai_multis.c +++ /dev/null @@ -1,1985 +0,0 @@ -/*****************************************************************************/ -/* */ -/* PROJET : COUCHE ACCES IMAGE */ -/* ------- */ -/* */ -/* MODULE : cai_multis.c */ -/* ------- */ -/* */ -/* ROLE : Ce module rassemble toutes les fonctions d'acces aux images */ -/* ------- stockees au format multiscope */ -/* */ -/* AUTEUR : R.CHAISEMARTIN (CISI) */ -/* ------- */ -/* */ -/* DATE DE CREATION : fevrier 1995 */ -/* ----------------- */ -/* */ -/* LANGAGE : C */ -/* -------- */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : FA : modifications pour compatibilite HP64bits */ -/*****************************************************************************/ - -/*---------------------------------------------------------------------------*/ -/* Inclusion des fichiers STANDARDS (.h) */ -/*---------------------------------------------------------------------------*/ - - -# include <stdio.h> -# include <string.h> -# include <stdlib.h> -# include <ctype.h> -# include <unistd.h> -# include <sys/types.h> -#include <dirent.h> -# include <sys/stat.h> -# include <fcntl.h> - -#define _CAI_IMAGE -# include "cai_image.h" - -/*----------------------------------------------------------------------------*/ -/* Variable pour la gestion en configuration */ -/*----------------------------------------------------------------------------*/ -static char *rcs_id="$Header: cai_multis.c,v 1.8 01/05/31 10:47:08 cmf Exp $"; - - -extern char *getenv(); - - -static void inverser (char * s , int nboct ); -static void calculer_histo(CAI_IMAGE *image1, unsigned char *buffer , - int nb_pix , int canal ); - -/*****************************************************************************/ -/*****************************************************************************/ -/* */ -/* Definition des OPERATIONS EXTERNES */ -/* */ -/*****************************************************************************/ -/*****************************************************************************/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_liste_ima_multis */ -/* ---------- */ -/* */ -/* ROLE : fonction de listage des images au format multiscope */ -/* ------ */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : int cai_liste_ima_multis (repert,tab_ima) */ -/* ----------------- */ -/* */ -/* repert (E) (char *) : repertoire a explorer */ -/* tab_ima (S) (char ***) : pointeur sur tableau des images listees*/ -/* alloue par la fonction,il doit etre */ -/* LIBERE PAR L'APPELANT */ -/* */ -/* cai_liste_ima_multis (S) (int) : = -1 repertoire inexistant */ /* = > 0 nombre d'images listees */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -long int cai_liste_ima_multis (char *repert, - char ***tab_ima) - - -{ - DIR *dirp; /* pointeur sur structure ouverture repertoire */ - -struct dirent *dp; /* structure resultat de la fonction readdir */ - - char *pch0,*pch1; /* pointeurs sur chaine de caracteres */ - char *pch2,*pch3; /* pointeurs sur chaine de caracteres */ - char car; /* variable de travail */ - int nb_ima; /* nombre d'images multiscope identifiees */ - int i; /* indice de boucle */ - -/*........................................ - INITIALISATION et ouverture du repertoire choisi - .........................................*/ - nb_ima=0; - - dirp=opendir(repert); - - if(dirp!=NULL) - { - -/*...................................... - - premiere passe pour comptabiliser les images du format donne - - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE MULTISCOPE - (EXTENSION =.img) - ..........................................*/ - - - while((dp=readdir(dirp))!=NULL) - { - - car='.'; - pch0=strrchr(dp->d_name,car); - if (pch0 != NULL) - { - car='i'; - pch1=strrchr(dp->d_name,car); - if ((pch1 != NULL)&&(pch1==pch0+1)) - { - car='m'; - pch2=strrchr(dp->d_name,car); - if ((pch2 != NULL)&&(pch2==pch1+1)) - { - car='g'; - pch3=strrchr(dp->d_name,car); - if ((pch3 != NULL)&&(pch3==pch2+1)) - { - *pch0='\0'; - *pch1=' '; - *pch2=' '; - *pch3=' '; - nb_ima=nb_ima+1; - } - } - } - } - } - - (void)closedir(dirp); -/*..................................... - ALLOCATION DU TABLEAU CONTENANT LA LISTE DES IMAGES DU FORMAT MULTISCOPE - ......................................*/ - *tab_ima = (char **) calloc(nb_ima,sizeof(char *)); - for (i=0;i<nb_ima;i=i+1) - (*tab_ima)[i]=(char *)calloc(1,100); - -/*...................................... - - deuxieme passe pour constituer la liste des images du format donne - - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE MULTISCOPE - (EXTENSION =.img) - SI C`EST LE CAS,STOCKAGE DANS LA LISTE - ..........................................*/ - dirp=opendir(repert); - - nb_ima=0; - while((dp=readdir(dirp))!=NULL) - { - - car='.'; - pch0=strrchr(dp->d_name,car); - if (pch0 != NULL) - { - car='i'; - pch1=strrchr(dp->d_name,car); - if ((pch1 != NULL)&&(pch1==pch0+1)) - { - car='m'; - pch2=strrchr(dp->d_name,car); - if ((pch2 != NULL)&&(pch2==pch1+1)) - { - car='g'; - pch3=strrchr(dp->d_name,car); - if ((pch3 != NULL)&&(pch3==pch2+1)) - { - *pch0='\0'; - *pch1=' '; - *pch2=' '; - *pch3=' '; - strcpy((*tab_ima)[nb_ima],dp->d_name); - nb_ima=nb_ima+1; - } - } - } - } - } - - (void)closedir(dirp); - - - } - else - { - /* Repertoire inexistant */ - nb_ima=-1; - } - return(nb_ima); - -} - -/* Fin de l'operation cai_liste_ima_multis -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_lecture_multis */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture d'une image au format multiscope */ -/* ----- et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_lecture_multis (nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_lecture_multis (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ /* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_IMAGE *cai_ouvre_lecture_multis(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) - -{ - FILE *fic; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - int iret; /* indicateur de retour ok ou pas */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char nom_fic_canal[1024]; /* nom du fichier canal */ - char nom_util_canal[1024]; /* nom du fichier utilisateur */ - char *deb,*deb1; /* pointeurs sur chaine de caracteres */ - int num,retour,lon; /* variables de travail */ - short int type,fin; /* variables de trvail */ - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - - *nb_lig=0; - *nb_col=0; - *nboct_pix=0; - *nb_can=0; - iret=1; - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); - -/*................................................. - Constitution du nom du fichier entete - .................................................*/ - nom_fic[0]='\0'; - if ((long int)strlen(repert)!=0) - { - sscanf(repert,"%s",nom_fic); - strcat(nom_fic,"/"); - strcat(nom_fic,nom_image); - strcat(nom_fic,".img"); - nom_fic[strlen(repert)+1+strlen(nom_image)+4]='\0'; - } - else - { - sscanf(nom_image,"%s",nom_fic); - strcat(nom_fic,".img"); - nom_fic[strlen(nom_image)+4]='\0'; - } - -/*........................ - Ouverture du fichier entete - ..........................................*/ - fic=fopen(nom_fic,"rb"); - if (fic == NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur ouverture fichier entete MULTISCOPE"); - } - else - { - -/*.................................... - positionnement sur le nombre de colonnes -*/ - fseek(fic,8,0); -/* - recuperation du nombre de colonnes */ - fread(nb_col,4,1,fic); -/* - inversion des octets pour compatibilite SUN */ - lon=sizeof(*nb_col)-1; - inverser((char *)nb_col,lon); - -/*.................................... - recuperation du nombre de lignes -*/ - fread(nb_lig,4,1,fic); -/* - inversion des octets pour compatibilite SUN */ - lon=sizeof(*nb_lig)-1; - inverser((char *)nb_lig,lon); - -/*...................................... - initialisation du nombre d'octets par pixel -*/ - *nboct_pix=1; - image1->NB_BITS_PIX=8; - sprintf(image1->COD_PIX,"OCT"); -/*................................. - positionnement sur le premier objet -*/ - fseek(fic,114,1); - retour=0; - deb = image1->NOM_FIC_CAN; - deb1= image1->NOM_UTIL_CAN; - - - while (retour == 0) - { -/*...........Recuperation de tous les objets jusqu'a l'eof - nom fichier,nom utilisateur et type de l'objet(avec inversion) -*/ - fread(nom_fic_canal,14,1,fic); - fread(nom_util_canal,40,1,fic); - fread(&type,2,1,fic); - lon=sizeof(type)-1; - inverser((char *)&type,lon); - if (type == 3) - { -/*....................................... - Initialisation des tableaux contenant le nom de fichier - et le nom utilisateur de chaque canal - .....................................................*/ - - - if (*nb_can<CAI_NB_MAX_CAN) - { - nom_fic_canal[0] = tolower(nom_fic_canal[0]); - nom_fic_canal[1] = tolower(nom_fic_canal[1]); - nom_fic_canal[2] = tolower(nom_fic_canal[2]); - nom_fic_canal[9] = tolower(nom_fic_canal[9]); - nom_fic_canal[10] = tolower(nom_fic_canal[10]); - nom_fic_canal[11] = tolower(nom_fic_canal[11]); - nom_fic[0]='\0'; - if ((long int)strlen(repert) != 0) - { - sscanf(repert,"%s",nom_fic); - strcat(nom_fic,"/"); - strcat(nom_fic,nom_fic_canal); - nom_fic[strlen(repert)+1+strlen(nom_fic_canal)]='\0'; - } - else - { - sscanf(nom_fic_canal,"%s",nom_fic); - nom_fic[strlen(nom_fic_canal)]='\0'; - } - sscanf(nom_fic_canal,"%s",deb); - deb=deb+100; - sscanf(nom_util_canal,"%s",deb1); - deb1=deb1+100; - - num=open(nom_fic,O_RDONLY,0); - if (num==-1) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur ouverture fi canal Multiscope"); - } - else - { - image1->ACCES_CANAL_INT[*nb_can]=num; - image1->POS_OCTET[*nb_can]=1280; - image1->NB_PIX_ECRITS[*nb_can]=0; - } - - } - *nb_can=*nb_can+1; - } - -/*............Positionnement en fin de bloc */ - fseek(fic,70,1); -/* - ............Test fin de fichier */ - fread(&fin,2,1,fic); - retour=feof(fic); - } -/*.................................. - Fermeture du fichier - ......................................*/ - fclose(fic); - } - - - if (iret != 0) - return (image1); - else - return(NULL); - -} - -/* - Fin de l'operation cai_ouvre_lecture_multis -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_creation_multis */ -/* ---------- */ -/* */ -/* ROLE : fonction de creation et d'ouverture en ecriture d'une image */ -/* ----- au format multiscope et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_creation_multis (nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig, */ -/* label) */ -/* */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* nb_can (E) (int ) : nombre de canaux de l'image */ -/* nboct_pix (E) (int ) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (E) (int ) : nombre de lignes de l'image */ -/* nb_col (E) (int ) : nombre de colonnes de l'image */ -/* label (E) (char *) : commentaire lie a l'image */ -/* */ -/* cai_ouvre_creation_multis (S) (CAI_IMAGE *) : =NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - - -CAI_IMAGE *cai_ouvre_creation_multis(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig, - char *label) - -{ - FILE *fic; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char fichier[1024]; /* variable intermediaire */ - char nom_fic_canal[1024]; /* nom fichier canal dont on teste existence*/ - long int retour; /* retour de fonction */ - char car3[3],car6[6]; /* indice du canal traite */ - int i,num,numero_fic; /* indice */ - struct stat buf_stat; /* structure decrivant status de fichier */ - unsigned char *buff ; /* buffer a ecrire */ - int taille,nb; /* variables de travail sur taille fichier */ - char *deb; /* pointeur sur chaine pour transfert */ - int col_pix_1; /* colonne du premier pixel */ - int lig_pix_1; /* ligne du premier pixel */ - char *nom_fic_carac; /* nom relatif du fichier caracteristiques */ - long int taille_nom_dos_vue; /* taille de fichier */ - char *nom_dos_vue; /* nom DOS de la vue */ - long int taille_nom_dos_ima; /* taille de fichier */ - char *nom_dos_ima; /* nom DOS de l'image */ - int flag_sauvegarde; /* flag de sauvegarde */ - char *nom_dos_obj; /* nom DOS de l'objet */ - char nom_util[100+1]; /* intitule ou nom utilisateur */ - int flag_suppression; /* flag de suppression */ - int type_obj; /* type de l'objet */ - int version; /* version */ - int filler; /* filler */ - int dim_bloc; /* dimension d'un bloc */ - int presence_histo; /* indicateur de presence des histogrammes */ - int int_tempo; /* entier utilise pour inversion d'octets */ - int lon; /* longueur de l'entier - 1 */ - int i_can; /* indice de boucle sur les canaux */ - long li; - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); - -/*................................................. - Constitution du nom du fichier entete et verification qu'il - n'existe pas deja - .................................................*/ - nom_fic[0]='\0'; - if ((long int)strlen(repert)!=0) - { - sscanf(repert,"%s",nom_fic); - strcat(nom_fic,"/"); - strcat(nom_fic,nom_image); - strcat(nom_fic,".img"); - nom_fic[strlen(repert)+1+strlen(nom_image)+4]='\0'; - } - else - { - sscanf(nom_image,"%s",nom_fic); - strcat(nom_fic,".img"); - nom_fic[strlen(nom_image)+4]='\0'; - } - retour = stat ( nom_fic , &buf_stat ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "L'image %s MULTISCOPE existe \n" , nom_image ); - goto ERREUR; - } - -/*............................................................... - Pour chaque canal de l'image,constitution du nom de fichier correspondant - Verification qu'il n'existe pas deja - Ouverture du fichier en ecriture - .................................................................*/ - - deb =(char *) image1->NOM_FIC_CAN; - i=0; - numero_fic=0; - while ((i<*nb_can)&& (numero_fic<10000)) - { - nom_fic_canal[0]='\0'; - fichier[0]='\0'; - sprintf ( car6 , "%05d" , numero_fic ); - strcat ( fichier,"fdo"); - strcat ( fichier , car6); - strcat ( fichier , ".per" ); - fichier[strlen(car6)+7]='\0'; - - if ((long int)strlen(repert) != 0) - { - sscanf(repert,"%s",nom_fic_canal); - strcat(nom_fic_canal,"/fdo"); - strcat ( nom_fic_canal , car6 ); - strcat ( nom_fic_canal , ".per" ); - nom_fic_canal[strlen(repert)+4+strlen(car6)+4]='\0'; - } - else - { - sscanf(fichier,"%s",nom_fic_canal); - nom_fic_canal[strlen(car6)+7]='\0'; - } - retour = stat ( nom_fic_canal , &buf_stat ); - if ( retour != 0 ) /* si ce fichier n'existe pas il peut etre creer */ - { - sscanf(fichier,"%s",deb); - i=i+1; - deb=deb+100; - } - numero_fic=numero_fic+1; - - } - -/*.................................................................. - ecriture du fichier img et de l'entete des fichiers canaux - .................................................................*/ - fic = fopen(nom_fic,"w"); - if ( fic == NULL ) - { - sprintf ( CAI_ERREUR , "Creation image multiscope impossible \n" , - nom_image ); - goto ERREUR; - } -/* la taille du fichier entete doit etre multiple de 512 */ - taille = 128*(1+(*nb_can)); - nb=taille; - if ( taille % 512 == 0 ) - taille = taille; - else - taille = taille - (taille%512) + 512; - - -/*************************************************/ -/* Ecriture des enregistrements d'entete et de */ -/* description des objets : */ -/* 128 + n*128 octets avec n = nombre d'objets */ -/*************************************************/ - -/*************************************************/ -/* ecriture de l'enregistrement d'entete */ -/*************************************************/ - buff = (unsigned char *) calloc ( 128,sizeof(unsigned char) ); - if ( buff == NULL ) - { - sprintf ( CAI_ERREUR , "Erreur : probleme d'allocation \n" ); - unlink(nom_fic); - goto ERREUR; - } - - col_pix_1 = 0; - int_tempo = col_pix_1; - lon = sizeof(int_tempo)-1; - inverser((char *)&int_tempo,lon); - memcpy ( buff , &int_tempo , 4 ); - - lig_pix_1 = 0; - int_tempo = lig_pix_1; - lon = sizeof(int_tempo)-1; - inverser((char *)&int_tempo,lon); - memcpy ( &buff[4] , &int_tempo , 4 ); - - int_tempo = (*nb_col); - lon = sizeof(int_tempo)-1; - inverser((char *)&int_tempo,lon); - memcpy ( &buff[8] , &int_tempo , 4 ); - - int_tempo = (*nb_lig); - lon = sizeof(int_tempo)-1; - inverser((char *)&int_tempo,lon); - memcpy ( &buff[12] , &int_tempo , 4 ); -/* construction du nom relatif du fichier */ -/* caracteristiques : nom_image.img */ - nom_fic_carac = (char *) strrchr ( nom_fic , '/' ) + 1; - - - taille_nom_dos_vue = - ( (long int)(strlen(nom_fic_carac))-3 > 15 )? - (long int)(strlen(nom_fic_carac))-3 : 15; - nom_dos_vue = (char *) malloc ( taille_nom_dos_vue*sizeof(char *) ); - strncpy ( nom_dos_vue , nom_fic_carac , strlen(nom_fic_carac)-4 ); - for ( li = (long int)(strlen(nom_fic_carac)-4) ; li < 14 ; li++ ) - { - nom_dos_vue[li]=' '; - } - nom_dos_vue[14]='\0'; - /* passage en majuscules */ - for ( i = 0 ; i < 14 ; i++ ) - { - nom_dos_vue[i] = toupper(nom_dos_vue[i]); - } -/* memcpy ( &buff[16] , nom_dos_vue , 14 ); */ - - - taille_nom_dos_ima = - ( (long int)(strlen(nom_fic_carac))-3 > 15 )? - (long int)(strlen(nom_fic_carac))-3 : 15; - nom_dos_ima = (char *) malloc ( taille_nom_dos_ima*sizeof(char *) ); - strncpy ( nom_dos_ima , nom_fic_carac , strlen(nom_fic_carac)-4 ); - nom_dos_ima[strlen(nom_fic_carac)-4]='\0'; - /* le nom DOS de l'image ne doit pas depasser 10 caracteres */ - if ( (long int)(strlen(nom_dos_ima)) > 10 ) - nom_dos_ima[10]='\0'; - /* passage en majuscule */ - for ( li = 0 ; li < (long int)(strlen(nom_dos_ima)) ; li++ ) - { - nom_dos_ima[li] = toupper(nom_dos_ima[li]); - } - li = (long int)strlen(nom_dos_ima)+1 ; - memcpy ( &buff[30] , nom_dos_ima , li); - -/* memcpy ( &buff[30+li] , "IMG" , 3 ); - for ( li = 30+(long int)strlen(nom_dos_ima)+1+3 ; li < 44 ; li++ ) - { - buff[li] = 0; - }*/ - - flag_sauvegarde = 0; - int_tempo = flag_sauvegarde; - lon = sizeof(int_tempo)-1; - inverser((char *)&int_tempo,lon); - memcpy ( &buff[44] , &int_tempo , 2 ); - -/* for ( i = 46 ; i < 128 ; i++ ) - { - buff[i] = 0; - }*/ - if ((*nb_can)==1) - buff[46]='I'; - retour = fwrite ( buff , 128 , 1 , fic ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR ,"Ecriture impossible dans fichier %s\n" ,nom_fic); - unlink(nom_fic); - goto ERREUR; - } - free ( nom_dos_vue ); - free ( nom_dos_ima ); - free ( buff ); - -/*************************************************/ -/* POUR chacun des objets */ -/*************************************************/ - deb=image1->NOM_FIC_CAN; - for ( i_can= 0 ; i_can< *nb_can ; i_can++ ) - { - - - buff = (unsigned char *) calloc ( 128,sizeof(unsigned char) ); - if ( buff == NULL ) - { - sprintf ( CAI_ERREUR , "Erreur : probleme d'allocation \n" ); - unlink(nom_fic); - goto ERREUR; - } - -/*************************************************/ -/* ecriture de la description de l'objet */ -/*************************************************/ - - flag_suppression = 1; - int_tempo = flag_suppression; - lon = sizeof(int_tempo)-1; - inverser((char *)&int_tempo,lon); - memcpy ( buff , &int_tempo , 2 ); - - - nom_fic_canal[0]='\0'; - sscanf(deb,"%s",nom_fic_canal); - deb=deb+100; - nom_dos_obj = (char *) calloc ( 15,sizeof(char *) ); - strcpy ( nom_dos_obj , nom_fic_canal ); - for ( li = (long int)strlen(nom_fic_canal) ; li < 14 ; li++ ) - { - nom_dos_obj[li]='\0'; - } - nom_dos_obj[14]='\0'; - nom_dos_obj[0] = toupper(nom_dos_obj[0]); - nom_dos_obj[1] = toupper(nom_dos_obj[1]); - nom_dos_obj[2] = toupper(nom_dos_obj[2]); - nom_dos_obj[9] = toupper(nom_dos_obj[9]); - nom_dos_obj[10] = toupper(nom_dos_obj[10]); - nom_dos_obj[11] = toupper(nom_dos_obj[11]); - memcpy ( &buff[2] , nom_dos_obj , 14 ); - - for ( i = 6 ; i < 40 ; i++ ) - { - nom_util[i]='\0'; - } - nom_util[40]='\0'; - sprintf(nom_util,"CANAL/PLAN%d",i_can+1); - memcpy ( &buff[16] , nom_util , 40 ); - - type_obj = 3; - int_tempo = type_obj; - lon = sizeof(int_tempo)-1; - inverser((char *)&int_tempo,lon); - memcpy ( &buff[56] , &int_tempo , 2 ); - - memcpy ( &buff[58] , "01-04-01 10:10" , 14 ); - - for ( i = 72 ; i < 128 ; i++ ) - { - buff[i] = 0; - } - - retour = fwrite ( buff , 128 , 1 , fic ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR ,"Ecriture impossible dans fichier %s\n" ,nom_fic); - unlink(nom_fic); - goto ERREUR; - } - free(buff); -/*.......................................................... - Ecriture de 0 jusqu'a la taille du fichier - .........................................................*/ - if (nb != taille) - { - buff = (unsigned char *) calloc ( taille-nb,sizeof(unsigned char) ); - if ( buff == NULL ) - { - sprintf ( CAI_ERREUR , "Erreur : probleme d'allocation \n" ); - unlink(nom_fic); - goto ERREUR; - } - retour = fwrite ( buff , taille-nb , 1 , fic ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR ,"Ecriture impossible dans fichier %s\n" ,nom_fic); - unlink(nom_fic); - goto ERREUR; - } - free(buff); - } - } - fclose(fic); - - /*************************************************/ - /* POUR chacun des fichiers canaux */ - /*************************************************/ - deb=image1->NOM_FIC_CAN; - for ( i_can = 0 ; i_can< *nb_can ; i_can++ ) - { - -/*************************************************/ -/* ouverture du fichier */ -/*************************************************/ - fichier[0]='\0'; - if ((long int)strlen(repert)!=0) - { - sscanf(repert,"%s",fichier); - strcat(fichier,"/"); - strcat(fichier,deb); - } - else - { - sscanf(deb,"%s",fichier); - } - deb=deb+100; - - fic = fopen ( fichier , "w" ); - if ( fic == NULL ) - { - sprintf ( CAI_ERREUR , "Erreur : ouverture fichier %s impossible \n", - fichier); - goto ERREUR ; - } - - -/*************************************************/ -/* ecriture de l'enregistrement d'entete */ -/* du filler et des enregistrements */ -/* histogrammes */ -/* 24 + 232 + 4*256 octets */ -/*************************************************/ - -/*************************************************/ -/* ecriture de l'enregistrement d'entete */ -/*************************************************/ - - buff = (unsigned char *) calloc ( 24 ,sizeof(unsigned char)); - if ( buff == NULL ) - { - strcpy ( CAI_ERREUR , "Erreur : probleme d'allocation\n" ); - goto ERREUR; - } - - version = 1; - int_tempo = version; - lon = sizeof(int_tempo)-1; - inverser((char *)&int_tempo,lon); - memcpy ( buff , &int_tempo , 2 ); - - type_obj = 3; - int_tempo = type_obj; - lon = sizeof(int_tempo)-1; - inverser((char *)&int_tempo,lon); - memcpy ( &buff[2] , &int_tempo , 2 ); - -/* memcpy ( &buff[4] , "*CAI**" , 6 ); */ - - filler = 0; - int_tempo = filler; - lon = sizeof(int_tempo)-1; - inverser((char *)&int_tempo,lon); - memcpy ( &buff[10] , &int_tempo , 2 ); - - dim_bloc = 16; - int_tempo = dim_bloc; - lon = sizeof(int_tempo)-1; - inverser((char *)&int_tempo,lon); - memcpy ( &buff[12] , &int_tempo , 2 ); - - int_tempo = (*nb_lig); - lon = sizeof(int_tempo)-1; - inverser((char *)&int_tempo,lon); - memcpy ( &buff[14] , &int_tempo , 4 ); - - int_tempo = (*nb_col); - lon = sizeof(int_tempo)-1; - inverser((char *)&int_tempo,lon); - memcpy ( &buff[18] , &int_tempo , 4 ); - - presence_histo = 0; - int_tempo = presence_histo; - lon = sizeof(int_tempo)-1; - inverser((char *)&int_tempo,lon); - memcpy ( &buff[22] , &int_tempo , 2 ); - retour = fwrite ( buff , 24 , 1 , fic ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "Erreur : ecriture impossible dans fichier %s\n", fichier ); - goto ERREUR; - } - - free ( buff ); - - -/*************************************************/ -/* ecriture du filler a 0 */ -/*************************************************/ - - buff = (unsigned char *) calloc ( 232 ,sizeof(unsigned char)); - if ( buff == NULL ) - { - strcpy ( CAI_ERREUR , "Erreur : probleme d'allocation\n" ); - goto ERREUR; - } - - retour = fwrite ( buff , 232 , 1 , fic ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "Erreur : ecriture impossible dans fichier %s\n", fichier ); - goto ERREUR; - } - - free ( buff ); - -/*************************************************/ -/* ecriture des histogrammes a 0 */ -/*************************************************/ - - /* initialisations de variables necessaire au calcul d'histogramme */ - - for ( i=0 ; i<256 ; i++ ) - { - image1->HISTO[i_can][i]=0; - } - - retour = fwrite ( image1->HISTO[i_can] , (sizeof(int)*256) , 1 , fic ); - if ( retour == 0 ) - { - sprintf (CAI_ERREUR , "Erreur : ecriture impossible dans fichier %s\n", fichier ); - goto ERREUR; - } - - -/*************************************************/ -/* fermeture du fichier canal */ -/*************************************************/ - - fclose ( fic ); - -/*................................................ - Ouverture du fichier canal pour ecriture radiometrie - .............................................................*/ - num = open(fichier,O_RDWR,0); - image1->ACCES_CANAL_INT[i_can]=num; - image1->POS_OCTET[i_can]=24 +232+ 4*256; - - } - - - free ( nom_dos_obj ); - - - return (image1); - -ERREUR : - return(NULL); -} - -/* - Fin de l'operation cai_ouvre_creation_multis -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_lecture_canal_multis */ -/* ---------- */ -/* */ -/* ROLE : fonction de lecture d'un canal d'une image multiscope */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_lecture_canal_multis(image1, canal, */ /* ------------------ premiere_ligne, */ -/* premiere_colonne, */ -/* nombre_lignes_lire , */ -/* nombre_colonnes_lire, */ -/* pas_ligne ,pas_colonne, */ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a lire */ -/* premiere_ligne (E) (int) : premiere ligne a lire dans l'image */ -/* premiere _colonne (E) (int) : premiere colonne a lire dans l'image */ -/* nombre_lignes_lire (E) (int) : nombre de lignes a lire */ -/* nombre_colonnes_lire (E) (int) : nombre de colonnes a lire */ -/* pas_ligne (E) (int) : pas en ligne */ -/* pas_colonne (E) (int) : pas en colonne */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels lus alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_lecture_canal_multis (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_OK_KO cai_lecture_canal_multis(CAI_IMAGE *image1 , - int *canal , - int *premiere_ligne , - int *premiere_colonne, - int *nombre_lignes_lire , - int *nombre_colonnes_lire, - int *pas_ligne , - int *pas_colonne, - unsigned char *data_image ) - -{ - - int num,i,j; /* variables de travail */ - long int pt_oct,n; /* position courante dans le fichier image */ - int no_oct; /* numero du premier octet a lire */ - int iret; /* indicateur d'erreur */ - int lig; /* indice de boucle sur les lignes */ - int l,p; /* variables de travail */ - long nb_oct; /* nb oct =1er octet a lire - position courante */ - unsigned char *buf_lec; /* buffer lecture d'une ligne */ - unsigned char *deb,*pch; /* pointeur chaine pour transfert buffer sortie */ - unsigned char *buffer; /* buffer de lecture d'un pave 16*16 */ - int pave; /* nombre de paves colonnes dans une ligne */ - int taille; /* nbcol_tot*taille lignes pave */ - int bloc; /* indice de boucle sur les paves */ - int nolig; /* indice de boucle sur les lignes */ - int numlig; /* numero de la ligne reconstituee */ - unsigned char *ind_lec; /* pointeur de travai pour transfert pave */ - unsigned char *ind_tab; /* pointeur de travai pour transfert pave */ - int nbcol16; /* nb pave*taille colonnes du pave (16) */ - -/*......................... - Initialisations - ........................*/ - iret=CAI_OK; - num=image1->ACCES_CANAL_INT[*canal-1]; - lig=*premiere_ligne; - i=0; - pch=data_image; - -/*.............................................. - allocation de memoire pour lire une ligne image - ............................................. */ - pave=image1->NB_COL/16; - if ((image1->NB_COL%16)!=0) - { - pave=pave+1; - } - nbcol16=pave*16; - taille=nbcol16*16; - buf_lec = (unsigned char *) malloc(256); - if (buf_lec == NULL) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Probleme allocation memoire"); - } - else - { - buffer = (unsigned char *) malloc(taille); - if (buffer == NULL) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Probleme allocation memoire"); - } - else - { - lig=*premiere_ligne; - i=0; - pch=data_image; -/*..................... - Pour chaque ligne a lire - .......................................*/ - while ((i < *nombre_lignes_lire)&&(iret==CAI_OK)) - { -/*............................................ - Recherche de la position courante dans le fichier - ............................................*/ - pt_oct=lseek(num,0L,1); - -/*................................ - Calcul du numero du 1er octet a lire - ....................................*/ - nolig=((lig-1)/16)*16; - no_oct=image1->POS_OCTET[*canal-1]+(nolig*nbcol16); - -/*.................................. - Saut d'octets pour etre positionne sur la ligne a lire - .......................................*/ - nb_oct=(long)(no_oct-pt_oct); - - lseek(num,nb_oct,1); -/*........................................... - lecture de 16 lignes completes de nolig+1 a nolig+16 - ................................................*/ - for (bloc=1;bloc<=pave;bloc=bloc+1) - { -/* lecture d'un bloc de 256 octets consecutifs */ - n=read(num,buf_lec,256); - if (n<=0) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Erreur lecture donnee image multis"); - } - else - { -/* stockage du pave dans le tableau de 16 lignes completes */ - ind_tab=buffer+(bloc-1)*16; - ind_lec=buf_lec; - - for (l=1;l<=16;l=l+1) - { - for (p=1;p<=16;p=p+1) - { - *ind_tab=*ind_lec; - ind_tab=ind_tab+1; - ind_lec=ind_lec+1; - } - ind_tab=ind_tab+nbcol16-16; - } - } - } - -/*...................................... - Sauvegarde des donnees lues entenant compte du pas - d'echantillonnage en colonne - ........................................*/ - - if (iret==CAI_OK) - { - numlig=lig-nolig; - deb=buffer+(numlig-1)*nbcol16+(*premiere_colonne)-1; - while ((numlig<=16)&&(i<*nombre_lignes_lire)) - { - j=1; - while (j<=*nombre_colonnes_lire) - { - *pch=*deb; - pch=pch+1; - j=j+1; - deb=deb+(*pas_colonne); - } - numlig=numlig+(*pas_ligne); - deb=buffer+(numlig-1)*nbcol16+(*premiere_colonne)-1; - lig=lig+(*pas_ligne); - i=i+1; - } - } - } - - free(buffer); - } - free(buf_lec); - } - - return(iret); -} -/* - Fin de l'operation cai_lecture_canal_multis -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ecriture_canal_multis */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ecriture d'un canal d'une image multiscope */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ecriture_canal_multis(image1, canal, */ /* ------------------ premiere_ligne, */ -/* nombre_lignes_ecrire, */ -/* nombre_colonnes_ecrire, */ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a ecrire */ -/* premiere_ligne (E) (int) : premiere ligne a ecrire ds l'image */ -/* nombre_lignes_ecrire (E) (int) : nombre de lignes a ecrire */ -/* nombre_colonnes_ecrire(E) (int) : nombre de lignes a ecrire */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels ecris alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_ecriture_canal_multis (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_OK_KO cai_ecriture_canal_multis (CAI_IMAGE *image1 , - int *canal , - int *premiere_ligne , - int *nombre_lignes_ecrire , - int *nombre_colonnes_ecrire, - unsigned char *data_image ) -{ -int num; /* descripteur de fichier */ -int nboct_pix; /* nombre d'octets par pixel */ -int nb_colon_correc; /* nombre de colonnes multiple de 16 */ -int nb_blocs; /* nombre de paquets de 16 pixels */ -int i_bloc; /* compteur de blocs */ -int nb_last_pix; /* nb initial de pixels dans le dernier bloc */ -int nb_blocs_prec_first_lig;/* nb de blocs avant 1ere ligne a ecrire */ -int nb_blocs_prec_lig; /* nb de blocs avant ligne courante */ -int pos_first_lig_ds_bloc; /* position 1ere ligne a ecrire dans son bloc*/ -int pos_lig_ds_bloc; /* position ligne courante dans son bloc */ -long position_first_oct; /* position du 1er octet a ecrire */ -long position_courante; /* position courante dans le fichier */ -long deplacement; /* deplacement a effectuer */ -long depla_bl; /* deplacement a effectuer */ -int i_ligne; /* compteur de lignes */ -unsigned char *buff_lig; /* tableau contenant une ligne a ecrire */ -unsigned char *buff_bloc; /* tableau contenant un bloc a ecrire */ -int taille_wr,octwr; /* nombre d'elements du buffer a ecrire */ -long int cr_write; /* code retour de write */ -int i,can; /* indice de boucle */ -int Nb1; /* Nombre d'octets de completion */ -int NbL,NbC,i_can; -unsigned char *buf; - -/* initialisations */ - -i_ligne = 0; -num = image1->ACCES_CANAL_INT[*canal-1]; -nboct_pix = image1->NBOCT_PIX; - - -/*************************************************/ -/* Les donnees doivent etre codees sur 8 bits */ -/*************************************************/ - -if ( nboct_pix != 1 ) -{ - strcpy ( CAI_ERREUR , "Erreur : les donnees doivent etre codees sur 8 bits\n"); - goto ERREUR; -} - - -/********************************************************/ -/* Calcul du nombre de colonnes multiple de 16 de */ -/* l'image a ecrire */ -/********************************************************/ - -if ( (*nombre_colonnes_ecrire) % 16 == 0 ) - nb_colon_correc = (*nombre_colonnes_ecrire); -else - nb_colon_correc = (*nombre_colonnes_ecrire) - ((*nombre_colonnes_ecrire)%16) + 16; - -/********************************************************/ -/* Calcul du nombre de blocs complets de 16 pixels */ -/* sur une meme ligne (eventuellement completes par 0) */ -/********************************************************/ - -nb_blocs = nb_colon_correc / 16; - -/********************************************************/ -/* Calcul du nombre de pixels presents initialement */ -/* dans le dernier bloc d'une ligne */ -/********************************************************/ - -nb_last_pix = 16 - ( nb_colon_correc - (*nombre_colonnes_ecrire) ); - - -/********************************************************/ -/* Calcul du nombre de blocs de 16 lignes precedant la */ -/* premiere ligne a ecrire */ -/* Calcul de la position de la premiere ligne a ecrire */ -/* au sein d'un bloc de 16 lignes */ -/********************************************************/ -if ( (*premiere_ligne) <= 16 ) -{ - nb_blocs_prec_first_lig = 0; - pos_first_lig_ds_bloc = (*premiere_ligne); -} -else if ( ((*premiere_ligne) - 1) % 16 == 0 ) -{ - nb_blocs_prec_first_lig = ((*premiere_ligne) - 1) / 16; - pos_first_lig_ds_bloc = 1; -} -else -{ - nb_blocs_prec_first_lig = - ( ((*premiere_ligne) - 1 ) - ((*premiere_ligne) - 1)%16 ) / 16; - pos_first_lig_ds_bloc = 1 + ((*premiere_ligne) - 1)%16; -} - - - -/********************************************************/ -/* Initialisations */ -/********************************************************/ - -pos_lig_ds_bloc = pos_first_lig_ds_bloc; -nb_blocs_prec_lig = nb_blocs_prec_first_lig; - - -/********************************************************/ -/* POUR chacune des lignes a ecrire */ -/********************************************************/ -for ( i_ligne = 0 ; i_ligne < (*nombre_lignes_ecrire) ; i_ligne++ ) -{ - -/********************************************************/ -/* calcul de la position du premier octet de la */ -/* ligne a ecrire */ -/********************************************************/ - - position_first_oct = (long) ( image1->POS_OCTET[*canal-1] - + 16 * (pos_lig_ds_bloc - 1) - + 16 * nb_blocs_prec_lig * nb_colon_correc ); -/********************************************************/ -/* recuperation de la position courante */ -/********************************************************/ - - position_courante = lseek ( num , 0L , 1 ); - -/********************************************************/ -/* deplacement jusqu'au premier octet a ecrire */ -/********************************************************/ - - deplacement = position_first_oct - position_courante; - lseek ( num , deplacement , 1 ); - -/********************************************************/ -/* extraction de la ligne du tableau */ -/********************************************************/ - - buff_lig = data_image + (*nombre_colonnes_ecrire) * i_ligne; - -/********************************************************/ -/* initialisation du decalage de 15*16 octets */ -/********************************************************/ - - depla_bl = 0; - -/********************************************************/ -/* POUR chacun des blocs de 16 pixels */ -/********************************************************/ - for ( i_bloc = 0 ; i_bloc < nb_blocs ; i_bloc++ ) - { - -/********************************************************/ -/* deplacement */ -/********************************************************/ - - lseek ( num , depla_bl , 1 ); - -/********************************************************/ -/* extraction d'un bloc de la ligne */ -/********************************************************/ - - buff_bloc = buff_lig + i_bloc * 16; - -/********************************************************/ -/* determination du nombre de pixels a */ -/* ecrire */ -/********************************************************/ - - if ( i_bloc == nb_blocs - 1 ) - taille_wr = (int) nb_last_pix; - else - taille_wr = 16; - - image1->NB_PIX_ECRITS[(*canal)-1] = - image1->NB_PIX_ECRITS[(*canal)-1] + taille_wr; - -/********************************************************/ -/* ecriture dans le fichier */ -/********************************************************/ - cr_write = write ( num , buff_bloc , taille_wr ); - if ( cr_write != taille_wr ) - { - strcpy ( CAI_ERREUR , - "Erreur ecriture canal image multiscope\n" ); - goto ERREUR; - } -/* ecriture des colonnes de completion si necessaire */ - octwr = 16 - taille_wr; - buf = (unsigned char *) calloc(octwr,sizeof(unsigned char)); - if (buf==NULL) - { - printf(CAI_ERREUR,"Erreur completion multiscope"); - return(CAI_KO); - } - - cr_write = write ( num , buf , octwr ); - if ( cr_write != octwr ) - { - strcpy ( CAI_ERREUR , - "Erreur ecriture canal image multiscope\n" ); - goto ERREUR; - } - free(buf); - - -/********************************************************/ -/* calcul de l'histogramme */ -/********************************************************/ - can=(*canal)-1; - calculer_histo (image1, buff_bloc , taille_wr , can); -/********************************************************/ -/* mise a jour du decalage de 15*16 octets */ -/********************************************************/ - - depla_bl = 15*16; - -/********************************************************/ -/* FIN POUR */ -/********************************************************/ - } - -/********************************************************/ -/* mise a jour de la position de la ligne dans le */ -/* bloc, et du nombre de blocs precedant la ligne */ -/********************************************************/ - - if ( pos_lig_ds_bloc == 16 ) - { - pos_lig_ds_bloc = 1; - nb_blocs_prec_lig++; - } - else - pos_lig_ds_bloc++; - -/********************************************************/ -/* FIN POUR */ -/********************************************************/ -} - - -/********************************************************/ -/* SI on a ecrit le dernier pixel du canal */ -/********************************************************/ - -if ( image1->NB_PIX_ECRITS[*canal-1] == image1->NB_COL*image1->NB_LIG ) -{ -/* Ecriture des 0 de completions si necessaires */ - - NbL= image1->NB_LIG; - NbC= image1->NB_COL; - if ((NbL%16) !=0) - NbL = ((NbL/16)+1)*16; - - if ((NbC%16) !=0) - NbC = ((NbC/16)+1)*16; - - Nb1 = (NbL*NbC)+1280; - if (Nb1 !=0) - { - position_courante = lseek ( num , 0L , 1 ); - deplacement = Nb1 - position_courante; - buf = (unsigned char *) calloc(deplacement,sizeof(unsigned char)); - if (buf==NULL) - { - printf(CAI_ERREUR,"Erreur ecriture multiscope"); - return(CAI_KO); - } - - - /* ecriture des octets a 0 pour bloc de 16 */ - num=image1->ACCES_CANAL_INT[(*canal)-1]; - cr_write = write ( num , buf , deplacement ); - - free(buf); - } - -/********************************************************/ -/* on ecrit l'histogramme dans le fichier */ -/* apres positionnement dans le fichier */ -/********************************************************/ - - lseek ( num , 0L , 0 ); - lseek ( num , 256L , 0 ); - - /* inversion des octets */ - for ( i=0 ; i<256 ; i++ ) - { - inverser((char *)&(image1->HISTO[(*canal)-1][i]), - (sizeof(int)-1)); - } - - cr_write = write ( num , image1->HISTO[(*canal)-1] , - (sizeof(int)*256) ); - if ( cr_write != (sizeof(int)*256) ) - { - strcpy ( CAI_ERREUR , - "Erreur ecriture canal image multiscope\n" ); - goto ERREUR; - } -} - - -return (CAI_OK); - -ERREUR : - -return (CAI_KO); - - -} - -/* - Fin de l'operation cai_ecriture_canal_multis -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ferme_multis */ -/* ---------- */ -/* */ -/* ROLE : fonction de fermeture d'une image au format multiscope et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ferme_multis(image1) */ /* ------------------ */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* */ -/* cai_ferme_multis (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_OK_KO cai_ferme_multis (CAI_IMAGE *image1) - -{ - int iret; /* code retour de l'operation */ - int i_can; /* indice du canal a fermer */ - int num; /* descripteur du fichier a fermer */ - - iret=CAI_OK; - -/*............................................. - Fermeture des fichiers image - .............................................*/ - for (i_can=0;i_can<image1->NB_CANAUX;i_can=i_can+1) - { - num=image1->ACCES_CANAL_INT[i_can]; - close(num); - } - - - return (iret); -} -/* - Fin de l'operation cai_ferme_multis -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_dest_ima_multis */ -/* ---------- */ -/* */ -/* ROLE : fonction de destruction d'une image stocke en multiscope et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_dest_ima_multis(format,nom_ima) */ /* ------------------ */ -/* format (E) (char *) : format de l'image a detruire */ -/* nom_image (E) (char *) : nom de l'image a detruire avec repertoire */ -/* */ -/* cai_dest_ima_multis (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_OK_KO cai_dest_ima_multis (char *repertoire , - char *nom_ima ) - -{ -int i_can; /* compteur de canaux */ -long iret; /* code retour fonction fermetrue lecture */ -char nom_fichier[1024]; /* nom du fichier entete a detruire */ -char nom_ima_complet[1024]; /* repertoire + nom de l'image */ -char nom_fic_canal[1024]; /* nom du fichier canal a detruire */ -char chemin[1024]; /* repertoire + "/" */ -char *ptr_nom_fic_can; /* pointeur sur nom fichier canal traite */ -int cr_stat; /* code retour de fonction status de fichier*/ -struct stat buf_stat; /* structure decrivant status de fichier */ -CAI_IMAGE *image1; /* structure ouverture image */ -int nb_can; /* nombre de canaux de l'image */ -int nboct_pix; /* nombre d'octets par pixel image */ -int nb_col; /* nombre de colonnes de l'image */ -int nb_lig; /* nombre de lignes de l'image */ - -/************************************************/ -/* Constitution du nom du fichier d'entete */ -/************************************************/ -nom_ima_complet[0]='\0'; -if ((long int)strlen(repertoire)!= 0) -{ - strcpy ( nom_ima_complet , repertoire ); - strcat ( nom_ima_complet, "/" ); - strcpy ( chemin,nom_ima_complet ); - strcat ( nom_ima_complet , nom_ima ); - chemin[strlen(repertoire)+1] = '\0'; -} -else -{ - strcpy ( nom_ima_complet , nom_ima); - chemin[0]='\0'; -} -strcpy(nom_fichier , nom_ima_complet); -strcat ( nom_fichier , ".img" ); -nom_fichier[strlen(nom_ima_complet)+4]='\0'; - - -/************************************************/ -/* Extraction des caracteristiques de l'image */ -/* et noms des fichiers fdoxxxxx.per */ -/* du fichier entete par l'appel a la fonction */ -/* cai_ouvre_lecture_multis */ -/************************************************/ - image1 = cai_ouvre_lecture_multis ( repertoire,nom_ima, &nb_can ,&nboct_pix , - &nb_col, &nb_lig ); - if ( image1 == NULL) goto ERREUR; - -image1->NB_CANAUX=nb_can; -image1->NB_COL=nb_col; -image1->NB_LIG=nb_lig; -image1->NBOCT_PIX=nboct_pix; - -ptr_nom_fic_can = image1->NOM_FIC_CAN; - -for ( i_can = 0 ; i_can < nb_can ; i_can++ ) -{ - strncpy ( nom_fic_canal , ptr_nom_fic_can , 49 ); - nom_fic_canal[49] = '\0'; - strcpy ( nom_fichier , chemin ); - strcat ( nom_fichier, nom_fic_canal ); - nom_fichier[strlen(chemin)+12] = '\0'; - cr_stat = stat ( nom_fichier , &buf_stat ); - if ( cr_stat == 0 ) - unlink ( nom_fichier ); - ptr_nom_fic_can = ptr_nom_fic_can + 100; -} - - iret=cai_ferme_multis(image1); - -/************************************************/ -/* Destruction du fichier d'entete */ -/************************************************/ -nom_fichier[0]='\0'; -strcpy(nom_fichier , nom_ima_complet); -strcat ( nom_fichier , ".img" ); -nom_fichier[strlen(nom_ima_complet)+4]='\0'; - -cr_stat = stat ( nom_fichier , &buf_stat ); -if ( cr_stat == 0 ) -unlink ( nom_fichier ); - -return (CAI_OK); - -ERREUR : - -return (CAI_KO); - - -} -/* - Fin de l'operation cai_dest_ima_multis -*/ - -/*****************************************************************************/ -/*****************************************************************************/ -/* */ -/* Definition des OPERATIONS INTERNES */ -/* */ -/*****************************************************************************/ -/*****************************************************************************/ - -/*****************************************************************************/ -/* */ -/* OPERATION : inverser */ -/* ---------- */ -/* */ -/* ROLE : Inversion des octets poids forts,poids faibles */ -/* ------ */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : void inverser((char *)s,nboct) */ -/* ----------------- */ -/* */ -/* s (E/S) (char *) : chaine a inverser */ -/* nboct (E) (int) : longueur de la chaine */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -static void inverser ( char *s , int nboct ) -{ - int c; - char *t; - - for ( t=s+nboct ; s<t ; s++,t-- ) - { - c=*s; - *s=*t; - *t=c; - } -} -/* Fin de l'operation inverser */ - -/*****************************************************************************/ -/* */ -/* OPERATION : calculer_histo */ -/* ---------- */ -/* */ -/* ROLE : Inversion des octets poids forts,poids faibles */ -/* ------ */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : void calculer_histo(s,nboct) */ -/* ----------------- */ -/* */ -/* s (E/S) (char *) : chaine a inverser */ -/* nboct (E) (int) : longueur de la chaine */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -static void calculer_histo (CAI_IMAGE *image1, unsigned char *buffer , - int nb_pix , int canal ) -{ - int i_pix; /* indice de boucle sur les pixels */ - int val_pix; /* valeur du pixel traite */ - - for ( i_pix=0 ; i_pix<nb_pix ; i_pix++ ) - { - val_pix = (int) buffer[i_pix]; - image1->HISTO[canal][val_pix]++; - } -} -/* - Fin de l'operation calculer_histo -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_modifie_multis */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture-ecriture d'une image au format */ -/* ----- multiscope et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_modifie_multis (nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_modifie_multis (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ /* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_IMAGE *cai_ouvre_modifie_multis(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) - - -{ - FILE *fic; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - int iret; /* indicateur de retour ok ou pas */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char nom_fic_canal[1024]; /* nom du fichier canal */ - char nom_util_canal[1024]; /* nom du fichier utilisateur */ - char *deb,*deb1; /* pointeurs sur chaine de caracteres */ - int num,retour,lon; /* variables de travail */ - short int type,fin; /* variables de trvail */ - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - - *nb_lig=0; - *nb_col=0; - *nboct_pix=0; - *nb_can=0; - iret=1; - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); - -/*................................................. - Constitution du nom du fichier entete - .................................................*/ - nom_fic[0]='\0'; - if ((long int)strlen(repert)!=0) - { - sscanf(repert,"%s",nom_fic); - strcat(nom_fic,"/"); - strcat(nom_fic,nom_image); - strcat(nom_fic,".img"); - nom_fic[strlen(repert)+1+strlen(nom_image)+4]='\0'; - } - else - { - sscanf(nom_image,"%s",nom_fic); - strcat(nom_fic,".img"); - nom_fic[strlen(nom_image)+4]='\0'; - } - -/*........................ - Ouverture du fichier entete - ..........................................*/ - fic=fopen(nom_fic,"rb"); - if (fic == NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur ouverture fichier entete MULTISCOPE"); - } - else - { - -/*.................................... - positionnement sur le nombre de colonnes -*/ - fseek(fic,8,0); -/* - recuperation du nombre de colonnes */ - fread(nb_col,4,1,fic); -/* - inversion des octets pour compatibilite SUN */ - lon=sizeof(*nb_col)-1; - inverser((char *)nb_col,lon); - -/*.................................... - recuperation du nombre de lignes -*/ - fread(nb_lig,4,1,fic); -/* - inversion des octets pour compatibilite SUN */ - lon=sizeof(*nb_lig)-1; - inverser((char *)nb_lig,lon); - -/*...................................... - initialisation du nombre d'octets par pixel -*/ - *nboct_pix=1; - image1->NB_BITS_PIX=8; - sprintf(image1->COD_PIX,"OCT"); -/*................................. - positionnement sur le premier objet -*/ - fseek(fic,114,1); - retour=0; - deb = image1->NOM_FIC_CAN; - deb1= image1->NOM_UTIL_CAN; - - - while (retour == 0) - { -/*...........Recuperation de tous les objets jusqu'a l'eof - nom fichier,nom utilisateur et type de l'objet(avec inversion) -*/ - fread(nom_fic_canal,14,1,fic); - fread(nom_util_canal,40,1,fic); - fread(&type,2,1,fic); - lon=sizeof(type)-1; - inverser((char *)&type,lon); - if (type == 3) - { -/*....................................... - Initialisation des tableaux contenant le nom de fichier - et le nom utilisateur de chaque canal - .....................................................*/ - - - if (*nb_can<CAI_NB_MAX_CAN) - { - nom_fic_canal[0] = tolower(nom_fic_canal[0]); - nom_fic_canal[1] = tolower(nom_fic_canal[1]); - nom_fic_canal[2] = tolower(nom_fic_canal[2]); - nom_fic_canal[9] = tolower(nom_fic_canal[9]); - nom_fic_canal[10] = tolower(nom_fic_canal[10]); - nom_fic_canal[11] = tolower(nom_fic_canal[11]); - nom_fic[0]='\0'; - if ((long int)strlen(repert) != 0) - { - sscanf(repert,"%s",nom_fic); - strcat(nom_fic,"/"); - strcat(nom_fic,nom_fic_canal); - nom_fic[strlen(repert)+1+strlen(nom_fic_canal)]='\0'; - } - else - { - sscanf(nom_fic_canal,"%s",nom_fic); - nom_fic[strlen(nom_fic_canal)]='\0'; - } - sscanf(nom_fic_canal,"%s",deb); - deb=deb+100; - sscanf(nom_util_canal,"%s",deb1); - deb1=deb1+100; - - num=open(nom_fic,O_RDWR,0); - if (num==-1) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur ouverture fi canal Multiscope"); - } - else - { - image1->ACCES_CANAL_INT[*nb_can]=num; - image1->POS_OCTET[*nb_can]=1280; - image1->NB_PIX_ECRITS[*nb_can]=0; - } - - } - *nb_can=*nb_can+1; - } - -/*............Positionnement en fin de bloc */ - fseek(fic,70,1); -/* - ............Test fin de fichier */ - fread(&fin,2,1,fic); - retour=feof(fic); - } -/*.................................. - Fermeture du fichier - ......................................*/ - fclose(fic); - } - - - if (iret != 0) - return (image1); - else - return(NULL); - -} -/* - Fin de l'operation cai_ouvre_modifie_multis -*/ diff --git a/Utilities/CAI/cai_dll/src/cai_onera.c b/Utilities/CAI/cai_dll/src/cai_onera.c deleted file mode 100755 index 76b55d78ab5852dfebe0b5ab58523b865b37cacc..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/src/cai_onera.c +++ /dev/null @@ -1,1296 +0,0 @@ -/*****************************************************************************/ -/* */ -/* PROJET : COUCHE ACCES IMAGE */ -/* ------- */ -/* */ -/* MODULE : cai_onera.c */ -/* ------- */ -/* */ -/* ROLE : Ce module rassemble toutes les fonctions d'acces aux images */ -/* ------- stockees au format onera */ -/* */ -/* AUTEUR : R.CHAISEMARTIN (CISI) */ -/* ------- */ -/* */ -/* DATE DE CREATION : fevrier 1995 */ -/* ----------------- */ -/* */ -/* LANGAGE : C */ -/* -------- */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ -/* MOD : VERSION : 3.3: DM : optimisation des acces */ -/*****************************************************************************/ -/* MOD : VERSION : 4.1 :FA:Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : FA : verification que l'image est codee sur un seul */ -/*octet par pixel (contrainte du format) */ -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : DM : modifications pour compatibilite HP64bits */ -/*****************************************************************************/ -/* MOD : VERSION : 4.4 : DM : modifications open et fopen pour PC NT */ -/*****************************************************************************/ -/* MOD : VERSION : 4.5 : FA : test sur fclose pour PC/LINUX */ -/*****************************************************************************/ -/* MOD : VERSION : 4.6 : FA : erreur ouverture en modification */ -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : FA : ecriture image entiere. Correction du test de */ -/* retour sur le nb d'octets ecrits */ -/*****************************************************************************/ -/* MOD : VERSION : 5.3 : FA : ouverture en lecture/ecriture */ -/*****************************************************************************/ - -/*---------------------------------------------------------------------------*/ -/* Inclusion des fichiers STANDARDS (.h) */ -/*---------------------------------------------------------------------------*/ - -# include <stdio.h> -# include <string.h> -# include <stdlib.h> -# include <unistd.h> -# include <sys/types.h> -#include <dirent.h> -# include <sys/stat.h> -# include <fcntl.h> - -#define _CAI_IMAGE -#define IN_CAI_ONERA - -# include "cai_image.h" - -/*----------------------------------------------------------------------------*/ -/* Variable pour la gestion en configuration */ -/*----------------------------------------------------------------------------*/ -static char *rcs_id="$Header: cai_onera.c,v 1.10 01/05/31 10:47:12 cmf Exp $"; - -extern char *getenv(); - -/*****************************************************************************/ -/*****************************************************************************/ -/* */ -/* Definition des OPERATIONS EXTERNES */ -/* */ -/*****************************************************************************/ -/*****************************************************************************/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_liste_ima_onera */ -/* ---------- */ -/* */ -/* ROLE : fonction de listage des images au format onera */ -/* ------ */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : int cai_liste_ima_onera(repert,tab_ima) */ -/* ----------------- */ -/* */ -/* repert (E) (char *) : repertoire a explorer */ -/* tab_ima (S) (char ***) : pointeur sur tableau des images listees*/ -/* alloue par la fonction,il doit etre */ -/* LIBERE PAR L'APPELANT */ -/* */ -/* cai_liste_ima_onera (S) (int) : = -1 repertoire inexistant */ /* = > 0 nombre d'images listees */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -long int cai_liste_ima_onera (char *repert, - char ***tab_ima) - - -{ - DIR *dirp; /* pointeur sur structure ouverture repertoire */ - -struct dirent *dp; /* structure resultat de la fonction readdir */ - - char *pch0,*pch1; /* pointeurs sur chaine de caracteres */ - char *pch2,*pch3; /* pointeurs sur chaine de caracteres */ - char car; /* variable de travail */ - int nb_ima; /* nombre d'images onera identifiees */ - int i; /* indice de boucle */ - - -/*........................................ - INITIALISATION et ouverture du repertoire choisi - .........................................*/ - nb_ima=0; - - dirp=opendir(repert); - - if(dirp!=NULL) - { - -/*...................................... - premiere passe pour comptabiliser les images du format donne - - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE ONERA - (EXTENSION =.inf) - ..........................................*/ - - while((dp=readdir(dirp))!=NULL) - { - - car='.'; - pch0=strrchr(dp->d_name,car); - if (pch0 != NULL) - { - car='i'; - pch1=strrchr(dp->d_name,car); - if ((pch1 != NULL)&&(pch1==pch0+1)) - { - car='n'; - pch2=strrchr(dp->d_name,car); - if ((pch2 != NULL)&&(pch2==pch1+1)) - { - car='f'; - pch3=strrchr(dp->d_name,car); - if ((pch3 != NULL)&&(pch3==pch2+1)) - { - *pch0='\0'; - *pch1=' '; - *pch2=' '; - *pch3=' '; - nb_ima=nb_ima+1; - } - } - } - } - } - - closedir(dirp); -/*..................................... - ALLOCATION DU TABLEAU CONTENANT LA LISTE DES IMAGES DU FORMAT ONERA - ......................................*/ - *tab_ima = (char **) calloc(nb_ima,sizeof(char *)); - for (i=0;i<nb_ima;i=i+1) - (*tab_ima)[i]=(char *)calloc(1,100); - -/*...................................... - - deuxieme passe pour constituer la liste des images du format donne - - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE ONERA - (EXTENSION =.inf) - SI C`EST LE CAS,STOCKAGE DANS LA LISTE - ..........................................*/ - dirp=opendir(repert); - - nb_ima=0; - while((dp=readdir(dirp))!=NULL) - { - - car='.'; - pch0=strrchr(dp->d_name,car); - if (pch0 != NULL) - { - car='i'; - pch1=strrchr(dp->d_name,car); - if ((pch1 != NULL)&&(pch1==pch0+1)) - { - car='n'; - pch2=strrchr(dp->d_name,car); - if ((pch2 != NULL)&&(pch2==pch1+1)) - { - car='f'; - pch3=strrchr(dp->d_name,car); - if ((pch3 != NULL)&&(pch3==pch2+1)) - { - *pch0='\0'; - *pch1=' '; - *pch2=' '; - *pch3=' '; - strcpy((*tab_ima)[nb_ima],dp->d_name); - nb_ima=nb_ima+1; - } - } - } - } - } - - (void)closedir(dirp); - - } - else - { - /* Repertoire inexistant */ - nb_ima=-1; - } - - return(nb_ima); - -} - -/* Fin de l'operation cai_liste_ima_onera -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_lecture_onera */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture d'une image au format onera */ -/* ----- et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_lecture_onera (nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels (1) */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_lecture_onera (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ /* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_IMAGE *cai_ouvre_lecture_onera(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) - -{ - int fic; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - int iret; /* indicateur de retour ok ou pas */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char *deb,*deb1; /* pointeurs sur chaine de caracteres */ - char car[2]; /* indice du canal traite */ - int num,ican; /* indice */ - char *buf_lec ; /* buffer lecture entete onera */ - long k; /* indice */ - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - - *nb_lig=0; - *nb_col=0; - *nboct_pix=0; - *nb_can=0; - - - iret=1; - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); -/*****************************************************************************/ -/* MOD : VERSION : 4.1 :FA:Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur allocation memoire dans cai_ouvre_lecture"); - } - else - { -/*................................................. - Constitution du nom du fichier entete - .................................................*/ - nom_fic[0]='\0'; - if ((long int)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s.inf",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.inf",nom_image); - } - - -/*........................ - Ouverture du fichier entete - ..........................................*/ - num=open(nom_fic,O_RDONLY|O_BINARY,0); - if (num == -1) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur ouverture fichier entete ONERA"); - } - else - { - -/*.................................... - Lecture du fichier entete - ............................................*/ - buf_lec=(char *) malloc(257); - if (buf_lec==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur allocation memoire dans cai_ouvre_lecture"); - } - else - { - - k=read(num,buf_lec,256); - if (k<=0) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur lecture entete Onera"); - close(num); - } - else - { - buf_lec[k]='\0'; -/*......................................... - Initialisation du nombre d'octets par pixel . Pour onera les pixels - sont toujours codes sur 1 octet - ...............................................................*/ - *nboct_pix=1; - image1->NB_BITS_PIX=8; - sprintf(image1->COD_PIX,"OCT"); -/*................................. - Decodage de l'enregistrement - .........................................*/ - deb=buf_lec; - sscanf(deb,"%d%d%d",nb_col,nb_lig,nb_can); - close(num); - } - free(buf_lec); - } - } - - if (iret !=0) - { -/*....................................... - INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL et ouverture - de ces fichiers - .....................................................*/ - - deb = image1->NOM_FIC_CAN; - deb1= image1->NOM_UTIL_CAN; - - ican=1; - while((ican<=*nb_can)&&(ican<CAI_NB_MAX_CAN)) - { - sprintf(deb,"%s.%d",nom_image,ican); - deb=deb+100; - sprintf(deb1,"%s.%d",nom_image,ican); - deb1=deb1+100; - nom_fic[0]='\0'; - if ((long int)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s.%d",repert,nom_image,ican); - } - else - { - sprintf(nom_fic,"%s.%d",nom_image,ican); - } - fic=open(nom_fic,O_RDONLY|O_BINARY,0); - if (fic != -1) - { - image1->ACCES_CANAL_INT[ican-1]=fic; - image1->POS_OCTET[ican-1]=0; - ican=ican+1; - } - else - { - iret=0; - strcpy(CAI_ERREUR,"incoherence au niveau du nb fichiers canaux"); - return(NULL); - } - } - } - } - - if (iret == 0) - { - return (NULL); - } - else - { - return(image1); - } - -} - -/* - Fin de l'operation cai_ouvre_lecture_onera -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_creation_onera */ -/* ---------- */ -/* */ -/* ROLE : fonction de creation et d'ouverture en ecriture d'une image */ -/* ----- au format onera et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_creation_onera(nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig, */ -/* label) */ -/* */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* nb_can (E) (int ) : nombre de canaux de l'image */ -/* nboct_pix (E) (int ) : nombre d'octets par pixels (1 ) */ -/* nb_lig (E) (int ) : nombre de lignes de l'image */ -/* nb_col (E) (int ) : nombre de colonnes de l'image */ -/* label (E) (char *) : commentaire lie a l'image */ -/* */ -/* cai_ouvre_creation_onera (S) (CAI_IMAGE *) : =NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_IMAGE *cai_ouvre_creation_onera(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig, - char *label) - -{ - FILE *fic; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char nom_fic_canal[1024]; /* nom fichier canal dont on teste existence*/ - int retour; /* retour de fonction */ - char car[2]; /* indice du canal traite */ - int i,num; /* indice */ - struct stat buf_stat; /* structure decrivant status de fichier */ - -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : FA : verification que l'image est codee sur un seul */ -/*octet par pixel (contrainte du format) */ -/*****************************************************************************/ - if (*nboct_pix != 1) - { - image1 = NULL; - sprintf ( CAI_ERREUR , - "Une image onera ne peutetre codee que sur un seul octet par pixel"); - goto ERREUR; - } - - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); -/*****************************************************************************/ -/* MOD : VERSION : 4.1 :FA:Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_creation"); - goto ERREUR; - } - -/*................................................. - Constitution du nom du fichier entete et verification qu'il - n'existe pas deja - .................................................*/ - nom_fic[0]='\0'; - if ((long int)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s.inf",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.inf",nom_image); - } - - retour = stat ( nom_fic , &buf_stat ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "L'image %s ONERA existe \n" , nom_image ); - goto ERREUR; - } - -/*............................................................... - Pour chaque canal de l'image,constitution du nom de fichier correspondant - Verification qu'il n'existe pas deja - Ouverture du fichier en ecriture - .................................................................*/ - - for (i=0;i<*nb_can;i=i+1) - { - nom_fic_canal[0]='\0'; - if ((long int)strlen(repert)!=0) - { - sprintf(nom_fic_canal,"%s/%s.%d",repert,nom_image,i+1); - } - else - { - sprintf(nom_fic_canal,"%s.%d",nom_image,i+1); - } - retour = stat ( nom_fic_canal , &buf_stat ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "L'image %s ONERA existe \n" , nom_image ); - goto ERREUR; - } - - num = open(nom_fic_canal,O_RDWR|O_CREAT|O_BINARY,PERMS); - if (num == -1) - { - sprintf(CAI_ERREUR,"Erreur: Creation %s canl impossible\n",nom_fic_canal); - goto ERREUR; - } - image1->ACCES_CANAL_INT[i]=num; - image1->POS_OCTET[i]=0; - } - -/*...................................................... - Ouverture du fichier entete en ecriture - Ecriture du contenu - ..........................................................*/ - fic = fopen(nom_fic,"w"); - if (fic == NULL) - { - sprintf(CAI_ERREUR, - "Erreur: Creation fichier entete %s impossible\n", - nom_fic); - goto ERREUR; - } - fprintf ( fic , "%d\n" , *nb_col ); - fprintf ( fic , "%d\n" , *nb_lig); - fprintf ( fic , "%d" , *nb_can ); - - -/*************************************************/ -/* Fermeture du fichier */ -/*************************************************/ - - if (fic!=NULL) fclose ( fic ); - return (image1); - -ERREUR : - return(NULL); -} - -/* - Fin de l'operation cai_ouvre_creation_onera -*/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_lecture_canal_onera */ -/* ---------- */ -/* */ -/* ROLE : fonction de lecture d'un canal d'une image onera */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_lecture_canal_onera(image1, canal, */ /* ------------------ premiere_ligne, */ -/* premiere_colonne, */ -/* nombre_lignes_lire , */ -/* nombre_colonnes_lire, */ -/* pas_ligne ,pas_colonne, */ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a lire */ -/* premiere_ligne (E) (int) : premiere ligne a lire dans l'image */ -/* premiere _colonne (E) (int) : premiere colonne a lire dans l'image */ -/* nombre_lignes_lire (E) (int) : nombre de lignes a lire */ -/* nombre_colonnes_lire (E) (int) : nombre de colonnes a lire */ -/* pas_ligne (E) (int) : pas en ligne */ -/* pas_colonne (E) (int) : pas en colonne */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels lus alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_lecture_canal_onera (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_OK_KO cai_lecture_canal_onera(CAI_IMAGE *image1 , - int *canal , - int *premiere_ligne , - int *premiere_colonne, - int *nombre_lignes_lire , - int *nombre_colonnes_lire, - int *pas_ligne , - int *pas_colonne, - unsigned char *data_image ) - -{ - int num,i,j; /* variables de travail */ - long pt_oct,n; /* position courante dans le fichier image */ - int no_oct; /* numero du premier octet a lire */ - int iret; /* indicateur d'erreur */ - int lig; /* indice de boucle sur les lignes */ - int oct_pix; /* nb octets par pixels */ - long nb_oct; /* nb oct =1er octet a lire - position courante */ - long oct_lig; /* nb oct. par ligne en considerant taille pixel */ - unsigned char *buf_lec; /* buffer lecture d'une ligne */ - unsigned char *deb,*pch; /* pointeur chaine pour transfert buffer sortie */ - - -/*........................... - Initialisations diverses - ..........................*/ - - iret=CAI_OK; - num=image1->ACCES_CANAL_INT[*canal-1]; - oct_pix=image1->NBOCT_PIX; - oct_lig=oct_pix*(image1->NB_COL); - -/*.......................................*/ -/* verification si lecture image entiere */ -/*.......................................*/ - if ((*nombre_lignes_lire==image1->NB_LIG)&&(*nombre_colonnes_lire==image1->NB_COL) - &&(*pas_ligne==1)&&(*pas_colonne==1)) - { - oct_lig=oct_pix*(image1->NB_COL)*(image1->NB_LIG); - - /* positionnement en debut de fichier */ - pt_oct=lseek(num,0L,0); - - /* lecture du canal complet */ - n=read(num,data_image,oct_lig); - if (n<=0) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Erreur lecture donnee image ONERA"); - } - else - iret=CAI_OK; - } - else - { - -/*.............................................. - allocation de memoire pour lire une ligne image - ............................................. */ - - buf_lec = (unsigned char *) malloc(oct_lig); - if (buf_lec == NULL) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Probleme allocation memoire"); - } - else - { -/*.................... - Initialisation - ......................*/ - lig=*premiere_ligne; - i=1; - pch=data_image; - -/*..................... - Pour chaque ligne a lire - .......................................*/ - while ((i <= *nombre_lignes_lire)&&(iret==CAI_OK)) - { -/*............................................ - Recherche de la position courante dans le fichier - ............................................*/ - pt_oct=lseek(num,0L,1); - -/*................................ - Calcul du numero du 1er octet a lire - ....................................*/ - no_oct=(lig-1)*image1->NB_COL; - -/*.................................. - Saut d'octets pour etre positionne sur la ligne a lire - .......................................*/ - nb_oct=(long)(no_oct-pt_oct); - lseek(num,nb_oct,1); - -/*........................................... - lecture d'une ligne image - ................................................*/ - n=read(num,buf_lec,image1->NB_COL); - - if (n<=0) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Erreur lecture donnee image onera"); - } - else - { -/*...................................... - Sauvegarde des donnees lues entenant compte du pas - d'echantillonnage en colonne - ........................................*/ - deb=buf_lec+(*premiere_colonne-1); - j=1; - while (j <= *nombre_colonnes_lire) - { - *pch=*deb; - pch=pch+1; - j=j+1; - deb=deb+*pas_colonne; - } - - } - i=i+1; - lig=lig+*pas_ligne; - - } - - free(buf_lec); - } - } - - return(iret); -} - -/* - Fin de l'operation cai_lecture_canal_onera -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ecriture_canal_onera */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ecriture d'un canal d'une image onera */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ecriture_canal_onera(image1, canal, */ /* ------------------ premiere_ligne, */ -/* nombre_lignes_ecrire, */ -/* nombre_colonnes_ecrire,*/ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a ecrire */ -/* premiere_ligne (E) (int) : premiere ligne a ecrire ds l'image */ -/* nombre_lignes_ecrire (E) (int) : nombre de lignes a ecrire */ -/* nombre_colonnes_ecrire(E) (int) : nombre de lignes a ecrire */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels ecris alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_ecriture_canal_onera (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_OK_KO cai_ecriture_canal_onera (CAI_IMAGE *image1 , - int *canal , - int *premiere_ligne , - int *nombre_lignes_ecrire , - int *nombre_colonnes_ecrire, - unsigned char *data_image ) -{ -long position_first_lig; /* position de la 1ere ligne a ecrire */ -long position_courante; /* position courante dans le fichier */ -long deplacement; /* deplacement a effectuer */ -int i_ligne; /* compteur de lignes */ -unsigned char *buff_lig; /* tableau contenant une ligne a ecrire */ -long cr_write; /* code retour de write */ -int num; /* descripteur de fichier */ -int nboct_pix; /* nombre d'octets par pixel */ -int tot_pix; /* nb de pixels total a ecrire */ - -/* ................ - Initialisations - .................*/ -i_ligne = 0; -num = image1->ACCES_CANAL_INT[*canal-1]; -nboct_pix = image1->NBOCT_PIX; - - -/*************************************************/ -/* Les donnees doivent etre codees sur 8 bits */ -/*************************************************/ - -if ( nboct_pix != 1 ) -{ - strcpy ( CAI_ERREUR , "Erreur : les donnees doivent etre codees sur 8 bits\n"); - goto ERREUR; -} -/*.......................................*/ -/* verification si ecriture image entiere */ -/*.......................................*/ - if ((*nombre_lignes_ecrire==image1->NB_LIG)&& - (*nombre_colonnes_ecrire==image1->NB_COL)) - { - tot_pix=nboct_pix*(image1->NB_COL)*(image1->NB_LIG); - - /* positionnement en debut de fichier */ - position_first_lig=lseek(num,0L,0); - -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : FA : ecriture image entiere. Correction du test de */ -/* retour sur le nb d'octets ecrits */ -/* tot_pix au lieu de nboct_pix */ -/*****************************************************************************/ - /* ecriture du canal complet */ - cr_write = write ( num , data_image,tot_pix); - if (cr_write != tot_pix) - { - strcpy(CAI_ERREUR,"Erreur ecriture donnee image ONERA"); - goto ERREUR; - } - } - else - { - -/********************************************************/ -/* Calcul de la position de la premiere ligne a ecrire */ -/********************************************************/ - -position_first_lig = - (long) ( image1->POS_OCTET[*canal-1] + - (*premiere_ligne - 1) * (*nombre_colonnes_ecrire) ); - - -/********************************************************/ -/* Recuperation de la position courante */ -/********************************************************/ - -position_courante = lseek ( num , 0L , 1 ); - - -/********************************************************/ -/* Deplacement jusqu'a la premiere ligne a ecrire */ -/********************************************************/ - -deplacement = position_first_lig - position_courante; -lseek ( num, deplacement , 1 ); - - -/********************************************************/ -/* TANT QUE il y a des lignes a ecrire */ -/********************************************************/ -while (i_ligne < *nombre_lignes_ecrire) -{ - -/********************************************************/ -/* extraction de la ligne du tableau */ -/********************************************************/ - - buff_lig = data_image + (*nombre_colonnes_ecrire) * i_ligne; - -/********************************************************/ -/* ecriture de la ligne */ -/********************************************************/ - - cr_write = write ( num , buff_lig ,(*nombre_colonnes_ecrire) ); - if ( cr_write !=(*nombre_colonnes_ecrire) ) - { - strcpy ( CAI_ERREUR , "Erreur ecriture canal image onera \n" ); - goto ERREUR; - } - -/********************************************************/ -/* incrementation du nombre de lignes */ -/********************************************************/ - - i_ligne++; - -/********************************************************/ -/* FIN TANT QUE */ -/********************************************************/ - } -} - - -return (CAI_OK); - -ERREUR : - -return (CAI_KO); - - -} -/* - Fin de l'operation cai_ecriture_canal_onera -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ferme_onera */ -/* ---------- */ -/* */ -/* ROLE : fonction de fermeture d'une image au format onera et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ferme_onera(image1) */ /* ------------------ */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* */ -/* cai_ferme_onera (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_OK_KO cai_ferme_onera (CAI_IMAGE *image1) - - -{ - int iret; /* code retour de l'operation */ - int i_can; /* indice du canal a fermer */ - int num; /* descripteur du fichier a fermer */ - - - iret=CAI_OK; -/*............................................. - Fermeture des fichiers image - .............................................*/ - for (i_can=0;i_can<image1->NB_CANAUX;i_can=i_can+1) - { - num=image1->ACCES_CANAL_INT[i_can]; - if (num>0) close(num); - } - - - return (iret); -} - -/* - Fin de l'operation cai_ferme_onera -*/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_dest_ima_onera */ -/* ---------- */ -/* */ -/* ROLE : fonction de destruction d'une image stocke en onera et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_dest_ima_onera(format,nom_ima) */ /* ------------------ */ -/* format (E) (char *) : format de l'image a detruire */ -/* nom_image (E) (char *) : nom de l'image a detruire avec repertoire */ -/* */ -/* cai_dest_ima_onera (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_OK_KO cai_dest_ima_onera ( char *repertoire , - char *nom_ima ) - -{ - -int i_can; /* compteur de canaux */ -long iret; /* code retour fonction fermetrue lecture */ -char str_num_canal[3]; /* suffixe numero du canal */ -char nom_fic_entete[1024]; /* nom du fichier entete a detruire */ -char nom_ima_complet[1024]; /* repertoire + nom de l'image */ -char nom_fic_canal[1024]; /* nom du fichier canal a detruire */ -int cr_stat; /* code retour de fonction status de fichier */ -struct stat buf_stat; /* structure decrivant status de fichier */ -CAI_IMAGE *image1; /* structure ouverture image */ -int nb_can; /* nombre de canaux de l'image */ -int nboct_pix; /* nombre d'octets par pixel image */ -int nb_col; /* nombre de colonnes de l'image */ -int nb_lig; /* nombre de lignes de l'image */ - -/************************************************/ -/* Constitution du nom du fichier d'entete */ -/************************************************/ -if ((long)strlen(repertoire)!= 0) -{ - sprintf ( nom_ima_complet, "%s/%s",repertoire,nom_ima ); - -} -else -{ - strcpy ( nom_ima_complet , nom_ima); -} -sprintf(nom_fic_entete ,"%s.inf", nom_ima_complet); - -/************************************************/ -/* Extraction des caracteristiques de l'image */ -/* du fichier entete par l'appel a la fonction */ -/* cai_ouvre_lecture_onera */ -/************************************************/ - - image1 = cai_ouvre_lecture_onera ( repertoire,nom_ima, &nb_can ,&nboct_pix , - &nb_col , &nb_lig); - if ( image1 == NULL) goto ERREUR; - - image1->NB_CANAUX=nb_can; - image1->NB_COL=nb_col; - image1->NB_LIG=nb_lig; - image1->NBOCT_PIX=nboct_pix; - -iret=cai_ferme_onera(image1); -image1 = NULL; - -/************************************************/ -/* Destruction du fichier d'entete */ -/************************************************/ - -cr_stat = stat ( nom_fic_entete , &buf_stat ); -if ( cr_stat == 0 ) - unlink ( nom_fic_entete ); - - -/************************************************/ -/* Constitution un a un des noms des fichiers */ -/* canaux et destruction */ -/************************************************/ - -for ( i_can = 0 ; i_can < nb_can ; i_can++ ) -{ - sprintf( nom_fic_canal , "%s.%d" ,nom_ima_complet,i_can+1); - cr_stat = stat ( nom_fic_canal , &buf_stat ); - if ( cr_stat == 0 ) - unlink ( nom_fic_canal ); -} - - -return (CAI_OK); - -ERREUR : - -return (CAI_KO); - - -} -/* - Fin de l'operation cai_dest-ima_onera -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_modifie_onera */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture-ecriture d'une image au format */ -/* ----- onera et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_modifie_onera (nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels (1 ) */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_modifie_onera (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ /* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_IMAGE *cai_ouvre_modifie_onera(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) - -{ - int fic; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - int iret; /* indicateur de retour ok ou pas */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char *deb,*deb1; /* pointeurs sur chaine de caracteres */ - char car[2]; /* indice du canal traite */ - int num,ican; /* indice */ - char *buf_lec ; /* buffer lecture entete onera */ - long k; /* indice */ - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - - *nb_lig=0; - *nb_col=0; - *nboct_pix=0; - *nb_can=0; - - - iret=1; - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); - if (image1==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_modifie"); - } - else - { - -/*................................................. - Constitution du nom du fichier entete - .................................................*/ - nom_fic[0]='\0'; - if ((long int)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s.inf",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.inf",nom_image); - } - - -/*........................ - Ouverture du fichier entete - ..........................................*/ - num=open(nom_fic,O_RDWR|O_BINARY,0); - if (num == -1) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur ouverture fichier entete ONERA"); - } - else - { -/*.................................... - Lecture du fichier entete - ............................................*/ - buf_lec=(char *) malloc(257); - if (buf_lec==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_modifie"); - } - else - { - - k=read(num,buf_lec,256); - if (k<=0) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur lecture entete Onera"); - close(num); - } - else - { - buf_lec[k]='\0'; -/*......................................... - Initialisation du nombre d'octets par pixel . Pour onera les pixels - sont toujours codes sur 1 octet - ...............................................................*/ - *nboct_pix=1; - image1->NB_BITS_PIX=8; - sprintf(image1->COD_PIX,"OCT"); -/*................................. - Decodage de l'enregistrement - .........................................*/ - deb=buf_lec; - sscanf(deb,"%d%d%d",nb_col,nb_lig,nb_can); - close(num); - } - free(buf_lec); - } - } - - if (iret !=0) - { -/*....................................... - INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL et ouverture - de ces fichiers - .....................................................*/ - - deb = image1->NOM_FIC_CAN; - deb1= image1->NOM_UTIL_CAN; - - ican=1; - while((ican<=*nb_can)&&(ican<CAI_NB_MAX_CAN)) - { - sprintf(deb,"%s.%d",nom_image,ican); - deb=deb+100; - sprintf(deb1,"%s.%d",nom_image,ican); - deb1=deb1+100; - nom_fic[0]='\0'; - if ((long int)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s.%d",repert,nom_image,ican); - } - else - { - sprintf(nom_fic,"%s.%d",nom_image,ican); - } -/*****************************************************************************/ -/* MOD : VERSION : 5.3 : FA : ouverture en lecture/ecriture */ -/*****************************************************************************/ - fic=open(nom_fic,O_RDWR|O_BINARY,0); - if (fic != -1) - { - image1->ACCES_CANAL_INT[ican-1]=fic; - image1->POS_OCTET[ican-1]=0; - ican=ican+1; - } - else - { - iret=0; - strcpy(CAI_ERREUR,"incoherence au niveau du nb fichiers canaux"); - return(NULL); - } - } - - } - } - if (iret==0) - { - return (NULL); - } - else - { - return(image1); - } - -} -/* - Fin de l'operation cai_ouvre_modifie_onera -*/ diff --git a/Utilities/CAI/cai_dll/src/cai_radar.c b/Utilities/CAI/cai_dll/src/cai_radar.c deleted file mode 100755 index ebf80637a44cf6d4c18be17f58734606345c43fa..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/src/cai_radar.c +++ /dev/null @@ -1,1466 +0,0 @@ -/*****************************************************************************/ -/* */ -/* PROJET : COUCHE ACCES IMAGE */ -/* ------- */ -/* */ -/* MODULE : cai_radar.c */ -/* ------- */ -/* */ -/* ROLE : Ce module rassemble toutes les fonctions d'acces aux images */ -/* ------- stockees au format radar */ -/* */ -/* AUTEUR : R.CHAISEMARTIN (CS) */ -/* ------- */ -/* */ -/* DATE DE CREATION : Juin 2001 */ -/* ----------------- */ -/* */ -/* LANGAGE : C */ -/* -------- */ -/* */ -/* VERSION : V5.1 */ -/* -------- */ -/* */ -/*****************************************************************************/ -/* MOD : VERSION : 1.2 : FA : IMA-FA-011 pb inversion des octets complexes */ -/*****************************************************************************/ -/* MOD : VERSION : 5.1 : DM : Maj du tag COD_PIX lorsque l'image est codée */ -/* en reel a partir du TYPE_CODE */ -/*****************************************************************************/ - -/*---------------------------------------------------------------------------*/ -/* Inclusion des fichiers STANDARDS (.h) */ -/*---------------------------------------------------------------------------*/ - - -# include <stdio.h> -#ifndef _MSC_VER -# include <strings.h> -#endif -# include <stdlib.h> -# include <sys/types.h> -# include <unistd.h> -# include <dirent.h> -# include <sys/stat.h> -# include <fcntl.h> -#include <errno.h> - -#define _CAI_IMAGE -#define IN_CAI_RADAR - -# include "cai_image.h" - -/*----------------------------------------------------------------------------*/ -/* Variable pour la gestion en configuration */ -/*----------------------------------------------------------------------------*/ -static char *rcs_id="$Header$"; - -extern char *getenv(); - -#define FREE(A) { if ((A)!=NULL) { free(A); (A)=NULL; } } - -/*****************************************************************************/ -/*****************************************************************************/ -/* */ -/* Definition des OPERATIONS EXTERNES */ -/* */ -/*****************************************************************************/ -/*****************************************************************************/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_liste_ima_radar */ -/* ---------- */ -/* */ -/* ROLE : fonction de listage des images au format radar */ -/* ------ */ -/* */ -/* CONTEXTE D'APPEL : int cai_liste_ima_radar(repert,tab_ima) */ -/* ----------------- */ -/* */ -/* repert (E) (char *) : repertoire a explorer */ -/* tab_ima (S) (char ***) : pointeur sur tableau des images listees */ -/* alloue par la fonction,il doit etre */ -/* LIBERE PAR L'APPELANT */ -/* */ -/* cai_liste_ima_radar (S) (long int) : = -1 repertoire inexistant */ -/* = > 0 nombre d'images listees */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -long int cai_liste_ima_radar (char *repert, - char ***tab_ima) -{ - - DIR *dirp; /* pointeur sur structure ouverture repertoire */ - struct dirent *dp; /* structure resultat de la fonction readdir */ - char *pch0,*pch1; /* pointeurs sur chaine de caracteres */ - int nb_ima; /* nombre d'images radar identifiees */ - int ind; /* indice de boucles */ - -/*........................................ - INITIALISATION et ouverture du repertoire choisi - .........................................*/ - nb_ima=0; - dirp=opendir(repert); - - if(dirp!=NULL) - { - -/*...................................... - - premiere passe pour comptabiliser les images du format donne - - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE RADAR_CNES - (EXTENSION =.rad ou .RAD) - ..........................................*/ - while((dp=readdir(dirp))!=NULL) - { -/* recherche de l'extension en minuscule */ - pch0 = strstr(dp->d_name,".rad"); - if (pch0==NULL) - { -/* recherche de l'extension en majuscule */ - pch1=strstr(dp->d_name,".RAD"); - if ((pch1 != NULL)&&(*(pch1+4) == '\0')) - { - nb_ima=nb_ima+1; - } - } - else - { - if (*(pch0+4) == '\0') - nb_ima=nb_ima+1; - } - } - (void)closedir(dirp); - -/*..................................... - ALLOCATION DU TABLEAU CONTENANT LA LISTE DES IMAGES DU FORMAT RADAR - ......................................*/ - *tab_ima = (char **) calloc(nb_ima,sizeof(char *)); - for (ind=0;ind<nb_ima;ind++) - (*tab_ima)[ind]=(char *)calloc(1,100); - -/*...................................... - - deuxieme passe pour constituer la liste des images du format donne - - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE RADAR_CNES - (EXTENSION =.rar ou .RAD) - SI C`EST LE CAS,STOCKAGE DANS LA LISTE - ..........................................*/ - dirp=opendir(repert); - - nb_ima=0; - while((dp=readdir(dirp))!=NULL) - { -/* recherche de l'extension en minuscule */ - pch0 = strstr(dp->d_name,".rad"); - if (pch0==NULL) - { -/* recherche de l'extension en majuscule */ - pch1=strstr(dp->d_name,".RAD"); - if ((pch1 != NULL)&&(*(pch1+4) == '\0')) - { - *pch1='\0'; - strcpy((*tab_ima)[nb_ima],dp->d_name); - nb_ima=nb_ima+1; - } - } - else - { - if (*(pch0+4) == '\0') - { - *pch0='\0'; - strcpy((*tab_ima)[nb_ima],dp->d_name); - nb_ima=nb_ima+1; - } - } - } - (void)closedir(dirp); - } - else - { - /* repertoire inexistant */ - nb_ima=-1; - } - return(nb_ima); -} - -/* Fin de l'operation cai_liste_ima_radar -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_lecture_radar */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture d'une image au format radar */ -/* ----- et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_lecture_radar (nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels et par canal */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_lecture_radar (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_IMAGE *cai_ouvre_lecture_radar(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) - - -{ - FILE *fic_in; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char nom_fic_canal[1024]; /* nom fichier canal dont on teste existence*/ - char label[80]; /* contient un enregistrement du fichier */ - int nbplan; /* nombre de canaux dans le fichier en-tete */ - int retour; /* retour de la fonction comparaison chaines*/ - char *deb,*pch0; /* pointeurs sur chaine de caracteres */ - int ind,num; /* indice */ - int nboct; /* variables de travail */ - int ind_typ; /* Indice du type de codage */ - int is_Cplx; /* Indique si type complexe ou pas */ - char *type_machine; /* ordre rangement octets machine de travail*/ - int cmp; /* retour de comparaison de chaine */ - - /*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - *nb_can=0; - *nb_lig=0; - *nb_col=0; - *nboct_pix = 0; - pch0=NULL; - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); - if (image1==NULL) - { - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_lecture"); - goto ERREUR; - } -/*................................................. - Constitution du nom du fichier entete - .................................................*/ - nom_fic[0]='\0'; - if ((long int)strlen(repert)== 0) - sprintf(repert,"./"); - sprintf(nom_fic,"%s/%s.rad",repert,nom_image); - sprintf(image1->NOM_IMAGE,"%s/%s",repert,nom_image); - - /*........................ - Ouverture du fichier entete - ..........................................*/ - fic_in=NULL; - fic_in=fopen(nom_fic,"r"); - if (fic_in==NULL) - { -/* verification si extension en majuscule */ - nom_fic[0]='\0'; - sprintf(nom_fic,"%s/%s.RAD",repert,nom_image); - fic_in=fopen(nom_fic,"r"); - if (fic_in==NULL) - { - strcpy(CAI_ERREUR,"Erreur ouverture fichier entete RADAR-CNES"); - goto ERREUR; - } - } - /*.................................... - Decodage du nombre de colonnes - ............................................*/ - retour=fscanf(fic_in,"%s",label); - pch0=strstr(label,"NBCOLONNES"); - if (pch0==NULL) - { - sprintf(CAI_ERREUR,"Informations incoherentes NBCOLONNES dans %s", - nom_fic); - goto ERREUR; - } - retour=fscanf(fic_in,"%d",nb_col); - - - /*.................................... - Decodage du nombre de lignes - ............................................*/ - retour=fscanf(fic_in,"%s",label); - pch0=strstr(label,"NBLIGNES"); - if (pch0==NULL) - { - sprintf(CAI_ERREUR,"Informations incoherentes NBLIGNES dans %s", - nom_fic); - goto ERREUR; - } - retour=fscanf(fic_in,"%d",nb_lig); - - /*........................................ - Decodage du nombre de plans - .........................................*/ - retour=fscanf(fic_in,"%s",label); - pch0=strstr(label,"NBPLANS"); - if (pch0==NULL) - { - sprintf(CAI_ERREUR,"Informations incoherentes NBPLANS dans %s", - nom_fic); - goto ERREUR; - } - retour=fscanf(fic_in,"%d",&nbplan); - *nb_can=nbplan; - - /*........................................ - Recuperation du type de codage du plan .........................................*/ - retour=fscanf(fic_in,"%s",label); - pch0=strstr(label,"TYPECODAGE"); - if (pch0==NULL) - { - sprintf(CAI_ERREUR,"Informations incoherentes TYPECODAGE dans %s", - nom_fic); - goto ERREUR; - } - - retour=fscanf(fic_in,"%s",label); - pch0=cai_En_majuscule( label ); - -/* Verification si type de codage reconnu et recuperation de la taille pixel*/ - nboct = cai_istyp_radar(pch0,&ind_typ,&is_Cplx); - if (nboct == -1) - { - sprintf(CAI_ERREUR,"Type de codage du plan %s non reconnu ", - nom_fic_canal); - goto ERREUR; - } - *nboct_pix=nboct; - sprintf(image1->TYPE_COD,"%s",pch0); - -/* ........................................................... - Determination du sens de codage de la machine de travail - .............................................................*/ - type_machine = cai_test_pFpf(); - -/*..................................................... - Recuperation du type de codage du plan (INTEL ou IEEE) .......................................................*/ - retour=fscanf(fic_in,"%s",label); - pch0=strstr(label,"SENSCODAGE"); - if (pch0==NULL) - { - sprintf(CAI_ERREUR,"Informations incoherentes SENSCODAGE dans %s", - nom_fic); - goto ERREUR; - } - - retour=fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"IEEE",4); - if (retour==0) - sprintf(image1->COD_PIX,"BE"); - else - sprintf(image1->COD_PIX,"LE"); - cmp = strncmp(type_machine,image1->COD_PIX,2); - if (cmp!=0) - { -/*****************************************************************************/ -/* MOD : VERSION : 1.2 : FA : IMA-FA-011 pb inversion des octets complexes */ -/*****************************************************************************/ - if (is_Cplx==0) - image1->INV_OCTETS =1; - else - image1->INV_OCTETS =2; - } - else - { - image1->INV_OCTETS =0; - } -/*****************************************************************************/ -/* MOD : VERSION : 5.1 : DM : Maj du tag COD_PIX lorsque l'image est codée */ -/* en reel a partir du TYPE_CODE */ -/*****************************************************************************/ sprintf(image1->COD_PIX,"%s",image1->TYPE_COD); - -/*............................................... - Pour chaque plan , decodage des caracteristiques du plans -..................................................................*/ - deb=image1->NOM_FIC_CAN; - for (ind=0;ind<nbplan;ind++) - { -/* Recuperation nom du plan */ - retour=fscanf(fic_in,"%s",label); - sprintf(deb,"%s",label); - sprintf(nom_fic_canal,"%s/%s",repert,label); - deb = deb+100; - -/* Verification de l'existence du plan et ouverture */ - num=open(nom_fic_canal,O_RDONLY|O_BINARY,0); - if (num!= -1) - { - image1->ACCES_CANAL_INT[ind]=num; - image1->POS_OCTET[ind]=0; - } - else - { - sprintf(CAI_ERREUR,"Impossible d'ouvrir le plan %s", - nom_fic_canal); - goto ERREUR; - } - } - - /*.................................. - Fermeture du fichier - ......................................*/ - if (fic_in!=NULL) fclose(fic_in); - - -/* sortie nominale */ - return(image1); - -ERREUR: -/* sortie en erreur */ - FREE(image1); - return (NULL); -} -/* - Fin de l'operation cai_ouvre_lecture_radar -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_creation_radar */ -/* ---------- */ -/* */ -/* ROLE : fonction de creation et d'ouverture en ecriture d'une image */ -/* ----- au format radar et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_creation_radar (nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig, */ -/* typcode) */ -/* */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* nb_can (E) (int ) : nombre de canaux de l'image */ -/* nboct_pix (E) (int ) : nb d'octets pixels */ -/* nb_lig (E) (int ) : nombre de lignes de l'image */ -/* nb_col (E) (int ) : nombre de colonnes de l'image */ -/* typcode (E) (char *) : type de codage de l'image */ -/* */ -/* cai_ouvre_creation_radar (S) (CAI_IMAGE *) : =NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_IMAGE *cai_ouvre_creation_radar(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig, - char *typcode) - -{ - FILE *fic; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - char nom_fic[1024]; /* nom du fichier en-tete */ - int retour,retour1; /* retour de fonction */ - int can,num; /* indice */ - struct stat buf_stat; /* structure decrivant status de fichier */ - char *type_machine; /* ordre rangement octets machine de travail*/ - int ind_typ; /* Indice du type de codage radar */ - int is_Cplx; /* Indique si type complexe ou pas */ - int nboct; - char *pch0; - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); - if (image1==NULL) - { - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_creation"); - goto ERREUR; - } - -/* Vérification si typecode est un type radar si non par défaut mettre und */ - pch0=cai_En_majuscule( typcode ); - nboct = cai_istyp_radar(pch0,&ind_typ,&is_Cplx); - if (nboct == -1) - { - sprintf(typcode,"und"); - } -/*................................................. - Constitution du nom du fichier entete et verification qu'il - n'existe pas deja - .................................................*/ - - nom_fic[0]='\0'; - if ((long int)strlen(repert) == 0) - sprintf(repert,"./"); - -/* Recherche avec l'extension en majuscule */ - sprintf(nom_fic,"%s/%s.RAD",repert,nom_image); - retour = stat ( nom_fic , &buf_stat ); - if ( retour == 0 ) - { - unlink(nom_fic); - } - -/* Recherche avec l'extension en minuscule */ - sprintf(nom_fic,"%s/%s.rad",repert,nom_image); - retour = stat ( nom_fic , &buf_stat ); - if ( retour == 0 ) - { - unlink(nom_fic); - } - sprintf(image1->NOM_IMAGE,"%s/%s",repert,nom_image); - - -/*...................................................... - Ouverture du fichier entete en ecriture - Ecriture du contenu - ..........................................................*/ - fic = fopen(nom_fic,"w"); - if (fic == NULL) - { - sprintf(CAI_ERREUR,"Erreur: Creation fichier %s impossible\n",nom_fic); - goto ERREUR; - } - -/* Nombre de colonnes */ - retour=fprintf ( fic , "NBCOLONNES "); - retour1=fprintf ( fic , "%d\n" , *nb_col ); - if ((retour == 0)||(retour1 == 0)) - { - sprintf(CAI_ERREUR,"Erreur: Ecriture %s impossible\n",nom_fic); - goto ERREUR; - } -/* Nombre de lignes */ - retour=fprintf ( fic , "NBLIGNES "); - retour1=fprintf ( fic , "%d\n" , *nb_lig ); - if ((retour == 0)||(retour1 == 0)) - { - sprintf(CAI_ERREUR,"Erreur: Ecriture %s impossible\n",nom_fic); - goto ERREUR; - } - -/* Nombre de plans */ - retour=fprintf ( fic , "NBPLANS "); - retour1=fprintf ( fic , "%d\n" , *nb_can); - if ((retour == 0)||(retour1 == 0)) - { - sprintf(CAI_ERREUR,"Erreur: Ecriture %s impossible\n",nom_fic); - goto ERREUR; - } - -/* TYPE DE CODAGE */ - retour=fprintf ( fic , "TYPECODAGE "); - retour1=fprintf ( fic , "%s\n" , typcode ); - if ((retour == 0)||(retour1 == 1)) - { - sprintf(CAI_ERREUR,"Erreur: Ecriture %s impossible\n",nom_fic); - goto ERREUR; - } - /*.................................. - determination ordre de rangement - des octets sur machine de travail - ......................................*/ - type_machine = cai_test_pFpf(); - -/* TYPE DE CODAGE */ - retour=fprintf ( fic , "SENSCODAGE "); - - if (strcmp(type_machine,"BE")==0) - retour=fprintf ( fic , "IEEE\n"); - else - retour=fprintf ( fic , "INTEL\n"); - if (retour == 0) - { - sprintf(CAI_ERREUR,"Erreur: Ecriture %s impossible\n", - nom_fic); - goto ERREUR; - } - -/*............................................................... - Pour chaque canal de l'image,constitution du nom de fichier correspondant - Verification qu'il n'existe pas deja - Ouverture du fichier en ecriture - .................................................................*/ - pch0=cai_En_minuscule( typcode ); - - for (can=0;can<*nb_can;can++) - { - nom_fic[0]='\0'; - if (*nb_can==1) - sprintf(nom_fic,"%s/%s.%s",repert,nom_image,pch0); - else - sprintf(nom_fic,"%s/%s_%d.%s",repert,nom_image,can+1,pch0); - - retour = stat ( nom_fic , &buf_stat ); - - if ( retour == 0 ) - { - unlink(nom_fic); - } - num = open(nom_fic,O_RDWR|O_CREAT|O_BINARY,PERMS); - if (num == -1) - { - sprintf(CAI_ERREUR,"Erreur: Creation %s impossible\n", - nom_fic); - goto ERREUR; - } - image1->ACCES_CANAL_INT[can]=num; - image1->POS_OCTET[can]=0; - if (*nb_can==1) - { - retour1=fprintf ( fic , "%s.%s\n" , nom_image,pch0); - snprintf(image1->NOM_FIC_CAN,100,"%s.%s",nom_image,pch0); - *(image1->NOM_FIC_CAN+99)='\0'; - } - else - { - retour1=fprintf ( fic , "%s_%d.%s\n" , nom_image,can+1,pch0); - snprintf(image1->NOM_FIC_CAN+can*100,100,"%s_%d.%s",nom_image,can+1,pch0); - *(image1->NOM_FIC_CAN+can*100+99)='\0'; - } - if (retour1 == 1) - { - sprintf(CAI_ERREUR,"Erreur: Ecriture %s impossible\n", - nom_fic); - goto ERREUR; - } - } - -/*************************************************/ -/* Fermeture du fichier */ -/*************************************************/ - - fclose ( fic ); - return (image1); - -ERREUR : - return(NULL); -} - -/* - Fin de l'operation cai_ouvre_creation_radar -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_lecture_canal_radar */ -/* ---------- */ -/* */ -/* ROLE : fonction de lecture d'un canal d'une image radar */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_lecture_canal_radar(image1, canal, */ -/* ------------------ premiere_ligne, */ -/* premiere_colonne, */ -/* nombre_lignes_lire , */ -/* nombre_colonnes_lire, */ -/* pas_ligne ,pas_colonne, */ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (lint): numero du canal a lire */ -/* premiere_ligne (E) (int) : premiere ligne a lire dans l'image */ -/* premiere _colonne (E) (int) : premiere colonne a lire dans l'image */ -/* nombre_lignes_lire (E) (int) : nombre de lignes a lire */ -/* nombre_colonnes_lire (E) (int) : nombre de colonnes a lire */ -/* pas_ligne (E) (int) : pas en ligne */ -/* pas_colonne (E) (int) : pas en colonne */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels lus alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_lecture_canal_radar (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - - -CAI_OK_KO cai_lecture_canal_radar(CAI_IMAGE *image1 , - int *canal , - int *premiere_ligne , - int *premiere_colonne, - int *nombre_lignes_lire , - int *nombre_colonnes_lire, - int *pas_ligne , - int *pas_colonne, - unsigned char *data_image ) - -{ - - int num,i,j,k; /* variables de travail */ - long int pt_oct; /* position courante dans le fichier image */ - long int no_oct; /* numero du premier octet a lire */ - int iret; /* indicateur d'erreur */ - long int lig; /* indice de boucle sur les lignes */ - long int oct_pix,octpix; /* nb octets par pixels */ - long int nb_oct; /* nb oct =1er octet a lire - position courante */ - long int oct_lig; /* nb oct. par ligne en considerant taille pixel */ - unsigned char *buf_lec; /* buffer lecture d'une ligne */ - unsigned char *deb,*pch; /* pointeur chaine pour transfert buffer sortie */ - long int n; - int nbpix; -/*........................... - Initialisations diverses - ..........................*/ - - iret=CAI_OK; - num=(int)image1->ACCES_CANAL_INT[(*canal)-1]; - oct_pix=image1->NBOCT_PIX;; - oct_lig=oct_pix*(image1->NB_COL); - -/*.............................................. - allocation de memoire pour lire une ligne image - ............................................. */ - buf_lec = (unsigned char *) calloc(oct_lig,sizeof(unsigned char)); - if (buf_lec == NULL) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Probleme allocation memoire"); - } - else - { -/*.................... - Initialisation - ......................*/ - lig=*premiere_ligne; - i=1; - pch=data_image; - /*..................... - Pour chaque ligne a lire - .......................................*/ - while ((i <= (*nombre_lignes_lire))&&(iret==CAI_OK)) - { - -/*............................................ - Recherche de la position courante dans le fichier - ............................................*/ - pt_oct=lseek(num,0L,1); - -/*................................ - Calcul du numero du 1er octet a lire - ....................................*/ - no_oct=image1->POS_OCTET[(*canal)-1]+((lig-1)*oct_lig); - -/*.................................. - Saut d'octets pour etre positionne sur la ligne a lire - .......................................*/ - nb_oct=(long)(no_oct-pt_oct); - lseek(num,nb_oct,1); - -/*........................................... - lecture d'une ligne image - ................................................*/ - n=read(num,buf_lec,oct_lig); - if (n<=0) - { - iret=CAI_KO; - sprintf(CAI_ERREUR,"Erreur lecture donnee image RADAR %s", - image1->NOM_IMAGE); - - } - else - { -/*...................................... - Sauvegarde des donnees lues entenant compte du pas - d'echantillonnage en colonne - ........................................*/ - deb=buf_lec+((*premiere_colonne)-1)*oct_pix; - j=1; - while (j <= (*nombre_colonnes_lire)) - { - for (k=0;k<oct_pix;k=k+1) - { - *(pch+k)=*(deb+k); - } - pch=pch+oct_pix; - j=j+1; - deb=deb+((*pas_colonne)*oct_pix); - } - - } - i=i+1; - lig=lig+(*pas_ligne); - - if ((image1->INV_OCTETS==1) && (oct_pix!=1)) - { - nbpix = (*nombre_lignes_lire)*(*nombre_colonnes_lire); - cai_inverser_tableau_complet(data_image,(int)nbpix,(int)oct_pix); - } - -/*****************************************************************************/ -/* MOD : VERSION : 1.2 : FA : IMA-FA-011 pb inversion des octets complexes */ -/*****************************************************************************/ - else if (image1->INV_OCTETS==2) - { - nbpix = (*nombre_lignes_lire)*(*nombre_colonnes_lire)*2; - octpix = oct_pix/2; - cai_inverser_tableau_complet(data_image,(int)nbpix,(int)octpix); - } - - } - free(buf_lec); - } - return(iret); - } -/* - Fin de l'operation cai_lecture_canal_radar -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ecriture_canal_radar */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ecriture d'un plan d'une image radar */ -/* ----- */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ecriture_canal_radar(image1, canal, */ -/* ------------------ premiere_ligne, */ -/* nombre_lignes_ecrire, */ -/* nombre_colonnes_ecrire,*/ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a ecrire */ -/* premiere_ligne (E) (int) : premiere ligne a ecrire ds l'image */ -/* nombre_lignes_ecrire (E) (int) : nombre de lignes a ecrire */ -/* nombre_colonnes_ecrire(E) (int) : nombre de lignes a ecrire */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels ecris alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_ecriture_canal_radar (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_OK_KO cai_ecriture_canal_radar (CAI_IMAGE *image1 , - int *canal , - int *premiere_ligne , - int *nombre_lignes_ecrire , - int *nombre_colonnes_ecrire, - unsigned char *data_image ) - -{ - - long int position_first_lig; /* position de la 1ere ligne a ecrire */ - long int position_courante; /* position courante dans le fichier */ - long int deplacement; /* deplacement a effectuer */ - int i_ligne; /* compteur de lignes */ - unsigned char *buff_lig; /* tableau contenant une ligne a ecrire */ - long int cr_write; /* code retour de write */ - int num; /* descripteur de fichier */ - int nboct_pix; /* nombre d'octets par pixel */ - int tot_pix; /* nb de pixels total a ecrire */ - -/* initialisations */ - -i_ligne = 0; -num = image1->ACCES_CANAL_INT[*canal-1]; -nboct_pix = image1->NBOCT_PIX; - -/*.......................................*/ -/* verification si ecriture image entiere */ -/*.......................................*/ - if ((*nombre_lignes_ecrire==image1->NB_LIG)&& - (*nombre_colonnes_ecrire==image1->NB_COL)) - { - tot_pix=nboct_pix*(image1->NB_COL)*(image1->NB_LIG); - - /* positionnement en debut de fichier */ - position_first_lig=lseek(num,0L,0); - - /* ecriture du canal complet */ - cr_write = write ( num , data_image,tot_pix); - if (cr_write != tot_pix) - { - sprintf(CAI_ERREUR,"Erreur ecriture donnee image RADAR %s", - image1->NOM_IMAGE); - - goto ERREUR; - } - } - else - { - -/********************************************************/ -/* Calcul de la position de la premiere ligne a ecrire */ -/********************************************************/ - -position_first_lig =(long int) ( image1->POS_OCTET[*canal-1]+ - (( *premiere_ligne - 1) * (*nombre_colonnes_ecrire) - * nboct_pix)); - - -/********************************************************/ -/* Recuperation de la position courante */ -/********************************************************/ - -position_courante = lseek ( num , 0L , 1 ); - - -/********************************************************/ -/* Deplacement jusqu'a la premiere ligne a ecrire */ -/********************************************************/ - -deplacement = position_first_lig - position_courante; -lseek ( num , deplacement , 1 ); - -/********************************************************/ -/* TANT QUE il y a des lignes a ecrire */ -/********************************************************/ -while (i_ligne < (*nombre_lignes_ecrire)) -{ - -/********************************************************/ -/* extraction de la ligne du tableau */ -/********************************************************/ - - buff_lig = data_image + (*nombre_colonnes_ecrire) * nboct_pix * i_ligne; - -/********************************************************/ -/* ecriture de la ligne */ -/********************************************************/ - - cr_write = write ( num , buff_lig , - (*nombre_colonnes_ecrire) * nboct_pix ); - if ( cr_write != (*nombre_colonnes_ecrire)*nboct_pix ) - { - sprintf( CAI_ERREUR , "Erreur ecriture canal image radar_cnes %s", - image1->NOM_IMAGE); - - goto ERREUR; - } - -/********************************************************/ -/* incrementation du nombre de lignes */ -/********************************************************/ - - i_ligne++; -/********************************************************/ -/* FIN TANT QUE */ -/********************************************************/ - } -} - - -return (CAI_OK); - -ERREUR : - -return (CAI_KO); - - -} - -/* - Fin de l'operation cai_ecriture_canal_radar -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ferme_radar */ -/* ---------- */ -/* */ -/* ROLE : fonction de fermeture d'une image au format radar et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ferme_radar(image1) */ -/* ------------------ */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* */ -/* cai_ferme_radar (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_OK_KO cai_ferme_radar (CAI_IMAGE *image1) - -{ - int iret; /* code retour de l'operation */ - int i_can; /* indice du canal a fermer */ - int num; /* descripteur du fichier a fermer */ - - iret=CAI_OK; -/*............................................. - Fermeture de tous les canaux - .............................................*/ - for (i_can=0;i_can<image1->NB_CANAUX;i_can=i_can+1) - { - - num=image1->ACCES_CANAL_INT[i_can]; - if (num>0) close(num); - } - - return (iret); -} - -/* - Fin de l'operation cai_ferme_radar -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_dest_ima_radar */ -/* ---------- */ -/* */ -/* ROLE : fonction de destruction d'une image stocke en radar et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_dest_ima_radar(repertoire,nom_ima) */ -/* ------------------ */ -/* repertoire (E) (char *) : repertoire de l'image a detruire */ -/* nom_image (E) (char *) : nom de l'image a detruire avec repertoire */ -/* */ -/* cai_dest_ima_radar (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - - -CAI_OK_KO cai_dest_ima_radar ( char *repertoire , - char *nom_ima ) - -{ -int i_can; /* compteur de canaux */ -long int iret; /* code retour fonction fermeture lecture */ -char nom_fic[1024]; /* nom du fichier entete a detruire */ -long int cr_stat; /* code retour de fonction status de fichier */ -struct stat buf_stat; /* structure decrivant status de fichier */ - -CAI_IMAGE *image1; /* structure ouverture image */ -int nb_can; /* nombre de canaux de l'image */ -int nboct_pix; /* nombre d'octets par pixel image */ -int nb_col; /* nombre de colonnes de l'image */ -int nb_lig; /* nombre de lignes de l'image */ -char *pch; - - if ((long int)strlen(repertoire)!= 0) - sprintf(repertoire,"./"); - -/************************************************/ -/* Extraction des caracteristiques de l'image */ -/* du fichier entete par l'appel a la fonction */ -/* cai_ouvre_lecture_radar */ -/************************************************/ - - image1 = cai_ouvre_lecture_radar ( repertoire,nom_ima, &nb_can ,&nboct_pix , - &nb_col , &nb_lig ); - if ( image1 == NULL) goto ERREUR; - - image1->NB_CANAUX=nb_can; - image1->NB_COL=nb_col; - image1->NB_LIG=nb_lig; - image1->NBOCT_PIX=nboct_pix; - - -/************************************************/ -/* Constitution un a un des noms des fichiers */ -/* canaux et destruction */ -/************************************************/ -pch = image1->NOM_FIC_CAN; -for ( i_can = 0 ; i_can < nb_can ; i_can++ ) -{ - sprintf(nom_fic,"%s/%s",repertoire,pch); - cr_stat = stat ( nom_fic , &buf_stat ); - if ( cr_stat == 0 ) - unlink ( nom_fic ); - pch=pch+100; -} - - iret=cai_ferme_radar(image1); - -/************************************************/ -/* Destruction du fichier d'entete */ -/************************************************/ -sprintf(nom_fic ,"%s/%s.RAD", repertoire,nom_ima); -cr_stat = stat ( nom_fic , &buf_stat ); -if ( cr_stat == 0 ) - unlink ( nom_fic ); -else -{ - sprintf(nom_fic ,"%s/%s.rad", repertoire,nom_ima); - cr_stat = stat ( nom_fic , &buf_stat ); - if ( cr_stat == 0 ) - unlink ( nom_fic ); -} - -return (CAI_OK); - -ERREUR : - -return (CAI_KO); - - -} -/* - Fin de l'operation cai_dest_ima_radar -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_modifie_radar */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture-ecriture d'une image au format */ -/* ----- radar et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_modifie_radar (nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_modifie_radar (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_IMAGE *cai_ouvre_modifie_radar(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) - - -{ - FILE *fic_in; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char nom_fic_canal[1024]; /* nom fichier canal dont on teste existence*/ - char label[80]; /* contient un enregistrement du fichier */ - int nbplan; /* nombre de canaux dans le fichier en-tete */ - int retour; /* retour de la fonction comparaison chaines*/ - char *deb,*pch0; /* pointeurs sur chaine de caracteres */ - int ind,num; /* indice */ - int nboct; /* variables de travail */ - int ind_typ; /* Indice du type de codage radar */ - int is_Cplx; /* Indique si type complexe ou pas */ - char *type_machine; /* Type de codage de la machine */ - int cmp; /* variable de travail */ - - /*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - *nb_can=0; - *nb_lig=0; - *nb_col=0; - *nboct_pix = 0; - pch0=NULL; - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); - if (image1==NULL) - { - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_modifie"); - goto ERREUR; - } -/*................................................. - Constitution du nom du fichier entete - .................................................*/ - nom_fic[0]='\0'; - if ((long int)strlen(repert)== 0) - sprintf(repert,"./"); - sprintf(nom_fic,"%s/%s.rad",repert,nom_image); - sprintf(image1->NOM_IMAGE,"%s/%s",repert,nom_image); - - /*........................ - Ouverture du fichier entete - ..........................................*/ - fic_in=NULL; - fic_in=fopen(nom_fic,"rw"); - if (fic_in==NULL) - { -/* verification si extension en majuscule */ - nom_fic[0]='\0'; - sprintf(nom_fic,"%s/%s.RAD",repert,nom_image); - fic_in=fopen(nom_fic,"r"); - if (fic_in==NULL) - { - strcpy(CAI_ERREUR,"Erreur ouverture fichier entete RADAR-CNES"); - goto ERREUR; - } - } - /*.................................... - Decodage du nombre de colonnes - ............................................*/ - retour=fscanf(fic_in,"%s",label); - pch0=strstr(label,"NBCOLONNES"); - if (pch0==NULL) - { - sprintf(CAI_ERREUR,"Informations incoherentes NBCOLONNES dans %s", - nom_fic); - goto ERREUR; - } - retour=fscanf(fic_in,"%d",nb_col); - - - /*.................................... - Decodage du nombre de lignes - ............................................*/ - retour=fscanf(fic_in,"%s",label); - pch0=strstr(label,"NBLIGNES"); - if (pch0==NULL) - { - sprintf(CAI_ERREUR,"Informations incoherentes NBLIGNES dans %s", - nom_fic); - goto ERREUR; - } - retour=fscanf(fic_in,"%d",nb_lig); - - /*........................................ - Decodage du nombre de plans - .........................................*/ - retour=fscanf(fic_in,"%s",label); - pch0=strstr(label,"NBPLANS"); - if (pch0==NULL) - { - sprintf(CAI_ERREUR,"Informations incoherentes NBPLANS dans %s", - nom_fic); - goto ERREUR; - } - retour=fscanf(fic_in,"%d",&nbplan); - *nb_can=nbplan; - - /*........................................ - Recuperation du type de codage du plan .........................................*/ - retour=fscanf(fic_in,"%s",label); - pch0=strstr(label,"TYPECODAGE"); - if (pch0==NULL) - { - sprintf(CAI_ERREUR,"Informations incoherentes TYPECODAGE dans %s", - nom_fic); - goto ERREUR; - } - - retour=fscanf(fic_in,"%s",label); - pch0=cai_En_majuscule( label ); - -/* Verification si type de codage reconnu et recuperation de la taille pixel*/ - nboct = cai_istyp_radar(pch0,&ind_typ,&is_Cplx); - if (nboct == -1) - { - sprintf(CAI_ERREUR,"Type de codage du plan %s non reconnu ", - nom_fic_canal); - goto ERREUR; - } - *nboct_pix=nboct; - sprintf(image1->TYPE_COD,"%s",pch0); -/* ........................................................... - Determination du sens de codage de la machine de travail - .............................................................*/ - type_machine = cai_test_pFpf(); - -/*..................................................... - Recuperation du type de codage du plan (INTEL ou IEEE) .......................................................*/ - retour=fscanf(fic_in,"%s",label); - pch0=strstr(label,"SENSCODAGE"); - if (pch0==NULL) - { - sprintf(CAI_ERREUR,"Informations incoherentes SENSCODAGE dans %s", - nom_fic); - goto ERREUR; - } - - retour=fscanf(fic_in,"%s\n",label); - retour=strncmp(label,"IEEE",4); - if (retour==0) - sprintf(image1->COD_PIX,"BE"); - else - sprintf(image1->COD_PIX,"LE"); - cmp = strncmp(type_machine,image1->COD_PIX,2); - if (cmp!=0) - { -/*****************************************************************************/ -/* MOD : VERSION : 1.2 : FA : IMA-FA-011 pb inversion des octets complexes */ -/*****************************************************************************/ - if (is_Cplx==0) - image1->INV_OCTETS =1; - else - image1->INV_OCTETS =2; - } - else - { - image1->INV_OCTETS =0; - } -/*****************************************************************************/ -/* MOD : VERSION : 5.1 : DM : Maj du tag COD_PIX lorsque l'image est codée */ -/* en reel a partir du TYPE_CODE */ -/*****************************************************************************/ sprintf(image1->COD_PIX,"%s",image1->TYPE_COD); - -/*............................................... - Pour chaque plan , decodage des caracteristiques du plans -..................................................................*/ - deb=image1->NOM_FIC_CAN; - for (ind=0;ind<nbplan;ind++) - { -/* Recuperation nom du plan */ - retour=fscanf(fic_in,"%s",label); - sprintf(deb,"%s",label); - sprintf(nom_fic_canal,"%s/%s",repert,label); - deb = deb+100; - -/* Verification de l'existence du plan et ouverture */ - num=open(nom_fic_canal,O_RDWR|O_BINARY,0); - if (num!= -1) - { - image1->ACCES_CANAL_INT[ind]=num; - image1->POS_OCTET[ind]=0; - } - else - { - sprintf(CAI_ERREUR,"Impossible d'ouvrir le plan %s", - nom_fic_canal); - goto ERREUR; - } - } - - /*.................................. - Fermeture du fichier - ......................................*/ - if (fic_in!=NULL) fclose(fic_in); - - -/* sortie nominale */ - return(image1); - -ERREUR: -/* sortie en erreur */ - FREE(image1); - return (NULL); -} - -/* - Fin de l'operation cai_ouvre_modifie_radar -*/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_istyp_radar */ -/* ---------- */ -/* */ -/* ROLE : fonction de verification si pixels de type radar ou non */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : retour = cai_istyp_radar(type_code) */ -/* ---------------- */ -/* */ -/* type_code (E) (char *) : type de codage a verifier */ -/* ind_typ (S) (int *) : indice du type des pixels */ -/* is_Cplx (S) (int *) : 1 si type complexe, 0 si non */ -/* retour (S) (int) : nb d'octets par pixel si type reconnu */ -/* -1 si non reconnu */ -/* */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ -int cai_istyp_radar(char *type_code,int *ind_typ,int *is_Cplx ) -{ - int ind; /* indice de boucle sur les types reconnus */ - int trouve,icr; /* indice pour la recherche */ - -/* Initialisations diverses */ - trouve = 0; - ind = 0; - while ((trouve==0)&&(ind< CAI_NB_RADAR)) - { - icr=strncmp(type_code,CAI_RADAR_TYP[ind],strlen(type_code)); - if (icr==0) - trouve=1; - else - ind=ind+1; - } - - if (trouve ==1) - { - *ind_typ=ind; - ind=CAI_RADAR_LONG[ind]; - } - else - { - *ind_typ=-1; - ind=-1; - } - - if (type_code[0]=='C') - *is_Cplx=1; - else - *is_Cplx=0; - -/* sortie normale */ - return(ind); -} -/* - Fin de l'operation cai_istyp_radar -*/ diff --git a/Utilities/CAI/cai_dll/src/cai_rasterfile.c b/Utilities/CAI/cai_dll/src/cai_rasterfile.c deleted file mode 100755 index 15ebf31274c14fe462e17bfc6644c6734f83b1d4..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/src/cai_rasterfile.c +++ /dev/null @@ -1,1440 +0,0 @@ -/*****************************************************************************/ -/* */ -/* PROJET : COUCHE ACCES IMAGE */ -/* ------- */ -/* */ -/* MODULE : cai_rasterfile.c */ -/* ------- */ -/* */ -/* ROLE : Ce module rassemble toutes les fonctions d'acces aux images */ -/* ------- stockees au format rasterfile */ -/* */ -/* AUTEUR : R.CHAISEMARTIN (CISI) */ -/* ------- */ -/* */ -/* DATE DE CREATION : fevrier 1995 */ -/* ----------------- */ -/* */ -/* LANGAGE : C */ -/* -------- */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ -/* MOD : VERSION : 3.3 : DM :optimisation des acces */ -/*****************************************************************************/ -/* MOD : VERSION : 4.1 :FA:Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ -/* MOD : VERSION : 4.2 :FA:Verification que le nombre de canaux est 1 ou 3. */ -/* sunrasterfile est un format de restitution */ -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : DM : modifications pour compatibilite HP64bits */ -/*****************************************************************************/ -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : modifications fopen binaire pour PC/NT */ -/*****************************************************************************/ -/* MOD : VERSION : 4.4 : DM : modifications open binaire pour PC/NT */ -/*****************************************************************************/ -/* MOD : VERSION : 4.5 : FA : test sur fclose pour PC/LINUX */ -/*****************************************************************************/ -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : FA : == au lieu de = simple */ -/* image1->MODE == CAI_ECRITURE */ -/*****************************************************************************/ - - -/*---------------------------------------------------------------------------*/ -/* Inclusion des fichiers STANDARDS (.h) */ -/*---------------------------------------------------------------------------*/ - - -# include <stdio.h> -# include <string.h> -# include <stdlib.h> -# include <unistd.h> -# include <sys/types.h> -#include <dirent.h> -# include <sys/stat.h> -# include <fcntl.h> - -#define _CAI_IMAGE -#define IN_CAI_RASTER - -# include "cai_image.h" - -/*----------------------------------------------------------------------------*/ -/* Variable pour la gestion en configuration */ -/*----------------------------------------------------------------------------*/ -static char *rcs_id="$Header: cai_rasterfile.c,v 1.11 01/05/31 10:47:16 cmf Exp $"; - -extern char *getenv(); - -/*****************************************************************************/ -/*****************************************************************************/ -/* */ -/* Definition des OPERATIONS EXTERNES */ -/* */ -/*****************************************************************************/ -/*****************************************************************************/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_liste_ima_sun_raster */ -/* ---------- */ -/* */ -/* ROLE : fonction de listage des images au format rasterfile */ -/* ------ */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : int cai_liste_ima_sun_raster(repert,tab_ima) */ -/* ----------------- */ -/* */ -/* repert (E) (char *) : repertoire a explorer */ -/* tab_ima (S) (char ***) : pointeur sur tableau des images listees*/ -/* alloue par la fonction,il doit etre */ -/* LIBERE PAR L'APPELANT */ -/* */ -/* cai_liste_ima_sun_raster (S) (int) : = -1 repertoire inexistant */ /* = > 0 nombre d'images listees */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -long int cai_liste_ima_sun_raster (char *repert, - char ***tab_ima) - - -{ - DIR *dirp; /* pointeur sur structure ouverture repertoire */ - struct dirent *dp; /* structure resultat de la fonction readdir */ - char *pch0,*pch1; /* pointeurs sur chaine de caracteres */ - char *pch2,*pch3; /* pointeurs sur chaine de caracteres */ - char car; /* variable de travail */ - int nb_ima; /* nombre d'images rasterfile identifiees */ - int i; /* indice de boucle */ - - -/*........................................ - INITIALISATION et ouverture du repertoire choisi - .........................................*/ - nb_ima=0; - - dirp=opendir(repert); - - if(dirp!=NULL) - { - -/*...................................... - premiere passe pour comptabiliser les images du format donne - - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE sun_raster_file - (EXTENSION =.srf) - ..........................................*/ - - - while((dp=readdir(dirp))!=NULL) - { - - car='.'; - pch0=strrchr(dp->d_name,car); - if (pch0 != NULL) - { - car='s'; - pch1=strrchr(dp->d_name,car); - if ((pch1 != NULL)&&(pch1==pch0+1)) - { - car='r'; - pch2=strrchr(dp->d_name,car); - if ((pch2 != NULL)&&(pch2==pch1+1)) - { - car='f'; - pch3=strrchr(dp->d_name,car); - if ((pch3 != NULL)&&(pch3==pch2+1)) - { - - *pch0=' '; - *pch1=' '; - *pch2=' '; - *pch3=' '; - nb_ima=nb_ima+1; - } - } - } - } - } - - (void)closedir(dirp); -/*..................................... - ALLOCATION DU TABLEAU CONTENANT LA LISTE DES IMAGES - ......................................*/ - *tab_ima = (char **) calloc(nb_ima,sizeof(char *)); - for (i=0;i<nb_ima;i=i+1) - (*tab_ima)[i]=(char *)calloc(1,100); - -/*...................................... - - deuxieme passe pour constituer la liste des images du format donne - - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE RASTERFILE - (EXTENSION =.srf) - SI C`EST LE CAS,STOCKAGE DANS LA LISTE - ..........................................*/ - dirp=opendir(repert); - - nb_ima=0; - while((dp=readdir(dirp))!=NULL) - { - - car='.'; - pch0=strrchr(dp->d_name,car); - if (pch0 != NULL) - { - car='s'; - pch1=strrchr(dp->d_name,car); - if ((pch1 != NULL)&&(pch1==pch0+1)) - { - car='r'; - pch2=strrchr(dp->d_name,car); - if ((pch2 != NULL)&&(pch2==pch1+1)) - { - car='f'; - pch3=strrchr(dp->d_name,car); - if ((pch3 != NULL)&&(pch3==pch2+1)) - { - - *pch0=' '; - *pch1=' '; - *pch2=' '; - *pch3=' '; - strcpy((*tab_ima)[nb_ima],dp->d_name); - nb_ima=nb_ima+1; - } - } - } - } - } - - (void)closedir(dirp); - - } - else - { - /* Erreur:Repertoire inexistant */ - nb_ima=-1; - } - - return(nb_ima); - -} -/* Fin de l'operation cai_liste_ima_sun_raster -*/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_lecture_sun_raster */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture d'une image au format rasterfile*/ -/* ----- et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_lecture_sun_raster(nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_lecture_sun_raster (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_IMAGE *cai_ouvre_lecture_sun_raster(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) - -{ - FILE *fic_in; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - int iret; /* indicateur de retour ok ou pas */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char *deb,*deb1; /* pointeurs sur chaine de caracteres */ - int i,j,ind; /* indice */ - int ras_type; /* type de fichier raster */ - int fic; /* code retour fonction open */ - unsigned char *colormap; /* tableau de colormap */ - unsigned char *pch; - int taille; - long li; - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - *nb_can=0; - *nb_lig=0; - *nb_col=0; - *nboct_pix=0; - iret=1; - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); -/*****************************************************************************/ -/* MOD : VERSION : 4.1 :FA:Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur allocation memoire dans cai_ouvre_lecture"); - } - else - { -/*................................................. - Constitution du nom du fichier SUN_RASTER srf - .................................................*/ - nom_fic[0]='\0'; - if((long int)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s.srf",repert,nom_image); - - } - else - { - sprintf(nom_fic,"%s.srf",nom_image); - } -/*........................ - Ouverture du fichier entete - ..........................................*/ - fic_in=fopen(nom_fic,"rb"); - if (fic_in==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur ouverture fichier sun_raster"); - } - else - { -/*.................................... - positionnement sur le nombre de colonnes */ - fseek(fic_in,4,0); - -/* recuperation du nombre de colonnes -............................................*/ - - li=fread(nb_col,4,1,fic_in); - - /*.................................... - recuperation du nombre de lignes -............................................*/ - - fread(nb_lig,4,1,fic_in); - -/*...................................... - recuperation du nombre de canaux -............................................*/ - fread(nb_can,4,1,fic_in); - if ((*nb_can!=8)&&(*nb_can!=24)) - { - iret=0; - strcpy(CAI_ERREUR,"Profondeur encodage ni 8 ni 24. Format non traite"); - } - else - { - - *nb_can=(*nb_can)/8; -/*......................................... - recuperation du type de fichier - ............................................*/ - - fseek(fic_in,4,1); - fread(&ras_type,4,1,fic_in); - if (ras_type!=1) - { - iret=0; - strcpy(CAI_ERREUR,"Type de fichier non standard.Non traite"); - } - else - { -/*......................................... - recuperation du nombre d'octets de colormap - ............................................*/ - fseek(fic_in,4,1); - fread(nboct_pix,4,1,fic_in); - image1->COLORMAP=*nboct_pix; - if (image1->COLORMAP != 0) - { -/*..................................................... - lecture de la colormap si elle existe - ......................................................*/ - colormap = (unsigned char *) malloc(image1->COLORMAP); - image1->TABCOLOR = (int *)malloc(sizeof(int)*768); - if (image1->TABCOLOR == NULL) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Probleme d'allocation memoire"); - } - - if (colormap == NULL) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Probleme d'allocation memoire"); - } - else - { - li=fread(colormap,image1->COLORMAP,1,fic_in); - pch=colormap; - taille=(image1->COLORMAP/3); -/* -------------- recuperation pour chaque couleur R V B ----*/ - for(j=0;j<3;j++) - { - for (i=0;i<taille;i++) - { - ind=i+(j*256); - image1->TABCOLOR[ind]=(int)(*pch); - pch=pch+1; - } - for (i=taille;i<256;i++) - { - ind=i+(j*256); - image1->TABCOLOR[ind]=0; - - } - } - free(colormap); - } - } -/*......................................... - recuperation du nombre d'octets par pixel - .................................................*/ - *nboct_pix=1; - image1->NB_BITS_PIX=1; - sprintf(image1->COD_PIX,"OCT"); - - } - } - } - - if (fic_in!=NULL) fclose(fic_in); -/*....................................... - INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL - .....................................................*/ - fic=NULL; - fic=open(nom_fic,O_RDONLY|O_BINARY,0); - if (fic == -1) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur ouverture fichier sun_raster"); - } - else - { - - deb = image1->NOM_FIC_CAN; - deb1= image1->NOM_UTIL_CAN; - - for (i=0;i<*nb_can;i=i+1) - { - sprintf(deb,"%s.srf",nom_image); - deb=deb+100; - sprintf(deb1,"%s.srf",nom_image); - deb1=deb1+100; - image1->POS_OCTET[i]=32+image1->COLORMAP; - image1->ACCES_CANAL_INT[i]=fic; - } - - } - } - if (iret == 0) - return (NULL); - else - return(image1); - -} -/* - Fin de l'operation cai_ouvre_lecture_sun_raster -*/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_creation_sun_raster */ -/* ---------- */ -/* */ -/* ROLE : fonction de creation et d'ouverture en ecriture d'une image */ -/* ----- au format rasterfile et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_creation_sun_raster(nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig, */ -/* label) */ -/* */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* nb_can (E) (int ) : nombre de canaux de l'image */ -/* nboct_pix (E) (int ) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (E) (int ) : nombre de lignes de l'image */ -/* nb_col (E) (int ) : nombre de colonnes de l'image */ -/* label (E) (char *) : commentaire lie a l'image */ -/* */ -/* cai_ouvre_creation_sun_raster (S) (CAI_IMAGE *) : =NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -#define RAS_MAGIC 0x59a66a95 - - -CAI_IMAGE *cai_ouvre_creation_sun_raster(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig, - char *label) - -{ - FILE *fic; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - char nom_fic[1024]; /* nom du fichier en-tete */ - long retour; /* retour de fonction */ - int i,num; /* indice */ - struct stat buf_stat; /* structure decrivant status de fichier */ - unsigned char *buff; /* pointeur sur buffer fichier */ - int taille; /* taille du fichier en octets */ - int ras_depth; /* profondeur d'encodage du pixel 8 ou 24 */ - int ras_magic; /* nombre magique raster file */ - int ras_length; /* nb octets total de l'image */ - int ras_type; /* type de fichier 1=sun raster standard */ - - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); -/*****************************************************************************/ -/* MOD : VERSION : 4.1 :FA:Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_creation"); - goto ERREUR; - } - - -/*************************************************/ -/* Les donnees doivent etre codees sur 8 bits */ -/*************************************************/ - - if ( *nboct_pix != 1 ) - { - strcpy ( CAI_ERREUR , - "Erreur : les donnees doivent etre codees sur 8 bits\n"); - goto ERREUR; - } -/*****************************************************************************/ -/* MOD : VERSION : 4.2 :FA:Verification que le nombre de canaux est 1 ou 3. */ -/* sunrasterfile est un format de restitution */ -/*****************************************************************************/ -/* Verification sur le nombre de canaux 1(noir&blanc) ou 3 (RVB) */ - if ((*nb_can !=1)&&(*nb_can !=3)) - { - strcpy(CAI_ERREUR,"Erreur une image RASTERFILE a 1 ou 3 canaux exclusivement"); - goto ERREUR; - } - -/*................................................. - Constitution du nom du fichier entete et verification qu'il - n'existe pas deja . - .................................................*/ - - nom_fic[0]='\0'; - if((long int)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s.srf",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.srf",nom_image); - } - - retour = stat ( nom_fic , &buf_stat ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "L'image %s SUN_RASTER existe \n" , nom_image ); - goto ERREUR; - } - -/*************************************************/ -/* creation du fichier et reservation de la */ -/* place necessaire a l'ecriture de l'entete */ -/*************************************************/ -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : modifications fopen binaire pour PC/NT */ -/*****************************************************************************/ - - fic = fopen ( nom_fic, "wb" ); - if ( nom_fic == NULL ) - { - sprintf ( CAI_ERREUR , "Erreur : creation fichier %s impossible\n" , - nom_fic ); - goto ERREUR; - } - - taille=32 ; - - buff = (unsigned char *) malloc (taille); - if ( buff== NULL ) - { - strcpy ( CAI_ERREUR , "Erreur : probleme d'allocation \n" ); - unlink(nom_fic); - goto ERREUR; - } - - ras_length=(*nb_lig)*(*nb_col)*(*nb_can); - if ((*nb_col)%2!=0) - ras_length=ras_length+(*nb_lig); - ras_magic=RAS_MAGIC; - ras_depth=(*nb_can)*8; - ras_type=1; - memcpy ( &buff[0] , &ras_magic , 4); - memcpy ( &buff[4] , nb_col , 4 ); - memcpy ( &buff[8] , nb_lig , 4 ); - memcpy ( &buff[12] , &ras_depth , 4 ); - memcpy ( &buff[16] , &ras_length, 4 ); - memcpy ( &buff[20] , &ras_type, 4 ); - - - for ( i = 24 ; i < taille ; i++ ) - { - buff[i] = 0; - } - - retour= fwrite ( buff , taille , 1 , fic ); - if ( retour == 0 ) - { - sprintf (CAI_ERREUR , "Erreur : ecriture impossible dans fichier %s\n", - nom_fic ); - goto ERREUR; - } - - - - free ( buff ); - if (fic!=NULL) fclose(fic); - -/*................................................. - Ouverture du fichier pour ecriture radiometrie - ...................................................*/ - num = open(nom_fic,O_RDWR|O_BINARY,0); - if (num == -1) - { - sprintf(CAI_ERREUR,"Erreur: Creation %s impossible\n",nom_fic); - goto ERREUR; - } - for (i=0;i<*nb_can;i=i+1) - { - image1->ACCES_CANAL_INT[i]=num; - image1->POS_OCTET[i]=32; - } - - return (image1); - -ERREUR : - return(NULL); -} - -/* - Fin de l'operation cai_ouvre_creation_sun_raster -*/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_lecture_canal_sun_raster */ -/* ---------- */ -/* */ -/* ROLE : fonction de lecture d'un canal d'une image rasterfile */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_lecture_canal_sun_raster(image1, canal, */ /* ------------------ premiere_ligne, */ -/* premiere_colonne, */ -/* nombre_lignes_lire , */ -/* nombre_colonnes_lire, */ -/* pas_ligne , */ -/* pas_colonne, */ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a lire */ -/* premiere_ligne (E) (int) : premiere ligne a lire dans l'image */ -/* premiere _colonne (E) (int) : premiere colonne a lire dans l'image */ -/* nombre_lignes_lire (E) (int) : nombre de lignes a lire */ -/* nombre_colonnes_lire (E) (int) : nombre de colonnes a lire */ -/* pas_ligne (E) (int) : pas en ligne */ -/* pas_colonne (E) (int) : pas en colonne */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels lus alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_lecture_canal_sun_raster (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - - -CAI_OK_KO cai_lecture_canal_sun_raster( CAI_IMAGE *image1 , - int *canal , - int *premiere_ligne , - int *premiere_colonne, - int *nombre_lignes_lire , - int *nombre_colonnes_lire, - int *pas_ligne , - int *pas_colonne, - unsigned char *data_image ) -{ - int num,i,j,k; /* variables de travail */ - long pt_oct,n; /* position courante dans le fichier image */ - int no_oct; /* numero du premier octet a lire */ - int iret; /* indicateur d'erreur */ - int lig; /* indice de boucle sur les lignes */ - int oct_pix; /* nb octets par pixels */ - long nb_oct; /* nb oct =1er octet a lire - position courante */ - unsigned char *buf_lec; /* buffer lecture d'une ligne */ - unsigned char *deb,*pch; /* pointeur chaine pour transfert buffer sortie */ - int Arrond; /* pixels rajoutes pour arrondi 2 octets */ - - -/*........................... - Initialisations diverses - ..........................*/ - iret=CAI_OK; - strcpy(CAI_ERREUR," "); - lig=*premiere_ligne; - i=1; - pch=data_image; - num = image1->ACCES_CANAL_INT[*canal-1]; - oct_pix = image1->NBOCT_PIX; - -/*.............................................. - allocation de memoire pour lire une ligne image - ............................................. */ - - buf_lec = (unsigned char *) malloc(image1->NB_COL*oct_pix*image1->NB_CANAUX); - if (buf_lec == NULL) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Probleme d'allocation memoire"); - } - else - { -/*..................... - Pour chaque ligne a lire - .......................................*/ - while ((i <= *nombre_lignes_lire)&&(iret==CAI_OK)) - { -/*............................................ - Recherche de la position courante dans le fichier - ............................................*/ - pt_oct=lseek(num,0L,1); - -/*................................ - Calcul du numero du 1er octet a lire - ....................................*/ - if ( image1->NB_COL%2 == 0 ) - Arrond=0; - else - Arrond=(lig-1); - no_oct= image1->POS_OCTET[*canal-1] + Arrond + - (lig-1)*(image1->NB_COL)*(oct_pix)*(image1->NB_CANAUX); - - -/*.................................. - Saut d'octets pour etre positionne sur la ligne a lire - .......................................*/ - nb_oct=(long)(no_oct-pt_oct); - lseek(num,nb_oct,1); - -/*........................................... - lecture d'une ligne image - ................................................*/ - n=read(num,buf_lec,(image1->NB_COL)*(oct_pix)*(image1->NB_CANAUX)); - - if (n<=0) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Erreur lecture donnee image sun_raster"); - } - else - { -/*...................................... - Sauvegarde des donnees lues en tenant compte du pas - d'echantillonnage en colonne - ........................................*/ - - deb=buf_lec+(((*premiere_colonne)-1)*(oct_pix)*(image1->NB_CANAUX))+ - (image1->NB_CANAUX-(*canal)); - j=1; - while (j <= *nombre_colonnes_lire) - { - for(k=0;k<oct_pix;k++) - { - *(pch+k)=*(deb+k); - } - j=j+1; - pch=pch+oct_pix; - deb=deb+((*pas_colonne)*(oct_pix)*(image1->NB_CANAUX)); - } - - } - i=i+1; - lig=lig+(*pas_ligne); - - } - - free(buf_lec); - } - - return(iret); -} -/* - Fin de l'operation cai_lecture_canal_sun_raster -*/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ecriture_canal_sun_raster */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ecriture d'un canal d'une image rasterfile */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ecriture_canal_sun_raster(image1, canal, */ /* ------------------ premiere_ligne, */ -/* nombre_lignes_ecrire, */ -/* nombre_colonnes_ecrire,*/ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a ecrire */ -/* premiere_ligne (E) (int) : premiere ligne a ecrire ds l'image */ -/* nombre_lignes_ecrire (E) (int) : nombre de lignes a ecrire */ -/* nombre_colonnes_ecrire(E) (int) : nombre de lignes a ecrire */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels ecris alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_ecriture_canal_sun_raster (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_OK_KO cai_ecriture_canal_sun_raster (CAI_IMAGE *image1 , - int *canal , - int *premiere_ligne , - int *nombre_lignes_ecrire , - int *nombre_colonnes_ecrire, - unsigned char *data_image ) -{ -long position_first_lig; /* position de la 1ere ligne a ecrire */ -long position_courante; /* position courante dans le fichie */ -long deplacement; /* deplacement a effectuer */ -int i_ligne; /* compteur de lignes */ -unsigned char *buff_lig; /* tableau contenant une ligne a ecrire */ -long cr_write; /* code retour de write */ -int num; /* descripteur de fichier */ -int nboct_pix; /* nombre d'octets par pixel */ -int i,j; /* indice de boucle sur les colonnes */ -long cr_read; /* code retour de la fonction read */ -int nb; /* nombre d'octets lus par le read */ -unsigned char *deb,*pch; /* pointeur sur chaine pour transfert */ -int nb_canaux; /* nombre de canaux de l'image */ -int Arrond; /* arrondi pour les lignes non paires */ - -/* ................ - Initialisations - .................*/ -i_ligne = 0; -num = image1->ACCES_CANAL_INT[(*canal)-1]; -nboct_pix = image1->NBOCT_PIX; -nb_canaux = image1->NB_CANAUX; - -/*************************************************/ -/* Les donnees doivent etre codees sur 8 bits */ -/*************************************************/ - -if ( nboct_pix != 1 ) -{ - strcpy ( CAI_ERREUR , - "Erreur : les donnees doivent etre codees sur 8 bits\n"); - goto ERREUR; -} - - -/********************************************************/ -/* Calcul de la position de la premiere ligne a ecrire */ -/********************************************************/ -Arrond=0; -if (*nombre_colonnes_ecrire%2 !=0) - Arrond=((*premiere_ligne) - 1); -position_first_lig = (long) ( image1->POS_OCTET[*canal-1] + Arrond + - ((*premiere_ligne) - 1) *(*nombre_colonnes_ecrire)*nb_canaux ); -/********************************************************/ -/* Recuperation de la position courante */ -/********************************************************/ - -position_courante = lseek ( num , 0L , 1 ); - - -/************************************************************************/ -/* Deplacement jusqu'au premier pixel de la premiere ligne a ecrire */ -/************************************************************************/ - -deplacement = position_first_lig - position_courante; -lseek ( num , deplacement , 1 ); -nb=(*nombre_colonnes_ecrire)*nb_canaux; -if (*nombre_colonnes_ecrire%2 !=0) - nb=nb+1; -buff_lig=(unsigned char *)(calloc(nb,sizeof(unsigned char))); -if (buff_lig == NULL) -{ - strcpy(CAI_ERREUR,"Probleme d'allocation memoire ecriture"); - goto ERREUR; - } - -pch=data_image; - -/********************************************************/ -/* TANT QUE il y a des lignes a ecrire */ -/********************************************************/ -while (i_ligne < (*nombre_lignes_ecrire)) -{ - -cr_read=read(num,buff_lig,nb); -if (cr_read <0) - { - strcpy ( CAI_ERREUR , "Erreur ecriture canal image sun_raster\n" ); - goto ERREUR; - } -else - { - if (cr_read==0) - { - for (i=0;i<nb;i++) - *(buff_lig+i)=0; - deplacement=0; - } - else - deplacement= - nb; - } -/************************************************************************/ -/* Redeplacement jusqu'au premier pixel de la premiere ligne a ecrire */ -/************************************************************************/ -lseek ( num , deplacement , 1 ); - -/*************************************************************************/ -/*chargement de la ligne en entrelacant les pixels par rapport aux canaux*/ -/*************************************************************************/ - -deb=buff_lig+(nb_canaux-(*canal)); -for (j=0;j<(*nombre_colonnes_ecrire);j=j+1) -{ - *deb=*pch; - pch=pch+1; - deb=deb+nb_canaux; -} - -/********************************************************/ -/* ecriture de la ligne */ -/********************************************************/ - - cr_write = write ( num , buff_lig , nb ); - - if ( cr_write != nb ) - { - strcpy ( CAI_ERREUR , "Erreur ecriture canal image sun_raster\n" ); - goto ERREUR; - } -/********************************************************/ -/* incrementation du nombre de lignes */ -/********************************************************/ - - i_ligne++; - -/********************************************************/ -/* FIN TANT QUE */ -/********************************************************/ -} -free(buff_lig); - -return (CAI_OK); - -ERREUR : - -return (CAI_KO); - - -} - -/* - Fin de l'operation cai_ecriture_canal_sun_raster -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ferme_sun_raster */ -/* ---------- */ -/* */ -/* ROLE : fonction de fermeture d'une image au format rasterfile et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ferme_sun_raster(image1) */ /* ------------------ */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* */ -/* cai_ferme_sun_raster (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_OK_KO cai_ferme_sun_raster (CAI_IMAGE *image1) - - -{ - long iret; /* code retour de l'operation */ - int num; /* descripteur du fichier a fermer */ - unsigned char *colormap; /* tableau de colormap */ - unsigned char *pch; /* pointeur de travail */ - int i; /* indice de boucle */ - long int pos_cour,li; /* position courante */ - long int deplacement; /* deplacement a effectuer */ - unsigned char *buf; /* buffer de lecture de l'image */ - int taille; /* taille totale de l'image (oct) */ - int val; /* variable intermediaire */ - - - iret=CAI_OK; - num=image1->ACCES_CANAL_INT[0]; - -/*............................................. - Traitement de la Colormap si ecriture - .............................................*/ -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : FA : == au lieu de = simple */ -/* image1->MODE == CAI_ECRITURE */ -/*****************************************************************************/ - - if ((image1->COLORMAP !=0) && (image1->MODE == CAI_ECRITURE)) - { -/*--- recuperation de la position courante ---*/ - pos_cour=lseek(num,0L,1); - -/*-- on se positionne sur le debut de la radiometrie --*/ - deplacement = 32 - pos_cour; - lseek(num,deplacement,1); - -/*--- lecture de l'image rasterfile ---*/ - taille = image1->NB_LIG*image1->NB_COL*image1->NB_CANAUX; - buf = (unsigned char *)malloc(taille); - li=read(num,buf,taille); - -/*--- recuperation de la position courante ---*/ - pos_cour=lseek(num,0L,1); - -/*-- on se positionne sur le debut des caracteristiques COLORMAP --*/ - deplacement = 24 - pos_cour; - lseek(num,deplacement,1); - -/*-- positionnement de l'indicateur de presence colormap --*/ - val=1; - li=write(num,(char *)(&val),4); - -/*-- positionnement de la taille de la colormap --*/ - val=image1->COLORMAP; - li=write(num,(char *)(&val),4); - -/*--- recuperation de la Colormap ---*/ - colormap = (unsigned char *) malloc(image1->COLORMAP); - pch=colormap; - for (i=0;i<image1->COLORMAP;i++) - { - *pch = (unsigned char )(image1->TABCOLOR[i]); - pch=pch+1; - } - -/*--- ecriture des octets de colormap dans l'image ---*/ - iret=write(num,colormap,image1->COLORMAP); - if (iret != image1->COLORMAP) - { - strcpy(CAI_ERREUR,"Erreur ecriture Colormap rasterfile "); - iret=CAI_KO; - } - else - { -/*--- ecriture de l'image ---*/ - iret=write(num,buf,taille); - } - free(buf); - free(colormap); - - - } - -/*............................................. - Fermeture de tous les canaux qui sont tous contenus - dans un seul fichier .srf - .............................................*/ - - if (num>0) close(num); - - return (iret); -} - -/* - Fin de l'operation cai_ferme_sun_raster -*/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_dest_ima_sun_raster */ -/* ---------- */ -/* */ -/* ROLE : fonction de destruction d'une image stocke en rasterfile et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_dest_ima_sun_raster(format,nom_ima) */ /* ------------------ */ -/* format (E) (char *) : format de l'image a detruire */ -/* nom_image (E) (char *) : nom de l'image a detruire avec repertoire */ -/* */ -/* cai_dest_ima_sun_raster (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK_KO si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_OK_KO cai_dest_ima_sun_raster (char * repertoire , - char *nom_ima ) - -{ - -char nom_fic[1024]; /* nom du fichier entete a detruire */ -char nom_ima_complet[1024]; /* repertoire + nom de l'image */ -int cr_stat; /* code retour de fonction status de fichier */ -struct stat buf_stat; /* structure decrivant status de fichier */ - - -/************************************************/ -/* Constitution du nom du fichier d'entete */ -/************************************************/ -if ((long)strlen(repertoire)!= 0) -{ - sprintf ( nom_ima_complet, "%s/%s",repertoire,nom_ima ); -} -else -{ - strcpy ( nom_ima_complet , nom_ima); -} -sprintf ( nom_fic , "%s.srf" ,nom_ima_complet); - -/************************************************/ -/* Destruction du fichier sun_raster */ -/************************************************/ - -cr_stat = stat ( nom_fic , &buf_stat ); -if ( cr_stat == 0 ) - unlink ( nom_fic ); - - -return (CAI_OK); - - -} -/* - Fin de l'operation cai_dest_ima_sun_raster -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_modifie_sun_raster */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture-ecriture d'une image au format */ -/* ----- rasterfile et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_modifie_sun_raster(nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_modifie_sun_raster (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_IMAGE *cai_ouvre_modifie_sun_raster(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) - -{ - FILE *fic_in; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - int iret; /* indicateur de retour ok ou pas */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char *deb,*deb1; /* pointeurs sur chaine de caracteres */ - int i,j,ind; /* indice */ - int ras_type; /* type de fichier raster */ - int fic; /* code retour fonction open */ - unsigned char *colormap; /* tableau de colormap */ - unsigned char *pch; - int taille; - long li; - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - *nb_can=0; - *nb_lig=0; - *nb_col=0; - *nboct_pix=0; - iret=1; - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); -/*****************************************************************************/ -/* MOD : VERSION : 4.1 :FA:Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_modifie"); - } - else - { -/*................................................. - Constitution du nom du fichier SUN_RASTER srf - .................................................*/ - nom_fic[0]='\0'; - if((long int)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s.srf",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.srf",nom_image); - } -/*........................ - Ouverture du fichier entete - ..........................................*/ - fic_in=fopen(nom_fic,"rb"); - if (fic_in==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur ouverture fichier sun_raster"); - } - else - { -/*.................................... - positionnement sur le nombre de colonnes */ - fseek(fic_in,4,0); - -/* recuperation du nombre de colonnes -............................................*/ - - li=fread(nb_col,4,1,fic_in); - - /*.................................... - recuperation du nombre de lignes -............................................*/ - - fread(nb_lig,4,1,fic_in); - -/*...................................... - recuperation du nombre de canaux -............................................*/ - fread(nb_can,4,1,fic_in); - if ((*nb_can!=8)&&(*nb_can!=24)) - { - iret=0; - strcpy(CAI_ERREUR,"Profondeur encodage ni 8 ni 24. Format non traite"); - } - else - { - - *nb_can=(*nb_can)/8; -/*......................................... - recuperation du type de fichier - ............................................*/ - - fseek(fic_in,4,1); - fread(&ras_type,4,1,fic_in); - if (ras_type!=1) - { - iret=0; - strcpy(CAI_ERREUR,"Type de fichier non standard.Non traite"); - } - else - { -/*......................................... - recuperation du nombre d'octets de colormap - ............................................*/ - fseek(fic_in,4,1); - fread(nboct_pix,4,1,fic_in); - image1->COLORMAP=*nboct_pix; - if (image1->COLORMAP != 0) - { -/*..................................................... - lecture de la colormap si elle existe - ......................................................*/ - colormap = (unsigned char *) malloc(image1->COLORMAP); - image1->TABCOLOR = (int *)malloc(sizeof(int)*768); - if (image1->TABCOLOR == NULL) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Probleme d'allocation memoire"); - } - - if (colormap == NULL) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Probleme d'allocation memoire"); - } - else - { - li=fread(colormap,image1->COLORMAP,1,fic_in); - pch=colormap; - taille=(image1->COLORMAP/3); -/* -------------- recuperation pour chaque couleur R V B ----*/ - for(j=0;j<3;j++) - { - for (i=0;i<taille;i++) - { - ind=i+(j*256); - image1->TABCOLOR[ind]=(int)(*pch); - pch=pch+1; - } - for (i=taille;i<256;i++) - { - ind=i+(j*256); - image1->TABCOLOR[ind]=0; - - } - } - free(colormap); - } - } -/*......................................... - recuperation du nombre d'octets par pixel - .................................................*/ - *nboct_pix=1; - image1->NB_BITS_PIX=1; - sprintf(image1->COD_PIX,"OCT"); - } - } - } - - if (fic_in!=NULL) fclose(fic_in); -/*....................................... - INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL - .....................................................*/ - - fic=open(nom_fic,O_RDWR|O_BINARY,0); - if (fic == -1) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur ouverture fichier sun_raster"); - } - else - { - - deb = image1->NOM_FIC_CAN; - deb1= image1->NOM_UTIL_CAN; - - for (i=0;i<*nb_can;i=i+1) - { - sprintf(deb,"%s.srf",nom_image); - deb=deb+100; - sprintf(deb1,"%s.srf",nom_image); - deb1=deb1+100; - image1->POS_OCTET[i]=32+image1->COLORMAP; - image1->ACCES_CANAL_INT[i]=fic; - } - - } - } - if (iret == 0) - return (NULL); - else - return(image1); - -}/* - Fin de l'operation cai_ouvre_modifie_sun_raster -*/ diff --git a/Utilities/CAI/cai_dll/src/cai_spot.c b/Utilities/CAI/cai_dll/src/cai_spot.c deleted file mode 100755 index ce687ed63742f7fe419cd1f38c9864f89b4c99ae..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/src/cai_spot.c +++ /dev/null @@ -1,22134 +0,0 @@ -/*****************************************************************************/ -/* PROJET : COUCHE ACCES IMAGE */ -/* ------- */ -/* */ -/* MODULE : cai_spot.c */ -/* ------- */ -/* */ -/* ROLE : Ce module rassemble toutes les fonctions d'acces aux images */ -/* ------- stockees au format spot */ -/* */ -/* AUTEUR : (CS-SI) */ -/* ------- */ -/* */ -/* DATE DE CREATION : Octobre 2000 */ -/* ----------------- */ -/* */ -/* LANGAGE : C */ -/* -------- */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ -/* MOD : VERSION : 4.4 : DM : prise en compte ecriture SPOT5 TIF et BIL */ -/*****************************************************************************/ -/* MOD : VERSION : 4.5 : FA : test sur fclose pour PC/LINUX */ -/*****************************************************************************/ -/* MOD : VERSION : 4.5 : FA : initialisation de image1=NULL a l'ouverture */ -/*****************************************************************************/ -/* MOD : VERSION : 4.5 : FA : anomalie sur sous-echantillonnage en lecture */ -/*****************************************************************************/ -/* MOD : VERSION : 4.5 : FA : erreur d'orthographe sur LATITUDE_ARGUMENT */ -/* et Look_Angles */ -/*****************************************************************************/ -/* MOD : VERSION : 4.5 : FA : erreur d'ecriture detector_id lookangle pour */ -/* PAN */ -/*****************************************************************************/ -/* MOD : VERSION : 4.5 : FA : erreur conversion jour julien dans CAI */ -/*****************************************************************************/ -/* MOD : VERSION : 4.5 : FA : Initialisation du champ COD_PIX (OCT,I2 ou UND)*/ -/*****************************************************************************/ -/* MOD : VERSION : 4.5 : FA : erreur d'ecriture detector_id lookangle pour */ -/* PAN */ -/*****************************************************************************/ -/* MOD : VERSION : 4.6 : FA : indice ind_tab_gain non initialise dans boucle */ -/*****************************************************************************/ -/* MOD : VERSION : 4.6 : FA : correction anomalie ecriture SOURCE_ID */ -/*****************************************************************************/ -/* MOD : VERSION : 4.6 : FA : pas d'ecriture <badlines> si pas de badlines */ -/*****************************************************************************/ -/*****************************************************************************/ -/* MOD : VERSION : 4.6 : FA : erreur calcul de la datation des attitudes */ -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : FA : erreur initialisation BYTEORDER en creation */ -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : FA : mot cle lignes perdues LOST au lieu de LOSS */ -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : LEAD_XX.dat devient METADATA.DIM */ -/* IMAG_XX.bil (tif) devient IMAGERY.BIL (.TIF) */ -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : FA : Prise en compte date de la scene non shiftée */ -/****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'attribut href="" */ -/****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'attribut version="5.2" */ -/****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element PIXEL_ORIGIN */ -/****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element TIE_POINTS_CRS_Z */ -/****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Deplacement de Simplified_Location_Model */ -/****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element lc_List */ -/****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element pc_List */ -/****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout attribut href="http://www.spotimage.fr" */ -/****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element DATA_TYPE */ -/****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : remplacement de SATURATE par SATURATED */ -/****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : remplacement 255 par 1 dans les element LEVEL */ -/****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : remplacement de BAND par BAND_DESCRIPTION */ -/****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : ajout de l'unite dans PHYSICAL_UNIT */ -/****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element Bad_Line_List */ -/****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ds les dates, utilisation du . au lieu de , */ -/* Separation de la date et heure par "T" */ -/****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element Look_Angles_List */ -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element Angles_List */ -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element Angular_Speeds_List */ -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element Instrument_look_Angles_List */ -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : FA : SPECIAL_VALUE_TEXT NODATA a la place NO_DATA */ -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Version DIMAP passe de 2.0 à 2.9 */ -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Rajouter ALPHA_LEVEL unqiement pour SPOT4 MIR */ -/*****************************************************************************/ -/* MOD : VERSION : 4.8 : FA : Rajout SCENE au début de chaine DATASET_NAME */ -/*****************************************************************************/ -/* MOD : VERSION : 4.8 : FA : Enlever le signe + pour FRAME_ROW, FRAME_COL */ -/* et pour TIE_POINTS_DATA_X et TIE_POINTS_DATA_Y */ -/*****************************************************************************/ -/* MOD : VERSION : 4.8 : FA : Blindage de la reconnaissance du fichier image */ -/*****************************************************************************/ -/* MOD : VERSION : 5.0 : DM : Remplacer les appels systemes pour renommer un */ -/* fichier par la commande C rename */ -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : FA : DIMAP Ajouter un espace entre SCENE et numsat */ -/* dans le DATASET_NAME */ -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : FA : DIMAP dans le DATASET_FRAME, inversion des deux*/ -/* derniers vertex : à mettre dans l'ordre */ -/* NO,NE,SE,SO */ -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : DIMAP remplissage des tags HORIZONTAL_CS_CODE */ -/* et HORIZONTAL_CS_NAME avec des valeurs défauts */ -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : DIMAP tag LOOK_ANGLE_LIST valeurs de PSI_X et */ -/* PSI_Y 1er et dernier detecteur inverses */ -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : Prise en compte de la lecture sur systeme LE */ -/* pour inversion des octets SPOT1A4 */ -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : FA : Correction sprintf(nom_fic,"IMAGERY") au lieu */ -/* de sprintf(nom_fic,"IMAGERY",nom_rep) */ -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : FA : Correction de */ -/* sprintf(valeur,"%d", (ind_tab_gain+1+1500*i)) au lieu de */ -/* sprintf(valeur,"%f", (ind_tab_gain+1+1500*i)) */ -/*****************************************************************************/ -/* MOD : VERSION : 5.3 : DM : portage de la couche CAI dans plateforme */ -/* Microsof Visual C++ V6.0 */ -/*****************************************************************************/ - - - - -/*---------------------------------------------------------------------------*/ -/* Inclusion des fichiers STANDARDS (.h) */ -/*---------------------------------------------------------------------------*/ - - -# include <stdio.h> -# include <string.h> -# ifndef _MSC_VER -# include <strings.h> -# endif -#include <stdlib.h> -# include <sys/types.h> -# include <dirent.h> -# include <sys/stat.h> -# include <fcntl.h> -# include <malloc.h> -# include <math.h> -# include <unistd.h> -# include <limits.h> -#include <ctype.h> -#include <errno.h> -#include <time.h> - -#define _CAI_IMAGE -#define IN_CAI_SPOT - -# include "cai_image.h" - -/*----------------------------------------------------------------------------*/ -/* Definition des CONSTANTES PROPRES */ -/*----------------------------------------------------------------------------*/ - -#define FREE(A) { if ((A)!=NULL) { free(A); (A)=NULL; } } -#define NOMBRE_DE_BITS "NBITS" -#define NOMBRE_DE_LIGNES "NROWS" -#define NOMBRE_DE_COLONNES "NCOLS" -#define NOMBRE_DE_CANAUX "NBANDS" -#define ORDRE_LECTURE_OCTETS "BYTEORDER" -#define NB_OCTETS_A_SAUTER "SKIPBYTES" -#define NB_SEC_PAR_JOUR 86400 -#define NB_MIN_PAR_JOUR 1440 -#define NB_HEURE_PAR_JOUR 24 -#define NB_JOURS_AN_BISSEX 366 -#define NB_JOURS_AN_NON_BISSEX 365 -#define NB_CENTIEME_PAR_JOUR 8640000 -#define ANNEE_DEBUT_JULIEN 1950 -#define PI 3.141592653589 - -/*----------------------------------------------------------------------------*/ -/* Declaration des OPERATION INTERNES (static) */ -/*----------------------------------------------------------------------------*/ - -static void cai_DMS_To_Float ( char DegMinSec [17] , double *Degre ); -static CAI_OK_KO cai_WriteElementXML ( FILE *desc , char *motCle , - char *valeur ); -static CAI_OK_KO cai_WriteOpenTagXML ( FILE *des , char *TagName ); -static CAI_OK_KO cai_WriteCloseTagXML ( FILE *des , char *TagName ); -static CAI_OK_KO cai_WriteNulTagXML ( FILE *des , char *TagName ); -static CAI_OK_KO cai_WriteEnteteXML ( FILE *des ); -static CAI_OK_KO cai_WriteElementXMLWithAttribute ( FILE *desc , - char *motCle , - char *valeur, - char *attribut, - char *valat , - int type); - -static void cai_JulToGreg ( long nbjours , double nbsec , char* dategreg ); -static double cai_DegreeToRadian ( double angle_degree ); -static int cai_addtime ( char ret[26] , char temps[18] , double milisec ); -static int cai_recup_nom_spot(char typspot,char * str_repertoire , - char * str_debut , - char **str_fichier ); -static CAI_OK_KO cai_lire_dimensions_spot5 ( char *fich_xml , int *nbcan , - int *nboct , int *nbcol , - int *nblig , char *byteorder , - int *skipbytes ); -static CAI_IMAGE *cai_ouvre_creation_spot1a4(char *repert, - char *nom_image, - int *nbca, - int *nboct_pix, - int *nbcol, - int *nblig, - char *label); -static CAI_IMAGE *cai_ouvre_creation_spot5TIF(char *repert, - char *nom_image, - int *nbca, - int *nboct_pix, - int *nbcol, - int *nblig, - char *label); -static CAI_IMAGE *cai_ouvre_creation_spot5BIL(char *repert, - char *nom_image, - int *nbca, - int *nboct_pix, - int *nbcol, - int *nblig, - char *label); -static char* cai_spot5_gettoken ( FILE *MyFile ); - -/*----------------------------------------------------------------------------*/ -/* Variables globales */ -/*----------------------------------------------------------------------------*/ - -char *type_machine; /* ordre rangement octets machine de travail */ -static char Command[1024]; /* commande envoye au shell */ - -/*----------------------------------------------------------------------------*/ -/* Variable pour la gestion en configuration */ -/*----------------------------------------------------------------------------*/ - -static char *rcs_id="$Header: cai_spot.c,v 1.3 01/05/31 10:47:53 cmf Exp $"; - - -/*****************************************************************************/ -/*****************************************************************************/ -/* */ -/* Definition des OPERATIONS EXTERNES */ -/* */ -/*****************************************************************************/ -/*****************************************************************************/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_liste_ima_spot */ -/* ---------- */ -/* */ -/* ROLE : fonction de determination des images au format spot */ -/* ------ */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : int cai_liste_ima_spot(typspot,repert,tab_ima) */ -/* ----------------- */ -/* */ -/* typspot (E) (char) : type spot (1=1a4,b=5bil ou t=5tif) */ -/* repert (E) (char *) : repertoire a explorer */ -/* tab_ima (S) (char ***) : pointeur sur tableau des images listees */ -/* alloue par la fonction,il doit etre */ -/* LIBERE PAR L'APPELANT */ -/* */ -/* cai_liste_ima_spot (S) (int) : = -1 repertoire inexistant */ /* = > 0 nombre d'images listees */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -long int cai_liste_ima_spot (char typspot, char *repert, - char ***tab_ima) - - { - DIR *dirp; /* pointeur sur structure ouverture repertoire */ - struct dirent *dp; /* structure resultat de la fonction readdir */ - struct stat buf_stat; /* structure contenant resultat stat */ - char *nom_entete_spot; /* nom fichier entete image SPOT */ - char *nom_trailer_spot; /* nom fichier trailer image SPOT */ - char *nom_fic_spot; /* nom fichier image SPOT */ - char *nom_vol_spot; /* nom fichier pour volume repertoire image SPOT */ - char *nom_NULL_spot; /* nom fichier volume NULL repertoire image SPOT */ - int nb_ima; /* nombre d'images lum identifiees */ - - int cr,i; /* compte rendu appel fonction */ - int v1,v2; /* comparaison nom repertoire avec . et .. */ - char path_rep[PATH_MAX]; /* chemin acces fichiers ds repertoire courant */ - -/*........................................ - INITIALISATION et ouverture du repertoire courant choisi - .........................................*/ - - nb_ima=0; - - dirp=opendir(repert); - - if(dirp!=NULL) - { -/*...................................... - - premiere passe pour comptabiliser les images du format donne - - POUR CHAQUE REPERTOIRE DU REPERTOIRE COURANT, - TEST POUR SAVOIR SI CE REPERTOIRE CONTIENT - TOUS LES FICHIER PROPRES AU FORMAT SPOT - ..........................................*/ - - while( (dp=readdir(dirp))!=NULL ) - { - - /********************************************/ - /* on ne doit pas tenir compte des . et .. */ - /* sous le repertoire courant */ - /*******************************************/ - - v1 = strcmp(dp->d_name, "."); - v2 = strcmp(dp->d_name, ".."); - - if ( (v1 != 0) && (v2 != 0) ) - { - sprintf(path_rep, "%s/%s", repert, dp->d_name); - - /*--------------------------------*/ - /*test sur exitence du repertoire */ - /*--------------------------------*/ - - cr = stat(path_rep,&buf_stat); - - if ( (cr!=-1) && ((buf_stat.st_mode&S_IFMT) == S_IFDIR) ) - { - /* verification existence des fichiers propres au format SPOT 1 a 4*/ - if (typspot == '1') - { - if ( - (cai_recup_nom_spot(typspot,path_rep,"lea",&nom_entete_spot) == 0) && - (cai_recup_nom_spot(typspot,path_rep,"tra",&nom_trailer_spot) == 0) && - (cai_recup_nom_spot(typspot,path_rep,"ima",&nom_fic_spot) == 0) && - (cai_recup_nom_spot(typspot,path_rep,"vol",&nom_vol_spot) == 0) && - ( cai_recup_nom_spot(typspot,path_rep,"NUL",&nom_NULL_spot) == 0) ) - { - /*image SPOT1 4*/ - nb_ima=nb_ima+1; - } - } - else if (typspot == 'B') - { - /* verification existence des fichiers propres au format SPOT5 BIL */ -/*****************************************************************/ -/* MOD : VERSION : 4.7 : DM : LEAD_01.DAT devient METADATA.DIM */ -/*****************************************************************/ - if ( - (cai_recup_nom_spot(typspot,path_rep,"METADATA.DIM",&nom_entete_spot) == 0) && - (cai_recup_nom_spot(typspot,path_rep,"im",&nom_fic_spot) == 0) ) - { - /*image SPOT5 BIL*/ - nb_ima=nb_ima+1; - } - } - else if (typspot == 'T') - { - /* verification existence des fichiers propres au format SPOT5 TIF */ -/*****************************************************************/ -/* MOD : VERSION : 4.7 : DM : LEAD_01.DAT devient METADATA.DIM */ -/*****************************************************************/ - if ( - (cai_recup_nom_spot(typspot,path_rep,"METADATA.DIM",&nom_entete_spot) == 0) && - (cai_recup_nom_spot(typspot,path_rep,"im",&nom_fic_spot) == 0) ) - { - /*image SPOT5 TIF*/ - nb_ima=nb_ima+1; - } - } - } /*fin if cr*/ - - } /*fin if (v1 v2)*/ - - } /*fin while*/ - - /*fermeture du repertoire*/ - (void)closedir(dirp); - -/*..................................... - ALLOCATION DU TABLEAU CONTENANT LA LISTE DES IMAGES DU FORMAT SPOT - ......................................*/ - *tab_ima = (char **) calloc( nb_ima,sizeof(char *) ); - for (i=0;i<nb_ima;i=i+1) - (*tab_ima)[i]=(char *)calloc(1,100); - -/*...................................... - - deuxieme passe pour constituer la liste des images du format donne - - POUR CHAQUE REPERTOIRE DU REPERTOIRE COURANT, - TEST POUR SAVOIR SI CE REPERTOIRE CONTIENT - TOUS LES FICHIER PROPRES AU FORMAT SPOT - SI C`EST LE CAS,STOCKAGE DANS LA LISTE - ..........................................*/ - - dirp=opendir(repert); - - nb_ima=0; - - while((dp=readdir(dirp))!=NULL) - { - - /**********************************************/ - /* on ne doit pas tenir compte des . et .. */ - /* sous le repertoire courant */ - /**********************************************/ - - v1 = strcmp(dp->d_name, "."); - v2 = strcmp(dp->d_name, ".."); - - if ( (v1 != 0) && (v2 != 0) ) - { - sprintf(path_rep, "%s/%s", repert,dp->d_name); - - /*-------------------------------------*/ - /* test sur exitence du repertoire */ - /*-------------------------------------*/ - - cr = stat(path_rep,&buf_stat); - - if ( (cr!=-1) && ((buf_stat.st_mode&S_IFMT) == S_IFDIR) ) - { - /* verification existence des fichiers propres au format SPOT 1 a 4*/ - if (typspot == '1') - { - if ( - (cai_recup_nom_spot(typspot,path_rep,"lea",&nom_entete_spot) == 0) && - (cai_recup_nom_spot(typspot,path_rep,"tra",&nom_trailer_spot) == 0) && - (cai_recup_nom_spot(typspot,path_rep,"ima",&nom_fic_spot) == 0) && - (cai_recup_nom_spot(typspot,path_rep,"vol",&nom_vol_spot) == 0) && - ( cai_recup_nom_spot(typspot,path_rep,"NUL",&nom_NULL_spot) == 0) ) - { - /*image SPOT1 4*/ - nb_ima=nb_ima+1; - strcpy( (*tab_ima)[nb_ima-1],dp->d_name ); - } - } - else if (typspot == 'B') - { - /* verification existence des fichiers propres au format SPOT5 BIL */ -/*****************************************************************/ -/* MOD : VERSION : 4.7 : DM : LEAD_01.DAT devient METADATA.DIM */ -/*****************************************************************/ - if ( - (cai_recup_nom_spot(typspot,path_rep,"METADATA.DIM",&nom_entete_spot) == 0) && - (cai_recup_nom_spot(typspot,path_rep,"im",&nom_fic_spot) == 0) ) - { - /*image SPOT5 BIL*/ - nb_ima=nb_ima+1; - strcpy( (*tab_ima)[nb_ima-1],dp->d_name ); - } - } - else if (typspot == 'T') - { - /* verification existence des fichiers propres au format SPOT5 TIF */ -/*****************************************************************/ -/* MOD : VERSION : 4.7 : DM : LEAD_01.DAT devient METADATA.DIM */ -/*****************************************************************/ - if ( - (cai_recup_nom_spot(typspot,path_rep,"METADATA.DIM",&nom_entete_spot) == 0) && - (cai_recup_nom_spot(typspot,path_rep,"im",&nom_fic_spot) == 0) ) - { - /*image SPOT5 TIF*/ - nb_ima=nb_ima+1; - strcpy( (*tab_ima)[nb_ima-1],dp->d_name ); - } - } - } /*fin if cr*/ - - }/*fin if (v1 v2)*/ - - }/*fin while*/ - - /*fermeture du repertoire*/ - (void)closedir(dirp); - - } - else - { - /* Erreur : Repertoire inexistant sous repertoire courant */ - nb_ima=-1; - } - - return(nb_ima); - -} -/* Fin de l'operation cai_liste_ima_spot*/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_lecture_spot */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture d'une image au format spot */ -/* ----- et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_lecture_spot(typspot,nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* */ -/* typspot (E) (char) : type spot (1=1a4,b=5bil ou t=5tif) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_lecture_spot (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ /* */ /* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_IMAGE *cai_ouvre_lecture_spot(char typspot,char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) - -{ -DIR *dirp; /* pointeur sur structure ouverture repertoire */ -CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ -struct dirent *dp; /* structure resultat de la fonction readdir */ -char fichier_clefs[1024]; /* Nom du fichier des donnees auxiliaires */ -int i,j,k; /* Variables de boucle */ -int descrip_leader; /* Descripteur du fichier LEADER */ -int descrip_imagery; /* Descripteur du fichier IMAGERY */ -int descrip_volume; /* Descripteur du fichier VOLUME */ -long cr_lseek; /* Code retour de lseek */ -long cr_read; /* Code retour de read */ -long lg_saut; /* Nombre d'octets a sauter */ -int lg_enreg,lgtemp; /* longueur d'un enregistrement */ -int NbCan; /* nombre de canaux de l'image */ -int test1,test2,test3,test4,test5;/* test sur nom de fichiers */ -int lg_entete; /* longueur de l'entete fichier IMAGERY */ -int num,trouve; /* variable de test */ -char nom_fic[1024]; /* nom du fichier en-tete */ -char nom_fic_canal[1024]; /* nom fichier canal dont on teste existence */ -char nom_rep[1024]; /* nom du repertoire image SPOT */ -char nom_fic_ima[1024]; /* nom du fichier imagery.dat */ -char nom_leader[1024]; /* nom du fichier leader */ -char path_rep[PATH_MAX]; /* chemin acces fichiers ds repertoire courant */ -char nom_fic_spot5[PATH_MAX];/* chemin acces fichier image tiff ou BIL SPOT5 */ -char nom_ima_spot5[PATH_MAX];/* nom du fichier image spot5 */ -char *pch0,*pch1; /* pointeur sur chaine de caracteres */ -char car[2],carpoint; /* variable de travail */ -int type_spot; /* type d'image spot */ -char byteorder[1]; /* Ordre de codage intel (LE) ou Motorola (BE) */ -int skipbytes; /* Taille entete pour les fichiers BIL SPOT5 */ -int Trouve; -CAI_OK_KO icr; - - -/* Donnees auxiliaires */ - -char TABLEAU[1][257]; /* Variable intermediaire */ - -/* premiere variable = pour le nombre d'elements = nbre de colonnes */ -/* deuxieme element = pour la taille de l'element */ - - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - descrip_leader = 0; - descrip_imagery = 0; - descrip_volume = 0; - *nb_can=0; - *nb_lig=0; - *nb_col=0; - *nboct_pix=1; - type_spot=0; - trouve=0; - car[0]='/'; - -#ifdef _WIN - car[0]='\\'; -#endif - -/*****************************************************************************/ -/* MOD : VERSION : 4.5 : FA : initialisation de image1=NULL a l'ouverture */ -/*****************************************************************************/ - image1= NULL; - /*.................................. - determination ordre de rangement - des octets sur machine de travail - ......................................*/ - - type_machine = cai_test_pFpf(); - -/******************************************************************************/ -/* Determination du type d'image : SPOT 1 a 4 ou SPOT 5 */ -/******************************************************************************/ -sprintf(nom_rep, "%s%s%s", repert,car, nom_image); - -dirp=opendir(nom_rep); - - -if(dirp!=NULL) - { - while( ((dp=readdir(dirp))!=NULL )&& (trouve ==0)) - { - - /*---------------------------------------------*/ - /* on ne doit pas tenir compte des . et .. */ - /* sous le repertoire courant */ - /*---------------------------------------------*/ - - test1 = strcmp(dp->d_name, "."); - test2 = strcmp(dp->d_name, ".."); - - if ( (test1 != 0) && (test2 != 0) ) - { -/*****************************************************************************/ -/* MOD : VERSION : 4.8 : FA : Blindage de la reconnaissance du fichier image */ -/*****************************************************************************/ - - /*---------------------------------------------*/ - /* on recherche le fichier Image */ - /*---------------------------------------------*/ - test3 = strncasecmp(dp->d_name,"IMAG", 4); - if (test3 == 0) - { - test4 = strcasecmp(dp->d_name,"imagery.tif"); - if (test4==0) /* format SPOT5TIF */ - { - type_spot = 2; - sprintf (nom_fic_spot5, "%s%s%s%s%s", repert, car, - nom_image, car,dp->d_name); - sprintf (nom_ima_spot5, "%s", dp->d_name); - trouve=1; - } - else - { - test4 = strcasecmp(dp->d_name,"imagery.bil"); - if (test4==0) /* format SPOT5BIL */ - { - type_spot = 3; - sprintf (nom_fic_spot5, "%s%s%s%s%s", repert, car, - nom_image, car,dp->d_name); - sprintf (nom_ima_spot5, "%s", dp->d_name); - trouve=1; - } - else /* format SPOT 1 a 4*/ - { - carpoint = '.'; - pch0 = strchr (dp->d_name, carpoint); - if (pch0 == NULL) - { - type_spot = 1; /* format SPOT 1 a 4*/ - sprintf(nom_fic_ima, "%s%s%s%s%s", repert, car, - nom_image, car,dp->d_name); - trouve=1; - } - else if (strcasecmp(pch0,".DAT")== 0) - { - type_spot = 1; /* format SPOT 1 a 4*/ - sprintf(nom_fic_ima, "%s%s%s%s%s", repert, car, - nom_image, car,dp->d_name); - trouve=1; - } - - } - } - } - } - - } - closedir(dirp); - } - - -if (type_spot == 0) -{ - sprintf (CAI_ERREUR,"Erreur : type d'image SPOT inconnu"); - goto ERREUR; -} -/*........................................................................*/ -/* Verication ed la coherence du type spot annonce et du type spot trouve */ -/*........................................................................*/ -if (((typspot == '1')&&(type_spot != 1))|| - ((typspot == 'T')&&(type_spot != 2))|| - ((typspot == 'B')&&(type_spot != 3))) -{ - sprintf (CAI_ERREUR, - "Erreur : L'image n'est pas du type SPOT annonce"); - goto ERREUR; -} - -/*=============================================*/ -/* TRAITEMENT D'UNE IMAGE AU FORMAT SPOT 1 A 4 */ -/*=============================================*/ -if (type_spot == 1) -{ - image1= NULL; - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); - image1->ACCES_SPOT[0]=0; - image1->ACCES_SPOT[1]=0; - -/*****************************************************************************/ -/* tests sur les retours d'allocation memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - strcpy(CAI_ERREUR,"Erreur allocation memoire dans cai_ouvre_lecture"); - goto ERREUR; - } - -/******************************************************************************/ -/* Ouverture des fichiers LEADER et IMAGERY en lecture */ -/******************************************************************************/ - - sprintf(nom_rep, "%s%s%s", repert,car, nom_image); - dirp=opendir(nom_rep); - - if(dirp!=NULL) - { - while( (dp=readdir(dirp))!=NULL ) - { - - /*---------------------------------------------*/ - /* on ne doit pas tenir compte des . et .. */ - /* sous le repertoire courant */ - /*---------------------------------------------*/ - - test1 = strcmp(dp->d_name, "."); - test2 = strcmp(dp->d_name, ".."); - - if ( (test1 != 0) && (test2 != 0) ) - { - - test3 = strncasecmp(dp->d_name,"LEAD", 4); - test4 = strncasecmp(dp->d_name,"IMAG", 4); - test5 = strncasecmp(dp->d_name,"VOL", 3); - - /********************************************************/ - /* tests de determination du fichier LEADER sous repert */ - /********************************************************/ - - if (test3==0) - { - sprintf(path_rep, "%s%s%s%s%s", repert, car,nom_image, - car,dp->d_name); - - /*ouverture du fichier LEADER*/ - - descrip_leader = open (path_rep, O_RDONLY |O_BINARY); - if (descrip_leader == -1) - { - strcpy(CAI_ERREUR, - "Erreur d'ouverture du fichier LEADER SPOT"); - goto ERREUR; - } - /*---------------------------------------------------------*/ - /* Lecture de la taille d'un enregistrement dans LEADER */ - /*---------------------------------------------------------*/ - - cr_lseek = lseek ( descrip_leader , 8L , 1 ); - if ( cr_lseek == -1 ) - { - strcpy(CAI_ERREUR,"Erreur acces au fichier leader SPOT"); - goto ERREUR; - } - - cr_read = read ( descrip_leader , &lg_enreg , 4 ); - if ( cr_read == -1 ) - { - strcpy(CAI_ERREUR,"Erreur acces au fichier leader SPOT"); - goto ERREUR; - } - if (strcmp(type_machine,"LE")==0) - { - swab( (void*)&lg_enreg, (void*)&lgtemp,4 ); - cai_inverser_tableau((short *)&lg_enreg, (short *)&lgtemp,2); - } - - /*------------------------------------------------------*/ - /* Retour au debut du fichier LEADER */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( descrip_leader , 0L , 0 ); - if ( cr_lseek == -1 ) - { - strcpy(CAI_ERREUR,"Erreur acces au fichier leader SPOT"); - goto ERREUR; - } - - /*------------------------------------------------------*/ - /* Saut de lg_enreg + 996 octets dans LEADER */ - /*------------------------------------------------------*/ - - lg_saut = (long)(lg_enreg + 996); - cr_lseek = lseek ( descrip_leader , lg_saut , 0 ); - if ( cr_lseek == -1 ) - { - strcpy(CAI_ERREUR,"Erreur acces au fichier leader SPOT"); - goto ERREUR; - } - /*------------------------------------------------------*/ - /* Lecture du nombre de colonnes dans LEADER */ - /*------------------------------------------------------*/ - - cr_read = read (descrip_leader, TABLEAU[0], 16); - if ( cr_read != 16 ) - { - strcpy(CAI_ERREUR,"Erreur acces au fichier leader SPOT"); - goto ERREUR; - } - TABLEAU[0][16] = '\0'; /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for (i=0;i<16;i++) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sscanf ( TABLEAU[0], "%d", nb_col); - /*------------------------------------------------------*/ - /* Lecture du nombre de lignes dans LEADER */ - /*------------------------------------------------------*/ - - cr_read = read (descrip_leader, TABLEAU[0], 16); - if ( cr_read != 16 ) - { - strcpy(CAI_ERREUR,"Erreur acces au fichier leader SPOT"); - goto ERREUR; - } - TABLEAU[0][16] = '\0'; /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for (i=0;i<16;i++) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sscanf ( TABLEAU[0], "%d", nb_lig); - - /*------------------------------------------------------*/ - /* Saut de 16 octets dans LEADER */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( descrip_leader , 16L , 1 ); - if ( cr_lseek == -1 ) - { - strcpy(CAI_ERREUR,"Erreur acces au fichier leader SPOT"); - goto ERREUR; - } - - /*------------------------------------------------------*/ - /* Lecture du nombre de canaux dans LEADER */ - /*------------------------------------------------------*/ - - cr_read = read (descrip_leader, TABLEAU[0], 16); - if ( cr_read != 16 ) - { - strcpy(CAI_ERREUR,"Erreur acces au fichier leader SPOT"); - goto ERREUR; - } - TABLEAU[0][16] = '\0'; /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for (i=0;i<16;i++) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sscanf ( TABLEAU[0], "%d", nb_can); - } /*fin test3 (v==0)*/ - - else if (test5==0) - { - /********************************************************/ - /* tests de determination du fichier VOLUME sous repert */ - /********************************************************/ - - sprintf(path_rep, "%s%s%s%s%s", repert, car,nom_image, - car,dp->d_name); - /*ouverture du fichier VOLUME*/ - - descrip_volume = open (path_rep, O_RDONLY|O_BINARY ); - if (descrip_volume == -1) - { - strcpy(CAI_ERREUR, - "Erreur d'ouverture du fichier VOLUME SPOT"); - goto ERREUR; - } - } - /********************************************************/ - /* tests de determination du fichier IMAGERY sous repert */ - /********************************************************/ - - else if (test4==0) - { - - /*ouverture du fichier IMAGERY*/ - - descrip_imagery = open (nom_fic_ima, O_RDONLY|O_BINARY ); - if (descrip_imagery == -1) - { - strcpy(CAI_ERREUR, - "Erreur d'ouverture du fichier IMAGERY SPOT"); - goto ERREUR; - } - - /*------------------------------------------------------*/ - /* Lecture de la taille de l'entete dans IMAGERY */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( descrip_imagery , 8L , 1); - if ( cr_lseek == -1 ) - { - strcpy(CAI_ERREUR, - "Erreur acces au fichier contenant donnees SPOT"); - goto ERREUR; - } - - cr_read = read ( descrip_imagery , &lg_entete , 4 ); - if ( cr_read == -1 ) - { - strcpy(CAI_ERREUR, - "Erreur acces au fichier contenant donnees SPOT"); - goto ERREUR; - } - if (strcmp(type_machine,"LE")==0) - { - swab( (void*)&lg_entete, (void*)&lgtemp,4 ); - cai_inverser_tableau((short *)&lg_entete, (short *)&lgtemp,2); - } - - } /*fin else if test4*/ - - } /*fin else test1 test2*/ - - } /*fin while*/ - - closedir(dirp); - - } /*fin if (dirp=!NULL)*/ - - -/* verification que tous les fichiers necessaires (lead,imag et vol ont ete trouves */ - if (descrip_leader == 0) - { - sprintf(CAI_ERREUR,"Erreur : Fichier Leader SPot1a4 absent"); - goto ERREUR; - } - if (descrip_imagery == 0) - { - sprintf(CAI_ERREUR,"Erreur : Fichier imagery SPot1a4 absent"); - goto ERREUR; - } - if (descrip_volume == 0) - { - sprintf(CAI_ERREUR,"Erreur : Fichier volume SPot1a4 absent"); - goto ERREUR; - } -/*....................................... - INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL - .....................................................*/ - - nom_fic[0]='\0'; - nom_fic_canal[0]='\0'; - - sprintf(nom_fic_canal,"%s",nom_fic_ima); - - for (i=0;i<*nb_can;i=i+1) - { - sscanf(nom_image,"%s",image1->NOM_FIC_CAN); - sscanf(nom_image,"%s",image1->NOM_UTIL_CAN); - image1->ACCES_CANAL_INT[i]=descrip_imagery; - image1->ACCES_SPOT[0]=descrip_leader; - image1->ACCES_SPOT[1]=descrip_volume; - image1->POS_OCTET[i]=lg_entete; - } - image1->TYPE_SPOT = type_spot; - image1->NBOCT_PIX = *nboct_pix; - - } /* fin TYPE IMAGE SPOT 1 a 4 */ - /*===========================*/ - -/*=============================================*/ -/* TRAITEMENT D'UNE IMAGE AU FORMAT SPOT 5 TIF */ -/*=============================================*/ - else if (type_spot == 2) - { - -/* Ouverture de l'image */ - image1 = cai_ouvre_lecture_image (nom_fic_spot5, "TIFF", - nb_can,nboct_pix,nb_col,nb_lig); - - if (image1 == NULL) - { - strcpy(CAI_ERREUR, - "Erreur acces au fichier image TIFF contenant donnees SPOT"); - goto ERREUR; - } - - image1->NB_CANAUX = *nb_can ; - image1->NBOCT_PIX = *nboct_pix ; - image1->NB_COL = *nb_col ; - image1->NB_LIG = *nb_lig ; - image1->TYPE_SPOT = type_spot; - image1->ACCES_SPOT[0]=0; - image1->ACCES_SPOT[1]=0; - - - } /* fin TYPE IMAGE SPOT 5 TIFF */ - /*============================*/ - -/*=============================================*/ -/* TRAITEMENT D'UNE IMAGE AU FORMAT SPOT 5 BIL */ -/*=============================================*/ - else - { - - image1= NULL; - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); - image1->ACCES_SPOT[0]=0; - image1->ACCES_SPOT[1]=0; - -/*****************************************************************************/ -/* tests sur les retours d'allocation memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - strcpy(CAI_ERREUR,"Erreur allocation memoire dans cai_ouvre_lecture"); - goto ERREUR; - } - - /* Recherche du leader Dimap */ - dirp=opendir(nom_rep); - Trouve=0; - if(dirp!=NULL) - { - while( (dp=readdir(dirp))!=NULL ) - { - - /*---------------------------------------------*/ - /* on ne doit pas tenir compte des . et .. */ - /* sous le repertoire courant */ - /*---------------------------------------------*/ - - test1 = strcmp(dp->d_name, "."); - test2 = strcmp(dp->d_name, ".."); - - if ( (test1 != 0) && (test2 != 0) ) - { -/*****************************************************************/ -/* MOD : VERSION : 4.7 : DM : LEAD_01.DAT devient METADATA.DIM */ -/*****************************************************************/ - test3 = strncasecmp(dp->d_name,"METADATA.DIM", 12); - - /**************************************************************/ - /* tests de determination du fichier METADATA.DIM sous repert */ - /**************************************************************/ - if (test3==0) - { - sprintf(nom_leader, "%s%s%s%s%s", repert,car, nom_image, - car, dp->d_name); - - -/* Extraction du nombre de lig col can et nboct du fichier DIMAP */ -/*...............................................................*/ - icr = cai_lire_dimensions_spot5(nom_leader,nb_can,nboct_pix , - nb_col , nb_lig,byteorder, - &skipbytes ); - if (icr != CAI_OK) - { - goto ERREUR; - } - else - Trouve=1; - } - } /*fin else test1 test2*/ - - } /*fin while*/ - - closedir(dirp); - - } /*fin if (dirp=!NULL)*/ - - if (Trouve==0) - { - sprintf(CAI_ERREUR, - "Erreur Le fichier METADATA.DIM n'existe pas ou erreur de lecture"); - goto ERREUR; - } - - -/* INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL - .....................................................*/ - - nom_fic[0]='\0'; - nom_fic_canal[0]='\0'; - - sprintf(nom_fic_canal,"%s",nom_fic_spot5); - - num=open(nom_fic_canal,O_RDONLY|O_BINARY,0); - if (num!= -1) - { - for (i=0;i<*nb_can;i=i+1) - { - sscanf(nom_ima_spot5,"%s",image1->NOM_FIC_CAN); - sscanf(nom_ima_spot5,"%s",image1->NOM_UTIL_CAN); - image1->ACCES_CANAL_INT[i]=num; - image1->POS_OCTET[i]=(*nb_col)*i*(*nboct_pix)+skipbytes; - } - image1->TYPE_SPOT = type_spot; - image1->NBOCT_PIX = *nboct_pix; - if (byteorder[0]=='M') - { - if (strcmp(type_machine,"BE")==0) - image1->INV_OCTETS=0; - else - image1->INV_OCTETS=1; - } - else - { - if (strcmp(type_machine,"LE")==0) - image1->INV_OCTETS=0; - else - image1->INV_OCTETS=1; - } - - } - else - { - strcpy(CAI_ERREUR, - "Erreur ouverture fichier BIL contenant donnees SPOT"); - goto ERREUR; - } - - } /* fin TYPE IMAGE SPOT 5 BIL */ - - /*===========================*/ - - -/*****************************************************************************/ -/* MOD : VERSION : 4.5 : FA : Initialisation du champ COD_PIX (OCT,I2 ou UND)*/ -/*****************************************************************************/ - if (*nboct_pix==1) - sprintf(image1->COD_PIX,"OCT"); - else if (*nboct_pix==2) - sprintf(image1->COD_PIX,"I2"); - else - sprintf(image1->COD_PIX,"UND"); - - - return(image1); - - -ERREUR: - if (descrip_leader !=0) close(descrip_leader); - if (descrip_imagery !=0) close(descrip_imagery); - if (descrip_volume !=0) close(descrip_volume); - if (image1!=NULL) free(image1); - return(NULL); -} -/* - Fin de l'operation cai_ouvre_lecture_spot -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_creation_spot */ -/* ---------- */ -/* */ -/* ROLE : fonction de creation et d'ouverture en ecriture d'une image */ -/* ----- au format spot et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_creation_spot(typspot,nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig, */ -/* label) */ -/* */ -/* typspot (E) (char ) : type d'images spot 91a4,5tif ou 5bil) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* nb_can (E) (int ) : nombre de canaux de l'image */ -/* nboct_pix (E) (int ) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (E) (int ) : nombre de lignes de l'image */ -/* nb_col (E) (int ) : nombre de colonnes de l'image */ -/* label (E) (char *) : commentaire lie a l'image */ -/* */ -/* cai_ouvre_creation_spot (S) (CAI_IMAGE *) : =NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_IMAGE *cai_ouvre_creation_spot(char typspot,char *repert, - char *nom_image, - int *nbca, - int *nboct_pix, - int *nbcol, - int *nblig, - char *label) - -{ - - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - int icr; /* Code retour de fonctions */ - -/*........................................ - INITIALISATIONS et allocation de place pour la structure CAI_IMAGE - .........................................*/ - icr = CAI_OK; - - -/*****************************************************************************/ -/* MOD : VERSION : 4.5 : FA : initialisation de image1=NULL a l'ouverture */ -/*****************************************************************************/ - image1= NULL; - -/*-------------------------------------------------------------*/ -/* test du type de machine sur laquelle est constituee l'image */ -/*-------------------------------------------------------------*/ - type_machine = cai_test_pFpf(); - - if (typspot=='1') - image1 = cai_ouvre_creation_spot1a4(repert,nom_image,nbca, - nboct_pix,nbcol,nblig,label); - else if (typspot=='B') - image1 = cai_ouvre_creation_spot5BIL(repert,nom_image,nbca, - nboct_pix,nbcol,nblig,label); - else if (typspot=='T') - image1 = cai_ouvre_creation_spot5TIF(repert,nom_image,nbca, - nboct_pix,nbcol,nblig,label); - if (image1==NULL) icr=CAI_KO; - - if (icr != CAI_OK) - { - if (image1!=NULL) free(image1); - image1 = NULL; - } - return(image1); - -} - -/* - Fin de l'operation cai_ouvre_creation_spot -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_lecture_canal_spot */ -/* ---------- */ -/* */ -/* ROLE : fonction de lecture d'un canal d'une image LUM */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_lecture_canal_spot(image1, canal, */ -/* ------------------ premiere_ligne, */ -/* premiere_colonne, */ -/* nombre_lignes_lire , */ -/* nombre_colonnes_lire, */ -/* pas_ligne ,pas_colonne, */ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a lire */ -/* premiere_ligne (E) (int) : premiere ligne a lire dans l'image */ -/* premiere _colonne (E) (int) : premiere colonne a lire dans l'image */ -/* nombre_lignes_lire (E) (int) : nombre de lignes a lire */ -/* nombre_colonnes_lire (E) (int) : nombre de colonnes a lire */ -/* pas_ligne (E) (int) : pas en ligne */ -/* pas_colonne (E) (int) : pas en colonne */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels lus alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_lecture_canal_spot (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_OK_KO cai_lecture_canal_spot(CAI_IMAGE *image1,int *canal, - int *premiere_ligne, int *premiere_colonne, - int *nb_lig_lire, int *nb_col_lire, - int *pas_lig, int *pas_col, - unsigned char *data_image ) - - -{ -DIR *dirp; /* pointeur sur structure ouverture repertoire */ -struct dirent *dp; /* structure resultat de la fonction readdir */ -int descrip_imagery; /* descripteur du fichier imagery */ -int nb_can; /* nombre de canaux de l'image SPOT */ -int num,lig,i,j,k; /* variables de travail */ -long nb_oct; /* nb oct =1er octet a lire - position courante */ -long oct_lig; /* nb oct. par ligne en considerant taille pixel */ -long int offset; /* Deplacement dans le fichier */ -long cr_lseek; /* Code retour de lseek */ -long cr_read; /* Code retour de read */ -int lg_prefixe; /* longueur du prefixe d'une ligne */ -int lg_suffixe; /* longueur du suffixe d'une ligne */ -int lg_entete ; /* longueur de l'entete d'une ligne */ -char *nom_fic; /* nom contenant le chemin de l'image */ -char path_rep[PATH_MAX]; /* chemin acces fichiers ds repertoire courant */ -unsigned char *buf_lec; /* buffer lecture d'une ligne */ -long pt_oct; /* position courante dans le fichier image */ -unsigned char *pch, *deb; /* pointeur chaine pour transfert buffer sortie */ -int no_oct; /* numero du premier octet a lire */ -CAI_OK_KO icr; /* code retour fonction */ -int taille_image; /* Taille en octets de la zone a lire */ -unsigned char *data_image2; /* pointeur donnees image pour inversion octets */ - - -data_image2 = NULL; -if ( (image1->TYPE_SPOT < 1) || (image1->TYPE_SPOT > 3) ) - { - sprintf (CAI_ERREUR,"Erreur : type d'image SPOT inconnu"); - goto ERREUR; - } -/*=============================================*/ -/* TRAITEMENT D'UNE IMAGE AU FORMAT SPOT 1 A 4 */ -/*=============================================*/ -else if (image1->TYPE_SPOT == 1) - { -/*........................... - Initialisations diverses - ..........................*/ - - lg_prefixe = 32; - descrip_imagery = image1->ACCES_CANAL_INT[*canal-1]; - nb_can = image1->NB_CANAUX; - -/*****************************************************************************/ -/* MOD : VERSION : 4.5 : FA : anomalie sur sous-echantillonnage en lecture */ -/*****************************************************************************/ -/* Une ligne modifiee */ - oct_lig = image1->NBOCT_PIX*(image1->NB_COL); - - /*.............................................. - allocation de memoire pour lire une ligne image - ............................................. */ - - buf_lec = (unsigned char *) calloc(oct_lig,sizeof(unsigned char)); - if (buf_lec == NULL) - { - sprintf(CAI_ERREUR,"ERREUR:Probleme allocation memoire\n"); - goto ERREUR; - } - - else - { - /*.................... - Initialisation - ......................*/ - lig=*premiere_ligne; - i=1; - pch=data_image; - lg_entete=image1->POS_OCTET[*canal-1]; - -/*..................... - Pour chaque ligne a lire - .......................................*/ - while (i <= *nb_lig_lire) - { -/*............................................ - Recherche de la position courante dans le fichier - ............................................*/ - pt_oct = lseek(descrip_imagery,0L,1); - - if ( pt_oct == -1 ) - { - strcpy(CAI_ERREUR,"Erreur acces au fichier contenant donnees SPOT"); - goto ERREUR; - } - -/*................................ - Calcul du numero du 1er octet a lire - no_oct=(*nblig-1)*lg_entete*nbcanaux+lg_entete*(canal-1)+lg_prefixe+(*canal-1)*lg_entete - ....................................*/ - - no_oct = (lig-1)*lg_entete*nb_can+image1->POS_OCTET[*canal-1]+lg_prefixe+(*canal-1)*lg_entete; - -/*.................................. - Saut d'octets pour etre positionne sur la ligne a lire - .......................................*/ - nb_oct=(long)(no_oct-pt_oct); - lseek(descrip_imagery,nb_oct,1); - -/*........................................... - lecture d'une ligne image - ................................................*/ - cr_read=read(descrip_imagery,buf_lec,oct_lig); - - if (cr_read==-1) - { - strcpy(CAI_ERREUR,"Erreur lecture donnee image SPOT"); - goto ERREUR; - } - else - { -/*...................................... - Sauvegarde des donnees lues en tenant compte du pas - d'echantillonnage en colonne - ........................................*/ - deb = buf_lec+(*premiere_colonne-1)*image1->NBOCT_PIX; - j=1; - while (j <= *nb_col_lire) - { - for (k=0;k<image1->NBOCT_PIX;k=k+1) - { - *(pch+k)=*(deb+k); - } - j=j+1; - pch=pch+image1->NBOCT_PIX; - deb=deb+(*pas_col*image1->NBOCT_PIX); - - }/*fin while j*/ - - }/*fin else*/ - - i=i+1; - lig=lig+(*pas_lig); - - } /*fin while i*/ - - free(buf_lec); - } /*fin else*/ - - - - } /* fin TYPE IMAGE SPOT 1 a 4 */ - /*===========================*/ - -/*=============================================*/ -/* TRAITEMENT D'UNE IMAGE AU FORMAT SPOT 5 TIF */ -/*=============================================*/ - else if (image1->TYPE_SPOT == 2) - { - - icr = cai_lecture_canal_tiff (image1, canal, - premiere_ligne, premiere_colonne, - nb_lig_lire, nb_col_lire, pas_lig, - pas_col, data_image); - if (icr != CAI_OK) - goto ERREUR; - - } /* fin TYPE IMAGE SPOT 5 TIFF */ - /*============================*/ - -/*=============================================*/ -/* TRAITEMENT D'UNE IMAGE AU FORMAT SPOT 5 BIL */ -/*=============================================*/ - else - { - - icr = cai_lecture_canal_bil (image1, canal, premiere_ligne, - premiere_colonne, nb_lig_lire, nb_col_lire, - pas_lig, pas_col, data_image); - if (icr != CAI_OK) - goto ERREUR; - else - { -/* Si necessaire inversion des octets */ - if ((image1->INV_OCTETS==1)&&(image1->NBOCT_PIX !=1)) - { - taille_image = (*nb_lig_lire)*(*nb_col_lire)*(image1->NBOCT_PIX); - data_image2 = (unsigned char *) calloc(taille_image, - sizeof(unsigned char)); - - if (data_image2 == NULL) - { - strcpy(CAI_ERREUR, - "Erreur allocation memoire dans cai_lecture_canal"); - goto ERREUR; - } - swab( (void*)(data_image), (void*)(data_image2), taille_image); - for (i=0; i<taille_image;i++) - { - /*stockage dans data_image*/ - data_image[i] = data_image2[i]; - } - free(data_image2); - } - } - - } /* fin TYPE IMAGE SPOT 5 BIL */ - /*===========================*/ - - -/* Sortie normale */ - return (CAI_OK); - -/* Sortie degradee */ -ERREUR: - if (descrip_imagery>0) close(descrip_imagery); - return(NULL); - -} - -/* - Fin de l'operation cai_lecture_canal_spot -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ecriture_canal_spot */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ecriture d'un canal d'une image spot */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ecriture_canal_spot(image1, canal, */ -/* ------------------ premiere_ligne, */ -/* nombre_lignes_ecrire, */ -/* nombre_colonnes_ecrire,*/ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a ecrire */ -/* premiere_ligne (E) (int) : premiere ligne a ecrire ds l'image */ -/* nombre_lignes_ecrire (E) (int) : nombre de lignes a ecrire */ -/* nombre_colonnes_ecrire(E) (int) : nombre de colonnes a ecrire */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels ecris alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_ecriture_canal_spot (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_OK_KO cai_ecriture_canal_spot (CAI_IMAGE *image1, - int *canal , - int *premiere_ligne , - int *nombre_lignes_ecrire , - int *nombre_colonnes_ecrire, - unsigned char *data_image ) - -{ - long cr_write; /* code retour de write */ - unsigned char *buf_lec; /* Buffer des radiometries */ - int descrip_imagery; /* Descripteur du fichier IMAGERY */ - int lgrec; - int i_ligne, j, i; - CAI_OK_KO icr; - int nb_can, nboct_pix,nboct,compl; - int no_oct,nblig,nbcol; - long deplacement; /* deplacement a effectuer */ - long position_courante; /* position courante dans le fichier */ - -/* Variables intermediaires */ - - unsigned char BYTE[4]; - unsigned char COMP[5300]; - int VAR_LONG[2]; - short int TAB_SHORT; - char TAB[3]; - -/************************************************/ -/* TRAITEMENT DIFFERENT SUIVANT LE TYPE DE SPOT */ -/************************************************/ -icr = CAI_OK; -if (image1->TYPE_SPOT ==1) -{ -/*--------------------*/ -/* IMAGE SPOT1A4 */ -/*--------------------*/ - - /*........................... - Initialisations diverses - ..........................*/ - - i_ligne = 0; - lgrec = image1->POS_OCTET[*canal-1]; /*long entete image SPOT*/ - descrip_imagery = image1->ACCES_CANAL_INT[*canal-1]; - nb_can = image1->NB_CANAUX; - nboct_pix = image1->NBOCT_PIX; - nboct= (*nombre_colonnes_ecrire) * nboct_pix ; - compl= lgrec-nboct-100; - for (i=0;i<5300;i++) COMP[i]=0; - nbcol = image1->NB_COL; - -/*---------------------------------------------------------------------------*/ -/* ECRITURE DU FICHIER IMAGERY */ -/*---------------------------------------------------------------------------*/ - - /*......................................................*/ - /* Calcul de la position du premier octet a ecrire */ - /*......................................................*/ - - no_oct = lgrec+(*premiere_ligne-1)*lgrec*nb_can+lgrec*(*canal-1); - - /*......................................................*/ - /* Recuperation de la position courante */ - /*......................................................*/ - - position_courante = lseek ( descrip_imagery , 0L , 1 ); - - /*.......................................................*/ - /* Calcul du deplacement jusqu'a la 1ere ligne a ecrire */ - /*.......................................................*/ - - deplacement = no_oct - position_courante; - - /********************************************************/ - /* TANT QUE il y a des lignes a ecrire */ - /********************************************************/ - buf_lec=data_image; - while (i_ligne < (*nombre_lignes_ecrire)) - { - nblig=(*premiere_ligne)+i_ligne; - /*.............................................*/ - /* deplacement jusqu'a la ligne a ecrire */ - /*............................................*/ - - lseek ( descrip_imagery , deplacement , 1 ); - - /******************************/ - /* Pour le fichier IMAGE DATA */ - /******************************/ - - /*initialisation des infos de l'entete de l'image dest*/ - BYTE[0] = 237; - BYTE[1] = 237; - BYTE[2] = 18; - BYTE[3] = 18; - VAR_LONG[1] = lgrec; - VAR_LONG[0] = i_ligne+1; - - /*ecriture dans le fichier image dest*/ - cr_write = write ( descrip_imagery , VAR_LONG , 4); - if (cr_write != 4) - { - icr = CAI_KO; - goto FIN; - } - - cr_write = write ( descrip_imagery , BYTE , 4); - if (cr_write != 4) - { - icr = CAI_KO; - goto FIN; - } - - cr_write = write ( descrip_imagery , &VAR_LONG[1] , 4); - if (cr_write != 4) - { - icr = CAI_KO; - goto FIN; - } - - /* Ecriture des prefixes : */ - - cr_write = write ( descrip_imagery, &nblig, 4); - if (cr_write != 4) - { - icr = CAI_KO; - goto FIN; - } - - strcpy ( TAB," "); - cr_write = write ( descrip_imagery , TAB, 2); - if (cr_write != 2) - { - icr = CAI_KO; - goto FIN; - } - - TAB_SHORT = (short)(*canal); - - cr_write = write ( descrip_imagery , &TAB_SHORT , 2); - if (cr_write !=2) - { - icr = CAI_KO; - goto FIN; - } - - cr_write = write ( descrip_imagery , COMP , 12); - if (cr_write != 12) - { - icr = CAI_KO; - goto FIN; - } - - /* Ecriture radiometries */ - - cr_write = write ( descrip_imagery , buf_lec ,nboct ); - if (cr_write != nboct) - { - icr = CAI_KO; - goto FIN; - } - - /* ecriture des octets de completion */ - cr_write = write ( descrip_imagery , COMP ,compl ); - if (cr_write != compl) - { - icr = CAI_KO; - goto FIN; - } - - /* Ecriture des suffixes : */ - - cr_write = write ( descrip_imagery , COMP , 24); - if (cr_write != 24) - { - icr = CAI_KO; - goto FIN; - } - - cr_write = write ( descrip_imagery , &nbcol , 4); - if (cr_write != 4) - { - icr = CAI_KO; - goto FIN; - } - - cr_write = write ( descrip_imagery , COMP, 40); - if (cr_write != 40) - { - icr = CAI_KO; - goto FIN; - } - - /********************************************************/ - /* mise a jour du deplacement jusqu'a la ligne */ - /* suivante */ - /********************************************************/ - - deplacement = ( nb_can - 1 ) * lgrec; - buf_lec = buf_lec+nboct; - - /********************************************************/ - /* incrementation du nombre de lignes */ - /********************************************************/ - - i_ligne++; - - } /*fin while*/ -} -else if (image1->TYPE_SPOT ==2) -{ -/*--------------------*/ -/* IMAGE SPOT5 TIFF */ -/*--------------------*/ - icr = cai_ecriture_canal_tiff (image1,canal,premiere_ligne, - nombre_lignes_ecrire , - nombre_colonnes_ecrire,data_image); -} -else if (image1->TYPE_SPOT ==3) -{ -/*--------------------*/ -/* IMAGE SPOT5 BIL */ -/*--------------------*/ - icr = cai_ecriture_canal_bil(image1,canal,premiere_ligne, - nombre_lignes_ecrire , - nombre_colonnes_ecrire,data_image); - -} - -FIN : - if (icr != CAI_OK) - strcpy(CAI_ERREUR,"Erreur ecriture du fichier Imagery"); - - return (icr); - -} - -/* - Fin de l'operation cai_ecriture_canal_spot -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ferme_spot */ -/* ---------- */ -/* */ -/* ROLE : fonction de fermeture d'une image au format spot et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ferme_spot(typspot,image1) */ /* ------------------ */ -/* */ -/* typspot (E) (char ) : =1 spot1a4, =T spot5Tif,=B spot5Bil */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* */ -/* cai_ferme_spot (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - -CAI_OK_KO cai_ferme_spot (char typspot,CAI_IMAGE *image1) - -{ - - CAI_OK_KO iret; /* code retour de l'operation */ - int num; /* descripteur du fichier a fermer */ - int temp; /* variable temporaire */ - long pt_oct; /* position courante ds fichier image */ - -/*--------------------------*/ -/* Initialisations diverses */ -/*--------------------------*/ - iret=CAI_OK; - -/************************************************/ -/* TRAITEMENT DIFFERENT SUIVANT LE TYPE DE SPOT */ -/************************************************/ - if (typspot == '1') - { -/* SPOT1a4 */ - - num=image1->ACCES_CANAL_INT[0]; - -/*--------------------------------------------------*/ -/* Mise a jour de l'entete si ouverture en creation */ -/*--------------------------------------------------*/ - if (image1->MODE == CAI_ECRITURE) - { - pt_oct=lseek(num,0L,0); - -/*........................................*/ -/* Mise a jour du niveau de pretraitement */ -/*........................................*/ - pt_oct=lseek(num,53L,1); - pt_oct = write ( num,image1->NIVEAU , 2 ); - if ( pt_oct == 0 ) - { - sprintf ( CAI_ERREUR , - "Erreur : MAJ impossible entete a la fermeture fichier SPOT1a4\n"); - iret=CAI_KO; - goto ERREUR; - } - - } -/*............................................. - Fermeture du fichier qui contient tous les canaux - .............................................*/ - if (num>0) close(num); - - if (image1->ACCES_SPOT[0]!=0) close(image1->ACCES_SPOT[0]); - if (image1->ACCES_SPOT[1]!=0) close(image1->ACCES_SPOT[1]); - } - else if (typspot == 'T') - { -/* SPOT5TIF */ - iret = cai_ferme_tiff(image1); - } - else if (typspot == 'B') - { -/* SPOT5BIL */ - iret = cai_ferme_bil(image1); - } - - - - return (iret); - -ERREUR: - return(CAI_KO); - -} - -/* - Fin de l'operation cai_ferme_spot -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_dest_ima_spot */ -/* ---------- */ -/* */ -/* ROLE : fonction de destruction d'une image stockee en spot et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_dest_ima_spot(typspot,repertoire,nom_ima)*/ /* ------------------ */ -/* typspot (E) (char ) : =1 spot1a4, =T spot5Tif,=B spot5Bil */ -/* repertoire (E) (char *) : repertoire de l'image a detruire */ -/* nom_image (E) (char *) : nom de l'image a detruire avec repertoire */ -/* */ -/* cai_dest_ima_spot (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_OK_KO cai_dest_ima_spot (char typspot, char *repertoire , - char *nom_ima ) - -{ -char nom_fic[1024]; /* nom du repertoire a detruire */ - -/************************************************/ -/* Constitution du nom du repertoire image */ -/************************************************/ - -if ((long)strlen(repertoire)!= 0) -{ - sprintf( nom_fic, "%s/%s" ,repertoire,nom_ima); -} -else -{ - strcpy ( nom_fic , nom_ima); -} - -/*****************************************************/ -/* Destruction du repertoire et de tous ses fichiers */ -/*****************************************************/ - - sprintf(Command,"rm -R %s",nom_fic); - system(Command); - -return (CAI_OK); - -} -/* - Fin de l'operation cai_dest_ima_spot -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_modifie_spot */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture-ecriture d'une image au format */ -/* ----- spot et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_modifie_spot(typspot,nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* */ -/* typspot (E) (char) : type spot (1=1a4,b=5bil ou t=5tif) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_modifie_spot (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ /* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_IMAGE *cai_ouvre_modifie_spot(char typspot,char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) - -{ -DIR *dirp; /* pointeur sur structure ouverture repertoire */ -CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ -struct dirent *dp; /* structure resultat de la fonction readdir */ -char fichier_clefs[1024]; /* Nom du fichier des donnees auxiliaires */ -int i,j,k; /* Variables de boucle */ -int descrip_leader; /* Descripteur du fichier LEADER */ -int descrip_imagery; /* Descripteur du fichier IMAGERY */ -int descrip_volume; /* Descripteur du fichier VOLUME */ -long cr_lseek; /* Code retour de lseek */ -long cr_read; /* Code retour de read */ -long lg_saut; /* Nombre d'octets a sauter */ -int lg_enreg,lgtemp; /* longueur d'un enregistrement */ -int NbCan; /* nombre de canaux de l'image */ -int test1,test2,test3,test4,test5;/* test sur nom de fichiers */ -int lg_entete; /* longueur de l'entete fichier IMAGERY */ -int num,trouve; /* variable de test */ -char nom_fic[1024]; /* nom du fichier en-tete */ -char nom_fic_canal[1024]; /* nom fichier canal dont on teste existence */ -char nom_rep[1024]; /* nom du repertoire image SPOT */ -char nom_fic_ima[1024]; /* nom du fichier imagery.dat */ -char nom_leader[1024]; /* nom du fichier leader */ -char path_rep[PATH_MAX]; /* chemin acces fichiers ds repertoire courant */ -char nom_fic_spot5[PATH_MAX];/* chemin acces fichier image tiff ou BIL SPOT5 */ -char nom_ima_spot5[PATH_MAX];/* nom du fichier image spot5 */ -char *pch0; /* pointeur sur chaine de caracteres */ -char car[2]; /* variable de travail */ -int type_spot; /* type d'image spot */ -char byteorder[1]; /* Ordre de codage intel (LE) ou Motorola (BE) */ -int skipbytes; /* Taille entete pour les fichiers BIL SPOT5 */ -CAI_OK_KO icr; -int Trouve; - - -/* Donnees auxiliaires */ - -char TABLEAU[1][257]; /* Variable intermediaire */ - -/* premiere variable = pour le nombre d'elements = nbre de colonnes */ -/* deuxieme element = pour la taille de l'element */ - - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ -*nb_can=0; -*nb_lig=0; -*nb_col=0; -*nboct_pix=1; - type_spot=0; - trouve=0; - car[0]='/'; - -#ifdef _WIN - car[0]='\\'; -#endif - -/*****************************************************************************/ -/* MOD : VERSION : 4.5 : FA : initialisation de image1=NULL a l'ouverture */ -/*****************************************************************************/ - image1= NULL; - - /*.................................. - determination ordre de rangement - des octets sur machine de travail - ......................................*/ - - type_machine = cai_test_pFpf(); - -/******************************************************************************/ -/* Determination du type d'image : SPOT 1 a 4 ou SPOT 5 */ -/******************************************************************************/ -sprintf(nom_rep, "%s%s%s", repert,car, nom_image); - -dirp=opendir(nom_rep); - - -if(dirp!=NULL) - { - while( ((dp=readdir(dirp))!=NULL )&& (trouve ==0)) - { - - /*---------------------------------------------*/ - /* on ne doit pas tenir compte des . et .. */ - /* sous le repertoire courant */ - /*---------------------------------------------*/ - - test1 = strcmp(dp->d_name, "."); - test2 = strcmp(dp->d_name, ".."); - - if ( (test1 != 0) && (test2 != 0) ) -{ -/*****************************************************************************/ -/* MOD : VERSION : 4.8 : FA : Blindage de la reconnaissance du fichier image */ -/*****************************************************************************/ - - /*---------------------------------------------*/ - /* on recherche le fichier Image */ - /*---------------------------------------------*/ - test3 = strncasecmp(dp->d_name,"IMAG", 4); - if (test3 == 0) - { - test4 = strcasecmp(dp->d_name,"imagery.tif"); - if (test4==0) /* format SPOT5TIF */ - { - type_spot = 2; - sprintf (nom_fic_spot5, "%s%s%s%s%s", repert, car, - nom_image, car,dp->d_name); - sprintf (nom_ima_spot5, "%s", dp->d_name); - trouve=1; - } - else - { - test4 = strcasecmp(dp->d_name,"imagery.bil"); - if (test4==0) /* format SPOT5BIL */ - { - type_spot = 3; - sprintf (nom_fic_spot5, "%s%s%s%s%s", repert, car, - nom_image, car,dp->d_name); - sprintf (nom_ima_spot5, "%s", dp->d_name); - trouve=1; - } - else /* format SPOT 1 a 4*/ - { - car[0] = '.'; - pch0 = strchr (dp->d_name, car[0]); - if (pch0 == NULL) - { - type_spot = 1; /* format SPOT 1 a 4*/ - sprintf(nom_fic_ima, "%s/%s/%s", repert, - nom_image, dp->d_name); - trouve=1; - } - else if (strcasecmp(pch0,".DAT")== 0) - { - type_spot = 1; /* format SPOT 1 a 4*/ - sprintf(nom_fic_ima, "%s%s%s%s%s", repert, car, - nom_image, car,dp->d_name); - trouve=1; - } - - } - } - } - } - } - closedir(dirp); - } - - -if (type_spot == 0) -{ - sprintf (CAI_ERREUR,"Erreur : type d'image SPOT inconnu"); - goto ERREUR; -} -/*........................................................................*/ -/* Verication ed la coherence du type spot annonce et du type spot trouve */ -/*........................................................................*/ - if (((typspot == '1')&&(type_spot != 1))|| - ((typspot == 'T')&&(type_spot != 2))|| - ((typspot == 'B')&&(type_spot != 3))) - { - sprintf (CAI_ERREUR, - "Erreur : L'image n'est pas du type SPOT annonce"); - goto ERREUR; - } - -/*=============================================*/ -/* TRAITEMENT D'UNE IMAGE AU FORMAT SPOT 1 A 4 */ -/*=============================================*/ -if (type_spot == 1) -{ - image1= NULL; - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); - image1->ACCES_SPOT[0]=0; - image1->ACCES_SPOT[1]=0; - -/*****************************************************************************/ -/* tests sur les retours d'allocation memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - strcpy(CAI_ERREUR, - "Erreur allocation memoire dans cai_ouvre_modifie_image spot1a4"); - goto ERREUR; - } - -/******************************************************************************/ -/* Ouverture des fichiers LEADER et IMAGERY en lecture */ -/******************************************************************************/ - - sprintf(nom_rep, "%s/%s", repert, nom_image); - - dirp=opendir(nom_rep); - - if(dirp!=NULL) - { - while( (dp=readdir(dirp))!=NULL ) - { - - /*---------------------------------------------*/ - /* on ne doit pas tenir compte des . et .. */ - /* sous le repertoire courant */ - /*---------------------------------------------*/ - - test1 = strcmp(dp->d_name, "."); - test2 = strcmp(dp->d_name, ".."); - - if ( (test1 != 0) && (test2 != 0) ) - { - - test3 = strncasecmp(dp->d_name,"LEAD", 4); - test4 = strncasecmp(dp->d_name,"IMAG", 4); - test5 = strncasecmp(dp->d_name,"VOL", 3); - - /********************************************************/ - /* tests de determination du fichier LEADER sous repert */ - /********************************************************/ - - if (test3==0) - { - sprintf(path_rep, "%s%s%s%s%s", repert, car,nom_image, - car,dp->d_name); - /*ouverture du fichier LEADER*/ - - descrip_leader = open (path_rep, O_RDWR|O_BINARY ); - if (descrip_leader == -1) - { - strcpy(CAI_ERREUR, - "Erreur d'ouverture du fichier LEADER SPOT1a4"); - goto ERREUR; - } - - /*---------------------------------------------------------*/ - /* Lecture de la taille d'un enregistrement dans LEADER */ - /*---------------------------------------------------------*/ - - cr_lseek = lseek ( descrip_leader , 8L , 1 ); - if ( cr_lseek == -1 ) - { - strcpy(CAI_ERREUR,"Erreur acces au fichier leader SPOT1a4"); - goto ERREUR; - } - - cr_read = read ( descrip_leader , &lg_enreg , 4 ); - if ( cr_read == -1 ) - { - strcpy(CAI_ERREUR,"Erreur acces au fichier leader SPOT1a4"); - goto ERREUR; - } - if (strcmp(type_machine,"LE")==0) - { - swab( (void*)&lg_enreg, (void*)&lgtemp,4 ); - cai_inverser_tableau((short *)&lg_enreg, (short *)&lgtemp,2); - } - - /*------------------------------------------------------*/ - /* Retour au debut du fichier LEADER */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( descrip_leader , 0L , 0 ); - if ( cr_lseek == -1 ) - { - strcpy(CAI_ERREUR,"Erreur acces au fichier leader SPOT1a4"); - goto ERREUR; - } - - /*------------------------------------------------------*/ - /* Saut de lg_enreg + 996 octets dans LEADER */ - /*------------------------------------------------------*/ - - lg_saut = (long)(lg_enreg + 996); - cr_lseek = lseek ( descrip_leader , lg_saut , 0 ); - if ( cr_lseek == -1 ) - { - strcpy(CAI_ERREUR,"Erreur acces au fichier leader SPOT1a4"); - goto ERREUR; - } - /*------------------------------------------------------*/ - /* Lecture du nombre de colonnes dans LEADER */ - /*------------------------------------------------------*/ - - cr_read = read (descrip_leader, TABLEAU[0], 16); - if ( cr_read != 16 ) - { - strcpy(CAI_ERREUR,"Erreur acces au fichier leader SPOT1a4"); - goto ERREUR; - } - TABLEAU[0][16] = '\0'; /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for (i=0;i<16;i++) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sscanf ( TABLEAU[0], "%d", nb_col); - - /*------------------------------------------------------*/ - /* Lecture du nombre de lignes dans LEADER */ - /*------------------------------------------------------*/ - - cr_read = read (descrip_leader, TABLEAU[0], 16); - if ( cr_read != 16 ) - { - strcpy(CAI_ERREUR,"Erreur acces au fichier leader SPOT1a4"); - goto ERREUR; - } - TABLEAU[0][16] = '\0'; /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for (i=0;i<16;i++) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sscanf ( TABLEAU[0], "%d", nb_lig); - - /*------------------------------------------------------*/ - /* Saut de 16 octets dans LEADER */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( descrip_leader , 16L , 1 ); - if ( cr_lseek == -1 ) - { - strcpy(CAI_ERREUR,"Erreur acces au fichier leader SPOT1a4"); - goto ERREUR; - } - - /*------------------------------------------------------*/ - /* Lecture du nombre de canaux dans LEADER */ - /*------------------------------------------------------*/ - - cr_read = read (descrip_leader, TABLEAU[0], 16); - if ( cr_read != 16 ) - { - strcpy(CAI_ERREUR,"Erreur acces au fichier leader SPOT1a4"); - goto ERREUR; - } - TABLEAU[0][16] = '\0'; /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for (i=0;i<16;i++) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sscanf ( TABLEAU[0], "%d", nb_can); - } /*fin test3 (v==0)*/ - - else if (test5==0) - { - /********************************************************/ - /* tests de determination du fichier VOLUME sous repert */ - /********************************************************/ - - sprintf(path_rep, "%s%s%s%s%s", repert, car,nom_image, - car,dp->d_name); - - /*ouverture du fichier VOLUME*/ - - descrip_volume = open (path_rep, O_RDWR|O_BINARY ); - if (descrip_volume == -1) - { - strcpy(CAI_ERREUR, - "Erreur d'ouverture du fichier VOLUME SPOT1a4"); - goto ERREUR; - } - } - /********************************************************/ - /* tests de determination du fichier IMAGERY sous repert */ - /********************************************************/ - - else if (test4==0) - { - - /*ouverture du fichier IMAGERY*/ - - descrip_imagery = open (nom_fic_ima, O_RDWR |O_BINARY); - if (descrip_imagery == -1) - { - strcpy(CAI_ERREUR, - "Erreur d'ouverture du fichier IMAGERY SPOT1a4"); - goto ERREUR; - } - - /*------------------------------------------------------*/ - /* Lecture de la taille de l'entete dans IMAGERY */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( descrip_imagery , 8L , 1); - if ( cr_lseek == -1 ) - { - strcpy(CAI_ERREUR, - "Erreur acces au fichier contenant donnees SPOT1a4"); - goto ERREUR; - } - - cr_read = read ( descrip_imagery , &lg_entete , 4 ); - if ( cr_read == -1 ) - { - strcpy(CAI_ERREUR, - "Erreur acces au fichier contenant donnees SPOT"); - goto ERREUR; - } - if (strcmp(type_machine,"LE")==0) - { - swab( (void*)&lg_entete, (void*)&lgtemp,4 ); - cai_inverser_tableau((short *)&lg_entete, - (short *)&lgtemp,2); - } - - } /*fin else if test4*/ - - } /*fin else test1 test2*/ - - } /*fin while*/ - - closedir(dirp); - - } /*fin if (dirp=!NULL)*/ - -/*....................................... - INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL - .....................................................*/ - - for (i=0;i<*nb_can;i=i+1) - { - image1->ACCES_CANAL_INT[i]=descrip_imagery; - image1->ACCES_SPOT[0]=descrip_leader; - image1->ACCES_SPOT[1]=descrip_volume; - image1->POS_OCTET[i]=lg_entete; - } - image1->TYPE_SPOT = type_spot; - image1->NBOCT_PIX = *nboct_pix; - - } /* fin TYPE IMAGE SPOT 1 a 4 */ - /*===========================*/ - -/*=============================================*/ -/* TRAITEMENT D'UNE IMAGE AU FORMAT SPOT 5 TIF */ -/*=============================================*/ - else if (type_spot == 2) - { - -/* Ouverture de l'image */ - image1 = cai_ouvre_modifie_image (nom_fic_spot5, "TIFF", - nb_can,nboct_pix,nb_col,nb_lig); - - if (image1 == NULL) - { - strcpy(CAI_ERREUR, - "Erreur acces au fichier image TIFF contenant donnees SPOT5TIF"); - goto ERREUR; - } - - image1->NB_CANAUX = *nb_can ; - image1->NBOCT_PIX = *nboct_pix ; - image1->NB_COL = *nb_col ; - image1->NB_LIG = *nb_lig ; - image1->TYPE_SPOT = type_spot; - image1->ACCES_SPOT[0]=0; - image1->ACCES_SPOT[1]=0; - - - } /* fin TYPE IMAGE SPOT 5 TIFF */ - /*============================*/ - -/*=============================================*/ -/* TRAITEMENT D'UNE IMAGE AU FORMAT SPOT 5 BIL */ -/*=============================================*/ - else - { - - image1= NULL; - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); - image1->ACCES_SPOT[0]=0; - image1->ACCES_SPOT[1]=0; - -/*****************************************************************************/ -/* tests sur les retours d'allocation memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - strcpy(CAI_ERREUR, - "Erreur allocation memoire dans cai_ouvre_modifie_image SPOT5TIF"); - goto ERREUR; - } - - /* Recherche du leader Dimap */ - dirp=opendir(nom_rep); - Trouve=0; - if(dirp!=NULL) - { - while( (dp=readdir(dirp))!=NULL ) - { - - /*---------------------------------------------*/ - /* on ne doit pas tenir compte des . et .. */ - /* sous le repertoire courant */ - /*---------------------------------------------*/ - - test1 = strcmp(dp->d_name, "."); - test2 = strcmp(dp->d_name, ".."); - - if ( (test1 != 0) && (test2 != 0) ) - { - -/*****************************************************************/ -/* MOD : VERSION : 4.7 : DM : LEAD_01.DAT devient METADATA.DIM */ -/*****************************************************************/ - test3 = strncasecmp(dp->d_name,"METADATA.DIM", 12); - - /**************************************************************/ - /* tests de determination du fichier METADATA.DIM sous repert */ - /**************************************************************/ - if (test3==0) - { - sprintf(nom_leader, "%s%s%s%s%s", repert,car, nom_image, - car, dp->d_name); - -/* Extraction du nombre de lig col can et nboct du fichier DIMAP */ -/*...............................................................*/ - icr = cai_lire_dimensions_spot5(nom_leader,nb_can,nboct_pix , - nb_col , nb_lig,byteorder, - &skipbytes ); - if (icr != CAI_OK) - { - goto ERREUR; - } - else - Trouve=1; - } - } /*fin else test1 test2*/ - - } /*fin while*/ - - closedir(dirp); - - } /*fin if (dirp=!NULL)*/ - - if (Trouve==0) - { - sprintf(CAI_ERREUR, - "Erreur Le fichier METADATA.DIM n'existe pas ou erreur de lecture"); - goto ERREUR; - } - - -/* INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL - .....................................................*/ - - nom_fic_canal[0]='\0'; - - sprintf(nom_fic_canal,"%s",nom_fic_spot5); - - num=open(nom_fic_canal,O_RDWR|O_BINARY,0); - if (num!= -1) - { - for (i=0;i<*nb_can;i=i+1) - { - image1->ACCES_CANAL_INT[i]=num; - image1->POS_OCTET[i]=(*nb_col)*i*(*nboct_pix)+skipbytes; - } - image1->TYPE_SPOT = type_spot; - image1->NBOCT_PIX = *nboct_pix; - if (byteorder[0]=='M') - { - if (strcmp(type_machine,"BE")==0) - image1->INV_OCTETS=0; - else - image1->INV_OCTETS=1; - } - else - { - if (strcmp(type_machine,"LE")==0) - image1->INV_OCTETS=0; - else - image1->INV_OCTETS=1; - } - - } - else - { - strcpy(CAI_ERREUR, - "Erreur ouverture fichier BIL contenant donnees SPOT5"); - goto ERREUR; - } - - } /* fin TYPE IMAGE SPOT 5 BIL */ - /*===========================*/ - - return(image1); - - -ERREUR: - if (type_spot==1) - { - if (descrip_leader >0) close(descrip_leader); - if (descrip_imagery >0) close(descrip_imagery); - if (descrip_volume >0) close(descrip_volume); - } - else - icr = cai_ferme_spot(typspot,image1); - - if (image1!=NULL) free(image1); - return(NULL); -} - -/* - Fin de l'operation cai_ouvre_modifie_spot -*/ -/******************************************************************************/ -/* */ -/*OPERATION : cai_lead4to5spot */ -/* */ -/*ROLE : Cette operation genère un fichier XML de donnees auxiliaires SPOT5 */ -/* a partir du fichier Leader donne en parametre */ -/* */ -/*CONTEXTE D'APPEL : */ -/* */ -/*RETOUR : CAI_OK si tout va bien , CAI_KO sinon */ -/* */ -/******************************************************************************/ - -/* MOD : VERSION : 4.5 : FA : erreur d'ecriture detector id lookangle pour PAN*/ - -CAI_OK_KO cai_lead4to5spot ( CAI_IMAGE *desc_im , char *repertoire ) -{ - CAI_OK_KO cr; - /* Variables destinees aux noms des fichiers manipules */ - - FILE *des; - char chemin_descripteur[1024] ; - /* Variables destinees aux controles de la lecture des fichiers */ - /* int desc_lead;*/ - - int BadFlag[4],Bad,type; - int desc_lead , desc_vol , desc_img; - int detect_id; - int lg_enreg ; /* longueur de l'enregistrement et retour de read */ - long cr_lseek , lg_saut; /* retour de lseek et saut demande */ - long cr_read; - - int i , x , j , ind_gains;/* indices de boucle */ - int can; - char TABLEAU[4][257]; /* variable destinee a la lecture des octets */ - - /* Variables stockant les donnees auxiliaires lues */ - - int nb_col , nb_lig; /* nbre de lignes et de colonnes */ - int K , J , nb_bs; /* valeurs K,J,decalage et nbre canaux */ - int ind_max; - int anneecal , moiscal , jourcal; - - char scene_id[17] ; /* identifiant de scene */ - char grille_ref[8] ; /* grille de reference K J */ - char shift_val[2] ; /* shift value */ - char latc[17] , lonc[17] ; /* lat lon au centre de scene */ - - char latse[17] , latso[17]; /* lat lon aux 4 coins */ - char latne[17] , latno[17]; /* */ - char lonse[17] , lonso[17]; /* */ - char lonne[17] , lonno[17]; /* */ - char al[17] , bl[17] , cl[17]; - char ap[17] , bp[17] , cp[17]; - - double lat_c ,lon_c; /* valeurs en double des latitudes et */ - double lat_se, lat_so; /* longitudes au centre de scene et */ - double lon_se , lon_so; /* 4 coins de scene */ - double lat_ne , lat_no; - double lon_ne , lon_no; - double lat_nad , long_nad; - double yawdeg , yawrad; - - char colc1[17] , ligc1[17]; /* Lignes et colonnes aux 4 coins */ - char colc2[17] , ligc2[17]; - char colc3[17] , ligc3[17]; - char colc4[17] , ligc4[17]; - int nbl_c , nbc_c; /* x y ligne et colonne centre de scene */ - int ivaleur; - char Valeur[17]; - - char decal_lat[17]; /* Decalage latitude */ - char decal_lon[17]; /* Decalage longitude */ - char longnad[17]; /* latitude nadir */ - char latnad[17]; /* longitude nadir */ - char datecalib[11]; - char datecentre[17]; - char datecal[9]; - char relativedatecalib[16][20]; - int relativeannee , relativemois , relativejour ; - char mapproj[33] ; /* Projection cartographique */ - char gains_a[4][9]; /* coefficient de calibration */ - char gains_b[4][9]; /* offset de calibration */ - char nb_gains[4][5]; /* nombre de gains */ - char date[11] ; /* date d'acquisition */ - char stepnum[5] ; - char heure[10] ; /* heure d'acquisition */ - char coupled[3] , sec[3] ; /* minute , seconde */ - char niv_trait[17] ; /* niveau de traitement */ - char direct_playback[17] ; - char compression[17] ; - char instrument[6] ; /* instrument HRV */ - char time_angle[73][27]; - char timeyaw[3][27]; - float gain_value[16][1500]; - float dark_value[16][1500]; - float anglin ; - short int val,valtemp ; - float val_float ; - int type_gain , ind_gain_val , ind_dark_val ; - int instrument_index , ind_tab_gain ; - int line[73] , line_raw[2] ; - char yaw[73][20] ,pitch[73][20] ,roll[73][20] ; - char yaw_angle[2][20] , pitch_angle[2][20] , roll_angle[2][20]; - double psi_x_first[3] ,psi_y_first[3] ,psi_x_last[3] ,psi_y_last[3]; - double psideg , periodeligne ; - char lineperiod[13] , outofrange[3] ; - char ins_ind[2] ; - char sat_ind[2] ; - char mode_spect[17]; /* mode spectral */ - char satellite[5]; /* nom du satellite */ - int satellite_index ; - char revolution[17]; /* revolution number */ - char band_layout[17]; - char spect_ind[17]; /* indicateur de bandes */ - char sat_alt[9]; /* altitude du satellite */ - char nb_leader[9]; /* nb enregistrements leader */ - char lg_leader[9] ; /* lg enregistrements leader */ - char nb_imagery[9] ; /* nb enregistrements imagery */ - char lg_imagery[9] ; /* lg enregistrements imagery */ - char nbima_imagery[9] ; /* nb enregist imagery image */ - char nb_trailer[9] ; /* nb enregistrements trailer */ - char lg_trailer[9] ; /* lg enregistrements trailer */ - char fpixraw[9] , flineraw[9] , fpix1b[9] , fline1b[9]; - char taille_pixlig[17]; /* taille pixel sur les lignes */ - char taille_pixcol[17]; /* taille pixel sur les colonnes */ - char x0[33] , y0[33]; /* coordonnees en pixel 1,1 */ - char lgx[17] , lgy [17]; /* longueur image en X et Y */ - char im[17] , deltai[17] , jm[17] ,deltaj[17]; - char lm[17] , deltal[17] , pm[17] , deltap[17]; - char valeur[100]; - char prod_info[31]; - char mean[9]; - char lowtresh[4][9]; - char uptresh[4][9]; - char firstwave[4][20]; - double unwave ; - double wavelong ; - char wavelengthstep[4][20] , solar_irradiance[4][5]; - char spectral_sensitivitie[4][64][6]; - char shval[9] , segmentstart[9] , scenestart[9] , segmentend[9]; - char resampling[3]; - int utdatej , utdates; - char p7[17] ,p8[17] ,p9[17] ,p10[17] ; - char axis[13] , ascension[13] , latarg[13]; - char ex[17] , ey[17] , inclin[13]; - char coeffi[17] , ai[17] , bi[17] , ci[17] , di[17] , ei[17]; - char coeffj[17] , aj[17] , bj[17] , cj[17]; - char coeff_a[17] , aa[17] , ba[17] , ca[17] , da[17]; - char coeff_b[17] , ab[17] , bb[17] , cb[17] , db[17] , eb[17]; - char coeff_l[17] , a_l[17] , b_l[17] , d_l[17] , e_l[17] , c_l[17]; - char coeff_p[17] , a_p[17] , b_p[17] , c_p[17]; - char alswir[17] , blswir[17] , clswir[17] , apswir[17] , bpswir[17]; - char cpswir[17],car[2]; - int jourjul; - int datejul; - char clockvalue[13] ; - char clockperiod[13] ; - double period , pico ; - char boardtime[13]; - double X_loc[9] , Y_loc[9] , Z_loc[9]; - double X_vel[9] , Y_vel[9] , Z_vel[9]; - char time[9][28]; - char dorisused[3]; - char time_scenecenter[31]; - char timecenter[18]; - char angle_in[17] , angle_o[17]; /* angles incidence et orientation Nord */ - char sunazim[17], sunelev[17]; /* azimut et elevation solaire */ - char *profile; - - int signe , swir ; /* signe des lat lon ( +1 ou -1 ) */ - char mirror_step[17] ; /* nombre de pas mirroir */ - int nbpix ; /* nombre de pixels */ - char satn , insn; - char insid, codecapt; - char a0 , a1 , m0 , m1 , j0 , j1 , h0 , h1 , mi0 , mi1 , s0 , s1 ; - char aprim0 , aprim1 , mprim0 , mprim1 , jprim0 , jprim1 , hprim0 , hprim1 , miprim0 , miprim1 , sprim0 , sprim1 ; - char datasetname[40]; - char datasetname_centre[40]; - char dsetname[25]; - char dsetname_centre[25]; - char toto[32] , coeffa[17] , coeffb[17], coeffc[17] , coeffd[17]; - char coeffe[17] , coefff[17] , coeffap[17] , coeffbp[17] ; - char coeffcp[17] , coeffdp[17] , coeffep[17] , coefffp[17]; - char rlma[17] , rlmb[17], rlmc[17] , rlmd[17]; - char rlme[17] , rlmf[17] , rlmap[17] , rlmbp[17] ; - char rlmcp[17] , rlmdp[17] , rlmep[17] , rlmfp[17]; - long jours[9]; - long jourscenter ; - int nb_passage = 0; - double secondescenter ; - double secondes[9]; - double milisecondes[9]; - - /* variables destinees a lire dans le voldir */ - - char job_id[17] , produser[13] , product_type[17]; - char software_name[13] , processing_center[9]; - int product_sec , product_min , product_heure; - int product_annee , product_jour , product_mois; - char copyright[100] , source_description[200]; - - /* variables destinees a lire dans le imagery */ - - unsigned char bad_line[10000][4]; - -/* Initialisations diverses */ -/*--------------------------*/ - for (i=0 ; i<16 ; i++) - { - for (j=0 ; j<1500 ; j++) - { - gain_value[i][j] = 0.0; - dark_value[i][j] = 0.0; - } - } - signe=1; - desc_lead = desc_im->ACCES_SPOT[0]; - desc_vol = desc_im->ACCES_SPOT[1]; - desc_img = desc_im->ACCES_CANAL_INT[0]; - - car[0]='/'; - -#ifdef _WIN - car[0]='\\'; -#endif - - - /* construction du chemin complet du fichier xml a generer */ - sprintf ( chemin_descripteur , "%s%sSPOT_DIMAP.xml" , repertoire, car); - - /********************************************************/ - /* LECTURE DU FICHIER LEADER */ - /********************************************************/ - - cr_lseek = lseek ( desc_lead , 8L , 1 ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*------------------------------------------------------*/ - /* lecture de la longueur de l'enregistrement */ - /*------------------------------------------------------*/ - lg_enreg = 0; - cr_read = read ( desc_lead , &lg_enreg , 4 ); - - if ( cr_read == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_read ); - goto ERREUR; - } - /*------------------------------------------------------*/ - /* Retour au debut du fichier */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 0L , 0 ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*------------------------------------------------------*/ - /* Saut de 52 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 52 , SEEK_SET ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /********************************************************/ - /* LEADER FILE DESCRIPTOR RECORD */ - /********************************************************/ - - /*------------------------------------------------------*/ - /* Lecture du code capteur */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 13 ); - - if ( cr_read != 13 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - TABLEAU[0][13] = '\0'; - - for ( i = 0 ; i < 13 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - codecapt = '\0'; - toto[0] ='\0'; - sscanf ( TABLEAU[0] , "%c%s" , &codecapt , toto ); - - /*------------------------------------------------------*/ - /* Retour au debut du fichier */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 0L , 0 ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*------------------------------------------------------*/ - /* Saut de lg_enreg + 20 octets */ - /*------------------------------------------------------*/ - - lg_saut = (long)( 3960 + 20); - - cr_lseek = lseek ( desc_lead , lg_saut , SEEK_SET ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /********************************************************/ - /* LEADER HEADER RECORD */ - /********************************************************/ - - /*------------------------------------------------------*/ - /* Lecture des coeeficients K et J */ - /*------------------------------------------------------*/ - - for ( x = 0 ; x < 2 ; x++ ) - { - cr_read = read ( desc_lead, TABLEAU[x], 3 ); - if ( cr_read != 3 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[x][3] = '\0'; - - for ( i = 0 ; i < 3 ; i++ ) - { - TABLEAU[x][i] = TABLEAU[x][i] & 0177; - } - } - K=0; - J=0; - sscanf ( TABLEAU[0], "%d", &K ); - sscanf ( TABLEAU[1], "%d", &J ); - sprintf ( grille_ref , "%.3d%.3d" , K , J ); - - /*------------------------------------------------------*/ - /* Lecture de shift value */ - /*------------------------------------------------------*/ - - /* sauter le slash */ - - cr_lseek = lseek ( desc_lead , 1 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - cr_read = read ( desc_lead , TABLEAU[0] , 1 ); - - if ( cr_read != 1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - TABLEAU[0][1] = '\0'; - - for ( i = 0 ; i < 1 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - shift_val[0]='\0'; - sscanf ( TABLEAU[0] , "%s" , shift_val ); - - /*------------------------------------------------------*/ - /* Saut de 8 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 8 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*------------------------------------------------------*/ - /* Lecture de l'identifiant de scene */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - TABLEAU[0][16] = '\0'; - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - - sprintf ( scene_id , "\0" ); - sscanf ( TABLEAU[0] , "%s" , scene_id ); - -/****************************************************************************/ -/* MOD : VERSION : 4.7 : FA : Prise en compte date de la scene non shiftée */ -/****************************************************************************/ strcpy ( datecentre , scene_id ); - - /*------------------------------------------------------*/ - /* Lecture de shift along track ( decal_lat ) */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - TABLEAU[0][16] = '\0'; - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( decal_lat , "\0" ); - sscanf ( TABLEAU[0] , "%s" , decal_lat ); - - /*------------------------------------------------------*/ - /* Lecture de shift along track ( decal_lon ) */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - TABLEAU[0][16] = '\0'; - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( decal_lon, "\0" ); - sscanf ( TABLEAU[0] , "%s" , decal_lon ); - - /*------------------------------------------------------*/ - /* Lecture de la latitude du centre de la scene */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( latc , "\0" ); - lat_c=0; - sscanf ( TABLEAU[0] , "%s" , latc ); - cai_DMS_To_Float ( latc , &lat_c ); - - /*------------------------------------------------------*/ - /* Lecture de la longitude du centre de la scene */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( lonc , "\0" ); - lon_c=0; - sscanf ( TABLEAU[0] , "%s" , lonc ); - cai_DMS_To_Float ( lonc , &lon_c ); - - /*------------------------------------------------------*/ - /* lecture des coordonnees lignes au centre de scene */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - nbc_c = 0; - sscanf ( TABLEAU[0] , "%d" , &nbc_c ); - - /*------------------------------------------------------*/ - /* lecture des coordonnees colonnes au centre de scene */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead , TABLEAU[0] , 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - nbl_c = 0; - sscanf ( TABLEAU[0] , "%d" , &nbl_c ); - /*------------------------------------------------------*/ - /* Lecture de la latitude NO */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - sprintf ( latno , "\0" ); - - lat_no=0; - - sscanf ( TABLEAU[0] , "%s" , latno ); - cai_DMS_To_Float ( latno , &lat_no ); - - /*------------------------------------------------------*/ - /* Lecture de la longitude NO */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( lonno , "\0" ); - lon_no=0; - sscanf ( TABLEAU[0] , "%s" , lonno ); - cai_DMS_To_Float ( lonno , &lon_no ); - - /*------------------------------------------------------*/ - /* Lecture ligne coin NO */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( ligc1 , "\0" ); - sscanf ( TABLEAU[0] , "%s" ,ligc1 ); - - /*------------------------------------------------------*/ - /* Lecture colonne coin NO */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( colc1 , "\0" ); - sscanf ( TABLEAU[0] , "%s" , colc1 ); - - /*------------------------------------------------------*/ - /* Lecture de la latitude NE */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( latne , "\0" ); - sscanf ( TABLEAU[0] , "%s" , latne ); - cai_DMS_To_Float ( latne , &lat_ne ); - - /*------------------------------------------------------*/ - /* Lecture de la longitude NE */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( lonne , "\0" ); - sscanf ( TABLEAU[0] , "%s" , lonne ); - cai_DMS_To_Float ( lonne , &lon_ne ); - - /*------------------------------------------------------*/ - /* Lecture ligne coin NE */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( ligc2 , "\0" ); - sscanf ( TABLEAU[0] , "%s" , ligc2 ); - - /*------------------------------------------------------*/ - /* Lecture colonne coin NE */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( colc2 , "\0" ); - sscanf ( TABLEAU[0] , "%s" , colc2 ); - - /*------------------------------------------------------*/ - /* Lecture de la latitude SO */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( latso , "\0" ); - sscanf ( TABLEAU[0] , "%s" , latso ); - cai_DMS_To_Float ( latso , &lat_so ); - - /*------------------------------------------------------*/ - /* Lecture de la longitude SO */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( lonso , "\0" ); - sscanf ( TABLEAU[0] , "%s" , lonso ); - cai_DMS_To_Float ( lonso , &lon_so ); - - /*------------------------------------------------------*/ - /* Lecture ligne coin SO */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( ligc3 , "\0" ); - sscanf ( TABLEAU[0] , "%s" , ligc3 ); - - /*------------------------------------------------------*/ - /* Lecture colonne coin SO */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( colc3 , "\0" ); - sscanf ( TABLEAU[0] , "%s" , colc3 ); - - /*------------------------------------------------------*/ - /* Lecture de la latitude SE */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( latse , "\0" ); - sscanf ( TABLEAU[0] , "%s" , latse ); - cai_DMS_To_Float ( latse , &lat_se ); - - /*------------------------------------------------------*/ - /* Lecture de la longitude SE */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( lonse , "\0" ); - sscanf ( TABLEAU[0] , "%s" , lonse ); - cai_DMS_To_Float ( lonse , &lon_se ); - - /*------------------------------------------------------*/ - /* Lecture ligne coin SE */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf (ligc4 , "\0" ); - sscanf ( TABLEAU[0] , "%s" , ligc4 ); - - /*------------------------------------------------------*/ - /* Lecture colonne coin SE */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( colc4 , "\0" ); - sscanf ( TABLEAU[0] , "%s" , colc4 ); - - /*------------------------------------------------------*/ - /* Lecture latitude nadir centre */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( latnad , "\0" ); - lat_nad = 0; - sscanf ( TABLEAU[0] , "%s" , latnad ); - cai_DMS_To_Float ( latnad , &lat_nad ); - - /*------------------------------------------------------*/ - /* Lecture longitude nadir centre */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( longnad , "\0" ); - long_nad = 0; - sscanf ( TABLEAU[0] , "%s" , longnad ); - cai_DMS_To_Float ( longnad , &long_nad ); - - /*------------------------------------------------------*/ - /* Lecture de l'angle d'orientation */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead , TABLEAU[0] , 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( angle_o , "\0" ); - sscanf ( TABLEAU[0] , "%s" , angle_o ); - - /*------------------------------------------------------*/ - /* Lecture de l'angle d'incidence */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead , TABLEAU[0] , 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; /* Pour ne pas lire les char suivants */ - - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( angle_in , "\0" ); - sscanf ( TABLEAU[0] , "%s" , angle_in ); - - /*------------------------------------------------------*/ - /* Lecture de l'azimut solaire */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( sunazim , "\0" ); - sscanf ( TABLEAU[0] , "%s" , sunazim ); - - /*------------------------------------------------------*/ - /* Lecture de l'elevation solaire */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( sunelev , "\0" ); - sscanf ( TABLEAU[0] , "%s" , sunelev ); - - /*------------------------------------------------------*/ - /* Lecture de l'altitude du satellite */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 8 ); - - if ( cr_read != 8 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][8] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 8 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( sat_alt , "\0" ); - sscanf ( TABLEAU[0] , "%s" , sat_alt ); - - /*------------------------------------------------------*/ - /* Saut de 72 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 72 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*------------------------------------------------------*/ - /* Lecture de la date */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 8 ); - - if ( cr_read != 8 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][8] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 8 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - date[0]='\0'; - mi0='\0'; - mi1='\0'; - a0='\0'; - a1='\0'; - m0='\0'; - m1='\0'; - j0='\0'; - j1='\0'; - miprim0='\0'; - miprim1='\0'; - aprim0='\0'; - aprim1='\0'; - mprim0='\0'; - mprim1='\0'; - jprim0='\0'; - jprim1='\0'; - - sscanf ( TABLEAU[0] , "%s" , date ); - sscanf ( date , "%c%c%c%c%c%c%c%c" , &mi0 , &mi1 , &a0 , - &a1 , &m0 , &m1 , &j0 , &j1 ); - sprintf ( date , "%c%c%c%c-%c%c-%c%c" , mi0 , mi1 , a0 , a1 , m0 , m1 , j0 , j1 ); - - /*------------------------------------------------------*/ - /* Lecture de l'heure */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 9 ); - - if ( cr_read != 9 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][9] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 9 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - heure[0]='\0'; - toto[0]='\0'; - h0='\0'; - h1='\0'; - insid='\0'; - insn='\0'; - s1='\0'; - s0='\0'; - hprim0='\0'; - hprim1='\0'; - sprim1='\0'; - sprim0='\0'; - - satn='\0'; - sscanf ( TABLEAU[0] , "%s" , heure ); - - sscanf ( heure , "%c%c%c%c%c%c%s" , &h0 , &h1 , &mi0 , &mi1 , &s0 , &s1 , toto ); - - sprintf ( heure , "%c%c:%c%c:%c%c" , h0 , h1 , mi0 , mi1 , s0 , s1 ); - sscanf ( scene_id , "S%c%c%c%s" , &satn , &insid , &insn ,toto ); - - sprintf ( datasetname , "%c %.3d-%.3d %c%c/%c%c/%c%c %c%c:%c%c:%c%c %c %c\0" , - satn , K , J , a0 , a1 , m0 , m1 , j0 , j1 , h0 , - h1 , mi0 , mi1 , s0 , s1 , insn , codecapt ); - - sscanf ( &datecentre[15] , "%c" , &sprim1 ); - datecentre[15] = '\0' ; - sscanf ( &datecentre[14] , "%c" , &sprim0 ); - datecentre[14] = '\0' ; - sscanf ( &datecentre[13] , "%c" , &miprim1 ); - datecentre[13] = '\0' ; - sscanf ( &datecentre[12] , "%c" , &miprim0 ); - datecentre[12] = '\0' ; - sscanf ( &datecentre[11] , "%c" , &hprim1 ); - datecentre[11] = '\0' ; - sscanf ( &datecentre[10] , "%c" , &hprim0 ); - datecentre[10] = '\0' ; - sscanf ( &datecentre[9] , "%c" , &jprim1 ); - datecentre[9] = '\0' ; - sscanf ( &datecentre[8] , "%c" , &jprim0 ); - datecentre[8] = '\0' ; - sscanf ( &datecentre[7] , "%c" , &mprim1 ); - datecentre[7] = '\0' ; - sscanf ( &datecentre[6] , "%c" , &mprim0 ); - datecentre[6] = '\0' ; - sscanf ( &datecentre[5] , "%c" , &aprim1 ); - datecentre[5] = '\0' ; - sscanf ( &datecentre[4] , "%c" , &aprim0 ); - datecentre[4] = '\0' ; -/*****************************************************************************/ -/* MOD : VERSION : 4.8 : FA : Rajout SCENE au début de chaine DATASET_NAME */ -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : DIMAP Ajouter un espace entre SCENE et numsat */ -/* dans le DATASET_NAME */ -/*****************************************************************************/ - sprintf ( datasetname_centre , "SCENE %c %.3d-%.3d %c%c/%c%c/%c%c %c%c:%c%c:%c%c %c %c\0" , - satn , K , J , aprim0 , aprim1 , mprim0 , mprim1 , jprim0 , jprim1 ,hprim0 , - hprim1 , miprim0 , miprim1 , sprim0 , sprim1 , insn , codecapt ); - sprintf ( dsetname , "%c%.3d%.3d%c%c%c%c%c%c%c%c%c%c%c%c%c%c\0" , - satn , K , J , a0 , a1 , m0 , m1 , j0 , j1 , h0 , - h1 , mi0 , mi1 , s0 , s1 , insn , codecapt ); - - sprintf ( dsetname_centre , "%c%.3d%.3d%c%c%c%c%c%c%c%c%c%c%c%c%c%c\0" , - satn , K , J , aprim0 , aprim1 , mprim0 , mprim1 , jprim0 , jprim1 , hprim0 , - hprim1 , miprim0 , miprim1 , sprim0 , sprim1 , insn , codecapt ); - - - /*------------------------------------------------------*/ - /* Saut de 15 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 15 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*------------------------------------------------------*/ - /* Lecture du nom de satellite */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 4); - - if ( cr_read != 4 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][4] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 4 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( satellite , "\0" ); - sscanf ( TABLEAU[0] , "%s" , satellite ); - - /*------------------------------------------------------*/ - /* Lecture du num de satellite */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 12 ); - - if ( cr_read != 12 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][12] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 12 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - satellite_index = 0; - sscanf ( TABLEAU[0] ,"%d" , &satellite_index ); - - /*------------------------------------------------------*/ - /* Lecture du nom d'instrument */ - /*------------------------------------------------------*/ - - if ( satellite_index != 4 ) - { - cr_read = read ( desc_lead, TABLEAU[0], 3 ); - - if ( cr_read != 3 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][3] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 3 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - sprintf ( instrument , "\0" ); - sscanf ( TABLEAU[0] , "%s" , instrument ); - - cr_read = read ( desc_lead, TABLEAU[0], 13 ); - - if ( cr_read != 13 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][13] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 13 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - instrument_index=0; - sscanf ( TABLEAU[0] , "%d" , &instrument_index ); - } - else - { - cr_read = read ( desc_lead, TABLEAU[0], 5 ); - - if ( cr_read != 5 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][5] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 5 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( instrument , "\0" ); - sscanf ( TABLEAU[0] , "%s" , instrument ); - - cr_read = read ( desc_lead, TABLEAU[0], 11 ); - - if ( cr_read != 11 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][11] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 11 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - instrument_index=0; - sscanf ( TABLEAU[0] , "%d" , &instrument_index ); - } - - /*------------------------------------------------------*/ - /* Lecture du mode spectral */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( mode_spect , "\0" ); - sscanf ( TABLEAU[0] , "%s" , mode_spect ); - - /*------------------------------------------------------*/ - /* Lecture du revolution number */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( revolution , "\0" ); - sscanf ( TABLEAU[0] , "%s" , revolution ); - - /*------------------------------------------------------*/ - /* Lecture du nombre de pas mirroir */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( mirror_step , "\0" ); - sscanf ( TABLEAU[0] , "%s" , mirror_step ); - - /*------------------------------------------------------*/ - /* Lecture du mode de compression */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( compression , "\0" ); - sscanf ( TABLEAU[0] , "%s" , compression ); - - /*------------------------------------------------------*/ - /* Lecture du direct playback */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( direct_playback , "\0" ); - sscanf ( TABLEAU[0] , "%s" , direct_playback ); - - /*------------------------------------------------------*/ - /* Lecture du nombre_de_gains */ - /*------------------------------------------------------*/ - - for ( j=0 ; j < 4 ; j++ ) - { - cr_read = read ( desc_lead, TABLEAU[0], 4 ); - - if ( cr_read != 4 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][4] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i=0 ; i < 4 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - sprintf(nb_gains[j],"\0"); - sscanf ( TABLEAU[0] , "%s" , nb_gains[j] ); - } - - /*------------------------------------------------------*/ - /* Lecture du step_num */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 4 ); - - if ( cr_read != 4 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][4] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 4 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - sprintf ( stepnum , "\0" ); - sscanf ( TABLEAU[0] , "%s" , stepnum ); - - /*------------------------------------------------------*/ - /* Lecture du coupled mode */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 2 ); - - if ( cr_read != 2 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][2] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i=0 ; i < 2 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - sprintf ( coupled , "\0" ); - - sscanf ( TABLEAU[0] , "%s" , coupled ); - - /*------------------------------------------------------*/ - /* Saut de 250 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 250 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*------------------------------------------------------*/ - /* Lecture du nombre de colonnes */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i=0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - nb_col=0; - sscanf ( TABLEAU[0], "%d", &nb_col ); - - /*------------------------------------------------------*/ - /* Lecture du nombre de lignes */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i=0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - nb_lig=0; - sscanf ( TABLEAU[0], "%d", &nb_lig ); - - /*------------------------------------------------------*/ - /* Lecture de bands layout */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i=0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - sprintf ( band_layout, "\0" ); - sscanf ( TABLEAU[0] , "%s" , band_layout ); - - /*------------------------------------------------------*/ - /* Lecture du nombre de Bandes spectrales */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - nb_bs=0; - sscanf ( TABLEAU[0], "%d", &nb_bs ); - - /*------------------------------------------------------*/ - /* Lecture indicateur de Bandes spectrales */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - sprintf ( spect_ind , "\0" ); - strcpy ( spect_ind , TABLEAU[0] ); - - /*------------------------------------------------------*/ - /* Saut de 240 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 240 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*-------------------------------------------------------*/ - /* Lecture du niveau de traitement */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - sprintf ( niv_trait , "\0" ); - - sscanf ( TABLEAU[0] , "%s" , niv_trait ); - if (strlen(niv_trait)==0) sprintf ( niv_trait , "0" ); - - /*------------------------------------------------------*/ - /* Saut de 32 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 32 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*-------------------------------------------------------*/ - /* Lecture de resampling method */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( resampling , "\0" ); - sscanf ( TABLEAU[0] , "%s" , resampling ); - - /*-------------------------------------------------------*/ - /* Lecture de la taille des pixels sur les lignes */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( taille_pixlig , "\0" ); - sscanf ( TABLEAU[0] , "%s" , taille_pixlig ); - - /*-------------------------------------------------------*/ - /* Lecture de la taille des pixels sur les colonnes */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( taille_pixcol , "\0" ); - sscanf ( TABLEAU[0] , "%s" , taille_pixcol ); - - /*-------------------------------------------------------*/ - /* Lecture de la projection cartographique */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 32); - - if ( cr_read != 32 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][32] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 32 ; i++) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( mapproj , "\0" ); - sscanf ( TABLEAU[0] , "%s" , mapproj ); - - /*-------------------------------------------------------*/ - /* Lecture longueur image en Y */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( lgy , "\0" ); - sscanf ( TABLEAU[0] , "%s" , lgy ); - - /*-------------------------------------------------------*/ - /* Lecture longueur image en X */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( lgx , "\0" ); - sscanf ( TABLEAU[0] , "%s" , lgx ); - - /*-------------------------------------------------------*/ - /* Lecture Mean_Rectification_Elevation (2A) */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 9 ); - - if ( cr_read != 9 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][9] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 9 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( mean , "\0" ); - sscanf ( TABLEAU[0] , "%s" , mean ); - - /*------------------------------------------------------*/ - /* Saut de 143 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 143 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*-------------------------------------------------------*/ - /* Lecture coordonnees X pixel 1,1 */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 12); - - if ( cr_read != 12 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][12] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 12 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( x0 , "\0" ); - sscanf ( TABLEAU[0] , "%s" , x0 ); - - /*-------------------------------------------------------*/ - /* Lecture coordonnees Y pixel 1,1 */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 12); - - if ( cr_read != 12 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][12] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 12 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( y0, "\0" ); - sscanf ( TABLEAU[0] , "%s" , y0 ); - - /*------------------------------------------------------*/ - /* Saut de 96 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 96 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*-------------------------------------------------------*/ - /* Lecture date de calibration */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead , TABLEAU[0] , 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - sprintf ( datecal , "\0" ); - - jourcal=0; - moiscal=0; - anneecal=0; - sscanf ( TABLEAU[0] , "%s" , datecal ); - if (strlen(datecal) != 0) - { - sscanf ( &datecal[6] , "%d" , &jourcal ); - datecal[6] = '\0'; - sscanf ( &datecal[4] , "%d" , &moiscal ); - - datecal[4] = '\0'; - sscanf ( datecal, "%d" , &anneecal ); - } - sprintf ( datecalib , "%.4d-%.2d-%.2d" , anneecal , moiscal , jourcal ); - - /*-------------------------------------------------------*/ - /* Lecture coeff de calibration */ - /*-------------------------------------------------------*/ - - for ( j = 0; j < 4 ; j++ ) - { - cr_read = read ( desc_lead , TABLEAU[j] , 8 ); - - if ( cr_read != 8 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[j][8] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 8 ; i++ ) - { - TABLEAU[j][i] = TABLEAU[j][i] & 0177; - } - sprintf(gains_a[j],"\0"); - - sscanf ( TABLEAU[j] , "%s" , gains_a[j] ); - } - - /*------------------------------------------------------*/ - /* Saut de 480 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 480 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*-------------------------------------------------------*/ - /* Lecture offset de calibration */ - /*-------------------------------------------------------*/ - - for ( j = 0; j < 4 ; j++ ) - { - cr_read = read ( desc_lead, TABLEAU[j], 8 ); - - if ( cr_read != 8 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[j][8] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 8 ; i++ ) - { - TABLEAU[j][i] = TABLEAU[j][i] & 0177; - } - - sprintf ( gains_b[j] , "\0" ); - - sscanf ( TABLEAU[j] , "%s" , gains_b[j] ); - } - - /*------------------------------------------------------*/ - /* Saut de 1191 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 608 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*-------------------------------------------------------*/ - /* Lecture shift val */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 8 ); - - if ( cr_read != 8 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][8] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 8 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( shval , "\0" ); - sscanf ( TABLEAU[0] , "%s" , shval ); - - /*------------------------------------------------------*/ - /* Saut de 100 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 100 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*-------------------------------------------------------*/ - /* Lecture SWIR REGISTRATION FLAG */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - swir=0; - sscanf ( TABLEAU[0] , "%d" , &swir ); - - /*------------------------------------------------------*/ - /* Saut de 459 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 459 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*-------------------------------------------------------*/ - /* Lecture coeff a */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( coeffa , "\0" ); - - sscanf ( TABLEAU[0] , "%s" , coeffa ); - - /*-------------------------------------------------------*/ - /* Lecture coeff b */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( coeffb , "\0" ) ; - - sscanf ( TABLEAU[0] , "%s" , coeffb ); - - /*-------------------------------------------------------*/ - /* Lecture coeff c */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( coeffc , "\0" ); - sscanf ( TABLEAU[0] , "%s" , coeffc ); - - /*-------------------------------------------------------*/ - /* Lecture coeff d */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( coeffd , "\0" ); - sscanf ( TABLEAU[0] , "%s" , coeffd ); - - /*-------------------------------------------------------*/ - /* Lecture coeff e */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( coeffe , "\0" ); - - sscanf ( TABLEAU[0] , "%s" , coeffe ); - - /*-------------------------------------------------------*/ - /* Lecture coeff f */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( coefff , "\0" ); - - sscanf ( TABLEAU[0] , "%s" , coefff ); - - /*-------------------------------------------------------*/ - /* Lecture coeff ap */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( coeffap , "\0" ); - - sscanf ( TABLEAU[0] , "%s" , coeffap ); - - /*-------------------------------------------------------*/ - /* Lecture coeff bp */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( coeffbp , "\0" ); - sscanf ( TABLEAU[0] , "%s" , coeffbp ); - - /*-------------------------------------------------------*/ - /* Lecture coeff cp */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( coeffcp , "\0" ) ; - - sscanf ( TABLEAU[0] , "%s" , coeffcp ); - - /*-------------------------------------------------------*/ - /* Lecture coeff dp */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( coeffdp , "\0" ); - sscanf ( TABLEAU[0] , "%s" , coeffdp ); - - /*-------------------------------------------------------*/ - /* Lecture coeff ep */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( coeffep , "\0" ); - - sscanf ( TABLEAU[0] , "%s" , coeffep ); - - /*-------------------------------------------------------*/ - /* Lecture coeff fp */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( coefffp , "\0" ); - sscanf ( TABLEAU[0] , "%s" , coefffp ); - - /*------------------------------------------------------*/ - /* Saut de 269 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 269 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /********************************************************/ - /* LEADER EPHEMERIS/ATTITUDE RECORD */ - /********************************************************/ - - /*------------------------------------------------------*/ - /* Saut de 3384 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 20 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - printf ( " erreur69\n" ); - goto ERREUR; - } - - for ( j = 0; j < 9 ; j++ ) - { - /*-------------------------------------------------------*/ - /* Lecture X , Y , Z location points */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 12 ); - - if ( cr_read != 12 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][12] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 12 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - X_loc[j] =0.0; - sscanf ( TABLEAU[0] , "%lf" , &X_loc[j] ); - - cr_read = read ( desc_lead, TABLEAU[0], 12 ); - - if ( cr_read != 12 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][12] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 12 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - Y_loc[j]= 0.0; - sscanf ( TABLEAU[0] , "%lf" , &Y_loc[j] ); - - cr_read = read ( desc_lead, TABLEAU[0], 12 ); - - if ( cr_read != 12 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][12]='\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 12 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - Z_loc[j] =0.0; - sscanf ( TABLEAU[0] , "%lf" , &Z_loc[j] ); - - cr_read = read ( desc_lead, TABLEAU[0], 12 ); - - if ( cr_read != 12 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][12] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 12 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - X_vel[j] =0.0; - sscanf ( TABLEAU[0] , "%lf" , &X_vel[j] ); - - cr_read = read ( desc_lead, TABLEAU[0], 12 ); - - if ( cr_read != 12 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][12] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 12 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - Y_vel[j] =0.0; - sscanf ( TABLEAU[0] , "%lf" , &Y_vel[j] ); - - cr_read = read ( desc_lead, TABLEAU[0], 12 ); - - if ( cr_read != 12 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][12] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 12 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - Z_vel[j] =0.0; - sscanf ( TABLEAU[0] , "%lf" , &Z_vel[j] ); - - /*-------------------------------------------------------*/ - /* Lecture satellite time */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 5 ); - - if ( cr_read != 5 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][5]='\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 5 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - jours[j] =0 ; - sscanf ( TABLEAU[0] , "%ld" , &jours[j] ); - - cr_read = read ( desc_lead, TABLEAU[0], 23 ); - - if ( cr_read != 23 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][23] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 23 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sscanf ( TABLEAU[0] , "%s" , toto ); - secondes[j] = (double) atof ( toto ); - - cai_JulToGreg ( jours[j] , secondes[j] , time[j] ); - - } - - /*-------------------------------------------------------*/ - /* Lecture DORIS FLAG */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 2 ); - - if ( cr_read != 2 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][2] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 2 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - dorisused[0]='\0'; - sscanf ( TABLEAU[0] , "%s" , dorisused ); - - /*------------------------------------------------------*/ - /* Saut de 24 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 24 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*-------------------------------------------------------*/ - /* Lecture line period */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 12 ); - - if ( cr_read != 12 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][12] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 12 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( lineperiod , "\0" ); - sscanf ( TABLEAU[0] , "%s" , lineperiod ); - periodeligne = atof ( lineperiod ) * 0.001; - - /*-------------------------------------------------------*/ - /* Lecture outofrange */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 2 ); - - if ( cr_read != 2 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][2] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 2 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( outofrange , "\0" ); - sscanf ( TABLEAU[0] , "%s" , outofrange ); - - /*------------------------------------------------------*/ - /* Saut de 4 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 4 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*-------------------------------------------------------*/ - /* Lecture timescenecenter */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 30 ); - - if ( cr_read != 30 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][30] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 30 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( timecenter , "\0" ); - sprintf ( time_scenecenter , "\0" ); - sscanf ( TABLEAU[0] , "%s" , time_scenecenter ); - if (time_scenecenter[0]!='\0') - { - strcpy ( timecenter , time_scenecenter ); - secondescenter = atof ( &time_scenecenter[5] ); - time_scenecenter[5] = '\0'; - jourscenter = 0; - sscanf ( time_scenecenter , "%ld" , &jourscenter ); - cai_JulToGreg ( jourscenter , secondescenter , time_scenecenter ); - } - /*------------------------------------------------------*/ - /* Saut de 6 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 6 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - for ( j = 0; j < 73 ; j++ ) - { - /*-------------------------------------------------------*/ - /* Lecture attitude line number */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 4 ); - - if ( cr_read != 4 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][4] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 4 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - line[j] = 0 ; - sscanf ( TABLEAU[0] , "%d" , &line[j] ); - -/*****************************************************************************/ -/* MOD : VERSION : 4.6 : FA : erreur calcul de la datation des attitudes */ -/*****************************************************************************/ - - cai_addtime ( time_angle[j] , timecenter , - ((double) ( line[j] - nbc_c ))*periodeligne ); - - /*-------------------------------------------------------*/ - /* Lecture rotation yaw axis */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 5 ); - - if ( cr_read != 5 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][5] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 5 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - yawdeg = atof ( TABLEAU[0] ); - yawrad = cai_DegreeToRadian ( yawdeg ) * 0.000001; - - if ( j == 72 ) - { - strcpy ( yaw[j] , "" ); - sscanf ( TABLEAU[0] , "%s" , yaw[j] ); - if ( strcmp ( yaw[j] , "" ) !=0) - sprintf ( yaw[j] , "%.12lf" , yawrad ); - } - else - sprintf ( yaw[j] , "%.12lf" , yawrad ); - - /*-------------------------------------------------------*/ - /* Lecture rotation roll axis */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 5 ); - - if ( cr_read != 5 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][5] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 5 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - yawdeg = atof ( TABLEAU[0] ) * 0.000001; - yawrad = cai_DegreeToRadian ( yawdeg ); - sprintf ( roll[j] , "%.12lf" , yawrad ); - - /*-------------------------------------------------------*/ - /* Lecture rotation pitch axis */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 5 ); - - if ( cr_read != 5 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][5] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 5 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - yawdeg = atof ( TABLEAU[0] ) * 0.000001; - yawrad = cai_DegreeToRadian ( yawdeg ); - - sprintf ( pitch[j] , "%.12lf" , yawrad ); - - /*------------------------------------------------------*/ - /* Saut de 1 octet */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 1 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - } - - /*-------------------------------------------------------*/ - /* Lecture psi_x_first */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 8 ); - - if ( cr_read != 8 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][8] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 8 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - /* sscanf ( TABLEAU[0] , "%s" , psi_x_first );*/ - - /*-------------------------------------------------------*/ - /* Lecture psi_x_last */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 8 ); - - if ( cr_read != 8 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][8] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 8 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - /* sscanf ( TABLEAU[0] , "%s" , psi_x_last );*/ - - /*-------------------------------------------------------*/ - /* Lecture psi_y_first */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 8 ); - - if ( cr_read != 8 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][8] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 8 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - /* sscanf ( TABLEAU[0] , "%s" , psi_y_first );*/ - - /*-------------------------------------------------------*/ - /* Lecture psi_y_last */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 8 ); - - if ( cr_read != 8 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][8] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 8 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - /* sscanf ( TABLEAU[0] , "%s" , psi_x_last );*/ - - /*------------------------------------------------------*/ - /* Saut de 508 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 508 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - for ( j = 0; j < 2 ; j++ ) - { - /*-------------------------------------------------------*/ - /* Lecture line number raw scene */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 8 ); - - if ( cr_read != 8 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][8] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 8 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - line_raw[j]= 0 ; - sscanf ( TABLEAU[0] , "%d" , &line_raw[j] ); - -/*****************************************************************************/ -/* MOD : VERSION : 4.6 : FA : erreur calcul de la datation des attitudes */ -/*****************************************************************************/ - - cai_addtime ( timeyaw[j] , timecenter , - ((double) ( line_raw[j] - nbc_c ))*periodeligne ); - - /*-------------------------------------------------------*/ - /* Lecture yaw_angle */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 8 ); - - if ( cr_read != 8 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][8] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 8 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - yawdeg = atof ( TABLEAU[0] ) * 0.000001; - yawrad = cai_DegreeToRadian ( yawdeg ); - - sprintf ( yaw_angle[j] , "%.12lf" , yawrad ); - - /*-------------------------------------------------------*/ - /* Lecture roll_angle */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 8 ); - - if ( cr_read != 8 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][8] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 8 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - yawdeg = atof ( TABLEAU[0] ) * 0.000001; - yawrad = cai_DegreeToRadian ( yawdeg ); - - sprintf ( roll_angle[j] , "%.12lf" , yawrad ); - - /*-------------------------------------------------------*/ - /* Lecture pitch_angle */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 8 ); - - if ( cr_read != 8 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][8] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 8 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - yawdeg = atof ( TABLEAU[0] ) * 0.000001; - yawrad = cai_DegreeToRadian ( yawdeg ); - - sprintf ( pitch_angle[j] , "%.12lf" , yawrad ); - - } - - if ( nb_bs == 1 ) - ind_max = nb_bs; - else - if ( nb_bs == 3 ) - ind_max = 2; - else - ind_max = 3; - - for ( j = 0; j < ind_max ; j++ ) - { - - /*-------------------------------------------------------*/ - /* Lecture psi_x_first */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 12 ); - - if ( cr_read != 12 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][12] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 12 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - cai_DMS_To_Float ( TABLEAU[0] , &psideg ); - psi_x_first[j] = cai_DegreeToRadian ( psideg ); - - /*-------------------------------------------------------*/ - /* Lecture psi_x_last */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 12 ); - - if ( cr_read != 12 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][12] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 12 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - cai_DMS_To_Float ( TABLEAU[0] , &psideg ); - psi_x_last[j] = cai_DegreeToRadian ( psideg ); - - /*-------------------------------------------------------*/ - /* Lecture psi_y_first */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 12 ); - - if ( cr_read != 12 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][12] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 12 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - cai_DMS_To_Float ( TABLEAU[0] , &psideg ); - psi_y_first[j] = cai_DegreeToRadian ( psideg ); - - /*-------------------------------------------------------*/ - /* Lecture psi_y_last */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 12 ); - - if ( cr_read != 12 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][12] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 12 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - psideg = 0.0; - cai_DMS_To_Float ( TABLEAU[0] , &psideg ); - psi_y_last[j] = cai_DegreeToRadian ( psideg ); - } - - /*-------------------------------------------------------*/ - /* saut different selon le nombre d'angles lus */ - /*-------------------------------------------------------*/ - - if ( ind_max == 1 ) - { - /* saut de 8*12 octets */ - - /*------------------------------------------------------*/ - /* Saut de 96 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 96 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - } - else - if ( ind_max == 2 ) - { - /* saut de 4*12 octets */ - - /*------------------------------------------------------*/ - /* Saut de 48 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 48 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - } - - /*-------------------------------------------------------*/ - /* Lecture date julienne */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 7 ); - - if ( cr_read != 7 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][7] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 7 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - jourjul=0; - sscanf ( TABLEAU[0] , "%d" , &jourjul ); - - cr_read = read ( desc_lead, TABLEAU[0], 5 ); - - if ( cr_read != 5 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][5] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 5 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - datejul=0; - sscanf ( TABLEAU[0] , "%d" , &datejul ); - - /*-------------------------------------------------------*/ - /* Lecture major axis */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 12 ); - - if ( cr_read != 12 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][12] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 12 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( axis , "\0" ); - sscanf ( TABLEAU[0] , "%s" , axis ); - - /*-------------------------------------------------------*/ - /* Lecture ex */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( ex , "\0" ); - sscanf ( TABLEAU[0] , "%s" , ex ); - - /*-------------------------------------------------------*/ - /* Lecture ey */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( ey , "\0" ); - sscanf ( TABLEAU[0] , "%s" , ey ); - - /*-------------------------------------------------------*/ - /* Lecture inclinaison */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 12 ); - - if ( cr_read != 12 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][12] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 12 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( inclin , "\0" ); - sscanf ( TABLEAU[0] , "%s" , inclin ); - - /*-------------------------------------------------------*/ - /* Lecture ascension */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 12 ); - - if ( cr_read != 12 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][12] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 12 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( ascension , "\0" ); - sscanf ( TABLEAU[0] , "%s" , ascension ); - - /*-------------------------------------------------------*/ - /* Lecture latitude argument */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 12 ); - - if ( cr_read != 12 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][12] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 12 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( latarg , "\0" ); - sscanf ( TABLEAU[0] , "%s" , latarg ); - - /*-------------------------------------------------------*/ - /* Lecture p7 */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( p7 , "\0" ); - sscanf ( TABLEAU[0] , "%s" , p7 ); - - /*-------------------------------------------------------*/ - /* Lecture p8 */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( p8 , "\0" ); - sscanf ( TABLEAU[0] , "%s" , p8 ); - - /*-------------------------------------------------------*/ - /* Lecture p9 */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 12 ); - - if ( cr_read != 12 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][12] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 12 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( p9 , "\0" ); - sscanf ( TABLEAU[0] , "%s" , p9 ); - - /*-------------------------------------------------------*/ - /* Lecture p10 */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( p10 , "\0" ); - sscanf ( TABLEAU[0] , "%s" , p10 ); - - /*-------------------------------------------------------*/ - /* Lecture segmentstart */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 8 ); - - if ( cr_read != 8 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][8] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 8 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( segmentstart , "\0" ); - sscanf ( TABLEAU[0] , "%s" , segmentstart ); - - /*-------------------------------------------------------*/ - /* Lecture scenestart */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 8 ); - - if ( cr_read != 8 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][8] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 8 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( scenestart , "\0" ); - sscanf ( TABLEAU[0] , "%s" , scenestart ); - - /*-------------------------------------------------------*/ - /* Lecture segmentend */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 8 ); - - if ( cr_read != 8 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][8] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 8 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( segmentend , "\0" ); - sscanf ( TABLEAU[0] , "%s" , segmentend ); - - /*-------------------------------------------------------*/ - /* Lecture UT date */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 7 ); - - if ( cr_read != 7 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][7] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 7 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - utdatej=0; - sscanf ( TABLEAU[0] , "%d" , &utdatej ); - - cr_read = read ( desc_lead, TABLEAU[0], 5 ); - - if ( cr_read != 5 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][5] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 5 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - utdates=0; - sscanf ( TABLEAU[0] , "%d" , &utdates ); - - /*-------------------------------------------------------*/ - /* Lecture clockvalue */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 12 ); - - if ( cr_read != 12 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][12] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 12 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( clockvalue , "\0" ); - sscanf ( TABLEAU[0] , "%s" , clockvalue ); - - /*-------------------------------------------------------*/ - /* Lecture clockperiod */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 12 ); - - if ( cr_read != 12 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][12] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 12 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( clockperiod , "\0" ); - sscanf ( TABLEAU[0] , "%s" , clockperiod ); - - /*-------------------------------------------------------*/ - /* Lecture boardtime */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 12 ); - - if ( cr_read != 12 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][12] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 12 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( boardtime , "\0" ); - sscanf ( TABLEAU[0] , "%s" , boardtime ); - - /*------------------------------------------------------*/ - /* Saut de 528 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 528 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /********************************************************/ - /* LEADER RADIOMETRIC CALIBRATION RECORD */ - /********************************************************/ - ind_gain_val = 0; - ind_dark_val = 0; - - for ( ind_gains = 0 ; ind_gains < 16 ; ind_gains++ ) - { - - /*------------------------------------------------------*/ - /* Saut de 24 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 24 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*------------------------------------------------------*/ - /* Lecture du flag indiquant si c'est un gains ou dark */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 4 ); - - if ( cr_read != 4 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][4] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 4 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - type_gain =0; - sscanf ( TABLEAU[0] , "%d" , &type_gain ); - - /*------------------------------------------------------*/ - /* Saut de 20 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 20 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*------------------------------------------------------*/ - /* Lecture date calibration de cette bande */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 8 ); - - if ( cr_read != 8 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][8] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 8 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - relativeannee=0; - sscanf ( &(TABLEAU[0][4]) , "%d" , &relativeannee ); - TABLEAU[0][4] = '\0'; - relativemois=0; - sscanf ( &(TABLEAU[0][2]) , "%d" , &relativemois ); - TABLEAU[0][2] = '\0'; - relativejour=0; - sscanf ( TABLEAU[0] , "%d" , &relativejour ); - - sprintf ( relativedatecalib[ind_gains] , "%.4d-%.2d-%.2d 00:00:00" , relativeannee , - relativemois , relativejour ); - - /*------------------------------------------------------*/ - /* Saut de 4 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 4 , SEEK_CUR ); - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - if ( type_gain == 1 ) - { - for ( ind_tab_gain = 0 ; ind_tab_gain < 1500 ; ind_tab_gain++ ) - { - - /*------------------------------------------------------*/ - /* Lecture des 1500 gains */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, &val , 2 ); - - if ( cr_read != 2 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - if (strcmp(type_machine,"LE")==0) - { - swab((void*)&val,(void*)&valtemp,2); - val=valtemp; - } - val_float = (float) val/10000.0; - gain_value[ind_gain_val][ind_tab_gain] = val_float ; - } - ind_gain_val++; - } - else if ( type_gain == 2 ) - { - for ( ind_tab_gain =0 ; ind_tab_gain < 1500 ; ind_tab_gain++ ) - { - - /*------------------------------------------------------*/ - /* Lecture des 1500 darks */ - /*------------------------------------------------------*/ - - cr_read = read ( desc_lead, &val, 2 ); - if ( cr_read != 2 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - if (strcmp(type_machine,"LE")==0) - { - swab((void*)&val,(void*)&valtemp,2); - val=valtemp; - } - val_float = (float) val/10.0; - dark_value[ind_dark_val][ind_tab_gain] = val_float ; - } - ind_dark_val++; - } - else - { -/* Valeurs non significatives . Saut de l'enregistrement */ - cr_lseek = lseek ( desc_lead , 3000 , SEEK_CUR ); - } - - /*------------------------------------------------------*/ - /* Saut de 900 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 900 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - } - - /********************************************************/ - /* LEADER MODELIZATION RECORD */ - /********************************************************/ - - /*------------------------------------------------------*/ - /* Saut de 16 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 16 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*-------------------------------------------------------*/ - /* Lecture first pixel of the raw scene */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 8 ); - - if ( cr_read != 8 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][8] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 8 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( fpixraw , "\0" ); - sscanf ( TABLEAU[0] , "%s" , fpixraw ); - - /*-------------------------------------------------------*/ - /* Lecture first line of the raw scene */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 8 ); - - if ( cr_read != 8 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][8] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 8 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( flineraw , "\0" ); - sscanf ( TABLEAU[0] , "%s" , flineraw ); - - /*-------------------------------------------------------*/ - /* Lecture first pixel 1b of the raw scene */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 8 ); - - if ( cr_read != 8 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][8] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 8 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( fpix1b , "\0" ); - sscanf ( TABLEAU[0] , "%s" , fpix1b ); - - /*-------------------------------------------------------*/ - /* Lecture first line 1b of the raw scene */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 8 ); - - if ( cr_read != 8 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][8] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 8 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( fline1b , "\0" ); - sscanf ( TABLEAU[0] , "%s" , fline1b ); - - /*------------------------------------------------------*/ - /* Saut de 32 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 32 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*-------------------------------------------------------*/ - /* Lecture al */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( al , "\0" ); - sscanf ( TABLEAU[0] , "%s" , al ); - - /*-------------------------------------------------------*/ - /* Lecture bl */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( bl , "\0" ); - sscanf ( TABLEAU[0] , "%s" , bl ); - - /*-------------------------------------------------------*/ - /* Lecture cl */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( cl , "\0" ); - sscanf ( TABLEAU[0] , "%s" , cl ); - - /*-------------------------------------------------------*/ - /* Lecture ap */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( ap , "\0" ); - sscanf ( TABLEAU[0] , "%s" , ap ); - - /*-------------------------------------------------------*/ - /* Lecture bp */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( bp , "\0" ); - sscanf ( TABLEAU[0] , "%s" , bp ); - - /*-------------------------------------------------------*/ - /* Lecture cp */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( cp , "\0" ); - sscanf ( TABLEAU[0] , "%s" , cp ); - - /*------------------------------------------------------*/ - /* Saut de 16 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 16 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*-------------------------------------------------------*/ - /* Lecture i_m */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( im , "\0" ); - sscanf ( TABLEAU[0] , "%s" , im ); - - /*-------------------------------------------------------*/ - /* Lecture delta_i */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( deltai , "\0" ); - sscanf ( TABLEAU[0] , "%s" , deltai ); - - /*-------------------------------------------------------*/ - /* Lecture j_m */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( jm , "\0" ); - sscanf ( TABLEAU[0] , "%s" , jm ); - - /*-------------------------------------------------------*/ - /* Lecture delta_j */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( deltaj , "\0" ); - sscanf ( TABLEAU[0] , "%s" , deltaj ); - - /*-------------------------------------------------------*/ - /* Lecture l_m */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( lm , "\0" ); - sscanf ( TABLEAU[0] , "%s" , lm ); - - /*-------------------------------------------------------*/ - /* Lecture delta_l */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( deltal , "\0" ); - sscanf ( TABLEAU[0] , "%s" , deltal ); - - /*-------------------------------------------------------*/ - /* Lecture p_m */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( pm , "\0" ); - sscanf ( TABLEAU[0] , "%s" , pm ); - - /*-------------------------------------------------------*/ - /* Lecture delta_p */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( deltap , "\0" ); - sscanf ( TABLEAU[0] , "%s" , deltap ); - - /*------------------------------------------------------*/ - /* Saut de 16 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 16 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*-------------------------------------------------------*/ - /* Lecture coeff_i */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( coeffi , "\0" ); - sscanf ( TABLEAU[0] , "%s" , coeffi ); - - /*-------------------------------------------------------*/ - /* Lecture ai */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( ai , "\0" ); - sscanf ( TABLEAU[0] , "%s" , ai ); - - /*-------------------------------------------------------*/ - /* Lecture bi */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( bi , "\0" ); - sscanf ( TABLEAU[0] , "%s" , bi ); - - /*-------------------------------------------------------*/ - /* Lecture ci */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( ci , "\0" ); - sscanf ( TABLEAU[0] , "%s" , ci ); - - /*-------------------------------------------------------*/ - /* Lecture di */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( di , "\0" ); - sscanf ( TABLEAU[0] , "%s" , di ); - - /*-------------------------------------------------------*/ - /* Lecture ei */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( ei , "\0" ); - sscanf ( TABLEAU[0] , "%s" , ei ); - - /*-------------------------------------------------------*/ - /* Lecture coeff_j */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( coeffj , "\0" ); - sscanf ( TABLEAU[0] , "%s" , coeffj ); - - /*-------------------------------------------------------*/ - /* Lecture aj */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( aj , "\0" ); - sscanf ( TABLEAU[0] , "%s" , aj ); - - /*-------------------------------------------------------*/ - /* Lecture bj */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( bj , "\0" ); - sscanf ( TABLEAU[0] , "%s" , bj ); - - /*-------------------------------------------------------*/ - /* Lecture cj */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( cj , "\0" ); - sscanf ( TABLEAU[0] , "%s" , cj ); - - /*-------------------------------------------------------*/ - /* Lecture coeff_a */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( coeff_a , "\0" ); - sscanf ( TABLEAU[0] , "%s" , coeff_a ); - - /*-------------------------------------------------------*/ - /* Lecture aa */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( aa , "\0" ); - sscanf ( TABLEAU[0] , "%s" , aa ); - - /*-------------------------------------------------------*/ - /* Lecture ba */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( ba , "\0" ); - sscanf ( TABLEAU[0] , "%s" , ba ); - - /*-------------------------------------------------------*/ - /* Lecture ca */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( ca , "\0" ); - sscanf ( TABLEAU[0] , "%s" , ca ); - - /*-------------------------------------------------------*/ - /* Lecture da */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( da , "\0" ); - sscanf ( TABLEAU[0] , "%s" , da ); - - /*-------------------------------------------------------*/ - /* Lecture coeff_b */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( coeff_b , "\0" ); - sscanf ( TABLEAU[0] , "%s" , coeff_b ); - - /*-------------------------------------------------------*/ - /* Lecture ab */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( ab , "\0" ); - sscanf ( TABLEAU[0] , "%s" , ab ); - - /*-------------------------------------------------------*/ - /* Lecture bb */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( bb , "\0" ); - sscanf ( TABLEAU[0] , "%s" , bb ); - - /*-------------------------------------------------------*/ - /* Lecture cb */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( cb , "\0" ); - sscanf ( TABLEAU[0] , "%s" , cb ); - - /*-------------------------------------------------------*/ - /* Lecture db */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( db , "\0" ); - sscanf ( TABLEAU[0] , "%s" , db ); - - /*-------------------------------------------------------*/ - /* Lecture eb */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( eb , "\0" ); - sscanf ( TABLEAU[0] , "%s" , eb ); - - /*------------------------------------------------------*/ - /* Saut de 16 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 16 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*-------------------------------------------------------*/ - /* Lecture coeff_l */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( coeff_l , "\0" ); - sscanf ( TABLEAU[0] , "%s" , coeff_l ); - /*-------------------------------------------------------*/ - /* Lecture a_l */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( a_l , "\0" ); - sscanf ( TABLEAU[0] , "%s" , a_l ); - - /*-------------------------------------------------------*/ - /* Lecture b_l */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( b_l , "\0" ); - sscanf ( TABLEAU[0] , "%s" , b_l ); - - /*-------------------------------------------------------*/ - /* Lecture c_l */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( c_l , "\0" ); - sscanf ( TABLEAU[0] , "%s" , c_l ); - - /*-------------------------------------------------------*/ - /* Lecture d_l */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( d_l , "\0" ); - sscanf ( TABLEAU[0] , "%s" , d_l ); - - /*-------------------------------------------------------*/ - /* Lecture e_l */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( e_l , "\0" ); - sscanf ( TABLEAU[0] , "%s" , e_l ); - - /*-------------------------------------------------------*/ - /* Lecture coeff_p */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( coeff_p , "\0" ); - sscanf ( TABLEAU[0] , "%s" , coeff_p ); - - /*-------------------------------------------------------*/ - /* Lecture a_p */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( a_p , "\0" ); - sscanf ( TABLEAU[0] , "%s" , a_p ); - - /*-------------------------------------------------------*/ - /* Lecture b_p */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( b_p , "\0" ); - sscanf ( TABLEAU[0] , "%s" , b_p ); - - /*-------------------------------------------------------*/ - /* Lecture c_p */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( c_p , "\0" ); - sscanf ( TABLEAU[0] , "%s" , c_p ); - - /*------------------------------------------------------*/ - /* Saut de 16 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 16 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*-------------------------------------------------------*/ - /* Lecture alswir */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( alswir , "\0" ); - sscanf ( TABLEAU[0] , "%s" , alswir ); - - /*-------------------------------------------------------*/ - /* Lecture blswir */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - ; - sprintf ( blswir , "\0" ); - sscanf ( TABLEAU[0] , "%s" , blswir ); - - /*-------------------------------------------------------*/ - /* Lecture clswir */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( clswir , "\0" ); - sscanf ( TABLEAU[0] , "%s" , clswir ); - - /*-------------------------------------------------------*/ - /* Lecture apswir */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - sprintf ( apswir , "\0" ); - sscanf ( TABLEAU[0] , "%s" , apswir ); - - /*-------------------------------------------------------*/ - /* Lecture bpswir */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( bpswir , "\0" ); - sscanf ( TABLEAU[0] , "%s" , bpswir ); - - /*-------------------------------------------------------*/ - /* Lecture cpswir */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( cpswir , "\0" ); - sscanf ( TABLEAU[0] , "%s" , cpswir ); - - /*------------------------------------------------------*/ - /* Saut de 16 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 16 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*------------------------------------------------------*/ - /* lecture de reverse simplified location model */ - /*------------------------------------------------------*/ - - /*-------------------------------------------------------*/ - /* Lecture coeff rlma */ - /*-------------------------------------------------------*/ - - - TABLEAU[0][0]='\0'; - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - strcpy ( rlma , "\0" ); - sscanf ( TABLEAU[0] , "%s" , rlma ); - - /*-------------------------------------------------------*/ - /* Lecture coeff rlmb */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - strcpy ( rlmb , "\0" ); - sscanf ( TABLEAU[0] , "%s" , rlmb ); - - /*-------------------------------------------------------*/ - /* Lecture coeff rlmc */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - strcpy ( rlmc , "\0" ); - sscanf ( TABLEAU[0] , "%s" , rlmc); - - /*-------------------------------------------------------*/ - /* Lecture coeff rlmd */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - strcpy ( rlmd , "\0" ); - sscanf ( TABLEAU[0] , "%s" , rlmd ); - - /*-------------------------------------------------------*/ - /* Lecture coeff rlme */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - strcpy ( rlme , "\0" ); - sscanf ( TABLEAU[0] , "%s" , rlme ); - - /*-------------------------------------------------------*/ - /* Lecture coeff rlmf */ - /*-------------------------------------------------------*/ - - TABLEAU[0][0]='\0'; - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - strcpy ( rlmf , "\0" ); - sscanf ( TABLEAU[0] , "%s" , rlmf ); - - /*-------------------------------------------------------*/ - /* Lecture coeff rlmap */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - strcpy ( rlmap , "\0" ); - sscanf ( TABLEAU[0] , "%s" , rlmap ); - - /*-------------------------------------------------------*/ - /* Lecture coeff rlmbp */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - strcpy ( rlmbp , "\0" ); - sscanf ( TABLEAU[0] , "%s" , rlmbp ); - - /*-------------------------------------------------------*/ - /* Lecture coeff rlmcp */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( rlmcp , "\0" ); - sscanf ( TABLEAU[0] , "%s" , rlmcp ); - - /*-------------------------------------------------------*/ - /* Lecture coeff rlmdp */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( rlmdp , "\0" ); - sscanf ( TABLEAU[0] , "%s" , rlmdp ); - - /*-------------------------------------------------------*/ - /* Lecture coeff rlmep */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( rlmep , "\0" ); - sscanf ( TABLEAU[0] , "%s" , rlmep ); - - /*-------------------------------------------------------*/ - /* Lecture coeff rlmfp */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( rlmfp , "\0" ); - sscanf ( TABLEAU[0] , "%s" , rlmfp ); - - /*------------------------------------------------------*/ - /* Saut de 2792 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 2792 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /********************************************************/ - /* LEADER GROUND CONTROL POINT RECORD */ - /********************************************************/ - - /*------------------------------------------------------*/ - /* Saut de 3960 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 3960 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /********************************************************/ - /* LEADER HISTOGRAM RECORD */ - /********************************************************/ - - for ( j = 0; j < nb_bs ; j++ ) - { - - /*------------------------------------------------------*/ - /* Saut de 2470 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 2470 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*-------------------------------------------------------*/ - /* Lecture lowthresh */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 8 ); - - if ( cr_read != 8 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][8] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 8 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( lowtresh[j] , "\0" ); - sscanf ( TABLEAU[0] , "%s" , lowtresh[j] ); - - /*-------------------------------------------------------*/ - /* Lecture upthresh */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 8 ); - - if ( cr_read != 8 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][8] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 8 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( uptresh[j] , "\0" ); - sscanf ( TABLEAU[0] , "%s" , uptresh[j] ); - - /*-------------------------------------------------------*/ - /* Lecture firstwavelength */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 8 ); - - if ( cr_read != 8 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][8] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 8 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - unwave =0.0; - - sscanf ( TABLEAU[0] , "%lf" , &unwave ); - sprintf ( firstwave[j] , "%.12lf" , unwave * 0.000001 ); - - /*-------------------------------------------------------*/ - /* Lecture wavelengthstep */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 4 ); - - if ( cr_read != 4 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][4] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 4 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - wavelong=0.0; - sscanf ( TABLEAU[0] , "%lf" , &wavelong ); - sprintf ( wavelengthstep[j] , "%.12lf" , wavelong * 0.000000001 ); - - /*-------------------------------------------------------*/ - /* Lecture des 64 coefficients */ - /*-------------------------------------------------------*/ - - for ( ind_tab_gain = 0 ; ind_tab_gain < 64 ; ind_tab_gain++ ) - { - cr_read = read ( desc_lead, TABLEAU[0], 5 ); - - if ( cr_read != 5 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][5] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 5 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( spectral_sensitivitie[j][ind_tab_gain] , "\0" ); - sscanf ( TABLEAU[0] , "%s" , spectral_sensitivitie[j][ind_tab_gain] ); - } - - /*-------------------------------------------------------*/ - /* Lecture solar_irradiance */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_lead, TABLEAU[0], 4 ); - - if ( cr_read != 4 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][4] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 4 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( solar_irradiance[j] , "\0" ); - sscanf ( TABLEAU[0] , "%s" , solar_irradiance[j] ); - - /*------------------------------------------------------*/ - /* Saut de 1138 octets */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_lead , 1138 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Leader octet %ld" , cr_lseek ); - goto ERREUR; - } - } - - /********************************************************/ - /* LECTURE DU FICHIER VOLUME DIRECTORY */ - /********************************************************/ - - /*------------------------------------------------------*/ - /* Retour au debut du fichier */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_vol , 0L , 0 ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Volume Directory octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*------------------------------------------------------*/ - /* Saut de 60 octects */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_vol , 60 , SEEK_SET ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Volume Directory octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*-------------------------------------------------------*/ - /* Lecture job_id */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_vol, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Volume Directory octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - sprintf ( job_id , "\0" ); - strcpy ( job_id , TABLEAU[0] ); - - /*-------------------------------------------------------*/ - /* Lecture product_type */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_vol, TABLEAU[0], 16 ); - - if ( cr_read != 16 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Volume Directory octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][16] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 16 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - sprintf( product_type, "\0" ); - strcpy ( product_type , TABLEAU[0] ); - - /*------------------------------------------------------*/ - /* Saut de 20 octects */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_vol , 20 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Volume Directory octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*-------------------------------------------------------*/ - /* Lecture product_date */ - /*-------------------------------------------------------*/ - - /*-------------------------------------------------------*/ - /* Lecture product_annee */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_vol, TABLEAU[0], 4 ); - - if ( cr_read != 4 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Volume Directory octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][4] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 4 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - product_annee=0; - sscanf ( TABLEAU[0] , "%d" , &product_annee ); - - /*-------------------------------------------------------*/ - /* Lecture product_mois */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_vol, TABLEAU[0], 2 ); - - if ( cr_read != 2 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Volume Directory octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][2] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 2 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - product_mois=0; - sscanf ( TABLEAU[0] , "%d" , &product_mois ); - - /*-------------------------------------------------------*/ - /* Lecture product_jour */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_vol, TABLEAU[0], 2 ); - - if ( cr_read != 2 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Volume Directory octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][2] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 2 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - product_jour=0; - sscanf ( TABLEAU[0] , "%d" , &product_jour ); - - /*-------------------------------------------------------*/ - /* Lecture product_heure */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_vol, TABLEAU[0], 2 ); - - if ( cr_read != 2 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Volume Directory octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][2] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 2 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - product_heure =0; - sscanf ( TABLEAU[0] , "%d" , &product_heure ); - - /*-------------------------------------------------------*/ - /* Lecture product_min */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_vol, TABLEAU[0], 2 ); - - if ( cr_read != 2 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Volume Directory octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][2] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 2 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - product_min=0; - sscanf ( TABLEAU[0] , "%d" , &product_min ); - - /*-------------------------------------------------------*/ - /* Lecture product_sec */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_vol, TABLEAU[0], 2 ); - - if ( cr_read != 2 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Volume Directory octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][2] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 2 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - product_sec=0; - sscanf ( TABLEAU[0] , "%d" , &product_sec ); - - /*------------------------------------------------------*/ - /* Saut de 2 octects */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_vol , 2 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Volume Directory octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*-------------------------------------------------------*/ - /* Lecture produser */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_vol, TABLEAU[0], 12 ); - - if ( cr_read != 12 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Volume Directory octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][12] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 12 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( produser , "\0" ); - strcpy ( produser , TABLEAU[0] ); - - /*-------------------------------------------------------*/ - /* Lecture processing_center */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_vol, TABLEAU[0], 8 ); - - if ( cr_read != 8 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Volume Directory octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][8] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 8 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( processing_center , "\0" ); - strcpy ( processing_center , TABLEAU[0] ); - - /*-------------------------------------------------------*/ - /* Lecture software_name */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_vol, TABLEAU[0], 12 ); - - if ( cr_read != 12 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Volume Directory octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][12] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 12 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( software_name , "\0" ); - strcpy ( software_name , TABLEAU[0] ); - - /*------------------------------------------------------*/ - /* Saut de 1296 octects */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_vol , 1296 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Volume Directory octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*-------------------------------------------------------*/ - /* Lecture source_description */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_vol, TABLEAU[0], 104 ); - - if ( cr_read != 104 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Volume Directory octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][104] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 104 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - sprintf ( source_description , "\0" ); - strcpy ( source_description , TABLEAU[0] ); - - /*------------------------------------------------------*/ - /* Saut de 18 octects */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_vol , 18 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Volume Directory octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*-------------------------------------------------------*/ - /* Lecture copyright */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_vol, TABLEAU[0], 14 ); - - if ( cr_read != 14 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Volume Directory octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][14] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 14 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - strcpy ( copyright , TABLEAU[0] ); - - /*------------------------------------------------------*/ - /* Saut de 2 octects */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_vol , 2 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Volume Directory octet %ld" , cr_lseek ); - goto ERREUR; - } - - cr_read = read ( desc_vol, TABLEAU[0], 12 ); - - if ( cr_read != 12 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Volume Directory octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][12] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 12 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - strcat ( copyright , TABLEAU[0] ); - - /*------------------------------------------------------*/ - /* Saut de 2 octects */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_vol , 2 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Volume Directory octet %ld" , cr_lseek ); - goto ERREUR; - } - - cr_read = read ( desc_vol, TABLEAU[0], 10 ); - - if ( cr_read != 10 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Volume Directory octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][10] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 10 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - strcat ( copyright , TABLEAU[0] ); - - /********************************************************/ - /* LECTURE DU FICHIER IMAGERY */ - /********************************************************/ - - /*------------------------------------------------------*/ - /* Retour au debut du fichier */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_img , 0L , 0 ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Imagery octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*------------------------------------------------------*/ - /* Saut de 186 octects */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_img , 186 , SEEK_SET ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Imagery octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*-------------------------------------------------------*/ - /* Lecture longueur enregistrement */ - /*-------------------------------------------------------*/ - - cr_read = read ( desc_img, TABLEAU[0], 6 ); - - if ( cr_read != 6 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Imagery octet %ld" , cr_lseek ); - goto ERREUR; - } - - TABLEAU[0][6] = '\0'; - - /* Pour ne pas lire les char suivants */ - /* On met un masque sur le 8ieme bit de chaque octet : */ - - for ( i = 0 ; i < 6 ; i++ ) - { - TABLEAU[0][i] = TABLEAU[0][i] & 0177; - } - - lg_enreg = 0; - sscanf ( TABLEAU[0] , "%d" , &lg_enreg ); - - /*------------------------------------------------------*/ - /* Retour au debut du fichier */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_img , 0L , SEEK_SET ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Imagery octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*------------------------------------------------------*/ - /* Saut de lg_enreg octects */ - /*------------------------------------------------------*/ - - cr_lseek = lseek ( desc_img , (long) lg_enreg , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Imagery octet %ld" , cr_lseek ); - goto ERREUR; - } - - for ( j = 0; j < nb_lig ; j++ ) - { - for ( can = 0 ; can < nb_bs ; can++ ) - { - /*---------------------------------------------------*/ - /* Saut de lg_enreg octects */ - /*---------------------------------------------------*/ - cr_lseek = lseek ( desc_img , (long) ( lg_enreg - 69 ), SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Imagery octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*----------------------------------------------------*/ - /* Lecture loss flag */ - /*----------------------------------------------------*/ - - cr_read = read ( desc_img , &bad_line[j][can] , 1 ); - - if ( cr_read != 1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Imagery octet %ld" , cr_lseek ); - goto ERREUR; - } - - /*---------------------------------------------------*/ - /* Saut de 68 octects */ - /*---------------------------------------------------*/ - - cr_lseek = lseek ( desc_img , 68 , SEEK_CUR ); - - if ( cr_lseek == -1 ) - { - sprintf ( CAI_ERREUR , "Erreur Lecture du fichier Imagery octet %ld" , cr_lseek ); - goto ERREUR; - } - } - } - - /********************************************************/ - /* OUVERTURE DU FICHIER XML PRODUIT */ - /********************************************************/ - - if ( ( des = fopen ( chemin_descripteur , "wb" ) ) == NULL ) - { - sprintf ( CAI_ERREUR , "Erreur Ouverture du fichier XML" ); - goto ERREUR; - } - - /********************************************************/ - /* ECRITURE DES DONNEES XML DANS LE FICHIER */ - /********************************************************/ - - /* Entete du document XML */ - - cr = cai_WriteEnteteXML ( des ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur Ecriture du fichier XML" ); - goto ERREUR; - } - - /* Element Dimap_document */ - - cr = cai_WriteOpenTagXML ( des , "Dimap_Document" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Dimap_Document" ); - goto ERREUR; - } - - /* Sous element Metadata_Id */ - - cr = cai_WriteOpenTagXML ( des , "Metadata_Id" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Metadata_Id" ); - goto ERREUR; - } - - /* sous element METADATA_FORMAT */ - /*****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Version DIMAP passe de 2.0 à 2.9 */ -/*****************************************************************************/ - type=0; - cr = cai_WriteElementXMLWithAttribute ( des , "METADATA_FORMAT" , "DIMAP" , - "version" , "2.9" ,type); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element METADATA_FORMAT" ); - goto ERREUR; - } - - /* sous element METADATA_PROFILE */ - - profile = (char*) NULL; - profile = (char*) calloc ( strlen ( niv_trait ) + 11 , sizeof (char) ); - - sprintf ( profile , "SPOTSCENE_%s" , niv_trait ); - - cr = cai_WriteElementXML ( des , "METADATA_PROFILE" , profile ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element METADATA_PROFILE" ); - goto ERREUR; - } - - FREE ( profile ); - - /* Fermeture de l'element Metadata_Id */ - - cr = cai_WriteCloseTagXML ( des , "Metadata_Id" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Metadata_Id" ); - goto ERREUR; - } - - /* Sous element Dataset_Id */ - - cr = cai_WriteOpenTagXML ( des , "Dataset_Id" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Dataset_Id" ); - goto ERREUR; - } - - /* sous element DATASET_NAME */ - - cr = cai_WriteElementXML ( des , "DATASET_NAME" , datasetname_centre ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element DATASET_NAME" ); - goto ERREUR; - } - - /* sous element COPYRIGHT */ - - cr = cai_WriteElementXML ( des , "COPYRIGHT" , copyright ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element COPYRIGHT" ); - goto ERREUR; - } - -/****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'attribut href="" */ -/****************************************************************************/ - - /* sous element DATASET_TN_PATH */ - type=1; - cr = cai_WriteElementXMLWithAttribute ( des , "DATASET_TN_PATH" , "" , "href" , "" ,type); - - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element DATASET_TN_PATH" ); - goto ERREUR; - } - - /* sous element DATASET_TN_FORMAT */ - - cr = cai_WriteElementXML ( des , "DATASET_TN_FORMAT" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element DATASET_TN_FORMAT" ); - goto ERREUR; - } - - /* sous element DATASET_QL_PATH */ - type=1; - cr = cai_WriteElementXMLWithAttribute ( des , "DATASET_QL_PATH" , "" , "href" , "",type ); - - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element DATASET_QL_PATH" ); - goto ERREUR; - } - - /* sous element DATASET_QL_FORMAT */ - - cr = cai_WriteElementXML ( des , "DATASET_QL_FORMAT" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element DATASET_QL_FORMAT" ); - goto ERREUR; - } - - /* Fermeture de l'element Dataset_Id */ - - cr = cai_WriteCloseTagXML ( des , "Dataset_Id" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Dataset_Id" ); - goto ERREUR; - } - - /* Sous element Dataset_Frame */ - - cr = cai_WriteOpenTagXML ( des , "Dataset_Frame" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Dataset_Frame" ); - goto ERREUR; - } - - /* sous element Vertex */ - - cr = cai_WriteOpenTagXML ( des , "Vertex" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Vertex" ); - goto ERREUR; - } - - /* sous element FRAME_LON */ - - sprintf ( valeur , "%lf" , lon_no ); - - cr = cai_WriteElementXML ( des , "FRAME_LON" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element FRAME_LON" ); - goto ERREUR; - } - - /* sous element FRAME_LAT */ - - sprintf ( valeur , "%lf" , lat_no ); - - cr = cai_WriteElementXML ( des , "FRAME_LAT" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element FRAME_LAT" ); - goto ERREUR; - } -/*****************************************************************************/ -/* MOD : VERSION : 4.8 : FA : Enlever le signe + pour FRAME_ROW, FRAME_COL */ -/*****************************************************************************/ -/* Coin NO */ -/***********/ - /* sous element FRAME_ROW */ - sscanf ( ligc1 , "%d" ,&ivaleur ); - sprintf(Valeur,"%d",ivaleur); - - cr = cai_WriteElementXML ( des , "FRAME_ROW" , Valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element FRAME_ROW" ); - goto ERREUR; - } - /* sous element FRAME_COL */ - sscanf ( colc1 , "%d" ,&ivaleur ); - sprintf(Valeur,"%d",ivaleur); - - cr = cai_WriteElementXML ( des , "FRAME_COL" , Valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element FRAME_COL" ); - goto ERREUR; - } - - /* Fermeture de l'element Vertex */ - - cr = cai_WriteCloseTagXML ( des , "Vertex" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Vertex" ); - goto ERREUR; - } - - /* sous element Vertex */ - - cr = cai_WriteOpenTagXML ( des , "Vertex" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Vertex" ); - goto ERREUR; - } - - /* sous element FRAME_LON */ - - sprintf ( valeur , "%f" , lon_ne ); - - cr = cai_WriteElementXML ( des , "FRAME_LON" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element FRAME_LON" ); - goto ERREUR; - } - - /* sous element FRAME_LAT */ - - sprintf ( valeur , "%f" , lat_ne ); - - cr = cai_WriteElementXML ( des , "FRAME_LAT" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element FRAME_LAT" ); - goto ERREUR; - } - /*****************************************************************************/ -/* MOD : VERSION : 4.8 : FA : Enlever le signe + pour FRAME_ROW, FRAME_COL */ -/*****************************************************************************/ -/* Coin NE */ -/***********/ - /* sous element FRAME_ROW */ - sscanf ( ligc2 , "%d" ,&ivaleur ); - sprintf(Valeur,"%d",ivaleur); - - cr = cai_WriteElementXML ( des , "FRAME_ROW" , Valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element FRAME_ROW" ); - goto ERREUR; - } - /* sous element FRAME_COL */ - sscanf ( colc2 , "%d" ,&ivaleur ); - sprintf(Valeur,"%d",ivaleur); - - cr = cai_WriteElementXML ( des , "FRAME_COL" , Valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element FRAME_COL" ); - goto ERREUR; - } - - /* Fermeture de l'element Vertex */ - - cr = cai_WriteCloseTagXML ( des , "Vertex" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Vertex" ); - goto ERREUR; - } - -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : FA : DIMAP dans le DATASET_FRAME, inversion des deux*/ -/* derniers vertex : à mettre dans l'ordre */ -/* NO,NE,SE,SO : inversion de c3 et c4 */ -/*****************************************************************************/ -/* Coin SE */ -/***********/ -/* sous element Vertex */ - - cr = cai_WriteOpenTagXML ( des , "Vertex" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Vertex" ); - goto ERREUR; - } - - /* sous element FRAME_LON */ - - sprintf ( valeur , "%lf" , lon_se ); - - cr = cai_WriteElementXML ( des , "FRAME_LON" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element FRAME_LON" ); - goto ERREUR; - } - - /* sous element FRAME_LAT */ - - sprintf ( valeur , "%lf" , lat_se ); - - cr = cai_WriteElementXML ( des , "FRAME_LAT" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element FRAME_LAT" ); - goto ERREUR; - } -/*****************************************************************************/ -/* MOD : VERSION : 4.8 : FA : Enlever le signe + pour FRAME_ROW, FRAME_COL */ -/*****************************************************************************/ - - /* sous element FRAME_ROW */ - sscanf ( ligc4 , "%d" ,&ivaleur ); - sprintf(Valeur,"%d",ivaleur); - - cr = cai_WriteElementXML ( des , "FRAME_ROW" , Valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element FRAME_ROW" ); - goto ERREUR; - } - /* sous element FRAME_COL */ - sscanf ( colc4 , "%d" ,&ivaleur ); - sprintf(Valeur,"%d",ivaleur); - - cr = cai_WriteElementXML ( des , "FRAME_COL" , Valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element FRAME_COL" ); - goto ERREUR; - } - - /* Fermeture de l'element Vertex */ - - cr = cai_WriteCloseTagXML ( des , "Vertex" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Vertex" ); - goto ERREUR; - } -/***********/ -/* Coin SO */ -/***********/ - /* sous element Vertex */ - - cr = cai_WriteOpenTagXML ( des , "Vertex" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Vertex" ); - goto ERREUR; - } - - /* sous element FRAME_LON */ - - sprintf ( valeur , "%lf" , lon_so ); - - cr = cai_WriteElementXML ( des , "FRAME_LON" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element FRAME_LON" ); - goto ERREUR; - } - - /* sous element FRAME_LAT */ - - sprintf ( valeur , "%lf" , lat_so ); - - cr = cai_WriteElementXML ( des , "FRAME_LAT" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element FRAME_LAT" ); - goto ERREUR; - } - -/*****************************************************************************/ -/* MOD : VERSION : 4.8 : FA : Enlever le signe + pour FRAME_ROW, FRAME_COL */ -/*****************************************************************************/ -/* sous element FRAME_ROW */ - sscanf ( ligc3 , "%d" ,&ivaleur ); - sprintf(Valeur,"%d",ivaleur); - - cr = cai_WriteElementXML ( des , "FRAME_ROW" , Valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element FRAME_ROW" ); - goto ERREUR; - } - /* sous element FRAME_COL */ - sscanf ( colc3 , "%d" ,&ivaleur ); - sprintf(Valeur,"%d",ivaleur); - - cr = cai_WriteElementXML ( des , "FRAME_COL" , Valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element FRAME_COL" ); - goto ERREUR; - } - - /* Fermeture de l'element Vertex */ - - cr = cai_WriteCloseTagXML ( des , "Vertex" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Vertex" ); - goto ERREUR; - } - - /* sous element Scene_Center */ - - cr = cai_WriteOpenTagXML ( des , "Scene_Center" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Scene_Center" ); - goto ERREUR; - } - - /* sous element FRAME_LON */ - - sprintf ( valeur , "%lf" , lon_c ); - cr = cai_WriteElementXML ( des , "FRAME_LON" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element FRAME_LON" ); - goto ERREUR; - } - /* sous element FRAME_LAT */ - - sprintf ( valeur , "%lf" , lat_c ); - - cr = cai_WriteElementXML ( des , "FRAME_LAT" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element FRAME_LAT" ); - goto ERREUR; - } - /* sous element FRAME_ROW */ - - sprintf ( valeur , "%d" , nbc_c ); - cr = cai_WriteElementXML ( des , "FRAME_ROW" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element FRAME_ROW" ); - goto ERREUR; - } - - /* sous element FRAME_COL */ - - sprintf ( valeur , "%d" , nbl_c ); - cr = cai_WriteElementXML ( des , "FRAME_COL" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element FRAME_COL" ); - goto ERREUR; - } - - /* Fermeture de l'element Scene_Center */ - - cr = cai_WriteCloseTagXML ( des , "Scene_Center" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Scene_Center" ); - goto ERREUR; - } - - /* sous element SCENE_ORIENTATION */ - - cr = cai_WriteElementXML ( des , "SCENE_ORIENTATION" , angle_o ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SCENE_ORIENTATION" ); - goto ERREUR; - } - - /* Fermeture de l'element Dataset_Frame */ - - cr = cai_WriteCloseTagXML ( des , "Dataset_Frame" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Dataset_Frame" ); - goto ERREUR; - } - - /* sous element Dataset_Sources */ - - cr = cai_WriteOpenTagXML ( des , "Dataset_Sources" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Dataset_Sources" ); - goto ERREUR; - } - - /* sous element Source_Information */ - - cr = cai_WriteOpenTagXML ( des , "Source_Information" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Source_Information" ); - goto ERREUR; - } - - /* sous element SOURCE_TYPE */ - - cr = cai_WriteElementXML ( des , "SOURCE_TYPE" , "SCENE" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SOURCE_TYPE" ); - goto ERREUR; - } - - /* sous element SOURCE_ID */ - - cr = cai_WriteElementXML ( des , "SOURCE_ID" , dsetname_centre ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SOURCE_ID" ); - goto ERREUR; - } - - /* sous element SOURCE_DESCRIPTION */ - - cr = cai_WriteElementXML ( des , "SOURCE_DESCRIPTION" , source_description ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SOURCE_DESCRIPTION" ); - goto ERREUR; - } - - /* sous element Scene_Source */ - - cr = cai_WriteOpenTagXML ( des , "Scene_Source" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Scene_Source" ); - goto ERREUR; - } - - /* sous element GRID_REFERENCE */ - - cr = cai_WriteElementXML ( des , "GRID_REFERENCE" , grille_ref ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element GRID_REFERENCE" ); - goto ERREUR; - } - - /* sous element SHIFT_VALUE */ - - cr = cai_WriteElementXML ( des , "SHIFT_VALUE" , shift_val ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SHIFT_VALUE" ); - goto ERREUR; - } - - /* sous element IMAGING_DATE */ - - cr = cai_WriteElementXML ( des , "IMAGING_DATE" , date ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element IMAGING_DATE" ); - goto ERREUR; - } - - /* sous element IMAGING_TIME */ - - cr = cai_WriteElementXML ( des , "IMAGING_TIME" , heure ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element IMAGING_TIME" ); - goto ERREUR; - } - - /* sous element MISSION */ - - cr = cai_WriteElementXML ( des , "MISSION" , satellite ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element MISSION" ); - goto ERREUR; - } - - /* sous element MISSION_INDEX */ - - sprintf ( sat_ind , "%d" , satellite_index ); - - cr = cai_WriteElementXML ( des , "MISSION_INDEX" , sat_ind ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element MISSION_INDEX" ); - goto ERREUR; - } - - /* sous element INSTRUMENT */ - - cr = cai_WriteElementXML ( des , "INSTRUMENT" , instrument ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element INSTRUMENT" ); - goto ERREUR; - } - - /* sous element INSTRUMENT_INDEX */ - - sprintf ( ins_ind , "%d" , instrument_index ); - - cr = cai_WriteElementXML ( des , "INSTRUMENT_INDEX" , ins_ind ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element INSTRUMENT_INDEX" ); - goto ERREUR; - } - - /* sous element SENSOR_CODE */ - - sprintf ( valeur , "%c" , codecapt ); - cr = cai_WriteElementXML ( des , "SENSOR_CODE" , valeur ); - - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SENSOR_CODE" ); - goto ERREUR; - } - - /* sous element SCENE_PROCESSING_LEVEL */ - - cr = cai_WriteElementXML ( des , "SCENE_PROCESSING_LEVEL" , niv_trait ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SCENE_PROCESSING_LEVEL" ); - goto ERREUR; - } - - /* sous element INCIDENCE_ANGLE */ - - if ( angle_in[0] == 'L' ) - { - sprintf ( valeur , "-%s" , &angle_in[1] ); - } - else if (angle_in[0] != '\0') - { - sprintf ( valeur , "%s" , &angle_in[1] ); - } - else - sprintf(valeur, "\0"); - - cr = cai_WriteElementXML ( des , "INCIDENCE_ANGLE" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element INCIDENCE_ANGLE" ); - goto ERREUR; - } - - /* sous element SUN_AZIMUT */ - - cr = cai_WriteElementXML ( des , "SUN_AZIMUTH" , sunazim ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SUN_AZIMUT" ); - goto ERREUR; - } - - /* sous element SUN_ELEVATION */ - - cr = cai_WriteElementXML ( des , "SUN_ELEVATION" , sunelev ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SUN_ELEVATION" ); - goto ERREUR; - } - - /* sous element Imaging_Parameters */ - - cr = cai_WriteOpenTagXML ( des , "Imaging_Parameters" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Imaging_Parameters" ); - goto ERREUR; - } - - /* sous element REVOLUTION_NUMBER */ - - cr = cai_WriteElementXML ( des , "REVOLUTION_NUMBER" , revolution ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element REVOLUTION_NUMBER" ); - goto ERREUR; - } - - /* sous element COMPRESSION_MODE */ - - cr = cai_WriteElementXML ( des , "COMPRESSION_MODE" , compression ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element COMPRESSION_MODE" ); - goto ERREUR; - } - - /* sous element DIRECT_PLAYBACK_INDICATOR */ - - cr = cai_WriteElementXML ( des , "DIRECT_PLAYBACK_INDICATOR" , direct_playback ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element DIRECT_PLAYBACK_INDICATOR" ); - goto ERREUR; - } - - /* sous element REFOCUSING_STEP_NUM */ - - cr = cai_WriteElementXML ( des , "REFOCUSING_STEP_NUM" , stepnum ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element REFOCUSING_STEP_NUM" ); - goto ERREUR; - } - - /* sous element COUPLED_MODE_FLAG */ - - cr = cai_WriteElementXML ( des , "COUPLED_MODE_FLAG" , coupled ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element COUPLED_MODE_FLAG" ); - goto ERREUR; - } - - /* sous element SWATH_MODE */ - - cr = cai_WriteElementXML ( des , "SWATH_MODE" , "FULL" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SWATH_MODE" ); - goto ERREUR; - } - - /* Fermeture de l'element Imaging_Parameters */ - - cr = cai_WriteCloseTagXML ( des , "Imaging_Parameters" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Imaging_Parameters" ); - goto ERREUR; - } - - /* Fermeture de l'element Scene_Source */ - - cr = cai_WriteCloseTagXML ( des , "Scene_Source" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Scene_Source" ); - goto ERREUR; - } - - /* Fermeture de l'element Source_Information */ - - cr = cai_WriteCloseTagXML ( des , "Source_Information" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Source_Information" ); - goto ERREUR; - } - - /* Fermeture de l'element Dataset_Sources */ - - cr = cai_WriteCloseTagXML ( des , "Dataset_Sources" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Dataset_Sources" ); - goto ERREUR; - } - - /* sous element Coordinate_Reference_System */ - - cr = cai_WriteOpenTagXML ( des , "Coordinate_Reference_System" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Coordinate_Reference_System" ); - goto ERREUR; - } - -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'attribut version="5.2" */ -/*****************************************************************************/ - - /* sous element GEO_TABLES */ - type=0; - cr = cai_WriteElementXMLWithAttribute ( des , "GEO_TABLES" , "EPSG" , "version" , "5.2",type ); - - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element GEO_TABLES" ); - goto ERREUR; - } - - /* sous element Horizontal_CS */ - - cr = cai_WriteOpenTagXML ( des , "Horizontal_CS" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Horizontal_CS" ); - goto ERREUR; - } - - /* sous element HORIZONTAL_CS_TYPE */ - - cr = cai_WriteElementXML ( des , "HORIZONTAL_CS_TYPE" , "GEOGRAPHIC" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element HORIZONTAL_CS_TYPE" ); - goto ERREUR; - } -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : DIMAP remplissage des tags HORIZONTAL_CS_CODE */ -/* et HORIZONTAL_CS_NAME avec des valeurs défauts */ -/*****************************************************************************/ - /* sous element HORIZONTAL_CS_CODE */ - - cr = cai_WriteElementXML ( des , "HORIZONTAL_CS_CODE" , "epsg:4326" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element HORIZONTAL_CS_CODE" ); - goto ERREUR; - } - - /* sous element HORIZONTAL_CS_NAME */ - - cr = cai_WriteElementXML ( des , "HORIZONTAL_CS_NAME" , "WGS 84" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element HORIZONTAL_CS_NAME" ); - goto ERREUR; - } - - /* Fermeture de l'element Horizontal_CS */ - - cr = cai_WriteCloseTagXML ( des , "Horizontal_CS" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Horizontal_CS" ); - goto ERREUR; - } - - /* Fermeture de l'element Coordinate_Reference_System */ - - cr = cai_WriteCloseTagXML ( des , "Coordinate_Reference_System" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Coordinate_Reference_System" ); - goto ERREUR; - } - - /* sous element Raster_CS */ - - cr = cai_WriteOpenTagXML ( des , "Raster_CS" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Raster_CS" ); - goto ERREUR; - } - - /* sous element RASTER_CS_TYPE */ - - if ( strncmp ( niv_trait , "2A" , 2 ) ==0 ) - { - cr = cai_WriteElementXML ( des , "RASTER_CS_TYPE" , "CELL" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element RASTER_CS_TYPE" ); - goto ERREUR; - } - } - else - { - cr = cai_WriteElementXML ( des , "RASTER_CS_TYPE" , "POINT" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element RASTER_CS_TYPE" ); - goto ERREUR; - } - } - -/****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element PIXEL_ORIGIN */ -/****************************************************************************/ - - /* sous element PIXEL_ORIGIN */ - - cr = cai_WriteElementXML ( des , "PIXEL_ORIGIN" , "1" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element PIXEL_ORIGIN" ); - goto ERREUR; - } - - - /* Fermeture de l'element Raster_CS */ - - cr = cai_WriteCloseTagXML ( des , "Raster_CS" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Raster_CS" ); - goto ERREUR; - } - - /* sous element Geoposition */ - - cr = cai_WriteOpenTagXML ( des , "Geoposition" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Geoposition" ); - goto ERREUR; - } - - /* sous element Geoposition_Points */ - - cr = cai_WriteOpenTagXML ( des , "Geoposition_Points" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Geoposition_Points" ); - goto ERREUR; - } - - /* sous element Tie_Point */ - - cr = cai_WriteOpenTagXML ( des , "Tie_Point" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Tie_Point" ); - goto ERREUR; - } - - /* sous element TIE_POINTS_CRS_X */ - - sprintf ( valeur , "%lf" , lon_no ); - - cr = cai_WriteElementXML ( des , "TIE_POINTS_CRS_X" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element TIE_POINTS_CRS_X" ); - goto ERREUR; - } - - /* sous element TIE_POINTS_CRS_Y */ - - sprintf ( valeur , "%lf" , lat_no ); - - cr = cai_WriteElementXML ( des , "TIE_POINTS_CRS_Y" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element TIE_POINTS_CRS_Y" ); - goto ERREUR; - } - -/****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element TIE_POINTS_CRS_Z */ -/****************************************************************************/ - - /* sous element TIE_POINTS_CRS_Z */ - - cr = cai_WriteElementXML ( des , "TIE_POINTS_CRS_Z" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element TIE_POINTS_CRS_Z" ); - goto ERREUR; - } - - /* sous element TIE_POINTS_DATA_X */ -/*****************************************************************************/ -/* MOD : VERSION : 4.8 : FA : Enlever le signe + pour TIE_POINTS_DATA_X et */ -/* TIE_POINTS_DATA_Y */ -/*****************************************************************************/ - sscanf ( ligc1 , "%d" ,&ivaleur ); - sprintf(Valeur,"%d",ivaleur); - - cr = cai_WriteElementXML ( des , "TIE_POINTS_DATA_X" , Valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element TIE_POINTS_DATA_X" ); - goto ERREUR; - } - - /* sous element TIE_POINTS_DATA_Y */ - sscanf ( colc1 , "%d" ,&ivaleur ); - sprintf(Valeur,"%d",ivaleur); - - cr = cai_WriteElementXML ( des , "TIE_POINTS_DATA_Y" , Valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element TIE_POINTS_DATA_Y" ); - goto ERREUR; - } - - /* Fermeture de l'element Tie_Point */ - - cr = cai_WriteCloseTagXML ( des , "Tie_Point" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Tie_Point" ); - goto ERREUR; - } - - /* sous element Tie_Point */ - - cr = cai_WriteOpenTagXML ( des , "Tie_Point" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Tie_Point" ); - goto ERREUR; - } - - /* sous element TIE_POINTS_CRS_X */ - - sprintf ( valeur , "%f" , lon_ne ); - - cr = cai_WriteElementXML ( des , "TIE_POINTS_CRS_X" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element TIE_POINTS_CRS_X" ); - goto ERREUR; - } - - /* sous element TIE_POINTS_CRS_Y */ - - sprintf ( valeur , "%f" , lat_ne ); - - cr = cai_WriteElementXML ( des , "TIE_POINTS_CRS_Y" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element TIE_POINTS_CRS_Y" ); - goto ERREUR; - } - -/****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element TIE_POINTS_CRS_Z */ -/****************************************************************************/ - - /* sous element TIE_POINTS_CRS_Z */ - - cr = cai_WriteElementXML ( des , "TIE_POINTS_CRS_Z" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element TIE_POINTS_CRS_Z" ); - goto ERREUR; - } - - -/*****************************************************************************/ -/* MOD : VERSION : 4.8 : FA : Enlever le signe + pour TIE_POINTS_DATA_X et */ -/* TIE_POINTS_DATA_Y */ -/*****************************************************************************/ - sscanf ( ligc2 , "%d" ,&ivaleur ); - sprintf(Valeur,"%d",ivaleur); - - cr = cai_WriteElementXML ( des , "TIE_POINTS_DATA_X" , Valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element TIE_POINTS_DATA_X" ); - goto ERREUR; - } - - /* sous element TIE_POINTS_DATA_Y */ - sscanf ( colc2 , "%d" ,&ivaleur ); - sprintf(Valeur,"%d",ivaleur); - - cr = cai_WriteElementXML ( des , "TIE_POINTS_DATA_Y" , Valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element TIE_POINTS_DATA_Y" ); - goto ERREUR; - } - - /* Fermeture de l'element Tie_Point */ - - cr = cai_WriteCloseTagXML ( des , "Tie_Point" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Tie_Point" ); - goto ERREUR; - } - - /* sous element Tie_Point */ - - cr = cai_WriteOpenTagXML ( des , "Tie_Point" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Tie_Point" ); - goto ERREUR; - } - - /* sous element TIE_POINTS_CRS_X */ - - sprintf ( valeur , "%lf" , lon_so ); - - cr = cai_WriteElementXML ( des , "TIE_POINTS_CRS_X" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element TIE_POINTS_CRS_X" ); - goto ERREUR; - } - - /* sous element TIE_POINTS_CRS_Y */ - - sprintf ( valeur , "%lf" , lat_so ); - - cr = cai_WriteElementXML ( des , "TIE_POINTS_CRS_Y" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element TIE_POINTS_CRS_Y" ); - goto ERREUR; - } - -/****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element TIE_POINTS_CRS_Z */ -/****************************************************************************/ - - /* sous element TIE_POINTS_CRS_Z */ - - cr = cai_WriteElementXML ( des , "TIE_POINTS_CRS_Z" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element TIE_POINTS_CRS_Z" ); - goto ERREUR; - } - - -/*****************************************************************************/ -/* MOD : VERSION : 4.8 : FA : Enlever le signe + pour TIE_POINTS_DATA_X et */ -/* TIE_POINTS_DATA_Y */ -/*****************************************************************************/ - /* sous element TIE_POINTS_DATA_X */ - - sscanf ( ligc3 , "%d" ,&ivaleur ); - sprintf(Valeur,"%d",ivaleur); - - - cr = cai_WriteElementXML ( des , "TIE_POINTS_DATA_X" , Valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element TIE_POINTS_DATA_X" ); - goto ERREUR; - } - - /* sous element TIE_POINTS_DATA_Y */ - sscanf ( colc3 , "%d" ,&ivaleur ); - sprintf(Valeur,"%d",ivaleur); - - cr = cai_WriteElementXML ( des , "TIE_POINTS_DATA_Y" , Valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element TIE_POINTS_DATA_Y" ); - goto ERREUR; - } - - /* Fermeture de l'element Tie_Point */ - - cr = cai_WriteCloseTagXML ( des , "Tie_Point" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Tie_Point" ); - goto ERREUR; - } - - /* sous element Tie_Point */ - - cr = cai_WriteOpenTagXML ( des , "Tie_Point" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Tie_Point" ); - goto ERREUR; - } - - /* sous element TIE_POINTS_CRS_X */ - - sprintf ( valeur , "%lf" , lon_se ); - - cr = cai_WriteElementXML ( des , "TIE_POINTS_CRS_X" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element TIE_POINTS_CRS_X" ); - goto ERREUR; - } - - /* sous element TIE_POINTS_CRS_Y */ - - sprintf ( valeur , "%lf" , lat_se ); - - cr = cai_WriteElementXML ( des , "TIE_POINTS_CRS_Y" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element TIE_POINTS_CRS_Y" ); - goto ERREUR; - } - -/****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element TIE_POINTS_CRS_Z */ -/****************************************************************************/ - - /* sous element TIE_POINTS_CRS_Z */ - - cr = cai_WriteElementXML ( des , "TIE_POINTS_CRS_Z" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element TIE_POINTS_CRS_Z" ); - goto ERREUR; - } - - - /*****************************************************************************/ -/* MOD : VERSION : 4.8 : FA : Enlever le signe + pour TIE_POINTS_DATA_X et */ -/* TIE_POINTS_DATA_Y */ -/*****************************************************************************/ - /* sous element TIE_POINTS_DATA_X */ - - sscanf ( ligc4 , "%d" ,&ivaleur ); - sprintf(Valeur,"%d",ivaleur); - - cr = cai_WriteElementXML ( des , "TIE_POINTS_DATA_X" , Valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element TIE_POINTS_DATA_X" ); - goto ERREUR; - } - - /* sous element TIE_POINTS_DATA_Y */ - sscanf ( colc4 , "%d" ,&ivaleur ); - sprintf(Valeur,"%d",ivaleur); - - cr = cai_WriteElementXML ( des , "TIE_POINTS_DATA_Y" , Valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element TIE_POINTS_DATA_Y" ); - goto ERREUR; - } - - /* Fermeture de l'element Tie_Point */ - - cr = cai_WriteCloseTagXML ( des , "Tie_Point" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Tie_Point" ); - goto ERREUR; - } - - /* Fermeture de l'element Geoposition_Points */ - - cr = cai_WriteCloseTagXML ( des , "Geoposition_Points" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Geoposition_Points" ); - goto ERREUR; - } - -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Deplacement de Simplified_Location_Model */ -/*****************************************************************************/ - - /* sous element Simplified_Location_Model */ - - cr = cai_WriteOpenTagXML ( des , "Simplified_Location_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Simplified_Location_Model" ); - goto ERREUR; - } - - /* sous element Direct_Location_Model */ - - cr = cai_WriteOpenTagXML ( des , "Direct_Location_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Direct_Location_Model" ); - goto ERREUR; - } - - /* sous element lc_List */ - - cr = cai_WriteOpenTagXML ( des , "lc_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element lc_List" ); - goto ERREUR; - } - - /* sous element lc */ - - cr = cai_WriteElementXML ( des , "lc" , coeffa ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element lc" ); - goto ERREUR; - } - - /* sous element lc */ - - cr = cai_WriteElementXML ( des , "lc" , coeffb ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element lc" ); - goto ERREUR; - } - - /* sous element lc */ - - cr = cai_WriteElementXML ( des , "lc" , coeffc ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element lc" ); - goto ERREUR; - } - - /* sous element lc */ - - cr = cai_WriteElementXML ( des , "lc" , coeffd ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element lc" ); - goto ERREUR; - } - - /* sous element lc */ - - cr = cai_WriteElementXML ( des , "lc" , coeffe ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element lc" ); - goto ERREUR; - } - - /* sous element lc */ - - cr = cai_WriteElementXML ( des , "lc" , coefff ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element lc" ); - goto ERREUR; - } - - /* Fermeture de l'element lc_List */ - - cr = cai_WriteCloseTagXML ( des , "lc_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element lc_List" ); - goto ERREUR; - } - - /* sous element pc_List */ - - cr = cai_WriteOpenTagXML ( des , "pc_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element pc_List" ); - goto ERREUR; - } - - /* sous element pc */ - - cr = cai_WriteElementXML ( des , "pc" , coeffap ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element pc" ); - goto ERREUR; - } - - /* sous element pc */ - - cr = cai_WriteElementXML ( des , "pc" , coeffbp ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element pc" ); - goto ERREUR; - } - - /* sous element pc */ - - cr = cai_WriteElementXML ( des , "pc" , coeffcp ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element pc" ); - goto ERREUR; - } - - /* sous element pc */ - - cr = cai_WriteElementXML ( des , "pc" , coeffdp ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element pc" ); - goto ERREUR; - } - - /* sous element pc */ - - cr = cai_WriteElementXML ( des , "pc" , coeffep ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element pc" ); - goto ERREUR; - } - - /* sous element pc */ - - cr = cai_WriteElementXML ( des , "pc" , coefffp ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element pc" ); - goto ERREUR; - } - - /* Fermeture de l'element pc_List */ - - cr = cai_WriteCloseTagXML ( des , "pc_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element pc_List" ); - goto ERREUR; - } - - /* Fermeture de l'element Direct_Location_Model */ - - cr = cai_WriteCloseTagXML ( des , "Direct_Location_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Direct_Location_Model" ); - goto ERREUR; - } - - /* sous element Reverse_Location_Model */ - - cr = cai_WriteOpenTagXML ( des , "Reverse_Location_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Reverse_Location_Model" ); - goto ERREUR; - } - - /* sous element lc_List */ - - cr = cai_WriteOpenTagXML ( des , "lc_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element lc_List" ); - goto ERREUR; - } - - /* sous element lc */ - - cr = cai_WriteElementXML ( des , "lc" , rlma ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element lc" ); - goto ERREUR; - } - - /* sous element lc */ - - cr = cai_WriteElementXML ( des , "lc" , rlmb ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element lc" ); - goto ERREUR; - } - - /* sous element lc */ - - cr = cai_WriteElementXML ( des , "lc" , rlmc ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element lc" ); - goto ERREUR; - } - - /* sous element lc */ - - cr = cai_WriteElementXML ( des , "lc" , rlmd ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element lc" ); - goto ERREUR; - } - - /* sous element lc */ - - cr = cai_WriteElementXML ( des , "lc" , rlme ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element lc" ); - goto ERREUR; - } - - /* sous element lc */ - - cr = cai_WriteElementXML ( des , "lc" , rlmf ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element lc" ); - goto ERREUR; - } - - /* Fermeture de l'element lc_List */ - - cr = cai_WriteCloseTagXML ( des , "lc_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element lc_List" ); - goto ERREUR; - } - - /* sous element pc_List */ - - cr = cai_WriteOpenTagXML ( des , "pc_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element pc_List" ); - goto ERREUR; - } - - /* sous element pc */ - - cr = cai_WriteElementXML ( des , "pc" , rlmap ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element pc" ); - goto ERREUR; - } - - /* sous element pc */ - - cr = cai_WriteElementXML ( des , "pc" , rlmbp ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element pc" ); - goto ERREUR; - } - - /* sous element pc */ - - cr = cai_WriteElementXML ( des , "pc" , rlmcp ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element pc" ); - goto ERREUR; - } - - /* sous element pc */ - - cr = cai_WriteElementXML ( des , "pc" , rlmdp ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element pc" ); - goto ERREUR; - } - - /* sous element pc */ - - cr = cai_WriteElementXML ( des , "pc" , rlmep ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element pc" ); - goto ERREUR; - } - - /* sous element pc */ - - cr = cai_WriteElementXML ( des , "pc" , rlmfp ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element pc" ); - goto ERREUR; - } - - /* Fermeture de l'element pc_List */ - - cr = cai_WriteCloseTagXML ( des , "pc_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element pc_List" ); - goto ERREUR; - } - - /* Fermeture de l'element Reverse_Location_Model */ - - cr = cai_WriteCloseTagXML ( des , "Reverse_Location_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Reverse_Location_Model" ); - goto ERREUR; - } - - /* Fermeture de l'element Simplified_Location_Model */ - - cr = cai_WriteCloseTagXML ( des , "Simplified_Location_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Simplified_Location_Model" ); - goto ERREUR; - } - - /* Fermeture de l'element Geoposition */ - - cr = cai_WriteCloseTagXML ( des , "Geoposition" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Geoposition" ); - goto ERREUR; - } - - /* sous element Production */ - - cr = cai_WriteOpenTagXML ( des , "Production" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Production" ); - goto ERREUR; - } - - /* sous element DATASET_PRODUCER_NAME */ - - cr = cai_WriteElementXML ( des , "DATASET_PRODUCER_NAME" , processing_center ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element DATASET_PRODUCER_NAME" ); - goto ERREUR; - } - -/******************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout attribut href="http://www.spotimage.fr" */ -/******************************************************************************/ - - /* sous element DATASET_PRODUCER_URL */ - type=1; - cr = cai_WriteElementXMLWithAttribute ( des , "DATASET_PRODUCER_URL" , "" , - "href" , "http://www.spotimage.fr" ,type); - - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element DATASET_PRODUCER_URL" ); - goto ERREUR; - } - - /* sous element DATASET_PRODUCTION_DATE */ - - sprintf ( valeur , "%.4d-%.2d-%.2d %.2d:%.2d:%.2d" , product_annee , - product_mois , product_jour , product_heure , product_min , - product_sec ); - - cr = cai_WriteElementXML ( des , "DATASET_PRODUCTION_DATE" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element DATASET_PRODUCTION_DATE" ); - goto ERREUR; - } - - /* sous element PRODUCT_TYPE */ - - cr = cai_WriteElementXML ( des , "PRODUCT_TYPE" , product_type ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element PRODUCT_TYPE" ); - goto ERREUR; - } - - /* sous element PRODUCT_INFO */ - - sprintf ( prod_info , "Spot SYSTEM SCENE level %s" , niv_trait ); - - cr = cai_WriteElementXML ( des , "PRODUCT_INFO" , prod_info ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element PRODUCT_INFO" ); - goto ERREUR; - } - - /* sous element JOB_ID */ - - cr = cai_WriteElementXML ( des , "JOB_ID" , job_id ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element JOB_ID" ); - goto ERREUR; - } - - /* sous element Production_Facility */ - - cr = cai_WriteOpenTagXML ( des , "Production_Facility" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Production_Facility" ); - goto ERREUR; - } - - /* sous element SOFTWARE_NAME */ - - cr = cai_WriteElementXML ( des , "SOFTWARE_NAME" , software_name ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SOFTWARE_NAME" ); - goto ERREUR; - } - - /* sous element SOFTWARE_VERSION */ - - cr = cai_WriteElementXML ( des , "SOFTWARE_VERSION" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SOFTWARE_VERSION" ); - goto ERREUR; - } - - /* sous element PROCESSING_CENTER */ - - cr = cai_WriteElementXML ( des , "PROCESSING_CENTER" , software_name ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element PROCESSING_CENTER" ); - goto ERREUR; - } - - /* Fermeture de l'element Production_Facility */ - - cr = cai_WriteCloseTagXML ( des , "Production_Facility" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Production_Facility" ); - goto ERREUR; - } - - /* Fermeture de l'element Production */ - - cr = cai_WriteCloseTagXML ( des , "Production" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Production" ); - goto ERREUR; - } - - /* sous element Raster_Dimensions */ - - cr = cai_WriteOpenTagXML ( des , "Raster_Dimensions" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Raster_Dimensions" ); - goto ERREUR; - } - - /* sous element NCOLS */ - - sprintf ( valeur , "%d" , nb_col ); - cr = cai_WriteElementXML ( des , "NCOLS" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element NCOLS" ); - goto ERREUR; - } - - /* sous element NROWS */ - - sprintf ( valeur , "%d" , nb_lig ); - cr = cai_WriteElementXML ( des , "NROWS" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element NROWS" ); - goto ERREUR; - } - - /* sous element NBANDS */ - - sprintf ( valeur , "%d" , nb_bs ); - cr = cai_WriteElementXML ( des , "NBANDS" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element NBANDS" ); - goto ERREUR; - } - - /* Fermeture de l'element Raster_Dimensions */ - - cr = cai_WriteCloseTagXML ( des , "Raster_Dimensions" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Raster_Dimensions" ); - goto ERREUR; - } - - /* sous element Raster_Encoding */ - - cr = cai_WriteOpenTagXML ( des , "Raster_Encoding" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Raster_Encoding" ); - goto ERREUR; - } - - /* sous element NBITS */ - - cr = cai_WriteElementXML ( des , "NBITS" , "8" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element NBITS" ); - goto ERREUR; - } - -/****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element DATA_TYPE */ -/****************************************************************************/ - - /* sous element DATA_TYPE */ - - cr = cai_WriteElementXML ( des , "DATA_TYPE" , "UNSIGNED" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element DATA_TYPE" ); - goto ERREUR; - } - - /* sous element BYTEORDER */ - - cr = cai_WriteElementXML ( des , "BYTEORDER" , "M" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element BYTEORDER" ); - goto ERREUR; - } - - /* sous element BANDS_LAYOUT */ - - cr = cai_WriteElementXML ( des , "BANDS_LAYOUT" , band_layout ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element BANDS_LAYOUT" ); - goto ERREUR; - } - - /* sous element SKIPBYTES */ - - cr = cai_WriteElementXML ( des , "SKIPBYTES" , "0" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SKIPBYTES" ); - goto ERREUR; - } - - /* sous element COMPRESSION_NAME */ - - cr = cai_WriteElementXML ( des , "COMPRESSION_NAME" , "NONE" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element COMPRESSION_NAME" ); - goto ERREUR; - } - - /* Fermeture de l'element Raster_Encoding */ - - cr = cai_WriteCloseTagXML ( des , "Raster_Encoding" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Raster_Encoding" ); - goto ERREUR; - } - - /* sous element Data_Processing */ - - cr = cai_WriteOpenTagXML ( des , "Data_Processing" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Data_Processing" ); - goto ERREUR; - } - - /* sous element PROCESSING_LEVEL */ - - cr = cai_WriteElementXML ( des , "PROCESSING_LEVEL" , niv_trait ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element PROCESSING_LEVEL" ); - goto ERREUR; - } - - /* sous element GEOMETRIC_PROCESSING */ - - if ( strncmp ( niv_trait , "2A" , 2 ) == 0) - { - cr = cai_WriteElementXML ( des , "GEOMETRIC_PROCESSING" , "CARTO" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element GEOMETRIC_PROCESSING" ); - goto ERREUR; - } - } - else - if ( ( strncmp ( niv_trait , "1A" , 2 ) == 0) || - ( strncmp ( niv_trait , "0" , 1 ) == 0) ) - { - cr = cai_WriteElementXML ( des , "GEOMETRIC_PROCESSING" , "RAW" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element GEOMETRIC_PROCESSING" ); - goto ERREUR; - } - } - else - { - cr = cai_WriteElementXML ( des , "GEOMETRIC_PROCESSING" , "SYSTEM" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element GEOMETRIC_PROCESSING" ); - goto ERREUR; - } - } - - /* sous element RADIOMETRIC_PROCESSING */ - - if ( strncmp ( niv_trait , "0" , 1 ) != 0) - { - cr = cai_WriteElementXML ( des , "RADIOMETRIC_PROCESSING" , "SYSTEM" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element RADIOMETRIC_PROCESSING" ); - goto ERREUR; - } - } - else - { - cr = cai_WriteElementXML ( des , "RADIOMETRIC_PROCESSING" , "NONE" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element RADIOMETRIC_PROCESSING" ); - goto ERREUR; - } - } - - /* sous element SPECTRAL_PROCESSING */ - - if ( ( codecapt == 'I' ) && ( nb_bs == 3 ) ) - { - cr = cai_WriteElementXML ( des , "SPECTRAL_PROCESSING" , "X" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SPECTRAL_PROCESSING" ); - goto ERREUR; - } - } - else - if ( ( codecapt == 'M' ) && ( nb_bs == 3 ) ) - { - cr = cai_WriteElementXML ( des , "SPECTRAL_PROCESSING" , "M+X" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SPECTRAL_PROCESSING" ); - goto ERREUR; - } - } - else - if ( ( codecapt == 'M' ) && ( nb_bs == 4 ) ) - { - cr = cai_WriteElementXML ( des , "SPECTRAL_PROCESSING" , "M+I" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SPECTRAL_PROCESSING" ); - goto ERREUR; - } - } - - /* sous element Processing_Options */ - - cr = cai_WriteOpenTagXML ( des , "Processing_Options" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Processing_Options" ); - goto ERREUR; - } - - /* sous element MEAN_RECTIFICATION_ELEVATION */ - - if ( strncmp ( niv_trait , "1B" , 2 ) == 0) - { - cr = cai_WriteElementXML ( des , "MEAN_RECTIFICATION_ELEVATION" , "0" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element MEAN_RECTIFICATION_ELEVATION" ); - goto ERREUR; - } - } - else - if ( strncmp ( niv_trait , "2A" , 2 ) == 0) - { - cr = cai_WriteElementXML ( des , "MEAN_RECTIFICATION_ELEVATION" , mean ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element MEAN_RECTIFICATION_ELEVATION" ); - goto ERREUR; - } - } - /* sous element Dynamic_Stretch */ - - cr = cai_WriteOpenTagXML ( des , "Dynamic_Stretch" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Dynamic_Stretch" ); - goto ERREUR; - } - - for ( i = 0 ; i < nb_bs ; i++ ) - { - /* sous element Thresholds */ - - cr = cai_WriteOpenTagXML ( des , "Thresholds" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Thresholds" ); - goto ERREUR; - } - - /* sous element BAND_INDEX */ - - sprintf ( valeur , "%d" , (i+1) ); - cr = cai_WriteElementXML ( des , "BAND_INDEX" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element BAND_INDEX" ); - goto ERREUR; - } - - /* sous element LOW_THRESHOLD */ - - cr = cai_WriteElementXML ( des , "LOW_THRESHOLD" , lowtresh[i] ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element LOW_THRESHOLD" ); - goto ERREUR; - } - - /* sous element HIGH_THRESHOLD */ - - cr = cai_WriteElementXML ( des , "HIGH_THRESHOLD" , uptresh[i] ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element HIGH_THRESHOLD" ); - goto ERREUR; - } - - /* Fermeture de l'element Thresholds */ - - cr = cai_WriteCloseTagXML ( des , "Thresholds" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Thresholds" ); - goto ERREUR; - } - } - /* Fermeture de l'element Dynamic_Stretch */ - - cr = cai_WriteCloseTagXML ( des , "Dynamic_Stretch" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Dynamic_Stretch" ); - goto ERREUR; - } - - /* sous element LINE_SHIFT */ - - cr = cai_WriteElementXML ( des , "LINE_SHIFT" , shval ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element LINE_SHIFT" ); - goto ERREUR; - } - - if ( ( strcmp ( niv_trait , "1A" ) != 0) && - ( strcmp ( niv_trait , "0" ) != 0) ) - { - /* sous element RESAMPLING_METHOD */ - - cr = cai_WriteElementXML ( des , "RESAMPLING_METHOD" , resampling ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element RESAMPLING_METHOD" ); - goto ERREUR; - } - - /* sous element Sampling_Step */ - - cr = cai_WriteOpenTagXML ( des , "Sampling_Step" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Sampling_Step" ); - goto ERREUR; - } - - /* sous element SAMPLING_STEP_X */ - - cr = cai_WriteElementXML ( des , "SAMPLING_STEP_X" , taille_pixlig ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SAMPLING_STEP_X" ); - goto ERREUR; - } - - /* sous element SAMPLING_STEP_Y */ - - cr = cai_WriteElementXML ( des , "SAMPLING_STEP_Y" , taille_pixcol ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SAMPLING_STEP_Y" ); - goto ERREUR; - } - - /* Fermeture de l'element Sampling_Step */ - - cr = cai_WriteCloseTagXML ( des , "Sampling_Step" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Sampling_Step" ); - goto ERREUR; - } - } - /* sous element SWIR_BAND_REGISTRATION_FLAG */ - - if ( swir == 1 ) - cr = cai_WriteElementXML ( des , "SWIR_BAND_REGISTRATION_FLAG" , "Y" ); - else - cr = cai_WriteElementXML ( des , "SWIR_BAND_REGISTRATION_FLAG" , "N" ); - - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SWIR_BAND_REGISTRATION_FLAG" ); - goto ERREUR; - } - - /* Fermeture de l'element Processing_Options */ - - cr = cai_WriteCloseTagXML ( des , "Processing_Options" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Processing_Options" ); - goto ERREUR; - } - - /* Fermeture de l'element Data_Processing */ - - cr = cai_WriteCloseTagXML ( des , "Data_Processing" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Data_Processing" ); - goto ERREUR; - } - - /* sous element Data_Access */ - - cr = cai_WriteOpenTagXML ( des , "Data_Access" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Data_Access" ); - goto ERREUR; - } - - /* sous element DATA_FILE_ORGANISATION */ - - cr = cai_WriteElementXML ( des , "DATA_FILE_ORGANISATION" , "BAND_COMPOSITE" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element DATA_FILE_ORGANISATION" ); - goto ERREUR; - } - - /* sous element DATA_FILE_FORMAT */ - - cr = cai_WriteElementXML ( des , "DATA_FILE_FORMAT" , "RAW" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element DATA_FILE_FORMAT" ); - goto ERREUR; - } - - /* sous element Data_File */ - - cr = cai_WriteOpenTagXML ( des , "Data_File" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Data_File" ); - goto ERREUR; - } - - /* sous element DATA_FILE_PATH */ - - cr = cai_WriteElementXML ( des , "DATA_FILE_PATH" , "./" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element DATA_FILE_PATH" ); - goto ERREUR; - } - - /* Fermeture de l'element Data_File */ - - cr = cai_WriteCloseTagXML ( des , "Data_File" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Data_File" ); - goto ERREUR; - } - - /* Fermeture de l'element Data_Access */ - - cr = cai_WriteCloseTagXML ( des , "Data_Access" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Data_Access" ); - goto ERREUR; - } - - /* sous element Image_Display */ - - cr = cai_WriteOpenTagXML ( des , "Image_Display" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Image_Display" ); - goto ERREUR; - } - - /* sous element Band_Display_Order */ - - cr = cai_WriteOpenTagXML ( des , "Band_Display_Order" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Band_Display_Order" ); - goto ERREUR; - } - - if ( strncasecmp ( mode_spect , "PM" , 2) == 0) - { - - /* sous element RED_CHANNEL */ - - cr = cai_WriteElementXML ( des , "RED_CHANNEL" , "1" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element RED_CHANNEL" ); - goto ERREUR; - } - /* sous element GREEN_CHANNEL */ - - cr = cai_WriteElementXML ( des , "GREEN_CHANNEL" , "1" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element GREEN_CHANNEL" ); - goto ERREUR; - } - /* sous element BLUE_CHANNEL */ - - cr = cai_WriteElementXML ( des , "BLUE_CHANNEL" , "1" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element BLUE_CHANNEL" ); - goto ERREUR; - } - } - else - if ( ( strncasecmp ( mode_spect , "XS" , 2) == 0)|| - ( strncasecmp ( mode_spect , "XI" , 2) == 0) ) - { - /* sous element RED_CHANNEL */ - - cr = cai_WriteElementXML ( des , "RED_CHANNEL" , "3" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element RED_CHANNEL" ); - goto ERREUR; - } - /* sous element GREEN_CHANNEL */ - - cr = cai_WriteElementXML ( des , "GREEN_CHANNEL" , "2" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element GREEN_CHANNEL" ); - goto ERREUR; - } - - /* sous element BLUE_CHANNEL */ - - cr = cai_WriteElementXML ( des , "BLUE_CHANNEL" , "1" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element BLUE_CHANNEL" ); - goto ERREUR; - } - } - - /* Fermeture de l'element Band_Display_Order */ - - cr = cai_WriteCloseTagXML ( des , "Band_Display_Order" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Band_Display_Order" ); - goto ERREUR; - } - - /* sous element Special_Value */ - - cr = cai_WriteOpenTagXML ( des , "Special_Value" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Special_Value" ); - goto ERREUR; - } - - /* sous element SPECIAL_VALUE_INDEX */ - - cr = cai_WriteElementXML ( des , "SPECIAL_VALUE_INDEX" , "0" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SPECIAL_VALUE_INDEX" ); - goto ERREUR; - } -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : FA : SPECIAL_VALUE_TEXT NODATA a la place NO_DATA */ -/*****************************************************************************/ - /* sous element SPECIAL_VALUE_TEXT */ - - cr = cai_WriteElementXML ( des , "SPECIAL_VALUE_TEXT" , "NODATA" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SPECIAL_VALUE_TEXT" ); - goto ERREUR; - } - - /* sous element Special_Value_Color */ - - cr = cai_WriteOpenTagXML ( des , "Special_Value_Color" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Special_Value_Color" ); - goto ERREUR; - } - - /* sous element RED_LEVEL */ - - cr = cai_WriteElementXML ( des , "RED_LEVEL" , "0" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element RED_LEVEL" ); - goto ERREUR; - } - - /* sous element GREEN_LEVEL */ - - cr = cai_WriteElementXML ( des , "GREEN_LEVEL" , "0" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element GREEN_LEVEL" ); - goto ERREUR; - } - - /* sous element BLUE_LEVEL */ - - cr = cai_WriteElementXML ( des , "BLUE_LEVEL" , "0" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element BLUE_LEVEL" ); - goto ERREUR; - } -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Rajouter ALPHA_LEVEL unqiement pour SPOT4 MIR */ -/*****************************************************************************/ - - if ((nb_bs == 4)&&(satellite_index==4)) - { - /* sous element ALPHA_LEVEL */ - - cr = cai_WriteElementXML ( des , "ALPHA_LEVEL" , "0" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element ALPHA_LEVEL" ); - goto ERREUR; - } - } - - /* Fermeture de l'element Special_Value_Color */ - - cr = cai_WriteCloseTagXML ( des , "Special_Value_Color" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Special_Value_Color" ); - goto ERREUR; - } - - /* Fermeture de l'element Special_Value */ - - cr = cai_WriteCloseTagXML ( des , "Special_Value" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Special_Value" ); - goto ERREUR; - } - - /* sous element Special_Value */ - - cr = cai_WriteOpenTagXML ( des , "Special_Value" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Special_Value" ); - goto ERREUR; - } - - /* sous element SPECIAL_VALUE_INDEX */ - - cr = cai_WriteElementXML ( des , "SPECIAL_VALUE_INDEX" , "255" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SPECIAL_VALUE_INDEX" ); - goto ERREUR; - } - -/******************************************************************************/ -/* MOD : VERSION : 4.7 : DM : remplacement de SATURATE par SATURATED */ -/******************************************************************************/ - - /* sous element SPECIAL_VALUE_TEXT */ - - cr = cai_WriteElementXML ( des , "SPECIAL_VALUE_TEXT" , "SATURATED" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SPECIAL_VALUE_TEXT" ); - goto ERREUR; - } - - /* sous element Special_Value_Color */ - - cr = cai_WriteOpenTagXML ( des , "Special_Value_Color" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Special_Value_Color" ); - goto ERREUR; - } - -/******************************************************************************/ -/* MOD : VERSION : 4.7 : DM : remplacement de 255 par 1 dans les element LEVEL*/ -/******************************************************************************/ - - /* sous element RED_LEVEL */ - - cr = cai_WriteElementXML ( des , "RED_LEVEL" , "1" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element RED_LEVEL" ); - goto ERREUR; - } - - /* sous element GREEN_LEVEL */ - - cr = cai_WriteElementXML ( des , "GREEN_LEVEL" , "1" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element GREEN_LEVEL" ); - goto ERREUR; - } - - /* sous element BLUE_LEVEL */ - - cr = cai_WriteElementXML ( des , "BLUE_LEVEL" , "1" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element BLUE_LEVEL" ); - goto ERREUR; - } -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Rajouter ALPHA_LEVEL uniquement pour SPOT4 MIR */ -/*****************************************************************************/ - - if ((nb_bs == 4)&&(satellite_index==4)) - { - /* sous element ALPHA_LEVEL */ - - cr = cai_WriteElementXML ( des , "ALPHA_LEVEL" , "1" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element ALPHA_LEVEL" ); - goto ERREUR; - } - } - - /* Fermeture de l'element Special_Value_Color */ - - cr = cai_WriteCloseTagXML ( des , "Special_Value_Color" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Special_Value_Color" ); - goto ERREUR; - } - - /* Fermeture de l'element Special_Value */ - - cr = cai_WriteCloseTagXML ( des , "Special_Value" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Special_Value" ); - goto ERREUR; - } - - /* Fermeture de l'element Image_Display */ - - cr = cai_WriteCloseTagXML ( des , "Image_Display" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Image_Display" ); - goto ERREUR; - } - - /* sous element Image_Interpretation */ - - cr = cai_WriteOpenTagXML ( des , "Image_Interpretation" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Image_Interpretation" ); - goto ERREUR; - } - - for ( j = 0; j < nb_bs ; j++ ) - { - /* sous element Spectral_Band_Info */ - - cr = cai_WriteOpenTagXML ( des , "Spectral_Band_Info" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Spectral_Band_Info" ); - goto ERREUR; - } - - /* sous element BAND_INDEX */ - - sprintf ( valeur , "%d" , (j+1) ); - - cr = cai_WriteElementXML ( des , "BAND_INDEX" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element BAND_INDEX" ); - goto ERREUR; - } - - /* sous element BAND_DESCRIPTION */ - - if ( nb_bs == 1 ) - sprintf ( valeur , "PAN" ); - else - if ( ( ( j == 0) || ( j == 1 ) ) || ( j == 2 ) ) - sprintf ( valeur , "XS%d" , (j+1) ); - else - if ( j == 3 ) - sprintf ( valeur , "SWIR" ); - -/******************************************************************************/ -/* MOD : VERSION : 4.7 : DM : remplacement de BAND par BAND_DESCRIPTION */ -/******************************************************************************/ - - cr = cai_WriteElementXML ( des , "BAND_DESCRIPTION" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element BAND_DESCRIPTION" ); - goto ERREUR; - } - - /* sous element PHYSICAL_CALIBRATION_DATE */ - - cr = cai_WriteElementXML ( des , "PHYSICAL_CALIBRATION_DATE" , datecalib ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element PHYSICAL_CALIBRATION_DATE" ); - goto ERREUR; - } - - /* sous element PHYSICAL_BIAIS */ - - cr = cai_WriteElementXML ( des , "PHYSICAL_BIAIS" , gains_b[j] ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element PHYSICAL_BIAIS" ); - goto ERREUR; - } - - /* sous element PHYSICAL_GAIN */ - - cr = cai_WriteElementXML ( des , "PHYSICAL_GAIN" , gains_a[j] ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element PHYSICAL_GAIN" ); - goto ERREUR; - } - -/******************************************************************************/ -/* MOD : VERSION : 4.7 : DM : ajout de l'unite dans PHYSICAL_UNIT */ -/******************************************************************************/ - - /* sous element PHYSICAL_UNIT */ - - cr = cai_WriteElementXML ( des , "PHYSICAL_UNIT" , "equivalent radiance (W.m-2.Sr-1.um-1)" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element PHYSICAL_UNIT" ); - goto ERREUR; - } - - /* Fermeture de l'element Spectral_Band_Info */ - - cr = cai_WriteCloseTagXML ( des , "Spectral_Band_Info" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Spectral_Band_Info" ); - goto ERREUR; - } - } - - /* Fermeture de l'element Image_Interpretation */ - - cr = cai_WriteCloseTagXML ( des , "Image_Interpretation" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Image_Interpretation" ); - goto ERREUR; - } - - /* sous element Data_Strip */ - - cr = cai_WriteOpenTagXML ( des , "Data_Strip" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Data_Strip" ); - goto ERREUR; - } - - /* sous element Satellite_Time */ - - cr = cai_WriteOpenTagXML ( des , "Satellite_Time" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Satellite_Time" ); - goto ERREUR; - } - - /* sous element UT_DATE */ - - sprintf ( valeur , "%.7d %.5d.000000" , utdatej , utdates ); - cr = cai_WriteElementXML ( des , "UT_DATE" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element UT_DATE" ); - goto ERREUR; - } - - /* sous element CLOCK_VALUE */ - - cr = cai_WriteElementXML ( des , "CLOCK_VALUE" , clockvalue ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element CLOCK_VALUE" ); - goto ERREUR; - } - - /* sous element CLOCK_PERIOD */ - - if ( clockperiod[0] != '\0' ) - sscanf ( clockperiod , "%lf" , &period ); - else - period = 0.0; - pico =0.000000000001; - period = period * pico; - - sprintf ( valeur , "%.12lf" , period ); - - cr = cai_WriteElementXML ( des , "CLOCK_PERIOD" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element CLOCK_PERIOD" ); - goto ERREUR; - } - - /* sous element BOARD_TIME */ - - cr = cai_WriteElementXML ( des , "BOARD_TIME" , boardtime ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element BOARD_TIME" ); - goto ERREUR; - } - - /* Fermeture de l'element Satellite_Time */ - - cr = cai_WriteCloseTagXML ( des , "Satellite_Time" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Satellite_Time" ); - goto ERREUR; - } - - /* sous element Ephemeris */ - - cr = cai_WriteOpenTagXML ( des , "Ephemeris" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Ephemeris" ); - goto ERREUR; - } - - /* sous element SATELLITE_ALTITUDE */ - - cr = cai_WriteElementXML ( des , "SATELLITE_ALTITUDE" , sat_alt ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SATELLITE_ALTITUDE" ); - goto ERREUR; - } - - /* sous element NADIR_LAT */ - - sprintf ( valeur , "%lf" , lat_nad ); - cr = cai_WriteElementXML ( des , "NADIR_LAT" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element NADIR_LAT" ); - goto ERREUR; - } - - /* sous element NADIR_LON */ - - sprintf ( valeur , "%lf" , long_nad ); - cr = cai_WriteElementXML ( des , "NADIR_LON" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element NADIR_LON" ); - goto ERREUR; - } - - /* sous element Points */ - - cr = cai_WriteOpenTagXML ( des , "Points" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Points" ); - goto ERREUR; - } - - for ( j = 0; j < 8 ; j++ ) - { - /* sous element Point */ - - cr = cai_WriteOpenTagXML ( des , "Point" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Point" ); - goto ERREUR; - } - - /* sous element Location */ - - cr = cai_WriteOpenTagXML ( des , "Location" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Location" ); - goto ERREUR; - } - - /* sous element X */ - - sprintf ( valeur , "%.3lf" , X_loc[j]*1000.0 ); - cr = cai_WriteElementXML ( des , "X" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element X" ); - goto ERREUR; - } - - /* sous element Y */ - - sprintf ( valeur , "%.3lf" , Y_loc[j]*1000.0 ); - cr = cai_WriteElementXML ( des , "Y" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Y" ); - goto ERREUR; - } - - /* sous element Z */ - - sprintf ( valeur , "%.3lf" , Z_loc[j]*1000.0 ); - cr = cai_WriteElementXML ( des , "Z" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Z" ); - goto ERREUR; - } - - /* Fermeture de l'element Location */ - - cr = cai_WriteCloseTagXML ( des , "Location" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Location" ); - goto ERREUR; - } - - /* sous element Velocity */ - - cr = cai_WriteOpenTagXML ( des , "Velocity" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Velocity" ); - goto ERREUR; - } - - /* sous element X */ - - sprintf ( valeur , "%.3lf" , X_vel[j]*1000.0 ); - cr = cai_WriteElementXML ( des , "X" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element X" ); - goto ERREUR; - } - - /* sous element Y */ - - sprintf ( valeur , "%.3lf" , Y_vel[j]*1000.0 ); - cr = cai_WriteElementXML ( des , "Y" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Y" ); - goto ERREUR; - } - - /* sous element Z */ - - sprintf ( valeur , "%.3lf" , Z_vel[j]*1000.0 ); - cr = cai_WriteElementXML ( des , "Z" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Z" ); - goto ERREUR; - } - - /* Fermeture de l'element Velocity */ - - cr = cai_WriteCloseTagXML ( des , "Velocity" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Velocity" ); - goto ERREUR; - } - - /* sous element TIME */ - - cr = cai_WriteElementXML ( des , "TIME" , time[j] ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element TIME" ); - goto ERREUR; - } - - /* Fermeture de l'element Point */ - - cr = cai_WriteCloseTagXML ( des , "Point" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Point" ); - goto ERREUR; - } - } - - if ( X_loc[8] != 0.0 ) - { - /* sous element Point */ - - cr = cai_WriteOpenTagXML ( des , "Point" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Point" ); - goto ERREUR; - } - - /* sous element Location */ - - cr = cai_WriteOpenTagXML ( des , "Location" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Location" ); - goto ERREUR; - } - - /* sous element X */ - - sprintf ( valeur , "%.3lf" , X_loc[8] ); - - cr = cai_WriteElementXML ( des , "X" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element X" ); - goto ERREUR; - } - - /* sous element Y */ - - sprintf ( valeur , "%.3lf" , Y_loc[8] ); - cr = cai_WriteElementXML ( des , "Y" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Y" ); - goto ERREUR; - } - - /* sous element Z */ - - sprintf ( valeur , "%.3lf" , Z_loc[8] ); - cr = cai_WriteElementXML ( des , "Z" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Z" ); - goto ERREUR; - } - - /* Fermeture de l'element Location */ - - cr = cai_WriteCloseTagXML ( des , "Location" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Location" ); - goto ERREUR; - } - - /* sous element Velocity */ - - cr = cai_WriteOpenTagXML ( des , "Velocity" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Velocity" ); - goto ERREUR; - } - - /* sous element X */ - - sprintf ( valeur , "%.3lf" , X_vel[8]*1000.0 ); - cr = cai_WriteElementXML ( des , "X" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element X" ); - goto ERREUR; - } - - /* sous element Y */ - - sprintf ( valeur , "%lf" , Y_vel[8]*1000.0 ); - cr = cai_WriteElementXML ( des , "Y" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Y" ); - goto ERREUR; - } - - /* sous element Z */ - - sprintf ( valeur , "%.3lf" , Z_vel[8]*1000.0 ); - cr = cai_WriteElementXML ( des , "Z" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Z" ); - goto ERREUR; - } - - /* Fermeture de l'element Velocity */ - - cr = cai_WriteCloseTagXML ( des , "Velocity" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Velocity" ); - goto ERREUR; - } - - /* sous element TIME */ - - cr = cai_WriteElementXML ( des , "TIME" , time[8] ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element TIME" ); - goto ERREUR; - } - - /* Fermeture de l'element Point */ - - cr = cai_WriteCloseTagXML ( des , "Point" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Point" ); - goto ERREUR; - } - - } - /* Fermeture de l'element Points */ - - cr = cai_WriteCloseTagXML ( des , "Points" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Points" ); - goto ERREUR; - } - - /* sous element DORIS_USED */ - - cr = cai_WriteElementXML ( des , "DORIS_USED" , dorisused ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element DORIS_USED" ); - goto ERREUR; - } - - if ( satellite_index == 4 ) - { - /* sous element Orbital_Bulletin */ - - cr = cai_WriteOpenTagXML ( des , "Orbital_Bulletin" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Orbital_Bulletin" ); - goto ERREUR; - } - - /* sous element UT_DATE */ - - sprintf ( valeur , "%.7d %.5d.000000" , jourjul , datejul ); - cr = cai_WriteElementXML ( des , "UT_DATE" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element UT_DATE" ); - goto ERREUR; - } - - /* sous element ELLIPSE_AXIS */ - - cr = cai_WriteElementXML ( des , "ELLIPSE_AXIS" , axis ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element ELLIPSE_AXIS" ); - goto ERREUR; - } - - /* sous element ELLIPSE_ECCENTRICITY_VECTOR_EX */ - - cr = cai_WriteElementXML ( des , "ELLIPSE_ECCENTRICITY_VECTOR_EX" , ex ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element ELLIPSE_ECCENTRICITY_VECTOR_EX" ); - goto ERREUR; - } - - /* sous element ELLIPSE_ECCENTRICITY_VECTOR_EY */ - - cr = cai_WriteElementXML ( des , "ELLIPSE_ECCENTRICITY_VECTOR_EY" , ey ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element ELLIPSE_ECCENTRICITY_VECTOR_EY" ); - goto ERREUR; - } - - /* sous element ELLIPSE_INCLINATION */ - - cr = cai_WriteElementXML ( des , "ELLIPSE_INCLINATION" , inclin ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element ELLIPSE_INCLINATION" ); - goto ERREUR; - } - - /* sous element RIGHT_ASCENSION */ - - cr = cai_WriteElementXML ( des , "RIGHT_ASCENSION" , ascension ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element RIGHT_ASCENSION" ); - goto ERREUR; - } - -/*****************************************************************************/ -/* MOD : VERSION : 4.5 : FA : erreur d'orthographe sur LATITUDE_ARGUMENT */ -/* et Look_Angles */ -/*****************************************************************************/ - - /* sous element LATITUDE_ARGUMENT */ - - cr = cai_WriteElementXML ( des , "LATITUDE_ARGUMENT" , latarg ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element LATITUDE_ARGUMENT" ); - goto ERREUR; - } - - /* sous element P7 */ - - cr = cai_WriteElementXML ( des , "P7" , p7 ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element P7" ); - goto ERREUR; - } - - /* sous element P8 */ - - cr = cai_WriteElementXML ( des , "P8" , p8 ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element P8" ); - goto ERREUR; - } - - /* sous element P9 */ - - cr = cai_WriteElementXML ( des , "P9" , p9 ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element P9" ); - goto ERREUR; - } - - /* sous element P10 */ - - cr = cai_WriteElementXML ( des , "P10" , p10 ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element P10" ); - goto ERREUR; - } - - /* Fermeture de l'element Orbital_Bulletin */ - - cr = cai_WriteCloseTagXML ( des , "Orbital_Bulletin" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Orbital_Bulletin" ); - goto ERREUR; - } - - } - - /* Fermeture de l'element Ephemeris */ - - cr = cai_WriteCloseTagXML ( des , "Ephemeris" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Ephemeris" ); - goto ERREUR; - } - - /* sous element Satellite_Attitudes */ - - cr = cai_WriteOpenTagXML ( des , "Satellite_Attitudes" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Satellite_Attitudes" ); - goto ERREUR; - } - - /* sous element Raw_Attitudes */ - - cr = cai_WriteOpenTagXML ( des , "Raw_Attitudes" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Raw_Attitudes" ); - goto ERREUR; - } - - /* sous element Aocs_Attitude */ - - cr = cai_WriteOpenTagXML ( des , "Aocs_Attitude" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Aocs_Attitude" ); - goto ERREUR; - } - -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element Angles_List */ -/*****************************************************************************/ - - /* sous element Angles_List */ - - cr = cai_WriteOpenTagXML ( des , "Angles_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Angles_List" ); - goto ERREUR; - } - - for ( j = 0; j < 2 ; j++ ) - { - /* sous element Angles */ - - cr = cai_WriteOpenTagXML ( des , "Angles" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Angles" ); - goto ERREUR; - } - - /* sous element TIME */ - - cr = cai_WriteElementXML ( des , "TIME" , timeyaw[j] ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element TIME" ); - goto ERREUR; - } - - /* sous element YAW */ - - cr = cai_WriteElementXML ( des , "YAW" , yaw_angle[j] ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element YAW" ); - goto ERREUR; - } - - /* sous element PITCH */ - - cr = cai_WriteElementXML ( des , "PITCH" , pitch_angle[j] ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element PITCH" ); - goto ERREUR; - } - - /* sous element ROLL */ - - cr = cai_WriteElementXML ( des , "ROLL" , roll_angle[j] ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element ROLL" ); - goto ERREUR; - } - - /* sous element OUT_OF_RANGE */ - - cr = cai_WriteElementXML ( des , "OUT_OF_RANGE" , "N" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element OUT_OF_RANGE" ); - goto ERREUR; - } - - /* Fermeture de l'element Angles */ - - cr = cai_WriteCloseTagXML ( des , "Angles" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Angles" ); - goto ERREUR; - } - } - - /* Fermeture de l'element Angles_List */ - - cr = cai_WriteCloseTagXML ( des , "Angles_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Angles_List" ); - goto ERREUR; - } - -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element Angular_Speeds_List */ -/*****************************************************************************/ - - /* sous element Angular_Speeds_List */ - - cr = cai_WriteOpenTagXML ( des , "Angular_Speeds_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Angular_Speeds_List" ); - goto ERREUR; - } - - for ( j = 0; j < 72 ; j++ ) - { - /* sous element Angular_Speeds */ - - cr = cai_WriteOpenTagXML ( des , "Angular_Speeds" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Angular_Speeds" ); - goto ERREUR; - } - - /* sous element TIME */ - - cr = cai_WriteElementXML ( des , "TIME" , time_angle[j] ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element TIME" ); - goto ERREUR; - } - - /* sous element YAW */ - - cr = cai_WriteElementXML ( des , "YAW" , yaw[j] ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element YAW" ); - goto ERREUR; - } - - /* sous element PITCH */ - - cr = cai_WriteElementXML ( des , "PITCH" , pitch[j] ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element PITCH" ); - goto ERREUR; - } - - /* sous element ROLL */ - - cr = cai_WriteElementXML ( des , "ROLL" , roll[j] ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element ROLL" ); - goto ERREUR; - } - - /* sous element OUT_OF_RANGE */ - - cr = cai_WriteElementXML ( des , "OUT_OF_RANGE" , outofrange ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element OUT_OF_RANGE" ); - goto ERREUR; - } - - /* Fermeture de l'element Angular_Speeds */ - - cr = cai_WriteCloseTagXML ( des , "Angular_Speeds" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Angular_Speeds" ); - goto ERREUR; - } - } - - if ( strcmp ( yaw[72] , "" ) != 0) - { - /* sous element Angular_Speeds */ - - cr = cai_WriteOpenTagXML ( des , "Angular_Speeds" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Angular_Speeds" ); - goto ERREUR; - } - - /* sous element TIME */ - - cr = cai_WriteElementXML ( des , "TIME" , time_angle[72] ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element TIME" ); - goto ERREUR; - } - - /* sous element YAW */ - - cr = cai_WriteElementXML ( des , "YAW" , yaw[72] ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element YAW" ); - goto ERREUR; - } - - /* sous element PITCH */ - - cr = cai_WriteElementXML ( des , "PITCH" , pitch[72] ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element PITCH" ); - goto ERREUR; - } - - /* sous element ROLL */ - - cr = cai_WriteElementXML ( des , "ROLL" , roll[72] ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element ROLL" ); - goto ERREUR; - } - - /* sous element OUT_OF_RANGE */ - - cr = cai_WriteElementXML ( des , "OUT_OF_RANGE" , outofrange ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element OUT_OF_RANGE" ); - goto ERREUR; - } - - /* Fermeture de l'element Angular_Speeds */ - - cr = cai_WriteCloseTagXML ( des , "Angular_Speeds" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Angular_Speeds" ); - goto ERREUR; - } - } - - /* Fermeture de l'element Angular_Speeds_List */ - - cr = cai_WriteCloseTagXML ( des , "Angular_Speeds_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Angular_Speeds_List" ); - goto ERREUR; - } - - /* Fermeture de l'element Aocs_Attitude */ - - cr = cai_WriteCloseTagXML ( des , "Aocs_Attitude" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Aocs_Attitude" ); - goto ERREUR; - } - - /* Fermeture de l'element Raw_Attitudes */ - - cr = cai_WriteCloseTagXML ( des , "Raw_Attitudes" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Raw_Attitudes" ); - goto ERREUR; - } - - /* Fermeture de l'element Satellite_Attitudes */ - - cr = cai_WriteCloseTagXML ( des , "Satellite_Attitudes" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Satellite_Attitudes" ); - goto ERREUR; - } - - /* sous element Sensor_Configuration */ - - cr = cai_WriteOpenTagXML ( des , "Sensor_Configuration" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Sensor_Configuration" ); - goto ERREUR; - } - - /* sous element Time_Stamp */ - - cr = cai_WriteOpenTagXML ( des , "Time_Stamp" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Time_Stamp " ); - goto ERREUR; - } - - /* sous element LINE_PERIOD */ - - sprintf ( valeur , "%.12lf" , periodeligne ); - cr = cai_WriteElementXML ( des , "LINE_PERIOD" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element LINE_PERIOD" ); - goto ERREUR; - } - - /* sous element SCENE_CENTER_TIME */ - - cr = cai_WriteElementXML ( des , "SCENE_CENTER_TIME" , time_scenecenter ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SCENE_CENTER_TIME" ); - goto ERREUR; - } - - /* sous element SCENE_CENTER_LINE */ - - sprintf ( valeur , "%d" , nbc_c ); - cr = cai_WriteElementXML ( des , "SCENE_CENTER_LINE" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SCENE_CENTER_LINE" ); - goto ERREUR; - } - - /* sous element SCENE_CENTER_COL */ - - sprintf ( valeur , "%d" , nbl_c ); - cr = cai_WriteElementXML ( des , "SCENE_CENTER_COL" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SCENE_CENTER_COL" ); - goto ERREUR; - } - - /* Fermeture de l'element Time_Stamp */ - - cr = cai_WriteCloseTagXML ( des , "Time_Stamp" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Time_Stamp" ); - goto ERREUR; - } - -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element Instrument_look_Angles_List */ -/*****************************************************************************/ - - /* sous element Instrument_Look_Angles_List */ - - cr = cai_WriteOpenTagXML ( des , "Instrument_Look_Angles_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Instrument_Look_Angles_List" ); - goto ERREUR; - } - - j = 0; - while ( ( j < nb_bs ) && ( j < 3 ) ) - { - /* sous element Instrument_Look_Angles */ - - cr = cai_WriteOpenTagXML ( des , "Instrument_Look_Angles" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Instrument_Look_Angles" ); - goto ERREUR; - } - - /* sous element VALIDITY_DATE */ - - cr = cai_WriteElementXML ( des , "VALIDITY_DATE" , datecalib ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element VALIDITY_DATE" ); - goto ERREUR; - } - - /* sous element BAND_INDEX */ - - sprintf ( valeur , "%d" , (j+1) ); - cr = cai_WriteElementXML ( des , "BAND_INDEX" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element BAND_INDEX" ); - goto ERREUR; - } - -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element Look_Angles_List */ -/*****************************************************************************/ - - /* sous element Look_Angles_List */ - - cr = cai_WriteOpenTagXML ( des , "Look_Angles_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Look_Angles_List" ); - goto ERREUR; - } - - /* sous element Look_Angles */ - - cr = cai_WriteOpenTagXML ( des , "Look_Angles" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Look_Angles" ); - goto ERREUR; - } - - /* sous element DETECTOR_ID */ - - cr = cai_WriteElementXML ( des , "DETECTOR_ID" , "1" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element DETECTOR_ID" ); - goto ERREUR; - } -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : DIMAP tag LOOK_ANGLE_LIST valeurs de PSI_X et */ -/* PSI_Y 1er et dernier detecteur inverses */ -/*****************************************************************************/ - - /* sous element PSI_X */ - - sprintf ( valeur , "%lf" , psi_x_last[0] ); - cr = cai_WriteElementXML ( des , "PSI_X" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element PSI_X" ); - goto ERREUR; - } - - /* sous element PSI_Y */ - - sprintf ( valeur , "%lf" , psi_y_last[0] ); - cr = cai_WriteElementXML ( des , "PSI_Y" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element PSI_Y" ); - goto ERREUR; - } - - /* Fermeture de l'element Look_Angles */ - - cr = cai_WriteCloseTagXML ( des , "Look_Angles" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Look_Angles" ); - goto ERREUR; - } - - /* sous element Look_Angle */ - - cr = cai_WriteOpenTagXML ( des , "Look_Angles" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Look_Angles" ); - goto ERREUR; - } - - /* sous element DETECTOR_ID */ - -/*****************************************************************************/ -/* MOD : VERSION : 4.5 : FA : erreur d'ecriture detector_id lookangle pour */ -/* PAN */ -/*****************************************************************************/ - - if ( nb_bs == 1 ) - detect_id = 6000; - else - detect_id = 3000; - - sprintf ( valeur , "%d" , detect_id ); - - cr = cai_WriteElementXML ( des , "DETECTOR_ID" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element DETECTOR_ID" ); - goto ERREUR; - } - - /* sous element PSI_X */ - - sprintf ( valeur , "%lf" , psi_x_first[0] ); - cr = cai_WriteElementXML ( des , "PSI_X" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element PSI_X" ); - goto ERREUR; - } - - /* sous element PSI_Y */ - - sprintf ( valeur , "%lf" , psi_y_first[0] ); - cr = cai_WriteElementXML ( des , "PSI_Y" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element PSI_Y" ); - goto ERREUR; - } - - /* Fermeture de l'element Look_Angles */ - - cr = cai_WriteCloseTagXML ( des , "Look_Angles" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Look_Angles" ); - goto ERREUR; - } - - /* Fermeture de l'element Look_Angles_List */ - - cr = cai_WriteCloseTagXML ( des , "Look_Angles_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Look_Angles_List" ); - goto ERREUR; - } - - /* Fermeture de l'element Instrument_Look_Angles */ - - cr = cai_WriteCloseTagXML ( des , "Instrument_Look_Angles" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Instrument_Look_Angles" ); - goto ERREUR; - } - j++; - } - - while ( ( nb_bs != 1 ) && ( j < nb_bs + 1 ) ) - { - /* sous element Instrument_Look_Angles */ - - cr = cai_WriteOpenTagXML ( des , "Instrument_Look_Angles" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Instrument_Look_Angles" ); - goto ERREUR; - } - - /* sous element VALIDITY_DATE */ - - cr = cai_WriteElementXML ( des , "VALIDITY_DATE" , datecalib ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element VALIDITY_DATE" ); - goto ERREUR; - } - - /* sous element BAND_INDEX */ - - sprintf ( valeur , "%d" , (j+1) ); - cr = cai_WriteElementXML ( des , "BAND_INDEX" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element BAND_INDEX" ); - goto ERREUR; - } - -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element Look_Angles_List */ -/*****************************************************************************/ - - /* sous element Look_Angles_List */ - - cr = cai_WriteOpenTagXML ( des , "Look_Angles_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Look_Angles_List" ); - goto ERREUR; - } - - - /* sous element Look_Angles */ - - cr = cai_WriteOpenTagXML ( des , "Look_Angles" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Look_Angles" ); - goto ERREUR; - } - - /* sous element DETECTOR_ID */ - - cr = cai_WriteElementXML ( des , "DETECTOR_ID" , "1" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element DETECTOR_ID" ); - goto ERREUR; - } -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : DIMAP tag LOOK_ANGLE_LIST valeurs de PSI_X et */ -/* PSI_Y 1er et dernier detecteur inverses */ -/*****************************************************************************/ - - /* sous element PSI_X */ - - sprintf ( valeur , "%lf" , psi_x_last[j-2] ); - cr = cai_WriteElementXML ( des , "PSI_X" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element PSI_X" ); - goto ERREUR; - } - - /* sous element PSI_Y */ - - sprintf ( valeur , "%lf" , psi_y_last[j-2] ); - cr = cai_WriteElementXML ( des , "PSI_Y" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element PSI_Y" ); - goto ERREUR; - } - - /* Fermeture de l'element Look_Angles */ - - cr = cai_WriteCloseTagXML ( des , "Look_Angles" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Look_Angles" ); - goto ERREUR; - } - - /* sous element Look_Angles */ - - cr = cai_WriteOpenTagXML ( des , "Look_Angles" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Look_Angles" ); - goto ERREUR; - } - - /* sous element DETECTOR_ID */ - -/*****************************************************************************/ -/* MOD : VERSION : 4.5 : FA : erreur d'ecriture detector_id lookangle pour */ -/* PAN */ -/*****************************************************************************/ - - if ( nb_bs == 1 ) - detect_id = 6000; - else - detect_id = 3000; - - sprintf ( valeur , "%d" , detect_id ); - - cr = cai_WriteElementXML ( des , "DETECTOR_ID" , valeur ); - - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element DETECTOR_ID" ); - goto ERREUR; - } - - /* sous element PSI_X */ - - sprintf ( valeur , "%lf" , psi_x_first[j-2] ); - cr = cai_WriteElementXML ( des , "PSI_X" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element PSI_X" ); - goto ERREUR; - } - - /* sous element PSI_Y */ - - sprintf ( valeur , "%lf" , psi_y_first[j-2] ); - cr = cai_WriteElementXML ( des , "PSI_Y" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element PSI_Y" ); - goto ERREUR; - } - - /* Fermeture de l'element Look_Angles */ - - cr = cai_WriteCloseTagXML ( des , "Look_Angles" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Look_Angles" ); - goto ERREUR; - } - - /* Fermeture de l'element Look_Angles_List */ - - cr = cai_WriteCloseTagXML ( des , "Look_Angles_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Look_Angles_List" ); - goto ERREUR; - } - - /* Fermeture de l'element Instrument_Look_Angles */ - - cr = cai_WriteCloseTagXML ( des , "Instrument_Look_Angles" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Instrument_Look_Angles" ); - goto ERREUR; - } - j++; - - } - - /* Fermeture de l'element Instrument_Look_Angles_List */ - - cr = cai_WriteCloseTagXML ( des , "Instrument_Look_Angles_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Instrument_Look_Angles_List" ); - goto ERREUR; - } - - /* sous element Mirror_Position */ - - cr = cai_WriteOpenTagXML ( des , "Mirror_Position" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Mirror_Position" ); - goto ERREUR; - } - - /* sous element STEP_COUNT */ - - cr = cai_WriteElementXML ( des , "STEP_COUNT" , mirror_step ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element STEP_COUNT" ); - goto ERREUR; - } - - /* Fermeture de l'element Mirror_Position */ - - cr = cai_WriteCloseTagXML ( des , "Mirror_Position" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Mirror_Position" ); - goto ERREUR; - } - - /* Fermeture de l'element Sensor_Configuration */ - - cr = cai_WriteCloseTagXML ( des , "Sensor_Configuration" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Sensor_Configuration" ); - goto ERREUR; - } - - /* sous element Frame_Counters */ - - cr = cai_WriteOpenTagXML ( des , "Frame_Counters" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Frame_Counters" ); - goto ERREUR; - } - - /* sous element SEGMENT_START */ - - cr = cai_WriteElementXML ( des , "SEGMENT_START" , segmentstart ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SEGMENT_START" ); - goto ERREUR; - } - - /* sous element SCENE_START */ - - cr = cai_WriteElementXML ( des , "SCENE_START" , scenestart ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SCENE_START" ); - goto ERREUR; - } - - /* sous element SEGMENT_END */ - - cr = cai_WriteElementXML ( des , "SEGMENT_END" , segmentend ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SEGMENT_END" ); - goto ERREUR; - } - - /* Fermeture de l'element Frame_Counters */ - - cr = cai_WriteCloseTagXML ( des , "Frame_Counters" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Frame_Counters" ); - goto ERREUR; - } - - /* sous element Data_Strip_Coordinates */ - - cr = cai_WriteOpenTagXML ( des , "Data_Strip_Coordinates" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Data_Strip_Coordinates" ); - goto ERREUR; - } - - /* sous element FIRST_PIXEL_RAW */ - - cr = cai_WriteElementXML ( des , "FIRST_PIXEL_RAW" , fpixraw ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element FIRST_PIXEL_RAW" ); - goto ERREUR; - } - - /* sous element FIRST_LINE_RAW */ - - cr = cai_WriteElementXML ( des , "FIRST_LINE_RAW" , flineraw ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element FIRST_LINE_RAW" ); - goto ERREUR; - } - - /* sous element FIRST_PIXEL_1B */ - - cr = cai_WriteElementXML ( des , "FIRST_PIXEL_1B" , fpix1b ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element FIRST_PIXEL_1B" ); - goto ERREUR; - } - - /* sous element FIRST_LINE_1B */ - - cr = cai_WriteElementXML ( des , "FIRST_LINE_1B" , fline1b ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element FIRST_LINE_1B" ); - goto ERREUR; - } - - /* Fermeture de l'element Data_Strip_Coordinates */ - - cr = cai_WriteCloseTagXML ( des , "Data_Strip_Coordinates" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Data_Strip_Coordinates" ); - goto ERREUR; - } - - /* sous element Models */ - - cr = cai_WriteOpenTagXML ( des , "Models" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Models" ); - goto ERREUR; - } - - /* sous element OneB_Model */ - - cr = cai_WriteOpenTagXML ( des , "OneB_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element OneB_Model" ); - goto ERREUR; - } - - /* sous element Coordinate_Normalization */ - - cr = cai_WriteOpenTagXML ( des , "Coordinate_Normalization" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Coordinate_Normalization" ); - goto ERREUR; - } - - /* sous element LINES_I_M */ - - cr = cai_WriteElementXML ( des , "LINES_I_M" , im ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element LINES_I_M" ); - goto ERREUR; - } - - /* sous element LINES_DELTA_I */ - - cr = cai_WriteElementXML ( des , "LINES_DELTA_I" , deltai ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element LINES_DELTA_I" ); - goto ERREUR; - } - - /* sous element COLUMNS_J_M */ - - cr = cai_WriteElementXML ( des , "COLUMNS_J_M" , jm ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element COLUMNS_J_M" ); - goto ERREUR; - } - - /* sous element COLUMNS_DELTA_J */ - - cr = cai_WriteElementXML ( des , "COLUMNS_DELTA_J" , deltaj ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element COLUMNS_DELTA_J" ); - goto ERREUR; - } - - /* sous element LINES_L_M */ - - cr = cai_WriteElementXML ( des , "LINES_L_M" , lm ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element LINES_L_M" ); - goto ERREUR; - } - - /* sous element LINES_DELTA_L */ - - cr = cai_WriteElementXML ( des , "LINES_DELTA_L" , deltal ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element LINES_DELTA_L" ); - goto ERREUR; - } - - /* sous element COLUMNS_P_M */ - - cr = cai_WriteElementXML ( des , "COLUMNS_P_M" , pm ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element COLUMNS_P_M" ); - goto ERREUR; - } - - /* sous element COLUMNS_DELTA_P */ - - cr = cai_WriteElementXML ( des , "COLUMNS_DELTA_P" , deltap ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element COLUMNS_DELTA_P" ); - goto ERREUR; - } - - /* Fermeture de l'element Coordinate_Normalization */ - - cr = cai_WriteCloseTagXML ( des , "Coordinate_Normalization" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Coordinate_Normalization" ); - goto ERREUR; - } - - /* sous element Direct_OneB_Model */ - - cr = cai_WriteOpenTagXML ( des , "Direct_OneB_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Direct_OneB_Model" ); - goto ERREUR; - } - - /* sous element I */ - - cr = cai_WriteOpenTagXML ( des , "I" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element I" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , coeffi ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , ai ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , bi ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , ci ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , di ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , ei ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element c" ); - goto ERREUR; - } - - /* Fermeture de l'element I */ - - cr = cai_WriteCloseTagXML ( des , "I" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element I" ); - goto ERREUR; - } - - /* sous element J */ - - cr = cai_WriteOpenTagXML ( des , "J" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element J" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , coeffj ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , aj ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , bj ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , cj ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element c" ); - goto ERREUR; - } - - /* Fermeture de l'element J */ - - cr = cai_WriteCloseTagXML ( des , "J" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element J" ); - goto ERREUR; - } - - /* Fermeture de l'element Direct_OneB_Model */ - - cr = cai_WriteCloseTagXML ( des , "Direct_OneB_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Direct_OneB_Model" ); - goto ERREUR; - } - - /* sous element Reverse_OneB_Model */ - - cr = cai_WriteOpenTagXML ( des , "Reverse_OneB_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Reverse_OneB_Model" ); - goto ERREUR; - } - - /* sous element L */ - - cr = cai_WriteOpenTagXML ( des , "L" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element L" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , coeff_l ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , a_l ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , b_l ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , c_l ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , d_l ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , e_l ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element c" ); - goto ERREUR; - } - - /* Fermeture de l'element L */ - - cr = cai_WriteCloseTagXML ( des , "L" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element L" ); - goto ERREUR; - } - - /* sous element P */ - - cr = cai_WriteOpenTagXML ( des , "P" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element P" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , coeff_p ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , a_p ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , b_p ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , c_p ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element c" ); - goto ERREUR; - } - - /* Fermeture de l'element P */ - - cr = cai_WriteCloseTagXML ( des , "P" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element P" ); - goto ERREUR; - } - - /* Fermeture de l'element Reverse_OneB_Model */ - - cr = cai_WriteCloseTagXML ( des , "Reverse_OneB_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Reverse_OneB_Model" ); - goto ERREUR; - } - - /* sous element A */ - - cr = cai_WriteOpenTagXML ( des , "A" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element A" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , coeff_a ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , aa ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , ba ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , ca ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , da ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element c" ); - goto ERREUR; - } - - /* Fermeture de l'element A */ - - cr = cai_WriteCloseTagXML ( des , "A" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element A" ); - goto ERREUR; - } - - /* sous element B */ - - cr = cai_WriteOpenTagXML ( des , "B" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element B" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , coeff_b ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , ab ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , bb ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , cb ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , db ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , eb ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element c" ); - goto ERREUR; - } - - /* Fermeture de l'element B */ - - cr = cai_WriteCloseTagXML ( des , "B" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element B" ); - goto ERREUR; - } - - /* Fermeture de l'element OneB_Model */ - - cr = cai_WriteCloseTagXML ( des , "OneB_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element OneB_Model" ); - goto ERREUR; - } - - /* sous element Attitude_Model */ - - cr = cai_WriteOpenTagXML ( des , "Attitude_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Attitude_Model" ); - goto ERREUR; - } - - /* sous element D_L */ - - cr = cai_WriteOpenTagXML ( des , "D_L" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element D_L" ); - goto ERREUR; - } - - /* sous element abc */ - - cr = cai_WriteElementXML ( des , "abc" , al ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element abc" ); - goto ERREUR; - } - - /* sous element abc */ - - cr = cai_WriteElementXML ( des , "abc" , bl ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element abc" ); - goto ERREUR; - } - - /* sous element abc */ - - cr = cai_WriteElementXML ( des , "abc" , cl ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element abc" ); - goto ERREUR; - } - - /* Fermeture de l'element D_L */ - - cr = cai_WriteCloseTagXML ( des , "D_L" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element D_L" ); - goto ERREUR; - } - - /* sous element D_P */ - - cr = cai_WriteOpenTagXML ( des , "D_P" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element D_P" ); - goto ERREUR; - } - - /* sous element abc */ - - cr = cai_WriteElementXML ( des , "abc" , ap ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element abc" ); - goto ERREUR; - } - - /* sous element abc */ - - cr = cai_WriteElementXML ( des , "abc" , bp ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element abc" ); - goto ERREUR; - } - - /* sous element abc */ - - cr = cai_WriteElementXML ( des , "abc" , cp ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element abc" ); - goto ERREUR; - } - - /* Fermeture de l'element D_P */ - - cr = cai_WriteCloseTagXML ( des , "D_P" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element D_P" ); - goto ERREUR; - } - - /* Fermeture de l'element Attitude_Model */ - - cr = cai_WriteCloseTagXML ( des , "Attitude_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Attitude_Model" ); - goto ERREUR; - } - - /* sous element SWIR_Registration_Model */ - - cr = cai_WriteOpenTagXML ( des , "SWIR_Registration_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SWIR_Registration_Model" ); - goto ERREUR; - } - - /* sous element D_L */ - - cr = cai_WriteOpenTagXML ( des , "D_L" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element D_L" ); - goto ERREUR; - } - - /* sous element abc */ - - cr = cai_WriteElementXML ( des , "abc" , alswir ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element abc" ); - goto ERREUR; - } - - /* sous element abc */ - - cr = cai_WriteElementXML ( des , "abc" , blswir ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element abc" ); - goto ERREUR; - } - - /* sous element abc */ - - cr = cai_WriteElementXML ( des , "abc" , clswir ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element abc" ); - goto ERREUR; - } - - /* Fermeture de l'element D_L */ - - cr = cai_WriteCloseTagXML ( des , "D_L" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element D_L" ); - goto ERREUR; - } - - /* sous element D_P */ - - cr = cai_WriteOpenTagXML ( des , "D_P" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element D_P" ); - goto ERREUR; - } - - /* sous element abc */ - - cr = cai_WriteElementXML ( des , "abc" , apswir ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element abc" ); - goto ERREUR; - } - - /* sous element abc */ - - cr = cai_WriteElementXML ( des , "abc" , bpswir ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element abc" ); - goto ERREUR; - } - - /* sous element abc */ - - cr = cai_WriteElementXML ( des , "abc" , cpswir ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element abc" ); - goto ERREUR; - } - - /* Fermeture de l'element D_P */ - - cr = cai_WriteCloseTagXML ( des , "D_P" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element D_P" ); - goto ERREUR; - } - - /* Fermeture de l'element SWIR_Registration_Model */ - - cr = cai_WriteCloseTagXML ( des , "SWIR_Registration_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SWIR_Registration_Model" ); - goto ERREUR; - } - - /* Fermeture de l'element Models */ - - cr = cai_WriteCloseTagXML ( des , "Models" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Models" ); - goto ERREUR; - } - /* sous element Sensor_Calibration */ - - cr = cai_WriteOpenTagXML ( des , "Sensor_Calibration" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Sensor_Calibration" ); - goto ERREUR; - } - - /* sous element METHOD */ - - cr = cai_WriteElementXML ( des , "METHOD" , "system" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element METHOD" ); - - goto ERREUR; - } - - /* sous element Calibration */ - - cr = cai_WriteOpenTagXML ( des , "Calibration" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Calibration" ); - goto ERREUR; - } - - for ( j = 0; j < nb_bs ; j++ ) - { - /* sous element Band_Parameters */ - - cr = cai_WriteOpenTagXML ( des , "Band_Parameters" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Band_Parameters" ); - goto ERREUR; - } - - /* sous element BAND_INDEX */ - sprintf ( valeur , "%d" , (j+1) ); - - cr = cai_WriteElementXML ( des , "BAND_INDEX" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element BAND_INDEX" ); - goto ERREUR; - } - - /* sous element Gain_Section */ - - cr = cai_WriteOpenTagXML ( des , "Gain_Section" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Gain_Section" ); - goto ERREUR; - } - - /* sous element GAIN_NUMBER */ - - cr = cai_WriteElementXML ( des , "GAIN_NUMBER" , nb_gains[j] ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element GAIN_NUMBER" ); - goto ERREUR; - } - - /* sous element GAIN_ANALOG_VALUE */ - - cr = cai_WriteElementXML ( des , "GAIN_ANALOG_VALUE" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element GAIN_ANALOG_VALUE" ); - goto ERREUR; - } - - /* sous element Pixel_Parameters */ - - cr = cai_WriteOpenTagXML ( des , "Pixel_Parameters" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Pixel_Parameters" ); - goto ERREUR; - } - - /* sous element G_DATE */ - - cr = cai_WriteElementXML ( des , "G_DATE" , relativedatecalib[2*j] ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element G_DATE" ); - goto ERREUR; - } - - /* sous element DC_DATE */ - - cr = cai_WriteElementXML ( des , "DC_DATE" , relativedatecalib[2*j+nb_bs*2] ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element DC_DATE" ); - goto ERREUR; - } - - /* sous element Cells */ - - cr = cai_WriteOpenTagXML ( des , "Cells" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Cells" ); - goto ERREUR; - } - - if ( nb_bs == 1 ) - { - for ( i = 0 ; i < 4 ; i ++ ) - { /* MOD : VERSION 4.6 : FA : initialisation de ind_tab_gain dans la boucle */ - for ( ind_tab_gain = 0 ; ind_tab_gain < 1500 ; ind_tab_gain ++ ) - { - - /* sous element Cell */ - - cr = cai_WriteOpenTagXML ( des , "Cell" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Cell" ); - goto ERREUR; - } - - /* sous element G */ - - sprintf ( valeur , "%5.4f" , gain_value[i][ind_tab_gain] ); - - cr = cai_WriteElementXML ( des , "G" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element G" ); - goto ERREUR; - } - - /* sous element DARK_CURRENT */ - - sprintf ( valeur , "%2.1f" , dark_value[i][ind_tab_gain] ); - - cr = cai_WriteElementXML ( des , "DARK_CURRENT" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element DARK_CURRENT" ); - goto ERREUR; - } - - /* Fermeture de l'element Cell */ - - cr = cai_WriteCloseTagXML ( des , "Cell" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Cell" ); - goto ERREUR; - } - } - } - } - else - { - for ( i = 2*j ; i < 2*j+2 ; i++ ) - { - for ( ind_tab_gain = 0 ; ind_tab_gain < 1500 ; ind_tab_gain ++ ) - { - /* sous element Cell */ - - cr = cai_WriteOpenTagXML ( des , "Cell" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Cell" ); - goto ERREUR; - } - - /* sous element G */ - - sprintf ( valeur , "%5.4f" , gain_value[i][ind_tab_gain] ); - - cr = cai_WriteElementXML ( des , "G" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element G" ); - goto ERREUR; - } - - /* sous element DARK_CURRENT */ - - sprintf ( valeur , "%2.1f" , dark_value[i][ind_tab_gain] ); - - cr = cai_WriteElementXML ( des , "DARK_CURRENT" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element DARK_CURRENT" ); - goto ERREUR; - } - - /* Fermeture de l'element Cell */ - - cr = cai_WriteCloseTagXML ( des , "Cell" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Cell" ); - goto ERREUR; - } - } - } - } - - /* Fermeture de l'element Cells */ - - cr = cai_WriteCloseTagXML ( des , "Cells" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Cells" ); - goto ERREUR; - } - - /* Fermeture de l'element Pixel_Parameters */ - - cr = cai_WriteCloseTagXML ( des , "Pixel_Parameters" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Pixel_Parameters" ); - goto ERREUR; - } - - /* Fermeture de l'element Gain_Section */ - - cr = cai_WriteCloseTagXML ( des , "Gain_Section" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Gain_Section" ); - goto ERREUR; - } - - /* sous element Dead_Detectors */ - - cr = cai_WriteOpenTagXML ( des , "Dead_Detectors" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Dead_Detectors" ); - goto ERREUR; - } - - /* sous element VALIDITY_DATE */ - - cr = cai_WriteElementXML ( des , "VALIDITY_DATE" , - relativedatecalib[2*j+1] ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element VALIDITY_DATE" ); - goto ERREUR; - } - - /* sous element Bad_Pixels */ - - cr = cai_WriteOpenTagXML ( des , "Bad_Pixels" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Bad_Pixels" ); - goto ERREUR; - } - - if ( nb_bs == 1 ) - { - for ( i = 0 ; i < 4 ; i ++ ) - { - for ( ind_tab_gain = 0; ind_tab_gain < 1500 ; ind_tab_gain ++ ) - { - if ( gain_value[i][ind_tab_gain] == (float) 0 ) - { - /* sous element Bad_Pixel */ - - cr = cai_WriteOpenTagXML ( des , "Bad_Pixel" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Bad_Pixel" ); - goto ERREUR; - } - - /* sous element PIXEL_INDEX */ -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : FA : Correction de */ -/* sprintf(valeur,"%d", (ind_tab_gain+1+1500*i)) au lieu de */ -/* sprintf(valeur,"%f", (ind_tab_gain+1+1500*i)) */ -/*****************************************************************************/ - - sprintf ( valeur , "%d" , (ind_tab_gain+1+1500*i) ); - cr = cai_WriteElementXML ( des , "PIXEL_INDEX" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element PIXEL_INDEX" ); - goto ERREUR; - } - - /* sous element BAD_PIXEL_STATUS */ - - cr = cai_WriteElementXML ( des , - "BAD_PIXEL_STATUS" , "ABERRANT" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element BAD_PIXEL_STATUS" ); - goto ERREUR; - } - - /* Fermeture de l'element Bad_Pixel */ - - cr = cai_WriteCloseTagXML ( des , "Bad_Pixel" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Bad_Pixel" ); - goto ERREUR; - } - } - } - } - } - else - { - nb_passage = 0; - for ( i = 2*j ; i < j*2 + 2 ; i++ ) - { - for ( ind_tab_gain = 0 ; ind_tab_gain < 1500 ; ind_tab_gain ++ ) - { - if ( gain_value[i][ind_tab_gain] == (float) 0 ) - { - /* sous element Bad_Pixel */ - - cr = cai_WriteOpenTagXML ( des , "Bad_Pixel" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Bad_Pixel" ); - goto ERREUR; - } - - /* sous element PIXEL_INDEX */ - - sprintf ( valeur , "%d" , ( ind_tab_gain+1+1500*nb_passage ) ); - cr = cai_WriteElementXML ( des , "PIXEL_INDEX" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element PIXEL_INDEX" ); - goto ERREUR; - } - - /* sous element BAD_PIXEL_STATUS */ - - cr = cai_WriteElementXML ( des , - "BAD_PIXEL_STATUS" , "ABERRANT" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element BAD_PIXEL_STATUS" ); - goto ERREUR; - } - - /* Fermeture de l'element Bad_Pixel */ - - cr = cai_WriteCloseTagXML ( des , "Bad_Pixel" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Bad_Pixel" ); - goto ERREUR; - } - } - } - if ( nb_passage == 0 ) - nb_passage = 1; - else - nb_passage = 0; - - } - } - - /* Fermeture de l'element Bad_Pixels */ - - cr = cai_WriteCloseTagXML ( des , "Bad_Pixels" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Bad_Pixels" ); - goto ERREUR; - } - - /* Fermeture de l'element Dead_Detectors */ - - cr = cai_WriteCloseTagXML ( des , "Dead_Detectors" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Dead_Detectors" ); - goto ERREUR; - } - - /* Fermeture de l'element Band_Parameters */ - - cr = cai_WriteCloseTagXML ( des , "Band_Parameters" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Band_Parameters" ); - goto ERREUR; - } - } - /* Fermeture de l'element Calibration */ - - cr = cai_WriteCloseTagXML ( des , "Calibration" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Calibration" ); - goto ERREUR; - } - - /* sous element Spectral_Sensitivities */ - - cr = cai_WriteOpenTagXML ( des , "Spectral_Sensitivities" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Spectral_Sensitivities" ); - goto ERREUR; - } - - - for ( j = 0; j < nb_bs ; j++ ) - { - - /* sous element Band_Spectral_Sensitivities */ - - cr = cai_WriteOpenTagXML ( des , "Band_Spectral_Sensitivities" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Band_Spectral_Sensitivities" ); - goto ERREUR; - } - - sprintf( valeur , "%d" , ( j+1 ) ); - /* sous element BAND_INDEX */ - - cr = cai_WriteElementXML ( des , "BAND_INDEX" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element BAND_INDEX" ); - goto ERREUR; - } - - /* sous element FIRST_WAVELENGTH_VALUE */ - - cr = cai_WriteElementXML ( des , - "FIRST_WAVELENGTH_VALUE" , firstwave[j] ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element FIRST_WAVELENGTH_VALUE" ); - goto ERREUR; - } - - /* sous element WAVELENGTH_STEP */ - - cr = cai_WriteElementXML ( des , - "WAVELENGTH_STEP" , wavelengthstep[j] ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element WAVELENGTH_STEP" ); - goto ERREUR; - } - - /* sous element CALIBRATION_DATE */ - - cr = cai_WriteElementXML ( des , "CALIBRATION_DATE" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element CALIBRATION_DATE" ); - goto ERREUR; - } - - /* sous element Spectral_Sensitivity_Values */ - - cr = cai_WriteOpenTagXML ( des , "Spectral_Sensitivity_Values" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Spectral_Sensitivity_Values" ); - goto ERREUR; - } - - for ( ind_tab_gain = 0 ; ind_tab_gain < 64 ; ind_tab_gain++ ) - { - - /* sous element SPECTRAL_SENSITIVITY_VALUE */ - - cr = cai_WriteElementXML ( des , "SPECTRAL_SENSITIVITY_VALUE" , - spectral_sensitivitie[j][ind_tab_gain] ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SPECTRAL_SENSITIVITY_VALUE" ); - goto ERREUR; - } - } - - /* Fermeture de l'element Spectral_Sensitivity_Values */ - - cr = cai_WriteCloseTagXML ( des , "Spectral_Sensitivity_Values" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Spectral_Sensitivity_Values" ); - goto ERREUR; - } - - /* Fermeture de l'element Band_Spectral_Sensitivities */ - - cr = cai_WriteCloseTagXML ( des , "Band_Spectral_Sensitivities" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Band_Spectral_Sensitivities" ); - goto ERREUR; - } - } - - /* Fermeture de l'element Spectral_Sensitivities */ - - cr = cai_WriteCloseTagXML ( des , "Spectral_Sensitivities" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Spectral_Sensitivities" ); - goto ERREUR; - } - - /* sous element Solar_Irradiance */ - - cr = cai_WriteOpenTagXML ( des , "Solar_Irradiance" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Solar_Irradiance" ); - goto ERREUR; - } - - for ( j = 0; j < nb_bs ; j++ ) - { - sprintf ( valeur , "%d" , ( j+1 ) ); - /* sous element Band_Solar_Irradiance */ - - cr = cai_WriteOpenTagXML ( des , "Band_Solar_Irradiance" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Band_Solar_Irradiance" ); - goto ERREUR; - } - - /* sous element BAND_INDEX */ - - cr = cai_WriteElementXML ( des , "BAND_INDEX" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element BAND_INDEX" ); - goto ERREUR; - } - - /* sous element SOLAR_IRRADIANCE_VALUE */ - - cr = cai_WriteElementXML ( des , "SOLAR_IRRADIANCE_VALUE" , - solar_irradiance[j] ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element SOLAR_IRRADIANCE_VALUE" ); - goto ERREUR; - } - - /* Fermeture de l'element Band_Solar_Irradiance */ - - cr = cai_WriteCloseTagXML ( des , "Band_Solar_Irradiance" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Band_Solar_Irradiance" ); - goto ERREUR; - } - } - /* Fermeture de l'element Solar_Irradiance */ - - cr = cai_WriteCloseTagXML ( des , "Solar_Irradiance" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Solar_Irradiance" ); - goto ERREUR; - } - - /* Fermeture de l'element Sensor_Calibration */ - - cr = cai_WriteCloseTagXML ( des , "Sensor_Calibration" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Sensor_Calibration" ); - goto ERREUR; - } - -/* MOD : VERSION : 4.6 : FA : pas d'écriture <badlines> si pas de badlines */ -/* le test s'effectue pour chaque canal */ - Bad=0; - for (can=0;can<nb_bs;can++) - BadFlag[can]=0; - can=0; - j=0; - while ((can<nb_bs)&&(BadFlag[can]==0)) - { - j=0; - while ((j<nb_lig)&&(BadFlag[can]==0)) - { - if ( bad_line[j][can] != 0) - { - BadFlag[can]=1; - Bad=1; - } - j=j+1; - } - can=can+1; - } - - if (Bad==1) - { - - /* sous element Bad_Lines */ - - cr = cai_WriteOpenTagXML ( des , "Bad_Lines" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Bad_Lines" ); - goto ERREUR; - } - } - - for ( can = 0 ; can < nb_bs ; can++ ) - { - if (BadFlag[can]==1) - { - - sprintf ( valeur , "%d" , (can+1) ); - - /* sous element Band_Bad_Lines */ - - cr = cai_WriteOpenTagXML ( des , "Band_Bad_Lines" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Band_Bad_Lines" ); - goto ERREUR; - } - - /* sous element BAND_INDEX */ - - cr = cai_WriteElementXML ( des , "BAND_INDEX" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element BAND_INDEX" ); - goto ERREUR; - } - -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element Bad_Line_List */ -/*****************************************************************************/ - - /* sous element Bad_Line_List */ - - cr = cai_WriteOpenTagXML ( des , "Bad_Line_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Bad_Line_List" ); - goto ERREUR; - } - - for ( j = 0; j < nb_lig ; j++ ) - { - if ( bad_line[j][can] == 1 ) - { - /* sous element Bad_Line */ - - cr = cai_WriteOpenTagXML ( des , "Bad_Line" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Bad_Line" ); - goto ERREUR; - } - - /* sous element BL_INDEX */ - - sprintf ( valeur , "%d" , ( j+1 ) ); - - cr = cai_WriteElementXML ( des , "BL_INDEX" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element BL_INDEX" ); - goto ERREUR; - } - - /* sous element BL_STATUS */ -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : FA : mot cle lignes perdues LOST au lieu de LOSS */ -/*****************************************************************************/ - cr = cai_WriteElementXML ( des , "BL_STATUS" , "LOST" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element BL_STATUS" ); - goto ERREUR; - } - - /* Fermeture de l'element Bad_Line */ - - cr = cai_WriteCloseTagXML ( des , "Bad_Line" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Bad_Line" ); - goto ERREUR; - } - } - else - { - if ( bad_line[j][can] == 2 ) - { - /* sous element Bad_Line */ - - cr = cai_WriteOpenTagXML ( des , "Bad_Line" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Bad_Line" ); - goto ERREUR; - } - - /* sous element BL_INDEX */ - - sprintf ( valeur , "%d" , ( j+1 ) ); - - cr = cai_WriteElementXML ( des , "BL_INDEX" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element BL_INDEX" ); - goto ERREUR; - } - - /* sous element BL_STATUS */ - - cr = cai_WriteElementXML ( des , "BL_STATUS" , "DEGRADED" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element BL_STATUS" ); - goto ERREUR; - } - - /* Fermeture de l'element Bad_Line */ - - cr = cai_WriteCloseTagXML ( des , "Bad_Line" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Bad_Line" ); - goto ERREUR; - } - } - } - } /* Fin boucle sur les lignes */ - - /* Fermeture de l'element Bad_Line_List */ - - cr = cai_WriteCloseTagXML ( des , "Bad_Line_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Bad_Line_List" ); - goto ERREUR; - } - - /* Fermeture de l'element Band_Bad_Lines */ - - cr = cai_WriteCloseTagXML ( des , "Band_Bad_Lines" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Band_Bad_Lines" ); - goto ERREUR; - } - - } - } - if (Bad==1) - { - - /* Fermeture de l'element Bad_Lines */ - - cr = cai_WriteCloseTagXML ( des , "Bad_Lines" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Bad_Lines" ); - goto ERREUR; - } - - } - /* Fermeture de l'element Data_Strip */ - - cr = cai_WriteCloseTagXML ( des , "Data_Strip" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Data_Strip" ); - goto ERREUR; - } - - /* Fermeture de l'element Dimap_Document */ - - cr = cai_WriteCloseTagXML ( des , "Dimap_Document" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Dimap_Document" ); - goto ERREUR; - } - - /* fermeture du fichier descripteur */ - - if (des!=NULL) fclose ( des ); - return CAI_OK; - - ERREUR: - return CAI_KO; - } -/* - Fin de l'operation cai_lead4to5spot -*/ - -/******************************************************************************/ -/******************************************************************************/ -/* */ -/* Definition des OPERATIONS INTERNES */ -/* */ -/******************************************************************************/ -/******************************************************************************/ - -/******************************************************************************/ -/* */ -/*OPERATION : cai_ElementWriteXML */ -/* */ -/*ROLE : Cette operation ecrit un element XML dans le fichier donne en */ -/* parametre */ -/* */ -/*CONTEXTE D'APPEL : */ -/* */ -/* RETOUR : CAI_OK ou CAI_KO */ -/* */ -/******************************************************************************/ - -static CAI_OK_KO cai_WriteElementXML ( FILE *desc , char *motCle , char *valeur ) - { - char *BaliseXmlOpen; - char *BaliseXmlClose; - - BaliseXmlOpen = (char*) NULL; - BaliseXmlOpen = (char*) calloc ( strlen ( motCle ) + 3 , sizeof ( char ) ); - - BaliseXmlClose = (char*) NULL; - BaliseXmlClose = (char*) calloc ( strlen ( motCle ) + 4 , sizeof ( char ) ); - - sprintf ( BaliseXmlOpen , "<%s>" , motCle ); - sprintf ( BaliseXmlClose , "</%s>" , motCle ); - - fprintf ( desc , "%s%s%s\n" , BaliseXmlOpen , valeur , BaliseXmlClose ); - - FREE ( BaliseXmlClose ); - FREE ( BaliseXmlOpen ); - return CAI_OK; - - } -/* - Fin de l'operation cai_WriteElementXML -*/ -/******************************************************************************/ -/* */ -/*OPERATION : cai_ElementWriteXMLWithAttribute */ -/* */ -/*ROLE : Cette operation ecrit un element XML dans le fichier donne en */ -/* parametre */ -/* */ -/*CONTEXTE D'APPEL : */ -/* */ -/* RETOUR : CAI_OK ou CAI_KO */ -/* */ -/******************************************************************************/ - -static CAI_OK_KO cai_WriteElementXMLWithAttribute ( FILE *desc , - char *motCle , - char *valeur, - char *attribut, - char *valat , - int type) - { - char *BaliseXmlOpen; - char *BaliseXmlClose; - - BaliseXmlOpen = (char*) NULL; - BaliseXmlOpen = (char*) calloc ( strlen ( motCle ) + - strlen ( attribut ) + - strlen ( valat ) + 10 , sizeof ( char ) ); - - BaliseXmlClose = (char*) NULL; - BaliseXmlClose = (char*) calloc ( strlen ( motCle ) + 4 , sizeof ( char ) ); - if (type==0) - sprintf ( BaliseXmlOpen , "<%s %s='%s'>" , motCle , attribut , valat ); - else - sprintf ( BaliseXmlOpen , "<%s %s=\"%s\">" , motCle , attribut , valat ); - sprintf ( BaliseXmlClose , "</%s>" , motCle ); - - fprintf ( desc , "%s%s%s\n" , BaliseXmlOpen , valeur , BaliseXmlClose ); - - FREE ( BaliseXmlClose ); - FREE ( BaliseXmlOpen ); - return CAI_OK; - - } - -/******************************************************************************/ -/* */ -/*OPERATION : cai_WriteOpenTagXML */ -/* */ -/*ROLE : Cette operation ecrit une balise ouvrante XML dans le fichier donne */ -/* en parametre */ -/* */ -/*CONTEXTE D'APPEL : */ -/* */ -/* RETOUR : CAI_OK ou CAI_KO */ -/* */ -/******************************************************************************/ - -static CAI_OK_KO cai_WriteOpenTagXML ( FILE *des , char *TagName ) - { - fprintf ( des , "<%s>\n" , TagName ); - return CAI_OK; - } -/* - Fin de l'operation cai_WriteOpenTagXML -*/ - -/******************************************************************************/ -/* */ -/*OPERATION : cai_WriteCloseTagXML */ -/* */ -/*ROLE : Cette operation ecrit une balise fermante XML dans le fichier donne */ -/* en parametre */ -/* */ -/*CONTEXTE D'APPEL : */ -/* */ -/* RETOUR : CAI_OK ou CAI_KO */ -/* */ -/******************************************************************************/ - -static CAI_OK_KO cai_WriteCloseTagXML ( FILE *des , char *TagName ) - { - fprintf ( des , "</%s>\n" , TagName ); - return CAI_OK; - } -/* - Fin de l'operation cai_WriteCloseTagXML -*/ - -/******************************************************************************/ -/* */ -/*OPERATION : cai_WriteNulTagXML */ -/* */ -/*ROLE : Cette operation ecrit une balise vide XML dans le fichier donne */ -/* en parametre */ -/* */ -/*CONTEXTE D'APPEL : */ -/* */ -/* RETOUR : CAI_OK ou CAI_KO */ -/* */ -/******************************************************************************/ - -static CAI_OK_KO cai_WriteNulTagXML ( FILE *des , char *TagName ) - { - fprintf ( des , "<%s/>\n" , TagName ); - return CAI_OK; - } -/* - Fin de l'operation cai_WriteNulTagXML -*/ - -/******************************************************************************/ -/* */ -/*OPERATION : cai_WriteEnteteXML */ -/* */ -/*ROLE : Cette operation ecrit l'entete d'un document XML */ -/* */ -/*CONTEXTE D'APPEL : */ -/* */ -/* RETOUR : CAI_OK ou CAI_KO */ -/* */ -/******************************************************************************/ - -static CAI_OK_KO cai_WriteEnteteXML ( FILE *des ) - { - fprintf ( des , "<?xml version='1.0'?>\n" ); - return CAI_OK; } -/* - Fin de l'operation cai_WriteEnteteXML -*/ - -/******************************************************************************/ -/* */ -/*OPERATION : cai_DMS_To_Float */ -/* */ -/*ROLE : Cette operation convertie une latitude/longitude exprimee en DDDMMSS */ -/* sous forme de chaine de caracteres en Flotants */ -/* */ -/*CONTEXTE D'APPEL : */ -/* */ -/* RETOUR : la donnee exprimee en double */ -/* */ -/******************************************************************************/ - -static void cai_DMS_To_Float ( char DegMinSec [17] , double *Degre ) - { - /*-------------------------------*/ - /* debut du code de l'operation */ - /*-------------------------------*/ - int i; - int signe = 1; - long int ValD = 0 , ValM = 0; - double ValS = 0.0; - char ValDeg[4] = ""; - char ValMin[3] = ""; - char ValSec[6] = ""; - - if (strlen(DegMinSec) != 0) - { - /* Traitement du signe */ - - if ( (DegMinSec[0] == 'N') || (DegMinSec[0] == 'E') ) - signe = 1; - - if ( (DegMinSec[0] == 'S') || (DegMinSec[0] == 'W') ) - signe = -1; - - if ( (DegMinSec[0] == 'R') || ( DegMinSec[0] == '+') ) - signe = 1; - - if ( (DegMinSec[0] == 'L') || ( DegMinSec[0] == '-') ) - signe = -1; - - /* Traitement de la valeur absolue */ - - for ( i = 0 ; i < 3 ; i++ ) - ValDeg[i] = DegMinSec[i+1]; - - ValDeg[3] = '\0'; - sscanf( ValDeg , "%ld" , &ValD ); - - for ( i = 0 ; i < 2 ; i++ ) - ValMin[i] = DegMinSec[i+4]; - - ValMin[2] = '\0'; - sscanf( ValMin , "%ld" , &ValM ); - - for ( i = 0 ; i < 5 ; i++ ) - ValSec[i] = DegMinSec[i+6]; - - ValSec[5] = '\0'; - sscanf( ValSec , "%lf" , &ValS ); - - *Degre = (double)signe*((double)ValD + - (double)ValM/60.0 + (double)ValS/3600.0); - } - else - *Degre = 0.0; - - /*-----------------------------------------------*/ - /* fin du code de l'operation cai_DMS_To_Float */ - /*-----------------------------------------------*/ - } - -/******************************************************************************/ -/* */ -/*OPERATION : cai_JulToGreg */ -/* */ -/*ROLE : Convertir une date julienne en date gregorienne */ -/*ROLE : */ -/* */ -/*RETOUR : */ -/* */ -/******************************************************************************/ - -int nb_jours_mois[12] = { 31 , 28 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31 }; - -static void cai_JulToGreg ( long nbjours , double nbsec , char* dategreg ) - { - /*-----------------------------------*/ - /* Declaration des variables locales */ - /*-----------------------------------*/ - int an = ANNEE_DEBUT_JULIEN ; /* annee debut = 1950 */ - int nb_jour_an = NB_JOURS_AN_NON_BISSEX ; /* 1950 = annee non bissextile */ - int mois, jour, heure, minute, seconde, centieme ; - long jourjulien = 0 ; - double secjulien = 0. ; - - /*---------------------------------------*/ - /* DEBUT DE L'OPERATION cai_JulToGreg */ - /*---------------------------------------*/ - jourjulien = nbjours ; - secjulien = nbsec ; - - /*---------------------------------------*/ - /* Calculer l'annee gregorienne */ - /*---------------------------------------*/ - while ( jourjulien >= (long)nb_jour_an ) - { - an = an + 1; - jourjulien = jourjulien - (long)nb_jour_an ; - - /*------------------------------------------------*/ - /* si anne bissextile mettre a jour le nb_jour_an */ - /*------------------------------------------------*/ - if ( ( ((an%4) == 0) && ((an%100) != 0) ) || (an%400 == 0) ) - nb_jour_an = NB_JOURS_AN_BISSEX ; - else - nb_jour_an = NB_JOURS_AN_NON_BISSEX ; - } - - /*---------------------------------------*/ - /* Attention : si l'annee est bissextile */ - /* il faut modifier le mois de fevrier ! */ - /*---------------------------------------*/ - if ( nb_jour_an == NB_JOURS_AN_BISSEX ) - nb_jours_mois[1] = 29 ; - - /*---------------------------------------*/ - /* Calculer le mois */ - /*---------------------------------------*/ - mois = 0 ; - while ( jourjulien >= (long)nb_jours_mois[mois] ) - { - jourjulien = jourjulien - (long)nb_jours_mois[mois] ; - mois++; - } - - /*---------------------------------------*/ - /* Calculer le jour */ - /*---------------------------------------*/ - -/* MOD : VERSION : 4.5 : FA : erreur conversion jour julien dans CAI */ - jour = (int)jourjulien +1; - - /*---------------------------------------*/ - /* Calculer l'heure */ - /*---------------------------------------*/ - heure = (int) ( secjulien / 3600 ) ; - secjulien = secjulien - ( heure * 3600 ) ; - - /*---------------------------------------*/ - /* Calculer les minutes */ - /*---------------------------------------*/ - minute = (int) ( secjulien / 60 ) ; - secjulien = secjulien - ( minute * 60 ) ; - - /*---------------------------------------*/ - /* Calculer les secondes */ - /*---------------------------------------*/ - seconde = (int)secjulien ; - secjulien = secjulien - seconde ; - - /*---------------------------------------*/ - /* Calculer les centiemes */ - /*---------------------------------------*/ - centieme = (int) ( secjulien * 1000000.0 + 0.5 ) ; - - /*---------------------------------------*/ - /* Ecrire le resultat */ - /*---------------------------------------*/ -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ds les dates, utilisation du . au lieu de , */ -/* Separation de la date et heure par "T" */ -/*****************************************************************************/ - sprintf ( dategreg , "%.4d-%.2d-%.2dT%.2d:%.2d:%.2d.%.6d\0" , an , (mois +1) , - jour , heure , minute , seconde , centieme ); - - } -/* Fin de l'operation cai_JulToGreg */ - - - -/*------------------------------------------*/ -/* Debut de l'operation cai_DegreeToRadian */ - -static double cai_DegreeToRadian ( double angle_degree ) - { - return ( (angle_degree * (double )PI) / 180.0); - } -/* Fin de l'operation cai_DegreeToRadian */ - - - -/*-----------------------------------*/ -/* Debut de l'operation cai_addtime */ - -static int cai_addtime ( char ret[26] , char temps[18] , double milisec ) -{ -double sec; -long lesjours=0; -char retour[25]=""; -char variable[18]=""; -strcpy ( variable , temps ); - -sec = atof ( &variable[5] ) + milisec; -if ( sec < 0 ) - { - sec = -sec; - lesjours--; - } - -variable[5] = '\0'; -sscanf ( variable , "%ld" , &lesjours ); - -while ( sec >= NB_SEC_PAR_JOUR ) - { - lesjours++; - sec = sec - NB_SEC_PAR_JOUR ; - } - -cai_JulToGreg ( lesjours , sec , retour ); -strcpy ( ret , retour ); - -return CAI_OK; -} - -/* Fin de l'operation cai_addtime */ - -/****************************************************************/ -/* Fonction permettant de retourner le nom d'un fichier a partir*/ -/* du nom du repertoire qui le contient et du debut de son nom */ -/* */ -/* PARAMETRES : */ -/* typspot (E) : type de spot (spot1a4, spot5 tif,spot5bil */ -/* str_repertoire (E) : chaine donnant le nom du repertoire */ -/* str_debut (E) : debut du nom du fichier */ -/* str_fichier (S) : nom complet du fichier */ -/* */ -/* VALEUR RETOURNEE : */ -/* 0 : ok */ -/* 1 : ko */ -/****************************************************************/ - -static int cai_recup_nom_spot (char typspot, char * str_repertoire , - char * str_debut , char **str_fichier ) -{ - - DIR *ptr_repertoire; - struct dirent *cr_readdir; - long lg_comp; - char str_comp[20]; - int fic_trouve; - int retour; - - - strcpy(CAI_ERREUR,""); - fic_trouve = 0; - retour = 0; - lg_comp = strlen(str_debut); - -/* -------------------------------------------------- - Ouverture du repertoire et listage des fichiers --------------------------------------------------- */ -/**************************************/ -/* Traitement suivant le type de spot */ -/**************************************/ - if (typspot=='1') -{ -/* Format SPOT1a4 */ - - ptr_repertoire = opendir(str_repertoire); - if (ptr_repertoire != NULL) - { - while ((cr_readdir=readdir(ptr_repertoire))!=NULL) - { - strncpy(str_comp,cr_readdir->d_name,lg_comp); - str_comp[lg_comp]='\0'; - if ((strcasecmp(str_comp,str_debut)==0) && (fic_trouve == 0) - && (retour == 0)) - { - *str_fichier = (char *) calloc(strlen(str_repertoire)+1+strlen(cr_readdir->d_name)+1, sizeof(char)); - if (*str_fichier != NULL) - { - strcpy(*str_fichier,str_repertoire); - strcat(*str_fichier,"/"); - strcat(*str_fichier,cr_readdir->d_name); - (*str_fichier)[strlen(str_repertoire)+1+strlen(cr_readdir->d_name)]='\0'; - fic_trouve++; - } - else - { - strcpy(CAI_ERREUR,"Erreur : Probleme d'allocation memoire"); - retour = 1; - } - } - } - closedir(ptr_repertoire); - - if (fic_trouve == 0) - { - sprintf(CAI_ERREUR,"Erreur : fichier %s/%s... n'existe pas", - str_repertoire,str_debut); - retour = 1; - } - } - } - else if (typspot=='B') -{ -/* Format SPOT5 BIL */ - - ptr_repertoire = opendir(str_repertoire); - if (ptr_repertoire != NULL) - { - while ((cr_readdir=readdir(ptr_repertoire))!=NULL) - { - strncpy(str_comp,cr_readdir->d_name,lg_comp); - str_comp[lg_comp]='\0'; - if ((strcasecmp(str_comp,str_debut)==0) && (fic_trouve == 0) - && (retour == 0)) - { - if (((strncasecmp(str_debut,"IM",2)== 0)&& - (((strstr(cr_readdir->d_name,".BIL")) != 0)|| - ((strstr(cr_readdir->d_name,".bil")) != 0)))|| - (strncasecmp(str_debut,"METADATA.DIM",12)== 0)) - { - *str_fichier = (char *) calloc(strlen(str_repertoire)+1+strlen(cr_readdir->d_name)+1, sizeof(char)); - if (*str_fichier != NULL) - { - strcpy(*str_fichier,str_repertoire); - strcat(*str_fichier,"/"); - strcat(*str_fichier,cr_readdir->d_name); - (*str_fichier)[strlen(str_repertoire)+1+strlen(cr_readdir->d_name)]='\0'; - fic_trouve++; - } - else - { - strcpy(CAI_ERREUR,"Erreur : Probleme d'allocation memoire"); - retour = 1; - } - } - } - } - closedir(ptr_repertoire); - - if (fic_trouve == 0) - { - sprintf(CAI_ERREUR,"Erreur : fichier %s/%s... n'existe pas", - str_repertoire,str_debut); - retour = 1; - } - } - -} -else if (typspot=='T') -{ -/* Format SPOT5 TIF */ - - ptr_repertoire = opendir(str_repertoire); - if (ptr_repertoire != NULL) - { - while ((cr_readdir=readdir(ptr_repertoire))!=NULL) - { - strncpy(str_comp,cr_readdir->d_name,lg_comp); - str_comp[lg_comp]='\0'; - if ((strcasecmp(str_comp,str_debut)==0) && (fic_trouve == 0) - && (retour == 0)) - { - if (((strncasecmp(str_debut,"IM",2)== 0)&& - (((strstr(cr_readdir->d_name,".TIF")) != 0)|| - ((strstr(cr_readdir->d_name,".tif")) != 0)))|| - (strncasecmp(str_debut,"METADATA.DIM",12)== 0)) - { - *str_fichier = (char *) calloc(strlen(str_repertoire)+1+strlen(cr_readdir->d_name)+1, sizeof(char)); - if (*str_fichier != NULL) - { - strcpy(*str_fichier,str_repertoire); - strcat(*str_fichier,"/"); - strcat(*str_fichier,cr_readdir->d_name); - (*str_fichier)[strlen(str_repertoire)+1+strlen(cr_readdir->d_name)]='\0'; - fic_trouve++; - } - else - { - strcpy(CAI_ERREUR,"Erreur : Probleme d'allocation memoire"); - retour = 1; - } - } - } - } - closedir(ptr_repertoire); - - if (fic_trouve == 0) - { - sprintf(CAI_ERREUR,"Erreur : fichier %s/%s... n'existe pas", - str_repertoire,str_debut); - retour = 1; - } - } - -} -else - retour=1; - return(retour); -} - -/* - Fin de l'operation cai_recup_nom_spot -*/ -/******************************************************************************/ -/* */ -/*OPERATION : cai_lire_dimensions_spot5 */ -/* */ -/*ROLE : Cette operation lit dans le leader XML de SPOT5 les caracteristiques */ -/* de l'image a lire */ -/* */ -/*CONTEXTE D'APPEL : */ -/* */ -/*RETOUR : CAI_OK si tout va bien , CAI_KO sinon */ -/* */ -/******************************************************************************/ - -static CAI_OK_KO cai_lire_dimensions_spot5 ( char *fich_xml , int *nbcan , - int *nboct , int *nbcol , - int *nblig , char *byteorder, - int *skipbytes ) -{ - /* variables locales */ - FILE *descripteur; /* descripteur du fichier XML */ - char *maval; /* variable servant a la lecture des mots */ - int trouve = 0; /* nombre de mot cles trouves */ - int ok_ncols = 0; /* indicateur de presence de NCOLS */ - int ok_nbits = 0; /* indicateur de presence de NBITS */ - int ok_nbands = 0; /* indicateur de presence de NBANDS */ - int ok_nrows = 0; /* indicateur de presence de NROWS */ - int ok_byteorder = 0; /* indicateur de presence de BYTEORDER */ - int ok_skipbytes = 0; /* indicateur de presence de SKIPBYTES */ - int nbits; /* nombre de bits par pixel */ - - - /* Initialisation par defaut */ - if (strcmp(type_machine,"BE")==0) - byteorder[0]='M'; - else - byteorder[0]='I'; - - /* ouvrir le fichier a lire */ - - if ( ( descripteur = fopen ( fich_xml , "rb" ) ) == NULL ) - { - sprintf ( CAI_ERREUR , "erreur ouverure de fichier" ); - goto ERREUR; - } - - /* tant que le fichier n'est pas a la fin */ - - while ( !feof ( descripteur ) ) - { - /* lire un mot */ - maval = cai_spot5_gettoken ( descripteur ); - if ( maval == NULL ) goto ERREUR; - - /* comparer le mot lu */ - - if ( strcasecmp ( maval , NOMBRE_DE_BITS ) == 0 ) - { - /* lire mot suivant */ - maval = cai_spot5_gettoken ( descripteur ); - if ( maval == NULL ) goto ERREUR; - - /* en deduire la valeur */ - sscanf ( maval , "%d" , &nbits ); - *nboct = nbits / 8 ; - - /* incrementer le nombre de champs trouves */ - trouve++; - - /* positionner le flag pour ce champs a 1 */ - ok_nbits = 1; - } - else - if ( strcasecmp ( maval , NOMBRE_DE_COLONNES ) == 0 ) - { - /* lire mot suivant */ - maval = cai_spot5_gettoken ( descripteur ); - if ( maval == NULL ) goto ERREUR; - - /* en deduire la valeur */ - sscanf ( maval , "%d" , nbcol ); - - /* incrementer le nombre de champs trouves */ - trouve++; - - /* positionner le flag pour ce champs a 1 */ - ok_ncols = 1; - } - else - if ( strcasecmp ( maval , NOMBRE_DE_CANAUX ) == 0 ) - { - /* lire mot suivant */ - maval = cai_spot5_gettoken ( descripteur ); - if ( maval == NULL ) goto ERREUR; - - /* en deduire la valeur */ - sscanf ( maval , "%d" , nbcan ); - - /* incrementer le nombre de champs trouves */ - trouve++; - - /* positionner le flag pour ce champs a 1 */ - ok_nbands = 1; - } - else - if ( strcasecmp ( maval , NOMBRE_DE_LIGNES ) == 0 ) - { - /* lire mot suivant */ - maval = cai_spot5_gettoken ( descripteur ); - if ( maval == NULL ) goto ERREUR; - - /* en deduire la valeur */ - sscanf ( maval , "%d" , nblig ); - - /* incrementer le nombre de champs trouves */ - trouve++; - - /* positionner le flag pour ce champs a 1 */ - ok_nrows = 1; - } - else - if ( strcasecmp ( maval , ORDRE_LECTURE_OCTETS ) == 0 ) - { - /* lire mot suivant */ - maval = cai_spot5_gettoken ( descripteur ); - if ( maval == NULL ) goto ERREUR; - - /* en deduire la valeur */ - sscanf ( maval , "%c" , byteorder ); - - /* incrementer le nombre de champs trouves */ - trouve++; - - /* positionner le flag pour ce champs a 1 */ - ok_byteorder = 1; - } - else - if ( strcasecmp ( maval , NB_OCTETS_A_SAUTER ) == 0 ) - { - /* lire mot suivant */ - maval = cai_spot5_gettoken ( descripteur ); - if ( maval == NULL ) goto ERREUR; - - /* en deduire la valeur */ - sscanf ( maval , "%d" , skipbytes ); - - /* incrementer le nombre de champs trouves */ - trouve++; - - /* positionner le flag pour ce champs a 1 */ - ok_skipbytes = 1; - } - - /* liber la ressource */ - FREE ( maval ); - - /* si les 6 mots a lire ont ete trouves , sortir de la boucle */ - if ( trouve == 6 ) - break; - } - - /* traiter les erreur dues au document */ - if ( trouve != 6 ) - { - if ( ok_ncols == 0 ) - { - sprintf ( CAI_ERREUR , "manque le tag %s dans le fichier DIMAP" , - NOMBRE_DE_COLONNES ); - goto ERREUR; - } - - if ( ok_nbits == 0 ) - { - sprintf ( CAI_ERREUR , "manque le tag %s dans le fichier DIMAP" , - NOMBRE_DE_BITS ); - goto ERREUR; - } - if ( ok_nrows == 0 ) - { - sprintf ( CAI_ERREUR , "manque le tag %s dans le fichier DIMAP" , - NOMBRE_DE_LIGNES ); - goto ERREUR; - } - - if ( ok_nbands == 0 ) - { - sprintf ( CAI_ERREUR , "manque le tag %s dans le fichier DIMAP" , - NOMBRE_DE_CANAUX ); - goto ERREUR; - } - - if ( ok_byteorder == 0 ) - { sprintf ( CAI_ERREUR , "manque le tag %s dans le fichier DIMAP" , - ORDRE_LECTURE_OCTETS ); - goto ERREUR; - } - -/* le skip byte n'est pas obligatoire */ - if ( ok_skipbytes == 0 ) - { - *skipbytes = 0; - } - } - - /* fermeture du fichier */ - if (descripteur !=NULL) fclose ( descripteur ); - - /* liberation des ressources */ - FREE ( maval ); - - return CAI_OK; - -ERREUR: - FREE ( maval ); - return CAI_KO; - } - - /* Fin de l'operation cai_lire_dimensions_spot5 */ - -/******************************************************************************/ -/* */ -/*OPERATION : cai_spot5_gettoken */ -/* */ -/*ROLE : Cette operation lit lit un mot dans le fichier donne en parametre */ -/* etretourne sa valeur en enlevent les eventuels caracteres < et > */ -/* */ -/*CONTEXTE D'APPEL : */ -/* */ -/*RETOUR : la valeur si tout va bien , CAI_KO sinon */ -/* */ -/******************************************************************************/ - -static char* cai_spot5_gettoken ( FILE *MyFile ) -{ - char valeur[1024] = ""; /* variable servant a stocker le mot lu */ - char *ret; /* variable retourne qui contiendra le mot lu */ - char c; /* caractere lu */ - int i = 0; /* indice de la chaine de caractere valeur */ - - /* lire le premier caractere */ - - if ( fscanf ( MyFile , "%c" , &c ) == 0 ) - { - sprintf ( CAI_ERREUR , "erreur lecture xml" ); - return (char*) NULL; - } - - /* tester si le caractere est <,>,retour chariot, espace */ - /* auquel cas, sauter les blancs < , > , tabulations, etc */ - /* et si on n'est pas en fin de fichier */ - - while ( ( ( ( c == '<' ) || ( c == ' ' ) ) || - ( ( c == '>' ) || ( c == '\n' ) ) || - ( ( c == '\r' ) || ( c == '\t' ) ) ) - && ( !feof ( MyFile ) ) ) - { - if ( fscanf ( MyFile , "%c" , &c ) == 0 ) - { - sprintf ( CAI_ERREUR , "erreur lecture xml" ); - return (char*) NULL; - } - } - - - /* tant que que le mot n'est pas fini, lire les caracteres */ - - while ( ( ( c != '>' ) && ( c != '<' ) ) && - ( ( c != ' ' ) && ( c != '\n' ) ) ) - { - valeur[i] = c; - if ( fscanf ( MyFile , "%c" , &c ) == 0 ) - { - sprintf ( CAI_ERREUR , "erreur lecture xml" ); - return (char*) NULL; - } - i++; - } - - /* terminer la chaine de caractere lue */ - - valeur[i+1] = '\0'; - - /* allouer la place pour la chaine qui contiendra le resultat */ - - ret = (char*) NULL; - ret = (char*) calloc ( strlen ( valeur ) + 1 , sizeof ( char ) ); - - /* copie du mot lu dans la variable resultat */ - - strcpy ( ret , valeur ); - - /* retour du resultat */ - - return ret; - } -/* fin de l'operation cai_spot5_gettoken */ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_creation_spot1a4 */ -/* ---------- */ -/* */ -/* ROLE : fonction de creation et d'ouverture en ecriture d'une image */ -/* ----- au format spot1a4 et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_creation_spot1a4(repert, */ -/* ---------------- nom_image,nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig, */ -/* label) */ -/* */ -/* repert (E) (char *) : repertoire de stockage */ -/* nom_image (E) (char *) : nom de l'image a ouvrir */ -/* nb_can (E) (int ) : nombre de canaux de l'image */ -/* nboct_pix (E) (int ) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (E) (int ) : nombre de lignes de l'image */ -/* nb_col (E) (int ) : nombre de colonnes de l'image */ -/* label (E) (char *) : commentaire lie a l'image */ -/* */ -/* cai_ouvre_creation_spot1a4 (S) (CAI_IMAGE *) : =NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ -static CAI_IMAGE *cai_ouvre_creation_spot1a4(char *repert, - char *nom_image, - int *nbca, - int *nboct_pix, - int *nbcol, - int *nblig, - char *label) -{ - CAI_IMAGE *image1; /* descripteur image */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char nom_rep[1024]; /* nom du fichier en-tete */ - int i,j,num,k; /* indice */ - int cr; /* compte rendu d'operation */ - int retour; /* compte rendu d'operation */ - struct stat buf_stat; /* structure decrivant status de fichier */ - int descrip_leader; /* Descripteur du fichier LEADER */ - int descrip_trailer; /* Descripteur du fichier TRAILER */ - int descrip_volume; /* Descripteur du fichier VOLUME DIRECTORY */ - int descrip_null; /* Descripteur du fichier NULL VOLUME DIRECTORY */ - int descrip_imagery; /* Descripteur du fichier IMAGERY */ - long cr_write; /* Code retour de write */ - CAI_OK_KO icr; /* code retour ecriture dans DA */ - int nouv_indic; /* indice */ - char str_int4[5]; /* Chaines intermediaires */ - char str_int5[6]; /* Chaines intermediaires */ - char str_int1[2]; /* Chaines intermediaires */ - char mode[4]; /* Mode spectral */ - int lgrec; /* Longueur des enregistrements */ - int nbrec; /* Nombre d'enregistrements de l'image */ - int nb; /* taille de l'image */ - int Existe; /* Indicateur d'existence du repertoire image */ - - char Message[200]; - - /* Variables intermediaires */ - unsigned char BYTE[4]; - int VAR_LONG[2]; - - char TAB[13000]; - char LEVEL[1]; - char TAMP2[5][9]; - - int LgDate; - char StrDate[24]; - time_t LocalTime; - int nbre_enreg; - - -/*........................................ - INITIALISATIONS et allocation de place pour la structure CAI_IMAGE - .........................................*/ - - descrip_leader = -1; - descrip_trailer = -1; - descrip_volume = -1; - descrip_null = -1; - descrip_imagery = -1; - Existe = 0; - image1 = NULL; - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); - - if (image1==NULL) - { - strcpy(CAI_ERREUR, - "Erreur allocation memoirem dans cai_ouvre_creation_spot1a4"); - goto ERREUR; - } - - if ((*nboct_pix) != 1 ) - { - strcpy(CAI_ERREUR, - "Seul un octet par pixel est autorise pour l'ecriture SPOT1a4"); - goto ERREUR; - } - - sprintf(image1->NIVEAU,"0 "); - -/******************************************************************/ -/* Constitution du nom du fichier LEADER et verification qu'il */ -/* n'existe pas deja */ -/******************************************************************/ - - nom_fic[0]='\0'; - if ((long)strlen(repert)!= 0) - { - sprintf(nom_rep,"%s/%s",repert,nom_image); - } - else - { - sprintf(nom_rep,"%s",nom_image); - } - - retour = stat ( nom_rep , &buf_stat ); - - /* si le repertoire image n'existe pas, le creer*/ - if ( retour != 0 ) - { - cr = mkdir (nom_rep,0775); - if (cr !=0) - { - sprintf ( CAI_ERREUR , - "probleme a la creation du repertoire image %s SPOT1A4 \n" , - nom_image ); - goto ERREUR; - } - } - else - Existe = 1; - - sprintf(nom_fic,"%s/LEAD_01.DAT",nom_rep); - - retour = stat ( nom_fic , &buf_stat ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "Le fichier %s LEADER SPOT1A4 existe \n" , - nom_image ); - goto ERREUR; - } - - -/*---------------------------------------------------------------------------*/ -/* Ouverture du fichier LEADER en creation */ -/*---------------------------------------------------------------------------*/ - - descrip_leader = open (nom_fic,O_RDWR|O_CREAT|O_BINARY, PERMS ); - if (descrip_leader == -1) - { - strcpy ( CAI_ERREUR , "Erreur de creation du fichier Leader SPOT1A4"); - goto ERREUR; - } - -/*---------------------------------------------------------------------------*/ -/* ECRITURE DU FICHIER LEADER */ -/*---------------------------------------------------------------------------*/ - - -/***********************************/ -/* Pour le fichier FILE DESCRIPTOR */ -/***********************************/ - -/* 1 RECORD */ - -/* SEGMENT FIXE : */ - - VAR_LONG[0] = 1; - BYTE[0] = 63; - BYTE[1] = 192; - BYTE[2] = 18; - BYTE[3] = 18; - VAR_LONG[1] = 3960; - - cr_write = write ( descrip_leader , &VAR_LONG[0] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader SPOT1A4"); - goto ERREUR; - } - - cr_write = write ( descrip_leader , &BYTE[0] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader SPOT1A4"); - goto ERREUR; - } - - - cr_write = write ( descrip_leader , &VAR_LONG[1] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - strcpy( TAB , "A S4-ST-73-1CN 0 0 1"); - cr_write = write ( descrip_leader , TAB , 36); - if (cr_write != 36) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - if (*nbca == 1) - { - strcpy(mode,"PAN"); - strcpy(TAB,"SP0 P0 LEADBIL "); - } - else - { - if (*nbca == 3) - { - strcpy(mode,"XS "); - strcpy(TAB,"SP0 X0 LEADBIL "); - } - else - { - if (*nbca == 4) - { - strcpy(mode,"XI "); - strcpy(TAB,"SP0 I0 LEADBIL "); - } - } - } - - cr_write = write ( descrip_leader, TAB , 16); - if (cr_write != 16) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - - strcpy( TAB , "FSEQ 1 4FTYP 5 4FLGT 9 4YNNN"); - cr_write = write ( descrip_leader , TAB , 52); - if (cr_write != 52) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - - for (i=0;i<13000;i++) - { - strcpy ( &TAB[i]," "); - } - - cr_write = write ( descrip_leader , TAB , 64); - if (cr_write != 64) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - -/* SEGMENT VARIABLE : */ - - strcpy( TAB , " 1 3960 24 3960 1 3960 2 37 16A 2 21 16A"); - cr_write = write ( descrip_leader , TAB , 68); - if (cr_write != 68) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - - for (i=0;i<81;i++) - { - strcpy ( &TAB[i]," "); - } - - strcpy( TAB , " 2 613 16A 2 629 16A 2 581 32A 2 85 32A 2 1317 64A"); - cr_write = write ( descrip_leader , TAB , 80); - if (cr_write != 80) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - for (i=0;i<50;i++) - { - strcpy ( &TAB[i]," "); - } - - strcpy( TAB , " 2 1029 16A 2 1061256A "); - cr_write = write ( descrip_leader , TAB , 48); - if (cr_write != 48) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - for (i=0;i<3600;i++) - { - strcpy ( &TAB[i]," "); - } - - cr_write = write ( descrip_leader , TAB , 3584); - if (cr_write != 3584) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - -/**************************/ -/* Pour le fichier HEADER */ -/**************************/ - -/* 1 RECORD */ - - VAR_LONG[0] = 2; - BYTE[0] = 18; - BYTE[1] = 18; - BYTE[2] = 18; - BYTE[3] = 18; - VAR_LONG[1] = 3960; - - - cr_write = write ( descrip_leader , &VAR_LONG[0] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - cr_write = write ( descrip_leader , BYTE , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - - cr_write = write ( descrip_leader , &VAR_LONG[1] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - strcpy ( TAB, " 1"); - cr_write = write ( descrip_leader , TAB , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - for (i=0;i<630;i++) - { - strcpy ( &TAB[i]," "); - } - - cr_write = write ( descrip_leader , TAB , 628); - if (cr_write != 628) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - /* Ecriture du mode spectral */ - - cr_write = write(descrip_leader,mode,3); - if (cr_write != 3) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - cr_write = write(descrip_leader,TAB,360); - if (cr_write != 360) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - /* Initialisation du nombre de colonnes, du nombre de lignes et du nombre - de canaux : */ - sprintf(TAB,"%5d" , *nbcol); - - cr_write = write ( descrip_leader , TAB , 5); - if (cr_write != 5) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - strcpy ( TAB, " "); - cr_write = write ( descrip_leader , TAB , 11); - if (cr_write != 11) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - sprintf(TAB,"%5d" , *nblig); - cr_write = write ( descrip_leader , TAB , 5); - if (cr_write != 5) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - for (i=0;i<35;i++) - { - strcpy(&TAB[i], " "); - } - cr_write = write ( descrip_leader , TAB , 31); - if (cr_write != 31) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - - sprintf(TAB,"%d",*nbca); - cr_write = write ( descrip_leader , TAB , 1); - if (cr_write != 1) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - for (i=0;i<2741;i++) - { - strcpy(&TAB[i], " "); - } - - cr_write = write ( descrip_leader , TAB , 2740); - if (cr_write != 2740) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - - strcpy ( TAB , " 1 3960 16 3960 "); - cr_write = write ( descrip_leader , TAB , 64); - if (cr_write != 64) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - - strcpy ( TAB , " 1 3960 4 3960 "); - cr_write = write ( descrip_leader , TAB , 64); - if (cr_write != 64) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - strcpy ( TAB , " 1 3960 "); - cr_write = write ( descrip_leader , TAB , 32); - if (cr_write != 32) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - - -/**************************************/ -/* Pour le fichier EPHEMERIS/ATTITUDE */ -/**************************************/ - -/* 1 RECORD */ - - VAR_LONG[0] = 3; - BYTE[0] = 246; - BYTE[1] = 36; - BYTE[2] = 18; - BYTE[3] = 18; - VAR_LONG[1] = 3960; - - - cr_write = write ( descrip_leader , &VAR_LONG[0] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - cr_write = write ( descrip_leader , BYTE , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - cr_write = write ( descrip_leader , &VAR_LONG[1] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - strcpy ( TAB , " 1"); - cr_write = write ( descrip_leader , TAB , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - for (i=0;i<3945;i++) - { - strcpy(&TAB[i], " "); - } - -/* Ecriture dans le fichier Leader */ - - cr_write = write ( descrip_leader , TAB , 3944); - if (cr_write != 3944) - { - strcpy(CAI_ERREUR, "Erreur acces au fichier Leader"); - goto ERREUR; - } - - - -/*******************************************/ -/* Pour le fichier RADIOMETRIC CALIBRATION */ -/*******************************************/ - -/* 16 RECORDS */ - - BYTE[0] = 63; - BYTE[1] = 36; - BYTE[2] = 18; - BYTE[3] = 18; - VAR_LONG[1] = 3960; - - /*image source non SPOT*/ - -/* Ecriture dans le fichier Leader */ - - for (i=0;i<16;i++) /* Pour 16 records */ - { - VAR_LONG[0] = 4+i; - cr_write = write ( descrip_leader , &VAR_LONG[0] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - cr_write = write ( descrip_leader , BYTE , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - cr_write = write ( descrip_leader , &VAR_LONG[1] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - cr_write = write ( descrip_leader , TAB , 48); - if (cr_write != 48) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - for (j=0;j<3000;j=j+2) - { - strcpy(&TAB[j], " "); - strcpy(&TAB[j+1], "0"); - } - - cr_write = write ( descrip_leader , TAB , 3000); - if ( cr_write != 3000) - { - strcpy(CAI_ERREUR,"Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - for (j=0;j<900;j++) - { - strcpy(&TAB[j], " "); - } - - cr_write = write ( descrip_leader , TAB , 900); - if (cr_write != 900) - { - strcpy ( CAI_ERREUR, - "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - } - - -/**********************************************/ -/* Pour MODELIZATION et GROUND CONTROL POINTS*/ -/**********************************************/ - -/* 2 RECORD */ - -for (i=0;i<2;i++) -{ - VAR_LONG[0] = 20+i; - BYTE[0] = 8; - BYTE[1] = 21; - BYTE[2] = 48; - BYTE[3] = 35; - VAR_LONG[1] = 3960; - - cr_write = write ( descrip_leader , &VAR_LONG[0] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - cr_write = write ( descrip_leader , BYTE , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - cr_write = write ( descrip_leader , &VAR_LONG[1] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - - strcpy ( TAB , " 1"); - cr_write = write ( descrip_leader , TAB, 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR , "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - for (i=0;i<3950;i++) - { - strcpy(&TAB[j], " "); - } - - - /* Ecriture dans le fichier Leader */ - - cr_write = write ( descrip_leader , TAB , 3944); - if ( cr_write != 3944) - { - strcpy(CAI_ERREUR,"Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } -} - -/*****************************/ -/* Pour HISTOGRAM */ -/*****************************/ - -/* 4 RECORDS */ - - BYTE[0] = 192; - BYTE[1] = 36; - BYTE[2] = 18; - BYTE[3] = 18; - VAR_LONG[1] = 3960; - - - for (i=0;i<*nbca;i++) /* nbca records */ - { - - VAR_LONG[0] = 22+i; - - cr_write = write ( descrip_leader , &VAR_LONG[0] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - cr_write = write ( descrip_leader , BYTE , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - cr_write = write ( descrip_leader , &VAR_LONG[1] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - cr_write = write ( descrip_leader , TAB , 3948); - if (cr_write != 3948) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - } - - if (*nbca!=4) - { - for (i=0;i<(4-(*nbca));i++) - { - VAR_LONG[0] = 22+i+(*nbca); - - cr_write = write ( descrip_leader , &VAR_LONG[0] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - cr_write = write ( descrip_leader , BYTE , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - - cr_write = write ( descrip_leader , &VAR_LONG[1] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - if (*nbca == 1) - { - sprintf(TAB," %d",i+2); - } - if (*nbca == 3) - { - strcpy(TAB," 4"); - } - - cr_write = write ( descrip_leader , TAB , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - for (i=0;i<4000;i++) - { - strcpy(&TAB[j], " "); - } - - cr_write = write(descrip_leader, TAB, 3944); - if (cr_write != 3944) - { - strcpy(CAI_ERREUR,"Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - } - } - - -/**********************************/ -/* Pour le fichier MAP PROJECTION */ -/**********************************/ - -/* 1 RECORD */ - - - VAR_LONG[0] = 26; - BYTE[0] = 36; - BYTE[1] = 36; - BYTE[2] = 18; - BYTE[3] = 18; - VAR_LONG[1] = 3960; - - cr_write = write ( descrip_leader , &VAR_LONG[0] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - cr_write = write ( descrip_leader , BYTE , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - cr_write = write ( descrip_leader , &VAR_LONG[1] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - strcpy(TAB, " 1"); - cr_write = write ( descrip_leader , TAB , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - for (i=0;i<4000;i++) - { - strcpy(&TAB[i], " "); - } - - cr_write = write ( descrip_leader , TAB , 3944); - if (cr_write != 3944) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - -/*******************************/ -/* Pour le fichier ANNOTATIONS */ -/*******************************/ - -/* 1 RECORD */ - - - VAR_LONG[0] = 27; - BYTE[0] = 18; - BYTE[1] = 219; - BYTE[2] = 18; - BYTE[3] = 18; - VAR_LONG[1] = 3960; - - cr_write = write ( descrip_leader , &VAR_LONG[0] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - cr_write = write ( descrip_leader , BYTE , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - cr_write = write ( descrip_leader , &VAR_LONG[1] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - strcpy(TAB, " 1 3"); - cr_write = write ( descrip_leader , TAB , 8); - if (cr_write != 8) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - strcpy(TAB, " "); - - cr_write = write ( descrip_leader , TAB , 32); - if (cr_write != 32) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - strcpy(TAB, " 180 36VT "); - cr_write = write ( descrip_leader , TAB , 12); - if (cr_write != 12) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - for (i=0;i<170;i++) - { - strcpy ( &TAB[i]," "); - } - - cr_write = write ( descrip_leader , TAB , 168); - if (cr_write != 168) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - strcpy(TAB, " 360 98VZ1 "); - cr_write = write ( descrip_leader , TAB , 12); - if (cr_write != 12) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - for (i=0;i<350;i++) - { - strcpy ( &TAB[i]," "); - } - - cr_write = write ( descrip_leader , TAB , 348); - if (cr_write != 348) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - - } - - strcpy(TAB, " 540 60VZ2 "); - cr_write = write ( descrip_leader , TAB , 12); - if (cr_write != 12) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - for (i=0;i<1120;i++) - { - strcpy ( &TAB[i]," "); - } - - cr_write = write ( descrip_leader , TAB , 1112); - if (cr_write != 1112) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - strcpy(TAB, " 4 8 "); - cr_write = write ( descrip_leader , TAB , 8); - if (cr_write != 8) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - - for (i=0;i<2240;i++) - { - strcpy(&TAB[i], " "); - } - - cr_write = write ( descrip_leader , TAB , 2236); - if (cr_write != 2236) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Leader Spot1a4"); - goto ERREUR; - } - -/*--------------------------------------------*/ -/* Fermeture du fichier LEADER */ -/*--------------------------------------------*/ - - close (descrip_leader); - - -/******************************************************************/ -/* Constitution du nom du fichier TRAILER et verification qu'il */ -/* n'existe pas deja */ -/******************************************************************/ - sprintf(nom_fic,"%s/TRAI_01.DAT",nom_rep); - retour = stat ( nom_fic , &buf_stat ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "Le fichier %s TRAILER SPOT1A4 existe \n" , - nom_image ); - goto ERREUR; - } - - -/*---------------------------------------------------------------------------*/ -/* Ouverture du fichier TRAILER en creation */ -/*---------------------------------------------------------------------------*/ - - descrip_trailer = open (nom_fic,O_RDWR|O_CREAT|O_BINARY, PERMS ); - - if (descrip_trailer == -1) - { - strcpy (CAI_ERREUR,"Erreur ouverture du fichier TRAILER SPOT1A4 "); - goto ERREUR; - } - -/*---------------------------------------------------------------------------*/ -/* ECRITURE DU FICHIER TRAILER */ -/*---------------------------------------------------------------------------*/ - -/***********************************/ -/* Pour le fichier FILE DESCRIPTOR */ -/***********************************/ - -/* 1 RECORD */ - -/* SEGMENT FIXE : */ - - VAR_LONG[0] = 1; - BYTE[0] = 63; - BYTE[1] = 192; - BYTE[2] = 18; - BYTE[3] = 18; - VAR_LONG[1] = 1080; - - cr_write = write ( descrip_trailer , &VAR_LONG[0] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Trailer SPOT1A4"); - goto ERREUR; - } - - cr_write = write ( descrip_trailer , BYTE , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Trailer SPOT1A4"); - goto ERREUR; - } - - - cr_write = write ( descrip_trailer , &VAR_LONG[1] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Trailer SPOT1A4"); - goto ERREUR; - } - - strcpy ( TAB , "A S4-ST-73-1CN 0 0 3"); - cr_write = write ( descrip_trailer , TAB , 36); - if ( cr_write != 36) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Trailer SPOT1A4"); - goto ERREUR; - } - - strcpy (TAB," TRAIBIL FSEQ 1 4FTYP 5 4FLGT 9 4YNNN"); - cr_write = write ( descrip_trailer , TAB , 68); - if ( cr_write != 68) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Trailer SPOT1A4"); - goto ERREUR; - } - - for (i=0;i<70;i++) - { - strcpy(&TAB[i], " "); - } - - cr_write = write ( descrip_trailer , TAB , 64); - if ( cr_write != 64) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Trailer SPOT1A4"); - goto ERREUR; - } - - -/* SEGMENT VARIABLE : */ - - strcpy ( TAB , " 3 1080"); - cr_write = write ( descrip_trailer , TAB , 12); - if ( cr_write != 12) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Trailer SPOT1A4"); - goto ERREUR; - } - - for (i=0;i<30;i++) - { - strcpy(&TAB[i], " "); - } - - cr_write = write ( descrip_trailer , TAB , 24); - if ( cr_write != 24) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Trailer SPOT1A4"); - goto ERREUR; - } - strcpy ( TAB , " 2 21 4N 2 35200A"); - cr_write = write ( descrip_trailer , TAB , 32); - if ( cr_write != 32) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Trailer SPOT1A4"); - goto ERREUR; - } - for (i=0;i<835;i++) - { - strcpy(&TAB[i], " "); - } - - cr_write = write ( descrip_trailer , TAB , 832); - if ( cr_write != 832) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Trailer SPOT1A4"); - goto ERREUR; - } - - -/***********************************/ -/* Pour le fichier TRAILER-QUALITY */ -/***********************************/ - -/* 1 RECORD */ - -/* SEGMENT FIXE : */ - - VAR_LONG[0] = 2; - BYTE[0] = 18; - BYTE[1] = 246; - BYTE[2] = 18; - BYTE[3] = 18; - VAR_LONG[1] = 1080; - - cr_write = write ( descrip_trailer , &VAR_LONG[0] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Trailer SPOT1A4"); - goto ERREUR; - } - - cr_write = write ( descrip_trailer , BYTE , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Trailer SPOT1A4"); - goto ERREUR; - } - - cr_write = write ( descrip_trailer , &VAR_LONG[1] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Trailer SPOT1A4"); - goto ERREUR; - } - - strcpy ( TAB , " 1 "); - cr_write = write ( descrip_trailer , TAB , 8); - if ( cr_write != 8) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Trailer SPOT1A4"); - goto ERREUR; - } - - - /*ecriture dans le fichier trailer*/ - for (i=0;i<215;i++) - { - strcpy(&TAB[i], " "); - } - cr_write = write ( descrip_trailer , TAB , 214); - if ( cr_write != 214) - { - strcpy ( CAI_ERREUR , "Erreur ecriture du fichier Trailer SPOT1A4"); - goto ERREUR; - } - - strcpy ( TAB , " 1 1080"); - cr_write = write ( descrip_trailer , TAB , 10); - if ( cr_write != 10) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Trailer SPOT1A4"); - goto ERREUR; - } - - for (i=0;i<840;i++) - { - strcpy(&TAB[i], " "); - } - - cr_write = write ( descrip_trailer , TAB , 836); - if ( cr_write != 836) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Trailer SPOT1A4"); - goto ERREUR; - } - -/*********************************************/ -/* Pour le fichier GEOMETRIC TRANSFORMATIONS */ -/*********************************************/ - -/* 1 RECORD */ - -/* SEGMENT FIXE : */ - - VAR_LONG[0] = 3; - BYTE[0] = 18; - BYTE[1] = 246; - BYTE[2] = 18; - BYTE[3] = 18; - VAR_LONG[1] = 1080; - - cr_write = write ( descrip_trailer , &VAR_LONG[0] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Trailer SPOT1A4"); - goto ERREUR; - } - - cr_write = write ( descrip_trailer , BYTE , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Trailer SPOT1A4"); - goto ERREUR; - } - - cr_write = write ( descrip_trailer , &VAR_LONG[1] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Trailer SPOT1A4"); - goto ERREUR; - } - - strcpy ( TAB , " 1"); - cr_write = write ( descrip_trailer , TAB , 4); - if ( cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Trailer SPOT1A4"); - goto ERREUR; - } - - for (i=0;i<1070;i++) - { - strcpy(&TAB[i], " "); - } - - cr_write = write ( descrip_trailer , TAB, 1064); - if ( cr_write != 1064) - { - strcpy ( CAI_ERREUR, "Erreur ecriture du fichier Trailer SPOT1A4"); - goto ERREUR; - } - - -/*----------------------------------------------*/ -/* Fermeture du fichier TRAILER */ -/*----------------------------------------------*/ - - close (descrip_trailer); - - -/******************************************************************/ -/* Constitution du nom du fichier VOLUME_DIRECTORY et */ -/* verification qu'il n'existe pas deja */ -/******************************************************************/ - sprintf(nom_fic,"%s/VOLD_01.DAT",nom_rep); - retour = stat ( nom_fic , &buf_stat ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , - "Le fichier %s VOLUME_DIRECTORY SPOT1A4 existe \n" , - nom_image ); - goto ERREUR; - } - - -/*---------------------------------------------------------------------------*/ -/* Ouverture du fichier VOLUME DIRECTORY en creation */ -/*---------------------------------------------------------------------------*/ - - descrip_volume = open (nom_fic,O_RDWR|O_CREAT|O_BINARY, PERMS ); - if (descrip_volume == -1) - { - strcpy (CAI_ERREUR, - "Erreur de creation du fichier VOLUME DIRECTORY SPOT1A4"); - goto ERREUR; - } - - -/*---------------------------------------------------------------------------*/ -/* ECRITURE DU FICHIER VOLUME DIRECTORY */ -/*---------------------------------------------------------------------------*/ - -/*************************************/ -/* Pour le fichier VOLUME DESCRIPTOR */ -/*************************************/ - -/* 1 RECORD */ - - VAR_LONG[0] = 1; - BYTE[0] =192; - BYTE[1] = 192; - BYTE[2] = 18; - BYTE[3] = 18; - VAR_LONG[1] = 360; - - cr_write = write ( descrip_volume , &VAR_LONG[0] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - cr_write = write ( descrip_volume , BYTE , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - - cr_write = write ( descrip_volume , &VAR_LONG[1] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - strcpy ( TAB , "A CCB-CCT-0002 A AECR_EXT_SPOT"); - cr_write = write ( descrip_volume, TAB, 32); - if (cr_write != 32) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - - for (i=0;i<70;i++) - { - strcpy ( &TAB[i]," "); - } - cr_write = write ( descrip_volume, TAB, 68); - if (cr_write != 68) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - -/* Recuperation de la date systeme */ - - LocalTime = time(NULL); /* Date calendaire */ - - -/* Ecriture dans une chaine de caracteres */ - - LgDate = 17; - - strftime ( StrDate , LgDate , "%Y%m%d%H%M%S ",localtime(&LocalTime)); - - cr_write = write ( descrip_volume,StrDate,16); - if (cr_write != 16) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - strcpy ( &TAB[33], " 3 5"); - cr_write = write ( descrip_volume , TAB , 232); - if (cr_write != 232) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - - -/************************************************/ -/* Pour le fichier FILE POINTER for Leader File */ -/************************************************/ - -/* 1 RECORD */ - - VAR_LONG[0] = 2; - BYTE[0] =219; - BYTE[1] = 192; - BYTE[2] = 18; - BYTE[3] = 18; - VAR_LONG[1] = 360; - - cr_write = write ( descrip_volume , &VAR_LONG[0] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - cr_write = write ( descrip_volume , BYTE , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - cr_write = write ( descrip_volume , &VAR_LONG[1] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - strcpy ( TAB,"A 1SP LEADBIL LEADER FILE "); - cr_write = write ( descrip_volume, TAB, 36); - if (cr_write != 36) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - strcpy ( TAB , " "); - cr_write = write ( descrip_volume, TAB, 16); - if (cr_write != 16) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - strcpy ( TAB,"LEADMIXED BINARY AND ASCII MBAA 27 3960 3960FIXED LENGHTFIXD "); - cr_write = write ( descrip_volume, TAB, 80); - if (cr_write != 80) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - - for (i=0;i<217;i++) - { - strcpy ( &TAB[i]," "); - } - - cr_write = write ( descrip_volume, TAB, 216); - if (cr_write != 216) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - -/*************************************************/ -/* Pour le fichier FILE POINTER for Imagery File */ -/*************************************************/ - -/* 1 RECORD */ - - VAR_LONG[0] = 3; - BYTE[0] =219; - BYTE[1] = 192; - BYTE[2] = 18; - BYTE[3] = 18; - VAR_LONG[1] = 360; - - cr_write = write ( descrip_volume , &VAR_LONG[0] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - cr_write = write ( descrip_volume , BYTE , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - cr_write = write ( descrip_volume , &VAR_LONG[1] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - strcpy ( TAB,"A 2SP IMGYBIL IMAGERY FIL "); - cr_write = write ( descrip_volume, TAB, 36); - if (cr_write != 36) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - strcpy ( TAB , " IMGYBINARY ONLY BINO"); - cr_write = write ( descrip_volume, TAB, 52); - if (cr_write != 52) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - strcpy ( TAB ,"000 FIXED LENGTHFIXD"); - cr_write = write ( descrip_volume, TAB, 40); - if (cr_write != 40) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - for (i=0;i<125;i++) - { - strcpy ( &TAB[i]," "); - } - - cr_write = write ( descrip_volume, TAB, 120); - if (cr_write != 120) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - strcpy(TAB,"000 "); - cr_write = write ( descrip_volume, TAB, 100); - if (cr_write != 100) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - -/*************************************************/ -/* Pour le fichier FILE POINTER for Trailer File */ -/*************************************************/ - -/* 1 RECORD */ - - VAR_LONG[0] = 4; - BYTE[0] = 219; - BYTE[1] = 192; - BYTE[2] = 18; - BYTE[3] = 18; - VAR_LONG[1] = 360; - - cr_write = write ( descrip_volume , &VAR_LONG[0] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - cr_write = write ( descrip_volume , BYTE , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - cr_write = write ( descrip_volume , &VAR_LONG[1] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - strcpy ( TAB,"A 3SP TRAIBIL TRAILER FILE"); - cr_write = write ( descrip_volume, TAB, 36); - if (cr_write != 36) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - strcpy(TAB," "); - cr_write = write ( descrip_volume, TAB, 16); - if (cr_write != 16) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - strcpy ( TAB,"TRAIMIXED BINARY AND ASCII MBAA 3 1080 1080FIXED LENGTHFIXD"); - cr_write = write ( descrip_volume, TAB, 76); - if (cr_write != 76) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - for (i=0;i<225;i++) - { - strcpy ( &TAB[i]," "); - } - cr_write = write ( descrip_volume, TAB, 220); - if (cr_write != 220) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - -/************************/ -/* Pour le fichier TEXT */ -/************************/ - -/* 1 RECORD */ - - VAR_LONG[0] = 5; - BYTE[0] = 18; - BYTE[1] = 63; - BYTE[2] = 18; - BYTE[3] = 18; - VAR_LONG[1] = 360; - - cr_write = write ( descrip_volume , &VAR_LONG[0] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - cr_write = write ( descrip_volume , BYTE , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - - cr_write = write ( descrip_volume , &VAR_LONG[1] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - strcpy ( TAB,"A PRODUCT: SPOT"); - cr_write = write ( descrip_volume, TAB, 28); - if (cr_write != 28) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - - strcpy ( TAB," MODE BIL LEVEL \r\n"); - cr_write = write ( descrip_volume, TAB, 40); - if (cr_write != 40) - { - strcpy ( CAI_ERREUR, "Erreur d'ecriture du fichier Volume Directory"); - goto ERREUR; - } - - for (i=0;i<50;i++) - { - strcpy ( &TAB[i]," "); - } - - cr_write = write ( descrip_volume, TAB, 40); - if ( cr_write != 40) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - - strcpy ( TAB , "PROD. CNES_QTIS COPYRIGHT CNES "); - cr_write = write ( descrip_volume , TAB , 35); - if (cr_write != 35) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - -/* Recuperation de la date systeme */ - - LocalTime = time(NULL); /* Date calendaire */ - -/* Ecriture dans une chaine de caracteres */ - - LgDate = 24; - - strftime ( StrDate , LgDate , "%d %m %Y - %HH%MMN%SS" , - localtime(&LocalTime)); - cr_write = write ( descrip_volume, StrDate , 23); - if (cr_write != 23) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - strcpy ( TAB ,"\r\nSCENE - THE "); - cr_write = write ( descrip_volume , TAB , 48); - if (cr_write != 48) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - strcpy ( TAB,"\r\nVOL : VOLUME 1 ORDER: ORDRE 1 \r\n"); - cr_write = write ( descrip_volume , TAB , 42); - if (cr_write != 42) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - - for (i=0;i<95;i++) - { - strcpy ( &TAB[i]," "); - } - - cr_write = write ( descrip_volume , TAB , 92); - if (cr_write != 92) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Volume Directory SPOT1A4"); - goto ERREUR; - } - -/*----------------------------------------------*/ -/* Fermeture du fichier VOLUME */ -/*----------------------------------------------*/ - - close (descrip_volume); - - -/******************************************************************/ -/* Constitution du nom du fichier NULL_VOLUME_DIRECTORY */ -/* et verification qu'il n'existe pas deja */ -/******************************************************************/ - sprintf(nom_fic,"%s/NULL_01.DAT",nom_rep); - retour = stat ( nom_fic , &buf_stat ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , - "Le fichier %s NULL_VOLUME_DIRECTORY SPOT1A4 existe \n" , - nom_image ); - goto ERREUR; - } - - -/*---------------------------------------------------------------------------*/ -/* Ouverture du fichier NULL VOLUME DIRECTORY en creation */ -/*---------------------------------------------------------------------------*/ - - descrip_null = open (nom_fic,O_RDWR|O_CREAT|O_BINARY, PERMS ); - if (descrip_null == -1) - { - strcpy (CAI_ERREUR, - "Erreur de creation du fichier NULL VOLUME DIRECTORY SPOT1A4"); - goto ERREUR; - } - - -/*---------------------------------------------------------------------------*/ -/* ECRITURE DU FICHIER NULL VOLUME DIRECTORY */ -/*---------------------------------------------------------------------------*/ - -/******************************************/ -/* Pour le fichier NULL VOLUME DESCRIPTOR */ -/******************************************/ - -/* 1 RECORD */ - - VAR_LONG[0] = 1; - BYTE[0] =192; - BYTE[1] = 192; - BYTE[2] = 63; - BYTE[3] = 18; - VAR_LONG[1] = 360; - - cr_write = write ( descrip_null , &VAR_LONG[0] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Null Volume Directory SPOT1A4"); - goto ERREUR; - } - - cr_write = write ( descrip_null , BYTE , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Null Volume Directory SPOT1A4"); - goto ERREUR; - } - - - cr_write = write ( descrip_null , &VAR_LONG[1] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Null Volume Directory SPOT1A4"); - goto ERREUR; - } - - strcpy ( TAB , "A CCB-CCT-0002 A A"); - cr_write = write ( descrip_null, TAB, 20); - if (cr_write != 20) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Null Volume Directory SPOT1A4"); - goto ERREUR; - } - - for (i=0;i<340;i++) - { - strcpy ( &TAB[i]," "); - } - cr_write = write ( descrip_null, TAB, 328); - if (cr_write != 328) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Null Volume Directory SPOT1A4"); - goto ERREUR; - } - - - -/*-------------------------------------------*/ -/* Fermeture du fichier NULL VOLUME */ -/*-------------------------------------------*/ - - close (descrip_null); - - -/******************************************************************/ -/* Constitution du nom du fichier IMAGERY et verification qu'il */ -/* n'existe pas deja */ -/******************************************************************/ - sprintf(nom_fic,"%s/IMAG_01.DAT",nom_rep); - retour = stat ( nom_fic , &buf_stat ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "Le fichier %s IMAGERY SPOT1A4 existe \n" , - nom_image ); - goto ERREUR; - } - - -/*---------------------------------------------------------------------------*/ -/* Ouverture du fichier IMAGERY en creation */ -/*---------------------------------------------------------------------------*/ - - descrip_imagery = open (nom_fic,O_RDWR|O_CREAT|O_BINARY, PERMS ); - if (descrip_imagery == -1) - { - strcpy ( CAI_ERREUR , "Erreur de creation du fichier Imagerie SPOT1A4"); - goto ERREUR; - } - -/*---------------------------------------------------------------------------*/ -/* ECRITURE DU FICHIER IMAGERY */ -/*---------------------------------------------------------------------------*/ - -/***********************************/ -/* Pour le fichier FILE DESCRIPTOR */ -/***********************************/ - -/* SEGMENT FIXE : */ - - /* Initialisation de nbrec et lgrec et des autres donnees utiles */ - nb = (*nbcol)*(*nboct_pix); - /* Definition de lgrec : */ - if (nb<=5300) - lgrec = 5400; - else if ((nb>5300) && (nb<=8540)) - lgrec = 8640; - else if ((nb>8540) && (nb<=10880)) - lgrec = 10980; - else if ((nb>10880) && (nb<=12140)) - lgrec = 12240; - else - { - strcpy ( CAI_ERREUR , "Enregistrement trop long pour le fichier imagery"); - goto ERREUR; - } - - - /* 1 RECORD */ - VAR_LONG[0] = 1; - BYTE[0] = 63; - BYTE[1] = 192; - BYTE[2] = 18; - BYTE[3] = 18; - VAR_LONG[1] = lgrec; - - - nbrec = (*nbca)*(*nblig); - if (nbrec<10000) - { - strcpy(&TAMP2[0][0]," "); - strcpy(&TAMP2[0][1]," "); - sprintf ( str_int4,"%d",nbrec); - for (i=0;i<4;i++) - { - strcpy(&TAMP2[0][i+2],&str_int4[i]); - } - } - else - { - strcpy(&TAMP2[0][0]," "); - sprintf (str_int5,"%d",nbrec); - for (i=0;i<5;i++) - { - strcpy(&TAMP2[0][i+1],&str_int5[i]); - } - } - - - if (lgrec<10000) - { - strcpy(&TAMP2[1][0]," "); - strcpy(&TAMP2[1][1]," "); - sprintf ( str_int4,"%d",lgrec); - for (i=0;i<4;i++) - { - strcpy(&TAMP2[1][i+2],&str_int4[i]); - } - } - else - { - strcpy(&TAMP2[1][0]," "); - sprintf (str_int5,"%d",lgrec); - for (i=0;i<5;i++) - { - strcpy(&TAMP2[1][i+1],&str_int5[i]); - } - } - - - /* Initialisation du nombre de colonnes et du nombre de lignes : */ - - for (i=0;i<3;i++) - { - strcpy ( &TAMP2[2][i]," "); - strcpy ( &TAMP2[3][i]," "); - } - - if (*nblig < 10000) - { - strcpy ( &TAMP2[2][3] , "0"); - sprintf( str_int4 , "%d" , *nblig); - for (j=0;j<4;j++) - { - strcpy(&TAMP2[2][j+4],&str_int4[j]); - } - } - else - { - sprintf( str_int5, "%d", *nblig); - for (j=0;j<5;j++) - { - strcpy ( &TAMP2[2][j+3],&str_int5[j]); - } - } - - if (*nbcol < 10000) - { - strcpy ( &TAMP2[3][3] , "0"); - sprintf ( str_int4 , "%d" , *nbcol); - for (j=0;j<4;j++) - { - strcpy ( &TAMP2[3][j+4],&str_int4[j]); - } - } - else - { - sprintf ( str_int5 , "%d" , *nbcol); - for ( j=0;j<5;j++) - { - strcpy ( &TAMP2[3][j+3],&str_int5[j]); - } - } - - for (i=0;i<4;i++) - { - strcpy(&TAMP2[4][i]," "); - } - - - cr_write = write ( descrip_imagery , &VAR_LONG[0] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur d'ecriture du fichier Imagery SPOT1A4"); - goto ERREUR; - } - - cr_write = write ( descrip_imagery , BYTE , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur d'ecriture du fichier Imagery SPOT1A4"); - goto ERREUR; - } - - - cr_write = write ( descrip_imagery , &VAR_LONG[1] , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR, "Erreur d'ecriture du fichier Imagery SPOT1A4"); - goto ERREUR; - } - - strcpy ( TAB, "A S4-ST-73-1CN 0 0 2"); - cr_write = write ( descrip_imagery , TAB , 36); - if ( cr_write != 36) - { - strcpy ( CAI_ERREUR, "Erreur d'ecriture du fichier Imagery SPOT1A4"); - goto ERREUR; - } - -/* Initialisation du mode spectral et du niveau : */ - if ((mode[0]=='X')&&(mode[1]=='I')) - sprintf(TAB," I0 "); - else - sprintf(TAB," %.1s0 ",&mode[0]); - - - cr_write = write (descrip_imagery, TAB, 8); - if (cr_write != 8) - { - strcpy(CAI_ERREUR,"Erreur d'ecriture du fichier Imagery SPOT1A4"); - goto ERREUR; - } - - /* Initialisation du niveau de traitement : */ - - LEVEL[0]=' '; - strcpy(TAB, "IMGYBIL FSEQ 1 4FTYP 5 4FLGT 9 4YNYN"); - cr_write = write (descrip_imagery, TAB, 60); - if (cr_write != 60) - { - strcpy(CAI_ERREUR,"Erreur d'ecriture du fichier Imagery SPOT1A4"); - goto ERREUR; - } - - for (i=0;i<70;i++) - { - strcpy ( &TAB[i]," "); - } - - cr_write = write (descrip_imagery, TAB, 64); - if (cr_write != 64) - { - strcpy(CAI_ERREUR,"Erreur d'ecriture du fichier Imagery SPOT1A4"); - goto ERREUR; - } - - -/* SEGMENT VARIABLE : */ - - cr_write = write (descrip_imagery , TAMP2 , 6); - if (cr_write != 6) - { - strcpy ( CAI_ERREUR, "Erreur d'ecriture du fichier Imagery SPOT1A4"); - goto ERREUR; - } - - cr_write = write (descrip_imagery , TAMP2[1] , 6); - if (cr_write != 6) - { - strcpy ( CAI_ERREUR, "Erreur d'ecriture du fichier Imagery SPOT1A4"); - goto ERREUR; - } - - - cr_write = write (descrip_imagery, TAB, 24); - if (cr_write != 24) - { - strcpy(CAI_ERREUR,"Erreur d'ecriture du fichier Imagery SPOT1A4"); - goto ERREUR; - } - - if (*nboct_pix == 1) - { - strcpy ( TAB ," 8"); - } - else if (*nboct_pix == 2) - { - strcpy ( TAB, " 16"); - } - - - cr_write = write (descrip_imagery, TAB, 4); - if (cr_write != 4) - { - strcpy(CAI_ERREUR,"Erreur d'ecriture du fichier Imagery SPOT1A4"); - goto ERREUR; - } - - for (i=0;i<15;i++) - { - strcpy ( &TAB[i]," "); - } - - strcpy(TAB, " 1 1 "); - cr_write = write (descrip_imagery, TAB, 12); - if (cr_write != 12) - { - strcpy(CAI_ERREUR,"Erreur d'ecriture du fichier Imagery SPOT1A4"); - goto ERREUR; - } - - - sprintf(TAB,"%4.d",*nbca); - cr_write = write ( descrip_imagery , TAB , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR,"Erreur d'ecriture du fichier Imagery SPOT1A4"); - goto ERREUR; - } - - cr_write = write (descrip_imagery, TAMP2[2], 8); - if (cr_write != 8) - { - strcpy(CAI_ERREUR,"Erreur d'ecriture du fichier Imagery SPOT1A4"); - goto ERREUR; - } - - for (i=0;i<5;i++) - { - strcpy ( &TAB[i]," "); - } - - - strcpy ( TAB, " 0"); - cr_write = write ( descrip_imagery , TAB , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR,"Erreur d'ecriture du fichier Imagery SPOT1A4"); - goto ERREUR; - } - - cr_write = write (descrip_imagery, TAMP2[3], 8); - if (cr_write != 8) - { - strcpy(CAI_ERREUR,"Erreur d'ecriture du fichier Imagery SPOT1A4"); - goto ERREUR; - } - - cr_write = write (descrip_imagery, TAMP2[4], 4); - if (cr_write != 4) - { - strcpy(CAI_ERREUR,"Erreur d'ecriture du fichier Imagery SPOT1A4"); - goto ERREUR; - } - - for (i=0;i<16;i++) - { - strcpy ( &TAB[i]," "); - } - - strcpy ( TAB, " 0 0BIL 1"); - cr_write = write ( descrip_imagery , TAB , 14); - if (cr_write != 14) - { - strcpy ( CAI_ERREUR,"Erreur d'ecriture du fichier Imagery SPOT1A4"); - goto ERREUR; - } - - sprintf(TAB,"%4.d",*nbca); - - cr_write = write ( descrip_imagery , TAB , 2); - if (cr_write != 2) - { - strcpy ( CAI_ERREUR,"Erreur d'ecriture du fichier Imagery SPOT1A4"); - goto ERREUR; - } - - - for (i=0;i<6;i++) - { - strcpy ( &TAB[i]," "); - } - - strcpy ( TAB, " 20"); - cr_write = write ( descrip_imagery , TAB , 4); - if (cr_write != 4) - { - strcpy ( CAI_ERREUR,"Erreur d'ecriture du fichier Imagery SPOT1A4"); - goto ERREUR; - } - - if (lgrec == 5400) - { - strcpy(TAB , " 5300"); - } - else - { - if (lgrec == 8640) - { - strcpy(TAB , " 8540"); - } - else - { - if (lgrec == 10980) - { - strcpy(TAB, " 10880"); - } - else strcpy(TAB, " 12140"); - } - } - cr_write = write ( descrip_imagery , TAB , 8); - if (cr_write != 8) - { - strcpy ( CAI_ERREUR , "Erreur d'ecriture du fichier Imagery SPOT1A4"); - goto ERREUR; - } - - strcpy ( TAB, " 28 1 4PB 5 4PB"); - cr_write = write ( descrip_imagery , TAB , 24); - if (cr_write != 24) - { - strcpy ( CAI_ERREUR,"Erreur d'ecriture du fichier Imagery SPOT1A4"); - goto ERREUR; - } - strcpy ( TAB, " "); - if ( LEVEL[0] == 'A') - { - strcpy(TAB," 9 4PB"); - } - if (( LEVEL[0] == 'B') || (LEVEL[0] == ' ')) - { - strcpy(TAB," "); - } - cr_write = write ( descrip_imagery , TAB , 8); - if (cr_write != 8) - { - strcpy ( CAI_ERREUR,"Erreur d'ecriture du fichier Imagery SPOT1A4"); - goto ERREUR; - } - - strcpy ( TAB , " 13 4PB 17 4PB"); - cr_write = write ( descrip_imagery , TAB , 16); - if (cr_write != 16) - { - strcpy ( CAI_ERREUR,"Erreur d'ecriture du fichier Imagery SPOT1A4"); - goto ERREUR; - } - - for (i=0;i<40;i++) - { - strcpy ( &TAB[i]," "); - } - - cr_write = write ( descrip_imagery , TAB , 32); - if (cr_write != 32) - { - strcpy ( CAI_ERREUR,"Erreur d'ecriture du fichier Imagery SPOT1A4"); - goto ERREUR; - } - - if ( LEVEL[0] == 'A') - { - strcpy(TAB," 1 2PB"); - } - if (( LEVEL[0] == 'B') || ( LEVEL[0] == ' ')) - { - strcpy(TAB," "); - } - cr_write = write ( descrip_imagery , TAB , 8); - if (cr_write != 8) - { - strcpy ( CAI_ERREUR,"Erreur d'ecriture du fichier Imagery SPOT1A4"); - goto ERREUR; - } - - for (i=0;i<60;i++) - { - strcpy ( &TAB[i]," "); - } - - cr_write = write ( descrip_imagery , TAB , 56); - if (cr_write != 56) - { - strcpy ( CAI_ERREUR,"Erreur d'ecriture du fichier Imagery SPOT1A4"); - goto ERREUR; - } - - strcpy ( TAB, " 0 0 254"); - cr_write = write ( descrip_imagery , TAB , 16); - if (cr_write != 16) - { - strcpy ( CAI_ERREUR,"Erreur d'ecriture du fichier Imagery SPOT1A4"); - goto ERREUR; - } - - -/* Mise a blanc de lgrec-180-268 = lgrec-448 octets */ - - for (i=0;i<5000;i++) - { - strcpy ( &TAB[i]," "); - } - - k = lgrec-448; - cr_write = write ( descrip_imagery , TAB , k); - if (cr_write != k) - { - strcpy ( CAI_ERREUR,"Erreur d'ecriture du fichier Imagery SPOT1A4"); - goto ERREUR; - } - -/*------------------------------------*/ -/* Ecriture de l'image entiere a vide */ -/*------------------------------------*/ - nb=(*nblig)*(*nbca); - for (i=0;i<lgrec;i++) - { - TAB[i]=0; - } - - for (i=0;i<nb;i++) - { - cr_write = write ( descrip_imagery , TAB , lgrec); - if (cr_write != lgrec) - { - strcpy ( CAI_ERREUR, - "Erreur d'ecriture du fichier Imagery SPOT1A4 a vide"); - goto ERREUR; - } - } - - /*stockage de la long enregistrement et port */ - - for (i=0;i<*nbca;i=i+1) - { - image1->ACCES_CANAL_INT[i]=descrip_imagery; - image1->POS_OCTET[i]=lgrec; - } - image1->TYPE_SPOT = 1; - - /* Sortie sans erreur : */ - return(image1); - -/* Sorties degradees : */ - -ERREUR: - -/* Fermeture des fichiers et destructions */ - if (descrip_leader>0) close(descrip_leader); - if (descrip_trailer>0) close(descrip_trailer); - if (descrip_volume>0) close(descrip_volume); - if (descrip_null>0) close(descrip_null); - if (descrip_imagery>0) close(descrip_imagery); - if (Existe==0) - { - sprintf(Command,"rm -R %s",nom_rep); - system(Command); - } - else - { - sprintf(nom_fic,"%s/LEAD_01.DAT",nom_rep); - unlink(nom_fic); - sprintf(nom_fic,"%s/TRAI_01.DAT",nom_rep); - unlink(nom_fic); - sprintf(nom_fic,"%s/VOLD_01.DAT",nom_rep); - unlink(nom_fic); - sprintf(nom_fic,"%s/IMAG_01.DAT",nom_rep); - unlink(nom_fic); - sprintf(nom_fic,"%s/NULL_01.DAT",nom_rep); - unlink(nom_fic); - } - - return(NULL); - -} -/* - Fin de l'operation cai_ouvre_creation_spot1a4 -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_creation_spot5TIF */ -/* ---------- */ -/* */ -/* ROLE : fonction de creation et d'ouverture en ecriture d'une image */ -/* ----- au format spot5 TIFF et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_creation_spot5TIF(repert, */ -/* ---------------- nom_image,nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig, */ -/* label) */ -/* */ -/* repert (E) (char *) : repertoire de stockage */ -/* nom_image (E) (char *) : nom de l'image a ouvrir */ -/* nb_can (E) (int ) : nombre de canaux de l'image */ -/* nboct_pix (E) (int ) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (E) (int ) : nombre de lignes de l'image */ -/* nb_col (E) (int ) : nombre de colonnes de l'image */ -/* label (E) (char *) : commentaire lie a l'image */ -/* */ -/* cai_ouvre_creation_spot5TIF (S) (CAI_IMAGE *) : =NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ -static CAI_IMAGE *cai_ouvre_creation_spot5TIF(char *repert, - char *nom_image, - int *nbca, - int *nboct_pix, - int *nbcol, - int *nblig, - char *label) - -{ - char nom_fic[1024]; /* nom du fichier leader */ - char nom_ficM[1024]; /* nom du fichier leader renomme */ - char nom_rep[1024]; /* nom du repertoire image */ - CAI_OK_KO icr; /* compte rendu d'operation */ - struct stat buf_stat; /* structure decrivant status de fichier */ - CAI_IMAGE *image1; /* descripteur image */ - int Existe; /* Indicateur d'existence du repertoire image */ - int retour,cr; /* retour de fonction stat */ - -/*........................................ - INITIALISATIONS et allocation de place pour la structure CAI_IMAGE - .........................................*/ - Existe = 0; - -/******************************************************************/ -/* Constitution du repertoire image s'il n'existe pas deja */ -/******************************************************************/ - - nom_fic[0]='\0'; - if ((long)strlen(repert)!= 0) - { - sprintf(nom_rep,"%s/%s",repert,nom_image); - } - else - { - sprintf(nom_rep,"%s",nom_image); - } - - retour = stat ( nom_rep , &buf_stat ); - - /* si le repertoire image n'existe pas, le creer*/ - if ( retour != 0 ) - { - cr = mkdir (nom_rep,0775); - if (cr !=0) - { - sprintf ( CAI_ERREUR , - "probleme a la creation du repertoire image %s SPOT5TIFF \n" , - nom_image ); - retour =0; - goto ERREUR; - } - } - else - Existe = 1; - -/******************************************************************/ -/* Constitution du nom du fichier IMAGERY et verification qu'il */ -/* n'existe pas deja */ /******************************************************************/ -/*****************************************************************/ -/* MOD : VERSION : 4.7 : DM : IMAG_01.TIF devient IMAGERY.TIF */ -/*****************************************************************/ - sprintf(nom_fic,"%s/IMAGERY.TIF",nom_rep); - retour = stat ( nom_fic , &buf_stat ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "Le fichier %s IMAGERY SPOT5TIFF existe \n" , - nom_image ); - goto ERREUR; - } - sprintf(nom_fic,"IMAGERY"); - image1 = cai_ouvre_creation_tiff(nom_rep,nom_fic,nbca, - nboct_pix,nbcol,nblig,label); - if (image1 == NULL) - goto ERREUR; -/******************************************************************/ -/* fichier LEADER : verification s'il existe pas deja */ -/******************************************************************/ -/*****************************************************************/ -/* MOD : VERSION : 4.7 : DM : LEAD_01.DAT devient METADATA.DIM */ -/*****************************************************************/ - - sprintf(nom_fic,"%s/METADATA.DIM",nom_rep); - - retour = stat ( nom_fic , &buf_stat ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR ,"Le fichier %s METADATA.DIM SPOT5TIFF existe \n" , - nom_image ); - goto ERREUR; - } - -/******************************************************************/ -/* fichier METADATA.DIM : constitution */ -/******************************************************************/ - image1->NB_LIG = (*nblig); - image1->NB_COL = (*nbcol); - image1->NB_CANAUX = (*nbca); - image1->NBOCT_PIX = (*nboct_pix); - image1->TYPE_SPOT = 2; - icr = cai_creat_leader_spot5(image1,nom_fic); - if (icr !=CAI_OK) - { - sprintf ( CAI_ERREUR , "Erreur creation METADATA.DIM SPOT5TIFF" ); - goto ERREUR; - - } - -/*****************************************************************************/ -/* MOD : VERSION : 5.0 : DM : Remplacer les appels systemes pour renommer un */ -/* fichier par la commande C rename */ -/*****************************************************************************/ - /* Sortie sans erreur : */ -/* renommer l'image en majuscule */ - sprintf(nom_fic,"%s/IMAGERY.tif",nom_rep); - sprintf(nom_ficM,"%s/IMAGERY.TIF",nom_rep); - rename(nom_fic,nom_ficM); - - return(image1); - -/* Sorties degradees : */ - -ERREUR: -/* destruction du fichier leader et de l'image */ -/* et s'il n'existe pas du repertoire */ - if (image1 != NULL) - icr = cai_ferme_tiff (image1); - - if (Existe==0) - { - sprintf(Command,"rm -R %s",nom_rep); - system(Command); - } - return(NULL); - -} -/* - Fin de l'operation cai_ouvre_creation_spot5TIF -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_creation_spot5BIL */ -/* ---------- */ -/* */ -/* ROLE : fonction de creation et d'ouverture en ecriture d'une image */ -/* ----- au format spot5 BIL et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_creation_spot5BIL(repert, */ -/* ---------------- nom_image,nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig, */ -/* label) */ -/* */ -/* repert (E) (char *) : repertoire de stockage */ -/* nom_image (E) (char *) : nom de l'image a ouvrir */ -/* nb_can (E) (int ) : nombre de canaux de l'image */ -/* nboct_pix (E) (int ) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (E) (int ) : nombre de lignes de l'image */ -/* nb_col (E) (int ) : nombre de colonnes de l'image */ -/* label (E) (char *) : commentaire lie a l'image */ -/* */ -/* cai_ouvre_creation_spot5BIL (S) (CAI_IMAGE *) : =NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ -static CAI_IMAGE *cai_ouvre_creation_spot5BIL(char *repert, - char *nom_image, - int *nbca, - int *nboct_pix, - int *nbcol, - int *nblig, - char *label) -{ - char nom_fic[1024]; /* nom du fichier leader */ - char nom_ficM[1024]; /* nom du fichier leader renomme */ - char nom_rep[1024],*Fic; /* nom du repertoire image */ - CAI_OK_KO icr; /* compte rendu d'operation */ - struct stat buf_stat; /* structure decrivant status de fichier */ - CAI_IMAGE *image1; /* descripteur image */ - int Existe; /* Indicateur d'existence du repertoire image */ - int retour,cr; /* retour de fonction stat */ - -/*........................................ - INITIALISATIONS et allocation de place pour la structure CAI_IMAGE - .........................................*/ - Existe = 0; - -/******************************************************************/ -/* Constitution du repertoire image s'il n'existe pas deja */ -/******************************************************************/ - - nom_fic[0]='\0'; - if ((long)strlen(repert)!= 0) - { - sprintf(nom_rep,"%s/%s",repert,nom_image); - } - else - { - sprintf(nom_rep,"%s",nom_image); - } - - retour = stat ( nom_rep , &buf_stat ); - - /* si le repertoire image n'existe pas, le creer*/ - if ( retour != 0 ) - { - cr = mkdir (nom_rep,0775); - if (cr !=0) - { - sprintf ( CAI_ERREUR , - "probleme a la creation du repertoire image %s SPOT5BIL \n" , - nom_image ); - goto ERREUR; - } - } - else - Existe = 1; - -/******************************************************************/ -/* Constitution du nom du fichier IMAGERY et verification qu'il */ -/* n'existe pas deja */ /******************************************************************/ -/****************************************************************/ -/* MOD : VERSION : 4.7 : DM : IMAG_XX.bil devient IMAGERY.BIL */ -/****************************************************************/ - sprintf(nom_fic,"%s/IMAGERY.BIL",nom_rep); - retour = stat ( nom_fic , &buf_stat ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "Le fichier %s IMAGERY SPOT5BIL existe \n" , - nom_image ); - goto ERREUR; - } -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : FA : Correction sprintf(nom_fic,"IMAGERY") au lieu */ -/* de sprintf(nom_fic,"IMAGERY",nom_rep) */ -/*****************************************************************************/ - sprintf(nom_fic,"IMAGERY"); - image1 = cai_ouvre_creation_bil(nom_rep,nom_fic,nbca, - nboct_pix,nbcol,nblig,label); - if (image1 == NULL) - goto ERREUR; - else - { -/* destruction du fichier .bil_hd qui n'a aucune utilite pour Spot5 */ - sprintf(nom_fic,"%s/IMAGERY.bil_hd",nom_rep); - unlink(nom_fic); - } -/******************************************************************/ -/* fichier LEADER : verification s'il existe pas deja */ -/******************************************************************/ -/*****************************************************************/ -/* MOD : VERSION : 4.7 : DM : LEAD_01.DAT devient METADATA.DIM */ -/*****************************************************************/ - sprintf(nom_fic,"%s/METADATA.DIM",nom_rep); - - retour = stat ( nom_fic , &buf_stat ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "Le fichier %s METADATA.DIM SPOT5BIL existe \n" , - nom_image ); - goto ERREUR; - } - -/******************************************************************/ -/* fichier METADATA.DIM : constitution */ -/******************************************************************/ - image1->NB_LIG = (*nblig); - image1->NB_COL = (*nbcol); - image1->NB_CANAUX = (*nbca); - image1->NBOCT_PIX = (*nboct_pix); - image1->TYPE_SPOT = 3; - icr = cai_creat_leader_spot5(image1,nom_fic); - if (icr !=CAI_OK) - { - sprintf ( CAI_ERREUR , "Erreur creation METADATA.DIM SPOT5BIL" ); - goto ERREUR; - - } - -/*****************************************************************************/ -/* MOD : VERSION : 5.0 : DM : Remplacer les appels systemes pour renommer un */ -/* fichier par la commande C rename */ -/*****************************************************************************/ - /* Sortie sans erreur : */ -/* renommer l'image en majuscule */ - sprintf(nom_fic,"%s/IMAGERY.bil",nom_rep); - sprintf(nom_ficM,"%s/IMAGERY.BIL",nom_rep); - rename(nom_fic,nom_ficM); - - return(image1); - -/* Sorties degradees : */ - -ERREUR: -/* destruction du fichier leader et de l'image */ -/* et s'il n'existe pas du repertoire */ - if (image1 != NULL) - icr = cai_ferme_bil (image1); - - if (Existe==0) - { - sprintf(Command,"rm -R %s",nom_rep); - system(Command); - } - return(NULL); - -} -/* - Fin de l'operation cai_ouvre_creation_spot5BIL -*/ -/******************************************************************************/ -/* */ -/*OPERATION : cai_creat_leader_spot5 */ -/* */ -/*ROLE : Cette operation genère un fichier XML de donnees auxiliaires SPOT5 */ -/* a partir des donnees cai_image passees en parametre */ -/* */ -/*CONTEXTE D'APPEL : */ -/* */ -/*RETOUR : CAI_OK si tout va bien , CAI_KO sinon */ -/* */ -/******************************************************************************/ -/*****************************************************************************/ -/* MOD : VERSION : 4.5 : FA : erreur d'orthographe sur LATITUDE_ARGUMENT */ -/* et Look_Angles */ -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : FA : erreur initialisation BYTEORDER en creation */ -/*****************************************************************************/ - -CAI_OK_KO cai_creat_leader_spot5 ( CAI_IMAGE *desc_im , char *nom_fich ) - { - /* Code retour */ - CAI_OK_KO cr; - /* Fichier XML a generer */ - FILE *des; - /* Nombre de lignes de l'image */ - int nblig; - /* Nombre de colonnes */ - int nbcol; - /* Nombre de canaux */ - int nbcan; - /* Nombre d'octets par pixel */ - int nboct; - /* type de SPOT ( TIFF ou BIL ) */ - int typeimg; - int type; - - int i; - - char valeur[200]; - - /* affectation des variables */ - - nblig = desc_im->NB_LIG; - nbcol = desc_im->NB_COL; - nbcan = desc_im->NB_CANAUX; - nboct = desc_im->NBOCT_PIX; - typeimg = desc_im->TYPE_SPOT; - - /********************************************************/ - /* OUVERTURE DU FICHIER XML PRODUIT */ - /********************************************************/ - - if ( ( des = fopen ( nom_fich , "wb" ) ) == NULL ) - { - sprintf ( CAI_ERREUR , "Impossible de creer le fichier XML %s" , nom_fich ); - goto ERREUR; - } - - /********************************************************/ - /* ECRITURE DES DONNEES XML DANS LE FICHIER */ - /********************************************************/ - - /* Entete du document XML */ - - cr = cai_WriteEnteteXML ( des ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture entete XML" ); - goto ERREUR; - } - - /* Element Dimap_Document */ - - cr = cai_WriteOpenTagXML ( des , "Dimap_Document" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Dimap_Document" ); - goto ERREUR; - } - - /* Sous element Metadata_Id */ - - cr = cai_WriteOpenTagXML ( des , "Metadata_Id" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Metadata_Id" ); - goto ERREUR; - } - - /* sous element METADATA_FORMAT */ -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Version DIMAP passe de 2.0 à 2.9 */ -/*****************************************************************************/ - type=0; - cr = cai_WriteElementXMLWithAttribute ( des , "METADATA_FORMAT" , "DIMAP" , - "version" , "2.9",type ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element METADATA_FORMAT" ); - goto ERREUR; - } - - /* sous element METADATA_PROFILE */ - - cr = cai_WriteElementXML ( des , "METADATA_PROFILE" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element METADATA_PROFILE" ); - goto ERREUR; - } - - /* Fermeture de l'element Metadata_Id */ - - cr = cai_WriteCloseTagXML ( des , "Metadata_Id" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Metadata_Id" ); - goto ERREUR; - } - - /* Sous element Dataset_Id */ - - cr = cai_WriteOpenTagXML ( des , "Dataset_Id" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Dataset_Id" ); - goto ERREUR; - } - - /* sous element DATASET_NAME */ - - cr = cai_WriteElementXML ( des , "DATASET_NAME" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element DATASET_NAME" ); - goto ERREUR; - } - - /* sous element COPYRIGHT */ - - cr = cai_WriteElementXML ( des , "COPYRIGHT" , "COPYRIGHT CNES" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element COPYRIGHT" ); - goto ERREUR; - } - -/****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'attribut href="" */ -/****************************************************************************/ - - /* sous element DATASET_TN_PATH */ - type=1; - cr = cai_WriteElementXMLWithAttribute ( des , "DATASET_TN_PATH" , "" , "href" , "" ,type); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element DATASET_TN_PATH" ); - goto ERREUR; - } - - /* sous element DATASET_TN_FORMAT */ - - cr = cai_WriteElementXML ( des , "DATASET_TN_FORMAT" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element DATASET_TN_FORMAT" ); - goto ERREUR; - } - - /* sous element DATASET_QL_PATH */ - type=1; - cr = cai_WriteElementXMLWithAttribute ( des , "DATASET_QL_PATH" , "" , "href" , "" ,type); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element DATASET_QL_PATH" ); - goto ERREUR; - } - - /* sous element DATASET_QL_FORMAT */ - - cr = cai_WriteElementXML ( des , "DATASET_QL_FORMAT" , "" ); - - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element DATASET_QL_FORMAT" ); - goto ERREUR; - } - - /* Fermeture de l'element Dataset_Id */ - - cr = cai_WriteCloseTagXML ( des , "Dataset_Id" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Dataset_Id" ); - goto ERREUR; - } - - /* sous element Dataset_Sources */ - - cr = cai_WriteOpenTagXML ( des , "Dataset_Sources" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Dataset_Sources" ); - goto ERREUR; - } - - /* sous element Source_Information */ - - cr = cai_WriteOpenTagXML ( des , "Source_Information" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Source_Information" ); - goto ERREUR; - } - - /* sous element SOURCE_TYPE */ - - cr = cai_WriteElementXML ( des , "SOURCE_TYPE" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element SOURCE_TYPE" ); - goto ERREUR; - } - - /* sous element SOURCE_ID */ - - cr = cai_WriteElementXML ( des , "SOURCE_ID" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element SOURCE_ID" ); - goto ERREUR; - } - - /* sous element SOURCE_DESCRIPTION */ - - cr = cai_WriteElementXML ( des , "SOURCE_DESCRIPTION" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element SOURCE_DESCRIPTION" ); - goto ERREUR; - } - - /* sous element Scene_Source */ - - cr = cai_WriteOpenTagXML ( des , "Scene_Source" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Scene_Source" ); - goto ERREUR; - } - - /* sous element IMAGING_DATE */ - - cr = cai_WriteElementXML ( des , "IMAGING_DATE" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element IMAGING_DATE" ); - goto ERREUR; - } - - /* sous element IMAGING_TIME */ - - cr = cai_WriteElementXML ( des , "IMAGING_TIME" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element IMAGING_TIME" ); - goto ERREUR; - } - - /* sous element MISSION */ - - cr = cai_WriteElementXML ( des , "MISSION" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element MISSION" ); - goto ERREUR; - } - - /* sous element MISSION_INDEX */ - - cr = cai_WriteElementXML ( des , "MISSION_INDEX" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element MISSION_INDEX" ); - goto ERREUR; - } - - /* sous element INSTRUMENT */ - - cr = cai_WriteElementXML ( des , "INSTRUMENT" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element INSTRUMENT" ); - goto ERREUR; - } - - /* sous element INSTRUMENT_INDEX */ - - cr = cai_WriteElementXML ( des , "INSTRUMENT_INDEX" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element INSTRUMENT_INDEX" ); - goto ERREUR; - } - - /* sous element SENSOR_CODE */ - - cr = cai_WriteElementXML ( des , "SENSOR_CODE" , "" ); - - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element SENSOR_CODE" ); - goto ERREUR; - } - - /* sous element INCIDENCE_ANGLE */ - - cr = cai_WriteElementXML ( des , "INCIDENCE_ANGLE" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element INCIDENCE_ANGLE" ); - goto ERREUR; - } - - /* sous element SUN_AZIMUT */ - - cr = cai_WriteElementXML ( des , "SUN_AZIMUTH" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element SUN_AZIMUT" ); - goto ERREUR; - } - - /* sous element SUN_ELEVATION */ - - cr = cai_WriteElementXML ( des , "SUN_ELEVATION" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element SUN_ELEVATION" ); - goto ERREUR; - } - - /* sous element Imaging_Parameters */ - - cr = cai_WriteOpenTagXML ( des , "Imaging_Parameters" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Imaging_Parameters" ); - goto ERREUR; - } - - /* sous element REVOLUTION_NUMBER */ - - cr = cai_WriteElementXML ( des , "REVOLUTION_NUMBER" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element REVOLUTION_NUMBER" ); - goto ERREUR; - } - - /* sous element COMPRESSION_MODE */ - - cr = cai_WriteElementXML ( des , "COMPRESSION_MODE" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element COMPRESSION_MODE" ); - goto ERREUR; - } - - /* sous element DIRECT_PLAYBACK_INDICATOR */ - - cr = cai_WriteElementXML ( des , "DIRECT_PLAYBACK_INDICATOR" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element DIRECT_PLAYBACK_INDICATOR" ); - goto ERREUR; - } - - /* sous element REFOCUSING_STEP_NUM */ - - cr = cai_WriteElementXML ( des , "REFOCUSING_STEP_NUM" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element REFOCUSING_STEP_NUM" ); - goto ERREUR; - } - - /* sous element SWATH_MODE */ - - cr = cai_WriteElementXML ( des , "SWATH_MODE" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element SWATH_MODE" ); - goto ERREUR; - } - - /* Fermeture de l'element Imaging_Parameters */ - - cr = cai_WriteCloseTagXML ( des , "Imaging_Parameters" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Imaging_Parameters" ); - goto ERREUR; - } - - /* Fermeture de l'element Scene_Source */ - - cr = cai_WriteCloseTagXML ( des , "Scene_Source" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Scene_Source" ); - goto ERREUR; - } - - /* Fermeture de l'element Source_Information */ - - cr = cai_WriteCloseTagXML ( des , "Source_Information" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Source_Information" ); - goto ERREUR; - } - - /* Fermeture de l'element Dataset_Sources */ - - cr = cai_WriteCloseTagXML ( des , "Dataset_Sources" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Dataset_Sources" ); - goto ERREUR; - } - - /* sous element Coordinate_Reference_System */ - - cr = cai_WriteOpenTagXML ( des , "Coordinate_Reference_System" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Coordinate_Reference_System" ); - goto ERREUR; - } - -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'attribut version="5.2" */ -/*****************************************************************************/ - - /* sous element GEO_TABLES */ - type=0; - cr = cai_WriteElementXMLWithAttribute ( des , "GEO_TABLES" , "" , "version" , "5.2" ,type); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element GEO_TABLES" ); - goto ERREUR; - } - - /* sous element Horizontal_CS */ - - cr = cai_WriteOpenTagXML ( des , "Horizontal_CS" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Horizontal_CS" ); - goto ERREUR; - } - - /* sous element HORIZONTAL_CS_TYPE */ - - cr = cai_WriteElementXML ( des , "HORIZONTAL_CS_TYPE" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element HORIZONTAL_CS_TYPE" ); - goto ERREUR; - } - - /* sous element HORIZONTAL_CS_CODE */ - - cr = cai_WriteElementXML ( des , "HORIZONTAL_CS_CODE" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element HORIZONTAL_CS_CODE" ); - goto ERREUR; - } - - /* sous element HORIZONTAL_CS_NAME */ - - cr = cai_WriteElementXML ( des , "HORIZONTAL_CS_NAME" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element HORIZONTAL_CS_NAME" ); - goto ERREUR; - } - - /* Fermeture de l'element Horizontal_CS */ - - cr = cai_WriteCloseTagXML ( des , "Horizontal_CS" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Horizontal_CS" ); - goto ERREUR; - } - - /* Fermeture de l'element Coordinate_Reference_System */ - - cr = cai_WriteCloseTagXML ( des , "Coordinate_Reference_System" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Coordinate_Reference_System" ); - goto ERREUR; - } - - /* sous element Raster_CS */ - - cr = cai_WriteOpenTagXML ( des , "Raster_CS" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Raster_CS" ); - goto ERREUR; - } - - /* sous element RASTER_CS_TYPE */ - - cr = cai_WriteElementXML ( des , "RASTER_CS_TYPE" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element RASTER_CS_TYPE" ); - goto ERREUR; - } - -/****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element PIXEL_ORIGIN */ -/****************************************************************************/ - - /* sous element PIXEL_ORIGIN */ - - cr = cai_WriteElementXML ( des , "PIXEL_ORIGIN" , "1" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element PIXEL_ORIGIN" ); - goto ERREUR; - } - - /* Fermeture de l'element Raster_CS */ - - cr = cai_WriteCloseTagXML ( des , "Raster_CS" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Raster_CS" ); - goto ERREUR; - } - - /* sous element Geoposition */ - - cr = cai_WriteOpenTagXML ( des , "Geoposition" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Geoposition" ); - goto ERREUR; - } - - /* sous element Geoposition_Points */ - - cr = cai_WriteOpenTagXML ( des , "Geoposition_Points" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Geoposition_Points" ); - goto ERREUR; - } - - /* sous element Tie_Point */ - - cr = cai_WriteOpenTagXML ( des , "Tie_Point" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Tie_Point" ); - goto ERREUR; - } - - /* sous element TIE_POINTS_CRS_X */ - - cr = cai_WriteElementXML ( des , "TIE_POINTS_CRS_X" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element TIE_POINTS_CRS_X" ); - goto ERREUR; - } - - /* sous element TIE_POINTS_CRS_Y */ - - cr = cai_WriteElementXML ( des , "TIE_POINTS_CRS_Y" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element TIE_POINTS_CRS_Y" ); - goto ERREUR; - } - -/****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element TIE_POINTS_CRS_Z */ -/****************************************************************************/ - - /* sous element TIE_POINTS_CRS_Z */ - - cr = cai_WriteElementXML ( des , "TIE_POINTS_CRS_Z" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element TIE_POINTS_CRS_Z" ); - goto ERREUR; - } - - /* sous element TIE_POINTS_DATA_X */ - - cr = cai_WriteElementXML ( des , "TIE_POINTS_DATA_X" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element TIE_POINTS_DATA_X" ); - goto ERREUR; - } - - /* sous element TIE_POINTS_DATA_Y */ - - cr = cai_WriteElementXML ( des , "TIE_POINTS_DATA_Y" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element TIE_POINTS_DATA_Y" ); - goto ERREUR; - } - - /* Fermeture de l'element Tie_Point */ - - cr = cai_WriteCloseTagXML ( des , "Tie_Point" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Tie_Point" ); - goto ERREUR; - } - - /* sous element Tie_Point */ - - cr = cai_WriteOpenTagXML ( des , "Tie_Point" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Tie_Point" ); - goto ERREUR; - } - - /* sous element TIE_POINTS_CRS_X */ - - cr = cai_WriteElementXML ( des , "TIE_POINTS_CRS_X" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element TIE_POINTS_CRS_X" ); - goto ERREUR; - } - - /* sous element TIE_POINTS_CRS_Y */ - - cr = cai_WriteElementXML ( des , "TIE_POINTS_CRS_Y" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element TIE_POINTS_CRS_Y" ); - goto ERREUR; - } - -/****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element TIE_POINTS_CRS_Z */ -/****************************************************************************/ - - /* sous element TIE_POINTS_CRS_Z */ - - cr = cai_WriteElementXML ( des , "TIE_POINTS_CRS_Z" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element TIE_POINTS_CRS_Z" ); - goto ERREUR; - } - - - /* sous element TIE_POINTS_DATA_X */ - - cr = cai_WriteElementXML ( des , "TIE_POINTS_DATA_X" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element TIE_POINTS_DATA_X" ); - goto ERREUR; - } - - /* sous element TIE_POINTS_DATA_Y */ - - cr = cai_WriteElementXML ( des , "TIE_POINTS_DATA_Y" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element TIE_POINTS_DATA_Y" ); - goto ERREUR; - } - - /* Fermeture de l'element Tie_Point */ - - cr = cai_WriteCloseTagXML ( des , "Tie_Point" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Tie_Point" ); - goto ERREUR; - } - - /* sous element Tie_Point */ - - cr = cai_WriteOpenTagXML ( des , "Tie_Point" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Tie_Point" ); - goto ERREUR; - } - - /* sous element TIE_POINTS_CRS_X */ - - cr = cai_WriteElementXML ( des , "TIE_POINTS_CRS_X" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element TIE_POINTS_CRS_X" ); - goto ERREUR; - } - - /* sous element TIE_POINTS_CRS_Y */ - - cr = cai_WriteElementXML ( des , "TIE_POINTS_CRS_Y" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element TIE_POINTS_CRS_Y" ); - goto ERREUR; - } - -/****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element TIE_POINTS_CRS_Z */ -/****************************************************************************/ - - /* sous element TIE_POINTS_CRS_Z */ - - cr = cai_WriteElementXML ( des , "TIE_POINTS_CRS_Z" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element TIE_POINTS_CRS_Z" ); - goto ERREUR; - } - - - /* sous element TIE_POINTS_DATA_X */ - - cr = cai_WriteElementXML ( des , "TIE_POINTS_DATA_X" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element TIE_POINTS_DATA_X" ); - goto ERREUR; - } - - /* sous element TIE_POINTS_DATA_Y */ - - cr = cai_WriteElementXML ( des , "TIE_POINTS_DATA_Y" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element TIE_POINTS_DATA_Y" ); - goto ERREUR; - } - - /* Fermeture de l'element Tie_Point */ - - cr = cai_WriteCloseTagXML ( des , "Tie_Point" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Tie_Point" ); - goto ERREUR; - } - - /* sous element Tie_Point */ - - cr = cai_WriteOpenTagXML ( des , "Tie_Point" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Tie_Point" ); - goto ERREUR; - } - - /* sous element TIE_POINTS_CRS_X */ - - cr = cai_WriteElementXML ( des , "TIE_POINTS_CRS_X" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element TIE_POINTS_CRS_X" ); - goto ERREUR; - } - - /* sous element TIE_POINTS_CRS_Y */ - - cr = cai_WriteElementXML ( des , "TIE_POINTS_CRS_Y" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element TIE_POINTS_CRS_Y" ); - goto ERREUR; - } - -/****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element TIE_POINTS_CRS_Z */ -/****************************************************************************/ - - /* sous element TIE_POINTS_CRS_Z */ - - cr = cai_WriteElementXML ( des , "TIE_POINTS_CRS_Z" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element TIE_POINTS_CRS_Z" ); - goto ERREUR; - } - - /* sous element TIE_POINTS_DATA_X */ - - cr = cai_WriteElementXML ( des , "TIE_POINTS_DATA_X" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element TIE_POINTS_DATA_X" ); - goto ERREUR; - } - - /* sous element TIE_POINTS_DATA_Y */ - - cr = cai_WriteElementXML ( des , "TIE_POINTS_DATA_Y" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element TIE_POINTS_DATA_Y" ); - goto ERREUR; - } - - /* Fermeture de l'element Tie_Point */ - - cr = cai_WriteCloseTagXML ( des , "Tie_Point" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Tie_Point" ); - goto ERREUR; - } - - /* Fermeture de l'element Geoposition_Points */ - - cr = cai_WriteCloseTagXML ( des , "Geoposition_Points" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Geoposition_Points" ); - goto ERREUR; - } - -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Deplacement de Simplified_Location_Model */ -/*****************************************************************************/ - - /* sous element Simplified_Location_Model */ - - cr = cai_WriteOpenTagXML ( des , "Simplified_Location_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Simplified_Location_Model" ); - goto ERREUR; - } - - /* sous element Direct_Location_Model */ - - cr = cai_WriteOpenTagXML ( des , "Direct_Location_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Direct_Location_Model" ); - goto ERREUR; - } - -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element lc_List */ -/*****************************************************************************/ - - /* sous element lc_List */ - - cr = cai_WriteOpenTagXML ( des , "lc_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element lc_List" ); - goto ERREUR; - } - - /* sous element lc */ - - cr = cai_WriteElementXML ( des , "lc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element lc" ); - goto ERREUR; - } - - /* sous element lc */ - - cr = cai_WriteElementXML ( des , "lc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element lc" ); - goto ERREUR; - } - - /* sous element lc */ - - cr = cai_WriteElementXML ( des , "lc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element lc" ); - goto ERREUR; - } - - /* sous element lc */ - - cr = cai_WriteElementXML ( des , "lc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element lc" ); - goto ERREUR; - } - - /* sous element lc */ - - cr = cai_WriteElementXML ( des , "lc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element lc" ); - goto ERREUR; - } - - /* sous element lc */ - - cr = cai_WriteElementXML ( des , "lc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element lc" ); - goto ERREUR; - } - - /* Fermeture de l'element lc_List */ - - cr = cai_WriteCloseTagXML ( des , "lc_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element lc_List" ); - goto ERREUR; - } - -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element pc_List */ -/*****************************************************************************/ - - /* sous element pc_List */ - - cr = cai_WriteOpenTagXML ( des , "pc_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element pc_List" ); - goto ERREUR; - } - - /* sous element pc */ - - cr = cai_WriteElementXML ( des , "pc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element pc" ); - goto ERREUR; - } - - /* sous element pc */ - - cr = cai_WriteElementXML ( des , "pc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element pc" ); - goto ERREUR; - } - - /* sous element pc */ - - cr = cai_WriteElementXML ( des , "pc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element pc" ); - goto ERREUR; - } - - /* sous element pc */ - - cr = cai_WriteElementXML ( des , "pc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element pc" ); - goto ERREUR; - } - - /* sous element pc */ - - cr = cai_WriteElementXML ( des , "pc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element pc" ); - goto ERREUR; - } - - /* sous element pc */ - - cr = cai_WriteElementXML ( des , "pc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element pc" ); - goto ERREUR; - } - - /* Fermeture de l'element pc_List */ - - cr = cai_WriteCloseTagXML ( des , "pc_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element pc_List" ); - goto ERREUR; - } - - /* Fermeture de l'element Direct_Location_Model */ - - cr = cai_WriteCloseTagXML ( des , "Direct_Location_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Direct_Location_Model" ); - goto ERREUR; - } - - /* sous element Reverse_Location_Model */ - - cr = cai_WriteOpenTagXML ( des , "Reverse_Location_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Reverse_Location_Model" ); - goto ERREUR; - } - - /* sous element lc_List */ - - cr = cai_WriteOpenTagXML ( des , "lc_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element lc_List" ); - goto ERREUR; - } - - /* sous element lc */ - - cr = cai_WriteElementXML ( des , "lc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element lc" ); - goto ERREUR; - } - - /* sous element lc */ - - cr = cai_WriteElementXML ( des , "lc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element lc" ); - goto ERREUR; - } - - /* sous element lc */ - - cr = cai_WriteElementXML ( des , "lc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element lc" ); - goto ERREUR; - } - - /* sous element lc */ - - cr = cai_WriteElementXML ( des , "lc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element lc" ); - goto ERREUR; - } - - /* sous element lc */ - - cr = cai_WriteElementXML ( des , "lc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element lc" ); - goto ERREUR; - } - - /* sous element lc */ - - cr = cai_WriteElementXML ( des , "lc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element lc" ); - goto ERREUR; - } - - /* Fermeture de l'element lc_List */ - - cr = cai_WriteCloseTagXML ( des , "lc_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element lc_List" ); - goto ERREUR; - } - - /* sous element pc_List */ - - cr = cai_WriteOpenTagXML ( des , "pc_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element pc_List" ); - goto ERREUR; - } - - /* sous element pc */ - - cr = cai_WriteElementXML ( des , "pc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element pc" ); - goto ERREUR; - } - - /* sous element pc */ - - cr = cai_WriteElementXML ( des , "pc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element pc" ); - goto ERREUR; - } - - /* sous element pc */ - - cr = cai_WriteElementXML ( des , "pc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element pc" ); - goto ERREUR; - } - - /* sous element pc */ - - cr = cai_WriteElementXML ( des , "pc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element pc" ); - goto ERREUR; - } - - /* sous element pc */ - - cr = cai_WriteElementXML ( des , "pc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element pc" ); - goto ERREUR; - } - - /* sous element pc */ - - cr = cai_WriteElementXML ( des , "pc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element pc" ); - goto ERREUR; - } - - /* Fermeture de l'element pc_List */ - - cr = cai_WriteCloseTagXML ( des , "pc_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element pc_List" ); - goto ERREUR; - } - - /* Fermeture de l'element Reverse_Location_Model */ - - cr = cai_WriteCloseTagXML ( des , "Reverse_Location_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Reverse_Location_Model" ); - goto ERREUR; - } - - /* Fermeture de l'element Simplified_Location_Model */ - - cr = cai_WriteCloseTagXML ( des , "Simplified_Location_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Simplified_Location_Model" ); - goto ERREUR; - } - - /* Fermeture de l'element Geoposition */ - - cr = cai_WriteCloseTagXML ( des , "Geoposition" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Geoposition" ); - goto ERREUR; - } - - /* sous element Production */ - - cr = cai_WriteOpenTagXML ( des , "Production" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Production" ); - goto ERREUR; - } - - /* sous element DATASET_PRODUCER_NAME */ - - cr = cai_WriteElementXML ( des , "DATASET_PRODUCER_NAME" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element DATASET_PRODUCER_NAME" ); - goto ERREUR; - } - -/****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout attribut href="http://www.spotimage.fr" */ -/****************************************************************************/ - - /* sous element DATASET_PRODUCER_URL */ - type=1; - cr = cai_WriteElementXMLWithAttribute ( des , "DATASET_PRODUCER_URL" , "" , - "href" , "http://www.spotimage.fr" ,type); - - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element DATASET_PRODUCER_URL" ); - goto ERREUR; - } - - /* sous element DATASET_PRODUCTION_DATE */ - - cr = cai_WriteElementXML ( des , "DATASET_PRODUCTION_DATE" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element DATASET_PRODUCTION_DATE" ); - goto ERREUR; - } - - /* sous element PRODUCT_TYPE */ - - cr = cai_WriteElementXML ( des , "PRODUCT_TYPE" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element PRODUCT_TYPE" ); - goto ERREUR; - } - - /* sous element PRODUCT_INFO */ - - cr = cai_WriteElementXML ( des , "PRODUCT_INFO" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element PRODUCT_INFO" ); - goto ERREUR; - } - - /* sous element Production_Facility */ - - cr = cai_WriteOpenTagXML ( des , "Production_Facility" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Production_Facility" ); - goto ERREUR; - } - - /* sous element SOFTWARE_NAME */ - - cr = cai_WriteElementXML ( des , "SOFTWARE_NAME" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element SOFTWARE_NAME" ); - goto ERREUR; - } - - /* sous element SOFTWARE_VERSION */ - - cr = cai_WriteElementXML ( des , "SOFTWARE_VERSION" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element SOFTWARE_VERSION" ); - goto ERREUR; - } - - /* sous element PROCESSING_CENTER */ - - cr = cai_WriteElementXML ( des , "PROCESSING_CENTER" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element PROCESSING_CENTER" ); - goto ERREUR; - } - - /* Fermeture de l'element Production_Facility */ - - cr = cai_WriteCloseTagXML ( des , "Production_Facility" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Production_Facility" ); - goto ERREUR; - } - - /* Fermeture de l'element Production */ - - cr = cai_WriteCloseTagXML ( des , "Production" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Production" ); - goto ERREUR; - } - - /* sous element Raster_Dimensions */ - - cr = cai_WriteOpenTagXML ( des , "Raster_Dimensions" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Raster_Dimension" ); - goto ERREUR; - } - - /* sous element NCOLS */ - - sprintf ( valeur , "%d" , nbcol ); - cr = cai_WriteElementXML ( des , "NCOLS" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element NCOLS" ); - goto ERREUR; - } - - /* sous element NROWS */ - - sprintf ( valeur , "%d" , nblig ); - cr = cai_WriteElementXML ( des , "NROWS" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element NROWS" ); - goto ERREUR; - } - - /* sous element NBANDS */ - - sprintf ( valeur , "%d" , nbcan ); - cr = cai_WriteElementXML ( des , "NBANDS" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element NBANDS" ); - goto ERREUR; - } - - /* Fermeture de l'element Raster_Dimensions */ - - cr = cai_WriteCloseTagXML ( des , "Raster_Dimensions" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Raster_Dimensions" ); - goto ERREUR; - } - - /* sous element Raster_Encoding */ - - cr = cai_WriteOpenTagXML ( des , "Raster_Encoding" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Raster_Encoding" ); - goto ERREUR; - } - - /* sous element NBITS */ - - sprintf ( valeur , "%d" , nboct*8 ); - cr = cai_WriteElementXML ( des , "NBITS" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element NBITS" ); - goto ERREUR; - } - -/****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element DATA_TYPE */ -/****************************************************************************/ - - /* sous element DATA_TYPE */ - - cr = cai_WriteElementXML ( des , "DATA_TYPE" , "UNSIGNED" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element DATA_TYPE" ); - goto ERREUR; - } - - /* sous element BYTEORDER */ -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : FA : erreur initialisation BYTEORDER en creation */ -/*****************************************************************************/ - - /* Initialisation par defaut */ - if (strcmp(type_machine,"BE")==0) - cr = cai_WriteElementXML ( des , "BYTEORDER" , "M" ); - else - cr = cai_WriteElementXML ( des , "BYTEORDER" , "I" ); - - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element BYTEORDER" ); - goto ERREUR; - } - - /* sous element BANDS_LAYOUT */ - - if ( typeimg == 3 ) - sprintf ( valeur , "BIL" ); - else - sprintf ( valeur , "" ); - cr = cai_WriteElementXML ( des , "BANDS_LAYOUT" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element BANDS_LAYOUT" ); - goto ERREUR; - } - - /* Fermeture de l'element Raster_Encoding */ - - cr = cai_WriteCloseTagXML ( des , "Raster_Encoding" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Raster_Encoding" ); - goto ERREUR; - } - - /* sous element Data_Processing */ - - cr = cai_WriteOpenTagXML ( des , "Data_Processing" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Data_Processing" ); - goto ERREUR; - } - - /* sous element PROCESSING_LEVEL */ - - cr = cai_WriteElementXML ( des , "PROCESSING_LEVEL" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element PROCESSING_LEVEL" ); - goto ERREUR; - } - - /* sous element GEOMETRIC_PROCESSING */ - - cr = cai_WriteElementXML ( des , "GEOMETRIC_PROCESSING" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element GEOMETRIC_PROCESSING" ); - goto ERREUR; - } - - /* sous element Processing_Options */ - - cr = cai_WriteOpenTagXML ( des , "Processing_Options" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Processing_Options" ); - goto ERREUR; - } - - /* sous element Dynamic_Stretch */ - - cr = cai_WriteOpenTagXML ( des , "Dynamic_Stretch" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Dynamic_Stretch" ); - goto ERREUR; - } - - for ( i = 0 ; i < nbcan ; i++ ) - { - /* sous element Thresholds */ - - cr = cai_WriteOpenTagXML ( des , "Thresholds" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Thresholds" ); - goto ERREUR; - } - - /* sous element BAND_INDEX */ - - sprintf ( valeur , "%d" , (i+1) ); - cr = cai_WriteElementXML ( des , "BAND_INDEX" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element BAND_INDEX" ); - goto ERREUR; - } - - /* sous element LOW_THRESHOLD */ - - cr = cai_WriteElementXML ( des , "LOW_THRESHOLD" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element LOW_THRESHOLD" ); - goto ERREUR; - } - - /* sous element HIGH_THRESHOLD */ - - cr = cai_WriteElementXML ( des , "HIGH_THRESHOLD" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element HIGH_THRESHOLD" ); - goto ERREUR; - } - - /* Fermeture de l'element Thresholds */ - - cr = cai_WriteCloseTagXML ( des , "Thresholds" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Thresholds" ); - goto ERREUR; - } - } - /* Fermeture de l'element Dynamic_Stretch */ - - cr = cai_WriteCloseTagXML ( des , "Dynamic_Stretch" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Dynamic_Stretch" ); - goto ERREUR; - } - - /* Fermeture de l'element Processing_Options */ - - cr = cai_WriteCloseTagXML ( des , "Processing_Options" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Processing_Options" ); - goto ERREUR; - } - - /* Fermeture de l'element Data_Processing */ - - cr = cai_WriteCloseTagXML ( des , "Data_Processing" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Data_Processing" ); - goto ERREUR; - } - - /* sous element Data_Access */ - - cr = cai_WriteOpenTagXML ( des , "Data_Access" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Data_Access" ); - goto ERREUR; - } - - /* sous element DATA_FILE_ORGANISATION */ - - if ( typeimg == 3 ) - sprintf ( valeur , "BAND_COMPOSITE" ); - else - sprintf ( valeur , "" ); - - cr = cai_WriteElementXML ( des , "DATA_FILE_ORGANISATION" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element DATA_FILE_ORGANISATION" ); - goto ERREUR; - } - - /* sous element DATA_FILE_FORMAT */ - - if ( typeimg == 3 ) - sprintf ( valeur , "RAW" ); - else - sprintf ( valeur , "TIFF" ); - - cr = cai_WriteElementXML ( des , "DATA_FILE_FORMAT" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element DATA_FILE_FORMAT" ); - goto ERREUR; - } - - /* Fermeture de l'element Data_Access */ - - cr = cai_WriteCloseTagXML ( des , "Data_Access" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Data_Access" ); - goto ERREUR; - } - - /* sous element Image_Display */ - - cr = cai_WriteOpenTagXML ( des , "Image_Display" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Image_Display" ); - goto ERREUR; - } - - /* sous element Band_Display_Order */ - - cr = cai_WriteOpenTagXML ( des , "Band_Display_Order" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Band_Display_Order" ); - goto ERREUR; - } - - /* sous element RED_CHANNEL */ - - cr = cai_WriteElementXML ( des , "RED_CHANNEL" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element RED_CHANNEL" ); - goto ERREUR; - } - /* sous element GREEN_CHANNEL */ - - cr = cai_WriteElementXML ( des , "GREEN_CHANNEL" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element GREEN_CHANNEL" ); - goto ERREUR; - } - /* sous element BLUE_CHANNEL */ - - cr = cai_WriteElementXML ( des , "BLUE_CHANNEL" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element BLUE_CHANNEL" ); - goto ERREUR; - } - - /* Fermeture de l'element Band_Display_Order */ - - cr = cai_WriteCloseTagXML ( des , "Band_Display_Order" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Band_Display_Order" ); - goto ERREUR; - } - - /* sous element Special_Value */ - - cr = cai_WriteOpenTagXML ( des , "Special_Value" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Special_Value" ); - goto ERREUR; - } - - /* sous element SPECIAL_VALUE_INDEX */ - - cr = cai_WriteElementXML ( des , "SPECIAL_VALUE_INDEX" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element SPECIAL_VALUE_INDEX" ); - goto ERREUR; - } - - /* sous element SPECIAL_VALUE_TEXT */ - - cr = cai_WriteElementXML ( des , "SPECIAL_VALUE_TEXT" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element SPECIAL_VALUE_TEXT" ); - goto ERREUR; - } - - /* sous element Special_Value_Color */ - - cr = cai_WriteOpenTagXML ( des , "Special_Value_Color" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Special_Value_Color" ); - goto ERREUR; - } - - /* sous element RED_LEVEL */ - - cr = cai_WriteElementXML ( des , "RED_LEVEL" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element RED_LEVEL" ); - goto ERREUR; - } - - /* sous element GREEN_LEVEL */ - - cr = cai_WriteElementXML ( des , "GREEN_LEVEL" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element GREEN_LEVEL" ); - goto ERREUR; - } - - /* sous element BLUE_LEVEL */ - - cr = cai_WriteElementXML ( des , "BLUE_LEVEL" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element BLUE_LEVEL" ); - goto ERREUR; - } - - if (nbcan == 4) - { - /* sous element ALPHA_LEVEL */ - - cr = cai_WriteElementXML ( des , "ALPHA_LEVEL" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element ALPHA_LEVEL" ); - goto ERREUR; - } - } - - /* Fermeture de l'element Special_Value_Color */ - - cr = cai_WriteCloseTagXML ( des , "Special_Value_Color" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Special_Value_Color" ); - goto ERREUR; - } - - /* Fermeture de l'element Special_Value */ - - cr = cai_WriteCloseTagXML ( des , "Special_Value" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Special_Value" ); - goto ERREUR; - } - - /* sous element Special_Value */ - - cr = cai_WriteOpenTagXML ( des , "Special_Value" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Special_Value" ); - goto ERREUR; - } - - /* sous element SPECIAL_VALUE_INDEX */ - - cr = cai_WriteElementXML ( des , "SPECIAL_VALUE_INDEX" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element SPECIAL_VALUE_INDEX" ); - goto ERREUR; - } - - /* sous element SPECIAL_VALUE_TEXT */ - - cr = cai_WriteElementXML ( des , "SPECIAL_VALUE_TEXT" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element SPECIAL_VALUE_TEXT" ); - goto ERREUR; - } - - /* sous element Special_Value_Color */ - - cr = cai_WriteOpenTagXML ( des , "Special_Value_Color" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Special_Value_Color" ); - goto ERREUR; - } - - /* sous element RED_LEVEL */ - - cr = cai_WriteElementXML ( des , "RED_LEVEL" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element RED_LEVEL" ); - goto ERREUR; - } - - /* sous element GREEN_LEVEL */ - - cr = cai_WriteElementXML ( des , "GREEN_LEVEL" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element GREEN_LEVEL" ); - goto ERREUR; - } - - /* sous element BLUE_LEVEL */ - - cr = cai_WriteElementXML ( des , "BLUE_LEVEL" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element BLUE_LEVEL" ); - goto ERREUR; - } - - if (nbcan == 4) - { - /* sous element ALPHA_LEVEL */ - - cr = cai_WriteElementXML ( des , "ALPHA_LEVEL" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element ALPHA_LEVEL" ); - goto ERREUR; - } - } - - /* Fermeture de l'element Special_Value_Color */ - - cr = cai_WriteCloseTagXML ( des , "Special_Value_Color" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Special_Value_Color" ); - goto ERREUR; - } - - /* Fermeture de l'element Special_Value */ - - cr = cai_WriteCloseTagXML ( des , "Special_Value" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Special_Value" ); - goto ERREUR; - } - - /* Fermeture de l'element Image_Display */ - - cr = cai_WriteCloseTagXML ( des , "Image_Display" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Image_Display" ); - goto ERREUR; - } - - /* sous element Image_Interpretation */ - - cr = cai_WriteOpenTagXML ( des , "Image_Interpretation" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Image_Interpretation" ); - goto ERREUR; - } - - for ( i = 0; i < nbcan ; i++ ) - { - /* sous element Spectral_Band_Info */ - - cr = cai_WriteOpenTagXML ( des , "Spectral_Band_Info" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Spectral_Band_Info" ); - goto ERREUR; - } - - /* sous element BAND_INDEX */ - - sprintf ( valeur , "%d" , (i+1) ); - - cr = cai_WriteElementXML ( des , "BAND_INDEX" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element BAND_INDEX" ); - goto ERREUR; - } - -/******************************************************************************/ -/* MOD : VERSION : 4.7 : DM : remplacement de BAND par BAND_DESCRIPTION */ -/******************************************************************************/ - - /* sous element BAND_DESCRIPTION */ - - cr = cai_WriteElementXML ( des , "BAND_DESCRIPTION" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element BAND" ); - goto ERREUR; - } - - /* sous element PHYSICAL_CALIBRATION_DATE */ - - cr = cai_WriteElementXML ( des , "PHYSICAL_CALIBRATION_DATE" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element PHYSICAL_CALIBRATION_DATE" ); - goto ERREUR; - } - - /* sous element PHYSICAL_BIAIS */ - - cr = cai_WriteElementXML ( des , "PHYSICAL_BIAIS" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element PHYSICAL_BIAIS" ); - goto ERREUR; - } - - /* sous element PHYSICAL_GAIN */ - - cr = cai_WriteElementXML ( des , "PHYSICAL_GAIN" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element PHYSICAL_GAIN" ); - goto ERREUR; - } - - /* sous element PHYSICAL_UNIT */ - - cr = cai_WriteElementXML ( des , "PHYSICAL_UNIT" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element PHYSICAL_UNIT" ); - goto ERREUR; - } - - /* Fermeture de l'element Spectral_Band_Info */ - - cr = cai_WriteCloseTagXML ( des , "Spectral_Band_Info" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Spectral_Band_Info" ); - goto ERREUR; - } - - } - /* Fermeture de l'element Image_Interpretation */ - - cr = cai_WriteCloseTagXML ( des , "Image_Interpretation" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Image_Interpretation" ); - goto ERREUR; - } - - /* sous element Data_Strip */ - - cr = cai_WriteOpenTagXML ( des , "Data_Strip" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Data_Strip" ); - goto ERREUR; - } - - /* sous element Satellite_Time */ - - cr = cai_WriteOpenTagXML ( des , "Satellite_Time" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Satellite_Time" ); - goto ERREUR; - } - - /* sous element UT_DATE */ - - cr = cai_WriteElementXML ( des , "UT_DATE" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element UT_DATE" ); - goto ERREUR; - } - - /* sous element CLOCK_VALUE */ - - cr = cai_WriteElementXML ( des , "CLOCK_VALUE" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element CLOCK_VALUE" ); - goto ERREUR; - } - - /* sous element CLOCK_PERIOD */ - - cr = cai_WriteElementXML ( des , "CLOCK_PERIOD" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element CLOCK_PERIOD" ); - goto ERREUR; - } - - /* sous element BOARD_TIME */ - - cr = cai_WriteElementXML ( des , "BOARD_TIME" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element BOARD_TIME" ); - goto ERREUR; - } - - /* Fermeture de l'element Satellite_Time */ - - cr = cai_WriteCloseTagXML ( des , "Satellite_Time" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Satellite_Time" ); - goto ERREUR; - } - - /* sous element Ephemeris */ - - cr = cai_WriteOpenTagXML ( des , "Ephemeris" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Ephemeris" ); - goto ERREUR; - } - - /* sous element SATELLITE_ALTITUDE */ - - cr = cai_WriteElementXML ( des , "SATELLITE_ALTITUDE" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element SATELLITE_ALTITUDE" ); - goto ERREUR; - } - - /* sous element NADIR_LAT */ - - cr = cai_WriteElementXML ( des , "NADIR_LAT" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element NADIR_LAT" ); - goto ERREUR; - } - - /* sous element NADIR_LON */ - - cr = cai_WriteElementXML ( des , "NADIR_LON" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element NADIR_LON" ); - goto ERREUR; - } - - /* sous element Points */ - - cr = cai_WriteOpenTagXML ( des , "Points" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Points" ); - goto ERREUR; - } - - for ( i = 0; i < 8 ; i++ ) - { - /* sous element Point */ - - cr = cai_WriteOpenTagXML ( des , "Point" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Point" ); - goto ERREUR; - } - - /* sous element Location */ - - cr = cai_WriteOpenTagXML ( des , "Location" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Location" ); - goto ERREUR; - } - - /* sous element X */ - - cr = cai_WriteElementXML ( des , "X" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element X" ); - goto ERREUR; - } - - /* sous element Y */ - - cr = cai_WriteElementXML ( des , "Y" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Y" ); - goto ERREUR; - } - - /* sous element Z */ - - cr = cai_WriteElementXML ( des , "Z" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Z" ); - goto ERREUR; - } - - /* Fermeture de l'element Location */ - - cr = cai_WriteCloseTagXML ( des , "Location" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Location" ); - goto ERREUR; - } - - /* sous element Velocity */ - - cr = cai_WriteOpenTagXML ( des , "Velocity" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Velocity" ); - goto ERREUR; - } - - /* sous element X */ - - cr = cai_WriteElementXML ( des , "X" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element X" ); - goto ERREUR; - } - - /* sous element Y */ - - cr = cai_WriteElementXML ( des , "Y" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Y" ); - goto ERREUR; - } - - /* sous element Z */ - - cr = cai_WriteElementXML ( des , "Z" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Z" ); - goto ERREUR; - } - - /* Fermeture de l'element Velocity */ - - cr = cai_WriteCloseTagXML ( des , "Velocity" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Velocity" ); - goto ERREUR; - } - - /* sous element TIME */ - - cr = cai_WriteElementXML ( des , "TIME" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element TIME" ); - goto ERREUR; - } - - /* Fermeture de l'element Point */ - - cr = cai_WriteCloseTagXML ( des , "Point" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Point" ); - goto ERREUR; - } - } - - /* Fermeture de l'element Points */ - - cr = cai_WriteCloseTagXML ( des , "Points" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Points" ); - goto ERREUR; - } - - /* sous element DORIS_USED */ - - cr = cai_WriteElementXML ( des , "DORIS_USED" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element DORIS_USED" ); - goto ERREUR; - } - - /* Fermeture de l'element Ephemeris */ - - cr = cai_WriteCloseTagXML ( des , "Ephemeris" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Ephemeris" ); - goto ERREUR; - } - - /* sous element Sensor_Configuration */ - - cr = cai_WriteOpenTagXML ( des , "Sensor_Configuration" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Sensor_Configuration" ); - goto ERREUR; - } - - /* sous element Time_Stamp */ - - cr = cai_WriteOpenTagXML ( des , "Time_Stamp" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Time_Stamp" ); - goto ERREUR; - } - - /* sous element LINE_PERIOD */ - - cr = cai_WriteElementXML ( des , "LINE_PERIOD" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element LINE_PERIOD" ); - goto ERREUR; - } - - /* sous element SCENE_CENTER_TIME */ - - cr = cai_WriteElementXML ( des , "SCENE_CENTER_TIME" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element SCENE_CENTER_TIME" ); - goto ERREUR; - } - - /* sous element SCENE_CENTER_LINE */ - - cr = cai_WriteElementXML ( des , "SCENE_CENTER_LINE" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element SCENE_CENTER_LINE" ); - goto ERREUR; - } - - /* sous element SCENE_CENTER_COL */ - - cr = cai_WriteElementXML ( des , "SCENE_CENTER_COL" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element SCENE_CENTER_COL" ); - goto ERREUR; - } - - /* Fermeture de l'element Time_Stamp */ - - cr = cai_WriteCloseTagXML ( des , "Time_Stamp" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Time_Stamp" ); - goto ERREUR; - } - -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element Instrument_look_Angles_List */ -/*****************************************************************************/ - - /* sous element Instrument_Look_Angles_List */ - - cr = cai_WriteOpenTagXML ( des , "Instrument_Look_Angles_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Instrument_Look_Angles_List" ); - goto ERREUR; - } - - for ( i = 0 ; i < nbcan ; i++ ) - { - /* sous element Instrument_Look_Angles */ - - cr = cai_WriteOpenTagXML ( des , "Instrument_Look_Angles" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Instrument_Look_Angles" ); - goto ERREUR; - } - - /* sous element VALIDITY_DATE */ - - cr = cai_WriteElementXML ( des , "VALIDITY_DATE" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element VALIDITY_DATE" ); - goto ERREUR; - } - - /* sous element BAND_INDEX */ - - sprintf ( valeur , "%d" , (i+1) ); - cr = cai_WriteElementXML ( des , "BAND_INDEX" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element BAND_INDEX" ); - goto ERREUR; - } - -/*****************************************************************************/ -/* MOD : VERSION : 4.7 : DM : Ajout de l'element Look_Angles_List */ -/*****************************************************************************/ - - /* sous element Look_Angles_List */ - - cr = cai_WriteOpenTagXML ( des , "Look_Angles_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture element Look_Angles_List" ); - goto ERREUR; - } - - /* sous element Look_Angles */ - - cr = cai_WriteOpenTagXML ( des , "Look_Angles" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Look_Angles" ); - goto ERREUR; - } - - /* sous element DETECTOR_ID */ - - cr = cai_WriteElementXML ( des , "DETECTOR_ID" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element DETECTOR_ID" ); - goto ERREUR; - } - - /* sous element PSI_X */ - - cr = cai_WriteElementXML ( des , "PSI_X" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element PSI_X" ); - goto ERREUR; - } - - /* sous element PSI_Y */ - - cr = cai_WriteElementXML ( des , "PSI_Y" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element PSI_Y" ); - goto ERREUR; - } - - /* Fermeture de l'element Look_Angles */ - - cr = cai_WriteCloseTagXML ( des , "Look_Angles" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Look_Angles" ); - goto ERREUR; - } - - /* sous element Look_Angles */ - - cr = cai_WriteOpenTagXML ( des , "Look_Angles" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Look_Angles" ); - goto ERREUR; - } - - /* sous element DETECTOR_ID */ - - cr = cai_WriteElementXML ( des , "DETECTOR_ID" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element DETECTOR_ID" ); - goto ERREUR; - } - - /* sous element PSI_X */ - - cr = cai_WriteElementXML ( des , "PSI_X" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element PSI_X" ); - goto ERREUR; - } - - /* sous element PSI_Y */ - - cr = cai_WriteElementXML ( des , "PSI_Y" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element PSI_Y" ); - goto ERREUR; - } - - /* Fermeture de l'element Look_Angles */ - - cr = cai_WriteCloseTagXML ( des , "Look_Angles" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Look_Angles" ); - goto ERREUR; - } - - /* Fermeture de l'element Look_Angles_List */ - - cr = cai_WriteCloseTagXML ( des , "Look_Angles_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Look_Angles_List" ); - goto ERREUR; - } - - /* Fermeture de l'element Instrument_Look_Angles */ - - cr = cai_WriteCloseTagXML ( des , "Instrument_Look_Angles" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Instrument_Look_Angles" ); - goto ERREUR; - } - } - - /* Fermeture de l'element Instrument_Look_Angles_List */ - - cr = cai_WriteCloseTagXML ( des , "Instrument_Look_Angles_List" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Instrument_Look_Angles_List" ); - goto ERREUR; - } - - /* Fermeture de l'element Sensor_Configuration */ - - cr = cai_WriteCloseTagXML ( des , "Sensor_Configuration" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Sensor_Configuration" ); - goto ERREUR; - } - - /* sous element Frame_Counters */ - - cr = cai_WriteOpenTagXML ( des , "Frame_Counters" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Frame_Counters" ); - goto ERREUR; - } - - /* sous element SEGMENT_START */ - - cr = cai_WriteElementXML ( des , "SEGMENT_START" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element SEGMENT_START" ); - goto ERREUR; - } - - /* sous element SCENE_START */ - - cr = cai_WriteElementXML ( des , "SCENE_START" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element SCENE_START" ); - goto ERREUR; - } - - /* sous element SEGMENT_END */ - - cr = cai_WriteElementXML ( des , "SEGMENT_END" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element SEGMENT_END" ); - goto ERREUR; - } - - /* Fermeture de l'element Frame_Counters */ - - cr = cai_WriteCloseTagXML ( des , "Frame_Counters" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Frame_Counters" ); - goto ERREUR; - } - - /* sous element Data_Strip_Coordinates */ - - cr = cai_WriteOpenTagXML ( des , "Data_Strip_Coordinates" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Data_Strip_Coordinates" ); - goto ERREUR; - } - - /* sous element FIRST_PIXEL_RAW */ - - cr = cai_WriteElementXML ( des , "FIRST_PIXEL_RAW" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element FIRST_PIXEL_RAW" ); - goto ERREUR; - } - - /* sous element FIRST_LINE_RAW */ - - cr = cai_WriteElementXML ( des , "FIRST_LINE_RAW" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element FIRST_LINE_RAW" ); - goto ERREUR; - } - - /* sous element FIRST_PIXEL_1B */ - - cr = cai_WriteElementXML ( des , "FIRST_PIXEL_1B" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element FIRST_PIXEL_1B" ); - goto ERREUR; - } - - /* sous element FIRST_LINE_1B */ - - cr = cai_WriteElementXML ( des , "FIRST_LINE_1B" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element FIRST_LINE_1B" ); - goto ERREUR; - } - - /* Fermeture de l'element Data_Strip_Coordinates */ - - cr = cai_WriteCloseTagXML ( des , "Data_Strip_Coordinates" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Data_Strip_Coordinates" ); - goto ERREUR; - } - - /* sous element Models */ - - cr = cai_WriteOpenTagXML ( des , "Models" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Models" ); - goto ERREUR; - } - - /* sous element OneB_Model */ - - cr = cai_WriteOpenTagXML ( des , "OneB_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element OneB_Model" ); - goto ERREUR; - } - - /* sous element Coordinate_Normalization */ - - cr = cai_WriteOpenTagXML ( des , "Coordinate_Normalization" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Coordinate_Normalization" ); - goto ERREUR; - } - - /* sous element LINES_I_M */ - - cr = cai_WriteElementXML ( des , "LINES_I_M" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element LINES_I_M" ); - goto ERREUR; - } - - /* sous element LINES_DELTA_I */ - - cr = cai_WriteElementXML ( des , "LINES_DELTA_I" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element LINES_DELTA_I" ); - goto ERREUR; - } - - /* sous element COLUMNS_J_M */ - - cr = cai_WriteElementXML ( des , "COLUMNS_J_M" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element COLUMNS_J_M" ); - goto ERREUR; - } - - /* sous element COLUMNS_DELTA_J */ - - cr = cai_WriteElementXML ( des , "COLUMNS_DELTA_J" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element COLUMNS_DELTA_J" ); - goto ERREUR; - } - - /* sous element LINES_L_M */ - - cr = cai_WriteElementXML ( des , "LINES_L_M" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element LINES_L_M" ); - goto ERREUR; - } - - /* sous element LINES_DELTA_L */ - - cr = cai_WriteElementXML ( des , "LINES_DELTA_L" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element LINES_DELTA_L" ); - goto ERREUR; - } - - /* sous element COLUMNS_P_M */ - - cr = cai_WriteElementXML ( des , "COLUMNS_P_M" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element COLUMNS_P_M" ); - goto ERREUR; - } - - /* sous element COLUMNS_DELTA_P */ - - cr = cai_WriteElementXML ( des , "COLUMNS_DELTA_P" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element COLUMNS_DELTA_P" ); - goto ERREUR; - } - - /* Fermeture de l'element Coordinate_Normalization */ - - cr = cai_WriteCloseTagXML ( des , "Coordinate_Normalization" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Coordinate_Normalization" ); - goto ERREUR; - } - - - /* sous element Direct_OneB_Model */ - - cr = cai_WriteOpenTagXML ( des , "Direct_OneB_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Direct_OneB_Model" ); - goto ERREUR; - } - - /* sous element I */ - - cr = cai_WriteOpenTagXML ( des , "I" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element I" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element c" ); - goto ERREUR; - } - - /* Fermeture de l'element I */ - - cr = cai_WriteCloseTagXML ( des , "I" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element I" ); - goto ERREUR; - } - - /* sous element J */ - - cr = cai_WriteOpenTagXML ( des , "J" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element J" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element c" ); - goto ERREUR; - } - - /* Fermeture de l'element J */ - - cr = cai_WriteCloseTagXML ( des , "J" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element J" ); - goto ERREUR; - } - - /* Fermeture de l'element Direct_OneB_Model */ - - cr = cai_WriteCloseTagXML ( des , "Direct_OneB_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Direct_OneB_Model" ); - goto ERREUR; - } - - /* sous element Reverse_OneB_Model */ - - cr = cai_WriteOpenTagXML ( des , "Reverse_OneB_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Reverse_OneB_Model" ); - goto ERREUR; - } - - /* sous element L */ - - cr = cai_WriteOpenTagXML ( des , "L" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element L" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element c" ); - goto ERREUR; - } - - /* Fermeture de l'element L */ - - cr = cai_WriteCloseTagXML ( des , "L" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element L" ); - goto ERREUR; - } - - /* sous element P */ - - cr = cai_WriteOpenTagXML ( des , "P" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element P" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element c" ); - goto ERREUR; - } - - /* Fermeture de l'element P */ - - cr = cai_WriteCloseTagXML ( des , "P" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element P" ); - goto ERREUR; - } - - /* Fermeture de l'element Reverse_OneB_Model */ - - cr = cai_WriteCloseTagXML ( des , "Reverse_OneB_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Reverse_OneB_Model" ); - goto ERREUR; - } - - /* sous element A */ - - cr = cai_WriteOpenTagXML ( des , "A" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element A" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element c" ); - goto ERREUR; - } - - /* Fermeture de l'element A */ - - cr = cai_WriteCloseTagXML ( des , "A" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element A" ); - goto ERREUR; - } - - /* sous element B */ - - cr = cai_WriteOpenTagXML ( des , "B" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element B" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element c" ); - goto ERREUR; - } - - /* sous element c */ - - cr = cai_WriteElementXML ( des , "c" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element c" ); - goto ERREUR; - } - - /* Fermeture de l'element B */ - - cr = cai_WriteCloseTagXML ( des , "B" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element B" ); - goto ERREUR; - } - - /* Fermeture de l'element OneB_Model */ - - cr = cai_WriteCloseTagXML ( des , "OneB_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element OneB_Model" ); - goto ERREUR; - } - - /* sous element Attitude_Model */ - - cr = cai_WriteOpenTagXML ( des , "Attitude_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Attitude_Model" ); - goto ERREUR; - } - - /* sous element D_L */ - - cr = cai_WriteOpenTagXML ( des , "D_L" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element D_L" ); - goto ERREUR; - } - - /* sous element abc */ - - cr = cai_WriteElementXML ( des , "abc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element abc" ); - goto ERREUR; - } - - /* sous element abc */ - - cr = cai_WriteElementXML ( des , "abc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element abc" ); - goto ERREUR; - } - - /* sous element abc */ - - cr = cai_WriteElementXML ( des , "abc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element abc" ); - goto ERREUR; - } - - /* Fermeture de l'element D_L */ - - cr = cai_WriteCloseTagXML ( des , "D_L" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element D_L" ); - goto ERREUR; - } - - /* sous element D_P */ - - cr = cai_WriteOpenTagXML ( des , "D_P" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element D_P" ); - goto ERREUR; - } - - /* sous element abc */ - - cr = cai_WriteElementXML ( des , "abc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element abc" ); - goto ERREUR; - } - - /* sous element abc */ - - cr = cai_WriteElementXML ( des , "abc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element abc" ); - goto ERREUR; - } - - /* sous element abc */ - - cr = cai_WriteElementXML ( des , "abc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element abc" ); - goto ERREUR; - } - - /* Fermeture de l'element D_P */ - - cr = cai_WriteCloseTagXML ( des , "D_P" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element D_P" ); - goto ERREUR; - } - - /* Fermeture de l'element Attitude_Model */ - - cr = cai_WriteCloseTagXML ( des , "Attitude_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Attitude_Model" ); - goto ERREUR; - } - - /* sous element SWIR_Registration_Model */ - - cr = cai_WriteOpenTagXML ( des , "SWIR_Registration_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element SWIR_Registration_Model" ); - goto ERREUR; - } - - /* sous element D_L */ - - cr = cai_WriteOpenTagXML ( des , "D_L" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element D_L" ); - goto ERREUR; - } - - /* sous element abc */ - - cr = cai_WriteElementXML ( des , "abc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element abc" ); - goto ERREUR; - } - - /* sous element abc */ - - cr = cai_WriteElementXML ( des , "abc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element abc" ); - goto ERREUR; - } - - /* sous element abc */ - - cr = cai_WriteElementXML ( des , "abc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element abc" ); - goto ERREUR; - } - - /* Fermeture de l'element D_L */ - - cr = cai_WriteCloseTagXML ( des , "D_L" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element D_L" ); - goto ERREUR; - } - - /* sous element D_P */ - - cr = cai_WriteOpenTagXML ( des , "D_P" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element D_P" ); - goto ERREUR; - } - - /* sous element abc */ - - cr = cai_WriteElementXML ( des , "abc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element abc" ); - goto ERREUR; - } - - /* sous element abc */ - - cr = cai_WriteElementXML ( des , "abc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element abc" ); - goto ERREUR; - } - - /* sous element abc */ - - cr = cai_WriteElementXML ( des , "abc" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element abc" ); - goto ERREUR; - } - - /* Fermeture de l'element D_P */ - - cr = cai_WriteCloseTagXML ( des , "D_P" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element D_P" ); - goto ERREUR; - } - - /* Fermeture de l'element SWIR_Registration_Model */ - - cr = cai_WriteCloseTagXML ( des , "SWIR_Registration_Model" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element SWIR_Registration_Model" ); - goto ERREUR; - } - - /* Fermeture de l'element Models */ - - cr = cai_WriteCloseTagXML ( des , "Models" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Models" ); - goto ERREUR; - } - /* sous element Sensor_Calibration */ - - cr = cai_WriteOpenTagXML ( des , "Sensor_Calibration" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Sensor_Calibration" ); - goto ERREUR; - } - - /* sous element METHOD */ - - cr = cai_WriteElementXML ( des , "METHOD" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element METHOD" ); - goto ERREUR; - } - - /* sous element Calibration */ - - cr = cai_WriteOpenTagXML ( des , "Calibration" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Calibration" ); - goto ERREUR; - } - - for ( i = 0; i < nbcan ; i++ ) - { - /* sous element Band_Parameters */ - - cr = cai_WriteOpenTagXML ( des , "Band_Parameters" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Band_Parameters" ); - goto ERREUR; - } - - /* sous element BAND_INDEX */ - sprintf ( valeur , "%d" , (i+1) ); - - cr = cai_WriteElementXML ( des , "BAND_INDEX" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element BAND_INDEX" ); - goto ERREUR; - } - - /* Fermeture de l'element Band_Parameters */ - - cr = cai_WriteCloseTagXML ( des , "Band_Parameters" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Band_Parameters" ); - goto ERREUR; - } - } - /* Fermeture de l'element Calibration */ - - cr = cai_WriteCloseTagXML ( des , "Calibration" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Calibration" ); - goto ERREUR; - } - - /* sous element Spectral_Sensitivities */ - - cr = cai_WriteOpenTagXML ( des , "Spectral_Sensitivities" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Spectral_Sensitivities" ); - goto ERREUR; - } - - for ( i = 0; i < nbcan ; i++ ) - { - /* sous element Band_Spectral_Sensitivities */ - - cr = cai_WriteOpenTagXML ( des , "Band_Spectral_Sensitivities" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Band_Spectral_Sensitivities" ); - goto ERREUR; - } - - sprintf( valeur , "%d" , ( i+1 ) ); - /* sous element BAND_INDEX */ - - cr = cai_WriteElementXML ( des , "BAND_INDEX" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element BAND_INDEX" ); - goto ERREUR; - } - - /* sous element FIRST_WAVELENGTH_VALUE */ - - cr = cai_WriteElementXML ( des , "FIRST_WAVELENGTH_VALUE" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element FIRST_WAVELENGTH_VALUE" ); - goto ERREUR; - } - - /* sous element WAVELENGTH_STEP */ - - cr = cai_WriteElementXML ( des , "WAVELENGTH_STEP" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element WAVELENGTH_STEP" ); - goto ERREUR; - } - - /* sous element CALIBRATION_DATE */ - - cr = cai_WriteElementXML ( des , "CALIBRATION_DATE" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element CALIBRATION_DATE" ); - goto ERREUR; - } - - /* sous element Spectral_Sensitivity_Values */ - - cr = cai_WriteOpenTagXML ( des , "Spectral_Sensitivity_Values" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Spectral_Sensitivity_Values" ); - goto ERREUR; - } - - /* sous element SPECTRAL_SENSITIVITY_VALUE */ - - cr = cai_WriteElementXML ( des , "SPECTRAL_SENSITIVITY_VALUE" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element SPECTRAL_SENSITIVITY_VALUE" ); - goto ERREUR; - } - - /* Fermeture de l'element Spectral_Sensitivity_Values */ - - cr = cai_WriteCloseTagXML ( des , "Spectral_Sensitivity_Values" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Spectral_Sensitivity_Values" ); - goto ERREUR; - } - - /* Fermeture de l'element Band_Spectral_Sensitivities */ - - cr = cai_WriteCloseTagXML ( des , "Band_Spectral_Sensitivities" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Band_Spectral_Sensitivities" ); - goto ERREUR; - } - - } - - /* Fermeture de l'element Spectral_Sensitivities */ - - cr = cai_WriteCloseTagXML ( des , "Spectral_Sensitivities" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Spectral_Sensitivities" ); - goto ERREUR; - } - - /* sous element Solar_Irradiance */ - - cr = cai_WriteOpenTagXML ( des , "Solar_Irradiance" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Solar_Irradiance" ); - goto ERREUR; - } - - for ( i = 0; i < nbcan ; i++ ) - { - sprintf ( valeur , "%d" , ( i+1 ) ); - /* sous element Band_Solar_Irradiance */ - - cr = cai_WriteOpenTagXML ( des , "Band_Solar_Irradiance" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Band_Solar_Irradiance" ); - goto ERREUR; - } - - /* sous element BAND_INDEX */ - - cr = cai_WriteElementXML ( des , "BAND_INDEX" , valeur ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element BAND_INDEX" ); - goto ERREUR; - } - - /* sous element SOLAR_IRRADIANCE_VALUE */ - - cr = cai_WriteElementXML ( des , "SOLAR_IRRADIANCE_VALUE" , "" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element SOLAR_IRRADIANCE_VALUE" ); - goto ERREUR; - } - - /* Fermeture de l'element Band_Solar_Irradiance */ - - cr = cai_WriteCloseTagXML ( des , "Band_Solar_Irradiance" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Band_Solar_Irradiance" ); - goto ERREUR; - } - } - /* Fermeture de l'element Solar_Irradiance */ - - cr = cai_WriteCloseTagXML ( des , "Solar_Irradiance" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Solar_Irradiance" ); - goto ERREUR; - } - - /* Fermeture de l'element Sensor_Calibration */ - - cr = cai_WriteCloseTagXML ( des , "Sensor_Calibration" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Sensor_Calibration" ); - goto ERREUR; - } - - /* Fermeture de l'element Data_Strip */ - - cr = cai_WriteCloseTagXML ( des , "Data_Strip" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Data_Strip" ); - goto ERREUR; - } - - /* Fermeture de l'element Dimap_Document */ - - cr = cai_WriteCloseTagXML ( des , "Dimap_Document" ); - if ( cr == CAI_KO ) - { - sprintf ( CAI_ERREUR , "Erreur ecriture Element Dimap_document" ); - goto ERREUR; - } - - /* fermeture du fichier descripteur */ - - if (des!=NULL) fclose ( des ); - - return CAI_OK; - - ERREUR: - - return CAI_KO; - } -/* - Fin de l'operation cai_creat_leader_spot5 -*/ diff --git a/Utilities/CAI/cai_dll/src/cai_tiff.c b/Utilities/CAI/cai_dll/src/cai_tiff.c deleted file mode 100755 index 3162c7542c067df71e1842670014d64c261b0430..0000000000000000000000000000000000000000 --- a/Utilities/CAI/cai_dll/src/cai_tiff.c +++ /dev/null @@ -1,1534 +0,0 @@ -/*****************************************************************************/ -/* */ -/* PROJET : COUCHE ACCES IMAGE */ -/* ------- */ -/* */ -/* MODULE : cai_tiff.c */ -/* ------- */ -/* */ -/* ROLE : Ce module rassemble toutes les fonctions d'acces aux images */ -/* ------- stockees au format tiff */ -/* */ -/* AUTEUR : R.CHAISEMARTIN (CISI) */ -/* ------- */ -/* */ -/* DATE DE CREATION : fevrier 1995 */ -/* ----------------- */ -/* */ -/* LANGAGE : C */ -/* -------- */ -/*****************************************************************************/ -/*****************************************************************************/ -/** **/ -/** CE MODULE A ETE DEVELOPPE EN UTILISANT LA BIBLIOTHEQUE **/ -/** D'ACCES AUX IMAGES TIFF DIPONIBLE EN FREE_WARE AVEC XV **/ -/** libtiff.a version 3.0 **/ -/** **/ -/*****************************************************************************/ -/*****************************************************************************/ -/* */ -/* VERSION : V3.3 */ -/* -------- */ -/* */ -/*****************************************************************************/ -/* MOD : VERSION : 3.3: DM : optimisation des acces */ -/*****************************************************************************/ -/* MOD : VERSION :4.1 :FA: Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ -/* MOD : VERSION : 4.2 :FA:Verification que le nombre d'octets par pixel est */ -/* egal a 1 et le nombre de canaux est 1 ou 3. tiff est un format de */ -/* restitution */ -/*****************************************************************************/ -/* MOD : VERSION : 4.2 : DM : modifications pour compatibilite HP64bits */ -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : prise en compte des extensions en majuscule */ -/*****************************************************************************/ -/* MOD : VERSION : 4.3 :FA: Suppression de la contrainte sur le nb d'octets */ -/* par pixel et du nombre de canaux */ -/*****************************************************************************/ -/* MOD : VERSION : 4.5 : DM : modification du nombre de lignes en ecriture */ -/* dans le TAG ROWPERSTRIP pour manipulation aussi bien pour chaque ligne, */ -/* tous les canaux qu pour chaque canal toutes les lignes */ -/*****************************************************************************/ -/*****************************************************************************/ -/* MOD : VERSION : 4.6 : FA : En ouverture en modification, ouverture en "a" */ -/* au lieu de "w" */ -/*****************************************************************************/ -/*****************************************************************************/ -/* MOD : VERSION : 4.9 : DM : Lecture d'une image sur 1 bit. Chaque bit est */ -/* expensé sur un octet avant d'être renvoyé à l'appelant */ -/*****************************************************************************/ -/*****************************************************************************/ -/* MOD : VERSION : 5.0 : DM : A l'ouverture d'une image en lecture, renvoie */ -/* de COD_PIX à I4 ou R4 pour les images codees en I4 ou R4 */ -/*****************************************************************************/ -/* MOD : VERSION : 5.0 : FA : Image 1bit :prise en compte de la lecture de */ -/* portion de lignes ou de sous-echantillonnage */ -/*****************************************************************************/ -/* MOD : VERSION : 5.1 : FA : Image 1bit :prise en compte de la lecture de */ -/* l'image en entier */ -/*****************************************************************************/ -/* MOD : VERSION : 5.1 : DM : Mise à jour du tag SAMPLEFORMAT lorsque */ -/* l'image est codée en reel et que l'utilisateur le precise dans le param */ -/* "label" */ -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : prise en compte des I2,I4,UI2,UI4 et R8 */ -/* en lecture et ecriture */ -/*****************************************************************************/ -/*---------------------------------------------------------------------------*/ -/* Inclusion des fichiers STANDARDS (.h) */ -/*---------------------------------------------------------------------------*/ - - -# include <stdio.h> -# include <string.h> -# include <stdlib.h> -# include <unistd.h> -# include <sys/types.h> -#include <dirent.h> -# include <sys/stat.h> -# include <fcntl.h> - -#define _CAI_IMAGE -#define IN_CAI_TIFF - -# include "cai_image.h" - -/*----------------------------------------------------------------------------*/ -/* Variable pour la gestion en configuration */ -/*----------------------------------------------------------------------------*/ -static char *rcs_id="$Header: cai_tiff.c,v 1.11 01/05/31 10:47:19 cmf Exp $"; - - -extern char *getenv(); - -/*****************************************************************************/ -/*****************************************************************************/ -/* */ -/* Definition des OPERATIONS EXTERNES */ -/* */ -/*****************************************************************************/ -/*****************************************************************************/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_liste_ima_tiff */ -/* ---------- */ -/* */ -/* ROLE : fonction de listage des images au format tiff */ -/* ------ */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : int cai_liste_ima_tiff (repert,tab_ima) */ -/* ----------------- */ -/* */ -/* repert (E) (char *) : repertoire a explorer */ -/* tab_ima (S) (char ***) : pointeur sur tableau des images listees*/ -/* alloue par la fonction,il doit etre */ -/* LIBERE PAR L'APPELANT */ -/* */ -/* cai_liste_ima_tiff (S) (int) : = -1 repertoire inexistant */ /* = > 0 nombre d'images listees */ -/* */ -/* VERSION : V2 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -long int cai_liste_ima_tiff (char *repert, - char ***tab_ima) - - -{ - FILE *fp; /* descripteur de fichier. retour fopen */ - - struct dirent *dp; /* structure resultat de la fonction readdir */ - - DIR *dirp; /* pointeur sur structure ouverture repertoire */ - char *pch0; /* pointeurs sur chaine de caracteres */ - unsigned short magic; /* nombre magique de reconnaissance tiff */ - char nomfic[1024]; /* nom du fichier dont on verifie s'il est tiff*/ - int nb_ima; /* nombre d'images tiff identifiees */ - int i; /* indice de boucle */ - char car; /* variable de travail */ - -/*........................................ - INITIALISATION et ouverture du repertoire choisi - .........................................*/ - nb_ima=0; - dirp=opendir(repert); - - if(dirp!=NULL) - { -/*...................................... - premiere passe pour comptabiliser les images du format donne - - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE tiff - lecture du nombre magique - ........................................*/ - - while((dp=readdir(dirp))!=NULL) - { - nomfic[0]='\0'; - sscanf(repert,"%s",nomfic); - strcat(nomfic,"/"); - strcat(nomfic,dp->d_name); - fp=fopen(nomfic,"r"); - if (fp != NULL) - { - fread(&magic,2,1,fp); - fclose(fp); - if ((magic == TIFF_BIGENDIAN)||(magic== TIFF_LITTLEENDIAN)) - { - nb_ima=nb_ima+1; - } - } - } - - (void)closedir(dirp); -/*..................................... - ALLOCATION DU TABLEAU CONTENANT LA LISTE DES IMAGES DU FORMAT BSQ - ......................................*/ - *tab_ima = (char **) calloc(nb_ima,sizeof(char *)); - for (i=0;i<nb_ima;i=i+1) - (*tab_ima)[i]=(char *)calloc(1,100); - -/*...................................... - - deuxieme passe pour constituer la liste des images du format donne - POUR CHAQUE FICHIER DU REPERTOIRE , - TEST POUR SAVOIR SI CE FICHIER EST UNE IMAGE tiff - lecture du nombre magique - si oui ,stockage dans la liste des images TIFF - ........................................*/ - nb_ima=0; - dirp=opendir(repert); - - while((dp=readdir(dirp))!=NULL) - { - - nomfic[0]='\0'; - sscanf(repert,"%s",nomfic); - strcat(nomfic,"/"); - strcat(nomfic,dp->d_name); - fp=fopen(nomfic,"r"); - - if (fp != NULL) - - { - - fread(&magic,2,1,fp); - fclose(fp); - if ((magic == TIFF_BIGENDIAN)||(magic== TIFF_LITTLEENDIAN)) - { - -/* suppression de l'extension */ - car='.'; - pch0=strrchr(dp->d_name,car); -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : prise en compte des extensions en majuscule */ -/*****************************************************************************/ - if ((pch0 != NULL)&&((*(pch0+1)=='t')||(*(pch0+1)=='T'))) - { - *pch0 = '\0'; - strcpy((*tab_ima)[nb_ima],dp->d_name); - nb_ima=nb_ima+1; - } - } - } - } - - (void)closedir(dirp); - - } - else - { - /* Erreur:Repertoire inexistant */ - nb_ima=-1; - } - - return(nb_ima); - -} - -/* Fin de l'operation cai_liste_ima_tiff -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_lecture_tiff */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture d'une image au format tiff */ -/* ----- et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_lecture_tiff (nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_lecture_tiff (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ /* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_IMAGE *cai_ouvre_lecture_tiff(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) - -{ - TIFF *tif; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - int iret,icr; /* indicateur de retour ok ou pas */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char *deb,*deb1; /* pointeurs sur chaine de caracteres */ - char Extension[6]; /* extension du fichier .tiff ou .tif */ - int i,Coher; /* indice */ - unsigned int imagelength; /* nombre de lignes de l'image */ - unsigned int imagewidth; /* nombre de colonnes de l'image */ - short samplesperpixel; /* nombre de canaux */ - short compression; /* indicateur de compression */ - short photo; /* indicateur de photometric interpretation */ - short bitspersample; /* nombre de bits par pixels */ - short sampleformat; /* type de codage du pixel */ - int Istile; /* indicateur de stockage en pave */ - int Mode; /* mode test existence d'un fichier */ - - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - *nb_can=0; - *nb_lig=0; - *nb_col=0; - *nboct_pix=0; - iret=1; - Mode = F_OK; - icr= 0; - sprintf(Extension,".tiff"); - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); - -/*****************************************************************************/ -/* MOD : VERSION :4.1 :FA:Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur allocation memoire dans cai_ouvre_lecture"); - } - else - { - -/*................................................. - Constitution du nom du fichier TIFF - .................................................*/ - nom_fic[0]='\0'; - if ((long int)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s.tiff",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.tiff",nom_image); - } -/* test sur l'existence avec .tiff sinon .tif */ -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : prise en compte des extensions en majuscule */ -/*****************************************************************************/ - icr = access(nom_fic,Mode); - if (icr !=0) - { - nom_fic[strlen(nom_fic)-1]='\0'; - Extension[4]='\0'; - icr = access(nom_fic,Mode); - if (icr !=0) - { - sprintf(Extension,".TIF"); - if ((long int)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s%s",repert,nom_image,Extension); - } - else - { - sprintf(nom_fic,"%s.%s",nom_image,Extension); - } - } - } - - -/*........................ - Ouverture du fichier entete - ..........................................*/ - tif = TIFFOpen(nom_fic,"r"); - if (tif==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur ouverture fichier tiff"); - } - else - { -/*.......................................................... - verification si l'image n'est pas comprimee -.............................................................*/ - TIFFGetField(tif,TIFFTAG_COMPRESSION,&compression); - if (compression != COMPRESSION_NONE) - { - iret=0; - strcpy(CAI_ERREUR,"Le fichier tiff est comprime. Format non traite !"); - } - else - { - -/*.......................................................... - verification si le fichier n'est pas code en pave -.............................................................*/ - Istile=TIFFIsTiled(tif); - if (Istile!=0) - { - iret=0; - strcpy(CAI_ERREUR,"Le fichier tiff est en paves . Format non traite !"); - } - else - { -/*.................................... - recuperation du nombre de colonnes -............................................*/ - TIFFGetField(tif,TIFFTAG_IMAGEWIDTH,&imagewidth); - *nb_col=imagewidth; -/*.................................... - recuperation du nombre de lignes -............................................*/ - TIFFGetField(tif,TIFFTAG_IMAGELENGTH,&imagelength); - *nb_lig=imagelength; - -/*...................................... - recuperation du nombre de canaux -............................................*/ - TIFFGetFieldDefaulted(tif,TIFFTAG_SAMPLESPERPIXEL,&samplesperpixel); - *nb_can=samplesperpixel; -/*......................................... - recuperation du nombre d'octets par pixel - .................................................*/ -/* Nombre de bits par pixels */ -/*****************************/ - TIFFGetField(tif,TIFFTAG_BITSPERSAMPLE,&bitspersample); - if ((bitspersample %8)==0) - *nboct_pix=(int)(bitspersample/8); - else - *nboct_pix=(int)((bitspersample/8)+1); - image1->NB_BITS_PIX=bitspersample; - -/*......................................... - recuperation du type de codage - .................................................*/ -/*****************************************************************************/ -/* MOD : VERSION : 5.0 : DM : A l'ouverture d'une image en lecture, renvoie */ -/* de COD_PIX à I4 ou R4 pour les images codees en I4 ou R4 */ -/*****************************************************************************/ - TIFFGetField(tif,TIFFTAG_SAMPLEFORMAT,&sampleformat); - -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : prise en compte des I2,I4,UI2,UI4 et R8 */ -/* en lecture et ecriture */ -/*****************************************************************************/ - Coher = 1; - if (*nboct_pix==1) - { - sprintf(image1->COD_PIX,"UOCT"); - if (sampleformat == SAMPLEFORMAT_INT) - sprintf(image1->COD_PIX,"OCT"); - else if (sampleformat != SAMPLEFORMAT_UINT) - Coher=0; - } - else if (*nboct_pix==2) - { - sprintf(image1->COD_PIX,"UI2"); - if (sampleformat == SAMPLEFORMAT_INT) - sprintf(image1->COD_PIX,"I2"); - else if (sampleformat != SAMPLEFORMAT_UINT) - Coher=0; - } - else if (*nboct_pix==4) - { - sprintf(image1->COD_PIX,"I4"); - if (sampleformat == SAMPLEFORMAT_IEEEFP) - sprintf(image1->COD_PIX,"R4"); - else if (sampleformat == SAMPLEFORMAT_UINT) - sprintf(image1->COD_PIX,"UI4"); - else if (sampleformat != SAMPLEFORMAT_INT) - Coher=0; - } - else if (*nboct_pix==8) - { - sprintf(image1->COD_PIX,"R8"); - if (sampleformat != SAMPLEFORMAT_IEEEFP) - Coher=0; - } - else - sprintf(image1->COD_PIX,"UND"); - -/*............................................*/ -/* Recuperation du type de codages des pixels */ -/*............................................*/ - TIFFGetField(tif,TIFFTAG_PLANARCONFIG,&photo); - -/*................................................... - recuperation de l'indice de photometric interpretation - ..............................................................*/ - TIFFGetField(tif,TIFFTAG_PHOTOMETRIC,&photo); - if ((photo<0)&&(photo>3)) - { - iret=0; - strcpy(CAI_ERREUR,"Photometric non connue . Format non traite !"); - } - - } - } - } - if (iret != 0) - { - -/*....................................... - INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL - .....................................................*/ - - - deb = image1->NOM_FIC_CAN; - deb1= image1->NOM_UTIL_CAN; - - for (i=0;i<*nb_can;i=i+1) - { - sprintf(deb,"%s%s",nom_image,Extension); - deb=deb+100; - sprintf(deb1,"%s%s",nom_image,Extension); - deb1=deb1+100; - image1->POS_OCTET[i]=0; - image1->ACCES_CANAL_TIFF[i]=tif; - } - } - } - if (iret==0) - { - return (NULL); - } - else - { - return(image1); - } - -} - -/* - Fin de l'operation cai_ouvre_lecture_tiff -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_creation_tiff */ -/* ---------- */ -/* */ -/* ROLE : fonction de creation et d'ouverture en ecriture d'une image */ -/* ----- au format tiff et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_creation_tiff (nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig, */ -/* label) */ -/* */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* nb_can (E) (int ) : nombre de canaux de l'image */ -/* nboct_pix (E) (int ) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (E) (int ) : nombre de lignes de l'image */ -/* nb_col (E) (int ) : nombre de colonnes de l'image */ -/* label (E) (char *) : commentaire lie a l'image */ -/* */ -/* cai_ouvre_creation_tiff (S) (CAI_IMAGE *) : =NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - - -CAI_IMAGE *cai_ouvre_creation_tiff(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig, - char *label) - -{ - TIFF *tif; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - char nom_fic[1024]; /* nom du fichier en-tete */ - int retour; /* retour de fonction */ - int i; /* indice */ - struct stat buf_stat; /* structure decrivant status de fichier */ - unsigned int imagelength; /* nombre de lignes de l'image */ - unsigned int imagewidth; /* nombre de colonnes de l'image */ - short samplesperpixel; /* nombre de canaux */ - short photo; /* indicateur de photometric interpretation */ - int rowsperstrip; /* taille totale de l'image en octets */ - short bitspersample; /* nombre de bits par pixels */ - short sampleformat; /* type de codage du pixel */ - int reconnaissance_type,Coher; - -/*****************************************************************************/ -/* MOD : VERSION : 4.3 :FA: Suppression de la contrainte sur le nb d'octets */ -/* par pixel et du nombre de canaux */ -/*****************************************************************************/ -/*****************************************************************************/ -/* MOD : VERSION : 4.2 :FA:Verification que le nombre d'octets par pixel est */ -/* egal a 1 et le nombre de canaux est 1 ou 3. tiff est un format de */ -/* restitution */ -/*****************************************************************************/ -/* Verification sur le nombre d'octets par pixel */ - - /* if (*nboct_pix !=1) - { - strcpy(CAI_ERREUR,"Erreur une image TIFF ne peut etre codee que sur un seul octet"); - goto ERREUR; - } -*/ -/* Verification sur le nombre de canaux */ -/* if ((*nb_can !=1)&&(*nb_can !=3)) - { - strcpy(CAI_ERREUR,"Erreur une image TIFF a 1 ou 3 canaux exclusivement"); - goto ERREUR; - } -*/ - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); -/*****************************************************************************/ -/* MOD : VERSION :4.1 :FA:Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_creation"); - goto ERREUR; - } - -/*................................................. - Constitution du nom du fichier entete et verification qu'il - n'existe pas deja - .................................................*/ - nom_fic[0]='\0'; - if ((long int)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s.tif",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.tif",nom_image); - } - retour = stat ( nom_fic , &buf_stat ); - if ( retour == 0 ) - { - sprintf ( CAI_ERREUR , "L'image %s TIFF existe \n" , nom_image ); - goto ERREUR; - } - -/*************************************************/ -/* Ouverture du fichier */ -/*************************************************/ -tif = TIFFOpen ( nom_fic , "w"); -if ( tif == NULL ) -{ - sprintf ( CAI_ERREUR , "Erreur : ouverture fichier %s impossible \n" , - nom_fic ); - goto ERREUR ; -} -/*************************************************/ -/* Ecriture de l'enregistrement d'entete */ -/*************************************************/ -/* Nombre de colonnes */ -/**********************/ -imagewidth=(unsigned int)(*nb_col); -TIFFSetField(tif,TIFFTAG_IMAGEWIDTH,imagewidth); - -/* Nombre de lignes */ -/********************/ -imagelength=(unsigned int)(*nb_lig); -TIFFSetField(tif,TIFFTAG_IMAGELENGTH,imagelength); - -/*****************************************************************************/ -/* MOD : VERSION : 4.5 : DM : modification du nombre de lignes en ecriture */ -/* dans le TAG ROWPERSTRIP pour manipulation aussi bien pour chaque ligne, */ -/* tous les canaux qu pour chaque canal toutes les lignes */ -/*****************************************************************************/ - -/* Nombre de lignes par strip */ -/******************************/ -/*rowsperstrip=(int)((*nb_lig));*/ -rowsperstrip = 1; -TIFFSetField(tif,TIFFTAG_ROWSPERSTRIP,rowsperstrip); - -/* Nombre de canaux */ -/********************/ -samplesperpixel=(short)(*nb_can); -TIFFSetField(tif,TIFFTAG_SAMPLESPERPIXEL,samplesperpixel); - -/* Indicateur de non compression */ -/*********************************/ -TIFFSetField(tif,TIFFTAG_COMPRESSION,COMPRESSION_NONE); - -/* Nombre de bits par pixels */ -/*****************************/ -bitspersample=(short)(*nboct_pix); -bitspersample=bitspersample*8; -TIFFSetField(tif,TIFFTAG_BITSPERSAMPLE,bitspersample); - -/* Type de codage du pixel */ -/*****************************************************************************/ -/* MOD : VERSION : 5.1 : DM : Mise à jour du tag SAMPLEFORMAT lorsque */ -/* l'image est codée en reel et que l'utilisateur le precise dans le param */ -/* "label" */ -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : prise en compte des I2,I4,UI2,UI4 et R8 */ -/* en lecture et ecriture */ -/*****************************************************************************/ -/*****************************************************************************/ -/* MOD : VERSION : 5.3 : DM : Correction erreur lorsque label non reconnu */ -/*****************************************************************************/ - -/*****************************************************************************/ -/* Verification si type de codage reconnu dans le label */ - reconnaissance_type = cai_istyp_connu(label); - if (reconnaissance_type == -1) - { - if (*nboct_pix == 1) sampleformat=SAMPLEFORMAT_UINT; - else if (*nboct_pix==2) sampleformat=SAMPLEFORMAT_INT; - else if ((*nboct_pix==4) && ((strcasecmp(label,"R4") == 0)|| - (strcasecmp(label,"FLOAT")== 0)|| - (strcasecmp(label,"REEL") == 0))) - sampleformat = SAMPLEFORMAT_IEEEFP; - else sampleformat=SAMPLEFORMAT_VOID; - } - else - { - -/* Verification de coherence entre le nb d'octets par pixel et le type donne */ - Coher=1; - if(*nboct_pix == 1) - { - sampleformat=SAMPLEFORMAT_UINT; - if (reconnaissance_type == 0) - sampleformat=SAMPLEFORMAT_INT; - else if (reconnaissance_type !=1) - Coher=0; - } - else if(*nboct_pix == 2) - { - sampleformat=SAMPLEFORMAT_INT; - if (reconnaissance_type == 3) - sampleformat=SAMPLEFORMAT_UINT; - else if (reconnaissance_type !=2) - Coher=0; - } - else if(*nboct_pix == 4) - { - sampleformat=SAMPLEFORMAT_IEEEFP; - if (reconnaissance_type == 4) - sampleformat=SAMPLEFORMAT_INT; - else if (reconnaissance_type == 5) - sampleformat=SAMPLEFORMAT_UINT; - else if (reconnaissance_type !=6) - Coher=0; - } - else if(*nboct_pix == 8) - { - sampleformat=SAMPLEFORMAT_IEEEFP; - if (reconnaissance_type != 7) Coher=0; - } - else - Coher = 0; - if (Coher == 0) - { - sprintf(CAI_ERREUR,"incoherence entre TYPE et Nb bits par pixels\n"); - goto ERREUR; - } - else - { - sprintf ( image1->COD_PIX , "%s" ,label); - } - } - -/* - FIN MOD 5.1 */ -/**************/ -TIFFSetField(tif,TIFFTAG_SAMPLEFORMAT,sampleformat); - -/*indicateur de photometric suivant le nombre de canaux */ -if (*nb_can==1) - { - photo=1; - TIFFSetField(tif,TIFFTAG_PLANARCONFIG,PLANARCONFIG_CONTIG); - - } -else - { - photo=2; - TIFFSetField(tif,TIFFTAG_PLANARCONFIG,PLANARCONFIG_SEPARATE); - - } -TIFFSetField(tif,TIFFTAG_PHOTOMETRIC,photo); - for (i=0;i<*nb_can;i=i+1) - { - image1->ACCES_CANAL_TIFF[i]=tif; - image1->POS_OCTET[i]=0; - } - return (image1); - -ERREUR : - cai_dest_ima_tiff ( repert , nom_image ); - return(NULL); -} - /* - Fin de l'operation cai_ouvre_creation_tiff -*/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_lecture_canal_tiff */ -/* ---------- */ -/* */ -/* ROLE : fonction de lecture d'un canal d'une image tiff */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_lecture_canal_tiff (image1, canal, */ /* ------------------ premiere_ligne, */ -/* premiere_colonne, */ -/* nombre_lignes_lire , */ -/* nombre_colonnes_lire, */ -/* pas_ligne ,pas_colonne, */ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a lire */ -/* premiere_ligne (E) (int) : premiere ligne a lire dans l'image */ -/* premiere _colonne (E) (int) : premiere colonne a lire dans l'image */ -/* nombre_lignes_lire (E) (int) : nombre de lignes a lire */ -/* nombre_colonnes_lire (E) (int) : nombre de colonnes a lire */ -/* pas_ligne (E) (int) : pas en ligne */ -/* pas_colonne (E) (int) : pas en colonne */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels lus alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_lecture_canal_tiff (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ -/*****************************************************************************/ -/* MOD : VERSION : 4.9 : DM : Lecture d'une image sur 1 bit. Chaque bit est */ -/* expensé sur un octet avant d'être renvoyé à l'appelant */ -/*****************************************************************************/ - -CAI_OK_KO cai_lecture_canal_tiff(CAI_IMAGE *image1 , - int *canal , - int *premiere_ligne , - int *premiere_colonne, - int *nombre_lignes_lire , - int *nombre_colonnes_lire, - int *pas_ligne , - int *pas_colonne, - unsigned char *data_image ) - -{ - TIFF *tif; /* descripteur de fichier , retour de TIFFOpen */ - int num,i,j,k,val; /* variables de travail */ - int mul,decal; /* variables de travail */ - int iret; /* indicateur d'erreur */ - long lig; /* indice de boucle sur les lignes */ - long nb_oct; /* nb oct =1er octet a lire - position courante */ - unsigned char *buf_lec; /* buffer lecture d'une ligne */ - unsigned char *deb,*pch; /* pointeur chaine pour transfert buffer sortie */ - int oct_pix; /* nb octets par pixels */ - unsigned char val1; - unsigned char Masque[8]={1,2,4,8,16,32,64,128}; - int temp1,temp2,temp3; - -/*........................... - Initialisations diverses - ..........................*/ - - iret=CAI_OK; - strcpy(CAI_ERREUR," "); - - tif=image1->ACCES_CANAL_TIFF[0]; - oct_pix = image1->NBOCT_PIX; - pch=data_image; - -/*.............................................. - allocation de memoire pour lire une ligne image - ............................................. */ - nb_oct=TIFFScanlineSize(tif); - if ((nb_oct==(image1->NB_COL)*(image1->NB_CANAUX))&&(image1->NB_CANAUX!=1)) - { -/* ligne multispectrale */ - num=0; - val=(*canal-1); - mul=image1->NB_CANAUX; - } - else - { -/* ligne monospectrale */ - num=*canal-1; - mul=1; - val=0; - } - buf_lec = (unsigned char *) malloc(nb_oct); - if (buf_lec == NULL) - { - iret=CAI_KO; - strcpy(CAI_ERREUR,"Probleme d'allocation memoire"); - } - else - { - -/*.................... - Initialisation - ......................*/ - lig=(long)(*premiere_ligne); - lig=lig-1; - i=0; - if ( image1->NB_BITS_PIX!=1) - { - while (i<(*nombre_lignes_lire)) - { - TIFFReadScanline(tif,buf_lec,lig,num); -/*...................................... - Sauvegarde des donnees lues entenant compte du pas - d'echantillonnage en colonne - ........................................*/ - decal= ((*premiere_colonne-1)*mul*oct_pix)+val; - deb=buf_lec+decal; - j=1; - while (j <= (*nombre_colonnes_lire)) - { - for (k=0;k<oct_pix;k=k+1) - { - *(pch+k)=*(deb+k); - } - pch=pch+oct_pix; - j=j+1; - deb=deb+((*pas_colonne)*oct_pix*mul); - } - i=i+1; - lig=lig+(long)(*pas_ligne); - - } - } - else - { -/*****************************************************************************/ -/* MOD : VERSION : 4.9 : DM : Lecture d'une image sur 1 bit. Chaque bit est */ -/* expensé sur un octet avant d'être renvoyé à l'appelant */ -/*****************************************************************************/ - - while (i<(*nombre_lignes_lire)) - { - TIFFReadScanline(tif,buf_lec,lig,num); -/*...................................... - Sauvegarde des donnees lues entenant compte du pas - d'echantillonnage en colonne - ........................................*/ -/*****************************************************************************/ -/* MOD : VERSION : 5.0 : FA : Image 1bit :prise en compte de la lecture de */ -/* portion de lignes ou de sous-echantillonnage */ -/*****************************************************************************/ -/* se déplacer jusqu'au premier paquet octet concerné */ - decal= (*premiere_colonne-1)/8; - deb=buf_lec+decal; - j=0; - while (j < (*nombre_colonnes_lire)) - { - val1 = *(deb); - if (j==0) - { -/* se déplacer jusqu'à la première colonne concernée */ - k = (*premiere_colonne -1) - (decal*8); - } - else - k=k-8; - while ((k<8)&&(j <(*nombre_colonnes_lire))) - { - *(pch+j) = val1 & Masque[7-k]; - if (*(pch+j) != 0) *(pch+j)=1; - k=k+(*pas_colonne); - j=j+1; - } - deb=deb+1; - } -/*****************************************************************************/ -/* MOD : VERSION : 5.1 : FA : Image 1bit :prise en compte de la lecture de */ -/* l'image en entier */ -/*****************************************************************************/ - pch=pch+(*nombre_colonnes_lire); -/**********/ -/*FIN MOD */ -/**********/ - i=i+1; - lig=lig+(long)(*pas_ligne); - - } - } - - free(buf_lec); - } - - return(iret); -} -/* - Fin de l'operation cai_lecture_canal_tiff -*/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ecriture_canal_tiff */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ecriture d'un canal d'une image tiff */ -/* ----- */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ecriture_canal_tiff (image1, canal, */ /* ------------------ premiere_ligne, */ -/* nombre_lignes_ecrire, */ -/* nombre_colonnes_ecrire,*/ -/* data_image ) */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* canal (E) (int) : numero du canal a ecrire */ -/* premiere_ligne (E) (int) : premiere ligne a ecrire ds l'image */ -/* nombre_lignes_ecrire (E) (int) : nombre de lignes a ecrire */ -/* nombre_colonnes_ecrire(E) (int) : nombre de lignes a ecrire */ -/* */ -/* data_image (S) (unsigned char): tableau des pixels ecris alloue et */ -/* libere par l'appelant */ -/* */ -/* cai_ecriture_canal_tiff (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - - - -CAI_OK_KO cai_ecriture_canal_tiff(CAI_IMAGE *image1 , - int *canal , - int *premiere_ligne , - int *nombre_lignes_ecrire , - int *nombre_colonnes_ecrire, - unsigned char *data_image ) -{ -int nboct_pix; /* nombre d'octets par pixel */ -unsigned int row,sample; /* variables intermediaires */ -int i_ligne,lig; /* compteur de lignes */ -unsigned char *buff_lig; /* tableau contenant une ligne a ecrire */ -TIFF *tif; /* descriteur de fichier,issu de TIFFopen */ -int icr; - -/* ................ - Initialisations - .................*/ - -i_ligne = 0; -lig=(*premiere_ligne); -tif = image1->ACCES_CANAL_TIFF[(*canal)-1]; -nboct_pix = image1->NBOCT_PIX; -/********************************************************/ -/* TANT QUE il y a des lignes a ecrire */ -/********************************************************/ -while (i_ligne < (*nombre_lignes_ecrire)) -{ - -/********************************************************/ -/* extraction de la ligne du tableau */ -/********************************************************/ - - buff_lig = data_image + (*nombre_colonnes_ecrire) * nboct_pix * i_ligne; - -/********************************************************/ -/* ecriture de la ligne */ -/********************************************************/ - row=(unsigned int)(lig); - row=row-1; - sample=(unsigned int)(*canal); - sample=sample-1; - icr=TIFFWriteScanline(tif,buff_lig,row,sample); -/********************************************************/ -/* incrementation du nombre de lignes */ -/********************************************************/ - lig=lig+1; - i_ligne++; - -/********************************************************/ -/* FIN TANT QUE */ -/********************************************************/ -} -return (CAI_OK); - - -} -/* - Fin de l'operation cai_ecriture_canal_tiff -*/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ferme_tiff */ -/* ---------- */ -/* */ -/* ROLE : fonction de fermeture d'une image au format tiff et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_ferme_tiff (image1) */ /* ------------------ */ -/* */ -/* image1 (E) (CAI_IMAGE *) : pointeur sur descripteur de fichier */ -/* */ -/* cai_ferme_tiff (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_OK_KO cai_ferme_tiff (CAI_IMAGE *image1) - - -{ - int iret; /* code retour de l'operation */ - TIFF *num; /* descripteur du fichier a fermer */ - - - iret=CAI_OK; -/*............................................. - Fermeture de tous les canaux qui sont tous contenus - dans un seul fichier .srf - .............................................*/ - - num=image1->ACCES_CANAL_TIFF[0]; - TIFFClose(num); - - return (iret); -} -/* - Fin de l'operation cai_ferme_tiff -*/ - -/*****************************************************************************/ -/* */ -/* OPERATION : cai_dest_ima_tiff */ -/* ---------- */ -/* */ -/* ROLE : fonction de destruction d'une image stocke en onera et de */ -/* ----- tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_OK_KO cai_dest_ima_tiff (format,nom_ima) */ /* ------------------ */ -/* format (E) (char *) : format de l'image a detruire */ -/* nom_image (E) (char *) : nom de l'image a detruire avec repertoire */ -/* */ -/* cai_dest_ima_tiff (S) (CAI_OK_KO) : = CAI_KO si pb */ -/* = CAI_OK si OK */ -/* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_OK_KO cai_dest_ima_tiff ( char *repertoire , - char *nom_ima ) - -{ - -char nom_fichier[1024]; /* nom du fichier entete a detruire */ -char nom_ima_complet[1024]; /* repertoire + nom de l'image */ -int cr_stat; /* code retour de fonction status de fichier */ -struct stat buf_stat; /* structure decrivant status de fichier */ -int Mode,icr; - - -/************************************************/ -/* Constitution du nom du fichier d'entete */ -/************************************************/ -if ((long)strlen(repertoire)!= 0) -{ - sprintf ( nom_ima_complet, "%s/%s" ,repertoire,nom_ima); -} -else -{ - strcpy ( nom_ima_complet , nom_ima); -} -sprintf ( nom_fichier , "%s.tiff",nom_ima_complet ); - -/* test sur l'existence avec .tiff sinon .tif */ - Mode = F_OK; -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : prise en compte des extensions en majuscule */ -/*****************************************************************************/ - icr = access(nom_fichier,Mode); - if (icr !=0) - { - nom_fichier[strlen(nom_fichier)-1]='\0'; - icr = access(nom_fichier,Mode); - if (icr !=0) - { - if ((long int)strlen(repertoire)!=0) - { - sprintf(nom_fichier,"%s/%s.TIF",repertoire,nom_ima_complet); - } - else - { - sprintf(nom_fichier,"%s.TIF",nom_ima_complet); - } - } - } - -/************************************************/ -/* Destruction du fichier TIFF */ -/************************************************/ -cr_stat = stat ( nom_fichier , &buf_stat ); -if ( cr_stat == 0 ) -{ - unlink ( nom_fichier ); - return (CAI_OK); -} -else -{ - return (CAI_KO); -} - - -} -/* - Fin de l'operation cai_dest_ima_tiff -*/ -/*****************************************************************************/ -/* */ -/* OPERATION : cai_ouvre_modifie_tiff */ -/* ---------- */ -/* */ -/* ROLE : fonction d'ouverture en lecture-ecriture d'une image au forma */ -/* ----- tiff et de tous les fichiers qui la composent */ -/* */ -/* */ -/* */ -/* CONTEXTE D'APPEL : CAI_IMAGE *cai_ouvre_modifie_tiff (nom_image, */ -/* ---------------- nb_can, */ -/* nboct_pix, */ -/* nb_col, */ -/* nb_lig) */ -/* nom_image (E) (char *) : nom de l'image a ouvrir avec repertoire */ -/* */ -/* nb_can (S) (int *) : nombre de canaux de l'image */ -/* nboct_pix (S) (int *) : nombre d'octets par pixels (1 ou 2) */ -/* nb_lig (S) (int *) : nombre de lignes de l'image */ -/* nb_col (S) (int *) : nombre de colonnes de l'image */ -/* */ -/* cai_ouvre_modifie_tiff (S) (CAI_IMAGE *) : = NULL si pb */ -/* = structure contenant */ -/* toutes les informations necessaires au */ -/* traitement de l'image */ /* */ -/* VERSION : V1 */ -/* -------- */ -/* */ -/*****************************************************************************/ - -CAI_IMAGE *cai_ouvre_modifie_tiff(char *repert, - char *nom_image, - int *nb_can, - int *nboct_pix, - int *nb_col, - int *nb_lig) - -{ - TIFF *tif; /* pointeur sur descripteur de fichier */ - CAI_IMAGE *image1; /* pointeur su descripteur de fichier image */ - int iret,icr; /* indicateur de retour ok ou pas */ - char nom_fic[1024]; /* nom du fichier en-tete */ - char *deb,*deb1; /* pointeurs sur chaine de caracteres */ - int i,Coher; /* indice */ - unsigned int imagelength; /* nombre de lignes de l'image */ - unsigned int imagewidth; /* nombre de colonnes de l'image */ - short samplesperpixel; /* nombre de canaux */ - short compression; /* indicateur de compression */ - short photo; /* indicateur de photometric interpretation */ - short bitspersample; /* nombre de bits par pixels */ - int Istile; /* indicateur de stockage en pave */ - short sampleformat; /* type de codage du pixel */ - int Mode; - char Extension[6]; - -/*........................................ - INITIALISATION et allocation de place pour la structure CAI_IMAGE - .........................................*/ - *nb_can=0; - *nb_lig=0; - *nb_col=0; - *nboct_pix=0; - iret=1; - Mode = F_OK; - icr = 0; - sprintf(Extension,".tiff"); - - image1 = (CAI_IMAGE *)calloc(1,sizeof(CAI_IMAGE)); -/*****************************************************************************/ -/* MOD : VERSION :4.1 :FA:Rajout des tests sur les retours d'allocation */ -/* memoire */ -/*****************************************************************************/ - - if (image1==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur allocation memoirem dans cai_ouvre_modifie"); - } - else - { -/*................................................. - Constitution du nom du fichier TIFF - .................................................*/ - nom_fic[0]='\0'; - if ((long int)strlen(repert)!=0) - { - sprintf(nom_fic,"%s%s.tiff",repert,nom_image); - } - else - { - sprintf(nom_fic,"%s.tiff",nom_image); - } - -/* test sur l'existence avec .tiff sinon .tif */ -/*****************************************************************************/ -/* MOD : VERSION : 4.3 : DM : prise en compte des extensions en majuscule */ -/*****************************************************************************/ - icr = access(nom_fic,Mode); - if (icr !=0) - { - nom_fic[strlen(nom_fic)-1]='\0'; - Extension[4]='\0'; - icr = access(nom_fic,Mode); - if (icr !=0) - { - sprintf(Extension,".TIF"); - if ((long int)strlen(repert)!=0) - { - sprintf(nom_fic,"%s/%s%s",repert,nom_image,Extension); - } - else - { - sprintf(nom_fic,"%s.%s",nom_image,Extension); - } - } - } - -/*........................ - Ouverture du fichier entete - ..........................................*/ -/******************************************************************************/ -/* MOD : VERSION : 4.6 : FA : En ouverture en modification, ouverture en "r+" */ -/* au lieu de "w" */ -/******************************************************************************/ - - tif = TIFFOpen(nom_fic,"r+"); - if (tif==NULL) - { - iret=0; - strcpy(CAI_ERREUR,"Erreur ouverture fichier tiff"); - } - else - { -/*.......................................................... - verification si l'image n'est pas comprimee -.............................................................*/ - TIFFGetField(tif,TIFFTAG_COMPRESSION,&compression); - if (compression != COMPRESSION_NONE) - { - iret=0; - strcpy(CAI_ERREUR,"Le fichier tiff est comprime. Format non traite !"); - } - else - { - -/*.......................................................... - verification si le fichier n'est pas code en pave -.............................................................*/ - Istile=TIFFIsTiled(tif); - if (Istile!=0) - { - iret=0; - strcpy(CAI_ERREUR,"Le fichier tiff est en paves . Format non traite !"); - } - else - { -/*.................................... - recuperation du nombre de colonnes -............................................*/ - TIFFGetField(tif,TIFFTAG_IMAGEWIDTH,&imagewidth); - *nb_col=imagewidth; -/*.................................... - recuperation du nombre de lignes -............................................*/ - TIFFGetField(tif,TIFFTAG_IMAGELENGTH,&imagelength); - *nb_lig=imagelength; - -/*...................................... - recuperation du nombre de canaux -............................................*/ - TIFFGetFieldDefaulted(tif,TIFFTAG_SAMPLESPERPIXEL,&samplesperpixel); - *nb_can=samplesperpixel; -/*......................................... - recuperation du nombre d'octets par pixel - .................................................*/ -/* Nombre de bits par pixels */ -/*****************************/ - TIFFGetField(tif,TIFFTAG_BITSPERSAMPLE,&bitspersample); - if ((bitspersample %8)==0) - *nboct_pix=(int)(bitspersample/8); - else - *nboct_pix=(int)((bitspersample/8)+1); - /*......................................... - recuperation du type de codage - .................................................*/ -/*****************************************************************************/ -/* MOD : VERSION : 5.0 : DM : A l'ouverture d'une image en lecture, renvoie */ -/* de COD_PIX à I4 ou R4 pour les images codees en I4 ou R4 */ -/*****************************************************************************/ - TIFFGetField(tif,TIFFTAG_SAMPLEFORMAT,&sampleformat); - -/*****************************************************************************/ -/* MOD : VERSION : 5.2 : DM : prise en compte des I2,I4,UI2,UI4 et R8 */ -/* en lecture et ecriture */ -/*****************************************************************************/ - Coher = 1; - if (*nboct_pix==1) - { - sprintf(image1->COD_PIX,"UOCT"); - if (sampleformat == SAMPLEFORMAT_INT) - sprintf(image1->COD_PIX,"OCT"); - else if (sampleformat != SAMPLEFORMAT_UINT) - Coher=0; - } - else if (*nboct_pix==2) - { - sprintf(image1->COD_PIX,"UI2"); - if (sampleformat == SAMPLEFORMAT_INT) - sprintf(image1->COD_PIX,"I2"); - else if (sampleformat != SAMPLEFORMAT_UINT) - Coher=0; - } - else if (*nboct_pix==4) - { - sprintf(image1->COD_PIX,"I4"); - if (sampleformat == SAMPLEFORMAT_IEEEFP) - sprintf(image1->COD_PIX,"R4"); - else if (sampleformat == SAMPLEFORMAT_UINT) - sprintf(image1->COD_PIX,"UI4"); - else if (sampleformat != SAMPLEFORMAT_INT) - Coher=0; - } - else if (*nboct_pix==8) - { - sprintf(image1->COD_PIX,"R8"); - if (sampleformat != SAMPLEFORMAT_IEEEFP) - Coher=0; - } - else - sprintf(image1->COD_PIX,"UND"); - -/*............................................*/ -/* Recuperation du type de codages des pixels */ -/*............................................*/ - TIFFGetField(tif,TIFFTAG_PLANARCONFIG,&photo); - -/*................................................... - recuperation de l'indice de photometric interpretation - ..............................................................*/ - TIFFGetField(tif,TIFFTAG_PHOTOMETRIC,&photo); - if ((photo<0)&&(photo>3)) - { - iret=0; - strcpy(CAI_ERREUR,"Photometric non connue . Format non traite !"); - } - - } - } - } - } - if (iret != 0) - { - -/*....................................... - INTIALISATION DES TABLEAUX CONTENANT LE NOM DE FICHIER - ET LE NOM UTILISATEUR DE CHAQUE CANAL - .....................................................*/ - - - deb = image1->NOM_FIC_CAN; - deb1= image1->NOM_UTIL_CAN; - - for (i=0;i<*nb_can;i=i+1) - { - sprintf(deb,"%s%s",nom_image,Extension); - deb=deb+100; - sprintf(deb1,"%s%s",nom_image,Extension); - deb1=deb1+100; - image1->POS_OCTET[i]=0; - image1->ACCES_CANAL_TIFF[i]=tif; - } - return (image1); - } - else - { - return(NULL); - } - -} - -/* - Fin de l'operation cai_ouvre_modifie_tiff -*/