Jump to content
xisto Community
HannahI

Flash With C In Unix

Recommended Posts

Are you asking how to download Adobe Flashplayer for Linux ? Or are you asking if Flash Player exists for Unix versions other than Linux ?Or are you saying that you want to write down a C program using flash instructions for people having not installed Flash on their Windows PC ?

Share this post


Link to post
Share on other sites

For me those three things put together... oh thats almost not possible as my knowledge says.You mean you want to embed flash elements in C language? I haven't seen anyone doing that, may be it requires lots of expertise if possible.May be if you could tell what you are trying to achieve, I would try guessing some alternatives.

Share this post


Link to post
Share on other sites

What I'm tring to say is that, I want to make a flash on the screen in C; I know it would be possible directly in Unix by having a for loop that clears the screen the prints something.

Share this post


Link to post
Share on other sites

What I'm tring to say is that, I want to make a flash on the screen in C; I know it would be possible directly in Unix by having a for loop that clears the screen the prints something.

Ha! Now we start understanding.You don't want an embedded Adobe Flashplayer.
You want to have a flashing light on the user's screen from a C program.
something like
system ("tput rev");printf("											  ");printf("											  ");printf("											  ");printf("											  ");system ("tput sgr0");
Of course, I hope this is to be used on a Unix system. On a Crosoft Winbows I would be curious to see the result of "tput rev" ! :D

Share this post


Link to post
Share on other sites

What file is the system command in?

Have a look at a C language manual, for instance here : https://support1-sgi.custhelp.com/And look for the "system" function :

system FunctionThe contents and mode of execution of the string passed to the system function (4.10.4.5).

The contents of the string should be a command string, as if typed to a normal IRIX shell, such as sh(1). A shell ( sh) is forked, and the string is passed to it. The current process waits until the shell has completed and returns the exit status of the shell as the return value.


Share this post


Link to post
Share on other sites

Assuming that you know how to program in C, the way to colorize text within a C program is to use ansi escape sequences. See: https://en.wikipedia.org/wiki/ANSI_escape_code

Basically you set up a bunch of defines that you put in a header and include it in any .c files that need color in them.

/* These are the ANSI codes for foreground text colors */
#define ANSI_BLACK "\033[0;30m"
#define ANSI_DRED "\033[0;31m"
#define ANSI_DGREEN "\033[0;32m"
#define ANSI_ORANGE "\033[0;33m"
#define ANSI_DBLUE "\033[0;34m"
#define ANSI_PURPLE "\033[0;35m"
#define ANSI_CYAN "\033[0;36m"
#define ANSI_GREY "\033[0;37m"
#define ANSI_DGREY "\033[1;30m"
#define ANSI_RED "\033[1;31m"
#define ANSI_GREEN "\033[1;32m"
#define ANSI_YELLOW "\033[1;33m"
#define ANSI_BLUE "\033[1;34m"
#define ANSI_PINK "\033[1;35m"
#define ANSI_LBLUE "\033[1;36m"
#define ANSI_WHITE "\033[1;37m"
#define ANSI_RESET "\033[0m"
#define ANSI_BOLD "\033[1m" /* For bright color stuff */
#define ANSI_ITALIC "\033[3m" /* Italic text */
#define ANSI_UNDERLINE "\033[4m" /* Underline text */
#define ANSI_BLINK "\033[5m" /* Blinking text */
#define ANSI_REVERSE "\033[7m" /* Reverse colors */
#define ANSI_STRIKEOUT "\033[9m" /* Overstrike line */


Then you can use these colors like this,

printf ( var, "%s this is red text", ANSI_RED);

This is by no means a really elegant way to do things, if you want something better you would need to write your own colour passer, that itterates over text and extracts color coders and then outputs correctly, the way i achieve this is to have my own output functions that do all this for me. That way i can do somethign like this,

