first commit

This commit is contained in:
Jose Caban
2025-06-07 01:59:34 -04:00
commit 388ac241f0
3558 changed files with 9116289 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
/Makefile/1.1/Fri Apr 14 23:43:57 2006//
/jpeg.x/1.2/Sat Apr 15 21:33:41 2006//
/main.c/1.2/Sat Apr 15 00:45:30 2006//
D/test_files////
/Makefile.rpc/1.3/Wed Apr 19 03:54:00 2006//
/remote.h/1.3/Wed Apr 19 03:41:43 2006//
/resize_client.c/1.5/Wed Apr 19 03:54:00 2006//
/resize_server.c/1.10/Wed Apr 19 03:54:00 2006//

View File

@@ -0,0 +1,8 @@
/Makefile////*///
/jpeg.x////*///
/main.c////*///
D/test_files///////
/Makefile.rpc////*///
/remote.h////*///
/resize_client.c////*///
/resize_server.c////*///

View File

@@ -0,0 +1,7 @@
/Makefile////*///
/Makefile.rpc////*///
/jpeg.x////*///
/main.c////*///
/resize_client.c////*///
/resize_server.c////*///
D/test_files///////

View File

@@ -0,0 +1,7 @@
/Makefile/1.1/Fri Apr 14 23:43:57 2006//
/Makefile.rpc/1.2/Sat Apr 15 22:45:21 2006//
/jpeg.x/1.2/Sat Apr 15 21:33:41 2006//
/main.c/1.2/Sat Apr 15 00:45:30 2006//
/resize_client.c/1.3/Sun Apr 16 00:04:14 2006//
/resize_server.c/1.9/Sun Apr 16 00:04:14 2006//
D/test_files////

View File

@@ -0,0 +1 @@
CS4210/Project 3/jpeg_resizer/rpc_server

View File

@@ -0,0 +1 @@
:ext:asskoala@192.168.0.3:/usr/_CVS

View File

