Пример #1
0
void exec_sle(){
    char* s1;
    char* s2;
    s1 = pop_string();
    s2 = pop_string();
    push_bool(strcmp(s2,s1)<=0);
}
Пример #2
0
/* Prints the stack in the inverse order */
void print_inverse_order(StringStack *stack)
{
	StringStack *aux = initialize_string_stack();
	while (stack->size > 0)
		push_string(aux,pop_string(stack));
	while (aux->size > 0)
	{
		printf("%stack",top_string(aux));	
		push_string(stack,pop_string(aux));
	}
}
Пример #3
0
void MsgBase::UnpackMsg(MsgInfo &msgInfo)
{
	msgInfo.msgType = m_pNetMsgBody->msgType;

	uint16_t mapSize= pop_u16() ;

	for(uint16_t i=0;i<mapSize;i++)
	{
		string sKey = pop_string();
		string sValue = pop_string();
		msgInfo.info.insert(make_pair(sKey,sValue));
	}

}
Пример #4
0
void rpn_csh_str()
{
    char *string;
    void dummy_sigusr1();
    signal(SIGUSR1, dummy_sigusr1);

    if (!fp) {
        /* open a pipe and start csh */
#if defined(vxWorks)
      fprintf(stderr, "popen is not supported in vxWorks\n");
      exit(1);
#else
      fp = popen("csh", "w");
      pid = getpid();
#endif
    }
    if (!(string = pop_string()))
        return;

    fprintf(fp, "%s\nkill -USR1 %d\n", string, pid);
    fflush(fp);
    /* pause until SIGUSR1 is received */
    sigpause(SIGUSR1);

    /* back to default behavior for sigusr1 */
    signal(SIGUSR1, SIG_DFL);
    }
