This file is indexed.

/usr/include/fontforge/scripting.h is in libfontforge-dev 20120731.b-7.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/* Copyright (C) 2005-2012 by George Williams */
/*
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:

 * Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.

 * Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.

 * The name of the author may not be used to endorse or promote products
 * derived from this software without specific prior written permission.

 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef _SCRIPTING_H
#define _SCRIPTING_H

#include "fontforgevw.h"
#include <setjmp.h>
#include <stdarg.h>

/* If users want to write user defined scripting built-in functions they will */
/*  need this file. The most relevant structure is the Context */

struct dictentry {
    char *name;
    Val val;
};

struct dictionary {
    struct dictentry *entries;
    int cnt, max;
};

typedef struct array {
    int argc;
    Val *vals;
} Array;

#define TOK_MAX	256
enum token_type { tt_name, tt_string, tt_number, tt_unicode, tt_real,
	tt_lparen, tt_rparen, tt_comma, tt_eos,		/* eos is end of statement, semicolon, newline */
	tt_lbracket, tt_rbracket,
	tt_minus, tt_plus, tt_not, tt_bitnot, tt_colon,
	tt_mul, tt_div, tt_mod, tt_and, tt_or, tt_bitand, tt_bitor, tt_xor,
	tt_eq, tt_ne, tt_gt, tt_lt, tt_ge, tt_le,
	tt_assign, tt_pluseq, tt_minuseq, tt_muleq, tt_diveq, tt_modeq,
	tt_incr, tt_decr,

	tt_if, tt_else, tt_elseif, tt_endif, tt_while, tt_foreach, tt_endloop,
	tt_shift, tt_return, tt_break,

	tt_eof,

	tt_error = -1
};

typedef struct context {
    struct context *caller;		/* The context of the script that called us */
    Array a;				/* The argument array */
    Array **dontfree;			/* Irrelevant for user defined funcs */
    struct dictionary locals;		/* Irrelevant for user defined funcs */
    FILE *script;			/* Irrelevant for user defined funcs */
    unsigned int backedup: 1;		/* Irrelevant for user defined funcs */
    unsigned int donteval: 1;		/* Irrelevant for user defined funcs */
    unsigned int returned: 1;		/* Irrelevant for user defined funcs */
    unsigned int broken: 1;		/* Irrelevant for user defined funcs */
    char tok_text[TOK_MAX+1];		/* Irrelevant for user defined funcs */
    enum token_type tok;		/* Irrelevant for user defined funcs */
    Val tok_val;			/* Irrelevant for user defined funcs */
    Val return_val;			/* Initialized to void. If user wants */
    					/*  return something set the return */
			                /*  value here */
    Val trace;				/* Irrelevant for user defined funcs */
    Val argsval;			/* Irrelevant for user defined funcs */
    char *filename;			/* Irrelevant for user defined funcs */
    int lineno;				/* Irrelevant for user defined funcs */
    int ungotch;			/* Irrelevant for user defined funcs */
    FontViewBase *curfv;		/* Current fontview */
    jmp_buf *err_env;			/* place to longjump to on an error */
} Context;

void arrayfree(Array *);

void FontImage(SplineFont *sf,char *filename,Array *arr,int width,int height);

 /* Adds a user defined scripting function to the interpretter */
 /* (you can't override a built-in name) */
 /* (you can replace a previous user defined function */
 /* Most functions will require a font to be loaded, but a few do not */
 /*  Open(), Exit(), Sin() don't.  ff uses the needs_font flag to perform */
 /*  this check for you */
 /* Returns 1 if the addition was successful, 2 if it replaced a previous func */
 /* Returns 0 on failure (ie. if it attempts to replace a builtin function) */
typedef void (*UserDefScriptFunc)(Context *);
extern int AddScriptingCommand(char *name,UserDefScriptFunc func,int needs_font);

 /* Returns whether a user defined scripting command already exists with the */
 /*  given name */
extern UserDefScriptFunc HasUserScriptingCommand(char *name);

 /* Scripts used to be in latin1, and we still support that if the user sets */
 /*  an environment variable. Now scripts are by default utf8. These two funcs */
 /*  will interconvert between latin1 & utf8 if appropriate, or just make a */
 /*  utf8 copy if not. They always make a copy. */
extern char *utf82script_copy(const char *ustr);
extern char *script2utf8_copy(const char *str);

 /* Various error routines. */
void ScriptError( Context *c, const char *msg );
	/* Prints an error message and exits. msg is in the script's encoding */
void ScriptErrorString( Context *c, const char *msg, const char *name);
	/* Prints an error message followed by a string and exits. */
	/*  both strings are in the script's encoding */
void ScriptErrorF( Context *c, const char *fmt, ... );
	/* Standard printf-style spec. All string arguments assumed to be in */
	/* utf8 */

extern int running_script;

/* Hooks so a scripting dlg can execute fontforge's legacy scripting language */
extern void ff_VerboseCheck(void);
extern enum token_type ff_NextToken(Context *c);
extern void ff_backuptok(Context *c);
extern void ff_statement(Context*);

#endif	/* _SCRIPTING_H */