int main(int argc, char *argv[])
{
	int i;

	i = sc_test_init(&argc, argv);
	if (i < 0)
		return 1;
	printf("Looking for a PKCS#15 compatible Smart Card... ");
	fflush(stdout);
	sc_lock(card);
	i = sc_pkcs15_bind(card, &p15card);
	/* Keep card locked to prevent useless calls to sc_logout */
	if (i) {
		fprintf(stderr, "failed: %s\n", sc_strerror(i));
		return 1;
	}
	printf("found.\n");
	sc_test_print_card(p15card);

	dump_objects("PIN codes", SC_PKCS15_TYPE_AUTH_PIN);
	dump_objects("Private keys", SC_PKCS15_TYPE_PRKEY);
	dump_objects("Public keys", SC_PKCS15_TYPE_PUBKEY);
	dump_objects("X.509 certificates", SC_PKCS15_TYPE_CERT_X509);
	dump_objects("data objects", SC_PKCS15_TYPE_DATA_OBJECT);
	dump_unusedspace();

	sc_pkcs15_unbind(p15card);
	sc_unlock(card);
	sc_test_cleanup();
	return 0;
}
Beispiel #2
0
void dump_objects(tmx_object *o, int depth) {
	char padding[11]; mk_padding(padding, depth);

	printf("\n%s" "object={", padding);
	if (!o) {
		printf(" (NULL) }");
	} else {
		printf("\n%s\t" "name='%s'", padding, o->name);
		printf("\n%s\t" "shape=", padding);  print_shape(o->shape);
		printf("\n%s\t" "x=%f", padding, o->x);
		printf("\n%s\t" "y=%f", padding, o->y);
		printf("\n%s\t" "number of points='%d'", padding, o->points_len);
		printf("\n%s\t" "rotation=%f", padding, o->rotation);
		printf("\n%s\t" "visible=%s", padding, str_bool(o->visible));
		if (o->points_len) {
			printf("\n%s\t" "points=", padding);
			dump_points(o->points, o->points_len);
		}
		dump_prop(o->properties, depth+1);
		printf("\n%s}", padding);
	}

	if (o && o->next) {
		dump_objects(o->next, depth);
	}
}
Beispiel #3
0
void dump_layer(tmx_layer *l, unsigned int tc) {
	unsigned int i;
	printf("\nlayer={");
	if (!l) {
		printf(" (NULL) }");
	} else {
		printf("\n\t" "name='%s'", l->name);
		printf("\n\t" "visible=%s", str_bool(l->visible));
		printf("\n\t" "opacity='%f'", l->opacity);
		if (l->type == L_LAYER && l->content.gids) {
			printf("\n\t" "type=Layer" "\n\t" "tiles=");
			for (i=0; i<tc; i++) {
				printf("%d,", l->content.gids[i] & TMX_FLIP_BITS_REMOVAL);
			}
		} else if (l->type == L_OBJGR) {
			printf("\n\t" "color=#%.6X", l->content.objgr->color);
			printf("\n\t" "draworder="); print_draworder(l->content.objgr->draworder);
			printf("\n\t" "type=ObjectGroup");
			dump_objects(l->content.objgr->head, 1);
		} else if (l->type == L_IMAGE) {
			printf("\n\t" "x_offset=%d", l->x_offset);
			printf("\n\t" "y_offset=%d", l->y_offset);
			printf("\n\t" "type=ImageLayer");
			dump_image(l->content.image, 1);
		}
		dump_prop(l->properties, 1);
		printf("\n}");
	}

	if (l) {
		if (l->next) dump_layer(l->next, tc);
	}
}
Beispiel #4
0
void dump_tile(tmx_tile *t) {
	unsigned int i;
	printf("\n\t" "tile={");
	if (t) {
		printf("\n\t\t" "id=%u", t->id);
		dump_image(t->image, 2);
		dump_prop(t->properties, 2);
		dump_objects(t->collision, 2);

		if (t->animation) {
			printf("\n\t\t" "animation={");
			for (i=0; i<t->animation_len; i++) {
				printf("\n\t\t\t" "tile=%3d (%6dms)", t->animation[i].tile_id, t->animation[i].duration);
			}
			printf("\n\t\t}");
		}

		printf("\n\t}");
	} else {
		printf(" (NULL) }");
	}

	if (t && t->next) {
		dump_tile(t->next);
	}
}
Beispiel #5
0
void dump_layer(tmx_layer l, unsigned int tc) {
	unsigned int i;
	printf("layer={");
	if (!l) {
		fputs("\n(NULL)", stdout);
	} else {
		printf("\n\tname='%s'", l->name);
		printf("\n\tvisible='%d'", l->visible);
		printf("\n\topacity='%f'", l->opacity);
		if (l->type == L_LAYER && l->content.gids) {
			printf("\n\ttype=Layer\n\ttiles=");
			for (i=0; i<tc; i++)
				printf("%d,", l->content.gids[i] & TMX_FLIP_BITS_REMOVAL);
		} else if (l->type == L_OBJGR) {
			printf("\n\ttype=ObjectGroup");
		}
	}
	puts("\n}");

	if (l) {
		if (l->type == L_OBJGR && l->content.head) dump_objects(l->content.head);
		if (l->properties) dump_prop(l->properties);
		if (l->next) dump_layer(l->next, tc);
	}
}
Beispiel #6
0
static int open_pipes(void)
{
	open_pipe_pair(0);
	open_pipe_pair(O_NONBLOCK);
	open_pipe_pair(O_CLOEXEC);
	open_pipe_pair(O_NONBLOCK | O_CLOEXEC);

	dump_objects(OBJ_GLOBAL, OBJ_FD_PIPE);

	return TRUE;
}
Beispiel #7
0
void dump_objects(tmx_object o) {
	printf("object={");
	if (!o) {
		fputs("\n(NULL)", stdout);
	} else {
		printf("\n\tname='%s'", o->name);
		printf("\n\t x ='%d'", o->x);
		printf("\n\t y ='%d'", o->y);
		printf("\n\tnumber of points='%d'", o->points_len);
		if (o->points_len) dump_points(o->points, o->points_len);
	}
	puts("\n}");

	if (o)
		if (o->next) dump_objects(o->next);
}
void grpc_iomgr_shutdown(void) {
  grpc_iomgr_closure *closure;
  gpr_timespec shutdown_deadline = gpr_time_add(
      gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_seconds(10, GPR_TIMESPAN));
  gpr_timespec last_warning_time = gpr_now(GPR_CLOCK_REALTIME);

  gpr_mu_lock(&g_mu);
  g_shutdown = 1;
  while (g_cbs_head != NULL || g_root_object.next != &g_root_object) {
    if (gpr_time_cmp(
            gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), last_warning_time),
            gpr_time_from_seconds(1, GPR_TIMESPAN)) >= 0) {
      if (g_cbs_head != NULL && g_root_object.next != &g_root_object) {
        gpr_log(GPR_DEBUG,
                "Waiting for %d iomgr objects to be destroyed and executing "
                "final callbacks",
                count_objects());
      } else if (g_cbs_head != NULL) {
        gpr_log(GPR_DEBUG, "Executing final iomgr callbacks");
      } else {
        gpr_log(GPR_DEBUG, "Waiting for %d iomgr objects to be destroyed",
                count_objects());
      }
      last_warning_time = gpr_now(GPR_CLOCK_REALTIME);
    }
    if (g_cbs_head) {
      do {
        closure = g_cbs_head;
        g_cbs_head = closure->next;
        if (!g_cbs_head) g_cbs_tail = NULL;
        gpr_mu_unlock(&g_mu);

        closure->cb(closure->cb_arg, 0);
        gpr_mu_lock(&g_mu);
      } while (g_cbs_head);
      continue;
    }
    if (grpc_alarm_check(&g_mu, gpr_inf_future(GPR_CLOCK_MONOTONIC), NULL)) {
      continue;
    }
    if (g_root_object.next != &g_root_object) {
      int timeout = 0;
      while (g_cbs_head == NULL) {
        gpr_timespec short_deadline = gpr_time_add(
          gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_millis(100, GPR_TIMESPAN));
        if (gpr_cv_wait(&g_rcv, &g_mu, short_deadline) && g_cbs_head == NULL) {
          if (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), shutdown_deadline) > 0) {
            timeout = 1;
            break;
          }
        }
      }
      if (timeout) {
        gpr_log(GPR_DEBUG,
                "Failed to free %d iomgr objects before shutdown deadline: "
                "memory leaks are likely",
                count_objects());
        dump_objects("LEAKED");
        break;
      }
    }
  }
  gpr_mu_unlock(&g_mu);

  grpc_kick_poller();
  gpr_event_wait(&g_background_callback_executor_done,
                 gpr_inf_future(GPR_CLOCK_REALTIME));

  grpc_alarm_list_shutdown();

  grpc_iomgr_platform_shutdown();
  gpr_mu_destroy(&g_mu);
  gpr_cv_destroy(&g_rcv);
}
Beispiel #9
0
void grpc_iomgr_shutdown(void) {
  gpr_timespec shutdown_deadline = gpr_time_add(
      gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_seconds(10, GPR_TIMESPAN));
  gpr_timespec last_warning_time = gpr_now(GPR_CLOCK_REALTIME);
  grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;

  grpc_iomgr_platform_flush();

  gpr_mu_lock(&g_mu);
  g_shutdown = 1;
  while (g_root_object.next != &g_root_object) {
    if (gpr_time_cmp(
            gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), last_warning_time),
            gpr_time_from_seconds(1, GPR_TIMESPAN)) >= 0) {
      if (g_root_object.next != &g_root_object) {
        gpr_log(GPR_DEBUG, "Waiting for %d iomgr objects to be destroyed",
                count_objects());
      }
      last_warning_time = gpr_now(GPR_CLOCK_REALTIME);
    }
    if (grpc_timer_check(&exec_ctx, gpr_inf_future(GPR_CLOCK_MONOTONIC),
                         NULL)) {
      gpr_mu_unlock(&g_mu);
      grpc_exec_ctx_flush(&exec_ctx);
      gpr_mu_lock(&g_mu);
      continue;
    }
    if (g_root_object.next != &g_root_object) {
      gpr_timespec short_deadline = gpr_time_add(
          gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_millis(100, GPR_TIMESPAN));
      if (gpr_cv_wait(&g_rcv, &g_mu, short_deadline)) {
        if (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), shutdown_deadline) > 0) {
          if (g_root_object.next != &g_root_object) {
            gpr_log(GPR_DEBUG,
                    "Failed to free %d iomgr objects before shutdown deadline: "
                    "memory leaks are likely",
                    count_objects());
            dump_objects("LEAKED");
            if (grpc_iomgr_abort_on_leaks()) {
              abort();
            }
          }
          break;
        }
      }
    }
  }
  gpr_mu_unlock(&g_mu);

  grpc_timer_list_shutdown(&exec_ctx);
  grpc_exec_ctx_finish(&exec_ctx);

  /* ensure all threads have left g_mu */
  gpr_mu_lock(&g_mu);
  gpr_mu_unlock(&g_mu);

  grpc_pollset_global_shutdown();
  grpc_iomgr_platform_shutdown();
  grpc_exec_ctx_global_shutdown();
  gpr_mu_destroy(&g_mu);
  gpr_cv_destroy(&g_rcv);
}
Beispiel #10
0
void cvg_load ( char *fname, Boolean selflag, Boolean wrtflg, 
			Boolean plotflg, int layer, int icol, int *iret )
