Beispiel #1
0
int dump_dives(program_options_t *options) {
    dc_family_t backend = DC_FAMILY_NULL;
    dc_loglevel_t loglevel = DC_LOGLEVEL_WARNING;
    const char *logfile = "output.log";
    const char *name = NULL;
    const char *fingerprint = NULL;
    unsigned int model = 0;

    if (options->backend != NULL) {
        backend = lookup_type(options->backend);
    }
    signal (SIGINT, sighandler);

    message_set_logfile(logfile);

    dc_context_t *context = NULL;

    /* create a new context */
    dc_status_t rc = dc_context_new(&context);
    if (rc != DC_STATUS_SUCCESS) {
        message_set_logfile(NULL);
        return EXIT_FAILURE;
    }

    dc_context_set_loglevel(context, loglevel);
    dc_context_set_logfunc(context, logfunc, NULL);

    dc_descriptor_t *descriptor = NULL;
    rc = search(&descriptor, name, backend, model);
    if (rc != DC_STATUS_SUCCESS) {
        message_set_logfile(NULL);
        return EXIT_FAILURE;
    }

    /* fail if no device descriptor found */
    if (descriptor == NULL) {
        WARNING("No matching device found");
        /* FIXME: bail out to usage information */
        message_set_logfile(NULL);
        return EXIT_FAILURE;
    }

    dc_buffer_t *fp = fpconvert(fingerprint);
    rc = dowork(context, descriptor, options, fp);
    dc_buffer_free(fp);
    /* FIXME: why aren't calls to errmsg working? */
    // message("Result: %s\n", errmsg(rc));

    dc_descriptor_free(descriptor);
    dc_context_free(context);

    message_set_logfile(NULL);

    return rc != DC_STATUS_SUCCESS ? EXIT_FAILURE : EXIT_SUCCESS;
}
Beispiel #2
0
 inline constexpr const char *c_str() const { return lookup_type(value, names, length); }
Beispiel #3
0
 static constexpr inline const char *lookup_type(Type e, EnumValue<Type> const * const list, size_t r) {
     return r == 0 ? "" : list->value == e ? list->name : lookup_type(e, list + 1, r - 1);
 }
Beispiel #4
0
yylex(){
int nstr; extern int yyprevious;
#ifdef __cplusplus
/* to avoid CC and lint complaining yyfussy not being used ...*/
static int __lex_hack = 0;
if (__lex_hack) goto yyfussy;
#endif
while((nstr = yylook()) >= 0)
yyfussy: switch(nstr){
case 0:
if(yywrap()) return(0); break;
case 1:

# line 10 "parse.lex"
	return (INCLUDE);
break;
case 2:

# line 11 "parse.lex"
	return (INPUT);
break;
case 3:

# line 12 "parse.lex"
	return (CLEAR);
break;
case 4:

# line 13 "parse.lex"
	return (LAYOUT);
break;
case 5:

# line 14 "parse.lex"
	return (MENU);
break;
case 6:

# line 15 "parse.lex"
return (KEYBOARD);
break;
case 7:

# line 16 "parse.lex"
return (TRANSLATION);
break;
case 8:

# line 17 "parse.lex"
return (FUNCTION);
break;
case 9:

# line 18 "parse.lex"
	return (VARIABLE);
break;
case 10:

# line 19 "parse.lex"
	return (IF);
break;
case 11:

# line 20 "parse.lex"
	return (ELSEIF);
break;
case 12:

# line 21 "parse.lex"
	return (ELSE);
break;
case 13:

# line 22 "parse.lex"
	return (FI);
break;
case 14:

# line 23 "parse.lex"
	return (DO);
break;
case 15:

# line 24 "parse.lex"
	return (ELSEDO);
break;
case 16:

# line 25 "parse.lex"
	return (OD);
break;
case 17:

# line 26 "parse.lex"
	return (OPTIONS);
break;
case 18:

# line 27 "parse.lex"
	return (PIN);
break;
case 19:

# line 28 "parse.lex"
return (LEFTRIGHT);
break;
case 20:

# line 29 "parse.lex"
return (RIGHTLEFT);
break;
case 21:

# line 30 "parse.lex"
return (SEPARATOR);
break;
case 22:

# line 31 "parse.lex"
	return (TITLE);
break;
case 23:

# line 32 "parse.lex"
	return (DEFAULT);
break;
case 24:

# line 33 "parse.lex"
	return (BUTTON);
break;
case 25:

# line 34 "parse.lex"
	return (IMAGE);
break;
case 26:

# line 35 "parse.lex"
return (SCROLLBAR);
break;
case 27:

# line 36 "parse.lex"
	return (LEFT);
break;
case 28:

# line 37 "parse.lex"
	return (RIGHT);
break;
case 29:

# line 38 "parse.lex"
	return (BOTTOM);
break;
case 30:

# line 39 "parse.lex"
	return (TOP);
break;
case 31:

# line 40 "parse.lex"
return (GEOMETRY);
break;
case 32:

# line 41 "parse.lex"
	return (TYPE);
break;
case 33:

# line 42 "parse.lex"
	return (EDIT);
break;
case 34:

# line 43 "parse.lex"
	return (COMMENT);
break;
case 35:

# line 44 "parse.lex"
	return (PROGRAM);
break;
case 36:

# line 45 "parse.lex"
	return (CONSOLE);
break;
case 37:

# line 46 "parse.lex"
	return (BUFFER);
break;
case 38:

# line 47 "parse.lex"
	return (SYMBOL);
break;
case 39:

# line 48 "parse.lex"
	return (STENCIL);
break;
case 40:

# line 49 "parse.lex"
	return (DEFINE);
break;
case 41:

# line 50 "parse.lex"
return (FINDREPLACE);
break;
case 42:

# line 51 "parse.lex"
	return (ALL);
break;
case 43:

# line 52 "parse.lex"
	return (SHELL);
break;
case 44:

# line 53 "parse.lex"
return (FILESELECT);
break;
case 45:

# line 54 "parse.lex"
	return (REMARK);
break;
case 46:

# line 55 "parse.lex"
	return (NOTEQUAL);
break;
case 47:

# line 56 "parse.lex"
	return (LESSEQUAL);
break;
case 48:

# line 57 "parse.lex"
	return (GREATEREQUAL);
break;
case 49:

# line 58 "parse.lex"
	return (LOGICAND);
break;
case 50:

# line 59 "parse.lex"
	return (LOGICOR);
break;
case 51:

# line 60 "parse.lex"
	return (LOGICXOR);
break;
case 52:

# line 61 "parse.lex"
	return (ASSIGN);
break;
case 53:

# line 62 "parse.lex"
         return (RANGE);
break;
case 54:

# line 63 "parse.lex"
	return (MINUS);
break;
case 55:

# line 64 "parse.lex"
	return (ADD);
break;
case 56:

# line 65 "parse.lex"
	return (MULTIPLY);
break;
case 57:

# line 66 "parse.lex"
	return (DIVIDE);
break;
case 58:

# line 67 "parse.lex"
	return (REMAINDER);
break;
case 59:

# line 68 "parse.lex"
	return (LOGICNOT);
break;
case 60:

# line 69 "parse.lex"
	return (BITNOT);
break;
case 61:

# line 70 "parse.lex"
	return (LAZYREF);
break;
case 62:

# line 71 "parse.lex"
	return (EQUAL);
break;
case 63:

# line 72 "parse.lex"
	return (LESS);
break;
case 64:

# line 73 "parse.lex"
	return (GREATER);
break;
case 65:

# line 74 "parse.lex"
	return (BITOR);
break;
case 66:

# line 75 "parse.lex"
	return (BITAND);
break;
case 67:

# line 76 "parse.lex"
	return (BITXOR);
break;
case 68:

# line 77 "parse.lex"
       { yylval.ival=strtol(yytext,NULL,8); return (INTEGER); }
break;
case 69:

# line 78 "parse.lex"
{ yylval.ival=strtol(yytext,NULL,16); return (INTEGER); }
break;
case 70:

# line 79 "parse.lex"
        { yylval.ival=strtol(yytext,NULL,10); return (INTEGER); }
break;
case 71:

# line 80 "parse.lex"
case 72:

# line 81 "parse.lex"
case 73:

# line 82 "parse.lex"
   case 74:

# line 83 "parse.lex"
case 75:

# line 84 "parse.lex"
{ sscanf(yytext, "%lf", &yylval.rval); return (REAL); }
break;
case 76:

# line 85 "parse.lex"
	{ int i;
		for (i=yyleng-1; i>=0 && yytext[i]=='\\'; i--);
		if ((yyleng-i)%2) {
			char *conv;
			int i;
			Uchar *ucon,*slashconv;
			input();
                        conv=(char*) malloc((yyleng+1)*sizeof(char));
			for (i=0; i<yyleng-1;i++) {
			  conv[i]=yytext[i+1];
			}
			conv[i]=0;
			ucon=LocaletoUstr(conv);
			free(conv);
			slashconv = (Uchar*)malloc((yyleng+1)*sizeof(Uchar));
			convertslash(slashconv, ucon);
			yylval.utval=slashconv;
			return (STRING);
		} else {
			yymore();
		}
		}
break;
case 77:

# line 101 "parse.lex"
	{ int i;
		for (i=yyleng-1; i>=0 && yytext[i]=='\\'; i--);
		if ((yyleng-i)%2) {
			input();
			convertslashascii(yytext, yytext+1, yyleng-1);
			parse_key(yytext, &yylval.keyval.key,
					  &yylval.keyval.mode);
			return (KEY);
		} else {
			yymore();
		}
		}
break;
case 78:

# line 113 "parse.lex"
   case 79:

# line 114 "parse.lex"
case 80:

# line 115 "parse.lex"
{ Uchar b[40];
                  char bc[40];
                  int i;
                  for (i=0; i<yyleng-2 && i<39;i++) {
                     bc[i]=yytext[i+1];
                  }
                  bc[i]=0;
		  convertslash(b,LocaletoUstr(bc));
		  yylval.ival= b[0];
		  return (INTEGER);
           }
break;
case 81:

# line 120 "parse.lex"
{ Type t;
			  t = lookup_type(yytext);
			  if (t) {
			     yylval.ival=t;
			     return (TYPEVAL);
			  }
			  yylval.tval=ident_buffer[current_id++];
			  if (current_id==MAXIDENTIFIER) current_id=0;
                          strncpy(yylval.tval,yytext, IDENTLENGTH-1);
                          return (IDENTIFIER); }
break;
case 82:

# line 130 "parse.lex"
{ int i;
		  if (yytext[yyleng-1]=='*') {
		    input();
		  } else {
		    yymore();
		  }
		}
break;
case 83:

# line 137 "parse.lex"
	;
break;
case 84:

# line 138 "parse.lex"
	return yytext[0];
break;
case -1:
break;
default:
(void)fprintf(yyout,"bad switch yylook %d",nstr);
} return(0); }
Beispiel #5
0
//
// Everything inside of a ( ) resolves to a DependencyProperty, if there is a
// '.' after the property, we get the object, and continue resolving from there
// if there is a [n] after the property, we convert the property to a collection
// and grab the nth item.
//
// Dependency properties can be specified as (PropertyName) of the current object
// or they can be specified as (DependencyObject.PropertyName).
//
// Returns NULL on any error
//
DependencyProperty *
resolve_property_path (DependencyObject **o, PropertyPath *propertypath, GHashTable *promoted_values)
{
	g_return_val_if_fail (o != NULL, NULL);
	g_return_val_if_fail (propertypath != NULL, NULL);
	g_return_val_if_fail (propertypath->path != NULL || propertypath->property != NULL, NULL);
	
	if (propertypath->property)
		return propertypath->property;

	const char *path = propertypath->path;
	if (propertypath->expanded_path)
		path = propertypath->expanded_path;

	const char *inend = path + strlen (path);
	register const char *inptr = path;
	const char *start, *prop = path;
	bool expression_found = false;
	DependencyProperty *res = NULL;
	DependencyObject *lu = *o;
	Collection *collection;
	char *p, *name = NULL;
	Value *value = NULL;
	Type *type = NULL;
	int index;
	bool paren_open = false;
	bool tick_open = false;
	bool cloned = false;

	while (inptr < inend) {
		switch (*inptr++) {
		case '(':
			paren_open = true;
			break;
		case ')':
			paren_open = false;
			break;
		case '\'':
			// Ticks are only legal in expanded paths, so we should just fail here
			if (!propertypath->expanded_path) {
				g_warning ("The ' character is not legal in property paths.");
				break;
			}

			tick_open = !tick_open;
			break;
		case '.':
			if (tick_open)
				continue;

			// resolve the dependency property
			if (res) {
				DependencyObject *new_lu;

				// make sure that we are getting what we expect
				if (!(value = lu->GetValue (res)))
					goto error;

				if (!(new_lu = value->AsDependencyObject ()))
					goto error;

				if (!cloned && !g_hash_table_lookup (promoted_values, value) && !value->Is (lu->GetDeployment (), Type::UIELEMENT)) {
					// we need to clone the value here so that we deep copy any
					// DO subclasses (such as brushes, etc) that we're promoting
					// from a shared space (Styles, default values)
					Value *cloned_value = Value::Clone (value);
					
					DependencyObject *cloned_do = cloned_value->AsDependencyObject();
					if (cloned_do != NULL) {
						new_lu = cloned_do;
						lu->SetValue (res, cloned_value);
						delete cloned_value;
						
						cloned_value = lu->GetValue (res);
						g_hash_table_insert (promoted_values, cloned_value, cloned_value);
					}
				}

				lu = new_lu;
			}
			
			expression_found = false;
			prop = inptr;
			break;
		case '[':
			// Need to be a little more loving
			if (*inptr == '\0')
				break;
			
			index = strtol (inptr, &p, 10);
			if (*p != ']' || *(p + 1) != '.')
				break;
			
			inptr = p + 2;
			prop = inptr;

			if (expression_found) {
				expression_found = false;
				if (!(value = lu->GetValue (res)))
					goto error;
			}
			
			if (value == NULL)
				goto error;
			
			if (!(collection = value->AsCollection ()))
				goto error;

			if (!(value = collection->GetValueAt (index)))
				goto error;
			
			if (!(lu = value->AsDependencyObject ()))
				goto error;
			
			break;
		
		default:
			bool explicit_type = false;
			expression_found = true;
			start = inptr - 1;

			while (inptr < inend && (*inptr != '.' || tick_open) && (!paren_open || *inptr != ')') && *inptr != '[') {
				if (*inptr == '\'') {
					tick_open = !tick_open;
					if (!tick_open) {
						inptr++;
						break;
					}
				}
				inptr++;
			}

			if (inptr == start)
				goto error;

			if (*inptr == '.') {
				// we found a type name, now we need to find the property name
				if ((inptr - start) == 11 && !g_ascii_strncasecmp (start, "TextElement", 11)) {
					// Some Beta versions of Blend had a bug where they would save the TextBlock
					// properties as TextElement instead. Since Silverlight 1.0 works around this
					// bug, we should too. Fixes http://silverlight.timovil.com and
					// http://election.msn.com/podium08.aspx.
					type = Type::Find (lu->GetDeployment (), "TextBlock");
					explicit_type = true;
				} else {
					const char *s = inptr;
					if (*(inptr -1) == '\'' && !tick_open) {
						s = inptr - 1;
					}
					name = g_strndup (start, s - start);
					type = lookup_type (lu, name);
					explicit_type = true;
					if (!type)
						type = lu->GetType ();
					g_free (name);
				}
				
				inptr++;
				start = inptr;
				while (inptr < inend && (!paren_open || *inptr != ')') && (*inptr != '.' || tick_open)) {
					if (*inptr == '\'') {
						tick_open = !tick_open;
						if (!tick_open) {
							inptr++;
							break;
						}
					}
					inptr++;
				}
				
				if (inptr == start)
					goto error;
			} else {
				type = lu->GetType ();
				explicit_type = false;
			}
			
			if ((*inptr != ')' && paren_open) || !type)
				goto error;

			name = g_strndup (start, inptr - start);
			if (!(res = DependencyProperty::GetDependencyProperty (type, name)) && lu)
				res = DependencyProperty::GetDependencyProperty (lu->GetType (), name);

			if (!res) {
				g_free (name);
				goto error;
			}

			if (!res->IsAttached () && !lu->Is (type->GetKind ())) {
				// We try to be gracefull here and do something smart...
				if (!(res = DependencyProperty::GetDependencyProperty (lu->GetType (), name))) {
					g_free (name);
					goto error;
				}
			}
			
			if (res->IsAttached () && explicit_type && !paren_open)
				goto error;
			
			g_free (name);
			break;
		}
	}
	
	*o = lu;
	return res;
	
 error:
	*o = NULL;	
	return NULL;
}
Beispiel #6
0
int nvlist_get_cur_type(const rnode *r)
{
	const nvlist *l = &r->nv;
	return lookup_type(l->cur->name);
}