Beispiel #1
0
int main(int argc, const char * argv[]) {
    
    /* Mandatory HTML info and navbar, etc. */
    init_page("blog");
    
    /* Google analytics script */
    include_google_analytics();
    
    /* Print Blog entries */
    char *env_string = getenv("QUERY_STRING");
    
    // Get the variables we want from env variable
    char *start = get_variable(env_string, "start=");
    char *end = get_variable(env_string, "end=");
    char *search = get_variable(env_string, "search=");
    char *month = get_variable(env_string, "month=");
    char *year = get_variable(env_string, "year=");
    
    printf("<div class=\"container\">"); // Start container that holds posts
    
    printf("<div class=\"row\"><div class=\"col-sm-8 blog-main\">");
    
    if (search != NULL) {
        print_search_notification(search);
        print_blog_posts(0, 10000, search);
    } else if (month != NULL && year != NULL) {
        print_posts_by_monthyear(atoi(month), atoi(year));
    } else if (start != NULL && end != NULL) {
        int int_start = atoi(start);
        int int_end = atoi(end);
        print_blog_posts(int_start, int_end, NULL);
    } else {
        print_blog_posts(0, 4, NULL);
    }
    // Free the variables we got
    free(start); free(end); free(search);
    
    printf("</div>"); // Close Blog
    
    // Blog sidebar
    printf("<div class=\"col-sm-3 col-sm-offset-1 blog-sidebar\">");
    
    print_about_box();
    print_archives();
    
    printf("</div>"); // Close sidebar
    
    printf("</div>"); // Close row
    
    printf("</div>"); // Close container
    
    printf("</body>"); // End HTML body, is opened in init_page()
    
    /* Print page footer, copyright, name, etc. */
    print_footer();
    
    printf("</html>");
    
    return 0;
}
Beispiel #2
0
Datei: gc.c Projekt: mtmiron/toi
void
Init_gc()
{
    cGC = define_class(intern("GC"), cObject);

    define_singleton_method(cGC, intern("run"), gc_s_run, 0);

    gc_never_free(get_variable(intern("ARGV")));
    gc_never_free(get_variable(intern("stdin")));
    gc_never_free(get_variable(intern("stdout")));
    gc_never_free(get_variable(intern("stderr")));
}
Beispiel #3
0
VALUE
kernel_puts_thunk(VALUE recv, int argc, VALUE *argv)
{
	VALUE self = get_variable(intern("stdout"));

	return file_puts_thunk(self, argc, argv);
}
char *minibuf_read_variable_name(char *msg)
{
	char *ms;
	historyp hp;

	hp = make_variable_history();

	for (;;) {
		ms = minibuf_read_history(msg, "", hp);

		if (ms == NULL) {
			free_history(hp);
			cancel();
			return NULL;
		}

		if (ms[0] == '\0') {
			free_history(hp);
			minibuf_error("No variable name given");
			return NULL;
		} else if (get_variable(ms) == NULL) {
			minibuf_error("Undefined variable name");
			waitkey(2 * 1000);
		} else {
			minibuf_clear();
			break;
		}
	}

	free_history(hp);

	return ms;
}
Beispiel #5
0
void LedController::cmd_load_reg_mav() {
  uint8_t register_number = program[pc++]; 
  uint8_t  mav_variable = program[pc++];
  if(register_number < MAX_REGISTERS) {
    registers[register_number] = get_variable(mav_variable);
  }
}
Beispiel #6
0
void parse_provides (char * id, char * version, char * package, int line)
{
    char * p;
    char real_version[128];
    char internal_id[128];

    mangle_version (real_version, sizeof(real_version), version, package);
    strcpy (internal_id, "provides_");
    strcat (internal_id, convert_to_upper (id));
    p = get_variable_package (internal_id);
    if (p)
    {
        char * q = get_variable_package (internal_id);
        if (strcmp (package, q))
        {
            fatal_exit ("Conflicting packages, package %s already"
                        " provides '%s' with version '%s'\n",
                        package, id, get_variable (internal_id));
        }
        return;
    }
    log_info (T_EXEC, "package %s provides %s version %s\n",
              package, id, version);
    var_add_weak_declaration (package, internal_id, real_version, version,
                              TYPE_NUMERIC, package, line,
                              T_EXEC);
    mark_var_generated (internal_id);
    mark_var_provide (internal_id);

    package_provider_added = 1;
}
Beispiel #7
0
char *minibuf_read_variable_name(char *msg)
{
  char *ms;
  Completion *cp = completion_new(FALSE);
  le *lp;

  for (lp = mainVarList; lp != NULL; lp = lp->list_next)
    list_append(cp->completions, zstrdup(lp->data));

  for (;;) {
    ms = minibuf_read_completion(msg, "", cp, NULL);

    if (ms == NULL) {
      free_completion(cp);
      cancel();
      return NULL;
    }

    if (ms[0] == '\0') {
      free_completion(cp);
      minibuf_error("No variable name given");
      return NULL;
    } else if (get_variable(ms) == NULL) {
      minibuf_error("Undefined variable name `%s'", ms);
      waitkey(WAITKEY_DEFAULT);
    } else {
      minibuf_clear();
      break;
    }
  }

  free_completion(cp);

  return ms;
}
Beispiel #8
0
	radc_var * radc_compiler::decl_variable(const char * name, radc_enum type, bool is_static)
	{
		if (get_variable(name) == NULL)
		{
			radc_var * v = new radc_var(name);

			switch (type)
			{
			case radc_enum::type_real:
				v->setReal(0);
				break;

			case radc_enum::type_string:
				v->setString("");
				break;

			case radc_enum::type_ptr:
				v->setPtr(NULL);
				break;
			}

			if (is_static)
			{
				global_varlist.PushBack(v);
			}
			else
			{
				varlist.PushBack(v);
			}

			return v;
		}

		return 0;
	}
