static void fz_expand_tiff_colormap(struct tiff *tiff) { int maxval = 1 << tiff->bitspersample; unsigned char *samples; unsigned char *src, *dst; unsigned int x, y; unsigned int stride; /* colormap has first all red, then all green, then all blue values */ /* colormap values are 0..65535, bits is 4 or 8 */ /* image can be with or without extrasamples: comps is 1 or 2 */ if (tiff->samplesperpixel != 1 && tiff->samplesperpixel != 2) fz_throw(tiff->ctx, FZ_ERROR_GENERIC, "invalid number of samples for RGBPal"); if (tiff->bitspersample != 1 && tiff->bitspersample != 4 && tiff->bitspersample != 8) fz_throw(tiff->ctx, FZ_ERROR_GENERIC, "invalid number of bits for RGBPal"); if (tiff->colormaplen < (unsigned)maxval * 3) fz_throw(tiff->ctx, FZ_ERROR_GENERIC, "insufficient colormap data"); /* SumatraPDF: prevent integer overflow */ if (tiff->imagelength > UINT_MAX / tiff->imagewidth / (tiff->samplesperpixel + 2)) fz_throw(tiff->ctx, FZ_ERROR_GENERIC, "image dimensions might overflow"); stride = tiff->imagewidth * (tiff->samplesperpixel + 2); samples = fz_malloc(tiff->ctx, stride * tiff->imagelength); for (y = 0; y < tiff->imagelength; y++) { src = tiff->samples + (unsigned int)(tiff->stride * y); dst = samples + (unsigned int)(stride * y); for (x = 0; x < tiff->imagewidth; x++) { if (tiff->extrasamples) { int c = getcomp(src, x * 2, tiff->bitspersample); int a = getcomp(src, x * 2 + 1, tiff->bitspersample); *dst++ = tiff->colormap[c + 0] >> 8; *dst++ = tiff->colormap[c + maxval] >> 8; *dst++ = tiff->colormap[c + maxval * 2] >> 8; *dst++ = a << (8 - tiff->bitspersample); } else { int c = getcomp(src, x, tiff->bitspersample); *dst++ = tiff->colormap[c + 0] >> 8; *dst++ = tiff->colormap[c + maxval] >> 8; *dst++ = tiff->colormap[c + maxval * 2] >> 8; } }
static inline int samplecomp(byte *s, int w, int h, int u, int v, int n, int k) { int ui = u >> 16; int vi = v >> 16; int ud = u & 0xFFFF; int vd = v & 0xFFFF; int a = getcomp(s, w, h, ui, vi, n, k); int b = getcomp(s, w, h, ui+1, vi, n, k); int c = getcomp(s, w, h, ui, vi+1, n, k); int d = getcomp(s, w, h, ui+1, vi+1, n, k); int ab = lerp(a, b, ud); int cd = lerp(c, d, ud); return lerp(ab, cd, vd); }
static int xps_expand_tiff_colormap(struct tiff *tiff) { int maxval = 1 << tiff->bitspersample; byte *samples; byte *src, *dst; unsigned int x, y; unsigned int stride; /* colormap has first all red, then all green, then all blue values */ /* colormap values are 0..65535, bits is 4 or 8 */ /* image can be with or without extrasamples: comps is 1 or 2 */ if (tiff->samplesperpixel != 1 && tiff->samplesperpixel != 2) return fz_error_make(tiff->ctx, "invalid number of samples for RGBPal"); if (tiff->bitspersample != 4 && tiff->bitspersample != 8) return fz_error_make(tiff->ctx, "invalid number of bits for RGBPal"); stride = tiff->imagewidth * (tiff->samplesperpixel + 2); samples = fz_malloc(tiff->ctx, stride * tiff->imagelength); for (y = 0; y < tiff->imagelength; y++) { src = tiff->samples + (tiff->stride * y); dst = samples + (stride * y); for (x = 0; x < tiff->imagewidth; x++) { if (tiff->extrasamples) { int c = getcomp(src, x * 2, tiff->bitspersample); int a = getcomp(src, x * 2 + 1, tiff->bitspersample); *dst++ = tiff->colormap[c + 0] >> 8; *dst++ = tiff->colormap[c + maxval] >> 8; *dst++ = tiff->colormap[c + maxval * 2] >> 8; *dst++ = a << (8 - tiff->bitspersample); } else { int c = getcomp(src, x, tiff->bitspersample); *dst++ = tiff->colormap[c + 0] >> 8; *dst++ = tiff->colormap[c + maxval] >> 8; *dst++ = tiff->colormap[c + maxval * 2] >> 8; } }
static void fz_invert_tiff(unsigned char *line, int width, int comps, int bits, int alpha) { int i, k, v; int m = (1 << bits) - 1; for (i = 0; i < width; i++) { for (k = 0; k < comps; k++) { v = getcomp(line, i * comps + k, bits); if (!alpha || k < comps - 1) v = m - v; putcomp(line, i * comps + k, bits, v); } } }
static void fz_unpredict_tiff(unsigned char *line, int width, int comps, int bits) { unsigned char left[32]; int i, k, v; for (k = 0; k < comps; k++) left[k] = 0; for (i = 0; i < width; i++) { for (k = 0; k < comps; k++) { v = getcomp(line, i * comps + k, bits); v = v + left[k]; v = v % (1 << bits); putcomp(line, i * comps + k, bits, v); left[k] = v; } } }
void articulation(int u) { int v; edge e; int x; status[u]=visiting; discover[u]=finish[u]=++time; //for(v=1; v<=n; v++) //if(adj[u][v]==adjacent) x=NodeHead[u]; while(x!=NIL) { v=EdgeList[x].dst; for(v=1; v<=n; v++){ if(parent[u]!=v && discover[v]<discover[u]) { e.u=u; e.v=v; push(e); } if(status[v]==notvisited) { parent[v]=u; articulation(v); if(finish[v]>=discover[u]) { point[u]+=1; getcomp(u, v); } finish[u]=min(finish[u], finish[v]); } else if(parent[u]!=v) x=EdgeList[x].next; finish[u]=min(finish[u], discover[v]); }} status[u]=visited; }
IDL_VPTR hds2idl( int argc, IDL_VPTR argv[] ) { /* ** Declare variables */ IDL_VPTR hds_name; /* IDL_VPTR to name of the HDS object to be read */ IDL_VPTR var; /* Variable pointer to IDL object */ IDL_VARIABLE temp; /* Temporary storage for primitive scalar variable */ IDL_StructDefPtr sdef; /* Structure definition of sub-structure */ IDL_STRING *objname; /* Pointer to object name as IDL string */ HDSLoc *objloc = NULL; /* Locator of file */ int status; /* Starlink status */ char type[DAT__SZTYP+1];/* HDS type of component */ UCHAR idltype; /* IDl type of component */ int ndims; /* Number of dimensions of object */ int dims[DAT__MXDIM]; /* Dimensions of object HDS style */ IDL_LONG idldims[DAT__MXDIM];/* Dimensions of object IDL style */ int i; /* loop index */ int fstat; /* Final status (before emsEload) */ int isstruct; /* Whether object is structure */ void *tdata; /* Pointer to data area of IDL variable or array */ char param[EMS__SZPAR+1]; /* Error message parameter name */ int parlen; /* Length of error message parameter name */ char opstr[EMS__SZMSG+1]; /* Error message */ int oplen; /* Length of error message */ IDL_LONG one[IDL_MAX_ARRAY_DIM]={1}; /* Start Error context */ status = SAI__OK; emsMark(); /* Check that the correct number of arguments were passed in */ if(argc != 1) { /* Print an error message and return */ status = SAI__ERROR; emsRep( " ", "hds2idl: Incorrect number of arguments", &status ); } else { /* Extract the arguments to comprehensible names */ hds_name = argv[0]; objname = &hds_name->value.str; /* Open the HDS object */ getcomp( IDL_STRING_STR(objname), "READ", &objloc, &status ); /* Check for structure or primitive */ datStruc( objloc, &isstruct, &status ); if (status == SAI__OK) { if ( isstruct ) { /* Create a structure */ sdef = idlstructdef( objloc, &status ); /* Create a temporary variable */ if ( status == SAI__OK ) { (void *)IDL_MakeTempStruct( sdef, 1, one, &var, TRUE ); idlstructfill( objloc, var->value.s, &status ); } } else { /* Object is primitive */ datType( objloc, type, &status ); idltype = getidltype( type ); datShape( objloc, DAT__MXDIM, dims, &ndims, &status ); if ( status == SAI__OK ) { if (ndims) { /* Get dimensions IDL style */ for (i=0;i<ndims;i++) idldims[i] = (IDL_LONG)dims[i]; /* Object is primitive array */ tdata = IDL_MakeTempArray( (int)idltype, ndims, idldims, IDL_BARR_INI_ZERO , &var ); } else { /* Object is primitive scalar */ var = &temp; var->type = idltype; var->flags = 0; tdata = &var->value; } idlprimfill( objloc, var, tdata, &status ); } } /* Annul the object (and close the file) */ datAnnul( &objloc, &status ); } } if ( status != SAI__OK ) { /* Report any error messages */ /* Adding Starlink-style !! and ! prefix */ fstat = status; while ( status != SAI__OK ) { emsEload( param, &parlen, opstr, &oplen, &status ); if ( status != SAI__OK ) IDL_Message( IDL_M_NAMED_GENERIC, IDL_MSG_INFO, opstr ); } /* Set to return undefined variable */ var = IDL_Gettmp(); /* and close error context */ emsRlse(); } /* That's it, return to the calling routine */ return var; }
int main(void) { char comp[50], name[50], pom[100], from[50], to[50]; char rcpt[MAXRCPT][50]; const char *rcptcomp[MAXRCPT]; const char *fcomp; char messg[MESSGLEN][LINELEN]; int n, i, j, k, rcptnum, lines, rgood, mnum, komu; scanf( "%s", pom ); while( pom[0]!='*' ) { scanf( "%s %d", comp, &n ); for( i=0; i<n; ++i ) { scanf( "%s", name ); sprintf( pom, "%s@%s", name, comp ); zarad( pom ); } scanf( "%s", pom ); } mnum=1; scanf( "%s", from ); while( from[0]!='*' ) { int c; fcomp=getcomp( from ); rcptnum=0; scanf( "%s", to); while( to[0]!='*' ) { strcpy( rcpt[rcptnum], to ); rcptcomp[rcptnum]=getcomp( rcpt[rcptnum] ); ++rcptnum; scanf( "%s", to ); } lines=0; while ((c = getchar()) != EOF && (c == ' ' || c == '\t')) ; if (c != '\n') ungetc(c, stdin); gets( messg[0] ); while( messg[lines++][0]!='*' ) { gets( messg[lines] ); } --lines; for( i=0; i<rcptnum; ++i ) { if( rcpt[i][0]!=0 ) { printf( "Connection between %s and %s\n", fcomp, rcptcomp[i] ); indent;printf( "HELO %s\n", fcomp ); indent;printf( "250\n" ); indent;printf( "MAIL FROM:<%s>\n", from ); indent;printf( "250\n" ); rgood=0; for( j=i; j<rcptnum; ++j ) { if( rcpt[j][0]!=0 && strcmp( rcptcomp[j], rcptcomp[i] )==0 ) { komu=vezmi( rcpt[j] ); if( komu==-1 ) { indent;printf( "RCPT TO:<%s>\n", rcpt[j] ); indent;printf( "550\n" ); /*********** spoleham, ze neni moc pripadu nesmysle adresy ****/ for( k=j+1; k<rcptnum; ++k ) if( strcmp( rcpt[j], rcpt[k] )==0 ) rcpt[k][0]=0; } else { if( lastmsg[komu]!=mnum ) { indent;printf( "RCPT TO:<%s>\n", rcpt[j] ); indent;printf( "250\n" ); lastmsg[komu]=mnum; ++rgood; } } rcpt[j][0]=0; } } if( rgood>0 ) { indent;printf( "DATA\n" ); indent;printf( "354\n" ); for( k=0; k<lines; ++k ) { indent;puts( messg[k] ); } indent;printf( ".\n"); indent;printf( "250\n" ); } indent;printf( "QUIT\n" ); indent;printf( "221\n" ); } } scanf( "%s", from ); ++mnum; } return 0; }
int main(int argc, char const *argv[]) { int i,j,k; if (strcmp(argv[1],"2") == 0) { decompress(); FILE *output2; output2 = fopen("dout.txt", "w"); nd *q; q=startinp; while(q!=NULL) { fprintf(output2,"%s\n",q->data); q=q->next; } } if(strcmp(argv[1],"1")==0) { FILE *cout; cout = fopen("cout.txt", "w"); int i, j, k=0; getins(); nd1 *show; count(); diction(); compress(); getcomp(); for (i = 0; i < (32-(strlen(str)%32)); i++) { } for (j = 0; j < i; ++j) { strcat(str,"1"); } strcat(str,"\0"); for (i = 0; i < (strlen(str)/32); ++i) { for (j = 0; j < 32; ++j) { fprintf(cout,"%c", str[k]); k++; } fprintf(cout,"\n"); } fprintf(cout,"xxxx\n"); show=startdict; while(show!=NULL) { fprintf(cout, "%s\n", show->data); show=show->next; } } }