cscg24-guacamole

CSCG 2024 Challenge 'Guacamole Mashup'
git clone https://git.sinitax.com/sinitax/cscg24-guacamole
Log | Files | Refs | sfeed.txt

instructions.h (4822B)


      1/*
      2 * Licensed to the Apache Software Foundation (ASF) under one
      3 * or more contributor license agreements.  See the NOTICE file
      4 * distributed with this work for additional information
      5 * regarding copyright ownership.  The ASF licenses this file
      6 * to you under the Apache License, Version 2.0 (the
      7 * "License"); you may not use this file except in compliance
      8 * with the License.  You may obtain a copy of the License at
      9 *
     10 *   http://www.apache.org/licenses/LICENSE-2.0
     11 *
     12 * Unless required by applicable law or agreed to in writing,
     13 * software distributed under the License is distributed on an
     14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     15 * KIND, either express or implied.  See the License for the
     16 * specific language governing permissions and limitations
     17 * under the License.
     18 */
     19
     20#ifndef GUACENC_INSTRUCTIONS_H
     21#define GUACENC_INSTRUCTIONS_H
     22
     23#include "config.h"
     24#include "display.h"
     25
     26/**
     27 * A callback function which, when invoked, handles a particular Guacamole
     28 * instruction. The opcode of the instruction is implied (as it is expected
     29 * that there will be a 1:1 mapping of opcode to callback function), while the
     30 * arguments for that instruction are included in the parameters given to the
     31 * callback.
     32 *
     33 * @param display
     34 *     The current internal display of the Guacamole video encoder.
     35 *
     36 * @param argc
     37 *     The number of arguments (excluding opcode) passed to the instruction
     38 *     being handled by the callback.
     39 *
     40 * @param argv
     41 *     All arguments (excluding opcode) associated with the instruction being
     42 *     handled by the callback.
     43 *
     44 * @return
     45 *     Zero if the instruction was handled successfully, non-zero if an error
     46 *     occurs.
     47 */
     48typedef int guacenc_instruction_handler(guacenc_display* display,
     49        int argc, char** argv);
     50
     51/**
     52 * Mapping of instruction opcode to corresponding handler function.
     53 */
     54typedef struct guacenc_instruction_handler_mapping {
     55
     56    /**
     57     * The opcode of the instruction that the associated handler function
     58     * should be invoked for.
     59     */
     60    const char* opcode;
     61
     62    /**
     63     * The handler function to invoke whenever an instruction having the
     64     * associated opcode is parsed.
     65     */
     66    guacenc_instruction_handler* handler;
     67
     68} guacenc_instruction_handler_mapping;
     69
     70/**
     71 * Array of all opcode/handler mappings for all supported opcodes, terminated
     72 * by an entry with a NULL opcode. All opcodes not listed here can be safely
     73 * ignored.
     74 */
     75extern guacenc_instruction_handler_mapping guacenc_instruction_handler_map[];
     76
     77/**
     78 * Handles the instruction having the given opcode and arguments, encoding the
     79 * result to the in-progress video.
     80 *
     81 * @param display
     82 *     The current internal display of the Guacamole video encoder.
     83 *
     84 * @param opcode
     85 *     The opcode of the instruction being handled.
     86 *
     87 * @param argc
     88 *     The number of arguments (excluding opcode) passed to the instruction
     89 *     being handled by the callback.
     90 *
     91 * @param argv
     92 *     All arguments (excluding opcode) associated with the instruction being
     93 *     handled by the callback.
     94 *
     95 * @return
     96 *     Zero if the instruction was handled successfully, non-zero if an error
     97 *     occurs.
     98 */
     99int guacenc_handle_instruction(guacenc_display* display,
    100        const char* opcode, int argc, char** argv);
    101
    102/**
    103 * Handler for the Guacamole "blob" instruction.
    104 */
    105guacenc_instruction_handler guacenc_handle_blob;
    106
    107/**
    108 * Handler for the Guacamole "img" instruction.
    109 */
    110guacenc_instruction_handler guacenc_handle_img;
    111
    112/**
    113 * Handler for the Guacamole "end" instruction.
    114 */
    115guacenc_instruction_handler guacenc_handle_end;
    116
    117/**
    118 * Handler for the Guacamole "mouse" instruction.
    119 */
    120guacenc_instruction_handler guacenc_handle_mouse;
    121
    122/**
    123 * Handler for the Guacamole "sync" instruction.
    124 */
    125guacenc_instruction_handler guacenc_handle_sync;
    126
    127/**
    128 * Handler for the Guacamole "cursor" instruction.
    129 */
    130guacenc_instruction_handler guacenc_handle_cursor;
    131
    132/**
    133 * Handler for the Guacamole "copy" instruction.
    134 */
    135guacenc_instruction_handler guacenc_handle_copy;
    136
    137/**
    138 * Handler for the Guacamole "transfer" instruction.
    139 */
    140guacenc_instruction_handler guacenc_handle_transfer;
    141
    142/**
    143 * Handler for the Guacamole "size" instruction.
    144 */
    145guacenc_instruction_handler guacenc_handle_size;
    146
    147/**
    148 * Handler for the Guacamole "rect" instruction.
    149 */
    150guacenc_instruction_handler guacenc_handle_rect;
    151
    152/**
    153 * Handler for the Guacamole "cfill" instruction.
    154 */
    155guacenc_instruction_handler guacenc_handle_cfill;
    156
    157/**
    158 * Handler for the Guacamole "move" instruction.
    159 */
    160guacenc_instruction_handler guacenc_handle_move;
    161
    162/**
    163 * Handler for the Guacamole "shade" instruction.
    164 */
    165guacenc_instruction_handler guacenc_handle_shade;
    166
    167/**
    168 * Handler for the Guacamole "dispose" instruction.
    169 */
    170guacenc_instruction_handler guacenc_handle_dispose;
    171
    172#endif
    173