CLIP_DLLEXPORT int _clip_put_env(char *name, char *val) { int l1 = strlen(name); int l2 = strlen(val); int r; #ifdef OS_MINGW char *buf = (char *) malloc(l1 + l2 + 2); #else char *buf = (char *) alloca(l1 + l2 + 2); #endif memcpy(buf, name, l1); memcpy(buf + l1 + 1, val, l2); buf[l1] = '='; buf[l1 + l2 + 1] = 0; r = put_env(&_clip_envp, buf); #ifdef OS_MINGW free(buf); #endif return r; }
int Platform_call_named_feature(char *funcname) { switch (funcname[0]) { case 'y': if (strcmp(funcname,"yield")==0) { yield(); return 0; } break; case 'P': if (strcmp(funcname,"PokerGame")==0) { //PokerGame(); return 0; } if (strcmp(funcname,"PollSleepSemaphore")==0) { // Grab and release the sleep semaphore. // If the UI thread is trying to put the terminal to sleep, these calls will hang until the sleep has ended. sem_wait(&SleepSemaphore); // Once the semaphore is acquired, immediately give it back up. sem_post(&SleepSemaphore); } break; case 'R': // ResetSMDL is accessed at the password menu, and applies to Verix only. // When set, it opens up the clock to be downloaded or controlled via COM1 immediately upon reboot. // This is basically a backdoor. It can be used to reload programming if (strcmp(funcname,"ResetSMDL")==0) { ClearLCDScreen(); printfLCD("SMDL has been set.\r\n" "%s to reboot now.\r\n" "%s to return to clock app.", LCDCancelKey, LCDEnterKey); put_env("*SMDL","1",1); // ShowPressEnterOrCancel(); // if (GetEnterOrCancel() == FALSE) SVC_RESTART(""); return 0; } break; case 'K': if (strcmp(funcname,"Keyclick")==0) { Platform_normal_tone(); return 0; } } return -1; }
int main(void) { char name[MAX], neu_wert[MAX]; printf("Umgebungsvariable: "); scanf("%254s", name); printf("Wert : %s\n", getenv(name)); printf("Wert aendern/setzen: "); scanf("%254s", neu_wert); if (put_env(name, neu_wert) != 0) { printf("Konnte neuen Wert nicht setzen\n"); } printf("Neuer Wert (%s): %s\n", name, getenv(name)); return EXIT_SUCCESS; }
// #include <stdio.h> void check_cmd(t_env *e) { char **str; int i; //printf("\t\tReceived command\n"); i = 0; //str = ft_split(line); // ft_memcpy(e->line, line, _POSIX2_LINE_MAX); // e->len = sizeof(line) - 1; // launch_interprete(e); str = e->argv; put_env(e); if (str[0] && ft_strcmp(str[0], "setenv") == 0) { while(str[i]) i++; if (i == 3) ft_set(e->list, str[1], str[2]); else if(i == 2) ft_set(e->list, str[1], "\0"); else if(i > 3) ft_putstr_fd("setenv: Too many arguments.\n", 2); else print_env(e->env); } else if (str[0] && ft_strcmp(str[0], "unsetenv") == 0) { if (str[1]) ft_unset(e->list, str); else ft_putstr_fd("unsetenv: Too few arguments.\n", 2); } else check_cmd2(str, e); // if (str) // ft_free_tab(&str); }
int Platform_set_startup_program(char *filename) { return put_env("*GO",filename,strlen(filename)); }
void SetVariable(const string& key, const string& value) { put_env(key.c_str(), value.c_str(), value.length()); }