Код:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sysctrl_struct.h>
int main(int argc, char *argv[])
{
char *query, action[3], user[USR_LEN], passwd[PW_LEN];
int qlen, level;
add_user_t account;
if (strcmp(getenv("REQUEST_METHOD"), "POST") != 0) {
printf("Content-Type: text/plain\n\n"
"{\"result\": \"ERROR\","
"\"answer\": \"Can't get request method or "
"request method is't POST!\"}");
return -1;
}
if (0 == (qlen = atoi(getenv("CONTENT_LENGTH")))) {
printf("Content-Type: text/plain\n\n"
"{\"result\": \"ERROR\","
"\"answer\": \"Can't get query string length!\"}");
return -1;
}
query = (char *)calloc(2048, 1);
fgets(query, qlen + 1, stdin);
if (NULL == query) {
printf("Content-Type: text/plain\n\n"
"{\"result\": \"ERROR\","
"\"answer\": \"Can't read query string length %d\"}", qlen);
return -1;
}
if (sscanf(query, "a=%[a-z]&user=%[a-z]&pwd=%[a-z]&level=%1d",
action, user, passwd, &level) != 4)
{
printf("Content-Type: text/plain\n\n"
"{\"result\": \"ERROR\","
"\"answer\": \"Can't parse query string!\n%s\"}", query);
return -1;
}
if (0 == strcmp(action, "add")) {
account.user_id = user; //проблемная строка
//account.password = passwd;
account.authority = level;
}
printf("Content-Type: text/plain\n\n"
"{\"result\": \"OK\", "
"\"answer\": \"Settings OK!\"}");
free(query);
return 0;
}Описание add_user_t из sysctrl_struct.h:
Код: Выделить всё
#define USR_LEN 33
#define PW_LEN 33
typedef struct{
char user_id[USR_LEN];
char password[PW_LEN];
unsigned char authority;
}add_user_t;При компиляции ошибка account.c:80: error: incompatible types in assignment на присваивание account.user_id = user.
Не могу сообразить в чём проблема и как её решить, подскажите?
Спасибо.