Beispiel #9
0
/* some UEFI machines have a buggy implementation
 * see if we can tip the system into Setup Mode */
static EFI_STATUS
change_setup_mode(int user_mode)
{
	static UINT8 *data = NULL;
	static UINTN len = 0;
	EFI_STATUS status;

	if (user_mode) {
		if (!data)
			/* can only do this if we previously reset to setup */
			return EFI_INVALID_PARAMETER;

		status = SetSecureVariable(L"PK", data, len, GV_GUID, 0, 0);	

		if (status == EFI_SUCCESS) {
			data = NULL;
			len = 0;
		}
		return status;
		
	} else {
		status = get_variable(L"PK", &data, &len, GV_GUID);
		if (status != EFI_SUCCESS)
			return status;
		/* try to update it to nothing */
		return SetSecureVariable(L"PK", data, 0, GV_GUID, 0, 0);	
	}

}
Beispiel #10
0
/// Evaluates a expression using these templates.
///
/// An expression is a query on the current templates to fetch a particular
/// value.  The value is always returned as a string, as this is how templates
/// are internally stored.
///
/// \param expression The expression to evaluate.  This should not include any
///     of the delimiters used in the user input, as otherwise the expression
///     will not be evaluated properly.
///
/// \return The result of the expression evaluation as a string.
///
/// \throw text::syntax_error If there is any problem while evaluating the
///     expression.
std::string
text::templates_def::evaluate(const std::string& expression) const
{
    const std::string::size_type paren_open = expression.find('(');
    if (paren_open == std::string::npos) {
        return get_variable(expression);
    } else {
        const std::string::size_type paren_close = expression.find(
            ')', paren_open);
        if (paren_close == std::string::npos)
            throw text::syntax_error(F("Expected ')' in expression '%s')") %
                                     expression);
        if (paren_close != expression.length() - 1)
            throw text::syntax_error(F("Unexpected text found after ')' in "
                                       "expression '%s'") % expression);

        const std::string arg0 = expression.substr(0, paren_open);
        const std::string arg1 = expression.substr(
            paren_open + 1, paren_close - paren_open - 1);
        if (arg0 == "defined") {
            return exists(arg1) ? "true" : "false";
        } else if (arg0 == "length") {
            return F("%s") % get_vector(arg1).size();
        } else {
            return get_vector(arg0, arg1);
        }
    }
}
Beispiel #11
0
bool evaluate_variable(const object& variable_name)
{
    object result;

//    std::cout << "GET VARIABLE" << std::endl;
    if(get_variable(variable_name.data.variable, &result) == OK)
    {
//        std::cout << "GET VARIABLE" << std::endl;

        // Auto call zero argument functions when they are found.
        if(result.type == FUNCTION)
        {
            if(result.data.function->arguments.size() == 1)
            {
                object arguments; // empty, won't be used by call_function so no need to initialize
                call_function(result, result, arguments);
            }
        }

        optic_stack.push_back(result); // result is already a copy, no need to copy again
        return true;
    }

    else
    {
        out() << "Variable " << reverse_variable_name_lookup[variable_name.data.variable] << " not found." << std::endl;
        clear_stack();
        return false;
    }
}
Beispiel #12
0
// Get random var for sub calculations
expr_val * get_new_var(expr_type type, scope * scope, str_list * lines) {
	// Ctreating var name
	int size = sizeof(char)*(int)log10(var_num) + 4;
	char * var = (char *) malloc(size);
	sprintf(var, "_v%d", var_num++);
	return get_variable(var, type, scope, lines);
}
Beispiel #13
0
static int get_variables(SEXP variables,
			 struct design *s, struct design *r, struct design2 *d,
			 struct variables *v)
{
	SEXP var;
	int i, n;
	int err = 0;

