This repository has been archived on 2018-06-04. You can view files and clone it, but cannot push or open issues/pull-requests.
iMoodUpdater/cmdline/imoodupdater.c

93 lines
2.8 KiB
C

/*
--------------------------------------------------------------------------
iMood - Using www.imood.com's API we can change our web mood
Copyright (C) 2003 Rise In Superior Code & SDF1 Networks
--------------------------------------------------------------------------
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
GNU License @ http://www.gnu.org/copyleft/gpl.htm
iMood version 1.0, Copyright (C) 2003 Rise In Superior Code & SDF1 Networks
iMood comes with ABSOLUTELY NO WARRANTY
*/
#include <netdb.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void iMoodSend(char **argv)
{
char buffy[2048];
int dstPort, sock, result;
struct sockaddr_in name;
struct hostent *hostinfo;
dstPort = 80;
hostinfo=gethostbyname("my.imood.com");
if (!hostinfo){
herror("Error"); exit(-1);
}
name.sin_family=AF_INET;
name.sin_port=htons(dstPort);
name.sin_addr=*(struct in_addr *)hostinfo->h_addr;
sock=socket(AF_INET, SOCK_STREAM, 0);
result=connect(sock, (struct sockaddr *)&name, sizeof(struct sockaddr_in));
if (result != 0) {
herror("Error");
exit(-1);
}
sock=socket(AF_INET, SOCK_STREAM, 0);
result=connect(sock, (struct sockaddr *)&name, sizeof(struct sockaddr_in));
if (result != 0) {
herror("Error");
exit(-1);
}
strcpy(buffy, "GET /updater.cgi?action=update&new_mood=");
strncat(buffy,argv[3],256);
strcat(buffy,"&face=");
strncat(buffy,argv[4],2);
strcat(buffy," HTTP/1.1\r\n");
strcat(buffy,"Host: www2.imood.com\r\n");
strcat(buffy, "Cookie: imood_pass=");
strncat(buffy,argv[2],256);
strcat(buffy,"; imood_user=");
strncat(buffy,argv[1],256);
strcat(buffy,"\r\n\r\n");
send(sock, buffy, sizeof(buffy), 0);
return;
}
int main(int argc, char **argv)
{
if (argc < 4 || argc > 5){
printf ("\r\nUsage:\r\n%s UID PW Mood FaceID\r\n", argv[0]);
printf ("FaceID:\t0-32\r\nie: imood bob@bob.com myPass happy 0\r\n\r\n");
exit(0);
}
iMoodSend(argv);
printf ("\r\niMood Updated\r\n");
return 0;
}