예제 #1
0
파일: ccache.c 프로젝트: asankah/MKShim
static cc_int32 
context_open_ccache (cc_context_t  in_context,
		     const char   *in_name,
		     cc_ccache_t  *out_ccache)
{
    char *name;
    krb5_error_code ret;
    krb5_ccache id;

    if (out_ccache == NULL || in_name == NULL || in_context == NULL)
	return ccErrBadParam;

    asprintf(&name, "API:%s", in_name);

    ret = heim_krb5_cc_resolve(milcontext, name, &id);
    free(name);
    if (ret)
	return LOG_FAILURE(ret, "open cache");

    if (!check_exists(id)) {
	heim_krb5_cc_close(milcontext, id);
	return ccErrCCacheNotFound;
    }

    *out_ccache = create_ccache(id);

    return ccNoError;
}
예제 #2
0
파일: ccache.c 프로젝트: asankah/MKShim
static cc_int32
context_open_default_ccache(cc_context_t  in_context,
			    cc_ccache_t  *out_ccache)
{
    krb5_error_code ret;
    krb5_ccache id;

    LOG_ENTRY();

    if (out_ccache == NULL)
	return ccErrBadParam;

    ret = heim_krb5_cc_default(milcontext, &id);
    if (ret)
	return LOG_FAILURE(ret, "cc default");

    if (!check_exists(id)) {
	heim_krb5_cc_close(milcontext, id);
	return ccErrCCacheNotFound;
    }

    *out_ccache = create_ccache(id);

    return ccNoError;
}
예제 #3
0
파일: romsplit.c 프로젝트: ullman/romsplit
void merge_file(char* outfile,char* hirom_name, char* lorom_name)
{   
    FILE* out_rom;
    FILE* hirom;
    FILE* lorom;


    unsigned char buff[1];

    hirom = fopen(hirom_name,"rb");
    lorom = fopen(lorom_name,"rb");
    check_open(hirom,hirom_name);
    check_open(lorom,lorom_name);

    check_exists(outfile);
    out_rom = fopen(outfile,"wb");

    while(fread(buff,sizeof(buff),1,hirom)!=0)
    {
        fwrite(buff,sizeof(buff),1,out_rom);
        if(fread(buff,sizeof(buff),1,lorom)!=0)
        {
        fwrite(buff,sizeof(buff),1,out_rom);
        }
    }
 
    fclose(hirom);
    fclose(lorom);
    fclose(out_rom);
    printf("Files are merged into: %s\n",outfile);
    printf("hirom: %s\n",hirom_name);
    printf("lorom: %s\n",lorom_name);


}
예제 #4
0
/*
** COMMAND: test-missing
**
** Usage: %fossil test-missing
**
** Look at every artifact in the repository and verify that
** all references are satisfied.  Report any referenced artifacts
** that are missing or shunned.
**
** Options:
**
**    --notshunned          Do not report shunned artifacts
**    --quiet               Only show output if there are errors
*/
void test_missing(void){
  Stmt q;
  Blob content;
  int nErr = 0;
  int nArtifact = 0;
  int i;
  Manifest *p;
  unsigned flags = 0;
  int quietFlag;

  if( find_option("notshunned", 0, 0)!=0 ) flags |= MISSING_SHUNNED;
  quietFlag = find_option("quiet","q",0)!=0;
  db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
  db_prepare(&q,
     "SELECT mid FROM mlink UNION "
     "SELECT srcid FROM tagxref WHERE srcid>0 UNION "
     "SELECT rid FROM tagxref UNION "
     "SELECT rid FROM attachment JOIN blob ON src=uuid UNION "
     "SELECT objid FROM event");
  while( db_step(&q)==SQLITE_ROW ){
    int rid = db_column_int(&q, 0);
    content_get(rid, &content);
    p = manifest_parse(&content, rid, 0);
    if( p ){
      nArtifact++;
      nErr += check_exists(p->zBaseline, flags, p, "baseline of", 0);
      nErr += check_exists(p->zAttachSrc, flags, p, "file of", 0);
      for(i=0; i<p->nFile; i++){
        nErr += check_exists(p->aFile[i].zUuid, flags, p, "file of", 
                             p->aFile[i].zName);
      }
      for(i=0; i<p->nParent; i++){
        nErr += check_exists(p->azParent[i], flags, p, "parent of", 0);
      }
      for(i=0; i<p->nCherrypick; i++){
        nErr +=  check_exists(p->aCherrypick[i].zCPTarget+1, flags, p,
                              "cherry-pick target of", 0);
        nErr +=  check_exists(p->aCherrypick[i].zCPBase, flags, p,
                              "cherry-pick baseline of", 0);
      }
      for(i=0; i<p->nCChild; i++){
        nErr += check_exists(p->azCChild[i], flags, p, "in", 0);
      }
      for(i=0; i<p->nTag; i++){
        nErr += check_exists(p->aTag[i].zUuid, flags, p, "target of", 0);
      }
      manifest_destroy(p);      
    }
  }
  db_finalize(&q);
  if( nErr>0 || quietFlag==0 ){
    fossil_print("%d missing or shunned references in %d control artifacts\n",
                 nErr, nArtifact);
  }
}
예제 #5
0
void File::close(){
  if (!check_exists())
    return;

  if (_file != NULL)
    fclose(_file);

  _file = NULL;
  _dirp = NULL;
}
예제 #6
0
파일: romsplit.c 프로젝트: ullman/romsplit
void split_files(char* infile,char* hirom_name, char* lorom_name){
    FILE* read_rom;
    FILE* hirom;
    FILE* lorom;
    unsigned char buff[1];
    int split;

    read_rom = fopen(infile, "rb");
    check_open(read_rom,infile);

    check_exists(hirom_name);
    check_exists(lorom_name);

    hirom = fopen(hirom_name, "wb");
    lorom = fopen(lorom_name, "wb");

    split = 0;
    while(fread(buff,sizeof(buff),1,read_rom)!=0){

        if(split ==0)
        {
            fwrite(buff,sizeof(buff),1,hirom);
            split = 1;
        }
        else
        {
            fwrite(buff,sizeof(buff),1,lorom);
            split = 0;
        }
    }
    fclose(hirom);
    fclose(lorom);
    fclose(read_rom);
    printf("File %s is split into:\n",infile);
    printf("hirom: %s\n",hirom_name);
    printf("lorom: %s\n",lorom_name);

}
예제 #7
0
/* Check the semantics of any type of TEST */
static void
check_test(stnode_t *st_node)
{
	test_op_t		st_op;
	stnode_t		*st_arg1, *st_arg2;
#ifdef DEBUG_dfilter
	static guint i = 0;
#endif

	DebugLog(("  3 check_test(stnode_t *st_node = %p) [%u]\n", st_node, i));

	sttype_test_get(st_node, &st_op, &st_arg1, &st_arg2);

	switch (st_op) {
		case TEST_OP_UNINITIALIZED:
			g_assert_not_reached();
			break;

		case TEST_OP_EXISTS:
			check_exists(st_arg1);
			break;

		case TEST_OP_NOT:
			semcheck(st_arg1);
			break;

		case TEST_OP_AND:
		case TEST_OP_OR:
			semcheck(st_arg1);
			semcheck(st_arg2);
			break;

		case TEST_OP_EQ:
			check_relation("==", FALSE, ftype_can_eq, st_node, st_arg1, st_arg2);
			break;
		case TEST_OP_NE:
			check_relation("!=", FALSE, ftype_can_ne, st_node, st_arg1, st_arg2);
			break;
		case TEST_OP_GT:
			check_relation(">", FALSE, ftype_can_gt, st_node, st_arg1, st_arg2);
			break;
		case TEST_OP_GE:
			check_relation(">=", FALSE, ftype_can_ge, st_node, st_arg1, st_arg2);
			break;
		case TEST_OP_LT:
			check_relation("<", FALSE, ftype_can_lt, st_node, st_arg1, st_arg2);
			break;
		case TEST_OP_LE:
			check_relation("<=", FALSE, ftype_can_le, st_node, st_arg1, st_arg2);
			break;
		case TEST_OP_BITWISE_AND:
			check_relation("&", FALSE, ftype_can_bitwise_and, st_node, st_arg1, st_arg2);
			break;
		case TEST_OP_CONTAINS:
			check_relation("contains", TRUE, ftype_can_contains, st_node, st_arg1, st_arg2);
			break;
		case TEST_OP_MATCHES:
#ifdef HAVE_LIBPCRE
			check_relation("matches", TRUE, ftype_can_matches, st_node, st_arg1, st_arg2);
#else
			dfilter_fail("This Wireshark version does not support the \"matches\" operation.");
			THROW(TypeError);
#endif
			break;

		default:
			g_assert_not_reached();
	}
	DebugLog(("  3 check_test(stnode_t *st_node = %p) [%u] - End\n", st_node, i++));
}
예제 #8
0
/* Check the semantics of any type of TEST */
static void
check_test(stnode_t *st_node, GPtrArray *deprecated)
{
	test_op_t		st_op, st_arg_op;
	stnode_t		*st_arg1, *st_arg2;
#ifdef DEBUG_dfilter
	static guint i = 0;
#endif

	DebugLog(("  3 check_test(stnode_t *st_node = %p) [%u]\n", st_node, i));

	sttype_test_get(st_node, &st_op, &st_arg1, &st_arg2);

	switch (st_op) {
		case TEST_OP_UNINITIALIZED:
			g_assert_not_reached();
			break;

		case TEST_OP_EXISTS:
			check_exists(st_arg1);
			break;

		case TEST_OP_NOT:
			semcheck(st_arg1, deprecated);
			break;

		case TEST_OP_AND:
		case TEST_OP_OR:
			if (stnode_type_id(st_arg1) == STTYPE_TEST) {
				sttype_test_get(st_arg1, &st_arg_op, NULL, NULL);
				if (st_arg_op == TEST_OP_AND || st_arg_op == TEST_OP_OR) {
					if (st_op != st_arg_op && !st_arg1->inside_brackets)
						g_ptr_array_add(deprecated, g_strdup("suggest parentheses around '&&' within '||'"));
				}
			}

			if (stnode_type_id(st_arg2) == STTYPE_TEST) {
				sttype_test_get(st_arg2, &st_arg_op, NULL, NULL);
				if (st_arg_op == TEST_OP_AND || st_arg_op == TEST_OP_OR) {
					if (st_op != st_arg_op && !st_arg2->inside_brackets)
						g_ptr_array_add(deprecated, g_strdup("suggest parentheses around '&&' within '||'"));
				}
			}

			semcheck(st_arg1, deprecated);
			semcheck(st_arg2, deprecated);
			break;

		case TEST_OP_EQ:
			check_relation("==", FALSE, ftype_can_eq, st_node, st_arg1, st_arg2);
			break;
		case TEST_OP_NE:
			check_relation("!=", FALSE, ftype_can_ne, st_node, st_arg1, st_arg2);
			break;
		case TEST_OP_GT:
			check_relation(">", FALSE, ftype_can_gt, st_node, st_arg1, st_arg2);
			break;
		case TEST_OP_GE:
			check_relation(">=", FALSE, ftype_can_ge, st_node, st_arg1, st_arg2);
			break;
		case TEST_OP_LT:
			check_relation("<", FALSE, ftype_can_lt, st_node, st_arg1, st_arg2);
			break;
		case TEST_OP_LE:
			check_relation("<=", FALSE, ftype_can_le, st_node, st_arg1, st_arg2);
			break;
		case TEST_OP_BITWISE_AND:
			check_relation("&", FALSE, ftype_can_bitwise_and, st_node, st_arg1, st_arg2);
			break;
		case TEST_OP_CONTAINS:
			check_relation("contains", TRUE, ftype_can_contains, st_node, st_arg1, st_arg2);
			break;
		case TEST_OP_MATCHES:
			check_relation("matches", TRUE, ftype_can_matches, st_node, st_arg1, st_arg2);			break;

		default:
			g_assert_not_reached();
	}
	DebugLog(("  3 check_test(stnode_t *st_node = %p) [%u] - End\n", st_node, i++));
}