source: trunk/essentials/app-arch/gzip/vms/vms.c

Last change on this file was 3325, checked in by bird, 18 years ago

gzip 1.3.11

File size: 2.2 KB
Line 
1/* vms.c -- target dependent functions for VMS
2 * This is free software; you can redistribute it and/or modify it under the
3 * terms of the GNU General Public License, see the file COPYING.
4 *
5 * This file was written by Karl-Jose Filler <pla_jfi@pki-nbg.philips.de>
6 * and updated by Jean-loup Gailly.
7 */
8
9#include <stdio.h>
10
11static char **vms_argv = NULL;
12
13static int max_files = 10000;
14
15struct Str_desc {
16 int length;
17 char *addr;
18};
19
20vms_expand_args(old_argc, argv)
21 int *old_argc;
22 char **argv[];
23{
24 int i;
25 int new_argc = 0;
26 int context, status;
27 char buf[255], *p;
28
29 vms_argv = (char**)xmalloc((max_files+1)*sizeof(char*));
30
31 vms_argv[new_argc++] = **argv;
32
33 for (i=1; i < *old_argc; i++) {
34 if (*argv[0][i] == '-') { /* switches */
35 if (new_argc < max_files) {
36 vms_argv[new_argc++] = argv[0][i];
37 }
38 } else { /* Files */
39 context = 0;
40 if (find_file_c(argv[0][i], buf, sizeof(buf), &context) & 1 != 1) {
41 /*
42 * Wrong file ?
43 * forward it to gzip
44 */
45 if (new_argc < max_files) {
46 vms_argv[new_argc++] = argv[0][i];
47 }
48 } else {
49 p = (char*)xmalloc(strlen(buf)+1);
50 strcpy(p, buf);
51 if (new_argc < max_files) {
52 vms_argv[new_argc++] = p;
53 }
54 while (find_file_c(argv[0][i], buf,
55 sizeof(buf), &context) & 1 == 1) {
56 p = (char*)xmalloc(strlen(buf)+1);
57 strcpy(p, buf);
58 if (new_argc < max_files) {
59 vms_argv[new_argc++] = p;
60 }
61 }
62 }
63 }
64 }
65 if (new_argc <= max_files) {
66 *old_argc = new_argc;
67 vms_argv[new_argc] = NULL;
68 *argv = vms_argv;
69 } else {
70 free(vms_argv); /* the expanded file names should also be freed ... */
71 vms_argv = NULL;
72 max_files = new_argc + 1;
73 vms_expand_args(old_argc, argv);
74 }
75}
76
77int find_file_c(in,out,out_len,context)
78 char *in;
79 char *out;
80 int out_len;
81 int *context;
82{
83 struct Str_desc in_desc,out_desc;
84 int status;
85 char *p;
86
87 in_desc.addr = in;
88 in_desc.length = strlen(in);
89
90 out_desc.addr = out;
91 out_desc.length = out_len;
92
93 status = lib$find_file(&in_desc,&out_desc,context);
94
95 p = out_desc.addr;
96 while(*p != ' ') {
97 p++;
98 }
99 *p = 0;
100
101 return status;
102}
Note: See TracBrowser for help on using the repository browser.