/************************************************************************
 * cvg_load								*
 *									*
 * This function loads data from a VGF formatted file and converts 	*
 * encountered records to a set of actions that display the feature	*
 * to an appropriate driver.  The parameter icol controls whether the	*
 * graphics will be plotted with the file-specified colors (icol=0)	*
 * or whether the VGF file will be plotted monochrome (icol=other).	*
 *									*
 * void cvg_load ( fname, selflag, wrtflg, plotflg, layer, icol, iret )	*
 *									*
 * Input parameters:							*
 *	*fname		char		Name of file to load		*
 *	selflag		Boolean		Are elements "selectable"	*
 *	wrtflg		Boolean		Write flag for file		*
 *	plotflg		Boolean		Display the elements or not	*
 *	layer		int		Layer the file contents will be	*
 *					   assigned to			*
 *	icol		int		Plot color			*
 *									*
 * Output parameters:							*
 *	*iret		int		Return code			*
 *					  1 = elms in file exceeded 	*
 *				              (MAX_EDITABLE_ELEMS)	*
 *					 -1 = error opening VG file	*
 *					 -2 = error closing VG file	*
 *					 -4 = error reading el hdr      *
 *					 -5 = VG file is empty		*
 **									*
 * Log:									*
 * E. Wehner/EAi	10/96	Created					*
 * D. Keiser/GSC	 1/97	Clean up				*
 * E. Wehner/EAi	 2/97	Added selection flag.			*
 * E. Wehner/EAi	 5/97	Add double tier loading 		*
 * E. Wehner/EAi	 5/97	Stop loading if > MAX_EDITABLE_ELEMS	*
 * E. Wehner/EAi	 5/97	Added refresh after displaying 		*
 * D. Keiser/GSC	 5/97	Change cvg_dsply to cds_dspvg		*
 * S. Jacobs/NCEP	 6/97	Added write flag			*
 * C. Lin/NCEP	 	 6/97	Bug fix in calling cfl_ropn 		*
 * E. Wehner/EAi	 6/97	Added check to not load header		*
 * E. Wehner/EAi	 7/97	Filled areas on all elements		*
 * E. Wehner/EAi	 8/97	Removed the graphics info record.	*
 * E. Wehner/EAi	 9/97	Allow NULL file name			*
 * F. Yen/NCEP		 1/98	Updated calls for crg library cleanup	*
 * I. Durham/GSC	 5/98	Changed underscore decl. to an include	*
 * F. J. Yen/NCEP	 5/98	Updated cds function names		*
 * E. Safford/GSC	10/98	added display levels revised file reads *
 * T. Piper/GSC		10/98	Prolog update				*
 * E. Safford/GSC	12/98	move display levels to pgprm.h		*
 * S. Jacobs/NCEP	 3/99	Added symbols to the last display level	*
 * A. Hardy/GSC          1/01   changed fptr from int to FILE           *
 * J. WU/SAIC           11/01   change prototype & add plotflg param	*
 * J. WU/SAIC           12/01   add layer param to feed crg_set()	*
 * J. WU/SAIC           12/01   locate displaying level	with cvg_level  *
 * T. Lee/SAIC		11/03	changed .DEFAULT.vgf to work_file	*
 * T. Lee/SAIC		11/03	used cvgcmn.h				*
 * M. Li/SAIC		08/04	Added time filter			*
 * B. Yin/SAIC          08/04   Added code to free TCA memory           *
 * B. Yin/SAIC          08/04   changed pgtca_freeBkpts to cvg_freeBkpts*
 * J. Wu/SAIC		10/04	free GFA block pointers			*
 * S. Danz/AWC          03/06   Call autoplacement if enabled           *
 * J. Wu/SAIC		06/06	call cvg_matchfilter 			*
 * M. Li/SAIC           03/07   Updated cvg_matchfilter                 *
 * m.gamazaychikov/SAIC	06/07	Add code to free TCB and TCT memory	*
 ***********************************************************************/
{
    int		    curpos, ier, flag, el_level;
    long	    maxbytes;
    int		    ier1, loglev, ic, icx, ii, jj, kk, one=1;
    int		    elms[3][MAX_EDITABLE_ELEMS], lvl_cnt[LEVELS], total_elms;
    char	    newfil[LLPATH], reqfil[LLPATH], grp[4], dbgfile[LLPATH];
    Boolean         autopl_enabled;
    VG_DBStruct	    el;
    filter_t	    el_filter, timeMatched;
    Boolean	    filter_match, matchAny = False;
    FILE	    *fptr;
    CMDObjectSet    nmap_metadata = NULL;
    PlacementSet    nmap_placements = NULL;
    cvg_group_info  *nmap_group_check = NULL;
/*---------------------------------------------------------------------*/

    ic = icol;
    icx = 256;
    if ( ic > icx || ic < 0 )  ic = 0;
    cds_scol ( ic, iret );

    strcpy(grp, "CVG");
    loglev = 0;
    *iret = 0;
    curpos  = 0;
    maxbytes = 0;    

    if (!fname) {
	strcpy(reqfil, work_file);
    }
    else {
	strcpy(reqfil, fname);
    }


    cvg_open(reqfil, (int)wrtflg, &fptr, &ier);

    if (( ier != 0 ) || ( fptr == NULL )) {
	*iret = -1;
	er_lmsg( &loglev, grp, &ier, reqfil, &ier1, strlen(grp),strlen(reqfil));
	return;
    }

    cfl_inqr(reqfil, NULL, &maxbytes, newfil, &ier);
    if (ier < 0) {
	*iret = -1;
	er_lmsg( &loglev, grp, &ier, reqfil, &ier1, strlen(grp),strlen(reqfil));
	return;
    }

    /*
     * Get each el.hdr and assign each elem offset to one of the levels.
     */
    for (ii = 0; ii < 3; ii++) {
        lvl_cnt[ii] = 0;
    }

    /*
     *  Scan the vg file and load the offsets of all non-deleted elements.
     *  Stop loading at end of file or MAX_EDITABLE_ELEMS.
     */
    total_elms = 0;
    while (((long)curpos < maxbytes) && (total_elms < MAX_EDITABLE_ELEMS))  {

        cvg_rdhdr(newfil, fptr, curpos, (int)maxbytes, &el, &flag, &ier);
	if (ier < 0 || el.hdr.recsz < 0 || el.hdr.recsz > 65536) {
	    *iret = -4;
	    return;
	}

        cvg_level( &el.hdr, &el_level, &ier );
	if ( ier == 0 ) {	
	    elms[ el_level ] [ lvl_cnt[el_level]++ ] = curpos;
	    total_elms++;
	}
		
 	curpos += el.hdr.recsz;	
    }

    if (total_elms >= MAX_EDITABLE_ELEMS) {
	*iret = 1;
	er_lmsg( &loglev, grp, &ier, newfil, &ier1, 
						strlen(grp),strlen(reqfil));
    }

    /*
     *  Create the structures to manage the metadata and object placement
     *  information.  If there were structures already in place, hold them
     *  aside as they were put there by product generation.
     */
    ctb_pfbool( "ENABLE_AUTOPLACE", &autopl_enabled, &ier );
    if (autopl_enabled) {
        if (cvg_metadata) {
            nmap_metadata = cvg_metadata;
            nmap_placements = cvg_placements;
            nmap_group_check = cvg_group_check;
        }
        cmd_osnew(&cvg_metadata, &ier);
        cap_psnew(&cvg_placements, &ier);
        G_CALLOC(cvg_group_check, cvg_group_info, one, "cvg_load: cvg_group_check");

        /*
         * Fill in the structures with the information needed
         */
        cvg_ld4place(fname, iret);

        /*
         * Ok, its all loaded, so place all the objects where they belong
         */
        cap_psplace(cvg_placements, cvg_metadata, iret);

        ctb_pfstr("AUTOPLACE_DBG", dbgfile, &ier );
        if (dbgfile[0] != '\0') {
            dump_objects(dbgfile, cvg_metadata, cvg_placements);
        }
    }

    /*
     *  Now loop thru the levels and display the elements
     */
    kk = 0;

    for (ii = 0; ii < LEVELS; ii++) {

	for (jj=0; jj<lvl_cnt[kk]; jj++) {
	    curpos = elms[ii][jj];
            cvg_rdhdr(newfil, fptr, curpos, (int)maxbytes, &el, &flag, &ier);
	    cvg_rdele(&el, curpos, el.hdr.recsz, fptr, &ier);

	    cvg_getElFilter ( &el, el_filter, &ier ); 

            cvg_matchfilter ( el_filter, matchAny, &filter_match, timeMatched, &ier );

	    if (selflag) {
	        crg_set(&el, curpos, layer, &ier);
	    }

	    if ( filter_match ) {
	        cds_dspelm( &el, &ier); 
	    }

            /*
             * Free TCA/GFA/TCT/TCB memory
             */
            if ( el.hdr.vg_type == TCA_ELM ) {
                cvg_freeBkpts ( &el );
            }
            else if ( el.hdr.vg_type == GFA_ELM ) {
                cvg_freeElPtr ( &el );
            }
            else if ( el.hdr.vg_type == TCTRK_ELM ) {
                cvg_freeTct ( &el );
            }
            else if ( el.hdr.vg_type == TCBKL_ELM ) {
                cvg_freeTcb ( &el );
	    }
	}

	kk++;
    }

    cvg_clos(fptr, &ier);
    if ( ier != 0 )
	*iret = -2;

    if ( plotflg ) geplot(&ier);
    ic = 0;
    cds_scol ( ic, iret );

    /*
     * Free up the metadata and placement information now that we 
     * are done plotting everything
     */
    if (autopl_enabled) {
        cmd_osdel(cvg_metadata, iret);
        cap_psdel(cvg_placements, iret);
        G_FREE(cvg_group_check, cvg_group_info);

        /*
         * Put back the product generation metadata
         */
        cvg_metadata = nmap_metadata;
        cvg_placements = nmap_placements;
        cvg_group_check = nmap_group_check;
    }

    return;

}
Beispiel #11
0
/* SIGHUP callback */
static void sighup_callback(void)
{
#ifdef DEBUG_OBJECTS
    dump_objects();
#endif
}