Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Help making manipulable variable Post 302754313 by Corona688 on Thursday 10th of January 2013 11:49:56 AM
Old 01-10-2013
An .h file is not a configuration file. It gets read when you run gcc, not when you run the program.

You could have a simple configuration file like this:

Code:
VAR1=VALUE1
VAR2=VALUE2
...

and use it like this:

Code:
char buf[512], var[512], val[512];
FILE *fp=fopen("/path/to/configfile", "r");

setenv("protocols", "PCTP"); // Set a default

while(fgets(buf, 512, fp) != NULL)
{
        if(sscanf(buf, "%[^=]=%s", var, val) != 2) continue;
        setenv(var, val);
}
fclose(fp);

str = g_strdup_printf (
   "rtspsrc protocols=%s latency=LAT "
   " timeout=TIMO  buffer-mode=BUFM location=%s name=src"
   " ! queue ! gstrtpbin latency=LATE name=srcbin "
   " ! queue min-threshold-time=QUE ! rtph264depay ! ffdec_h264"
   " ! interlace top-field-first=true field-pattern=FP"
   " ! videoscale add-borders=true ! videorate"
   " ! colorspace"
   " ! video/x-raw-yuv,framerate=25/1,height=576,width=720,format=(fourcc)UYVY"
   " ! decklinksink name=sink mode= mood "
   " src. ! queue min-threshold-time=QMTT ! rtpmp4adepay !  aacparse ! faad ! audioconvert ! audioresample ! sink. sync=true"
   ,getenv("protocols"), argv[1]);

 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Making a variable equal a pattern

Hi, I would like to assign a pattern to a variable eg test8* or abc etc The problem I have is that when I assign the pattern to the variable, if any files within the current directory match the pattern then the variable will be evaluated to equal the filenames rather than the literal pattern.... (3 Replies)
Discussion started by: Bab00shka
3 Replies

2. Shell Programming and Scripting

Making a Directory

Hi everyone, Im trying to make a new directory based on a name given in a file called directory_file which contains the following content: garbage gargbage Directory: running more garbage gargbage more garbage gargbage more garbage gargbage So basically i have a shell script that... (3 Replies)
Discussion started by: nbvcxzdz
3 Replies

3. UNIX for Dummies Questions & Answers

making a variable as string

I am evaluating a variable from a database and storing it as inside. The value of the variable is alpha numeric.How can i make this a string type.Any functions for the same. (1 Reply)
Discussion started by: dr46014
1 Replies

4. Shell Programming and Scripting

How to define a variable with variable definition is stored in a variable?

Hi all, I have a variable say var1 (output from somewhere, which I can't change)which store something like this: echo $var1 name=fred age=25 address="123 abc" password=pass1234 how can I make the variable $name, $age, $address and $password contain the info? I mean do this in a... (1 Reply)
Discussion started by: freddy1228
1 Replies

5. Shell Programming and Scripting

Making script show command (e.g. copy) being executed and variable substitution?

When script is running you only see when some of the commands are not successfull. Is there a way to see which command are executed and to show the substitution of variables as every line is executed ? (3 Replies)
Discussion started by: gr0124
3 Replies

6. UNIX for Dummies Questions & Answers

Making a function

I am practicing making my own functions in bash for an upcoming exam. For this example, I want to print out a message and maybe add two numbers. What I would do then is: bash-3.2$ function practice { #code to print #code to add } This would be run using an input file, that would... (1 Reply)
Discussion started by: Midwest Product
1 Replies

7. UNIX for Advanced & Expert Users

Regarding help for making own OS

Dear Fellow, I want to make my own OS, Kindly suggest from where i should start. please help me out. (2 Replies)
Discussion started by: zaigham_tt
2 Replies

8. UNIX for Beginners Questions & Answers

Help me making this script

This script is executed whenever a new vehicle is added to the cycle-motor park of campus. The script asks for the following information about the car and adds a new line to the vehicle file.txt: name (name of an animal, unique identifier), color, mark, model, type (e.g., electrical, manual),... (2 Replies)
Discussion started by: andre2222
2 Replies

9. Shell Programming and Scripting

Help with making the output of a command a variable

I'm writing a script that goes something like this: #!/bin/bash zenity --list --checklist --title="Choose Packages to Install" --width="1000" --height="400" \ --column="Select" --column="Package Name" --column="Description" \ GIMP=$( " " GIMP "GIMP is a free and open source photo editor." ... (1 Reply)
Discussion started by: Defunct_Lizard
1 Replies
mouse_x(3alleg4)						  Allegro manual						  mouse_x(3alleg4)

NAME
mouse_x, mouse_y, mouse_z, mouse_w, mouse_b, mouse_pos - Global variable with the mouse position/button state. Allegro game programming library. SYNOPSIS
#include <allegro.h> extern volatile int mouse_x; extern volatile int mouse_y; extern volatile int mouse_z; extern volatile int mouse_w; extern volatile int mouse_b; extern volatile int mouse_pos; DESCRIPTION
Global variables containing the current mouse position and button state. Wherever possible these values will be updated asynchronously, but if mouse_needs_poll() returns TRUE, you must manually call poll_mouse() to update them with the current input state. The `mouse_x' and `mouse_y' positions are integers ranging from zero to the bottom right corner of the screen. The `mouse_z' and `mouse_w' variables hold the current vertical and horizontal wheel position, when using an input driver that supports wheel mice. The `mouse_b' variable is a bitfield indicating the state of each button: bit 0 is the left button, bit 1 the right, and bit 2 the middle button. Additional non standard mouse buttons might be available as higher bits in this variable. Usage example: if (mouse_b & 1) printf("Left button is pressed "); if (!(mouse_b & 2)) printf("Right button is not pressed "); The `mouse_pos' variable has the current X coordinate in the upper 16 bits and the Y in the lower 16 bits. This may be useful in tight polling loops where a mouse interrupt could occur between your reading of the two separate variables, since you can copy this value into a local variable with a single instruction and then split it up at your leisure. Example: int pos, x, y; pos = mouse_pos; x = pos >> 16; y = pos & 0x0000ffff; SEE ALSO
install_mouse(3alleg4), poll_mouse(3alleg4), mouse_needs_poll(3alleg4), exalpha(3alleg4), exlights(3alleg4), exmouse(3alleg4), exshade(3alleg4), exspline(3alleg4), extrans(3alleg4) Allegro version 4.4.2 mouse_x(3alleg4)
All times are GMT -4. The time now is 04:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy