Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <nspire.h>
- struct nsp_ctx {
- nspire_handle_t *handle;
- };
- int main(int argc, char *argv[] )
- {
- int ret = 0;
- struct nsp_ctx *ctx = malloc(sizeof(*ctx));
- if (argc != 3) {
- printf( "usage: %s local-source-path remote-destination-path\r\n", argv[0]);
- }
- else if ((ret = nspire_init(&ctx->handle))) {
- printf("Couldn't init handle, error: %d\r\n", ret);
- }
- else {
- FILE *f = fopen(argv[1], "rb");
- fseek(f, 0, SEEK_END);
- long fsize = ftell(f);
- fseek(f, 0, SEEK_SET);
- char *data = malloc(fsize);
- size_t bsize = fread(data, fsize, 1, f);
- fclose(f);
- nspire_file_write(ctx->handle, argv[2], data, bsize);
- nspire_free(ctx->handle);
- }
- free(ctx);
- return ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement