00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 static int next_sequence_to_files(UINT seq_position, void *user_data,
00033 fid_Error *error)
00034 {
00035 fid_Sequences *seqs=(fid_Sequences *)user_data;
00036
00037 assert(seqs->tisfile.content == NULL || (seqs->tisfile.content != NULL && seqs->tisfile.occupied == seq_position));
00038 fid_MAPPEDFILE_APPEND_TRY(&seqs->sspfile,UINT,seq_position,error,
00039 {
00040 fid_error_throw(error,"Could not write sequence separator position "
00041 "file \"%s\".",seqs->sspfile.filename);
00042 return -1;
00043 });
00044 fid_MAPPEDFILE_APPEND_TRY(&seqs->tisfile,fid_Symbol,fid_SEPARATOR,error,
00045 {
00046 fid_error_throw(error,"Could not write transformed input sequence "
00047 "file \"%s\".",seqs->tisfile.filename);
00048 return -1;
00049 });
00050 fid_MAPPEDFILE_APPEND_TRY(&seqs->oisfile,unsigned char,fid_SEPARATOR,error,
00051 {
00052 fid_error_throw(error,"Could not write original input sequence "
00053 "file \"%s\".",seqs->oisfile.filename);
00054 return -1;
00055 });
00056
00057 return 0;
00058 }
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 static int append_desc_to_files(const char *desc, UINT desc_length,
00073 int write_separator, void *user_data,
00074 fid_Error *error)
00075 {
00076 fid_Sequences *seqs=(fid_Sequences *)user_data;
00077
00078 assert(seqs->sdsfile.content != NULL || desc == NULL);
00079 if(write_separator)
00080 {
00081 fid_MAPPEDFILE_APPEND_GROW(&seqs->sdsfile,UINT,seqs->desfile.occupied,error,
00082 {
00083 fid_error_throw(error,"Could not write sequence description "
00084 "separator file \"%s\".",seqs->sdsfile.filename);
00085 return -1;
00086 });
00087 }
00088 if(desc != NULL)
00089 {
00090 if(fid_file_ensure_free_space(&seqs->desfile,(size_t)desc_length,
00091 error) == -1)
00092 {
00093 fid_error_throw(error,"Could not write description file \"%s\".",
00094 seqs->desfile.filename);
00095 return -1;
00096 }
00097 memcpy(&seqs->desfile.content[seqs->desfile.occupied],desc,
00098 (size_t)desc_length);
00099 seqs->desfile.occupied+=(size_t)desc_length;
00100 }
00101 return 0;
00102 }
00103
00104
00105 #include "check32in64.h"
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118 static int next_sequence_to_dynarrays(UINT seq_position, void *user_data,
00119 fid_Error *error)
00120 {
00121 Sequencearrays *ptrs=(Sequencearrays *)user_data;
00122 #if defined SEQUENCES_32BIT_VERSION && fid_WORDSIZE == 64
00123 const char *what=NULL;
00124 #endif
00125
00126 assert(ptrs->tis.dyndata == NULL || (ptrs->tis.dyndata != NULL && ptrs->tis.occupied == seq_position));
00127 if(ptrs->ssp.VU.dyndata != NULL)
00128 {
00129 fid_DYNARRAY_APPEND(&ptrs->ssp.VU,UINT,fid_MAPPEDFILE_GROWSIZE,seq_position,
00130 fid_OUTOFMEM(error);
00131 return -1;);
00132 CHECK_32_IN_64_ENV(ptrs->ssp.VU,"sequence separators (ssp)");
00133 }
00134 if(ptrs->tis.dyndata != NULL)
00135 {
00136 fid_DYNARRAY_APPEND(&ptrs->tis,fid_Symbol,fid_MAPPEDFILE_GROWSIZE,
00137 fid_SEPARATOR,
00138 fid_OUTOFMEM(error);
00139 return -1;);
00140 CHECK_32_IN_64_ENV(ptrs->tis,"transformed sequences (tis)");
00141 }
00142 if(ptrs->ois.dyndata != NULL)
00143 {
00144 fid_DYNARRAY_APPEND(&ptrs->ois,char,fid_MAPPEDFILE_GROWSIZE,fid_SEPARATOR,
00145 fid_OUTOFMEM(error);
00146 return -1;);
00147 CHECK_32_IN_64_ENV(ptrs->ois,"sequences (ois)");
00148 }
00149 return 0;
00150
00151 #if defined SEQUENCES_32BIT_VERSION && fid_WORDSIZE == 64
00152 bail_out:
00153 fid_error_throw(error,too_large_for_32bits_error,what,ptrs->filename);
00154 return -1;
00155 #endif
00156 }
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170 static int append_desc_to_dynarrays(const char *desc, UINT desc_length,
00171 int write_separator, void *user_data,
00172 fid_Error *error)
00173 {
00174 Sequencearrays *ptrs=(Sequencearrays *)user_data;
00175 #if defined SEQUENCES_32BIT_VERSION && fid_WORDSIZE == 64
00176 const char *what=NULL;
00177 #endif
00178
00179 assert(ptrs->sds.VU.dyndata != NULL || desc == NULL);
00180 if(write_separator)
00181 {
00182 fid_DYNARRAY_APPEND(&ptrs->sds.VU,UINT,fid_MAPPEDFILE_GROWSIZE,
00183 (UINT)ptrs->des.occupied,
00184 fid_OUTOFMEM(error);
00185 return -1;);
00186 CHECK_32_IN_64_ENV(ptrs->sds.VU,"description separators (sds)");
00187 }
00188 if(desc != NULL)
00189 {
00190 fid_DYNARRAY_ENSURE_NFREE(&ptrs->des,char,(size_t)desc_length,
00191 fid_OUTOFMEM(error);
00192 return -1;);
00193 CHECK_32_IN_64_ENV(ptrs->des,"sequence descriptions (des)");
00194 memcpy(&ptrs->des.dyndata[ptrs->des.occupied],desc,(size_t)desc_length);
00195 ptrs->des.occupied+=(size_t)desc_length;
00196 }
00197 return 0;
00198
00199 #if defined SEQUENCES_32BIT_VERSION && fid_WORDSIZE == 64
00200 bail_out:
00201 fid_error_throw(error,too_large_for_32bits_error,what,ptrs->filename);
00202 return -1;
00203 #endif
00204 }
00205