Пример #5
0
void init_commands (void) {
    GHashTable* _tmp0_;
    GHashTable* _tmp1_;
    g_return_if_fail (commands_table == NULL);
    commands_table = (_tmp0_ = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL), _g_hash_table_unref0 (commands_table), _tmp0_);
    command_descriptions_table = (_tmp1_ = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free), _g_hash_table_unref0 (command_descriptions_table), _tmp1_);
    {
        gint i;
        i = 0;
        {
            gboolean _tmp2_;
            _tmp2_ = TRUE;
            while (TRUE) {
                char* description;
                char* name;
                if (!_tmp2_) {
                    i++;
                }
                _tmp2_ = FALSE;
                if (!(commands[i].description != NULL)) {
                    break;
                }
                description = g_strdup (commands[i].description);
                name = pop_string (&description);
                g_hash_table_insert (commands_table, g_strdup (name), commands[i].function);
                g_hash_table_insert (command_descriptions_table, g_strdup (name), g_strdup (description));
                _g_free0 (name);
                _g_free0 (description);
            }
        }
    }
}
Пример #6
0
static void
eval_tos(void)
{
	char *p;

	p = pop_string();
	if (p != NULL)
		eval_string(p);
}
Пример #7
0
static void
eval_tos(void)
{
	char *p;

	p = pop_string();
	if (p == NULL)
		return;
	eval_string(p);
}
Пример #8
0
/*
** 'get_name' evaluates an expression that returns a string (normally
** a file name). It returns a pointer to that string as a null-terminated
** C string. If this string has to be kept, a copy of has to be made
*/
static char *get_name(void) {
  stackitem topitem;
  basicstring descriptor;
  char *cp;
  expression();
  topitem = get_topitem();
  if (topitem != STACK_STRING && topitem != STACK_STRTEMP) error(ERR_TYPESTR);
  descriptor = pop_string();
  cp = tocstring(descriptor.stringaddr, descriptor.stringlen);
  if (topitem == STACK_STRTEMP) free_string(descriptor);
  return cp;
}
Пример #9
0
Файл: q3_2.c Проект: vdloo/SICP
int main(void) {
    int i;
    char c;
    printf("Verifying stack can store data\n");
    assert_store_data(push, pop);
    printf("Asserting min char in string is newline\n");
    push_string(push);
    assert(min() == '\n');
    pop_string(pop);
    push('z');
    printf("Asserting min char on 1 elem stack is correct\n");
    assert(min() == 'z');
    return 0;
}
Пример #10
0
/*!	\brief Adds a jcache_entry to a jamfile_cache.
	\param cache The jamfile_cache.
	\param entry The jcache_entry to be added.
	\return \c !0, if everything went fine, 0, if an error occured (out of
			memory).
*/
static
int
add_jcache_entry(jamfile_cache* cache, jcache_entry* entry)
{
	int result = 0;
	if (cache && entry) {
		result = push_string(cache->filenames, entry->filename);
		if (result) {
			result = hashenter(cache->entries, (HASHDATA**)&entry);
			if (!result)
				pop_string(cache->filenames);
		}
	}
	return result;
}
Пример #11
0
/*
** 'discard' removes an item from the Basic stack, carrying out any
** work needed to undo the effects of that item
*/
static void discard(stackitem item) {
  basicstring temp;
#ifdef DEBUG
  if (basicvars.debug_flags.stack) fprintf(stderr, "Drop '%s' entry at %p\n",
   entryname(item), basicvars.stacktop.bytesp);
#endif
  switch(item) {
  case STACK_STRTEMP:
    temp = pop_string();
    free_string(temp);
    break;
  case STACK_LOCAL: 	/* Restore local variable to its old value */
    restore(1);
    break;
  case STACK_RETPARM:	/* Deal with a 'return' parameter and restore local parameter */
    restore_retparm(1);
    break;
  case STACK_GOSUB:	/* Clear 'GOSUB' block from stack */
    (void) pop_gosub();
    break;
  case STACK_PROC:	/* Clear 'PROC' block */
    (void) pop_proc();
    break;
  case STACK_FN:	/* Clear 'FN' block */
    (void) pop_fn();
    break;
  case STACK_ERROR:	/* Restore old Basic error handler */
    basicvars.error_handler = pop_error();
    break;
  case STACK_DATA:	/* Restore old Basic data pointer */
    basicvars.datacur = pop_data();
    break;
  case STACK_LOCARRAY:	/* Local numeric array */
    basicvars.stacktop.bytesp+=entrysize[STACK_LOCARRAY]+basicvars.stacktop.locarraysp->arraysize;
    break;
  case STACK_LOCSTRING:	/* Local string array */
    discard_strings(basicvars.stacktop.bytesp+entrysize[STACK_LOCARRAY], basicvars.stacktop.locarraysp->arraysize);
    basicvars.stacktop.bytesp+=entrysize[STACK_LOCARRAY]+basicvars.stacktop.locarraysp->arraysize;
    break;
  default:
    if (item==STACK_UNKNOWN || item>=STACK_HIGHEST) error(ERR_BROKEN, __LINE__, "stack");
    basicvars.stacktop.bytesp+=entrysize[item];
  }
}
Пример #12
0
void rpn_execn()
{
#if !defined(vxWorks)
    char *ptr;
    char buffer[1024];
    FILE *fp;
    double value;
#endif
    char *string;

    if (!(string = pop_string()))
        return;

#if defined(vxWorks)
    fprintf(stderr, "popen is not supported in vxWorks\n");
    exit(1);
#else
    if (!(fp = popen(string, "r"))) {
      fprintf(stderr, "error: invalid command: %s\n", string);
      stop();
      return;
    }
    if (feof(fp)) {
      fprintf(stderr, "error: command %s returns EOF\n", string);
      stop();
      return;
    }
    if (fgets(buffer, 1024, fp) == NULL) {
      fprintf(stderr, "error: command %s returns NULL\n", string);
      stop();
      return;
    }
    do {
      while ((ptr=get_token(buffer))) {
        if (sscanf(ptr, "%le", &value)==1)
          push_num(value);
        else
          push_string(ptr);
      }
    } while (fgets(buffer, 1024, fp));
#endif

  }
Пример #13
0
void rpn_execs()
{
    char *string;
#if !defined(vxWorks)
    char buffer[1024];
    FILE *fp;
#endif

    if (!(string = pop_string()))
        return;

#if defined(vxWorks)
    fprintf(stderr, "popen is not supported in vxWorks\n");
    exit(1);
#else
    if (!(fp = popen(string, "r"))) {
      fprintf(stderr, "error: invalid command: %s\n", string);
      stop();
      return;
    }
    if (feof(fp)) {
      fprintf(stderr, "error: command %s returns EOF\n", string);
      stop();
      return;
    }
    if (!fgets(buffer, 1024, fp)) {
      fprintf(stderr, "error: command %s returns NULL\n", string);
      stop();
      return;
    }
    do {
      chop_nl(buffer);
      push_string(buffer);
    } while (fgets(buffer, 1024, fp));
#endif

  }
