~ubuntu-branches/ubuntu/jaunty/nas/jaunty

« back to all changes in this revision

Viewing changes to server/dia/main.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve McIntyre
  • Date: 2004-06-23 01:15:02 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040623011502-30uqd1dyu47iv2dp
Tags: 1.6d-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
******************************************************************/
49
49
 
50
50
/*
51
 
 * $Id: main.c,v 1.8 2001/04/29 22:47:48 jon Exp $
 
51
 * $Id: main.c,v 1.12 2004/02/14 23:38:33 jon Exp $
52
52
 */
53
53
 
54
54
#include <stdio.h>
63
63
#include "servermd.h"
64
64
#include "site.h"
65
65
#include "globals.h"
66
 
#include "nasconfig.h"
 
66
#include "nasconf.h"
67
67
 
68
68
extern void     OsInit(), InitClient(), ResetWellKnownSockets(),
69
69
                Dispatch(), FreeAllResources();
90
90
 
91
91
static FILE     *openConfigFile (char *path)
92
92
{
93
 
  static char   buf[1024];
94
93
  FILE *config;
95
94
 
96
 
  strcat (buf, path);
97
 
  strcat (buf, "nasd.conf");
98
 
  if ((config = fopen (buf, "r")) != NULL)
 
95
  if ((config = fopen (path, "r")) != NULL)
99
96
    return config;
100
97
  else
101
98
    return NULL;
108
105
    char        *argv[];
109
106
{
110
107
    int         i;
 
108
    char    *config_file;
111
109
 
112
110
    /* Notice if we're restart.  Probably this is because we jumped through
113
111
     * uninitialized pointer */
119
117
    /* Init the globals... */
120
118
    diaInitGlobals();
121
119
 
122
 
                                /* Now parse the config file */
123
 
    if ((yyin = openConfigFile (NASCONFSEARCHPATH)) != NULL)
 
120
    if ((config_file = FindConfigFile(argc, argv)) == NULL)
 
121
        config_file = NASCONFSEARCHPATH"/nasd.conf";
 
122
 
 
123
    /* Now parse the config file */
 
124
    if ((yyin = openConfigFile (config_file)) != NULL)
124
125
      yyparse();
125
126
 
126
127
    /* These are needed by some routines which are called from interrupt
137
138
    if (display == NULL)
138
139
      display = AuServerName();
139
140
 
140
 
    /* We're running as a daemon, so close stdin, stdout and stderr
141
 
       before we start the main loop */
142
 
 
143
 
    close(0);
144
 
    close(1);
145
 
 
146
 
    if (!NasConfig.DoDebug)
147
 
      close(2);                 /* only close stderr if no debugging */
 
141
    if (NasConfig.DoDaemon)
 
142
      {
 
143
        osBecomeOrphan();
 
144
        osBecomeDaemon();
 
145
 
 
146
        /* we could store pid info here... */
 
147
        /* osStorePid() */
 
148
      }
148
149
 
149
150
    /* And cd to / so we don't hold anything up; core files will also
150
151
       go there. */