Ejemplo n.º 1
0
int cmain()
{
    char buf[1024], csum[33];
    int len;

    checksum_init();
    while ((len = fread(buf, 1, sizeof(buf), stdin)) > 0)
	checksum_update(len, buf);
    checksum_final(csum);

    printf("sum = %s\n", csum);

    return 0;
}
Ejemplo n.º 2
0
gssize   read_fn      (GInputStream        *stream,
                       void                *buffer,
                       gsize                count,
                       GCancellable        *cancellable,
                       GError             **error)
{
  CheckcopyInputStreamPrivate *priv = GET_PRIVATE (CHECKCOPY_INPUT_STREAM (stream));
  GFilterInputStream *filter_stream = G_FILTER_INPUT_STREAM (stream);
  GInputStream *base_stream = filter_stream->base_stream;
  gssize nread;
  int i;

  nread = g_input_stream_read (base_stream, buffer, count, cancellable, error);

  for (i=CHECKCOPY_NO_CHECKSUM+1; i<CHECKCOPY_ALL_CHECKSUMS; i++) {
    checksum_update (i, &(priv->checksum[i]), buffer, nread);
  }

  return nread;
}
Ejemplo n.º 3
0
void checksum_simple_(integer *len, const void *buf, char *f, int flen)
{
    checksum_init();
    checksum_update((int) *len, buf);
    checksum_final_(f, flen);
}
Ejemplo n.º 4
0
void checksum_simple_(integer *len, const void *buf, _fcd f)
{
    checksum_init();
    checksum_update((int) *len, buf);
    checksum_final_(f);
}
Ejemplo n.º 5
0
void FATR checksum_char_update_(const char *buf, int len)
{
    checksum_update(len, buf);
}
Ejemplo n.º 6
0
void FATR checksum_char_update_(_fcd f)
{
    checksum_update(_fcdlen(f), _fcdtocp(f));
}
Ejemplo n.º 7
0
/**
\brief Fortran binding for the `checksum_update` function.

This function accepts all types of data except character data.
The reason for the latter is that character strings are handled 
differently in Fortran than in C. So for those an additional 
conversion step is required. See `checksum_char_update` for 
details.
\param len [Input] The number of bytes of data
\param buf [Input] The data to be checksummed
*/
void FATR checksum_update_(integer *len, const void *buf)
{
    checksum_update((int) *len, buf);
}
Ejemplo n.º 8
0
void checksum_simple(int len, const void *buf, char csum[33])
{
    checksum_init();
    checksum_update(len, buf);
    checksum_final(csum);
}