Пример #14
0
/* Prints the stack in the correct order */
void print_correct_order(StringStack *stack)
{
	while (stack->size > 0)
		printf("%stack",pop_string(stack));	
}
Пример #15
0
void event_acceuil(game_state* state)
{

    SDL_Event event;

  SDL_WaitEvent(&event);
  switch(event.type)
    {
    case SDL_QUIT:
      state->continuer = 0;

      break;
    case SDL_KEYDOWN:
      switch (event.key.keysym.sym)
	{
	case SDLK_ESCAPE: 
	  state->continuer = 0;
	  break;
	  
	  APPENDER(a);
	  APPENDER(b);
	  APPENDER(c);
	  APPENDER(d);
	  APPENDER(e);
	  APPENDER(f);
	  APPENDER(g);
	  APPENDER(h);
	  APPENDER(i);
	  APPENDER(j);
	  APPENDER(k);
	  APPENDER(l);
	  APPENDER(m);
	  APPENDER(n);
	  APPENDER(o);
	  APPENDER(p);
	  APPENDER(q);
	  APPENDER(r);
	  APPENDER(s);
	  APPENDER(t);
	  APPENDER(u);
	  APPENDER(v);
	  APPENDER(w);
	  APPENDER(x);
	  APPENDER(y);
	  APPENDER(z);
	  
	case SDLK_BACKSPACE: 
	  pop_string(&(state->common_data->name)); 
	  break;
	  
	case SDLK_RETURN:
	    state->next=menu;
	    break;

	default:
	  break;
	}
      break;
    default:
      break;

    }
}
Пример #16
0
gboolean command_set (const char* line) {
    gboolean result = FALSE;
    char* args;
    char* element_name;
    char* property_name;
    char* value_string;
    GstElement* element;
    GParamSpec* property;
    GType property_type;
    GValue property_value = {0};
    g_return_val_if_fail (line != NULL, FALSE);
    args = g_strdup (line);
    if (args == NULL) {
        g_printerr ("No element given\n");
        result = FALSE;
        _g_free0 (args);
        return result;
    }
    element_name = pop_string (&args);
    if (args == NULL) {
        g_printerr ("No property given\n");
        result = FALSE;
        _g_free0 (element_name);
        _g_free0 (args);
        return result;
    }
    property_name = pop_string (&args);
    if (args == NULL) {
        g_printerr ("No value given\n");
        result = FALSE;
        _g_free0 (property_name);
        _g_free0 (element_name);
        _g_free0 (args);
        return result;
    }
    value_string = pop_string (&args);
    element = gst_bin_get_by_name (pipeline, element_name);
    if (element == NULL) {
        g_printerr ("No element named '%s'\n", element_name);
        result = FALSE;
        _gst_object_unref0 (element);
        _g_free0 (value_string);
        _g_free0 (property_name);
        _g_free0 (element_name);
        _g_free0 (args);
        return result;
    }
    property = g_object_class_find_property (G_OBJECT_GET_CLASS ((GObject*) element), property_name);
    if (property == NULL) {
        g_printerr ("No property named '%s'\n", property_name);
        result = FALSE;
        _gst_object_unref0 (element);
        _g_free0 (value_string);
        _g_free0 (property_name);
        _g_free0 (element_name);
        _g_free0 (args);
        return result;
    }
    property_type = property->value_type;
    g_value_init (&property_value, property_type);
    if (gst_value_deserialize (&property_value, value_string)) {
        g_object_set_property ((GObject*) element, property_name, &property_value);
        result = TRUE;
        _gst_object_unref0 (element);
        _g_free0 (value_string);
        _g_free0 (property_name);
        _g_free0 (element_name);
        _g_free0 (args);
        return result;
    } else {
        g_printerr ("Could not transform value %s to type %s\n", value_string, g_type_name (property_type));
        result = FALSE;
        _gst_object_unref0 (element);
        _g_free0 (value_string);
        _g_free0 (property_name);
        _g_free0 (element_name);
        _g_free0 (args);
        return result;
    }
    _gst_object_unref0 (element);
    _g_free0 (value_string);
    _g_free0 (property_name);
    _g_free0 (element_name);
    _g_free0 (args);
}
Пример #17
0
 std::string operator()(cell_ptr& l) {
     return pop_string(l);
 }