@@ -0,0 +1,27 @@
CC = gcc
OPT = -O2 -fomit-frame-pointer
LIBS = -lpthread
TARGET = l33t_rpc
MISC = Makefile
BINDIR = ../../bin/rpc_server
LIBJPEG = ../jpeg-6b
MAKE = make
all: $(TARGET)
$(TARGET): $(BINDIR)/lowres.o $(BINDIR)/lowres-write.o $(BINDIR)/main.o
$(CC) $(OPT) -o $(BINDIR)/$(TARGET) $(BINDIR)/*.o $(LIBJPEG)/libjpeg.a -lpthread
$(BINDIR)/lowres.o: $(LIBJPEG)/lowres.c
-mkdir -p $(BINDIR) > /dev/null
$(CC) $(OPT) -c -o $(BINDIR)/lowres.o $(LIBJPEG)/lowres.c
$(BINDIR)/lowres-write.o: $(LIBJPEG)/lowres-write.c
$(CC) $(OPT) -c -o $(BINDIR)/lowres-write.o $(LIBJPEG)/lowres-write.c
$(BINDIR)/main.o: main.c
$(CC) $(OPT) -c -o $(BINDIR)/main.o main.c
clean:
rm -f $(BINDIR)/*.o $(BINDIR)/$(TARGET)

View File

@@ -0,0 +1,48 @@
# This is a template makefile generated by rpcgen
# Parameters
# What a bunch of bitches, we'll just add that
BINDIR = ../../bin/rpc_server
LDLIBS = $(BINDIR)/lowres-write.o $(BINDIR)/lowres.o ../jpeg-6b/libjpeg.a
OPT = -D_TEST_MAIN_
CLIENT = jpeg_client
SERVER = jpeg_server
SOURCES_CLNT.c = resize_client.c
SOURCES_CLNT.h =
SOURCES_SVC.c = resize_server.c
SOURCES_SVC.h =
SOURCES.x = jpeg.x
TARGETS_SVC.c = jpeg_svc.c jpeg_xdr.c
TARGETS_CLNT.c = jpeg_clnt.c jpeg_xdr.c
TARGETS = jpeg.h jpeg_xdr.c jpeg_clnt.c jpeg_svc.c
OBJECTS_CLNT = $(SOURCES_CLNT.c:%.c=%.o) $(TARGETS_CLNT.c:%.c=%.o)
OBJECTS_SVC = $(SOURCES_SVC.c:%.c=%.o) $(TARGETS_SVC.c:%.c=%.o)
# Compiler flags
RPCGENFLAGS =
# Targets
all : $(CLIENT) $(SERVER)
$(TARGETS) : $(SOURCES.x)
rpcgen $(RPCGENFLAGS) $(SOURCES.x)
$(OBJECTS_CLNT) : $(SOURCES_CLNT.c) $(SOURCES_CLNT.h) $(TARGETS_CLNT.c)
$(OBJECTS_SVC) : $(SOURCES_SVC.c) $(SOURCES_SVC.h) $(TARGETS_SVC.c)
$(CLIENT) : $(OBJECTS_CLNT)
$(CC) -o $(CLIENT) $(OBJECTS_CLNT) $(LDLIBS) $(OPT)
$(SERVER) : $(OBJECTS_SVC)
$(CC) -o $(SERVER) $(OBJECTS_SVC) $(LDLIBS) $(OPT)
clean:
$(RM) -f core $(TARGETS) $(OBJECTS_CLNT) $(OBJECTS_SVC) $(CLIENT) $(SERVER)

View File

@@ -0,0 +1,9 @@
typedef opaque file_in<>;
typedef opaque file_out<>;
program JPEGRESIZE {
version JPEGVER {
file_out RESIZE(file_in) = 1;
} = 1;
} = 0x20001337;

View File

@@ -0,0 +1,57 @@
#include "../jpeg-6b/lowres.h"
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
void test_jpeglib(int argc, char** argv) {
int file_sock;
int size;
char* output = NULL;
FILE* fp;
if(argc < 3) {
printf("%s input_file output_file\n", argv[0]);
exit(1);
}
file_sock = open(argv[1], O_RDONLY);
if (!change_res_JPEG (file_sock, &output, &size)) {
printf("Resize Failed. pwnt. \n");
close(file_sock);
exit(1);
}
if(NULL == (fp = fopen(argv[2], "w"))) {
printf("Failed to open for write\n");
free(output);
close(file_sock);
exit(1);
}
printf("%d\n", size);
// for(i = 0; i < size; i++) {
// fprintf(fp, "%c", *(output+i));
// }
fwrite(output, sizeof(char), size, fp);
fflush(fp);
free(output);
close(file_sock);
fclose(fp);
}
int main(int argc, char** argv) {
test_jpeglib(argc,argv);
return EXIT_SUCCESS;
}

View File

@@ -0,0 +1,6 @@
#ifndef _REMOTE_H_
#define _REMOTE_H_
file_out* jpegresize_1_proxy(char*, char*, unsigned int);
#endif

View File

@@ -0,0 +1,190 @@
/*
* This is sample code generated by rpcgen.
* These are only templates and you can use them
* as a guideline for developing your own functions.
*/
#include "jpeg.h"
#include "remote.h"
#define TESTJPEG "test_files/Ryoko_Red.jpg"
file_out*
jpegresize_1_proxy(char *host, char *jpeg_file, unsigned int size)
{
CLIENT *clnt;
file_out *result_1;
file_in resize_1_arg;
//Set the argument
{
resize_1_arg.file_in_val = jpeg_file;
resize_1_arg.file_in_len = size;
}
#ifndef DEBUG
clnt = clnt_create(host, JPEGRESIZE, JPEGVER, "tcp");
if (clnt == (CLIENT *) NULL) {
clnt_pcreateerror(host);
exit(1);
}
#endif /* DEBUG */
result_1 = resize_1(&resize_1_arg, clnt);
if (result_1 == (file_out *) NULL) {
clnt_perror(clnt, "call failed");
}
#ifndef DEBUG
clnt_destroy(clnt);
#endif /* DEBUG */
return result_1;
}
void
jpegresize_1(host)
char *host;
{
CLIENT *clnt;
file_out *result_1;
file_in resize_1_arg;
//Set the argument
{
FILE* jpeg_to_resize;
int c;
unsigned int size;
jpeg_to_resize = fopen(TESTJPEG, "r");
resize_1_arg.file_in_val = NULL;
for(size=0;EOF != (c = fgetc(jpeg_to_resize));size++) {
resize_1_arg.file_in_val =
realloc(resize_1_arg.file_in_val, size+1);
resize_1_arg.file_in_val[size] = c;
}
resize_1_arg.file_in_len = size;
fclose(jpeg_to_resize);
}
void
jpegresize_1(host)
char *host;
{
CLIENT *clnt;
file_out *result_1;
file_in resize_1_arg;
//Set the argument
{
FILE* jpeg_to_resize;
int c;
unsigned int size;
jpeg_to_resize = fopen(TESTJPEG, "r");
resize_1_arg.file_in_val = NULL;
for(size=0;EOF != (c = fgetc(jpeg_to_resize));size++) {
resize_1_arg.file_in_val =
realloc(resize_1_arg.file_in_val, size+1);
resize_1_arg.file_in_val[size] = c;
}
resize_1_arg.file_in_len = size;
fclose(jpeg_to_resize);
}
#ifndef DEBUG
clnt = clnt_create(host, JPEGRESIZE, JPEGVER, "tcp");
if (clnt == (CLIENT *) NULL) {
clnt_pcreateerror(host);
exit(1);
}
#endif /* DEBUG */
result_1 = resize_1(&resize_1_arg, clnt);
if (result_1 == (file_out *) NULL) {
clnt_perror(clnt, "call failed");
}
/* Call is done, let's do some cleanup and make sure it worked */
{
FILE* fp;
free(resize_1_arg.file_in_val);
fp = fopen("resized.jpg", "w");
fwrite(result_1->file_out_val, sizeof(char),
result_1->file_out_len, fp);
fflush(fp);
fclose(fp);
}
#ifndef DEBUG
clnt_destroy(clnt);
#endif /* DEBUG */
}
#ifndef DEBUG
clnt = clnt_create(host, JPEGRESIZE, JPEGVER, "tcp");
if (clnt == (CLIENT *) NULL) {
clnt_pcreateerror(host);
exit(1);
}
#endif /* DEBUG */
result_1 = resize_1(&resize_1_arg, clnt);
if (result_1 == (file_out *) NULL) {
clnt_perror(clnt, "call failed");
}
/* Call is done, let's do some cleanup and make sure it worked */
{
FILE* fp;
free(resize_1_arg.file_in_val);
fp = fopen("resized.jpg", "w");
fwrite(result_1->file_out_val, sizeof(char),
result_1->file_out_len, fp);
fflush(fp);
fclose(fp);
}
#ifndef DEBUG
clnt_destroy(clnt);
#endif /* DEBUG */
}
main(argc, argv)
int argc;
char *argv[];
{
char *host;
if (argc < 2) {
printf("usage: %s server_host\n", argv[0]);
exit(1);
}
host = argv[1];
jpegresize_1(host);
}

