~ubuntu-branches/debian/sid/ntp/sid

« back to all changes in this revision

Viewing changes to sntp/libopts/environment.c

  • Committer: Package Import Robot
  • Author(s): Peter Eisentraut
  • Date: 2012-02-27 13:55:56 UTC
  • mfrom: (1.2.12)
  • Revision ID: package-import@ubuntu.com-20120227135556-dkx4mkod5trl5bgt
Tags: 1:4.2.6.p5+dfsg-1
* New upstream release (closes: #644673)
* Updated instructions on generating autotools.patch
* Updated standards version

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
/**
3
3
 * \file environment.c
4
4
 *
5
 
 * Time-stamp:      "2010-12-06 15:01:45 bkorb"
 
5
 * Time-stamp:      "2011-04-06 09:35:55 bkorb"
6
6
 *
7
7
 *  This file contains all of the routines that must be linked into
8
8
 *  an executable to use the generated option processing.  The optional
11
11
 *
12
12
 *  This file is part of AutoOpts, a companion to AutoGen.
13
13
 *  AutoOpts is free software.
14
 
 *  AutoOpts is Copyright (c) 1992-2010 by Bruce Korb - all rights reserved
 
14
 *  AutoOpts is Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
15
15
 *
16
16
 *  AutoOpts is available under any one of two licenses.  The license
17
17
 *  in use must be one of these two and the choice is under the control
206
206
    spaceLeft = AO_NAME_SIZE - (pzFlagName - zEnvName) - 1;
207
207
 
208
208
    for (;ct-- > 0; st.pOD++) {
 
209
        size_t nln;
 
210
 
209
211
        /*
210
212
         *  If presetting is disallowed, then skip this entry
211
213
         */
217
219
         *  IF there is no such environment variable,
218
220
         *  THEN skip this entry, too.
219
221
         */
220
 
        if (strlen(st.pOD->pz_NAME) >= spaceLeft)
221
 
            continue;
222
 
 
223
 
        /*
224
 
         *  Set up the option state
225
 
         */
226
 
        strcpy(pzFlagName, st.pOD->pz_NAME);
227
 
        do_env_opt(&st, zEnvName, pOpts, type);
 
222
        nln = strlen(st.pOD->pz_NAME) + 1;
 
223
        if (nln <= spaceLeft) {
 
224
            /*
 
225
             *  Set up the option state
 
226
             */
 
227
            memcpy(pzFlagName, st.pOD->pz_NAME, nln);
 
228
            do_env_opt(&st, zEnvName, pOpts, type);
 
229
        }
228
230
    }
229
231
 
230
232
    /*
232
234
     */
233
235
    if (  (pOpts->specOptIdx.save_opts != NO_EQUIVALENT)
234
236
       && (pOpts->specOptIdx.save_opts != 0)) {
 
237
        size_t nln;
235
238
        st.pOD = pOpts->pOptDesc + pOpts->specOptIdx.save_opts + 1;
236
239
 
237
 
        if (st.pOD->pz_NAME != NULL) {
238
 
            strcpy(pzFlagName, st.pOD->pz_NAME);
239
 
            do_env_opt(&st, zEnvName, pOpts, type);
240
 
        }
 
240
        if (st.pOD->pz_NAME == NULL)
 
241
            return;
 
242
 
 
243
        nln = strlen(st.pOD->pz_NAME) + 1;
 
244
            
 
245
        if (nln > spaceLeft)
 
246
            return;
 
247
 
 
248
        memcpy(pzFlagName, st.pOD->pz_NAME, nln);
 
249
        do_env_opt(&st, zEnvName, pOpts, type);
241
250
    }
242
251
}
243
252