2012-05-28 14:49:29 +00:00
|
|
|
/*
|
|
|
|
* This file is a part of Pcompress, a chunked parallel multi-
|
|
|
|
* algorithm lossless compression and decompression program.
|
|
|
|
*
|
2013-03-07 14:56:48 +00:00
|
|
|
* Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved.
|
2012-05-28 14:49:29 +00:00
|
|
|
* Use is subject to license terms.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2012-07-07 16:48:29 +00:00
|
|
|
* version 3 of the License, or (at your option) any later version.
|
2012-05-28 14:49:29 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
2013-03-07 14:56:48 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this program.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
2012-05-28 14:49:29 +00:00
|
|
|
* moinakg@belenix.org, http://moinakg.wordpress.com/
|
2014-07-26 09:58:40 +00:00
|
|
|
*
|
2012-05-28 14:49:29 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* pcompress - Do a chunked parallel compression/decompression of a file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <strings.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <libgen.h>
|
2014-05-24 18:22:30 +00:00
|
|
|
#include "pcompress.h"
|
2012-12-27 17:36:48 +00:00
|
|
|
#include <ctype.h>
|
2013-10-02 15:15:33 +00:00
|
|
|
#include <utils.h>
|
2012-05-28 14:49:29 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
2013-06-02 15:24:33 +00:00
|
|
|
int err;
|
|
|
|
pc_ctx_t *pctx;
|
2012-05-28 14:49:29 +00:00
|
|
|
|
2012-12-27 17:36:48 +00:00
|
|
|
err = 0;
|
2013-06-02 15:24:33 +00:00
|
|
|
pctx = create_pc_context();
|
|
|
|
|
|
|
|
err = init_pc_context(pctx, argc, argv);
|
|
|
|
if (err != 0 && err != 2) {
|
2013-10-02 15:15:33 +00:00
|
|
|
log_msg(LOG_ERR, 0, "Invalid arguments to pcompress.\n");
|
|
|
|
log_msg(LOG_ERR, 0, "Please see usage.\n");
|
2013-06-02 15:24:33 +00:00
|
|
|
destroy_pc_context(pctx);
|
|
|
|
return (err);
|
|
|
|
|
|
|
|
} else if (err == 2) {
|
|
|
|
usage(pctx);
|
|
|
|
destroy_pc_context(pctx);
|
|
|
|
return (0);
|
2012-11-23 16:57:14 +00:00
|
|
|
}
|
|
|
|
|
2012-05-28 14:49:29 +00:00
|
|
|
/*
|
|
|
|
* Start the main routines.
|
|
|
|
*/
|
2013-06-02 15:24:33 +00:00
|
|
|
err = start_pcompress(pctx);
|
|
|
|
destroy_pc_context(pctx);
|
2012-11-24 18:23:07 +00:00
|
|
|
return (err);
|
2012-05-28 14:49:29 +00:00
|
|
|
}
|