~ubuntu-branches/ubuntu/natty/alien-arena/natty

« back to all changes in this revision

Viewing changes to source/utils3/common/parsecfg.c

  • Committer: Bazaar Package Importer
  • Author(s): Andres Mejia, Barry deFreese, Ansgar Burchardt, Gonéri Le Bouder, Andres Mejia
  • Date: 2008-04-18 17:43:24 UTC
  • mfrom: (1.1.2 upstream) (3.1.1 hardy)
  • Revision ID: james.westby@ubuntu.com-20080418174324-si1umi8dngglaha4
Tags: 7.0-1
[ Barry deFreese ]
* Escape - in alien-arena-server.6.
* Add myself to uploaders.

[ Ansgar Burchardt ]
* Remove deprecated Encoding key from .desktop file.

[ Gonéri Le Bouder ]
* Remove Homepage from package description.

[ Andres Mejia ]
* New upstream release.
* Removing XS- part for Vcs-* lines.
* Removing +ssh part of Vcs-Svn line.
* Bumped to Standards-Version 3.7.3.
* Test for existence of *-stamp stamps before removing them.
* Removed Encoding field in desktop file.
* Modify patch for upstream Makefile to make Makefile more useful in building
  Debian packages.
  + Also fixes problem not detecting the existence of libcurl.
* Remove debug packages for release. Will support nostrip option instead.
* Add description for fix-CVE-2007-4754-CVE-2007-4755.dpatch, silences
  lintian warning.
* Add new link for watchfile.
  + Closes: #453555
* Moved debian/scripts/alien-arena-tarball.sh to
  debian/alien-arena-get-orig-source.
* Modified alien-arena-data-get-orig-source to make it easier to maintain.
* Switched from dpatch to quilt.
* Cut down package description.
* Closing bug about mouse constantly looking up. The submitter could not
  reproduce the bug after deleting the ~/.alien-arena directory.
  + Closes: #457700
* Updated copyright file for new release.
* Updated README.Debian files.
* Adding new images for icons. Need build dependency on sharutils.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <stdlib.h>
 
3
#include <string.h>
 
4
#include "cmdlib.h"
 
5
#include "parsecfg.h"
 
6
                         
 
7
typedef struct arg_node_def
 
8
{
 
9
    char *param;
 
10
    struct arg_node_def *next;
 
11
} arg_node;
 
12
 
 
13
static arg_node *arg_node_root = 0;
 
14
static arg_node *arg_node_tail = 0;
 
15
static int first = 1;
 
16
 
 
17
static void AddParam(char *s)
 
18
{
 
19
    arg_node *node;
 
20
 
 
21
    node = malloc(sizeof(arg_node));
 
22
 
 
23
    node->next = 0;
 
24
    node->param = malloc(strlen(s)+1);
 
25
    strcpy(node->param, s);
 
26
 
 
27
    if(arg_node_tail == 0)
 
28
        {
 
29
        arg_node_root = node;
 
30
        first = 1;
 
31
        }
 
32
    else
 
33
        arg_node_tail->next = node;
 
34
        
 
35
    arg_node_tail = node;
 
36
}
 
37
 
 
38
void LoadConfigurationFile(char *s, int err)
 
39
{
 
40
    FILE *in;
 
41
    char file[128];
 
42
    arg_node *node, *node2;
 
43
    char line[256];
 
44
    int n;
 
45
    
 
46
    memset(file, 0, 128);
 
47
    strncpy(file, s, 121);
 
48
    strcat(file, ".cfg");
 
49
        
 
50
    in = fopen(file, "rt");
 
51
        
 
52
    if(in == 0)
 
53
        {
 
54
        if(err)
 
55
            fprintf(stderr, "Could not find configuration file %s.\n", file);
 
56
                
 
57
        return;
 
58
        }
 
59
        
 
60
    if(!first)
 
61
        {
 
62
        node = arg_node_root;
 
63
        arg_node_root = arg_node_root->next;
 
64
        free(node);
 
65
        }
 
66
        
 
67
    first = 1;
 
68
        
 
69
    node = arg_node_root;
 
70
    node2 = arg_node_tail;
 
71
        
 
72
    arg_node_root = 0;
 
73
    arg_node_tail = 0;
 
74
        
 
75
    while(fgets(line, 256, in) != 0)
 
76
        {
 
77
        if(line[0] == ';')
 
78
            continue;
 
79
                
 
80
        n = strlen(line)-1;
 
81
                
 
82
        if(n < 0)
 
83
            continue;
 
84
                
 
85
        if(line[n] == '\n')
 
86
                {
 
87
            if(n == 0)
 
88
                continue;
 
89
                        
 
90
            line[n] = 0;
 
91
                }
 
92
                
 
93
        AddParam(line);
 
94
        }
 
95
        
 
96
    arg_node_tail->next = node;
 
97
        
 
98
    if(node2 != 0)
 
99
        arg_node_tail = node2;
 
100
        
 
101
    fclose(in);
 
102
}
 
103
 
 
104
void LoadConfiguration(int argc, char *argv[])
 
105
{
 
106
    int n;
 
107
        
 
108
    for(n = 0; n < argc; n++)
 
109
        AddParam(argv[n]);
 
110
}
 
111
 
 
112
char *WalkConfiguration()
 
113
{
 
114
    arg_node *del;
 
115
 
 
116
    if(!first)
 
117
        {
 
118
        del = arg_node_root;
 
119
        arg_node_root = arg_node_root->next;
 
120
        free(del);
 
121
        }
 
122
 
 
123
    first = 0;
 
124
        
 
125
    if (arg_node_root == 0)
 
126
        {
 
127
        arg_node_tail = 0;
 
128
        return 0;
 
129
        }
 
130
 
 
131
    return arg_node_root->param;
 
132
}