Home | History | Annotate | Download | only in kati
      1 // Copyright 2015 Google Inc. All rights reserved
      2 //
      3 // Licensed under the Apache License, Version 2.0 (the "License");
      4 // you may not use this file except in compliance with the License.
      5 // You may obtain a copy of the License at
      6 //
      7 //      http://www.apache.org/licenses/LICENSE-2.0
      8 //
      9 // Unless required by applicable law or agreed to in writing, software
     10 // distributed under the License is distributed on an "AS IS" BASIS,
     11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 // See the License for the specific language governing permissions and
     13 // limitations under the License.
     14 
     15 #ifndef FUNC_H_
     16 #define FUNC_H_
     17 
     18 #include <memory>
     19 #include <string>
     20 #include <vector>
     21 
     22 #include "expr.h"
     23 
     24 using namespace std;
     25 
     26 struct FuncInfo {
     27   const char* name;
     28   void (*func)(const vector<Value*>& args, Evaluator* ev, string* s);
     29   int arity;
     30   int min_arity;
     31   // For all parameters.
     32   bool trim_space;
     33   // Only for the first parameter.
     34   bool trim_right_space_1st;
     35 };
     36 
     37 void InitFuncTable();
     38 void QuitFuncTable();
     39 
     40 FuncInfo* GetFuncInfo(StringPiece name);
     41 
     42 struct FindCommand;
     43 
     44 enum struct CommandOp {
     45   SHELL,
     46   FIND,
     47   READ,
     48   READ_MISSING,
     49   WRITE,
     50   APPEND,
     51 };
     52 
     53 struct CommandResult {
     54   CommandOp op;
     55   string shell;
     56   string shellflag;
     57   string cmd;
     58   unique_ptr<FindCommand> find;
     59   string result;
     60 };
     61 
     62 const vector<CommandResult*>& GetShellCommandResults();
     63 
     64 #endif  // FUNC_H_
     65