File: join.c

package info (click to toggle)
arj 3.10.22-13
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,352 kB
  • ctags: 4,701
  • sloc: ansic: 32,990; makefile: 2,034; sh: 1,547; asm: 436
file content (75 lines) | stat: -rw-r--r-- 1,500 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
 * $Id: join.c,v 1.3 2003/04/27 20:54:42 andrew_belov Exp $
 * ---------------------------------------------------------------------------
 * This program writes overlay data to ARJ executables.
 *
 */

#include "arj.h"

static char buffer[PROC_BLOCK_SIZE];

static void _fput_dword(const unsigned long l, FILE *stream)
{
#ifdef WORDS_BIGENDIAN
 fputc(l    ,stream);
 fputc(l>>8 ,stream);
 fputc(l>>16,stream);
 fputc(l>>24,stream);
#else
 fwrite(&l,4,1,stream);
#endif
}
 
int main(int argc, char **argv)
{
 FILE *V1, *V2;
 unsigned long b;
 int i, rc=0;

 printf("JOIN v 1.30  [26/04/2003]  Not a part of any binary package!\r\n\r\n");
 if(argc>=3)
 {
  if((V1=fopen(argv[1], m_abp))!=NULL)
  {
   if((V2=fopen(argv[2], m_rb))!=NULL)
   {
    fseek(V1, 0, SEEK_END);
    b=ftell(V1);
    fgetc(V1);
    fwrite("ARJ_SFX", 1, 8, V1); _fput_dword(b, V1);
    fseek(V2, 0, SEEK_END); b=ftell(V2); fseek(V2, 0, SEEK_SET);
    _fput_dword(b, V1);
    /* Now simply copy the file */
    printf("Copying ");
    while((i=fread(buffer, 1, sizeof(buffer), V2))!=0)
    {
     fwrite(buffer, 1, i, V1);
     printf(".");
    }
    printf(" done!\r\n");
    fclose(V2);
   }
   else
   {
    printf("Can't open %s\r\n", argv[1]);
    rc=3;
   }
   fclose(V1);
  }
  else
  {
   printf("Can't open ARJ.EXE\r\n");
return 0;
   rc=2;
  }
 }
 else
 {
  printf("Usage: JOIN <target> <overlay>,\r\n"
         "       e.g, to append HELP.ARJ to ARJ.EXE, type JOIN ARJ.EXE HELP.ARJ\r\n");
  rc=1;
 }

 return rc;
}