• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/ucode/include/ucode/source.h

  1 /*
  2  * Copyright (C) 2021 Jo-Philipp Wich <jo@mein.io>
  3  *
  4  * Permission to use, copy, modify, and/or distribute this software for any
  5  * purpose with or without fee is hereby granted, provided that the above
  6  * copyright notice and this permission notice appear in all copies.
  7  *
  8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 15  */
 16 
 17 #ifndef UCODE_SOURCE_H
 18 #define UCODE_SOURCE_H
 19 
 20 #include <stdint.h>
 21 #include <stddef.h>
 22 #include <stdio.h>
 23 
 24 #include "util.h"
 25 #include "types.h"
 26 
 27 
 28 #define UC_PRECOMPILED_BYTECODE_MAGIC 0x1b756362  /* <esc> 'u' 'c' 'b' */
 29 
 30 typedef enum {
 31         UC_SOURCE_TYPE_PLAIN = 0,
 32         UC_SOURCE_TYPE_PRECOMPILED = 1,
 33 } uc_source_type_t;
 34 
 35 uc_source_t *uc_source_new_file(const char *path);
 36 uc_source_t *uc_source_new_buffer(const char *name, char *buf, size_t len);
 37 
 38 size_t uc_source_get_line(uc_source_t *source, size_t *offset);
 39 
 40 static inline uc_source_t *
 41 uc_source_get(uc_source_t *source) {
 42         return (uc_source_t *)ucv_get(source ? &source->header : NULL);
 43 }
 44 
 45 static inline void
 46 uc_source_put(uc_source_t *source) {
 47         ucv_put(source ? &source->header : NULL);
 48 }
 49 
 50 __hidden uc_source_type_t uc_source_type_test(uc_source_t *source);
 51 
 52 __hidden void uc_source_line_next(uc_source_t *source);
 53 __hidden void uc_source_line_update(uc_source_t *source, size_t off);
 54 
 55 __hidden void uc_source_runpath_set(uc_source_t *source, const char *runpath);
 56 
 57 __hidden bool uc_source_export_add(uc_source_t *source, uc_value_t *name);
 58 __hidden ssize_t uc_source_export_lookup(uc_source_t *source, uc_value_t *name);
 59 
 60 #endif /* UCODE_SOURCE_H */
 61 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt