/* ---------------------------------------------------------------------------- libconfig - A library for processing structured configuration files Copyright (C) 2005-2010 Mark A Lindner This file is part of libconfig. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, see . ---------------------------------------------------------------------------- */ #include "scanctx.h" #include "wincompat.h" #include #include #include #define STRING_BLOCK_SIZE 64 #define CHUNK_SIZE 32 /* ------------------------------------------------------------------------- */ static const char *err_bad_include = "cannot open include file"; static const char *err_include_too_deep = "include file nesting too deep"; /* ------------------------------------------------------------------------- */ static const char *__scanctx_add_filename(struct scan_context *ctx, const char *filename) { unsigned int count = ctx->num_filenames; const char **f; for(f = ctx->filenames; count > 0; ++f, --count) { if(!strcmp(*f, filename)) { free((void *)filename); return(*f); /* already in list */ } } if((ctx->num_filenames % CHUNK_SIZE) == 0) { ctx->filenames = (const char **)realloc( (void *)ctx->filenames, (ctx->num_filenames + CHUNK_SIZE) * sizeof(const char *)); } ctx->filenames[ctx->num_filenames] = filename; ++ctx->num_filenames; return(filename); } /* ------------------------------------------------------------------------- */ void scanctx_init(struct scan_context *ctx, const char *top_filename) { memset(ctx, 0, sizeof(struct scan_context)); if(top_filename) ctx->top_filename = __scanctx_add_filename(ctx, strdup(top_filename)); } /* ------------------------------------------------------------------------- */ const char **scanctx_cleanup(struct scan_context *ctx, unsigned int *num_filenames) { int i; for(i = 0; i < ctx->depth; ++i) fclose(ctx->streams[i]); free((void *)(strbuf_release(&(ctx->string)))); *num_filenames = ctx->num_filenames; return(ctx->filenames); } /* ------------------------------------------------------------------------- */ FILE *scanctx_push_include(struct scan_context *ctx, void *buffer, const char **error) { FILE *fp = NULL; const char *file; char *full_file = NULL; *error = NULL; if(ctx->depth == MAX_INCLUDE_DEPTH) { *error = err_include_too_deep; return(NULL); } file = scanctx_take_string(ctx); if(ctx->config->include_dir) { full_file = (char *)malloc(strlen(ctx->config->include_dir) + strlen(file) + 2); strcpy(full_file, ctx->config->include_dir); strcat(full_file, FILE_SEPARATOR); strcat(full_file, file); } fp = fopen(full_file ? full_file : file, "rt"); free((void *)full_file); if(fp) { ctx->streams[ctx->depth] = fp; ctx->files[ctx->depth] = __scanctx_add_filename(ctx, file); ctx->buffers[ctx->depth] = buffer; ++(ctx->depth); } else { free((void *)file); *error = err_bad_include; } return(fp); } /* ------------------------------------------------------------------------- */ void *scanctx_pop_include(struct scan_context *ctx) { void *buffer; if(ctx->depth == 0) return(NULL); /* stack underflow */ --(ctx->depth); buffer = ctx->buffers[ctx->depth]; fclose(ctx->streams[ctx->depth]); return(buffer); } /* ------------------------------------------------------------------------- */ char *scanctx_take_string(struct scan_context *ctx) { char *r = strbuf_release(&(ctx->string)); return(r ? r : strdup("")); } /* ------------------------------------------------------------------------- */ const char *scanctx_current_filename(struct scan_context *ctx) { return((ctx->depth == 0) ? ctx->top_filename : ctx->files[ctx->depth - 1]); } /* ------------------------------------------------------------------------- */ /* eof */ * Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/* $Id: rgb.h,v 1.1 2006/01/30 05:47:38 reinelt Exp $
 *
 * generic color handling
 *
 * Copyright (C) 2005 Michael Reinelt <reinelt@eunet.at>
 * Copyright (C) 2005 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
 *
 * This file is part of LCD4Linux.
 *
 * LCD4Linux is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * LCD4Linux is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *
 * $Log: rgb.h,v $
 * Revision 1.1  2006/01/30 05:47:38  reinelt
 * graphic subsystem changed to full-color RGBA
 *
 */


#ifndef _RGB_H_
#define _RGB_H_

typedef struct {
    unsigned char R;
    unsigned char G;
    unsigned char B;
    unsigned char A;
} RGBA;


int color2RGBA(const char *color, RGBA * C);

#endif