<commit_before>/**
 * Please do not remove the following notices.
 *
 * \file       lisp_extend.c
 * \author     <NAME> <<EMAIL>>
 * \copyright  (c) 2015 by Geekscape Pty. Ltd.
 * \license    AGPLv3 http://geekscape.org/static/aiko_license.html
 *
 * Description
 * ~~~~~~~~~~~
 * Aiko server Lisp extensions.
 *
 * Usage
 * ~~~~~
 * (5:debug)               // toggle lispDebug flag
 * (8:addTimer)            // add timer every 1 second  for a single count
 * (8:addTimer4:2000)      // add timer every 2 seconds for a single count
 * (8:addtimer4:2000:1:4)  // add timer every 2 seconds for 4 counts
 *
 * To Do
 * ~~~~~
 * - None, yet.
 */

#include "aiko_engine.h"
#include "lisp.h"

#include "lisp_extend.h"

/* ------------------------------------------------------------------------- */

static uint8_t timer_counter = 0;
static uint8_t timer_maximum = 1;

uint8_t ATTRIBUTES
timer_handler(
  void *timer_self) {

  printf("timer_handler(): %d\n", timer_counter ++);

  if (timer_counter == timer_maximum) {
    aiko_delete_timer((aiko_timer_t *) timer_self);
  }

  return(AIKO_HANDLED);
}

tExpression ATTRIBUTES
*primitiveAddTimer(
  tExpression *expression,
  tExpression *environment) {

  timer_counter = 0;
  timer_maximum = 1;

  uint32_t microseconds = 1000000;  // default timer period: 1 second

  if (expression != NULL) {
    tExpression *parameter1 = expression->list.car;   // milliseconds
    tExpression *parameter2 = expression->list.cdr;   // (timer_maximum)
<commit_msg>Change example timer values from uint8_t to uint32_t.<commit_after>/**
 * Please do not remove the following notices.
 *
 * \file       lisp_extend.c
 * \author     <NAME> <<EMAIL>>
 * \copyright  (c) 2015 by Geekscape Pty. Ltd.
 * \license    AGPLv3 http://geekscape.org/static/aiko_license.html
 *
 * Description
 * ~~~~~~~~~~~
 * Aiko server Lisp extensions.
 *
 * Usage
 * ~~~~~
 * (5:debug)               // toggle lispDebug flag
 * (8:addTimer)            // add timer every 1 second  for a single count
 * (8:addTimer4:2000)      // add timer every 2 seconds for a single count
 * (8:addtimer4:2000:1:4)  // add timer every 2 seconds for 4 counts
 *
 * To Do
 * ~~~~~
 * - None, yet.
 */

#include "aiko_engine.h"
#include "lisp.h"

#include "lisp_extend.h"

/* ------------------------------------------------------------------------- */

static uint32_t timer_counter = 0;
static uint32_t timer_maximum = 1;

uint8_t ATTRIBUTES
timer_handler(
  void *timer_self) {

  printf("timer_handler(): %d\n", timer_counter ++);

  if (timer_counter == timer_maximum) {
    aiko_delete_timer((aiko_timer_t *) timer_self);
  }

  return(AIKO_HANDLED);
}

tExpression ATTRIBUTES
*primitiveAddTimer(
  tExpression *expression,
  tExpression *environment) {

  timer_counter = 0;
  timer_maximum = 1;

  uint32_t microseconds = 1000000;  // default timer period: 1 second

  if (expression != NULL) {
    tExpression *parameter1 = expression->list.car;   // milliseconds
    tExpression *parameter2 = expression->list.cdr;   // (timer_maximum)

{'fraction_non_alphanumeric': 0.17555994729907773, 'fraction_numerical': 0.030632411067193676, 'mean_word_length': 2.645858343337335, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4614158', 'n_tokens_mistral': 1069, 'n_tokens_neox': 987, 'n_words': 255}