Example #1
0
int parsing(char **parameters,int ParaNum,struct parse_info *info)
{
    int i;
    parse_info_init(info);
    if(strcmp(parameters[ParaNum-1],"&") ==0)
    {
        info->flag |= BACKGROUND;
        parameters[ParaNum-1] = NULL;
        ParaNum--;
    }
    for(i=0;i<ParaNum;)
    {
        if(strcmp(parameters[i],"<<")==0 || strcmp(parameters[i],"<")==0)
        {
            info->flag |= IN_REDIRECT;
            info->in_file = parameters[i+1];
            parameters[i] = NULL;
            i+=2;
        }
        else if(strcmp(parameters[i],">>")==0 || strcmp(parameters[i],">")==0)
        {
            info->flag |= OUT_REDIRECT;
            info->out_file = parameters[i+1];
            parameters[i] = NULL;
            i+=2;
        }
        else if(strcmp(parameters[i],"|")==0)
        {
            char* pCh;
			info->flag |= IS_PIPED;
            parameters[i] = NULL;
            info->command2 = parameters[i+1];
            info->parameters2 = &parameters[i+1];
            for(pCh = info->parameters2[0]+strlen(info->parameters2[0]);
                    pCh!=&(info->parameters2[0][0]) && *pCh!='/';pCh--)
                ;
            if(*pCh == '/')
                pCh++;
            info->parameters2[0] = pCh;
            break;
        }
        else
            i++;
    }
#ifdef DEBUG
	printf("\nbackground:%s\n",info->flag&BACKGROUND?"yes":"no");
	printf("in redirect:");
	info->flag&IN_REDIRECT?printf("yes,file:%s\n",info->in_file):printf("no\n");
	printf("out redirect:");
	info->flag&OUT_REDIRECT?printf("yes,file:%s\n",info->out_file):printf("no\n");
	printf("pipe:");
	info->flag&IS_PIPED?printf("yes,command:%s %s %s\n",info->command2,info->parameters2[0],info->parameters2[1]):printf("no\n");
#endif
	return 1;
}
Example #2
0
File: strict.c Project: skaes/oj
VALUE
oj_strict_parse_cstr(int argc, VALUE *argv, char *json, size_t len) {
    struct _ParseInfo	pi;

    parse_info_init(&pi);
    pi.options = oj_default_options;
    pi.handler = Qnil;
    pi.err_class = Qnil;
    oj_set_strict_callbacks(&pi);

    return oj_pi_parse(argc, argv, &pi, json, len, true);
}
Example #3
0
File: strict.c Project: skaes/oj
VALUE
oj_strict_parse(int argc, VALUE *argv, VALUE self) {
    struct _ParseInfo	pi;

    parse_info_init(&pi);
    pi.options = oj_default_options;
    pi.handler = Qnil;
    pi.err_class = Qnil;
    oj_set_strict_callbacks(&pi);

    if (T_STRING == rb_type(*argv)) {
	return oj_pi_parse(argc, argv, &pi, 0, 0, true);
    } else {
	return oj_pi_sparse(argc, argv, &pi, 0);
    }
}
gboolean
gimp_text_buffer_deserialize (GtkTextBuffer *register_buffer,
                              GtkTextBuffer *content_buffer,
                              GtkTextIter   *iter,
                              const guint8  *text,
                              gsize          length,
                              gboolean       create_tags,
                              gpointer       user_data,
                              GError       **error)
{
  GMarkupParseContext *context;
  ParseInfo            info;
  gboolean             retval = FALSE;

  static const GMarkupParser markup_parser =
  {
    start_element_handler,
    end_element_handler,
    text_handler,
    NULL,
    NULL
  };

  parse_info_init (&info, register_buffer, content_buffer);

  context = g_markup_parse_context_new (&markup_parser, 0, &info, NULL);

  if (! g_markup_parse_context_parse (context,
                                      (const gchar *) text,
                                      length,
                                      error))
    goto out;

  if (! g_markup_parse_context_end_parse (context, error))
    goto out;

  retval = TRUE;

  insert_text (&info, iter);

 out:
  parse_info_free (&info);

  g_markup_parse_context_free (context);

  return retval;
}
Example #5
0
File: parse.c Project: shyrfxl/sish
//----------------------------------------------------------------------------------------------
int parsing( char **parameters, int arg_num, struct parse_info *info)
{
	int i = 0;
	parse_info_init(info);
	if(strcmp(parameters[arg_num-1],"&") == 0)
	{
		fprintf( stdout,"&&\n");
		info->flag |= BACKGROUND;
		parameters[arg_num-1] = NULL;
		arg_num--;
	}
	for( i = 0;i<arg_num;)
	{
		if(strcmp(parameters[i], "<<")== 0 || strcmp(parameters[i], "<") == 0)
		{
			info->flag |= IN_REDIRECT;
			info->in_file = parameters[i+1];
			parameters[i] = NULL;
			i+=2;
		}
		else if( strcmp(parameters[i], ">") == 0)
		{
			info->flag |= OUT_REDIRECT;
			info->out_file = parameters[i+1];
			parameters[i] = NULL;
			i+= 2;
		}
		else if( strcmp(parameters[i], ">>") == 0)
		{
			info->flag |= OUT_REDIRECT_APPEND;
			info->out_file = parameters[i+1];
			parameters[i] = NULL;
			i+= 2;
			fprintf(stdout,"11\n");
		}
		else if( strcmp(parameters[i], "|") == 0)
		{
			char * pch;
			info->flag |= IS_PIPED;
			parameters[i] = NULL;
			info->command2 = parameters[i+1];
			info->parameters2 = &parameters[i+1];
			for( pch = info->parameters2[0]+strlen(info->parameters2[0]);\
			pch!=&(info->parameters2[0][0]) && *pch != '/'; pch --);
			if(*pch == '/')
				pch++;
			info->parameters2[0] = pch;
			break;
			
		}
		else
			i++;
	
	}
/*	
	fprintf(stdout,"\nbackground:%s\n",info->flag&BACKGROUND?"yes":"no");
	fprintf(stdout,"in redirect:");
	info->flag&IN_REDIRECT?fprintf(stdout,"yes,file:%s\n",info->in_file):fprintf(stdout,"no\n");
	fprintf(stdout, "out redirect:");
	info->flag&OUT_REDIRECT?fprintf(stdout,"yes,file:%s\n",info->out_file):fprintf(stdout,"no\n");
	fprintf(stdout, "pipe:");
	info->flag&IS_PIPED?fprintf(stdout,"yes,command:%s %s %s\n",info->command2,info->parameters2[0],info->parameters2[1]):fprintf(stdout,"no\n");
*/	
	return 1;
}