	if (!IS_VECTOR(variables))
		DOMAIN_ERROR("'variables' should be a list");

	n = LENGTH(variables);

	v->count = (size_t)n;
	v->item = (void *)R_alloc(n, sizeof(*v->item));
	for (i = 0; i < n; i++) {
		var = VECTOR_ELT(variables, i);

		err = get_variable(var, s, r, d, &v->item[i]);
		if (err < 0)
			goto out;
	}
out:
	return err;
}
Beispiel #14
0
expr_val * compile_type_assignment(binary_op_node * node, scope * scope, str_list * lines) {
	expr_val * type = compile_statement(node->right, scope, lines);

	// Convert to id
	id_node * left_id = (id_node *) node->left; 
	expr_val * name = get_variable(left_id->val, type->type, scope, lines);
	return name;
}
Beispiel #15
0
int
http_get_query_variable(http_request_t* request, const char *name, char* output, uint16_t output_size)
{
    if (request->query) {
        return get_variable(name, request->query, request->query_len, output, output_size, 0);
    }

    return 0;
}
Beispiel #16
0
int
http_get_post_variable(http_request_t* request, const char *name, char* output, uint16_t output_size)
{
    if (request->payload) {
        return get_variable(name, request->payload, request->payload_len, output, output_size, 1);
    }

    return 0;
}
Beispiel #17
0
VALUE
kernel_write(VALUE recv, VALUE arg)
{
	VALUE out;

	out = get_variable(intern("stdout"));

	return toi_funcall(out, intern("write"), 1, arg);
}
Beispiel #18
0
int lookup_bool_variable(char *var)
{
  char *p;

  if ((p = get_variable(var)) != NULL)
    return strcmp(p, "nil") != 0;

  return FALSE;
}
Beispiel #19
0
void PageTemplate::yield_if(const ArgumentList& arguments, const ArrayArgument::Item* arrayItem, const TokenPtr& token, std::string& result) const
{
	const IfToken* iftoken = static_cast<const IfToken*>(token.get());
	const std::string& value = get_variable(arguments, arrayItem, iftoken->data);
	if (value.empty())
		yield_tokens(arguments, arrayItem, iftoken->if_false, result);
	else
		yield_tokens(arguments, arrayItem, iftoken->if_true, result);
}
Beispiel #20
0
void opcode_inc(void)
{
  int16_t value;
  
  TRACE_LOG("Opcode: INC.\n");
  value = (int16_t)get_variable(op[0], false);
  TRACE_LOG("Incrementing variable %d from %d to %d.\n", op[0], value, value+1);

  set_variable(op[0], (uint16_t)(value + 1), false);
}
void get_variable_value(const frontend::stache_model &model,
                        const std::string &key,
                        variable_sink &sink)
{
    auto ivar = model.find(key);
    if (ivar != model.end()) {
        detail::variable_getter_visitor get_variable(sink);
        boost::apply_visitor(get_variable, ivar->second);
    }
}
Beispiel #22
0
END_TEST

