static void cleanup(void) { bind_cleanup(); pp_tidyup(); if (debugging(DEBUG_STORE)) { #ifndef TARGET_IS_HELIOS fprintf( stderr,"Time: %ldcs front-end %ldcs back-end\n", (long) tmuse_front,(long) tmuse_back); #endif show_store_use(); } cg_tidy(); #ifndef NO_OBJECT_OUTPUT # ifdef COMPILING_ON_ACORN_KIT { bool have_obj = (objstream != NULL); /* objstream cannot be stdout, so cc_close does a spurious test. */ cc_close(&objstream, objectfile); # ifdef COMPILING_ON_RISC_OS if (have_obj) set_time_stamp(objectfile, YES); # endif # ifdef COMPILING_ON_UNIX if (have_obj && system_flavour != NULL) { char *cmd; cmd = GlobAlloc(SU_Other, 24 + strlen(system_flavour) + strlen(objectfile)); sprintf(cmd,"/usr/bin/symrename -%s %s",system_flavour,objectfile); system(cmd); } # endif } # else cc_close(&objstream, objectfile); # endif #endif #ifndef NO_ASSEMBLER_OUTPUT cc_close(&asmstream, asmfile); #endif cc_close(&listingstream, listingfile); cc_close(&makestream, makefile); summarise(); #ifdef ENABLE_MAPSTORE if (debugging(DEBUG_MAPSTORE)) _mapstore(); #endif alloc_dispose(); }
extern void compile_abort(int sig_no) { /* pre-conditions: initialisation done, closing not done. Call from */ /* SIGINT handler at your peril! */ #ifndef COMPILING_ON_MSDOS signal(SIGINT, SIG_IGN); #endif cc_close(&asmstream, asmfile); cc_close(&listingstream, listingfile); if (objstream) { cc_close(&objstream, objectfile); #ifndef COMPILING_ON_MVS remove(objectfile); #endif } exit(sig_no == (-1) ? EXIT_fatal : EXIT_syserr); }
int cc_fclose(FILE *stream) { if (stream == NULL) { cc_errno = CC_EINVAL; cc_InOutRes = EINOUTRES_NOT_OPENED; return -1; } switch (stream->mode) { case cc_fmClosed: cc_errno = CC_EINVAL; cc_InOutRes = EINOUTRES_NOT_OPENED; return -1; case cc_fmInput: case cc_fmOutput: case cc_fmInOut: if (stream->handle > 4) { if (!cc_close(stream->handle)) { _cc_dos_freemem(FP_SEG(stream)); cc_InOutRes = EINOUTRES_SUCCESS; return 0; } else { cc_InOutRes = _cc_doserrno; return -1; } } else { _cc_dos_freemem(FP_SEG(stream)); cc_InOutRes = EINOUTRES_SUCCESS; return 0; } default: cc_errno = CC_EINVAL; cc_InOutRes = EINOUTRES_NOT_ASSIGNED; return -1; } }
/* * initialize * * initialize the cache, check to see if one already exists for this * principal if not set our principal to this principal. This * searching enables ticket sharing */ krb5_error_code KRB5_CALLCONV krb5_stdcc_initialize (krb5_context context, krb5_ccache id, krb5_principal princ) { stdccCacheDataPtr ccapi_data = NULL; int err; char *cName = NULL; krb5_error_code retval; if ((retval = stdcc_setup(context, NULL))) return retval; /* test id for null */ if (id == NULL) return KRB5_CC_NOMEM; if ((retval = krb5_unparse_name(context, princ, &cName))) return retval; ccapi_data = id->data; if (ccapi_data->NamedCache) cc_close(gCntrlBlock, &ccapi_data->NamedCache); err = cc_create(gCntrlBlock, ccapi_data->cache_name, cName, CC_CRED_V5, 0L, &ccapi_data->NamedCache); if (err != CC_NOERROR) { krb5_free_unparsed_name(context, cName); return cc_err_xlate(err); } #if 0 /* * Some implementations don't set the principal name * correctly, so we force set it to the correct value. */ err = cc_set_principal(gCntrlBlock, ccapi_data->NamedCache, CC_CRED_V5, cName); #endif krb5_free_unparsed_name(context, cName); cache_changed(); return cc_err_xlate(err); }
int main() { static const char* cubeNames[CC_FACE_NUM] = { "TOP.bmp", "LEFT.bmp", "FRONT.bmp", "RIGHT.bmp", "BACK.bmp", "DOWN.bmp" }; struct cc_context ctx; unsigned int i = 0; unsigned int j = 0; unsigned char rr; unsigned char gg; unsigned char bb; BMP *bmpCube[CC_FACE_NUM]; unsigned int width = 0; unsigned int height = 0; unsigned short depth = 0; BMP *output = NULL; unsigned int pano_width = 0; unsigned int pano_height = 0; const struct cc_coord* coord = NULL; // Read the 6 input images for (i = 0; i < CC_FACE_NUM; ++i) { bmpCube[i] = BMP_ReadFile(cubeNames[i]); if (BMP_GetError() != BMP_OK) { return 1; } } // Get image's dimensions width = (unsigned int)BMP_GetWidth( bmpCube[0]); height = (unsigned int)BMP_GetHeight(bmpCube[0]); depth = BMP_GetDepth( bmpCube[0]); // The input images must be square if (width != height) { return 1; } /* Initialise the algorithm: the width of each input is 640 pixel, the vertical view portion is PI (180 degrees), the horizontal view portion is 2*PI (360 degress). In this case, the output image size will be calculated accordingly. There is another more detailed init function you can play with. */ cc_init(&ctx, width, M_PI*2.0, M_PI); // Generate the mapping from panorama to cubic cc_gen_map(&ctx); // Access the dimension of the panorama image pano_width = ctx.px_pano_h; pano_height = ctx.px_pano_v; // Create the panorama output image output = BMP_Create(pano_width, pano_height, depth); // Map the pixels from the panorama back to the source image for (i = 0; i < pano_width; ++i) { for (j = 0; j < pano_height; ++j) { // Get the corresponding position of (i, j) coord = cc_get_coord(&ctx, i, j); // Access the pixel BMP_GetPixelRGB(bmpCube[coord->face], (unsigned long)coord->x, (unsigned long)coord->y, &rr, &gg, &bb); // Write the pixel to the panorama BMP_SetPixelRGB(output, i, j, rr, gg, bb); } } // Write the output file BMP_WriteFile(output, "PANO.bmp"); // Release memory BMP_Free(output); for (i = 0; i < CC_FACE_NUM; ++i) { BMP_Free(bmpCube[i]); } cc_close(&ctx); return 0; }
void main(void) { // XXX (3) - infoNC not properly filled out when returned. infoNC** allCacheInfo = 0; // XXX (2) - bug in krbcc32 infoNC* cacheInfo; ccache_p* theCache = 0; ccache_cit* iterator = 0; cred_union* theCreds = 0; cc_uint32 err; unsigned long index; apiCB* context = 0; // XXX (1) - bug in krbcc32 cc_int32 version; printf ("Dumping all credential caches... (times are in GMT)\n"); err = cc_initialize (&context, CC_API_VER_2, &version, NULL); // XXX (1) if (err != CC_NOERROR) { printf ("*** cc_initialize returned %d ***\n", err); return; } err = cc_get_NC_info (context, &allCacheInfo); // XXX (2) - another bug if (err != CC_NOERROR) { printf ("*** cc_get_NC_info returned %d ***\n", err); return; } for (index = 0; allCacheInfo [index] != 0; index++) { cacheInfo = allCacheInfo [index]; switch (cacheInfo->vers) { case CC_CRED_V4: printf ("\tv4 credentials\n"); break; case CC_CRED_V5: printf ("\tv5 credentials\n"); break; default: printf ("\t*** bogus credentials type %d***\n", cacheInfo->vers); continue; } printf ("\tfor %s\n\tin %s\n", cacheInfo->principal, cacheInfo->name); err = cc_open (context, cacheInfo->name, cacheInfo->vers, 0L, &theCache); if (err != CC_NOERROR) { printf ("\t*** cc_open returned %d ***\n", err); continue; } err = cc_seq_fetch_creds_begin (context, theCache, &iterator); if (err != CC_NOERROR) { printf ("\t*** cc_seq_fetch_creds_begin returned %d ***\n", err); continue; } for (;;) { err = cc_seq_fetch_creds_next (context, &theCreds, iterator); if (err == CC_END) break; if (err != CC_NOERROR) { printf ("\t\t*** seq_fetch_creds returned %d ***\n", err); continue; } switch (theCreds->cred_type) { case CC_CRED_V4: { char start [26]; char end [26]; printf ("\t\t%s - %s: %s.%s@%s\n", datestring (start, theCreds->cred.pV4Cred->issue_date), datestring (end, theCreds->cred.pV4Cred->issue_date + theCreds->cred.pV4Cred->lifetime * 5 * 60), theCreds->cred.pV4Cred->service, theCreds->cred.pV4Cred->service_instance, theCreds->cred.pV4Cred->realm); break; } case CC_CRED_V5: { char start [26]; char end [26]; printf ("\t\t%s - %s: %s\n", datestring (start, theCreds->cred.pV5Cred->starttime), datestring (end, theCreds->cred.pV5Cred->endtime), theCreds->cred.pV5Cred->server); break; } } cc_free_creds (context, &theCreds); } cc_seq_fetch_creds_end (context, &iterator); cc_close (context, &theCache); printf ("\n"); } cc_free_NC_info (context, &allCacheInfo); cc_shutdown (&context); }