~ubuntu-branches/ubuntu/precise/arj/precise-security

« back to all changes in this revision

Viewing changes to file_reg.c

  • Committer: Bazaar Package Importer
  • Author(s): Guillem Jover
  • Date: 2004-06-27 08:07:09 UTC
  • Revision ID: james.westby@ubuntu.com-20040627080709-1gkxm72ex66gkwe4
Tags: upstream-3.10.21
ImportĀ upstreamĀ versionĀ 3.10.21

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Id: file_reg.c,v 1.2 2003/05/03 22:18:47 andrew_belov Exp $
 
3
 * ---------------------------------------------------------------------------
 
4
 * This file contains registration-related helper procedures.
 
5
 *
 
6
 */
 
7
 
 
8
#include "arj.h"
 
9
 
 
10
DEBUGHDR(__FILE__)                      /* Debug information block */
 
11
 
 
12
/* Local variables */
 
13
 
 
14
static char special_key[]="Y2K";
 
15
#if TARGET==DOS
 
16
 static char default_key_name[]="C:ARJX";
 
17
 static char key_name[]="ARJ.KEY";
 
18
#else
 
19
 static char key_name[]="arj.key";
 
20
#endif
 
21
 
 
22
/* Validates registration information */
 
23
 
 
24
int reg_validation(char *key1, char *key2, char *name, char *validation)
 
25
{
 
26
 return(verify_reg_name(key1, key2, name, validation));
 
27
}
 
28
 
 
29
/* Hot-fix registration procedure */
 
30
 
 
31
void hot_reg(char *block)
 
32
{
 
33
 char *nptr;
 
34
 int i;
 
35
 
 
36
 strip_lf(block);
 
37
 nptr=block;
 
38
 if(!stricmp(block, special_key))
 
39
  in_key=0;
 
40
 for(i=0; i<8; i++)
 
41
 {
 
42
  nptr=ltrim(nptr);
 
43
  mput_dword(strtoul(nptr, &nptr, 10), (char*)&regdata[REG_HDR_SHIFT+(i<<2)]);
 
44
 }
 
45
 nptr=ltrim(nptr);
 
46
 for(i=0; *nptr!=' '&&*nptr!='\0'&&i<REG_KEY1_LEN; i++)
 
47
  regdata[REG_KEY1_SHIFT+i]=*nptr++;
 
48
 regdata[REG_KEY1_SHIFT+i]='\0';
 
49
 nptr=ltrim(nptr);
 
50
 for(i=0; *nptr!=' '&&*nptr!='\0'&&i<REG_KEY2_LEN; i++)
 
51
  regdata[REG_KEY2_SHIFT+i]=*nptr++;
 
52
 regdata[REG_KEY2_SHIFT+i]='\0';
 
53
 nptr=ltrim(nptr);
 
54
 for(i=0; *nptr!='\0'&&i<REG_NAME_LEN; i++)
 
55
  regdata[REG_NAME_SHIFT+i]=*nptr++;
 
56
 regdata[REG_NAME_SHIFT+i]='\0';
 
57
 alltrim(regdata+REG_KEY1_SHIFT);
 
58
}
 
59
 
 
60
/* Parses the registration key, if any */
 
61
 
 
62
void parse_reg_key()
 
63
{
 
64
 char *nptr;
 
65
 char key_path[FILENAME_MAX];
 
66
 char key[200];
 
67
 FILE *stream;
 
68
 
 
69
 if(regdata[REG_NAME_SHIFT]=='\0')
 
70
 {
 
71
  #ifndef SKIP_GET_EXE_NAME
 
72
   nptr=exe_name;
 
73
   #if TARGET==DOS
 
74
    if(_osmajor<3)
 
75
     nptr=default_key_name;
 
76
   #endif
 
77
   split_name(nptr, key_path, NULL);
 
78
   strcat(key_path, key_name);
 
79
  #else
 
80
   split_name(exe_name, key_path, NULL); /* Hack for PACKAGER */
 
81
   strcat(key_path, key_name);           /* Hack for PACKAGER */
 
82
   if(!file_exists(key_path))                      
 
83
    sprintf(key_path, "%s/.%s", getenv("HOME"), key_name);
 
84
   if(!file_exists(key_path))
 
85
    sprintf(key_path, "/etc/%s", key_name);
 
86
  #endif
 
87
  if(file_exists(key_path))
 
88
  {
 
89
   if((stream=fopen(key_path, m_r))!=NULL)
 
90
   {
 
91
    if(fgets(key, sizeof(key), stream)==NULL)
 
92
     fclose(stream);
 
93
    else
 
94
    {
 
95
     fclose(stream);
 
96
     hot_reg(key);
 
97
    }
 
98
   }
 
99
  }
 
100
 }
 
101
}