View File

@@ -0,0 +1,100 @@
/*
* This is sample code generated by rpcgen.
* These are only templates and you can use them
* as a guideline for developing your own functions.
*/
#include "jpeg.h"
#include "../jpeg-6b/lowres.h"
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
// Temp file name, used as "swap" space
#define TEMPFILENAME "l33t_temp_file"
// We'll use this so we can free the result from
// jpeg resize despite the fact that its returned
// This is an uber mega work-a-hack
static char* mallocd = NULL;
#ifdef linux
file_out *
resize_1_svc(argp, rqstp)
#else
file_out *
resize_1(argp, rqstp)
#endif
file_in *argp;
struct svc_req *rqstp;
{
static file_out result;
/*
* inseoutputrt server code here
*/
// Free before using again
if (mallocd) {
//printf("Freeing.\n");
free(mallocd);
mallocd = NULL;
}
{
char *data;
int size;
FILE* fp; // For writing the file
int file_sock; // File socket
printf("Handling a JPEG of size %d.\n", size);
////
// First we need to write the temp file
// Obtain file from paramater
data = argp->file_in_val;
size = argp->file_in_len;
// Write the file
if (NULL == (fp = fopen(TEMPFILENAME, "w"))) {
printf("Oh Snap! Failed to create temp file\n");
return NULL;
}
if (fwrite(data, sizeof(char), size, fp) != size) {
printf("Failed to write temp file\n");
}
fflush(fp);
fclose(fp);
////
// Resize the JPEG
file_sock = open(TEMPFILENAME, O_RDONLY);
if (!change_res_JPEG (file_sock,
&(result.file_out_val),
&(result.file_out_len)))
{
printf("Resize Failed. pwnt. \n");
close(file_sock);
remove(TEMPFILENAME);
result.file_out_val = NULL;
result.file_out_len = 0;
return (&result);
}
// Store for later freeing
mallocd = result.file_out_val;
close(file_sock);
remove(TEMPFILENAME);
}
return (&result);
}

View File

@@ -0,0 +1,2 @@
/Ryoko_Red.jpg/1.1/Fri Apr 14 23:44:20 2006/-kb/
D

View File

@@ -0,0 +1 @@
/Ryoko_Red.jpg////*///

View File

@@ -0,0 +1 @@
CS4210/Project 3/jpeg_resizer/rpc_server/test_files

View File

@@ -0,0 +1 @@
:ext:asskoala@192.168.0.3:/usr/_CVS

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 KiB