cscg24-guacamole

CSCG 2024 Challenge 'Guacamole Mashup'
git clone https://git.sinitax.com/sinitax/cscg24-guacamole
Log | Files | Refs | sfeed.txt

argv.c (1747B)


      1/*
      2 * Licensed to the Apache Software Foundation (ASF) under one
      3 * or more contributor license agreements.  See the NOTICE file
      4 * distributed with this work for additional information
      5 * regarding copyright ownership.  The ASF licenses this file
      6 * to you under the Apache License, Version 2.0 (the
      7 * "License"); you may not use this file except in compliance
      8 * with the License.  You may obtain a copy of the License at
      9 *
     10 *   http://www.apache.org/licenses/LICENSE-2.0
     11 *
     12 * Unless required by applicable law or agreed to in writing,
     13 * software distributed under the License is distributed on an
     14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     15 * KIND, either express or implied.  See the License for the
     16 * specific language governing permissions and limitations
     17 * under the License.
     18 */
     19
     20#include "config.h"
     21#include "argv.h"
     22#include "vnc.h"
     23
     24#include <guacamole/mem.h>
     25#include <guacamole/protocol.h>
     26#include <guacamole/socket.h>
     27#include <guacamole/string.h>
     28#include <guacamole/user.h>
     29
     30#include <pthread.h>
     31#include <stdlib.h>
     32#include <string.h>
     33
     34int guac_vnc_argv_callback(guac_user* user, const char* mimetype,
     35        const char* name, const char* value, void* data) {
     36
     37    guac_client* client = user->client;
     38    guac_vnc_client* vnc_client = (guac_vnc_client*) client->data;
     39    guac_vnc_settings* settings = vnc_client->settings;
     40
     41    /* Update username */
     42    if (strcmp(name, GUAC_VNC_ARGV_USERNAME) == 0) {
     43        guac_mem_free(settings->username);
     44        settings->username = guac_strdup(value);
     45    }
     46    
     47    /* Update password */
     48    else if (strcmp(name, GUAC_VNC_ARGV_PASSWORD) == 0) {
     49        guac_mem_free(settings->password);
     50        settings->password = guac_strdup(value);
     51    }
     52
     53    return 0;
     54
     55}