START_TEST(get_variable_test)
  {
  struct job test_job;
  char* variable = (char *)"variable";
  char* result = NULL;

  memset(&test_job, 0, sizeof(test_job));

  result = get_variable(NULL, variable);
  fail_unless(result == NULL, "NULL input job pointer fail");

  result = get_variable(&test_job, NULL);
  fail_unless(result == NULL, "NULL input variable string pointer fail");

  result = get_variable(&test_job, variable);
  fail_unless(result == NULL, "svr_setjobstate fail");

  }
Beispiel #23
0
void game_data::set_variable(const std::string& key, const t_string& value)
{
	try
	{
		get_variable(key) = value;
	}
	catch(const invalid_variablename_exception&)
	{
		ERR_NG << "variable " << key << "cannot be set to " << value << std::endl;
	}
}
Beispiel #24
0
void opcode_load(void)
{
  TRACE_LOG("Opcode: LOAD.\n");

  read_z_result_variable();
  
  TRACE_LOG("Loading variable with code %d to variable with code %d.\n",
      op[0], z_res_var);

  set_variable(z_res_var, get_variable(op[0], true), false);
}
Beispiel #25
0
float fuzzy_system::defuzzify_centroid(fuzzy_id const& id, std::size_t sample_count)
{
    KISMET_ASSERT(has_variable(id) && sample_count > 0);

    auto& var = get_variable(id);
    var.reset_dom();

    // run through all rules to calculate the consequent dom
    for_each(m_rules.begin(), m_rules.end(), [](fuzzy_rule& r) { r.calculate(); });

    return var.defuzzify_centroid(sample_count);
}
Beispiel #26
0
float fuzzy_system::defuzzify_mean_max(fuzzy_id const& id)
{
    KISMET_ASSERT(has_variable(id));

    auto& var = get_variable(id);
    var.reset_dom();

    // run through all rules to calculate the consequent dom
    for_each(m_rules.begin(), m_rules.end(), [](fuzzy_rule& r) { r.calculate(); });

    return var.defuzzify_mean_max();
}
int svr_authorize_jobreq(

  struct batch_request *preq,  /* I */
  job                  *pjob)  /* I */

  {
  char  owner[PBS_MAXUSER + 1];

  get_jobowner(pjob->ji_wattr[JOB_ATR_job_owner].at_val.at_str, owner);

  return svr_authorize_req(preq, owner, get_variable(pjob, pbs_o_host));
  }  /* END svr_authorize_jobreq() */
Beispiel #28
0
char *
parse_get_variable (char * name, char * package, int line)
{
    char * content;

    content = get_variable (convert_to_upper (name));
    if (!content)
    {
        fatal_exit ("unknown variable '%s' in %s, line %d\n",
                    name, package, line);
    }
    return content;
}
Beispiel #29
0
/*
 * Check whether we're in Secure Boot and user mode
 */
BOOLEAN secure_mode (VOID)
{
   EFI_STATUS status;
   EFI_GUID global_var = EFI_GLOBAL_VARIABLE;
   UINTN charsize = sizeof(char);
   UINT8 sb, setupmode;
   UINT32 attributes;

   status = get_variable(L"SecureBoot", global_var, &attributes, &charsize, (VOID *)&sb);

   /* FIXME - more paranoia here? */
   if (status != EFI_SUCCESS || sb != 1) {
      return FALSE;
   }

   status = get_variable(L"SetupMode", global_var, &attributes, &charsize, (VOID *)&setupmode);

   if (status == EFI_SUCCESS && setupmode == 1) {
      return FALSE;
   }

   return TRUE;
} // secure_mode()
Beispiel #30
0
EFI_STATUS
find_in_variable_esl(CHAR16* var, EFI_GUID owner, UINT8 *key, UINTN keylen)
{
	UINTN DataSize;
	UINT8 *Data;
	EFI_STATUS status;

	status = get_variable(var, &Data, &DataSize, owner);
	if (status != EFI_SUCCESS)
		return status;

	status = find_in_esl(Data, DataSize, key, keylen);

	FreePool(Data);

	return status;
}