cmCPackDebGenerator.cxx 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmCPackDebGenerator.h"
  11. #include "cmSystemTools.h"
  12. #include "cmMakefile.h"
  13. #include "cmGeneratedFileStream.h"
  14. #include "cmCPackLog.h"
  15. #include <cmsys/SystemTools.hxx>
  16. #include <cmsys/Glob.hxx>
  17. #include <limits.h> // USHRT_MAX
  18. // NOTE:
  19. // A debian package .deb is simply an 'ar' archive. The only subtle difference
  20. // is that debian uses the BSD ar style archive whereas most Linux distro have
  21. // a GNU ar.
  22. // See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=161593 for more info
  23. // Therefore we provide our own implementation of a BSD-ar:
  24. static int ar_append(const char*archive,const std::vector<std::string>& files);
  25. //----------------------------------------------------------------------
  26. cmCPackDebGenerator::cmCPackDebGenerator()
  27. {
  28. }
  29. //----------------------------------------------------------------------
  30. cmCPackDebGenerator::~cmCPackDebGenerator()
  31. {
  32. }
  33. //----------------------------------------------------------------------
  34. int cmCPackDebGenerator::InitializeInternal()
  35. {
  36. this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
  37. if (cmSystemTools::IsOff(this->GetOption("CPACK_SET_DESTDIR")))
  38. {
  39. this->SetOption("CPACK_SET_DESTDIR", "I_ON");
  40. }
  41. return this->Superclass::InitializeInternal();
  42. }
  43. //----------------------------------------------------------------------
  44. int cmCPackDebGenerator::PackageFiles()
  45. {
  46. this->ReadListFile("CPackDeb.cmake");
  47. const char* cmakeExecutable = this->GetOption("CMAKE_COMMAND");
  48. // debian-binary file
  49. std::string dbfilename;
  50. dbfilename = toplevel;
  51. dbfilename += "/debian-binary";
  52. { // the scope is needed for cmGeneratedFileStream
  53. cmGeneratedFileStream out(dbfilename.c_str());
  54. out << "2.0";
  55. out << std::endl; // required for valid debian package
  56. }
  57. // control file
  58. std::string ctlfilename;
  59. ctlfilename = toplevel;
  60. ctlfilename += "/control";
  61. // debian policy enforce lower case for package name
  62. // mandatory entries:
  63. std::string debian_pkg_name = cmsys::SystemTools::LowerCase(
  64. this->GetOption("CPACK_DEBIAN_PACKAGE_NAME") );
  65. const char* debian_pkg_version =
  66. this->GetOption("CPACK_DEBIAN_PACKAGE_VERSION");
  67. const char* debian_pkg_section =
  68. this->GetOption("CPACK_DEBIAN_PACKAGE_SECTION");
  69. const char* debian_pkg_priority =
  70. this->GetOption("CPACK_DEBIAN_PACKAGE_PRIORITY");
  71. const char* debian_pkg_arch =
  72. this->GetOption("CPACK_DEBIAN_PACKAGE_ARCHITECTURE");
  73. const char* maintainer = this->GetOption("CPACK_DEBIAN_PACKAGE_MAINTAINER");
  74. const char* desc = this->GetOption("CPACK_DEBIAN_PACKAGE_DESCRIPTION");
  75. // optional entries
  76. const char* debian_pkg_dep = this->GetOption("CPACK_DEBIAN_PACKAGE_DEPENDS");
  77. const char* debian_pkg_rec =
  78. this->GetOption("CPACK_DEBIAN_PACKAGE_RECOMMENDS");
  79. const char* debian_pkg_sug =
  80. this->GetOption("CPACK_DEBIAN_PACKAGE_SUGGESTS");
  81. const char* debian_pkg_url =
  82. this->GetOption("CPACK_DEBIAN_PACKAGE_HOMEPAGE");
  83. const char* debian_pkg_predep =
  84. this->GetOption("CPACK_DEBIAN_PACKAGE_PREDEPENDS");
  85. const char* debian_pkg_enhances =
  86. this->GetOption("CPACK_DEBIAN_PACKAGE_ENHANCES");
  87. const char* debian_pkg_breaks =
  88. this->GetOption("CPACK_DEBIAN_PACKAGE_BREAKS");
  89. const char* debian_pkg_conflicts =
  90. this->GetOption("CPACK_DEBIAN_PACKAGE_CONFLICTS");
  91. const char* debian_pkg_provides =
  92. this->GetOption("CPACK_DEBIAN_PACKAGE_PROVIDES");
  93. const char* debian_pkg_replaces =
  94. this->GetOption("CPACK_DEBIAN_PACKAGE_REPLACES");
  95. { // the scope is needed for cmGeneratedFileStream
  96. cmGeneratedFileStream out(ctlfilename.c_str());
  97. out << "Package: " << debian_pkg_name << "\n";
  98. out << "Version: " << debian_pkg_version << "\n";
  99. out << "Section: " << debian_pkg_section << "\n";
  100. out << "Priority: " << debian_pkg_priority << "\n";
  101. out << "Architecture: " << debian_pkg_arch << "\n";
  102. if(debian_pkg_dep && *debian_pkg_dep)
  103. {
  104. out << "Depends: " << debian_pkg_dep << "\n";
  105. }
  106. if(debian_pkg_rec && *debian_pkg_rec)
  107. {
  108. out << "Recommends: " << debian_pkg_rec << "\n";
  109. }
  110. if(debian_pkg_sug && *debian_pkg_sug)
  111. {
  112. out << "Suggests: " << debian_pkg_sug << "\n";
  113. }
  114. if(debian_pkg_url && *debian_pkg_url)
  115. {
  116. out << "Homepage: " << debian_pkg_url << "\n";
  117. }
  118. if (debian_pkg_predep && *debian_pkg_predep)
  119. {
  120. out << "Pre-Depends: " << debian_pkg_predep << "\n";
  121. }
  122. if (debian_pkg_enhances && *debian_pkg_enhances)
  123. {
  124. out << "Enhances: " << debian_pkg_enhances << "\n";
  125. }
  126. if (debian_pkg_breaks && *debian_pkg_breaks)
  127. {
  128. out << "Breaks: " << debian_pkg_breaks << "\n";
  129. }
  130. if (debian_pkg_conflicts && *debian_pkg_conflicts)
  131. {
  132. out << "Conflicts: " << debian_pkg_conflicts << "\n";
  133. }
  134. if (debian_pkg_provides && *debian_pkg_provides)
  135. {
  136. out << "Provides: " << debian_pkg_provides << "\n";
  137. }
  138. if (debian_pkg_replaces && *debian_pkg_replaces)
  139. {
  140. out << "Replaces: " << debian_pkg_replaces << "\n";
  141. }
  142. unsigned long totalSize = 0;
  143. {
  144. std::string dirName = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
  145. dirName += '/';
  146. for (std::vector<std::string>::const_iterator fileIt = files.begin();
  147. fileIt != files.end(); ++ fileIt )
  148. {
  149. totalSize += cmSystemTools::FileLength(fileIt->c_str());
  150. }
  151. }
  152. out << "Installed-Size: " << (totalSize + 1023) / 1024 << "\n";
  153. out << "Maintainer: " << maintainer << "\n";
  154. out << "Description: " << desc << "\n";
  155. out << std::endl;
  156. }
  157. std::string cmd;
  158. cmd = "\"";
  159. cmd += cmakeExecutable;
  160. cmd += "\" -E tar cfz data.tar.gz ";
  161. // now add all directories which have to be compressed
  162. // collect all top level install dirs for that
  163. // e.g. /opt/bin/foo, /usr/bin/bar and /usr/bin/baz would give /usr and /opt
  164. size_t topLevelLength = toplevel.length();
  165. std::set<std::string> installDirs;
  166. for (std::vector<std::string>::const_iterator fileIt = files.begin();
  167. fileIt != files.end(); ++ fileIt )
  168. {
  169. std::string::size_type slashPos = fileIt->find('/', topLevelLength+1);
  170. std::string relativeDir = fileIt->substr(topLevelLength,
  171. slashPos - topLevelLength);
  172. if (installDirs.find(relativeDir) == installDirs.end())
  173. {
  174. installDirs.insert(relativeDir);
  175. cmd += " .";
  176. cmd += relativeDir;
  177. }
  178. }
  179. std::string output;
  180. int retVal = -1;
  181. int res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output,
  182. &retVal, toplevel.c_str(), this->GeneratorVerbose, 0);
  183. if ( !res || retVal )
  184. {
  185. std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
  186. tmpFile += "/Deb.log";
  187. cmGeneratedFileStream ofs(tmpFile.c_str());
  188. ofs << "# Run command: " << cmd.c_str() << std::endl
  189. << "# Working directory: " << toplevel << std::endl
  190. << "# Output:" << std::endl
  191. << output.c_str() << std::endl;
  192. cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running tar command: "
  193. << cmd.c_str() << std::endl
  194. << "Please check " << tmpFile.c_str() << " for errors" << std::endl);
  195. return 0;
  196. }
  197. std::string md5filename;
  198. md5filename = toplevel;
  199. md5filename += "/md5sums";
  200. { // the scope is needed for cmGeneratedFileStream
  201. cmGeneratedFileStream out(md5filename.c_str());
  202. std::vector<std::string>::const_iterator fileIt;
  203. std::string topLevelWithTrailingSlash = toplevel;
  204. topLevelWithTrailingSlash += '/';
  205. for ( fileIt = files.begin(); fileIt != files.end(); ++ fileIt )
  206. {
  207. cmd = "\"";
  208. cmd += cmakeExecutable;
  209. cmd += "\" -E md5sum \"";
  210. cmd += *fileIt;
  211. cmd += "\"";
  212. //std::string output;
  213. //int retVal = -1;
  214. res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output,
  215. &retVal, toplevel.c_str(), this->GeneratorVerbose, 0);
  216. // debian md5sums entries are like this:
  217. // 014f3604694729f3bf19263bac599765 usr/bin/ccmake
  218. // thus strip the full path (with the trailing slash)
  219. cmSystemTools::ReplaceString(output,
  220. topLevelWithTrailingSlash.c_str(), "");
  221. out << output;
  222. }
  223. // each line contains a eol.
  224. // Do not end the md5sum file with yet another (invalid)
  225. }
  226. cmd = "\"";
  227. cmd += cmakeExecutable;
  228. cmd += "\" -E tar cfz control.tar.gz ./control ./md5sums";
  229. const char* controlExtra =
  230. this->GetOption("CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA");
  231. if( controlExtra )
  232. {
  233. std::vector<std::string> controlExtraList;
  234. cmSystemTools::ExpandListArgument(controlExtra, controlExtraList);
  235. for(std::vector<std::string>::iterator i =
  236. controlExtraList.begin(); i != controlExtraList.end(); ++i)
  237. {
  238. std::string filenamename =
  239. cmsys::SystemTools::GetFilenameName(i->c_str());
  240. std::string localcopy = toplevel;
  241. localcopy += "/";
  242. localcopy += filenamename;
  243. // if we can copy the file, it means it does exist, let's add it:
  244. if( cmsys::SystemTools::CopyFileIfDifferent(
  245. i->c_str(), localcopy.c_str()) )
  246. {
  247. // debian is picky and need relative to ./ path in the tar.gz
  248. cmd += " ./";
  249. cmd += filenamename;
  250. }
  251. }
  252. }
  253. res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output,
  254. &retVal, toplevel.c_str(), this->GeneratorVerbose, 0);
  255. if ( !res || retVal )
  256. {
  257. std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
  258. tmpFile += "/Deb.log";
  259. cmGeneratedFileStream ofs(tmpFile.c_str());
  260. ofs << "# Run command: " << cmd.c_str() << std::endl
  261. << "# Working directory: " << toplevel << std::endl
  262. << "# Output:" << std::endl
  263. << output.c_str() << std::endl;
  264. cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running tar command: "
  265. << cmd.c_str() << std::endl
  266. << "Please check " << tmpFile.c_str() << " for errors" << std::endl);
  267. return 0;
  268. }
  269. // ar -r your-package-name.deb debian-binary control.tar.gz data.tar.gz
  270. // since debian packages require BSD ar (most Linux distros and even
  271. // FreeBSD and NetBSD ship GNU ar) we use a copy of OpenBSD ar here.
  272. std::vector<std::string> arFiles;
  273. std::string topLevelString = toplevel;
  274. topLevelString += "/";
  275. arFiles.push_back(topLevelString + "debian-binary");
  276. arFiles.push_back(topLevelString + "control.tar.gz");
  277. arFiles.push_back(topLevelString + "data.tar.gz");
  278. res = ar_append(packageFileNames[0].c_str(), arFiles);
  279. if ( res!=0 )
  280. {
  281. std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
  282. tmpFile += "/Deb.log";
  283. cmGeneratedFileStream ofs(tmpFile.c_str());
  284. ofs << "# Problem creating archive using: " << res << std::endl;
  285. return 0;
  286. }
  287. return 1;
  288. }
  289. // The following code is taken from OpenBSD ar:
  290. // http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ar/
  291. // It has been slightly modified:
  292. // -return error codes instead exit() in functions
  293. // -use the stdio file I/O functions instead the file descriptor based ones
  294. // -merged into one cxx file
  295. // -no additional options supported
  296. // The coding style hasn't been modified.
  297. /*-
  298. * Copyright (c) 1990, 1993, 1994
  299. * The Regents of the University of California. All rights reserved.
  300. *
  301. * This code is derived from software contributed to Berkeley by
  302. * Hugh Smith at The University of Guelph.
  303. *
  304. * Redistribution and use in source and binary forms, with or without
  305. * modification, are permitted provided that the following conditions
  306. * are met:
  307. * 1. Redistributions of source code must retain the above copyright
  308. * notice, this list of conditions and the following disclaimer.
  309. * 2. Redistributions in binary form must reproduce the above copyright
  310. * notice, this list of conditions and the following disclaimer in the
  311. * documentation and/or other materials provided with the distribution.
  312. * 3. Neither the name of the University nor the names of its contributors
  313. * may be used to endorse or promote products derived from this software
  314. * without specific prior written permission.
  315. *
  316. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  317. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  318. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  319. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  320. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  321. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  322. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  323. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  324. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  325. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  326. * SUCH DAMAGE.
  327. */
  328. #include <sys/types.h>
  329. #include <sys/stat.h>
  330. #include <stdio.h>
  331. #include <string.h>
  332. #include <stdlib.h>
  333. #define ARMAG "!<arch>\n" /* ar "magic number" */
  334. #define SARMAG 8 /* strlen(ARMAG); */
  335. #define AR_EFMT1 "#1/" /* extended format #1 */
  336. #define ARFMAG "`\n"
  337. /* Header format strings. */
  338. #define HDR1 "%s%-13d%-12ld%-6u%-6u%-8o%-10lld%2s"
  339. #define HDR2 "%-16.16s%-12ld%-6u%-6u%-8o%-10lld%2s"
  340. struct ar_hdr {
  341. char ar_name[16]; /* name */
  342. char ar_date[12]; /* modification time */
  343. char ar_uid[6]; /* user id */
  344. char ar_gid[6]; /* group id */
  345. char ar_mode[8]; /* octal file permissions */
  346. char ar_size[10]; /* size in bytes */
  347. char ar_fmag[2]; /* consistency check */
  348. };
  349. /* Set up file copy. */
  350. #define SETCF(from, fromname, to, toname, pad) { \
  351. cf.rFile = from; \
  352. cf.rname = fromname; \
  353. cf.wFile = to; \
  354. cf.wname = toname; \
  355. cf.flags = pad; \
  356. }
  357. /* File copy structure. */
  358. typedef struct {
  359. FILE* rFile; /* read file descriptor */
  360. const char *rname; /* read name */
  361. FILE* wFile; /* write file descriptor */
  362. const char *wname; /* write name */
  363. #define NOPAD 0x00 /* don't pad */
  364. #define WPAD 0x02 /* pad on writes */
  365. unsigned int flags; /* pad flags */
  366. } CF;
  367. /* misc.c */
  368. static const char * ar_rname(const char *path)
  369. {
  370. const char *ind = strrchr(path, '/');
  371. return (ind ) ? ind + 1 : path;
  372. }
  373. /* archive.c */
  374. typedef struct ar_hdr HDR;
  375. static char ar_hb[sizeof(HDR) + 1]; /* real header */
  376. static size_t ar_already_written;
  377. /* copy_ar --
  378. * Copy size bytes from one file to another - taking care to handle the
  379. * extra byte (for odd size files) when reading archives and writing an
  380. * extra byte if necessary when adding files to archive. The length of
  381. * the object is the long name plus the object itself; the variable
  382. * already_written gets set if a long name was written.
  383. *
  384. * The padding is really unnecessary, and is almost certainly a remnant
  385. * of early archive formats where the header included binary data which
  386. * a PDP-11 required to start on an even byte boundary. (Or, perhaps,
  387. * because 16-bit word addressed copies were faster?) Anyhow, it should
  388. * have been ripped out long ago.
  389. */
  390. static int copy_ar(CF *cfp, off_t size)
  391. {
  392. static char pad = '\n';
  393. off_t sz = size;
  394. size_t nr, nw;
  395. char buf[8*1024];
  396. if (sz == 0)
  397. return 0;
  398. FILE* from = cfp->rFile;
  399. FILE* to = cfp->wFile;
  400. while (sz &&
  401. (nr = fread(buf, 1, sz < static_cast<off_t>(sizeof(buf))
  402. ? static_cast<size_t>(sz) : sizeof(buf), from ))
  403. > 0) {
  404. sz -= nr;
  405. for (size_t off = 0; off < nr; nr -= off, off += nw)
  406. if ((nw = fwrite(buf + off, 1, nr, to)) < nr)
  407. return -1;
  408. }
  409. if (sz)
  410. return -2;
  411. if (cfp->flags & WPAD && (size + ar_already_written) & 1
  412. && fwrite(&pad, 1, 1, to) != 1)
  413. return -4;
  414. return 0;
  415. }
  416. /* put_arobj -- Write an archive member to a file. */
  417. static int put_arobj(CF *cfp, struct stat *sb)
  418. {
  419. int result = 0;
  420. struct ar_hdr *hdr;
  421. /* If passed an sb structure, reading a file from disk. Get stat(2)
  422. * information, build a name and construct a header. (Files are named
  423. * by their last component in the archive.) */
  424. const char* name = ar_rname(cfp->rname);
  425. (void)stat(cfp->rname, sb);
  426. /* If not truncating names and the name is too long or contains
  427. * a space, use extended format 1. */
  428. size_t lname = strlen(name);
  429. uid_t uid = sb->st_uid;
  430. gid_t gid = sb->st_gid;
  431. if (uid > USHRT_MAX) {
  432. uid = USHRT_MAX;
  433. }
  434. if (gid > USHRT_MAX) {
  435. gid = USHRT_MAX;
  436. }
  437. if (lname > sizeof(hdr->ar_name) || strchr(name, ' '))
  438. (void)sprintf(ar_hb, HDR1, AR_EFMT1, (int)lname,
  439. (long int)sb->st_mtime, uid, gid, sb->st_mode,
  440. (long long)sb->st_size + lname, ARFMAG);
  441. else {
  442. lname = 0;
  443. (void)sprintf(ar_hb, HDR2, name,
  444. (long int)sb->st_mtime, uid, gid, sb->st_mode,
  445. (long long)sb->st_size, ARFMAG);
  446. }
  447. off_t size = sb->st_size;
  448. if (fwrite(ar_hb, 1, sizeof(HDR), cfp->wFile) != sizeof(HDR))
  449. return -1;
  450. if (lname) {
  451. if (fwrite(name, 1, lname, cfp->wFile) != lname)
  452. return -2;
  453. ar_already_written = lname;
  454. }
  455. result = copy_ar(cfp, size);
  456. ar_already_written = 0;
  457. return result;
  458. }
  459. /* append.c */
  460. /* append --
  461. * Append files to the archive - modifies original archive or creates
  462. * a new archive if named archive does not exist.
  463. */
  464. static int ar_append(const char* archive,const std::vector<std::string>& files)
  465. {
  466. int eval = 0;
  467. FILE* aFile = fopen(archive, "wb+");
  468. if (aFile!=NULL) {
  469. fwrite(ARMAG, SARMAG, 1, aFile);
  470. if (fseek(aFile, 0, SEEK_END) != -1) {
  471. CF cf;
  472. struct stat sb;
  473. /* Read from disk, write to an archive; pad on write. */
  474. SETCF(NULL, 0, aFile, archive, WPAD);
  475. for(std::vector<std::string>::const_iterator fileIt = files.begin();
  476. fileIt!=files.end(); ++fileIt) {
  477. const char* filename = fileIt->c_str();
  478. FILE* file = fopen(filename, "rb");
  479. if (file == NULL) {
  480. eval = -1;
  481. continue;
  482. }
  483. cf.rFile = file;
  484. cf.rname = filename;
  485. int result = put_arobj(&cf, &sb);
  486. (void)fclose(file);
  487. if (result!=0) {
  488. eval = -2;
  489. break;
  490. }
  491. }
  492. }
  493. else {
  494. eval = -3;
  495. }
  496. fclose(aFile);
  497. }
  498. else {
  499. eval = -4;
  500. }
  501. return eval;
  502. }