Find Jobs
Hire Freelancers

c++ image fix for webserver

$30-100 USD

Abgeschlossen
Veröffentlicht vor mehr als 16 Jahren

$30-100 USD

Bezahlt bei Lieferung
Okay, i have a custom webserver written in c++, it currently only serves html need it to do images to. For images i just need it to pick a random one from a directory and print it out dynamically, so i had this routine written by somone on here int random_image(vector<char> &s, const char *path) { vector<struct dirent> l; int r, i; struct dirent *d; DIR *dh; [login to view URL](); if ((dh = opendir(path)) == NULL) return -1; while((d = readdir(dh)) != NULL) { if (strlen(d->d_name) <= 4 || d->d_name[0] == '.' || strcasecmp(d->d_name+strlen(d->d_name)-4,".jpg")) continue; l.push_back(*d); } closedir(dh); if ([login to view URL]() == 0) return -1; /* No valid images present */ /* Generate a random number in our list */ r = (double)rand() *[login to view URL]() / RAND_MAX; for (i = 0; i < [login to view URL](); i++) if (i == r) { FILE *f; char buff[4096]; int c; snprintf(buff, 4096, "%s/%s", path, l[i].d_name); if ((f = fopen(buff, "r")) == NULL) return -1; while((c = fgetc(f)) != EOF) s.push_back(c); fclose(f); } return 0; } Okay so the image gets stored in the vector called data. My http headers are stored in strResponse which is of type std::string strResponse += "HTTP/1.1 200 OK\r\n"; strResponse += "Date: "; strResponse += szDate; strResponse += " GMT\r\n"; strResponse += "Server: Apache/2.0.48 (Unix) PHP/4.3.4\r\n"; strResponse += "Connection: close\r\n"; strResponse += "Content-Type: image/jpg\r\n"; strResponse += "Content-Length: "; strResponse += szPageLength; strResponse += "\r\n"; strResponse += "\r\n"; Need to have the headers and image all stored in strResponse. ## Deliverables 1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done. 2) Deliverables must be in ready-to-run condition, as follows (depending on the nature of the deliverables): a) For web sites or other server-side deliverables intended to only ever exist in one place in the Buyer's environment--Deliverables must be installed by the Seller in ready-to-run condition in the Buyer's environment. b) For all others including desktop software or software the buyer intends to distribute: A software installation package that will install the software in ready-to-run condition on the platform(s) specified in this bid request. 3) All deliverables will be considered "work made for hire" under U.S. Copyright law. Buyer will receive exclusive and complete copyrights to all work purchased. (No GPL, GNU, 3rd party components, etc. unless all copyright ramifications are explained AND AGREED TO by the buyer on the site per the coder's Seller Legal Agreement). ## Platform gcc 2.355 unix c++
Projekt-ID: 3539670

Über das Projekt

1 Vorschlag
Remote Projekt
Aktiv vor 16 Jahren

Möchten Sie etwas Geld verdienen?

Vorteile einer Ausschreibung auf Freelancer

Legen Sie Ihr Budget und Ihren Zeitrahmen fest
Für Ihre Arbeit bezahlt werden
Skizzieren Sie Ihren Vorschlag
Sie können sich kostenlos anmelden und auf Aufträge bieten
Vergeben an:
Avatar des Nutzers
See private message.
$21,25 USD in 2 Tagen
5,0 (89 Bewertungen)
6,4
6,4

Über den Kunden

Flagge von UNITED STATES
San Diego, United States
5,0
7
Mitglied seit Nov. 30, 2007

Kundenüberprüfung

Danke! Wir haben Ihnen per E-Mail einen Link geschickt, über den Sie Ihr kostenloses Guthaben anfordern können.
Beim Senden Ihrer E-Mail ist ein Fehler aufgetreten. Bitte versuchen Sie es erneut.
Registrierte Benutzer Veröffentlichte Jobs
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Vorschau wird geladen
Erlaubnis zur Geolokalisierung erteilt.
Ihre Anmeldesitzung ist abgelaufen und Sie wurden abgemeldet. Bitte melden Sie sich erneut an.