Go to the source code of this file.
Defines | |
#define | NEXT_ARG { curr_arg++; argc--; } |
Functions | |
static int | tcl_compress_file (ClientData cd, Tcl_Interp *irp, int argc, char *argv[]) |
static int | tcl_uncompress_file (ClientData cd, Tcl_Interp *irp, int argc, char *argv[]) |
static int | tcl_iscompressed (ClientData cd, Tcl_Interp *irp, int argc, char *argv[]) |
Variables | |
static tcl_cmds | my_tcl_cmds [] |
#define NEXT_ARG { curr_arg++; argc--; } |
static int tcl_compress_file | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 34 of file tclcompress.c.
References compress_file, compress_level, compress_to_file, NEXT_ARG, and NULL.
00036 { 00037 int mode_num = compress_level, result, curr_arg = 1; 00038 char *fn_src = NULL, *fn_target = NULL; 00039 00040 BADARGS(2, 5, " ?options...? src-file ?target-file?"); 00041 while ((argc > 1) && ((argv[curr_arg])[0] == '-')) { 00042 if (!strcmp(argv[curr_arg], "-level")) { 00043 argc--; 00044 if (argc <= 1) { 00045 Tcl_AppendResult(irp, "option `-level' needs parameter", NULL); 00046 return TCL_ERROR; 00047 } 00048 curr_arg++; 00049 mode_num = atoi(argv[curr_arg]); 00050 } else { 00051 Tcl_AppendResult(irp, "unknown option `", argv[curr_arg], "'", NULL); 00052 return TCL_ERROR; 00053 } 00054 NEXT_ARG; 00055 } 00056 if (argc <= 1) { 00057 Tcl_AppendResult(irp, "expecting src-filename as parameter", NULL); 00058 return TCL_ERROR; 00059 } 00060 fn_src = argv[curr_arg]; 00061 NEXT_ARG; 00062 if (argc > 1) { 00063 fn_target = argv[curr_arg]; 00064 NEXT_ARG; 00065 } 00066 if (argc > 1) { 00067 Tcl_AppendResult(irp, "trailing, unexpected parameter to command", NULL); 00068 return TCL_ERROR; 00069 } 00070 00071 if (fn_target) 00072 result = compress_to_file(fn_src, fn_target, mode_num); 00073 else 00074 result = compress_file(fn_src, mode_num); 00075 00076 if (result) 00077 Tcl_AppendResult(irp, "1", NULL); 00078 else 00079 Tcl_AppendResult(irp, "0", NULL); 00080 return TCL_OK; 00081 }
static int tcl_iscompressed | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 101 of file tclcompress.c.
References COMPF_COMPRESSED, COMPF_UNCOMPRESSED, is_compressedfile, and NULL.
00103 { 00104 int result; 00105 00106 BADARGS(2, 2, " compressed-file"); 00107 result = is_compressedfile(argv[1]); 00108 if (result == COMPF_UNCOMPRESSED) 00109 Tcl_AppendResult(irp, "0", NULL); /* Uncompressed. */ 00110 else if (result == COMPF_COMPRESSED) 00111 Tcl_AppendResult(irp, "1", NULL); /* Compressed. */ 00112 else 00113 Tcl_AppendResult(irp, "2", NULL); /* Failed to detect. */ 00114 return TCL_OK; 00115 }
static int tcl_uncompress_file | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 83 of file tclcompress.c.
References NULL, uncompress_file, and uncompress_to_file.
00085 { 00086 int result; 00087 00088 BADARGS(2, 3, " src-file ?target-file?"); 00089 if (argc == 2) 00090 result = uncompress_file(argv[1]); 00091 else 00092 result = uncompress_to_file(argv[1], argv[2]); 00093 00094 if (result) 00095 Tcl_AppendResult(irp, "1", NULL); 00096 else 00097 Tcl_AppendResult(irp, "0", NULL); 00098 return TCL_OK; 00099 }
tcl_cmds my_tcl_cmds[] [static] |
Initial value:
{ {"compressfile", tcl_compress_file}, {"uncompressfile", tcl_uncompress_file}, {"iscompressed", tcl_iscompressed}, {NULL, NULL} }
Definition at line 118 of file tclcompress.c.
Referenced by compress_close(), and start().