MY_printf ( var, "This is <G26> grey text: );

The MY_printf function iterates over the char * removing the <G26> and replacing it with the correct escape sequence.

Edited by The_Fury (see edit history)

Share this post


Link to post
Share on other sites

here is a nice colour parser.

/*	xterm 256 color code parser by Igor van den Hoven	No restrictions on use. 02/11/2009*//*	Use <aaa> to <fff> for RGB foreground colors and for RGB background	colors yse <AAA> to <FFF>.	Use <g00> to <g23> for grayscale foreground colors and <G00> to <G23>	for grayscale background colors.	With xterm256 disabled ASCII colors are emulated.*//*	Syntax:  <xyz>  with x, y, z being parameters	Parameter 'x': ASCII code	0 - Reset all colors and codes to default	1 - Bold	2 - Dim	4 - Underscore	5 - Blink	7 - Reverse	8 - Skip (use previous code)	Parameter 'y':  Foreground color	Parameter 'z':  Background color	0 - Black				5 - Magenta	1 - Red				  6 - Cyan	2 - Green				7 - White	3 - Yellow			   8 - Skip	4 - Blue				 9 - Default*/#include <string.h>#include <stdlib.h>#include <stdio.h>#define BUFFER_SIZE 10000void substitute_color(char *string, char *result, int xterm256){	char buffer[BUFFER_SIZE], *pti, *pto;	int cnt;	pti = string;	pto = string != result ? result : buffer;	while (*pti)	{		switch (*pti)		{			case '<':				if (isdigit(pti[1]) && isdigit(pti[2]) && isdigit(pti[3]) && pti[4] == '>')				{					if (pti[1] != '8' || pti[2] != '8' || pti[3] != '8')					{						*pto++ = '\033';						*pto++ = '[';						switch (pti[1])						{							case '2':								*pto++ = '2';								*pto++ = '2';								*pto++ = ';';								break;							case '8':								break;							default:								*pto++ = pti[1];								*pto++ = ';';						}						switch (pti[2])						{							case '8':								break;							default:								*pto++ = '3';								*pto++ = pti[2];								*pto++ = ';';								break;						}						switch (pti[3])						{							case '8':								break;							default:								*pto++ = '4';								*pto++ = pti[3];								*pto++ = ';';								break;						}						pto--;						*pto++ = 'm';					}					pti += 5;				}				else if (pti[1] >= 'a' && pti[1] <= 'f' && pti[2] >= 'a' && pti[2] <= 'f' && pti[3] >= 'a' && pti[3] <= 'f' && pti[4] == '>')				{					if (xterm256)					{						*pto++ = '\033';						*pto++ = '[';						*pto++ = '3';						*pto++ = '8';						*pto++ = ';';						*pto++ = '5';						*pto++ = ';';						cnt = 16 + (pti[1] - 'a') * 36 + (pti[2] - 'a') * 6 + (pti[3] - 'a');						*pto++ = '0' + cnt / 100;						*pto++ = '0' + cnt % 100 / 10;						*pto++ = '0' + cnt % 10;						*pto++ = 'm';					}					else					{						*pto++ = '\033';						*pto++ = '[';						cnt = pti[1] - 'a' + pti[2] - 'a' + pti[3] - 'a';						*pto++ = '0' + ((pti[1] > 'd' || pti[2] > 'd' || pti[3] > 'd'));						*pto++ = ';';						*pto++ = '3';						*pto++ = '0' + (cnt && pti[1] >= pti[2] ? pti[1] >= pti[3] : 0) + (cnt && pti[2] >= pti[1] ? pti[2] >= pti[3] : 0) * 2 + (cnt && pti[3] >= pti[2] ? pti[3] >= pti[1] : 0) * 4;						*pto++ = 'm';					}					pti += 5;																	}				else if (pti[1] >= 'A' && pti[1] <= 'F' && pti[2] >= 'A' && pti[2] <= 'F' && pti[3] >= 'A' && pti[3] <= 'F' && pti[4] == '>')				{					if (xterm256)					{						*pto++ = '\033';						*pto++ = '[';						*pto++ = '4';						*pto++ = '8';						*pto++ = ';';						*pto++ = '5';						*pto++ = ';';						cnt = 16 + (pti[1] - 'A') * 36 + (pti[2] - 'A') * 6 + (pti[3] - 'A');						*pto++ = '0' + cnt / 100;						*pto++ = '0' + cnt % 100 / 10;						*pto++ = '0' + cnt % 10;						*pto++ = 'm';					}					else					{						*pto++ = '\033';						*pto++ = '[';						cnt = pti[1] - 'A' + pti[2] - 'A' + pti[3] - 'A';						if (pti[1] > 'D' || pti[2] > 'D' || pti[3] > 'D')						{							*pto++ = '1';							*pto++ = '0';						}						else						{							*pto++ = '4';						}						*pto++ = '0' + (cnt && pti[1] >= pti[2] ? pti[1] >= pti[3] : 0) + (cnt && pti[2] >= pti[1] ? pti[2] >= pti[3] : 0) * 2 + (cnt && pti[3] >= pti[2] ? pti[3] >= pti[1] : 0) * 4;						*pto++ = 'm';					}					pti += 5;				}				else if (pti[1] == 'g' && isdigit(pti[2]) && isdigit(pti[3]) && pti[4] == '>')				{					if (xterm256)					{						*pto++ = '\033';						*pto++ = '[';						*pto++ = '3';						*pto++ = '8';						*pto++ = ';';						*pto++ = '5';						*pto++ = ';';						cnt = 232 + (pti[2] - '0') * 10 + (pti[3] - '0');						*pto++ = '0' + cnt / 100;						*pto++ = '0' + cnt % 100 / 10;						*pto++ = '0' + cnt % 10;						*pto++ = 'm';					}					else					{						*pto++ = '\033';						*pto++ = '[';						cnt = (pti[2] - '0') * 10 + (pti[3] - '0');						*pto++ = '0' + (cnt / 6 != 2);						*pto++ = ';';						*pto++ = '3';						*pto++ = '0' + (cnt / 12 ? 7 : 0);						*pto++ = 'm';					}					pti += 5;				}				else if (pti[1] == 'G' && isdigit(pti[2]) && isdigit(pti[3]) && pti[4] == '>')				{					if (xterm256)					{						*pto++ = '\033';						*pto++ = '[';						*pto++ = '4';						*pto++ = '8';						*pto++ = ';';						*pto++ = '5';						*pto++ = ';';						cnt = 232 + (pti[2] - '0') * 10 + (pti[3] - '0');						*pto++ = '0' + cnt / 100;						*pto++ = '0' + cnt % 100 / 10;						*pto++ = '0' + cnt % 10;						*pto++ = 'm';					}					else					{						*pto++ = '\033';						*pto++ = '[';						cnt = (pti[2] - '0') * 10 + (pti[3] - '0');						if (cnt / 6 == 2)						{							*pto++ = '4';						}						else						{							*pto++ = '1';							*pto++ = '0';						}						*pto++ = '0' + (cnt / 12 ? 7 : 0);						*pto++ = 'm';					}					pti += 5;				}				else				{					*pto++ = *pti++;				}				break;			default:				*pto++ = *pti++;				break;		}	}	*pto = 0;	if (string == result)	{		strcpy(result, buffer);	}	return;}/*	Compile for an example display of xterm 256 colors*/int main(int argc, char **argv){	char buf[BUFFER_SIZE], tmp[BUFFER_SIZE], out[BUFFER_SIZE];	int x, y, z;	/*		Foreground	*/	buf[0] = 0;	for (x = 'a'; x <= 'f'; x++)	{		for (y = 'a'; y <= 'f'; y++)		{			for (z = 'a'; z <= 'f'; z++)			{				sprintf(tmp, "<%c%c%c><<880>%c%c%c> ", x, y, z, x, y, z);				strcat(buf, tmp);			}			strcat(buf, "\n");		}	}	substitute_color(buf, out, 1);	printf("%s\n", out);	substitute_color(buf, out, 0);	printf("%s\n", out);	buf[0] = 0;	for (x = 0; x < 24; x++)	{		sprintf(tmp, "<g%02d>%02d<088> ", x, x);		strcat(buf, tmp);	}	substitute_color(buf, out, 1);	printf("%s\n", out);	substitute_color(buf, out, 0);	printf("%s\n", out);	/*		Background	*/	buf[0] = 0;	for (x = 'A'; x <= 'F'; x++)	{		for (y = 'A'; y <= 'F'; y++)		{			for (z = 'A'; z <= 'F'; z++)			{				sprintf(tmp, "<%c%c%c><<878>%c%c%c><880> ", x, y, z, x, y, z);				strcat(buf, tmp);			}			strcat(buf, "\n");		}	}	substitute_color(buf, out, 1);	printf("%s\n", out);	substitute_color(buf, out, 0);	printf("%s\n", out);	buf[0] = 0;	for (x = 0; x < 24; x++)	{		sprintf(tmp, "<G%02d>%02d<088> ", x, x);		strcat(buf, tmp);	}	substitute_color(buf, out, 1);	printf("%s\n", out);	substitute_color(buf, out, 0);	printf("%s\n", out);	return 0;}

Edited by The_Fury (see edit history)

Share this post


Link to post
Share on other sites

I'm trying ask what file it is defined in. E.G.

#include <stdio.h>int main() {printf("Hello");}
In order to printf "Hello", the C linker needs some standards subroutines, which are in the file stdio.h (standard input-output subroutines). #include means "please include in my program the routines in stdio.h, so that each function I will call will be defined in stdio.h

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.