"Fossies" - the Fresh Open Source Software Archive

Member "cook-2.34/cook/builtin/interi_files.c" (25 Sep 2010, 4640 Bytes) of package /linux/misc/old/cook-2.34.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "interi_files.c" see the Fossies "Dox" file reference documentation.

    1 /*
    2  *      cook - file construction tool
    3  *      Copyright (C) 1998, 1999, 2001, 2006-2008 Peter Miller
    4  *
    5  *      This program is free software; you can redistribute it and/or modify
    6  *      it under the terms of the GNU General Public License as published by
    7  *      the Free Software Foundation; either version 3 of the License, or
    8  *      (at your option) any later version.
    9  *
   10  *      This program is distributed in the hope that it will be useful,
   11  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
   12  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13  *      GNU General Public License for more details.
   14  *
   15  *      You should have received a copy of the GNU General Public License
   16  *      along with this program. If not, see
   17  *      <http://www.gnu.org/licenses/>.
   18  */
   19 
   20 #include <cook/builtin/interi_files.h>
   21 #include <common/error_intl.h>
   22 #include <cook/expr/position.h>
   23 #include <cook/graph.h>
   24 #include <cook/opcode/context.h>
   25 #include <common/str_list.h>
   26 #include <common/trace.h>
   27 
   28 
   29 /*
   30  * NAME
   31  *      builtin_interior_files - graph details
   32  *
   33  * SYNOPSIS
   34  *      int builtin_interior_files(string_list_ty *result,
   35  *              string_list_ty *args);
   36  *
   37  * DESCRIPTION
   38  *      Interior_files is a built-in function of cook, described as
   39  *      follows: This function requires no arguments.  Interior_files
   40  *      returns the files in the dependency graph which are derived files,
   41  *      i.e. are interior to the graph.
   42  *
   43  * CAVEAT
   44  *      The returned result is in dynamic memory.
   45  *      It is the responsibility of the caller to dispose of
   46  *      the result when it is finished, with a string_list_destructor() call.
   47  */
   48 
   49 static int
   50 interior_interpret(string_list_ty *result, const string_list_ty *args,
   51     const expr_position_ty *pp, const opcode_context_ty * ocp)
   52 {
   53     trace(("interior_files\n"));
   54     assert(result);
   55     assert(args);
   56     assert(args->nstrings);
   57     if (args->nstrings != 1)
   58     {
   59         sub_context_ty  *scp;
   60 
   61         scp = sub_context_new();
   62         sub_var_set_string(scp, "Name", args->string[0]);
   63         error_with_position(pp, scp, i18n("$name: requires no arguments"));
   64         sub_context_delete(scp);
   65         return -1;
   66     }
   67 
   68     /*
   69      * Only meaningful *inside* a recipe body.
   70      */
   71     if (!ocp->gp)
   72     {
   73         sub_context_ty  *scp;
   74 
   75         scp = sub_context_new();
   76         sub_var_set_string(scp, "Name", args->string[0]);
   77         error_with_position
   78         (
   79             pp,
   80             scp,
   81             i18n("$name: only meaningful inside recipe body")
   82         );
   83         sub_context_delete(scp);
   84         return -1;
   85     }
   86 
   87     /*
   88      * ask for the info
   89      */
   90     graph_interior_files(ocp->gp, result);
   91     return 0;
   92 }
   93 
   94 
   95 builtin_ty builtin_interior_files =
   96 {
   97     "interior_files",
   98     interior_interpret,
   99     interior_interpret,         /* script */
  100 };
  101 
  102 
  103 /*
  104  * NAME
  105  *      builtin_leaf_files - graph details
  106  *
  107  * SYNOPSIS
  108  *      int builtin_leaf_files(string_list_ty *result, string_list_ty *args);
  109  *
  110  * DESCRIPTION
  111  *      Leaf_files is a built-in function of cook, described as follows:
  112  *      This function requires no arguments.    Leaf_files returns
  113  *      the files in the dependency graph which are not derived files,
  114  *      i.e. are leaves of the graph.
  115  *
  116  * CAVEAT
  117  *      The returned result is in dynamic memory.
  118  *      It is the responsibility of the caller to dispose of
  119  *      the result when it is finished, with a string_list_destructor() call.
  120  */
  121 
  122 static int
  123 leaf_interpret(string_list_ty *result, const string_list_ty *args,
  124     const expr_position_ty *pp, const opcode_context_ty *ocp)
  125 {
  126     trace(("leaf_files\n"));
  127     assert(result);
  128     assert(args);
  129     assert(args->nstrings);
  130     if (args->nstrings != 1)
  131     {
  132         sub_context_ty  *scp;
  133 
  134         scp = sub_context_new();
  135         sub_var_set_string(scp, "Name", args->string[0]);
  136         error_with_position(pp, scp, i18n("$name: requires no arguments"));
  137         sub_context_delete(scp);
  138         return -1;
  139     }
  140 
  141     /*
  142      * Only meaningful *inside* a recipe body.
  143      */
  144     if (!ocp->gp)
  145     {
  146         sub_context_ty  *scp;
  147 
  148         scp = sub_context_new();
  149         sub_var_set_string(scp, "Name", args->string[0]);
  150         error_with_position
  151         (
  152             pp,
  153             scp,
  154             i18n("$name: only meaningful inside recipe body")
  155         );
  156         sub_context_delete(scp);
  157         return -1;
  158     }
  159 
  160     /*
  161      * ask for the info
  162      */
  163     graph_leaf_files(ocp->gp, result);
  164     return 0;
  165 }
  166 
  167 
  168 builtin_ty builtin_leaf_files =
  169 {
  170     "leaf_files",
  171     leaf_interpret,
  172     leaf_interpret,             /* script */
  173 };